Skip to content

[anneal][mir] Modularize MIR Lean modules and harden M_ref isolation - #3971

Open
joshlf wants to merge 1 commit into
mainfrom
joshlf-anneal-mir-completeness-01-modularize
Open

joshlf wants to merge 1 commit into
mainfrom
joshlf-anneal-mir-completeness-01-modularize

Conversation

@joshlf

@joshlf joshlf commented Nov 20, 2026

Copy link
Copy Markdown
Member

Authored by an AI agent acting on joshlf's behalf.

Human review surface

  • Pass 1 Lean TCB (anneal/trusted/lean/Trusted/{MirAst*,MirModel,MirSemantics*}.lean):
    • Pure 1:1 modular split of Trusted.MirAst (into an acyclic DAG under candidate:mir_ast) and Trusted.MirSemantics (extracting the 13 operational-rule-free boundary data types and total list helpers into Trusted.MirModel, keeping all 21 locked Pass 1 *Claim definitions and Trusted.{Crate,CrateTheorem,UnitTheorem} directly in Trusted.MirSemantics). Exact 1:1 declaration and body bijection preserved.
  • Pass 2 Correspondence TCB (anneal/trusted/correspondence/Trusted/Correspondence*.lean):
    • Pure 1:1 split into Codec, State, Eval, Simulation, CanaryFixtures, and umbrella Trusted.Correspondence (keeping all 30 locked Pass 2 *Claim definitions directly in Trusted.Correspondence, with Codec, State, and Eval importing only Trusted.MirAst and Trusted.MirModel, never Trusted.MirSemantics).
  • Auditor & tests (anneal/trusted/audit/{TrustedBoundary.lean,src/lib.rs,tests/boundary_audit.rs}, anneal/trusted/cargo-anneal/tests/installed_smoke.rs):
    • Replaced the manual 25-entry forbiddenAnneal denylist in verifyRefEvaluatorIndependence with a closed Trusted module-origin allowlist (isAllowedRefTrustedModule), restricting every Trusted constant in the transitive cone of [evalRefStep, initRefState] to Trusted.MirAst*, Trusted.MirModel, or Trusted.Correspondence*.
    • Updated negative tests (adding submodule, sibling-module, initRefState, and transitive negative tests plus positive Trusted.MirModel admission) and installed-smoke fixture copying.
  • Governing & architecture docs (anneal/docs/{trust-model,architecture,mir-correspondence-design}.md):
    • Updated module layout and tightened verifyRefEvaluatorIndependence allowlist descriptions.
  • Intentional policy relaxations: none (all TCB and auditor invariants are strictly preserved or strengthened).

Summary

PR 1 of the Anneal MIR operational semantics completeness stack (google/zerocopy under anneal/). Splits the monolithic Pass 1 and Pass 2 MIR Lean modules into maintainable topic submodules—preserving an exact 1:1 declaration and body bijection across trusted/lean/ and trusted/correspondence/—and replaces the manual 25-entry $M_{\text{ref}}$ evaluator denylist in TrustedBoundary.lean with a closed Trusted module-origin allowlist.

Split the monolithic Pass 1 and Pass 2 MIR Lean modules in anneal/ into
topic submodules—preserving an exact 1:1 declaration and body bijection
across trusted/lean/ and trusted/correspondence/—and replace the manual
25-entry M_ref evaluator denylist in TrustedBoundary.lean with a closed
Trusted module-origin allowlist.

