Workspace Composition and Role Binding

cargo anneal verify assembles Rust source files, captured MIR artifacts, installed semantics and theory modules, generated claim modules, and user Lean files inside an isolated temporary workspace before running isolated Lean elaborator containment (ExecSeal) and fresh Lean kernel replay (TrustedBoundary). Understanding how those inputs combine clarifies what an untrusted proof can influence and what remains fixed by the verifier.

[!NOTE] Earlier design documents (architecture, design, and trust model) refer informally to Mir.lean as the captured MIR module. The shipped pipeline generates capture/Captured.lean (defining Captured.program), optional capture/Captured/Shard_NNN.lean modules, and generated/Expected.lean (defining Expected.claim).

Entrypoints and canonical request assembly

Three CLI frontends in trusted/cargo-anneal/src/verify.rs normalize into the same Request (schema_version = 1):

  1. Explicit request (cargo anneal verify --request path/to/request.json): Specifies compilation (source_root, crate_root, crate_name, crate_type, panic, overflow_checks, edition, target, source_files), scope ({"kind": "crate"} yielding crate_verified or {"kind": "selected_unit", "roots": [...], "instantiations": [...]} yielding selected_unit_verified), and proof (source_root, specification defaulting to "Spec.specs", theorem defaulting to "Proof.verify", and {module, path, role} entries with role in {"specification", "proof"}). Inputs use SymlinkPolicy::Reject.
  2. Cargo manifest shortcut (--manifest-path Cargo.toml --proof-dir <dir>): Stages .rs files under a dependency-free primary target (rejecting build scripts, proc-macros, and toolchain overrides), assigns role specification to Spec / Spec.* modules and proof to all other .lean files, selects crate unless --select or --instantiate is passed, and uses SymlinkPolicy::Reject.
  3. Direct rustc wrapper (cargo anneal verify rustc ...): Accepts rustc-like compilation flags alongside --spec-file and --proof-file and normalizes them into Request using SymlinkPolicy::DereferenceRegular.

Both load_request and the Cargo shortcut enforce regular-file reading with zero symlink traversal, and all entrypoints validate --receipt-out aliasing before touching disk.

Ephemeral workspace layout and reserved roots

During verification, cargo-anneal isolates tool-owned artifacts from authored modules (generated/Proof/IdTree.lean appears when sharded capture is active):

work/
├── request.json                              # Canonical Request (request_sha256)
├── rust/<source_files...>                    # Verified Rust source snapshot
├── capture/
│   ├── capture.json                          # Capture Schema v5 receipt
│   ├── Captured.lean                         # TargetRole::Capture (`Captured.program`)
│   └── Captured/Shard_NNN.lean               # Optional sharded capture modules
├── anneal/
│   ├── trusted/lean/Trusted/.../*.lean       # TargetRole::Model (embedded semantics)
│   └── theory/Anneal/.../*.lean              # TargetRole::Proof (embedded theory)
├── authored/<Module>.lean                    # User/attacker Lean files
├── generated/Expected.lean                   # TargetRole::Expected (`Expected.claim`)
├── generated/Proof/IdTree.lean               # Optional sharded ID tree (TargetRole::Proof)
└── audit-request.json                        # Authenticated TargetAuditRequest checked by Checker / TrustedBoundary

Authored Lean sources cannot declare modules under reserved top-level roots (Captured, Expected, Trusted, Anneal, Init, Std, Lean, Lake, TrustedBoundary, SpecPreflight). Embedded Anneal.* theory helpers receive TargetRole::Proof, never Model or Specification, so they undergo fresh kernel replay alongside user proofs.

Connecting scope, mir_profile_version, Spec, and Expected.claim

cargo-anneal generates generated/Expected.lean defining Expected.claim:

namespace Expected
def claim : Prop :=
  _root_.Trusted.MirSemantics.<RootTheorem>
    (_root_.Trusted.MirSemantics.<CrateCtor>.mk
      _root_.Captured.program
      _root_.<specification>)
end Expected
scope.kindmir_profile_version<RootTheorem><CrateCtor>Untainted status
crate1CrateTheoremCratecrate_verified
crate2CrateTheoremV2CrateV2crate_verified
selected_unit1UnitTheoremCrateselected_unit_verified
selected_unit2UnitTheoremV2CrateV2selected_unit_verified

TrustedBoundary enforces TargetRole.allows (Specification cannot import Proof or Lean.*/meta constants; Expected excludes Proof), confirms via kernel isDefEq that Expected.claim and <theorem> match the canonical root claim, and binds hashes across Receipt v3.

Automated red-teaming composition contract

In automated red-teaming, the defender pins all locked inputs (src/lib.rs, Spec.lean, request.json, Proof.lean, or trusted/ + core MirWp files) using SHA-256 and file-metadata snapshots in defender-private memory, and reserves top-level Lean module roots (Captured, Expected, Trusted, Anneal, Init, Std, Lean, Lake, TrustedBoundary, SpecPreflight, Spec, Specs, IncorrectnessCheck, IncorrectnessExpected, and src) across Proof/ submissions and outside Spec/'s Spec.* and theory/Anneal/'s Anneal.* slots:

Challenge IDDefender-fixed inputsAttacker-supplied slotsBound claim / verification target
proof_only_ubsrc/lib.rs (unconditional UB), Spec.lean, request.jsonProof/*.lean, explanation.mdUnitTheorem (mir_profile_version = 1) over defender Captured.program + Spec.specs
proof_only_wrong_returnsrc/lib.rs (wrong_const), Spec.lean (Spec.specs wrapping Spec.returnsZero), request.jsonProof/*.lean, explanation.mdUnitTheorem (mir_profile_version = 1) over defender Captured.program + Spec.specs
spec_preflight_soundnesssrc/lib.rs (trigger_ub), request.json (plus default Proof.lean when omitted)Spec/*.lean (Spec/Spec.lean required), optional Proof/*.lean, explanation.mdUnitTheorem over Captured.program + untrusted Spec.specs, plus olean_audit.lean inspection of exported lean-lib/Spec*.oleans
theory_audit_soundnesstrusted/lean/, trusted/audit/{TrustedBoundary.lean,SpecPreflight.lean,library-lock.json}, theory/bundle-manifest.json, and 10 core MirWp filesNew theory/Anneal.lean / theory/Anneal/**/*.lean, explanation.mdanneal-audit --anneal-root ... --lean ... --json plus olean_audit.lean over compiled Anneal.* .oleans