From 900d1ca1a57ea78a293b9fafe4b6c0619bb58a8f Mon Sep 17 00:00:00 2001 From: Claude Date: Mon, 30 Nov 2026 23:34:55 +0000 Subject: [PATCH 1/2] fix(integrity): the dispatch gate matches manifest keys by ProverKind The three copies of the solver-integrity gate in dispatch.rs matched a report's manifest key against format!("{:?}", prover_kind).to_lowercase(). The shipped manifest keys lean4 and hol_light never equal "lean" or "hollight", so a Tampered or Missing Lean or HOL Light binary still gave solver_integrity_ok = true. MizAR lower-cased to "mizar" and read the Mizar entry. find() took the first match from HashMap order. One integrity_gate in solver_integrity.rs now replaces the three copies. It parses each key through the canonical ProverKind parser, which now accepts lean4 and hol_light. The gate fails when any matching report is not Verified or Uninitialized. gate_tests reproduce each case: six of seven failed against the old logic, and all pass now. A test also checks that every key in config/solver-manifest.toml names a ProverKind. Unchanged, pending owner decision D9: Uninitialized is accepted, and the gate passes when no report matches or no checker is configured. Co-Authored-By: Claude Opus 5.5 Claude-Session: https://claude.ai/code/session_019a95kk88TZ1iegsBK3kox3 --- crates/echidna-core/src/prover_kind.rs | 4 +- docs/PROOF-STATUS.adoc | 13 +++ src/rust/dispatch.rs | 59 ++++-------- src/rust/integrity/solver_integrity.rs | 126 +++++++++++++++++++++++++ 4 files changed, 160 insertions(+), 42 deletions(-) diff --git a/crates/echidna-core/src/prover_kind.rs b/crates/echidna-core/src/prover_kind.rs index d5290928..9eecb6a7 100644 --- a/crates/echidna-core/src/prover_kind.rs +++ b/crates/echidna-core/src/prover_kind.rs @@ -381,12 +381,12 @@ impl std::str::FromStr for ProverKind { match s.to_lowercase().as_str() { "agda" => Ok(ProverKind::Agda), "coq" => Ok(ProverKind::Coq), - "lean" => Ok(ProverKind::Lean), + "lean" | "lean4" => Ok(ProverKind::Lean), "isabelle" => Ok(ProverKind::Isabelle), "z3" => Ok(ProverKind::Z3), "cvc5" => Ok(ProverKind::CVC5), "metamath" => Ok(ProverKind::Metamath), - "hollight" | "hol-light" => Ok(ProverKind::HOLLight), + "hollight" | "hol-light" | "hol_light" => Ok(ProverKind::HOLLight), "mizar" => Ok(ProverKind::Mizar), "pvs" => Ok(ProverKind::PVS), "acl2" => Ok(ProverKind::ACL2), diff --git a/docs/PROOF-STATUS.adoc b/docs/PROOF-STATUS.adoc index 6b4c605a..d36fd97d 100644 --- a/docs/PROOF-STATUS.adoc +++ b/docs/PROOF-STATUS.adoc @@ -182,6 +182,19 @@ shipped code. *Verus:* not started; no Verus specification or proof exists. solver in four ways (an `+Uninitialized+` status, a prover missing from the manifest, no checker configured, and a `+verify_all()+` error read as an empty report), and runs the integrity step after proving, not first. +*Name-matching hole, fixed 2026-11-30.* The gate matched manifest keys +against `+ProverKind+` debug names. A `+Tampered+` or `+Missing+` report under +the shipped keys `+lean4+` and `+hol_light+` therefore never reached Lean or +HOL Light, and MizAR read the Mizar entry. The three gate copies in dispatch +now call one `+integrity_gate+` (`+src/rust/integrity/solver_integrity.rs+`). +It parses each key into a `+ProverKind+`, and it fails when any matching +report is bad, whatever order the reports come in. Tests: `+gate_tests+` in +that file. A test also checks that every key in the shipped manifest names a +prover. Tested only, not proved. Three of the four paths above are unchanged +until the owner decides which statuses the gate accepts (D9 in the placement +ledger, `+docs/PROOF-PLACEMENT.adoc+`): `+Uninitialized+`, a prover missing +from the manifest, and no checker. The fourth path is unreachable: +`+verify_all()+` has no error path. Row stays `+open+` until a Creusot or Verus run on shipped code yields a receipt with a commit hash. diff --git a/src/rust/dispatch.rs b/src/rust/dispatch.rs index 49229511..ebe77212 100644 --- a/src/rust/dispatch.rs +++ b/src/rust/dispatch.rs @@ -19,7 +19,7 @@ use tracing::{info, warn}; use crate::diagnostics::{ CircuitBreakerStateSnapshot, DegradationMode, HealthStatus, ProverHealth, }; -use crate::integrity::solver_integrity::{IntegrityChecker, IntegrityStatus}; +use crate::integrity::solver_integrity::{integrity_gate, IntegrityChecker}; use crate::llm::LlmAdvisor; use crate::provers::outcome::{classify_anyhow_error, ProverOutcome}; use crate::provers::{ProverConfig, ProverFactory, ProverKind}; @@ -645,19 +645,12 @@ impl ProverDispatcher { .and_then(|usages| usages.first().cloned()); // Step 6: Check solver integrity (if checker configured) - let solver_integrity_ok = if let Some(ref checker) = self.integrity_checker { - let reports = checker.verify_all().await.unwrap_or_default(); - let prover_name = format!("{:?}", prover_kind).to_lowercase(); - reports - .iter() - .find(|r| r.name.to_lowercase() == prover_name) - .map(|r| { - r.status == IntegrityStatus::Verified - || r.status == IntegrityStatus::Uninitialized - }) - .unwrap_or(true) // If prover not in manifest, assume ok - } else { - true // No checker configured, assume ok + let solver_integrity_ok = match self.integrity_checker { + Some(ref checker) => { + let reports = checker.verify_all().await.unwrap_or_default(); + integrity_gate(Some(&reports), prover_kind) + }, + None => integrity_gate(None, prover_kind), }; // Step 7: Compute trust level @@ -855,19 +848,12 @@ impl ProverDispatcher { .unwrap_or(DangerLevel::Safe); // Check solver integrity for cross-checked path - let solver_integrity_ok = if let Some(ref checker) = self.integrity_checker { - let reports = checker.verify_all().await.unwrap_or_default(); - let prover_name = format!("{:?}", primary_prover).to_lowercase(); - reports - .iter() - .find(|r| r.name.to_lowercase() == prover_name) - .map(|r| { - r.status == IntegrityStatus::Verified - || r.status == IntegrityStatus::Uninitialized - }) - .unwrap_or(true) - } else { - true + let solver_integrity_ok = match self.integrity_checker { + Some(ref checker) => { + let reports = checker.verify_all().await.unwrap_or_default(); + integrity_gate(Some(&reports), primary_prover) + }, + None => integrity_gate(None, primary_prover), }; let trust_factors = TrustFactors { @@ -1006,19 +992,12 @@ impl ProverDispatcher { let axiom_report = axiom_usages.as_ref().and_then(|u| u.first().cloned()); - let solver_integrity_ok = if let Some(ref checker) = self.integrity_checker { - let reports = checker.verify_all().await.unwrap_or_default(); - let prover_name = format!("{:?}", winning_kind).to_lowercase(); - reports - .iter() - .find(|r| r.name.to_lowercase() == prover_name) - .map(|r| { - r.status == IntegrityStatus::Verified - || r.status == IntegrityStatus::Uninitialized - }) - .unwrap_or(true) - } else { - true + let solver_integrity_ok = match self.integrity_checker { + Some(ref checker) => { + let reports = checker.verify_all().await.unwrap_or_default(); + integrity_gate(Some(&reports), winning_kind) + }, + None => integrity_gate(None, winning_kind), }; let trust_factors = TrustFactors { diff --git a/src/rust/integrity/solver_integrity.rs b/src/rust/integrity/solver_integrity.rs index 4c17b61e..ba68b060 100644 --- a/src/rust/integrity/solver_integrity.rs +++ b/src/rust/integrity/solver_integrity.rs @@ -391,6 +391,40 @@ fn hex_encode(bytes: &[u8]) -> String { bytes.iter().map(|b| format!("{:02x}", b)).collect() } +/// The prover a solver-manifest key names, through the canonical +/// `ProverKind` parser. `None` when the key names no prover. +pub fn manifest_key_prover(key: &str) -> Option { + key.parse().ok() +} + +/// The dispatch pipeline's solver-integrity gate. +/// +/// A report counts for `prover` when its manifest key parses to that +/// `ProverKind` (so `lean4` counts for `Lean` and `hol_light` for +/// `HOLLight`, and `mizar` does not count for `MizAR`). The gate fails when +/// any counting report is not `Verified` or `Uninitialized`, whatever order +/// the reports come in. +/// +/// Unchanged from the code this replaces, pending owner decision D9: with +/// no checker (`reports` is `None`) or no counting report the gate passes, +/// and `Uninitialized` passes. +pub fn integrity_gate( + reports: Option<&[SolverIntegrityReport]>, + prover: crate::provers::ProverKind, +) -> bool { + let Some(reports) = reports else { + return true; + }; + reports + .iter() + .filter(|r| manifest_key_prover(&r.name) == Some(prover)) + .all(|r| { + matches!( + r.status, + IntegrityStatus::Verified | IntegrityStatus::Uninitialized + ) + }) +} #[cfg(test)] mod tests { use super::*; @@ -492,3 +526,95 @@ mod tests { Ok(()) } } + +#[cfg(test)] +mod gate_tests { + use super::*; + use crate::provers::ProverKind; + + fn report(name: &str, status: IntegrityStatus) -> SolverIntegrityReport { + SolverIntegrityReport { + name: name.to_string(), + status, + actual_path: None, + computed_shake3_512: None, + computed_blake3: None, + expected_shake3_512: None, + last_checked: chrono::Utc::now(), + } + } + + /// The shipped manifest names Lean 4 `lean4` and HOL Light `hol_light`. + /// A tampered binary under either key must fail the gate for its prover. + #[test] + fn tampered_lean4_entry_fails_lean() { + let reports = vec![report("lean4", IntegrityStatus::Tampered)]; + assert!(!integrity_gate(Some(&reports), ProverKind::Lean)); + } + + #[test] + fn tampered_hol_light_entry_fails_hol_light() { + let reports = vec![report("hol_light", IntegrityStatus::Tampered)]; + assert!(!integrity_gate(Some(&reports), ProverKind::HOLLight)); + } + + #[test] + fn missing_lean4_entry_fails_lean() { + let reports = vec![report("lean4", IntegrityStatus::Missing)]; + assert!(!integrity_gate(Some(&reports), ProverKind::Lean)); + } + + /// MizAR lower-cases to `mizar`; it must not read the Mizar entry. + #[test] + fn mizar_entry_is_not_mizar_ar() { + let reports = vec![report("mizar", IntegrityStatus::Verified)]; + assert!(integrity_gate(Some(&reports), ProverKind::Mizar)); + let tampered = vec![report("mizar", IntegrityStatus::Tampered)]; + assert!(!integrity_gate(Some(&tampered), ProverKind::Mizar)); + // MizAR has no entry, so the Mizar report says nothing about it. + assert_eq!( + integrity_gate(Some(&tampered), ProverKind::MizAR), + integrity_gate(Some(&[]), ProverKind::MizAR) + ); + } + + /// Two keys that name the same prover: one bad report fails the gate, + /// whatever order the manifest map yields them in. + #[test] + fn any_bad_matching_report_fails() { + for reports in [ + vec![ + report("lean", IntegrityStatus::Verified), + report("lean4", IntegrityStatus::Tampered), + ], + vec![ + report("lean4", IntegrityStatus::Tampered), + report("lean", IntegrityStatus::Verified), + ], + ] { + assert!(!integrity_gate(Some(&reports), ProverKind::Lean)); + } + } + + #[test] + fn verified_entry_passes() { + let reports = vec![report("lean4", IntegrityStatus::Verified)]; + assert!(integrity_gate(Some(&reports), ProverKind::Lean)); + } + + /// Every key in the shipped manifest names a prover, so no entry is + /// silently ignored by the gate. + #[test] + fn every_shipped_manifest_key_names_a_prover() { + let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("config/solver-manifest.toml"); + let text = std::fs::read_to_string(&path).expect("read shipped manifest"); + let manifest: SolverManifest = toml::from_str(&text).expect("parse shipped manifest"); + assert!(!manifest.solvers.is_empty()); + for key in manifest.solvers.keys() { + assert!( + manifest_key_prover(key).is_some(), + "manifest key {key:?} names no ProverKind" + ); + } + } +} From 4fb8c5b8026bd6ef8bb0d723d3f220f157294254 Mon Sep 17 00:00:00 2001 From: "Jonathan D.A. Jewell" <6759885+hyperpolymath@users.noreply.github.com> Date: Tue, 1 Dec 2026 20:11:44 +0000 Subject: [PATCH 2/2] fix(integrity): an Uninitialized report fails the dispatch gate (#537) ## Summary Stacked on #536. Owner decision D9 (2026-11-30): the dispatch integrity gate accepts `Verified` only. This PR closes the first of the three remaining fail-open paths: an `Uninitialized` report no longer passes. An `Uninitialized` report comes from a placeholder manifest hash, and a placeholder pins nothing. ## Changes - `src/rust/integrity/solver_integrity.rs`: `integrity_gate` requires every matching report to be `Verified`. New test `uninitialized_entry_fails`. - `docs/PROOF-STATUS.adoc` R1: records D9 and this step. **Effect today:** none on a production path. All 17 entries in `config/solver-manifest.toml` are placeholders, and no code in `src/` calls `with_integrity_checker`, so no dispatch reaches the gate with reports. Once a checker is wired in, an unpinned binary lowers the trust level until its hash is pinned. Still passing, each with its own PR to follow: a prover with no manifest entry, and no checker configured. ## RSR Quality Checklist ### Required - [x] Tests pass (`cargo test --lib`: 1339 passed, 0 failed, 3 ignored) - [x] Code is formatted (`cargo fmt`) - [x] Linter is clean (`cargo clippy --lib --tests -- -D warnings`: 0 warnings) - [x] No banned language patterns - [x] No `unsafe` blocks - [x] No banned functions - [x] SPDX headers present (no new files) - [x] No secrets ### As Applicable - [x] Documentation updated (`docs/PROOF-STATUS.adoc` R1) ## Testing Test-first: `uninitialized_entry_fails` was added and failed against #536's gate (`7 passed; 1 failed`), then passed after the change (`gate_tests`: 8 passed). CI note: Rust CI ends in `startup_failure` on `main` too (#533 is investigating), so `CI/gate` will not report until that is fixed. The results above are local runs on this commit. --- _Generated by [Claude Code](https://claude.ai/code)_ Co-authored-by: Claude --- docs/PROOF-STATUS.adoc | 13 ++++++++----- src/rust/integrity/solver_integrity.rs | 25 ++++++++++++++----------- 2 files changed, 22 insertions(+), 16 deletions(-) diff --git a/docs/PROOF-STATUS.adoc b/docs/PROOF-STATUS.adoc index d36fd97d..6c61f7dc 100644 --- a/docs/PROOF-STATUS.adoc +++ b/docs/PROOF-STATUS.adoc @@ -190,11 +190,14 @@ now call one `+integrity_gate+` (`+src/rust/integrity/solver_integrity.rs+`). It parses each key into a `+ProverKind+`, and it fails when any matching report is bad, whatever order the reports come in. Tests: `+gate_tests+` in that file. A test also checks that every key in the shipped manifest names a -prover. Tested only, not proved. Three of the four paths above are unchanged -until the owner decides which statuses the gate accepts (D9 in the placement -ledger, `+docs/PROOF-PLACEMENT.adoc+`): `+Uninitialized+`, a prover missing -from the manifest, and no checker. The fourth path is unreachable: -`+verify_all()+` has no error path. +prover. Tested only, not proved. The owner ruled on 2026-11-30 (D9 in the +placement ledger, `+docs/PROOF-PLACEMENT.adoc+`) that the gate accepts +`+Verified+` only. `+Uninitialized+` now fails the gate (test +`+uninitialized_entry_fails+`). A prover missing from the manifest, and no +checker, still pass; each is closed by its own change. The fourth path is +unreachable: `+verify_all()+` has no error path. All 17 entries in the +shipped manifest are placeholders, and no code in `+src/+` attaches a checker, +so no production path reaches the gate with reports today. Row stays `+open+` until a Creusot or Verus run on shipped code yields a receipt with a commit hash. diff --git a/src/rust/integrity/solver_integrity.rs b/src/rust/integrity/solver_integrity.rs index ba68b060..f25140be 100644 --- a/src/rust/integrity/solver_integrity.rs +++ b/src/rust/integrity/solver_integrity.rs @@ -402,12 +402,12 @@ pub fn manifest_key_prover(key: &str) -> Option { /// A report counts for `prover` when its manifest key parses to that /// `ProverKind` (so `lean4` counts for `Lean` and `hol_light` for /// `HOLLight`, and `mizar` does not count for `MizAR`). The gate fails when -/// any counting report is not `Verified` or `Uninitialized`, whatever order -/// the reports come in. +/// any counting report is not `Verified`, whatever order the reports come +/// in. `Uninitialized` (a placeholder manifest hash) fails: it pins nothing +/// (owner decision D9, 2026-11-30). /// -/// Unchanged from the code this replaces, pending owner decision D9: with -/// no checker (`reports` is `None`) or no counting report the gate passes, -/// and `Uninitialized` passes. +/// Still passing, each to be closed by its own change under D9: no checker +/// (`reports` is `None`) and no counting report. pub fn integrity_gate( reports: Option<&[SolverIntegrityReport]>, prover: crate::provers::ProverKind, @@ -418,12 +418,7 @@ pub fn integrity_gate( reports .iter() .filter(|r| manifest_key_prover(&r.name) == Some(prover)) - .all(|r| { - matches!( - r.status, - IntegrityStatus::Verified | IntegrityStatus::Uninitialized - ) - }) + .all(|r| r.status == IntegrityStatus::Verified) } #[cfg(test)] mod tests { @@ -596,6 +591,14 @@ mod gate_tests { } } + /// D9 (owner, 2026-11-30): a placeholder manifest hash pins nothing, so an + /// Uninitialized report does not pass the gate. + #[test] + fn uninitialized_entry_fails() { + let reports = vec![report("lean4", IntegrityStatus::Uninitialized)]; + assert!(!integrity_gate(Some(&reports), ProverKind::Lean)); + } + #[test] fn verified_entry_passes() { let reports = vec![report("lean4", IntegrityStatus::Verified)];