Skip to content

fix(integrity): the dispatch gate matches manifest keys by ProverKind - #536

Open
hyperpolymath wants to merge 2 commits into
mainfrom
claude/new-session-th4e9w-integrity-gate
Open

hyperpolymath wants to merge 2 commits into
mainfrom
claude/new-session-th4e9w-integrity-gate

Conversation

@hyperpolymath

Copy link
Copy Markdown
Owner

Summary

Fixes one of the trust-pipeline holes found by the proof-placement review. The owner ruled on 2026-11-30 that each hole is fixed test-first, one PR per hole. This PR fixes the hole that needs no policy decision: the solver-integrity gate in dispatch.rs ignored tampered Lean and HOL Light binaries.

The gate matched a report's manifest key against format!("{:?}", prover_kind).to_lowercase(). The shipped manifest (config/solver-manifest.toml) names those two solvers lean4 and hol_light, which never equal lean or hollight. So a Tampered or Missing report for them still gave solver_integrity_ok = true. MizAR lower-cased to mizar and read the Mizar entry. find() took the first match in HashMap order.

Changes

  • src/rust/integrity/solver_integrity.rs: adds manifest_key_prover (a key is parsed by the canonical ProverKind parser) and integrity_gate. A report counts for a prover when its key parses to that prover. The gate fails when any counting report is not Verified or Uninitialized, whatever the order.
  • src/rust/dispatch.rs: the three gate copies (verify_proof_with_class, verify_proof_cross_checked, verify_proof_parallel) call integrity_gate.
  • crates/echidna-core/src/prover_kind.rs: FromStr accepts lean4 (Lean, which is Lean 4; Lean3 is a separate variant) and hol_light.
  • docs/PROOF-STATUS.adoc R1 records the hole and the fix, as tested only, not proved. It also notes that the verify_all() error path is unreachable.

