review: adversarial pass — fix ROI leak for overturned rows + load-gen guards

Two defects found and fixed in a hostile review of the whole package:

1. The ROI report generator trusted the ledger verdict field and would
   mint a clean $16,886/year report for phase2-comrak-010 — the
   memory-leaking patch the audit overturned (immutably 'accepted' in the
   append-only ledger, sanitizers_clean:false). report_row now exposes
   sanitizers_clean and the report treats accepted-but-not-sanitizer-clean
   as NOT shippable, printing a warning before any dollar figure. Legit
   wins (sanitizers_clean:true) still render clean.
2. bench-runner service --rate 0 / --count 0 could panic via
   from_secs_f64(1/0); run_session now guards finite/positive rate and
   non-zero count/workers.

Attacks correctly refused (verified, no change): ledger UPDATE/DELETE,
propose_patch ../ + .git escapes, read_target_source traversal. All 10
accepted rows satisfy the green-gates + CI>=1.02 invariant. Findings
recorded in results/adversarial-review.md.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01EcKPWQ3MQD4NdEHwar96u2
This commit is contained in:
Claude
2026-07-12 00:10:06 +00:00
parent d1ef2a0dd6
commit 42c86a1f6b
4 changed files with 106 additions and 7 deletions
+18
View File
@@ -217,12 +217,30 @@ impl Ledger {
.and_then(|b| b.get("env_fingerprint"))
.and_then(|f| f.get("workload"))
.cloned();
// Pull the sanitizer gate out so the report can refuse to
// mint a clean ROI for an `accepted` row that predates the
// machine-enforced sanitizer gate and was overturned by
// audit (phase2-comrak-010). The gates JSON is stored
// separately; read it here.
let sanitizers_clean = self
.conn
.query_row(
"SELECT gates FROM attempts WHERE run_id = ?1",
[run_id],
|r| r.get::<_, Option<String>>(0),
)
.ok()
.flatten()
.and_then(|g| serde_json::from_str::<serde_json::Value>(&g).ok())
.and_then(|g| g.get("sanitizers_clean").and_then(|v| v.as_bool()))
.unwrap_or(false);
Ok(Some(serde_json::json!({
"run_id": run_id,
"target": target,
"playbook_class": class,
"hypothesis": hypothesis,
"verdict": verdict,
"sanitizers_clean": sanitizers_clean,
"timestamp": ts,
"speedup_median": bench.as_ref().and_then(|b| b.get("speedup_median").cloned()),
"speedup_ci": bench.as_ref().and_then(|b| b.get("speedup_ci").cloned()),