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

Function run_shim_review

atomic-cli/src/commands/git/hooks.rs:1222–1452  ·  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

1220/// that links them to Git operations, stating each evidence class's exact
1221/// identity limit (RFC §5.4).
1222pub(crate) fn run_shim_review(root: &Path, view: Option<&str>) -> CliResult<()> {
1223 let root = canonical_root(root)?;
1224 let repo = atomic_repository::Repository::open(&root)
1225 .map_err(|error| git_error(format!("cannot open the Atomic repository: {error}")))?;
1226 let view_name = match view {
1227 Some(view) => view.to_string(),
1228 None => repo.current_view().to_string(),
1229 };
1230 if !repo
1231 .view_exists(&view_name)
1232 .map_err(|error| git_error(format!("cannot inspect views: {error}")))?
1233 {
1234 return Err(git_error(format!("view '{view_name}' does not exist")));
1235 }
1236
1237 // Imported interpretations, straight from hash-authoritative change bytes.
1238 let entries = repo
1239 .effective_history(Some(&view_name))
1240 .map_err(|error| git_error(format!("cannot read view history: {error}")))?;
1241 let mut merges = 0usize;
1242 let mut squashes = 0usize;
1243 let mut empty_commits = 0usize;
1244 let mut candidates: Vec<String> = Vec::new();
1245 for entry in &entries {
1246 let change = repo
1247 .load_change(&entry.hash)
1248 .map_err(|error| git_error(format!("cannot load change {}: {error}", entry.hash)))?;
1249 let sha = change
1250 .unhashed
1251 .as_ref()
1252 .and_then(|value| value.get("git"))
1253 .and_then(|git| git.get("sha"))
1254 .and_then(|sha| sha.as_str())
1255 .unwrap_or("?")
1256 .to_string();
1257 match change.origin() {
1258 atomic_core::change::ChangeOrigin::GitResolution { parents, .. } => {
1259 merges += 1;
1260 candidates.push(format!(
1261 "merge-resolution {} parents={} — verified causal frontier covers every parent closure",
1262 short(&sha),
1263 parents.len()
1264 ));
1265 }
1266 atomic_core::change::ChangeOrigin::GitSynthesized {
1267 commit, derivation, ..
1268 } => match derivation {
1269 atomic_core::change::GitDerivation::Squash => {
1270 squashes += 1;
1271 candidates.push(format!(
1272 "squash/rewrite candidate {} ({}) — synthesized interpretation; identity requires a verified predecessor binding or explicit review",
1273 short(&sha),
1274 oid_hex(commit.as_bytes()),
1275 ));
1276 }
1277 atomic_core::change::GitDerivation::EmptyCommit => {
1278 empty_commits += 1;
1279 candidates.push(format!(

Callers 1

runMethod · 0.85

Calls 15

canonical_rootFunction · 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
openFunction · 0.50
current_viewMethod · 0.45
load_changeMethod · 0.45
as_strMethod · 0.45

Tested by

no test coverage detected