diff --git a/.containerization/Containerfile b/.containerization/Containerfile index 9122c3c6..99d2162a 100644 --- a/.containerization/Containerfile +++ b/.containerization/Containerfile @@ -108,6 +108,10 @@ WORKDIR /app # Copy echidna binary COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # Copy Idris2 runtime if available (optional) COPY --from=idris2-builder /opt/idris2 /opt/idris2/ diff --git a/.containerization/Containerfile.full b/.containerization/Containerfile.full index 3bfb8abc..42f11bc8 100644 --- a/.containerization/Containerfile.full +++ b/.containerization/Containerfile.full @@ -208,6 +208,10 @@ WORKDIR /app # Copy echidna binary COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # Copy Idris2 runtime (optional — may be empty if pack install failed) COPY --from=idris2-builder /opt/idris2 /opt/idris2/ diff --git a/.containerization/Containerfile.mcp b/.containerization/Containerfile.mcp index ef69531e..b6e840c8 100644 --- a/.containerization/Containerfile.mcp +++ b/.containerization/Containerfile.mcp @@ -136,6 +136,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml COPY --from=rust-builder /build/target/release/echidna-mcp /app/bin/echidna-mcp COPY --from=lean-installer /root/.elan /opt/elan COPY --from=isabelle-installer /opt/Isabelle2025-2 /opt/Isabelle2025-2 diff --git a/.containerization/Containerfile.wave3 b/.containerization/Containerfile.wave3 index 3dd3a6f6..ec5ce50c 100644 --- a/.containerization/Containerfile.wave3 +++ b/.containerization/Containerfile.wave3 @@ -157,6 +157,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # Deterministic export tree (real binary if the GitHub download + smoke-test # succeeded, a one-file stub otherwise). A directory COPY never hard-fails. COPY --from=tamarin-installer /opt/tamarin-export/ /opt/tamarin/ @@ -269,6 +273,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml COPY --from=proverif-builder /opt/proverif-export/bin/proverif /usr/local/bin/proverif ENV PATH="/app/bin:/usr/local/bin:${PATH}" @@ -355,6 +363,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # Copy the deterministic export tree (always exists: the real self-contained # bundle if the GitHub download succeeded, a one-file stub otherwise). A @@ -455,6 +467,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # Copy OR-Tools libs/headers from the deterministic export tree (always # present — real content if the tarball downloaded, just .keep otherwise; @@ -573,6 +589,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # Copy Poly/ML runtime (HOL4 loads ML code via poly at runtime) COPY --from=polyml-builder /opt/polyml /opt/polyml @@ -659,6 +679,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # Copy ACL2 saved image and source tree (ACL2 loads books from its source tree) # Built in-place at /opt/acl2 → the saved_acl2 wrapper's baked core path and @@ -747,6 +771,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # Copy the Twelf installation (src tree + compiled heap + wrapper scripts) # Built in-place at /opt/twelf → the baked absolute heap path in @@ -874,6 +902,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml # The metamath-exe CLI verifier. The Rust backend execs bare `metamath` # (provers/mod.rs default_executable), resolved via PATH; /usr/local/bin is @@ -960,6 +992,10 @@ RUN apt-get update && apt-get install -y --no-install-recommends \ WORKDIR /app COPY --from=rust-builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml COPY --from=imandra-installer /usr/local/bin/imandra /usr/local/bin/imandra ENV PATH="/app/bin:/usr/local/bin:${PATH}" diff --git a/Containerfile b/Containerfile index 5cf199d5..4461f861 100644 --- a/Containerfile +++ b/Containerfile @@ -100,6 +100,10 @@ RUN apk add --no-cache \ WORKDIR /app COPY --from=rust-builder /out/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml COPY --from=prover-installer /opt/z3/bin/z3 /app/bin/z3 COPY --from=prover-installer /opt/elan /opt/elan diff --git a/container/Containerfile b/container/Containerfile index bdb5a808..d078d2f6 100644 --- a/container/Containerfile +++ b/container/Containerfile @@ -58,6 +58,10 @@ RUN addgroup -S appuser && adduser -S appuser -G appuser WORKDIR /app COPY --from=builder /build/target/release/echidna /app/bin/echidna +# Solver integrity manifest: `echidna server` refuses to start without it. +# Pin installed binaries with `echidna integrity pin` (docs/ENV-VARS.adoc). +COPY config/solver-manifest.toml /app/config/solver-manifest.toml +ENV ECHIDNA_SOLVER_MANIFEST=/app/config/solver-manifest.toml COPY container/entrypoint.sh /app/entrypoint.sh RUN chmod +x /app/entrypoint.sh diff --git a/docs/ARCHITECTURE.adoc b/docs/ARCHITECTURE.adoc index 75b9dcaf..ce364577 100644 --- a/docs/ARCHITECTURE.adoc +++ b/docs/ARCHITECTURE.adoc @@ -112,12 +112,16 @@ link:handover/TODO.adoc[`+handover/TODO.adoc+`] for current state): [arabic] . *Integrity* (`+integrity/+`) — solver binary SHAKE3-512 + BLAKE3 -against `+config/solver-manifest.toml+`. *Caveat, 2026-11-01*: this step -runs only when a checker is attached, and nothing in the tree calls -`+with_integrity_checker+`; unconfigured, the pipeline treats integrity as -passing (`+dispatch.rs:632+`). The manifest also still holds -`+PLACEHOLDER_COMPUTE_ON_FIRST_RUN+` for every solver. Treat this step as -*not executed* until it is wired; see +against `+config/solver-manifest.toml+`. *Status, 2026-12-01*: `+echidna server+` loads the manifest at start-up +(`+$ECHIDNA_SOLVER_MANIFEST+`, else `+config/solver-manifest.toml+`) and refuses +to start without it. It attaches the checker to the shared dispatcher used by +`+/api/verify_parallel+` and, under `+verisim+`, `+/api/prove+`. Each dispatch +hashes only the dispatching prover's binaries (`+IntegrityChecker::verify_for+`). +The gate (`+integrity_gate+`) accepts `+Verified+` only (owner decision D9). +`+/api/verify+`, the REPL and the CLI do not go through the dispatcher, so +no integrity step runs for them. The shipped manifest still holds +`+PLACEHOLDER_COMPUTE_ON_FIRST_RUN+` for every solver until an operator runs +`+echidna integrity pin+`. Background: link:reports/2026-11-01-routing-and-rule-engine-recon.adoc[`+docs/reports/2026-11-01-routing-and-rule-engine-recon.adoc+`] §6 RD5. . *Dispatch* (`+dispatch.rs+`) — `+ProverDispatcher::select_prover+` diff --git a/docs/ENV-VARS.adoc b/docs/ENV-VARS.adoc index 3e4872c2..a151598f 100644 --- a/docs/ENV-VARS.adoc +++ b/docs/ENV-VARS.adoc @@ -67,9 +67,10 @@ environment override for this one. |`+ECHIDNA_SOLVER_MANIFEST+` |path |`+config/solver-manifest.toml+` (relative to the working directory) |`+src/rust/integrity/solver_integrity.rs+` -(`+default_manifest_path+`), `+echidna integrity pin+` and -`+echidna integrity check+` |The solver binary manifest. An empty value -means the default. `+echidna integrity pin+` replaces placeholder hashes +(`+default_manifest_path+`): `+echidna server+`, `+echidna integrity pin+` +and `+echidna integrity check+` |The solver binary manifest. An empty value +means the default. `+echidna server+` refuses to start when it cannot read +it. The images set it to `+/app/config/solver-manifest.toml+`. `+echidna integrity pin+` replaces placeholder hashes with the SHAKE3-512 of the binaries found now; it refuses to change a real hash that differs unless given `+--force+`. |=== diff --git a/docs/PROOF-STATUS.adoc b/docs/PROOF-STATUS.adoc index 3a7f6c08..3bb0d139 100644 --- a/docs/PROOF-STATUS.adoc +++ b/docs/PROOF-STATUS.adoc @@ -194,11 +194,16 @@ 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+`). With a checker attached, a prover missing from -the manifest now fails too (test `+unlisted_prover_fails+`). No checker still -passes, pending a further owner decision. 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. +the manifest now fails too (test `+unlisted_prover_fails+`). The fourth path is unreachable: `+verify_all()+` has no error path. +Since 2026-12-01 `+echidna server+` attaches a checker from the manifest at +start-up and refuses to start without one (owner ruling 2026-11-30: wire a +checker in before closing the no-checker path). Each dispatch hashes only +the dispatching prover's binaries (`+verify_for+`). A dispatcher built with +no checker still passes the gate, and closing that is the next step. All 17 +shipped manifest entries remain placeholders until `+echidna integrity pin+` +is run, so under D9 a server dispatch fails the gate for every prover until +its binary is pinned. `+/api/verify+` does not go through the dispatcher and +runs no integrity step. 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 ebe77212..67be4ee9 100644 --- a/src/rust/dispatch.rs +++ b/src/rust/dispatch.rs @@ -647,7 +647,7 @@ impl ProverDispatcher { // Step 6: Check solver integrity (if checker configured) let solver_integrity_ok = match self.integrity_checker { Some(ref checker) => { - let reports = checker.verify_all().await.unwrap_or_default(); + let reports = checker.verify_for(prover_kind).await; integrity_gate(Some(&reports), prover_kind) }, None => integrity_gate(None, prover_kind), @@ -850,7 +850,7 @@ impl ProverDispatcher { // Check solver integrity for cross-checked path let solver_integrity_ok = match self.integrity_checker { Some(ref checker) => { - let reports = checker.verify_all().await.unwrap_or_default(); + let reports = checker.verify_for(primary_prover).await; integrity_gate(Some(&reports), primary_prover) }, None => integrity_gate(None, primary_prover), @@ -994,7 +994,7 @@ impl ProverDispatcher { let solver_integrity_ok = match self.integrity_checker { Some(ref checker) => { - let reports = checker.verify_all().await.unwrap_or_default(); + let reports = checker.verify_for(winning_kind).await; integrity_gate(Some(&reports), winning_kind) }, None => integrity_gate(None, winning_kind), diff --git a/src/rust/integrity/solver_integrity.rs b/src/rust/integrity/solver_integrity.rs index 6f549241..81dd01a6 100644 --- a/src/rust/integrity/solver_integrity.rs +++ b/src/rust/integrity/solver_integrity.rs @@ -552,6 +552,30 @@ pub fn apply_pins(text: &str, pins: &std::collections::BTreeMap) } Ok(doc.to_string()) } + +impl IntegrityChecker { + /// Verify only the manifest entries whose key names `prover` (through + /// `manifest_key_prover`), and cache their reports. This is what the + /// dispatch gate needs: hashing every listed binary on each dispatch + /// costs a full read of each one. The result is empty when no entry + /// names the prover, which the gate treats as a failure (D9). + pub async fn verify_for( + &self, + prover: crate::provers::ProverKind, + ) -> Vec { + let mut results = Vec::new(); + for (name, entry) in &self.manifest.solvers { + if manifest_key_prover(name) == Some(prover) { + results.push(self.verify_solver(name, entry).await); + } + } + let mut reports = self.reports.write().await; + for report in &results { + reports.insert(report.name.clone(), report.clone()); + } + results + } +} #[cfg(test)] mod tests { use super::*; @@ -908,3 +932,48 @@ mod pin_tests { assert!(apply_pins(text, &pins).is_err()); } } + +#[cfg(test)] +mod verify_for_tests { + use super::*; + use crate::provers::ProverKind; + use std::io::Write; + use tempfile::NamedTempFile; + + /// Per dispatch only the dispatching prover's binaries are hashed: + /// verify_for returns reports for the entries that name that prover and + /// for no other. + #[tokio::test] + async fn verify_for_checks_only_the_named_prover() { + let mut bin = NamedTempFile::new().unwrap(); + bin.write_all(b"z3 binary").unwrap(); + let hash = IntegrityChecker::compute_shake3_512(bin.path()).unwrap(); + let entry = |path: &str, hash: &str| SolverManifestEntry { + version: "1".into(), + shake3_512: hash.into(), + path: path.into(), + fallback_paths: vec![], + }; + let checker = IntegrityChecker::new(SolverManifest { + solvers: [ + ( + "z3".to_string(), + entry(&bin.path().display().to_string(), &hash), + ), + ("cvc5".to_string(), entry("/nonexistent/echidna-cvc5", "00")), + ] + .into_iter() + .collect(), + }); + + let z3 = checker.verify_for(ProverKind::Z3).await; + assert_eq!(z3.len(), 1); + assert_eq!(z3[0].name, "z3"); + assert_eq!(z3[0].status, IntegrityStatus::Verified); + assert!(integrity_gate(Some(&z3), ProverKind::Z3)); + + let lean = checker.verify_for(ProverKind::Lean).await; + assert!(lean.is_empty()); + assert!(!integrity_gate(Some(&lean), ProverKind::Lean)); + } +} diff --git a/src/rust/server/mod.rs b/src/rust/server/mod.rs index aea3be82..e24daa20 100644 --- a/src/rust/server/mod.rs +++ b/src/rust/server/mod.rs @@ -16,6 +16,7 @@ use colored::Colorize; use echidna::agent::meta_controller::MetaController; use echidna::core::{ProofState, Tactic}; use echidna::dispatch::ProverDispatcher; +use echidna::integrity::solver_integrity::{default_manifest_path, IntegrityChecker}; use echidna::verification::StatisticsTracker; use echidna::{ProverBackend, ProverKind}; use reqwest::Client; @@ -111,7 +112,7 @@ pub async fn start_server(port: u16, host: String, enable_cors: bool) -> Result< // loop. The writer runs fire-and-forget; a VeriSimDB outage never blocks // or alters a dispatch result. let dispatcher = { - let d = ProverDispatcher::new(); + let d = build_dispatcher(&default_manifest_path())?; #[cfg(feature = "verisim")] let d = { let url = std::env::var("VERISIM_URL") @@ -346,3 +347,48 @@ impl IntoResponse for AppError { (status, body).into_response() } } + +/// The dispatcher the server shares across requests, with the solver +/// integrity checker attached from the manifest at `manifest`. +/// +/// # Errors +/// +/// When the manifest cannot be read or parsed. The server then refuses to +/// start rather than run with no integrity check. +fn build_dispatcher(manifest: &std::path::Path) -> Result { + use anyhow::Context; + let checker = IntegrityChecker::from_manifest_file(manifest).with_context(|| { + format!( + "solver integrity manifest {} is required: set ECHIDNA_SOLVER_MANIFEST to its \ + path, then pin installed binaries with `echidna integrity pin`", + manifest.display() + ) + })?; + info!( + "✓ Solver integrity manifest loaded from {}", + manifest.display() + ); + Ok(ProverDispatcher::new().with_integrity_checker(checker)) +} + +#[cfg(test)] +mod build_dispatcher_tests { + use super::build_dispatcher; + use std::path::Path; + + #[test] + fn a_missing_manifest_stops_the_server() { + let err = build_dispatcher(Path::new("/nonexistent/echidna-solver-manifest.toml")) + .err() + .expect("a missing manifest must be an error"); + let msg = format!("{err:#}"); + assert!(msg.contains("ECHIDNA_SOLVER_MANIFEST"), "{msg}"); + assert!(msg.contains("echidna integrity pin"), "{msg}"); + } + + #[test] + fn the_shipped_manifest_loads() { + let path = Path::new(env!("CARGO_MANIFEST_DIR")).join("config/solver-manifest.toml"); + assert!(build_dispatcher(&path).is_ok()); + } +} diff --git a/src/rust/server/verify.rs b/src/rust/server/verify.rs index 89322375..7298f428 100644 --- a/src/rust/server/verify.rs +++ b/src/rust/server/verify.rs @@ -3,10 +3,10 @@ //! Verification routes: `/api/verify`, `/api/verify_parallel`, `/api/verify_raw` and the SMT passthrough helpers. -use super::{is_empty_state, AppError}; +use super::{is_empty_state, AppError, AppState}; use anyhow::Result; +use axum::extract::State; use axum::Json; -use echidna::dispatch::ProverDispatcher; use echidna::{ProverConfig, ProverKind}; use serde::{Deserialize, Serialize}; use tracing::{info, instrument}; @@ -105,6 +105,7 @@ pub(super) async fn verify_handler( /// Falls back to sequential `select_prover` heuristic when Chapel is /// unavailable. Callers that want a specific prover should use `/api/verify`. pub(super) async fn verify_parallel_handler( + State(app_state): State, Json(req): Json, ) -> Result, AppError> { let content = req @@ -114,8 +115,8 @@ pub(super) async fn verify_parallel_handler( info!("verify_parallel request ({} bytes)", content.len()); - let dispatcher = ProverDispatcher::new(); - let result = dispatcher + let result = app_state + .dispatcher .verify_proof_parallel(content) .await .map_err(|e| AppError::VerificationError(e.to_string()))?;