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

Function verify_at

atomic-cli/src/commands/git/shim.rs:2644–2695  ·  view source on GitHub ↗
(root: &Path)

Source from the content-addressed store, hash-verified

2642
2643#[tracing::instrument(name = "verify", skip_all)]
2644fn verify_at(root: &Path) -> CliResult<ShimSnapshot> {
2645 // CB-13A R2: the same read-only diagnostic boundary as `verify` — the
2646 // repository is observed for operation inspection without recovery.
2647 let repo = Repository::open_readonly_for_operation_inspection(root).map_err(CliError::from)?;
2648 let working_copy = repo.require_working_copy_id().map_err(CliError::from)?;
2649 let git = open_git(root)?;
2650 // CB-13A R2: an incomplete or diverged operation head may never pass
2651 // the inspection helper when the writable path would recover or gate
2652 // on it — the operations-head verdict is a hard gate here too.
2653 let (_, heads_ok, heads_detail) = operation_layer_verdict(&repo, working_copy);
2654 if !heads_ok {
2655 return Err(git_error(format!(
2656 "operation journal heads are incomplete or diverged; run recovery first: {heads_detail}"
2657 )));
2658 }
2659 let (branch, head, tree) = workspace_head_aligned(&repo, working_copy, &git)?;
2660 require_clean_git_worktree(&git)?;
2661 let atomic_status = repo
2662 .status(working_copy, StatusOptions::default())
2663 .map_err(CliError::from)?;
2664 // CB-13C review R1: status itself never writes telemetry. This helper
2665 // runs only inside explicit shim command flows (reconcile/switch/
2666 // import/publish), so it is the authorized sink boundary that records
2667 // the degradation the status metrics just returned — consent-gated via
2668 // `for_repository`.
2669 if let Some(metrics) = atomic_status.change_source_metrics() {
2670 if metrics.fallback_count > 0 {
2671 emit_change_source_fallback(
2672 &repo,
2673 metrics.source,
2674 metrics.fallback_source,
2675 metrics.fallback_reason.as_ref(),
2676 );
2677 }
2678 }
2679 if !atomic_status.is_clean() {
2680 return Err(git_error("Atomic working copy is not clean"));
2681 }
2682 verify_complete_equivalence(&repo, &branch, root, &git, "Git shim verification")?;
2683 let atomic_state = repo
2684 .get_view_info(&branch)
2685 .map_err(CliError::from)?
2686 .state
2687 .to_string();
2688
2689 Ok(ShimSnapshot {
2690 view: branch,
2691 atomic_state,
2692 git_head: head.to_string(),
2693 git_tree: tree.to_string(),
2694 })
2695}
2696
2697/// Verify a workspace whose HEAD may be detached (RFC §7.5, CB-8A Draft
2698/// policy): an attached HEAD follows the branch rule; a detached HEAD aligns

Callers 5

switch_transactionFunction · 0.85
verify_at_detached_okFunction · 0.85

Calls 13

operation_layer_verdictFunction · 0.85
workspace_head_alignedFunction · 0.85
change_source_metricsMethod · 0.80
as_refMethod · 0.80
get_view_infoMethod · 0.80
open_gitFunction · 0.70
git_errorFunction · 0.70
statusMethod · 0.45

Tested by

no test coverage detected