Scan the advisory post-rewrite journal for records that link this commit by its exact full OID. Returns `(predecessors, event_ids, untrusted_count, unauthenticated_count)`. A record counts as operation linkage only when ALL of the following hold (review R4 + F5 + B3 + C2): - it matches the advisory interpretation contract (record type, advisory flag, verbatim identity-limit string) and carries fu
(
&self,
repo: &Repository,
sha: &str,
)
| 7904 | /// (review C2; immutable storage authenticates persistence, not the |
| 7905 | /// external event's truth). |
| 7906 | fn captured_post_rewrite_linkage( |
| 7907 | &self, |
| 7908 | repo: &Repository, |
| 7909 | sha: &str, |
| 7910 | ) -> Option<(Vec<String>, Vec<String>, usize, usize)> { |
| 7911 | use std::io::BufRead; |
| 7912 | let journal = repo.root().join(".atomic/bridge/git-events.jsonl"); |
| 7913 | let file = std::fs::File::open(journal).ok()?; |
| 7914 | let reader = std::io::BufReader::new(file); |
| 7915 | let mut predecessors = Vec::new(); |
| 7916 | let mut event_ids = Vec::new(); |
| 7917 | let mut untrusted = 0usize; |
| 7918 | let mut unauthenticated = 0usize; |
| 7919 | for line in reader.lines() { |
| 7920 | let Ok(line) = line else { |
| 7921 | continue; |
| 7922 | }; |
| 7923 | let Ok(record) = serde_json::from_str::<serde_json::Value>(&line) else { |
| 7924 | untrusted += 1; |
| 7925 | continue; |
| 7926 | }; |
| 7927 | if record.get("record_type").and_then(|v| v.as_str()) != Some("post-rewrite") { |
| 7928 | continue; |
| 7929 | } |
| 7930 | // An advisory record must carry the advisory flag and the exact |
| 7931 | // identity-limit interpretation it was journaled with; anything |
| 7932 | // else is arbitrary journal text, not captured-operation proof. |
| 7933 | if record.get("advisory").and_then(|v| v.as_bool()) != Some(true) |
| 7934 | || record.get("interpretation").and_then(|v| v.as_str()) |
| 7935 | != Some(super::hooks::REWRITE_INTERPRETATION) |
| 7936 | { |
| 7937 | untrusted += 1; |
| 7938 | continue; |
| 7939 | } |
| 7940 | let Some(pairs) = record.get("rewritten").and_then(|v| v.as_array()) else { |
| 7941 | untrusted += 1; |
| 7942 | continue; |
| 7943 | }; |
| 7944 | let event_id = record |
| 7945 | .get("event_id") |
| 7946 | .and_then(|v| v.as_str()) |
| 7947 | .unwrap_or_default() |
| 7948 | .to_string(); |
| 7949 | let mut matched_oids = Vec::new(); |
| 7950 | for pair in pairs { |
| 7951 | let new_oid = pair |
| 7952 | .get("new_oid") |
| 7953 | .and_then(|v| v.as_str()) |
| 7954 | .unwrap_or_default(); |
| 7955 | let old_oid = pair |
| 7956 | .get("old_oid") |
| 7957 | .and_then(|v| v.as_str()) |
| 7958 | .unwrap_or_default(); |
| 7959 | // Full-length hex OIDs only, and exact equality on the new |
| 7960 | // OID — an empty, partial, or prefixed value is never a |
| 7961 | // match (review blocker 4). |
| 7962 | if !is_full_oid(new_oid) || !is_full_oid(old_oid) { |
| 7963 | untrusted += 1; |
no test coverage detected