The corpus identity: every logical state layer the AC-2 text names. Binding ref NAMES embed repository-specific ids, so the corpus compares the sorted set of binding ref TARGETS (deterministic commit OIDs) plus the ref classes; working-copy records (pointer + current view) and the repository manifest roots are compared verbatim.
(fixture: &WatchFixture)
| 1136 | /// the ref classes; working-copy records (pointer + current view) and the |
| 1137 | /// repository manifest roots are compared verbatim. |
| 1138 | fn corpus_identity(fixture: &WatchFixture) -> String { |
| 1139 | let mut identity = String::new(); |
| 1140 | // Views: the checkpoint's state-shape fields (incl. manifest roots). |
| 1141 | let checkpoint = fs::read_to_string(fixture.root().join(".atomic/bridge/workspace.json")) |
| 1142 | .expect("checkpoint"); |
| 1143 | for line in checkpoint.lines() { |
| 1144 | let trimmed = line.trim(); |
| 1145 | for key in [ |
| 1146 | "\"version\"", |
| 1147 | "\"view\"", |
| 1148 | "\"kind\"", |
| 1149 | "\"git_tree\"", |
| 1150 | "\"git_index_tree\"", |
| 1151 | "\"git_index_digest\"", |
| 1152 | "\"atomic_manifest_root\"", |
| 1153 | "\"git_manifest_root\"", |
| 1154 | ] { |
| 1155 | if trimmed.starts_with(key) { |
| 1156 | identity.push_str(trimmed); |
| 1157 | identity.push('\n'); |
| 1158 | } |
| 1159 | } |
| 1160 | if trimmed.starts_with("\"value\"") { |
| 1161 | identity.push_str(trimmed); |
| 1162 | identity.push('\n'); |
| 1163 | } |
| 1164 | } |
| 1165 | // Git refs: non-binding targets verbatim (deterministic), binding |
| 1166 | // refs by COUNT — binding names AND targets carry per-repository |
| 1167 | // entropy (fresh ids/ULIDs); their cryptographic verification is |
| 1168 | // covered by the verify layer below. |
| 1169 | let refs = fixture.git(&["for-each-ref", "--format=%(refname) %(objectname)"]); |
| 1170 | let mut binding_count = 0usize; |
| 1171 | identity.push_str("refs:\n"); |
| 1172 | for line in refs.lines() { |
| 1173 | let (refname, _target) = line.split_once(' ').unwrap_or((line, "")); |
| 1174 | if refname.starts_with("refs/atomic/bindings/") { |
| 1175 | binding_count += 1; |
| 1176 | } else { |
| 1177 | identity.push_str(line); |
| 1178 | identity.push('\n'); |
| 1179 | } |
| 1180 | } |
| 1181 | identity.push_str(&format!("binding-refs: {binding_count}\n")); |
| 1182 | // Working-copy records: the current-view file. The working-copy ULID |
| 1183 | // itself is per-repository by construction and excluded. |
| 1184 | let current_view = |
| 1185 | fs::read_to_string(fixture.root().join(".atomic/current_view")).unwrap_or_default(); |
| 1186 | identity.push_str(&format!("current_view: {}\n", current_view.trim())); |
| 1187 | // Verified layers (base32-normalized) + physical bytes + change count. |
| 1188 | let verify = fixture.atomic(&["git", "shim", "verify"]); |
| 1189 | identity.push_str(&format!("verify:\n{}\n", normalize_base32(&verify))); |
| 1190 | identity.push_str(&format!("worktree:\n{}\n", fixture.worktree_snapshot())); |
| 1191 | let changes = fs::read_dir(fixture.root().join(".atomic/changes")) |
| 1192 | .map(|dirs| { |
| 1193 | dirs.flatten() |
| 1194 | .filter_map(|d| fs::read_dir(d.path()).ok()) |
| 1195 | .flatten() |