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

Function operation_layer_verdict

atomic-cli/src/commands/git/shim.rs:2282–2372  ·  view source on GitHub ↗

CB-13A R2: the operations-head layer of `shim verify`, collected read-only through the public operation log. A repository-scope or working-copy-scope head that is diverged, or whose head operation has no verified receipt yet, means the repository is still completing an operation. The verdict fails with actionable guidance; it never performs the recovery itself.

(
    repo: &Repository,
    working_copy: atomic_core::types::WorkingCopyId,
)

Source from the content-addressed store, hash-verified

2280/// completing an operation. The verdict fails with actionable guidance; it
2281/// never performs the recovery itself.
2282fn operation_layer_verdict(
2283 repo: &Repository,
2284 working_copy: atomic_core::types::WorkingCopyId,
2285) -> (&'static str, bool, String) {
2286 use atomic_core::operation::OperationScope;
2287 use atomic_repository::OperationVerificationState;
2288 let describe = |scope: OperationScope| -> Result<String, String> {
2289 let log = repo
2290 .operation_log(scope, None, false)
2291 .map_err(|error| error.to_string())?;
2292 match &log.head_state {
2293 atomic_repository::OperationHeadState::Empty => Ok(String::new()),
2294 atomic_repository::OperationHeadState::Single(head) => {
2295 let incomplete: Vec<String> = log
2296 .entries
2297 .iter()
2298 .filter(|entry| {
2299 entry.is_head && entry.verification != OperationVerificationState::Verified
2300 })
2301 .map(|entry| format!("{} ({:?})", entry.operation.id(), entry.verification))
2302 .collect();
2303 if incomplete.is_empty() {
2304 Ok(String::new())
2305 } else {
2306 Err(format!(
2307 "operation head is incomplete and requires recovery: {}",
2308 incomplete.join(", ")
2309 ))
2310 }
2311 }
2312 atomic_repository::OperationHeadState::Diverged(heads) => Err(format!(
2313 "operation heads are diverged and require consolidation: {}",
2314 heads
2315 .iter()
2316 .map(ToString::to_string)
2317 .collect::<Vec<_>>()
2318 .join(", ")
2319 )),
2320 }
2321 };
2322 let mut divergences = Vec::new();
2323 match describe(OperationScope::Repository) {
2324 Ok(detail) if detail.is_empty() => {}
2325 Ok(detail) | Err(detail) => divergences.push(format!("repository scope: {detail}")),
2326 }
2327 match describe(OperationScope::WorkingCopy(working_copy)) {
2328 Ok(detail) if detail.is_empty() => {}
2329 Ok(detail) | Err(detail) => divergences.push(format!("working-copy scope: {detail}")),
2330 }
2331 // CB-13A follow-up R2: incomplete heads are enumerated across ALL
2332 // working-copy scopes, not just the repository and the inspecting
2333 // working copy — another linked worktree's interrupted operation is
2334 // exactly the head the writable path would gate on.
2335 let all_scopes = repo
2336 .pristine()
2337 .read_txn()
2338 .and_then(|txn| {
2339 atomic_core::pristine::WorkingCopyTxnT::list_working_copies(&txn).map(|records| {

Callers 2

verifyFunction · 0.85
verify_atFunction · 0.85

Calls 9

WorkingCopyInterface · 0.85
operation_logMethod · 0.80
read_txnMethod · 0.80
pristineMethod · 0.80
collectMethod · 0.45
iterMethod · 0.45
is_emptyMethod · 0.45
pushMethod · 0.45
into_iterMethod · 0.45

Tested by

no test coverage detected