Pure causal-baseline classifier used by every future command boundary.
(
operation: GuardOperation,
checkpoint: Option<&ShimCheckpoint>,
current: &GuardEvidence,
)
| 525 | |
| 526 | /// Pure causal-baseline classifier used by every future command boundary. |
| 527 | pub(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) = ¤t.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 ¤t_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, |