(
reason: GuardRefusalReason,
old: Option<&GuardEvidence>,
current: &GuardEvidence,
)
| 848 | } |
| 849 | |
| 850 | fn remediation( |
| 851 | reason: GuardRefusalReason, |
| 852 | old: Option<&GuardEvidence>, |
| 853 | current: &GuardEvidence, |
| 854 | ) -> GuardRemediation { |
| 855 | let forensic = "atomic status --no-reconcile".to_string(); |
| 856 | let reconcile = "atomic git shim reconcile".to_string(); |
| 857 | match reason { |
| 858 | GuardRefusalReason::CheckpointMissing | GuardRefusalReason::StaleGitBaseline => { |
| 859 | GuardRemediation { |
| 860 | summary: "Reconcile the observed Git baseline before retrying the refused operation." |
| 861 | .to_string(), |
| 862 | commands: vec![forensic, reconcile], |
| 863 | } |
| 864 | } |
| 865 | GuardRefusalReason::Diverged => GuardRemediation { |
| 866 | summary: "No automatic authority choice is safe. Inspect both preserved histories, choose the intended side explicitly, and only then reconcile." |
| 867 | .to_string(), |
| 868 | commands: vec![forensic], |
| 869 | }, |
| 870 | GuardRefusalReason::DetachedHead => { |
| 871 | let mut commands = vec![forensic]; |
| 872 | if let Some(branch) = checkpoint_branch(old) { |
| 873 | commands.push(format!("git switch {branch}")); |
| 874 | commands.push(reconcile); |
| 875 | } |
| 876 | GuardRemediation { |
| 877 | summary: "Return Git to the checkpoint's attached branch, then reconcile." |
| 878 | .to_string(), |
| 879 | commands, |
| 880 | } |
| 881 | } |
| 882 | GuardRefusalReason::UnbornHead => GuardRemediation { |
| 883 | summary: "Create the repository's initial Git commit, then establish a shim checkpoint." |
| 884 | .to_string(), |
| 885 | commands: vec![forensic, "git status".to_string(), reconcile], |
| 886 | }, |
| 887 | GuardRefusalReason::MissingHeadTarget => { |
| 888 | let mut commands = vec![forensic]; |
| 889 | if let (Some(branch), Some(oid)) = (checkpoint_branch(old), checkpoint_oid(old)) { |
| 890 | commands.push(format!("git branch --force {branch} {oid}")); |
| 891 | commands.push(format!("git switch {branch}")); |
| 892 | commands.push(reconcile); |
| 893 | } |
| 894 | GuardRemediation { |
| 895 | summary: "Restore the missing branch target from the recorded checkpoint, then reconcile." |
| 896 | .to_string(), |
| 897 | commands, |
| 898 | } |
| 899 | } |
| 900 | GuardRefusalReason::IndexLocked | GuardRefusalReason::RefLocked => GuardRemediation { |
| 901 | summary: "Wait for the active Git process to finish; do not remove a live lock. Re-observe before retrying." |
| 902 | .to_string(), |
| 903 | commands: vec!["git status".to_string(), forensic], |
| 904 | }, |
| 905 | GuardRefusalReason::GitOperationInProgress => GuardRemediation { |
| 906 | summary: format!( |
| 907 | "Complete or abort the in-progress Git operation ({}) before reconciliation.", |
no test coverage detected