Not changed, pending owner decision D9 (which statuses the gate accepts; see docs/PROOF-PLACEMENT.adoc on #518): Uninitialized is accepted, the gate passes when no report matches, and it passes when no checker is configured. Each gets its own test-first PR once D9 is decided.

RSR Quality Checklist

Required

  • Tests pass (cargo test --lib: 1338 passed, 0 failed, 3 ignored; cargo test -p echidna-core: all passed)
  • Code is formatted (cargo fmt --check clean)
  • Linter is clean (cargo clippy --lib --tests -- -D warnings exit 0)
  • No banned language patterns
  • No unsafe blocks
  • No banned functions
  • SPDX headers present (no new files)
  • No secrets

As Applicable

  • Documentation updated (docs/PROOF-STATUS.adoc R1)

Testing

Test-first. I added gate_tests (7 tests), then ran them against a copy of today's gate logic before the fix:

test result: FAILED. 1 passed; 6 failed
  tampered_lean4_entry_fails_lean, tampered_hol_light_entry_fails_hol_light,
  missing_lean4_entry_fails_lean, mizar_entry_is_not_mizar_ar,
  any_bad_matching_report_fails, every_shipped_manifest_key_names_a_prover

After the fix: test result: ok. 7 passed; 0 failed.

CI note: Rust CI ends in startup_failure on main as well (6165b8f; #533 is investigating), so CI/gate and rust-ci / * will not report on this PR until that is fixed. Dependency audit is red on main, and #534 fixes it. The results above come from local runs on this commit.


Generated by Claude Code

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 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_019a95kk88TZ1iegsBK3kox3
@gitnotebooks

gitnotebooks Bot commented Nov 30, 2026

Copy link
Copy Markdown

Review these changes at https://app.gitnotebooks.com/hyperpolymath/echidna/pull/536

@coderabbitai

coderabbitai Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 59 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration

  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: ASSERTIVE
  • Plan: Advanced
  • Run ID: 7f2f431b-2dfc-467c-b8d2-1fdf3f08643f
Commits

Reviewing files that changed from the base of the PR and between 6165b8f and 4fb8c5b.

Files selected for processing: 4

  • crates/echidna-core/src/prover_kind.rs
  • docs/PROOF-STATUS.adoc
  • src/rust/dispatch.rs
  • src/rust/integrity/solver_integrity.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@chatgpt-codex-connector

Copy link
Copy Markdown
Codex Review Summary: ❌ Failed

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ❌ Failed 2026-12-01T20:11:26.006925Z
We couldn’t complete this review. Comment @codex review to try again.
900d1ca Draft marked ready
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.

## 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 <noreply@anthropic.com>
hyperpolymath added a commit that referenced this pull request Dec 1, 2026
…anifest (#539)

## Summary

Stacked on #538 (← #537 ← #536). This is step 1 of three for the last
fail-open path in the dispatch integrity gate, "no checker configured".
On 2026-11-30 the owner chose to wire a checker in before closing that
path.

A checker is useless today: all 17 entries in
`config/solver-manifest.toml` hold `PLACEHOLDER_COMPUTE_ON_FIRST_RUN`,
and nothing ever computes a hash. Under D9 an unpinned binary fails the
gate, so a pinning step must exist first. This PR adds it.

## Changes

- `echidna integrity pin [--manifest PATH] [--solver NAME]... [--force]
[--dry-run]`. An explicit operator step; dispatch never pins, so there
is no trust on first use.
- It replaces a placeholder with the SHAKE3-512 of the binary found now.
- It refuses, writing nothing, when a real hash differs from the binary,
which may mean tampering. `--force` overrides.
- It refuses when a binary cannot be read, or when a solver named with
`--solver` is not found.
- It rewrites the file through `toml_edit`, so comments, order and every
other field are kept.
- `echidna integrity check [--manifest PATH]` prints each binary's
status and exits non-zero on `Tampered`.
- `src/rust/integrity/solver_integrity.rs` gains:
- `PinOutcome` and `IntegrityChecker::pin_entries`, which computes and
writes nothing.
  - `apply_pins`, which rejects an unknown solver.
- `default_manifest_path` (`$ECHIDNA_SOLVER_MANIFEST`, else
`config/solver-manifest.toml`).
  - `PLACEHOLDER_PREFIX`.
- `docs/ENV-VARS.adoc` documents `ECHIDNA_SOLVER_MANIFEST`.
- `toml_edit = "0.25"` becomes a direct dependency; it was already in
`Cargo.lock`.

Next in the stack: load the manifest at startup and attach the checker
(failing loudly when it is unreadable), then close the no-checker path.

## RSR Quality Checklist

### Required

- [x] Tests pass (`cargo test --lib`: 1348 passed, 0 failed, 3 ignored)
- [x] Code is formatted (`cargo fmt --check`)
- [x] Linter is clean (`cargo clippy --all-targets -- -D warnings`: exit
0)
- [x] No banned language patterns
- [x] No `unsafe` blocks
- [x] No banned functions
- [x] SPDX license headers present (new `src/rust/cli/integrity.rs`:
MPL-2.0)
- [x] No secrets

### As Applicable

- [x] Documentation updated (`docs/ENV-VARS.adoc`)
- [x] New dependencies reviewed for licence compatibility (`toml_edit`:
MIT OR Apache-2.0)

## Testing

`pin_tests` (8 tests) cover:

- a placeholder is pinned;
- a matching hash is left unchanged;
- a differing hash is refused without `--force` and replaced with it;
- an absent binary is reported as not found;
- an unknown `--solver` is an error;
- only the named solvers are pinned;
- `apply_pins` keeps the rest of the file byte for byte and rejects an
unknown solver.

The last test caught a real bug: `toml_edit`'s `Item::get_mut` creates a
missing table, so an unknown solver was silently added.

I also ran the built binary end to end against a scratch manifest (a
copy of `/bin/true` as `z3`, plus an absent `cvc5`):

| Step | Result |
|---|---|
| `pin --dry-run` | reports `z3: pinned`, writes nothing, exit 0 |
| `pin` | writes the hash; comments kept; exit 0 |
| `check` | `z3: Verified`, `cvc5: Missing`, exit 0 |
| append a byte to the binary, `check` | `z3: Tampered`, exit 1 |
| `pin` | `REFUSED`, manifest byte-identical, exit 1 |
| `pin --solver cvc5` | `no binary found`, exit 1 |
| `pin --force` | `REPINNED`, exit 0 |

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 <noreply@anthropic.com>
@hyperpolymath
hyperpolymath added this pull request to stack #541 December 1, 2026 20:12
@sonarqubecloud

sonarqubecloud Bot commented Dec 1, 2026

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath enabled stacked auto-merge (squash) December 1, 2026 20:16

Copy link
Copy Markdown
Owner Author

The "Dependency audit" failure on this head comes from main, not this PR. cargo-audit.yml is red on main because Cargo.lock and fuzz/Cargo.lock report vulnerabilities. #534 fixes it, and its own audit is green. Rust CI also ends in startup_failure on main (#533), so CI/gate cannot report on any PR yet. Once both land, I will merge main into this branch and then up the stack (#538, #540).


Generated by Claude Code

stacked auto-merge was automatically disabled December 1, 2026 20:18

Auto-merge was disabled for another pull request in the stack

@hyperpolymath
hyperpolymath enabled stacked auto-merge (squash) December 1, 2026 20:18

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants