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

Function classify_guard

atomic-cli/src/commands/git/guard.rs:527–723  ·  view source on GitHub ↗

Pure causal-baseline classifier used by every future command boundary.

(
    operation: GuardOperation,
    checkpoint: Option<&ShimCheckpoint>,
    current: &GuardEvidence,
)

Source from the content-addressed store, hash-verified

525
526/// Pure causal-baseline classifier used by every future command boundary.
527pub(crate) fn classify_guard(
528 operation: GuardOperation,
529 checkpoint: Option<&ShimCheckpoint>,
530 current: &GuardEvidence,
531) -> GuardOutcome {
532 if operation.is_bypass() {
533 return GuardOutcome::Pass(Box::new(GuardPass {
534 operation,
535 reason: GuardPassReason::Bypass,
536 old: None,
537 current: None,
538 }));
539 }
540
541 let GuardGitEvidence::Repository(current_git) = &current.git else {
542 return GuardOutcome::Pass(Box::new(GuardPass {
543 operation,
544 reason: GuardPassReason::NoGit,
545 old: None,
546 current: Some(current.clone()),
547 }));
548 };
549 let old = checkpoint.map(checkpoint_evidence);
550
551 match &current_git.head {
552 GitHeadEvidence::Detached { .. } => {
553 return refuse(
554 operation,
555 GuardRefusalReason::DetachedHead,
556 vec![DriftField::GitHeadState],
557 old,
558 current,
559 );
560 }
561 GitHeadEvidence::Unborn { .. } => {
562 return refuse(
563 operation,
564 GuardRefusalReason::UnbornHead,
565 vec![DriftField::GitHeadState],
566 old,
567 current,
568 );
569 }
570 GitHeadEvidence::MissingTarget { .. } => {
571 return refuse(
572 operation,
573 GuardRefusalReason::MissingHeadTarget,
574 vec![DriftField::GitHeadState],
575 old,
576 current,
577 );
578 }
579 GitHeadEvidence::Unknown { .. } => {
580 return refuse(
581 operation,
582 GuardRefusalReason::MissingHeadTarget,
583 vec![DriftField::GitHeadState],
584 old,

Calls 10

refuseFunction · 0.85
checkpoint_evidenceFunction · 0.85
is_bypassMethod · 0.80
is_noneMethod · 0.80
sortMethod · 0.80
cloneMethod · 0.45
is_emptyMethod · 0.45
symrefMethod · 0.45
pushMethod · 0.45
oidMethod · 0.45