MCPcopy Create free account
hub / github.com/atomicdotdev/atomic / run_shim_review

Function run_shim_review

atomic-cli/src/commands/git/hooks.rs:1191–1421  ·  view source on GitHub ↗

CB-9B: `atomic git shim review` — surface squash/rewrite candidates, merge resolutions, and empty-commit interpretations with the evidence that links them to Git operations, stating each evidence class's exact identity limit (RFC §5.4).

(root: &Path, view: Option<&str>)

Source from the content-addressed store, hash-verified

1189/// that links them to Git operations, stating each evidence class's exact
1190/// identity limit (RFC §5.4).
1191pub(crate) fn run_shim_review(root: &Path, view: Option<&str>) -> CliResult<()> {
1192 let root = canonical_root(root)?;
1193 let repo = atomic_repository::Repository::open(&root)
1194 .map_err(|error| git_error(format!("cannot open the Atomic repository: {error}")))?;
1195 let view_name = match view {
1196 Some(view) => view.to_string(),
1197 None => repo.current_view().to_string(),
1198 };
1199 if !repo
1200 .view_exists(&view_name)
1201 .map_err(|error| git_error(format!("cannot inspect views: {error}")))?
1202 {
1203 return Err(git_error(format!("view '{view_name}' does not exist")));
1204 }
1205
1206 // Imported interpretations, straight from hash-authoritative change bytes.
1207 let entries = repo
1208 .effective_history(Some(&view_name))
1209 .map_err(|error| git_error(format!("cannot read view history: {error}")))?;
1210 let mut merges = 0usize;
1211 let mut squashes = 0usize;
1212 let mut empty_commits = 0usize;
1213 let mut candidates: Vec<String> = Vec::new();
1214 for entry in &entries {
1215 let change = repo
1216 .load_change(&entry.hash)
1217 .map_err(|error| git_error(format!("cannot load change {}: {error}", entry.hash)))?;
1218 let sha = change
1219 .unhashed
1220 .as_ref()
1221 .and_then(|value| value.get("git"))
1222 .and_then(|git| git.get("sha"))
1223 .and_then(|sha| sha.as_str())
1224 .unwrap_or("?")
1225 .to_string();
1226 match change.origin() {
1227 atomic_core::change::ChangeOrigin::GitResolution { parents, .. } => {
1228 merges += 1;
1229 candidates.push(format!(
1230 "merge-resolution {} parents={} — verified causal frontier covers every parent closure",
1231 short(&sha),
1232 parents.len()
1233 ));
1234 }
1235 atomic_core::change::ChangeOrigin::GitSynthesized {
1236 commit, derivation, ..
1237 } => match derivation {
1238 atomic_core::change::GitDerivation::Squash => {
1239 squashes += 1;
1240 candidates.push(format!(
1241 "squash/rewrite candidate {} ({}) — synthesized interpretation; identity requires a verified predecessor binding or explicit review",
1242 short(&sha),
1243 oid_hex(commit.as_bytes()),
1244 ));
1245 }
1246 atomic_core::change::GitDerivation::EmptyCommit => {
1247 empty_commits += 1;
1248 candidates.push(format!(

Callers 1

runMethod · 0.85

Calls 15

canonical_rootFunction · 0.85
openFunction · 0.85
view_existsMethod · 0.80
effective_historyMethod · 0.80
as_refMethod · 0.80
originMethod · 0.80
list_tags_for_viewMethod · 0.80
git_errorFunction · 0.70
getMethod · 0.65
current_viewMethod · 0.45
load_changeMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected