Skip to content

Commit f3fff1a

Browse files
HoTT-stuffclaude
andcommitted
fix(adjudicate): never report pass when no report was processed or one failed to load
`adjudicate` printed "verdict: pass (processed 0, failed 1)" and exited 0 for a missing or unrecognised report. Add an `error` verdict (fail-closed) for zero processed or any failed report, record failures in notes and stderr, and exit 2 (same as assail --fail-on-incomplete). A real `fail` still dominates `error`. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_0136P7ZkERqsQWMogHRpM2z8
1 parent d577f7b commit f3fff1a

5 files changed

Lines changed: 188 additions & 1 deletion

File tree

‎CHANGELOG.adoc‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,16 @@
22

33
=== [Unreleased]
44

5+
==== Fixed — adjudicate no longer passes when it processed nothing
6+
7+
* `+panic-attack adjudicate+` printed `+verdict: pass (processed 0, failed 1)+` and
8+
exited 0 when a report was missing or unrecognised. A run that processed no
9+
report, or failed to load any report, now gets the new verdict `+error+` (JSON
10+
`+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+`.
14+
515
==== Fixed — the shell `/tmp/` rule ignores comments and reports a line
616

717
* `+analyze_shell+` raised "Hardcoded /tmp/ path without mktemp" on a

‎man/panic-attack.1‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@ 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.
3637
.TP
3738
.B axial TARGET
3839
Observes reaction signals by executing an external tool against a target and/or by inspecting existing report artifacts.

‎src/adjudicate/mod.rs‎

Lines changed: 61 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,6 +75,31 @@ pub struct PriorityFinding {
7575
pub message: String,
7676
}
7777

78+
/// Verdict for a run that could not adjudicate its input: no report processed,
79+
/// or at least one report failed to load/parse. Distinct from `pass`/`warn`/`fail`.
80+
pub const VERDICT_ERROR: &str = "error";
81+
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".
84+
pub const EXIT_INCOMPLETE: i32 = 2;
85+
86+
impl AdjudicateReport {
87+
/// True when no report was processed or any report failed to load.
88+
pub fn is_incomplete(&self) -> bool {
89+
self.processed_reports == 0 || self.failed_reports > 0
90+
}
91+
92+
/// Exit status: `EXIT_INCOMPLETE` when incomplete, otherwise 0 (a `fail`
93+
/// verdict on fully loaded input keeps its existing exit 0).
94+
pub fn exit_code(&self) -> i32 {
95+
if self.is_incomplete() {
96+
EXIT_INCOMPLETE
97+
} else {
98+
0
99+
}
100+
}
101+
}
102+
78103
pub fn run(config: AdjudicateConfig) -> Result<AdjudicateReport> {
79104
if config.reports.is_empty() {
80105
return Err(anyhow!("provide at least one report path"));
@@ -198,15 +223,36 @@ pub fn run(config: AdjudicateConfig) -> Result<AdjudicateReport> {
198223

199224
let has_fail = !db.get_facts("campaign_fail").is_empty();
200225
let has_warn = !db.get_facts("campaign_warn").is_empty();
226+
// Fail-closed: a run that processed nothing, or could not load every report,
227+
// has not adjudicated the campaign and must never read as `pass`/`warn`.
228+
// A genuine `fail` signal from a loaded report still dominates `error`.
229+
let incomplete = processed == 0 || failed > 0;
230+
if processed == 0 {
231+
notes.push("no report was processed; nothing was adjudicated".to_string());
232+
}
201233
let verdict = if has_fail {
202234
"fail"
235+
} else if incomplete {
236+
VERDICT_ERROR
203237
} else if has_warn {
204238
"warn"
205239
} else {
206240
"pass"
207241
};
208242

209-
let priorities = build_priorities(&totals, verdict);
243+
let mut priorities = build_priorities(&totals, verdict);
244+
if incomplete {
245+
priorities.insert(
246+
0,
247+
PriorityFinding {
248+
level: "high".to_string(),
249+
message: format!(
250+
"adjudication incomplete: {} report(s) processed, {} failed to load",
251+
processed, failed
252+
),
253+
},
254+
);
255+
}
210256

211257
Ok(AdjudicateReport {
212258
schema_version: adjudicate_schema_version(),
@@ -397,4 +443,18 @@ mod tests {
397443
assert_eq!(out.totals.amuck_reports, 1);
398444
assert_eq!(out.verdict, "warn");
399445
}
446+
447+
#[test]
448+
fn adjudicate_zero_processed_is_error_not_pass() {
449+
let dir = TempDir::new().expect("tempdir should create");
450+
let out = run(AdjudicateConfig {
451+
reports: vec![dir.path().join("missing.json")],
452+
})
453+
.expect("adjudicate should run");
454+
assert_eq!(out.processed_reports, 0);
455+
assert_eq!(out.failed_reports, 1);
456+
assert_eq!(out.verdict, VERDICT_ERROR);
457+
assert!(out.is_incomplete());
458+
assert_eq!(out.exit_code(), EXIT_INCOMPLETE);
459+
}
400460
}

‎src/main.rs‎

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2049,6 +2049,16 @@ fn run_main() -> Result<()> {
20492049
"adjudicate report saved to: {}",
20502050
report_path.display()
20512051
);
2052+
for note in &report.notes {
2053+
eprintln!("adjudicate: {}", note);
2054+
}
2055+
if report.is_incomplete() {
2056+
eprintln!(
2057+
"adjudicate: incomplete ({} processed, {} failed); verdict is not a pass",
2058+
report.processed_reports, report.failed_reports
2059+
);
2060+
std::process::exit(report.exit_code());
2061+
}
20522062
}
20532063

20542064
Commands::Axial {

‎tests/adjudicate_cli.rs‎

Lines changed: 106 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,106 @@
1+
// SPDX-License-Identifier: MPL-2.0
2+
// SPDX-FileCopyrightText: 2026 Jonathan D.A. Jewell <j.d.a.jewell@open.ac.uk>
3+
4+
//! CLI contract for `panic-attack adjudicate`: an adjudication that processed
5+
//! no report, or failed to load any report, must never read as `pass`.
6+
7+
use std::fs;
8+
use std::path::Path;
9+
use std::process::{Command, Output};
10+
use tempfile::TempDir;
11+
12+
fn adjudicate(dir: &Path, reports: &[&Path]) -> (Output, serde_json::Value) {
13+
let out = dir.join("out.json");
14+
let output = Command::new(env!("CARGO_BIN_EXE_panic-attack"))
15+
.current_dir(dir)
16+
.arg("adjudicate")
17+
.args(reports)
18+
.arg("--output")
19+
.arg(&out)
20+
.output()
21+
.expect("binary should run");
22+
let json = fs::read_to_string(&out)
23+
.ok()
24+
.and_then(|s| serde_json::from_str(&s).ok())
25+
.unwrap_or(serde_json::Value::Null);
26+
(output, json)
27+
}
28+
29+
fn good_abduct(dir: &Path) -> std::path::PathBuf {
30+
let p = dir.join("good-abduct.json");
31+
let report = serde_json::json!({
32+
"schema_version": "2.5",
33+
"created_at": "2026-01-01T00:00:00Z",
34+
"target": "src/main.rs",
35+
"source_root": ".",
36+
"workspace_dir": "runtime/abduct",
37+
"dependency_scope": "none",
38+
"selected_files": 0,
39+
"locked_files": 0,
40+
"mtime_shifted_files": 0,
41+
"mtime_offset_days": 0,
42+
"time_mode": "normal",
43+
"time_scale": null,
44+
"virtual_now": null,
45+
"files": [],
46+
"execution": null,
47+
});
48+
fs::write(&p, report.to_string()).unwrap();
49+
p
50+
}
51+
52+
#[test]
53+
fn missing_file_is_not_pass() {
54+
let dir = TempDir::new().unwrap();
55+
let missing = dir.path().join("nope.json");
56+
let (o, j) = adjudicate(dir.path(), &[&missing]);
57+
assert_eq!(o.status.code(), Some(2), "{:?}", o);
58+
assert_eq!(j["verdict"], "error");
59+
assert_eq!(j["processed_reports"], 0);
60+
assert_eq!(j["failed_reports"], 1);
61+
assert!(j["notes"].to_string().contains("nope.json"));
62+
assert!(!String::from_utf8_lossy(&o.stdout).contains("verdict: pass"));
63+
}
64+
65+
#[test]
66+
fn unrecognised_file_is_not_pass() {
67+
let dir = TempDir::new().unwrap();
68+
let junk = dir.path().join("junk.json");
69+
fs::write(&junk, r#"{"hello": "world"}"#).unwrap();
70+
let (o, j) = adjudicate(dir.path(), &[&junk]);
71+
assert_eq!(o.status.code(), Some(2), "{:?}", o);
72+
assert_eq!(j["verdict"], "error");
73+
assert_eq!(j["failed_reports"], 1);
74+
assert!(String::from_utf8_lossy(&o.stderr).contains("junk.json"));
75+
}
76+
77+
#[test]
78+
fn good_plus_bad_is_not_pass() {
79+
let dir = TempDir::new().unwrap();
80+
let good = good_abduct(dir.path());
81+
let missing = dir.path().join("gone.json");
82+
83+
// Control: the good report alone passes and exits 0.
84+
let (o, j) = adjudicate(dir.path(), &[&good]);
85+
assert_eq!(j["processed_reports"], 1, "fixture must parse: {:?}", o);
86+
assert_eq!(j["verdict"], "pass");
87+
assert_eq!(o.status.code(), Some(0));
88+
89+
let (o, j) = adjudicate(dir.path(), &[&good, &missing]);
90+
assert_eq!(j["processed_reports"], 1);
91+
assert_eq!(j["failed_reports"], 1);
92+
assert_eq!(j["verdict"], "error");
93+
assert_eq!(o.status.code(), Some(2));
94+
}
95+
96+
#[test]
97+
fn zero_arguments_is_rejected() {
98+
let dir = TempDir::new().unwrap();
99+
let o = Command::new(env!("CARGO_BIN_EXE_panic-attack"))
100+
.current_dir(dir.path())
101+
.arg("adjudicate")
102+
.output()
103+
.unwrap();
104+
assert_eq!(o.status.code(), Some(2));
105+
assert!(!String::from_utf8_lossy(&o.stdout).contains("verdict: pass"));
106+
}

0 commit comments

Comments
 (0)