Why:
- Extending Anneal toward complete Rust MIR operational semantics would
  push the single-file MIR AST, semantics, WP, correspondence adapter,
  and correspondence proof modules past maintainable review and Lean
  memory limits (especially Pass 2's -M4096 compilation ceiling).
- The prior 25-entry forbiddenAnneal list in
  verifyRefEvaluatorIndependence had to be updated manually whenever
  M_anneal gained a new operational helper, creating a maintenance and
  soundness hazard.

What changed (paths relative to anneal/):
- trusted/lean/Trusted/MirAst.lean + Trusted/MirAst/{Types,Places,
  Rvalues,Statements,Terminators,Body}.lean: Pure 1:1 split into an
  acyclic DAG under the existing candidate:mir_ast tier.
- trusted/lean/Trusted/MirModel.lean: Pure extraction of the 13 shared
  boundary data types (FaultKind, StepResult, ScalarVal, PtrVal,
  AllocByte, Val, Allocation, CallerMemory, Query, Out, TerminalOut,
  LocalSlot, Choice) and total list helpers (getElem?, setElem?) into
  an operational-rule-free module (candidate:mir_semantics).
- trusted/lean/Trusted/MirSemantics.lean + Trusted/MirSemantics/{Ops,
  Enum,State,Step,Boundary,CanaryFixtures}.lean: Pure 1:1 split keeping
  all 21 locked Pass 1 *Claim definitions and Trusted.{Crate,
  CrateTheorem,UnitTheorem} directly in Trusted.MirSemantics.
- trusted/correspondence/Trusted/Correspondence.lean +
  Trusted/Correspondence/{Codec,State,Eval,Simulation,
  CanaryFixtures}.lean: Pure 1:1 split so Codec, State, and Eval import
  only Trusted.MirAst and Trusted.MirModel (never
  Trusted.MirSemantics), keeping all 30 locked Pass 2 *Claim
  definitions directly in Trusted.Correspondence.
- theory/Anneal/MirWp.lean + theory/Anneal/MirWp/{Core,Scalars,
  Reflection,Execution,Canaries}.lean: Split the 100%-computable Pass 1
  WP proofs into submodules behind 21 *_base theorems, with thin
  forwarding wrappers keeping all 21 locked theorems directly in
  Anneal.MirWp (updating internal callers to *_base).
- correspondence/Anneal/MirCorrespondenceProof.lean +
  correspondence/Anneal/MirCorrespondence/{Codec,SimHelpers,
  ScalarEquiv,EnumEquiv,RvalueStep,StmtTermStep,InitAndSim,
  Canaries}.lean: Split Pass 2 proofs, retiring MirCorrespondenceBase
  (renamespaced to Anneal.MirCorrespondence), moving 20 additional
  locked witnesses behind *_base lemmas with thin forwarding wrappers
  in Anneal.MirCorrespondenceProof (all 30 locked witnesses preserved
  with unchanged claim types), making readRefPrimitiveSlot_eq public
  for cross-module use, and adjusting refEnumDiscrInBounds_eq's tactic
  proof for cross-module match_N elaboration.
- trusted/audit/TrustedBoundary.lean: Tightened
  verifyRefEvaluatorIndependence with isAllowedRefTrustedModule,
  restricting every Trusted constant in the transitive cone of
  [evalRefStep, initRefState] to Trusted.MirAst*, Trusted.MirModel, or
  Trusted.Correspondence* (rejecting Trusted.MirSemantics,
  Trusted.MirSemantics.*, and any other sibling Trusted.* module).
- trusted/audit/tests/boundary_audit.rs,
  trusted/cargo-anneal/tests/installed_smoke.rs,
  trusted/audit/src/lib.rs, and docs/{trust-model,architecture,
  mir-correspondence-design}.md: Updated Pass 2 preflight/non-
  backsliding tests (adding submodule, sibling-module, initRefState,
  and transitive negative tests plus positive Trusted.MirModel
  admission), installed smoke fixture copying, and TCB/governing docs
  to match the modular layout and tightened allowlist.

Agent-authored-by: AI agent acting on joshlf's behalf
@joshlf

joshlf commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

Authored by an AI agent acting on joshlf's behalf.

Review Receipt (Gate 1)

  • Reviewed range: target_base = merge_base = origin/main (1962a9c0e3eda8a3a58387f61c70ddd2c396b118), head = f6ee0da0010ad6632b586ecd1a25b3d22ed17542 (joshlf-anneal-mir-completeness-01-modularize), 44 paths under anneal/.
  • Passes & reviewers: Independent read-only Pass 1, Pass 2 (trust-review), and general change-review across two distinct model families (inspecting read-only via git from clean base, never entering the candidate worktree).
  • Verdict: Unanimous APPROVE (0 blocking findings, 0 open trust questions). Both reviewers mechanically confirmed exact 1:1 declaration/body bijection across trusted/lean/ and trusted/correspondence/, vetted isolation on Trusted.lean, closed module-origin allowlist hardening (isAllowedRefTrustedModule), negative-test coverage, and accurate Human review surface block.
  • Deterministic checks executed on f6ee0da001 (clean tree):
    • cargo run --locked -p anneal-audit -- --require-correspondence --miri-cache-dir <cache> --json: exit 0 (replay: true, replayedDeclarations: 4972, miriReplay: true, miriReplayedDeclarations: 38728, miriClosureModules: 160, correspondenceReplay: true, correspondenceReplayedDeclarations: 1551/1551).
    • cargo test --locked -p anneal-audit: 61/61 passed (19 unit, 38 boundary_audit, 4 cli_environment).
    • ./ci/check_todo.sh (root and anneal/), sha256sum --check --strict trusted/root-manifest.sha256, ./ci/check_job_dependencies.sh, ./ci/check_actions.sh, ./ci/check_non_stable_version.sh, python3 -B -m unittest discover -s ci -p 'test_*.py' (67/67 passed), cargo fmt -- --config-path /dev/null --check (clean).
  • Checks not executed locally (gated on GitHub CI): nix build .#omnibus-archive, cargo test --workspace, and installed_smoke.
  • Remaining gates: Gate 2 (Codex review), Gate 3 (GitHub CI), Gate 5 (human review & merge).

@codex review

@chatgpt-codex-connector

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

Copy link
Copy Markdown
Codex Review Summary: ✅ Completed

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

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-20T20:37:19.961819Z f6ee0da 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

Codex Review: Didn't find any major issues. Nice work!

Reviewed commit: f6ee0da001

ℹ️ About Codex in GitHub

Codex has been enabled to automatically 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 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

@codecov-commenter

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.99%. Comparing base (1962a9c) to head (f6ee0da).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3971   +/-   ##
=======================================
  Coverage   92.99%   92.99%           
=======================================
  Files          16       16           
  Lines        2469     2469           
=======================================
  Hits         2296     2296           
  Misses        173      173           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@joshlf
joshlf marked this pull request as ready for review November 20, 2026 20:28
@joshlf
joshlf added this pull request to the merge queue Nov 20, 2026
@joshlf
joshlf removed this pull request from the merge queue due to a manual request Nov 20, 2026

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