Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .containerization/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
4 changes: 4 additions & 0 deletions .containerization/Containerfile.full
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down
4 changes: 4 additions & 0 deletions .containerization/Containerfile.mcp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
36 changes: 36 additions & 0 deletions .containerization/Containerfile.wave3
Original file line number Diff line number Diff line change
Expand Up @@ -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/
Expand Down Expand Up @@ -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}"
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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;
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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}"
Expand Down
4 changes: 4 additions & 0 deletions Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions container/Containerfile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
16 changes: 10 additions & 6 deletions docs/ARCHITECTURE.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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+`
Expand Down
7 changes: 4 additions & 3 deletions docs/ENV-VARS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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+`.
|===
Expand Down
15 changes: 10 additions & 5 deletions docs/PROOF-STATUS.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -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.

Expand Down
6 changes: 3 additions & 3 deletions src/rust/dispatch.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down Expand Up @@ -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),
Expand Down
69 changes: 69 additions & 0 deletions src/rust/integrity/solver_integrity.rs
Original file line number Diff line number Diff line change
Expand Up @@ -552,6 +552,30 @@ pub fn apply_pins(text: &str, pins: &std::collections::BTreeMap<String, String>)
}
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<SolverIntegrityReport> {
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::*;
Expand Down Expand Up @@ -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));
}
}
48 changes: 47 additions & 1 deletion src/rust/server/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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")
Expand Down Expand Up @@ -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<ProverDispatcher> {
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());
}
}
Loading
Loading