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

Function verify_at

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

Source from the content-addressed store, hash-verified

2598
2599#[tracing::instrument(name = "verify", skip_all)]
2600fn verify_at(root: &Path) -> CliResult<ShimSnapshot> {
2601 // CB-13A R2: the same read-only diagnostic boundary as `verify` — the
2602 // repository is observed for operation inspection without recovery.
2603 let repo = Repository::open_readonly_for_operation_inspection(root).map_err(CliError::from)?;
2604 let working_copy = repo.require_working_copy_id().map_err(CliError::from)?;
2605 let git = open_git(root)?;
2606 // CB-13A R2: an incomplete or diverged operation head may never pass
2607 // the inspection helper when the writable path would recover or gate
2608 // on it — the operations-head verdict is a hard gate here too.
2609 let (_, heads_ok, heads_detail) = operation_layer_verdict(&repo, working_copy);
2610 if !heads_ok {
2611 return Err(git_error(format!(
2612 "operation journal heads are incomplete or diverged; run recovery first: {heads_detail}"
2613 )));
2614 }
2615 let (branch, head, tree) = workspace_head_aligned(&repo, working_copy, &git)?;
2616 require_clean_git_worktree(&git)?;
2617 let atomic_status = repo
2618 .status(working_copy, StatusOptions::default())
2619 .map_err(CliError::from)?;
2620 // CB-13C review R1: status itself never writes telemetry. This helper
2621 // runs only inside explicit shim command flows (reconcile/switch/
2622 // import/publish), so it is the authorized sink boundary that records
2623 // the degradation the status metrics just returned — consent-gated via
2624 // `for_repository`.
2625 if let Some(metrics) = atomic_status.change_source_metrics() {
2626 if metrics.fallback_count > 0 {
2627 emit_change_source_fallback(
2628 &repo,
2629 metrics.source,
2630 metrics.fallback_source,
2631 metrics.fallback_reason.as_ref(),
2632 );
2633 }
2634 }
2635 if !atomic_status.is_clean() {
2636 return Err(git_error("Atomic working copy is not clean"));
2637 }
2638 verify_complete_equivalence(&repo, &branch, root, &git, "Git shim verification")?;
2639 let atomic_state = repo
2640 .get_view_info(&branch)
2641 .map_err(CliError::from)?
2642 .state
2643 .to_string();
2644
2645 Ok(ShimSnapshot {
2646 view: branch,
2647 atomic_state,
2648 git_head: head.to_string(),
2649 git_tree: tree.to_string(),
2650 })
2651}
2652
2653/// Verify a workspace whose HEAD may be detached (RFC §7.5, CB-8A Draft
2654/// 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