Skip to content

feat(proofs): faithful trust-rule model in Agda with a Rocq recheck - #484

Closed
hyperpolymath wants to merge 2 commits into
mainfrom
claude/trust-rule-model
Closed

hyperpolymath wants to merge 2 commits into
mainfrom
claude/trust-rule-model

Conversation

@hyperpolymath

@hyperpolymath hyperpolymath commented Nov 9, 2026 •

Copy link
Copy Markdown
Owner

Summary

The meta-checker's Dispatch.compute-trust is not a faithful model of the Rust compute_trust_level (src/rust/verification/confidence.rs). Given two confirming provers and no certificate, Rust returns Level3 and the model returns Level2. The model also uses one flag for both "certificate produced" and "certificate verified". The existing theorems hold for the model, but they do not carry over to the Rust code on that input.

This PR adds a model that follows the Rust code line for line and proves it in Agda. It then re-proves the same statements in Rocq: the first Rocq leg under PROOF-POLICY §2. It is new ledger row R12.

Changes

  • meta-checker/src/Echidna/TrustRule.agda (new, part of the MetaChecker closure)
    • Transcribes the Rust rule: separate certificate flags, the confirming count, and the four rules in Rust order, first match wins.
    • Theorems:
      • dangerous-gives-level1 and integrity-failure-gives-level1;
      • level5-sound;
      • compute-mono, monotone in every factor;
      • two witnesses: level5-without-certificate and dispatch-model-diverges.
    • Raises no UnsupportedIndexedMatch warning: equality and order proofs are matched only in absurd clauses, or through stdlib ≤-pred.
  • verification/proofs/rocq/TrustRule.v (new): re-proves the same statements under the same names.
  • Justfile:
    • New recipe proofs-verif-rocq. It compiles each file in a temporary directory, then runs coqchk -o (Rocq's separate checker kernel) over the compiled libraries. It fails unless coqchk reports no axioms and no unsafe flags. Every Axiom, Parameter or Admitted declaration counts, whatever its keyword or position and whether or not a theorem uses it.
    • proofs-coq (the CI Coq job) now depends on it.
    • The proofs aggregate includes it.
  • dogfood-proofs-ci.yml: verification/proofs/rocq/** added to the push and pull_request path filters. No uses: change, so actions.lock is untouched.
  • docs/PROOF-STATUS.adoc:
    • A model-fidelity note under R4.
    • New row R12:
      • Agda: proven for the model.
      • Correspondence between the model and the Rust code: argued.
      • Rocq leg: COQ-CHECKED and BRIDGE-PENDING.
      • Lean leg: open.
    • R5 notes that the first Rocq leg exists.
  • CHANGELOG.adoc: an Unreleased entry.

Findings in the Rust code (owner decision, not changed here)

  1. Level5 doesn't check "2+ small-kernel provers". It is documented as "cross-checked by 2+ independent small-kernel systems". But TrustFactors carries only the primary prover's kernel and a count of agreeing provers, so that condition is never checked.
  2. Level4 and Level5 test certificate_verified but not has_certificate. So a verified flag with no certificate behind it reaches Level5 (level5-without-certificate).

RSR Quality Checklist

Required

  • Tests pass. just test was not run: no Rust is touched. The proof recipes were run (see Testing).
  • Code is formatted. No Rust or other formatter-covered files changed.
  • Linter is clean. Echidna modules raise no Agda warnings; asciidoctor --failure-level WARN is clean on both .adoc files.
  • No banned language patterns.
  • No unsafe blocks.
  • No banned functions: no postulate, TERMINATING, Admitted or admit in the new files.
  • SPDX headers (MPL-2.0) on both new source files.
  • No secrets.

As Applicable

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

Testing

These are session checks, not receipts. The session toolchains are older than CI's:

Check Toolchain Result
agda --safe --without-K --cubical-compatible on Echidna/MetaChecker.agda, fresh interfaces Agda 2.6.3, stdlib 1.7.3 exit 0, 10 modules, no warnings in TrustRule
Mutant: last rule swapped to make the rule non-monotone Agda 2.6.3 fails: Level2 != Level3 in rule-mono-sk
just proofs-verif-rocq Coq 8.18.0 passes; coqchk reports Axioms: <none>
Same recipe with one of these appended, unused: an indented admitted Fact, an admitted Corollary, an Axiom, an admitted Remark in a Section Coq 8.18.0 each fails, coqchk names it
Same recipe with a coqchk stub that prints nothing, or exits 3 — fails
just proofs-coq, the CI Coq job's command Coq 8.18.0 passes

CI checks the Agda side with Agda 2.7.0.1 and stdlib 2.1 (agda-meta-checker.yml), which I could not run here. Watch that job: Data.Nat.Properties.≤-pred is the one new stdlib import.

No Lean toolchain could be run in this environment, so the Lean leg is still open.

🤖 Generated with Claude Code

https://claude.ai/code/session_01J4QvDjbjhwmFbcYz4FKn16

Echidna.TrustRule transcribes compute_trust_level from
src/rust/verification/confidence.rs: separate certificate flags, the
confirming-prover count, and the four rules in Rust order. It proves the
two Level1 guards, what Level5 requires, and monotonicity in every
factor. It is in the MetaChecker closure, so agda-meta-checker.yml
checks it with the section 2.1 flags.

The existing Dispatch.compute-trust model is not faithful: with two
confirming provers and no certificate, Rust returns Level3 and the model
returns Level2. dispatch-model-diverges states this as a theorem; the
older model is left in place.

verification/proofs/rocq/TrustRule.v re-proves the same statements.
just proofs-verif-rocq compiles it and fails unless Print Assumptions
reports every theorem closed; just proofs-coq, which the CI Coq job
runs, now depends on it. The Lean leg is open.

Two findings in the Rust rule are recorded in PROOF-STATUS R12 for an
owner decision, not changed here: Level5 does not enforce "2+
small-kernel provers", and Level4/5 do not check has_certificate.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjbjhwmFbcYz4FKn16
@coderabbitai

coderabbitai Bot commented Nov 9, 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 27 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: ab1011cd-87ff-4ebc-bb6b-98552fda9bdc
Commits

Reviewing files that changed from the base of the PR and between 2ab7574 and b4a74ea.

Files selected for processing: 7

  • .github/workflows/dogfood-proofs-ci.yml
  • CHANGELOG.adoc
  • Justfile
  • docs/PROOF-STATUS.adoc
  • meta-checker/src/Echidna/MetaChecker.agda
  • meta-checker/src/Echidna/TrustRule.agda
  • verification/proofs/rocq/TrustRule.v
  • 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

@hyperpolymath
hyperpolymath marked this pull request as ready for review November 9, 2026 15:31
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 9, 2026 •

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 ✅ Completed 2026-11-09T15:55:24.608652Z b4a74ea New commits
🔒 Security Review ❌ Failed 2026-11-09T15:52:39.860703Z
We couldn’t complete this review. Comment @codex security review to try again.
b4a74ea New commits
ℹ️ 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

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: dbeb616e33

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread Justfile Resolved
Comment thread .github/workflows/dogfood-proofs-ci.yml Resolved
proofs-verif-rocq took theorem names from unindented Theorem/Lemma lines
and ran Print Assumptions on each. An admitted Fact, Corollary, Remark
or indented lemma was never checked, and a file with no matching line
passed vacuously.

The recipe now runs coqchk -o, Rocq's separate checker kernel, over
every compiled library. Its context summary lists each Axiom, Parameter
and Admitted declaration whatever its keyword or position, and whether
or not a theorem uses it. The recipe requires all four "relying on"
lines to read <none>; any other output, including none, fails.

Checked: the real file passes; an indented admitted Fact, an admitted
Corollary, an Axiom, and an admitted Remark in a section each fail; a
coqchk that prints nothing or exits non-zero fails.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01J4QvDjbjhwmFbcYz4FKn16
@chatgpt-codex-connector

Copy link
Copy Markdown

This security review couldn’t start because the paying account has exhausted its Codex allowance and has insufficient available credits. The payer can check their balance and add credits in the Codex usage dashboard, then try again. If you do not manage the paying account, contact this repository's admins.

@sonarqubecloud

sonarqubecloud Bot commented Nov 9, 2026

Copy link
Copy Markdown

@hyperpolymath
hyperpolymath enabled auto-merge (squash) November 9, 2026 23:31

Copy link
Copy Markdown
Owner Author

Closing. TrustRule.agda models the trust rule as it was before #477, so level5-without-certificate is false of today's Rust. #477 fixed the 2 defects this PR found, at their source. Under the R4 split recorded in #474, statements about echidna's own Rust behaviour are verified with Creusot and Verus on the Rust (R1), not as Agda models with a Rocq leg. The row label R12 is also taken by SPARK. The coqchk gate recipe here can be reused if a later PR needs it.


Generated by Claude Code

auto-merge was automatically disabled November 10, 2026 21:13

Pull request was closed

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.

3 participants