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

Function operation_layer_verdict

atomic-cli/src/commands/git/shim.rs:2326–2416  ·  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

2324/// completing an operation. The verdict fails with actionable guidance; it
2325/// never performs the recovery itself.
2326fn operation_layer_verdict(
2327 repo: &Repository,
2328 working_copy: atomic_core::types::WorkingCopyId,
2329) -> (&'static str, bool, String) {
2330 use atomic_core::operation::OperationScope;
2331 use atomic_repository::OperationVerificationState;
2332 let describe = |scope: OperationScope| -> Result<String, String> {
2333 let log = repo
2334 .operation_log(scope, None, false)
2335 .map_err(|error| error.to_string())?;
2336 match &log.head_state {
2337 atomic_repository::OperationHeadState::Empty => Ok(String::new()),
2338 atomic_repository::OperationHeadState::Single(head) => {
2339 let incomplete: Vec<String> = log
2340 .entries
2341 .iter()
2342 .filter(|entry| {
2343 entry.is_head && entry.verification != OperationVerificationState::Verified
2344 })
2345 .map(|entry| format!("{} ({:?})", entry.operation.id(), entry.verification))
2346 .collect();
2347 if incomplete.is_empty() {
2348 Ok(String::new())
2349 } else {
2350 Err(format!(
2351 "operation head is incomplete and requires recovery: {}",
2352 incomplete.join(", ")
2353 ))
2354 }
2355 }
2356 atomic_repository::OperationHeadState::Diverged(heads) => Err(format!(
2357 "operation heads are diverged and require consolidation: {}",
2358 heads
2359 .iter()
2360 .map(ToString::to_string)
2361 .collect::<Vec<_>>()
2362 .join(", ")
2363 )),
2364 }
2365 };
2366 let mut divergences = Vec::new();
2367 match describe(OperationScope::Repository) {
2368 Ok(detail) if detail.is_empty() => {}
2369 Ok(detail) | Err(detail) => divergences.push(format!("repository scope: {detail}")),
2370 }
2371 match describe(OperationScope::WorkingCopy(working_copy)) {
2372 Ok(detail) if detail.is_empty() => {}
2373 Ok(detail) | Err(detail) => divergences.push(format!("working-copy scope: {detail}")),
2374 }
2375 // CB-13A follow-up R2: incomplete heads are enumerated across ALL
2376 // working-copy scopes, not just the repository and the inspecting
2377 // working copy — another linked worktree's interrupted operation is
2378 // exactly the head the writable path would gate on.
2379 let all_scopes = repo
2380 .pristine()
2381 .read_txn()
2382 .and_then(|txn| {
2383 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