Skip to content

Commit 4b7d268

Browse files
HoTT-stuffclaude
andcommitted
fix(adjudicate): exit 1 on a complete fail verdict; exit 2 on incomplete input
Exit contract: 0 pass/warn, 1 complete fail, 2 incomplete or error (zero processed or any report failed to load; wins over everything). Verdict precedence stays fail > error > warn > pass. CLI tests for each code, man page and CHANGELOG updated, and the Chapel MassPanic adjudicate pass reads exit 1 as a valid fail verdict instead of dropping it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZkERqsQWMogHRpM2z8
1 parent f3fff1a commit 4b7d268

6 files changed

Lines changed: 135 additions & 10 deletions

File tree

‎CHANGELOG.adoc‎

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,13 @@
88
exited 0 when a report was missing or unrecognised. A run that processed no
99
report, or failed to load any report, now gets the new verdict `+error+` (JSON
1010
`+verdict+`; each failure is in `+notes+` and echoed to stderr) and exits with
11-
status 2, the same code as `+assail --fail-on-incomplete+`. A real `+fail+` from a
12-
loaded report still reports `+fail+`, but exits 2 too when any other report did
13-
not load. Complete input keeps its exit code 0, including for `+warn+` and `+fail+`.
11+
status 2, the same code as `+assail --fail-on-incomplete+`. Verdict precedence is
12+
`+fail+` > `+error+` > `+warn+` > `+pass+`: a real `+fail+` from a loaded report is
13+
still reported as `+fail+`. Exit contract: `+2+` for incomplete input (zero
14+
processed or any report failed to load), whatever the verdict, winning over
15+
everything; `+1+` for a complete `+fail+` (new: previously exit 0); `+0+` for a
16+
complete `+pass+` or `+warn+`. The Chapel `+MassPanic+` adjudicate pass now reads
17+
exit 1 as a valid `+fail+` verdict and exit 2 as `+error+`.
1418

1519
==== Fixed — the shell `/tmp/` rule ignores comments and reports a line
1620

‎chapel/src/MassPanic.chpl‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -843,7 +843,11 @@ module MassPanic {
843843
}
844844
sub.wait();
845845

846-
if sub.exitCode == 0 {
846+
// Exit contract: 0 pass/warn, 1 complete fail (a valid verdict),
847+
// 2 incomplete/error (no verdict is trustworthy).
848+
if sub.exitCode == 2 {
849+
adjResult.verdict = "error";
850+
} else if sub.exitCode == 0 || sub.exitCode == 1 {
847851
result = parseRepoResult(jsonOutput, repoPath);
848852
result.fingerprint = computeFingerprint(repoPath);
849853
} else {

‎man/panic-attack.1‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,11 @@ Copies a target into an isolated workspace, optionally includes related files, a
3333
.TP
3434
.B adjudicate REPORTS...
3535
Aggregates assault/amuck/abduct report artifacts into a campaign-level verdict using rule-based inference.
36-
Verdicts are pass, warn, fail, or error. error means no report was processed or at least one failed to load; it is never a pass. Exits 2 in that case, 0 otherwise.
36+
Verdict precedence is fail > error > warn > pass. The verdict error means no report was processed or at least one failed to load; it is never a pass.
37+
.RS
38+
.PP
39+
Exit status: 2 if the input is incomplete (zero reports processed or any report failed to load), whatever the verdict; this wins over every other status. 1 if all reports loaded and the verdict is fail. 0 if all reports loaded and the verdict is pass or warn.
40+
.RE
3741
.TP
3842
.B axial TARGET
3943
Observes reaction signals by executing an external tool against a target and/or by inspecting existing report artifacts.

‎src/adjudicate/mod.rs‎

Lines changed: 10 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,12 @@ pub struct PriorityFinding {
7979
/// or at least one report failed to load/parse. Distinct from `pass`/`warn`/`fail`.
8080
pub const VERDICT_ERROR: &str = "error";
8181

82-
/// Process exit status for an incomplete adjudication (`error` verdict). Matches
83-
/// `assail --fail-on-incomplete`: 2 means "ran, but the result is not trustworthy".
82+
/// Exit status for a complete run whose verdict is `fail`.
83+
pub const EXIT_FAIL: i32 = 1;
84+
85+
/// Exit status for incomplete input (zero processed or any report failed to load),
86+
/// whatever the verdict. Matches `assail --fail-on-incomplete`: 2 means "ran, but
87+
/// the result is not trustworthy". Wins over every other status.
8488
pub const EXIT_INCOMPLETE: i32 = 2;
8589

8690
impl AdjudicateReport {
@@ -89,11 +93,13 @@ impl AdjudicateReport {
8993
self.processed_reports == 0 || self.failed_reports > 0
9094
}
9195

92-
/// Exit status: `EXIT_INCOMPLETE` when incomplete, otherwise 0 (a `fail`
93-
/// verdict on fully loaded input keeps its existing exit 0).
96+
/// Exit status. Precedence: incomplete input (2) > complete `fail` (1) >
97+
/// complete `pass`/`warn` (0).
9498
pub fn exit_code(&self) -> i32 {
9599
if self.is_incomplete() {
96100
EXIT_INCOMPLETE
101+
} else if self.verdict == "fail" {
102+
EXIT_FAIL
97103
} else {
98104
0
99105
}

‎src/main.rs‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2057,7 +2057,10 @@ fn run_main() -> Result<()> {
20572057
"adjudicate: incomplete ({} processed, {} failed); verdict is not a pass",
20582058
report.processed_reports, report.failed_reports
20592059
);
2060-
std::process::exit(report.exit_code());
2060+
}
2061+
let code = report.exit_code();
2062+
if code != 0 {
2063+
std::process::exit(code);
20612064
}
20622065
}
20632066

‎tests/adjudicate_cli.rs‎

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,107 @@ fn zero_arguments_is_rejected() {
104104
assert_eq!(o.status.code(), Some(2));
105105
assert!(!String::from_utf8_lossy(&o.stdout).contains("verdict: pass"));
106106
}
107+
108+
fn assault_json(crashes: usize) -> String {
109+
assault_json_with(crashes, false)
110+
}
111+
112+
fn assault_json_with(crashes: usize, failed_attack: bool) -> String {
113+
use panic_attack::types::*;
114+
let report = AssaultReport {
115+
schema_version: "2.5".to_string(),
116+
assail_report: AssailReport {
117+
coverage: Default::default(),
118+
schema_version: "2.5".to_string(),
119+
program_path: std::path::PathBuf::from("/tmp/t"),
120+
language: Language::Rust,
121+
frameworks: vec![],
122+
weak_points: vec![],
123+
statistics: ProgramStatistics {
124+
total_lines: 1,
125+
unsafe_blocks: 0,
126+
panic_sites: 0,
127+
unwrap_calls: 0,
128+
safe_unwrap_calls: 0,
129+
allocation_sites: 0,
130+
io_operations: 0,
131+
threading_constructs: 0,
132+
},
133+
file_statistics: vec![],
134+
dependency_graph: DependencyGraph { edges: vec![] },
135+
taint_matrix: TaintMatrix { rows: vec![] },
136+
recommended_attacks: vec![],
137+
migration_metrics: None,
138+
suppressed_count: 0,
139+
},
140+
attack_results: if failed_attack {
141+
vec![AttackResult {
142+
program: std::path::PathBuf::from("/tmp/t"),
143+
axis: AttackAxis::Cpu,
144+
success: false,
145+
skipped: false,
146+
skip_reason: None,
147+
exit_code: Some(1),
148+
duration: std::time::Duration::from_millis(1),
149+
peak_memory: 0,
150+
crashes: vec![],
151+
signatures_detected: vec![],
152+
}]
153+
} else {
154+
vec![]
155+
},
156+
total_crashes: crashes,
157+
total_signatures: 0,
158+
overall_assessment: OverallAssessment {
159+
robustness_score: 50.0,
160+
critical_issues: vec![],
161+
recommendations: vec![],
162+
},
163+
timeline: None,
164+
};
165+
serde_json::to_string(&report).unwrap()
166+
}
167+
168+
#[test]
169+
fn exit_0_on_complete_pass() {
170+
let dir = TempDir::new().unwrap();
171+
let p = dir.path().join("clean.json");
172+
fs::write(&p, assault_json(0)).unwrap();
173+
let (o, j) = adjudicate(dir.path(), &[&p]);
174+
assert_eq!(j["verdict"], "pass", "{:?}", o);
175+
assert_eq!(o.status.code(), Some(0));
176+
}
177+
178+
#[test]
179+
fn exit_0_on_complete_warn() {
180+
let dir = TempDir::new().unwrap();
181+
let p = dir.path().join("flaky.json");
182+
fs::write(&p, assault_json_with(0, true)).unwrap();
183+
let (o, j) = adjudicate(dir.path(), &[&p]);
184+
assert_eq!(j["verdict"], "warn", "{:?}", o);
185+
assert_eq!(o.status.code(), Some(0));
186+
}
187+
188+
#[test]
189+
fn exit_1_on_complete_fail() {
190+
let dir = TempDir::new().unwrap();
191+
let p = dir.path().join("crashy.json");
192+
fs::write(&p, assault_json(3)).unwrap();
193+
let (o, j) = adjudicate(dir.path(), &[&p]);
194+
assert_eq!(j["verdict"], "fail", "{:?}", o);
195+
assert_eq!(j["failed_reports"], 0);
196+
assert_eq!(o.status.code(), Some(1));
197+
}
198+
199+
#[test]
200+
fn exit_2_wins_over_fail_when_a_report_is_missing() {
201+
let dir = TempDir::new().unwrap();
202+
let p = dir.path().join("crashy.json");
203+
fs::write(&p, assault_json(3)).unwrap();
204+
let missing = dir.path().join("gone.json");
205+
let (o, j) = adjudicate(dir.path(), &[&p, &missing]);
206+
// Verdict precedence keeps the real failure visible...
207+
assert_eq!(j["verdict"], "fail");
208+
// ...but incomplete input wins the exit code.
209+
assert_eq!(o.status.code(), Some(2));
210+
}

0 commit comments

Comments
 (0)