Skip to content

trusted/rustc-capture: add generic family MIR capture - #756

Draft
joshlf wants to merge 1 commit into
mainfrom
joshlf/mir-b1-family-capture
Draft

joshlf wants to merge 1 commit into
mainfrom
joshlf/mir-b1-family-capture

Conversation

@joshlf

@joshlf joshlf commented Dec 6, 2026 •

Copy link
Copy Markdown
Member

Add an open, GenArgs-parameterized MIR family capture pipeline in anneal_rustc_capture::family without altering existing concrete capture behavior or Lean AST files:

  • family::ir: Open GenArgs-parameterized family IR (FamilyBody, FamilyTy, FamilyPlace, FamilyRvalue, FamilyStatement, FamilyTerminator, FamilyGenArgs) with explicit type, const, struct-layout, direct-callee, and instName slots.
  • family::hypotheses: Fail-closed classifier over tcx.predicates_of mapping Copy, Sized, ConstArgHasType, outlives, Send/Sync, and Unpin obligations and rejecting unmodeled trait bounds.
  • family::lower: Member-independent lowering preserving .useRetag on parameter-mentioning moves, keeping CopyForDeref as .use(.copy p), retaining parameter Drop terminators, keeping size_of::<T>() as an open call op, and failing closed on member-dependent lowering, generic intra-crate callees, or trait calls.
  • family::lean_emit: Lean 4.35 emitter producing bodyOf_<name>, hyp_<name>, and genArgs_* records compatible with Anneal.Generics.{ClaimShape,SymTy}.
  • family::parity: Concrete instance-argument parity tripwire comparing instantiated family bodies against concrete MIR capture modulo no-op retag erasure and closed size_of evaluation, plus duplicate instName detection.
  • tests/family_capture.rs: End-to-end invariant, parity, Lean 4.35 elaboration, negative-canary, and zerocopy wrapper tests.

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

@joshlf

joshlf commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

🤖 Exact-HEAD verification receipt (b36916746a62fd79c8bc2299b9c7b35cc0fdc against merge-base 4ad81da4274cfa6a285a2e252c49d772bfba9c10, tree 7536e97eba277fb4fd90d8023e9131e10e75b3ca):

Human review surface

  • trusted/rustc-capture/src/family/hypotheses.rs
  • trusted/rustc-capture/src/family/ir.rs
  • trusted/rustc-capture/src/family/lean_emit.rs
  • trusted/rustc-capture/src/family/lower.rs
  • trusted/rustc-capture/src/family/mod.rs
  • trusted/rustc-capture/src/family/parity.rs
  • trusted/rustc-capture/src/lib.rs

(Zero edits to trusted/lean/**, ci/**, theory/bundle-manifest.json, extract/**, ir/terminators.rs, capture/{isolation,lowering}.rs, or lean.rs.)

Exact-HEAD checks

  • [real measurement] python3 ci/prebuild_bundled_oleans.py: Prebuilt 141 bundled .olean entries
  • [real measurement] cargo run --locked --bin anneal-audit -- --cargo-boundary-only: PASS
  • [real measurement] cargo clippy --locked --no-deps -p anneal-rustc-capture-tests --test family_capture -- -D warnings: 0 warnings/errors
  • [real measurement] cargo clippy --locked --no-deps -p anneal-rustc-capture --lib: 0 diagnostics in trusted/rustc-capture/src/family/ or lib.rs (only pre-existing baseline lint in untouched trusted/rustc-capture/src/ffi_exports.rs:1296)
  • [real measurement] cargo test --locked -p anneal-rustc-capture --lib: 147 passed; 0 failed
  • [real measurement] cargo test --locked -p anneal-rustc-capture-tests --test family_capture -- --test-threads=1 --nocapture (with unmodified upstream zerocopy/src via ANNEAL_ZEROCOPY_ROOT): 5 passed; 0 failed (box_use_retag_parity_and_canary11, lean_elaboration_and_type0_level_params, member_independent_lowering_and_parity_invariants, negative_canaries_and_fail_closed_rejections, real_zerocopy_wrappers_family_capture_and_parity)
  • [real measurement] Local hygiene & tripwires (ci/check_pr_hygiene.py, ./ci/check_todo.sh, ci/pr_preflight.py, ci/check_phase0_tripwires.py): PASS (0 conflicts against base; 0 findings)
  • Automated pre-PR cross-family static review gate: 3 rounds completed, final round CLEAN (0 P0 / 0 P1 / 0 P2, 1 non-blocking test-fixture advisory).

First-customer zerocopy coverage ([real measurement])

  • Full family lowering + concrete instance parity (u32, bool) + unique instName: zerocopy::util::macro_util::must_use
  • Family lowering + extract_closed_gen_args + instantiate_concrete + unique instName (u32, bool): zerocopy::wrappers::read_only_def::ReadOnly<T>::{new, into_inner, as_mut, as_ref_unchecked} (blocked from concrete PR8 body parity solely by the untouched concrete extract/types.rs args.is_empty() generic-struct guard)
  • Verified fail-closed gap: zerocopy::wrappers::Unalign<T>::new (#[repr(C, packed)]) is rejected fail-closed (packed) until packed-field layout semantics are modeled.

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

Add an open, `GenArgs`-parameterized MIR family capture pipeline in
`anneal_rustc_capture::family` without altering existing concrete
capture behavior or Lean AST files:

- `family::ir`: Open `GenArgs`-parameterized family IR (`FamilyBody`,
  `FamilyTy`, `FamilyPlace`, `FamilyRvalue`, `FamilyStatement`,
  `FamilyTerminator`, `FamilyGenArgs`) with explicit type, const,
  struct-layout, direct-callee, and `instName` slots.
- `family::hypotheses`: Fail-closed classifier over `tcx.predicates_of`
  mapping `Copy`, `Sized`, `ConstArgHasType`, outlives, `Send`/`Sync`,
  and `Unpin` obligations and rejecting unmodeled trait bounds.
- `family::lower`: Member-independent lowering preserving `.useRetag` on
  parameter-mentioning moves, keeping `CopyForDeref` as `.use(.copy p)`,
  retaining parameter `Drop` terminators, keeping `size_of::<T>()` as an
  open call op, and failing closed on member-dependent lowering, generic
  intra-crate callees, or trait calls.
- `family::lean_emit`: Lean 4.35 emitter producing `bodyOf_<name>`,
  `hyp_<name>`, and `genArgs_*` records compatible with
  `Anneal.Generics.{ClaimShape,SymTy}`.
- `family::parity`: Concrete instance-argument parity tripwire comparing
  instantiated family bodies against concrete MIR capture modulo
  no-op retag erasure and closed `size_of` evaluation, plus duplicate
  `instName` detection.
- `tests/family_capture.rs`: End-to-end invariant, parity, Lean 4.35
  elaboration, negative-canary, and `zerocopy` wrapper tests.

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

joshlf commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

🤖 Exact-HEAD verification receipt (b37e03a1884391424cda099c4ae0fe413da9bcf3 against merge-base 4ad81da4274cfa6a285a2e252c49d772bfba9c10, tree 26f2a448b1a7888d57b6e61c156a4c0f4580a98c):

Human review surface

  • trusted/rustc-capture/src/family/hypotheses.rs
  • trusted/rustc-capture/src/family/ir.rs
  • trusted/rustc-capture/src/family/lean_emit.rs
  • trusted/rustc-capture/src/family/lower.rs
  • trusted/rustc-capture/src/family/mod.rs
  • trusted/rustc-capture/src/family/parity.rs
  • trusted/rustc-capture/src/lib.rs

(Zero edits to trusted/lean/**, ci/**, theory/**, extract/**, ir/terminators.rs, capture/{isolation,lowering}.rs, or lean.rs.)

Exact-HEAD checks

  • [real measurement] rustfmt +nightly-2026-05-31 --edition 2024 --config-path rustfmt.toml --check tests/rustc-capture/tests/family_capture.rs trusted/rustc-capture/src/family/*.rs: 0 formatting diffs
  • [real measurement] cargo +nightly-2026-05-31 clippy --locked --no-deps -p anneal-rustc-capture-tests --test family_capture -- -D warnings: 0 warnings/errors
  • [real measurement] cargo +nightly-2026-05-31 clippy --locked --no-deps -p anneal-rustc-capture --all-targets: 0 diagnostics in trusted/rustc-capture/src/family/ or lib.rs (only pre-existing baseline clippy::unnecessary_lazy_evaluations warning in untouched trusted/rustc-capture/src/ffi_exports.rs:1296)
  • [real measurement] cargo +nightly-2026-05-31 test --locked -p anneal-rustc-capture --lib: 147 passed; 0 failed
  • [real measurement] cargo +nightly-2026-05-31 test --locked -p anneal-rustc-capture-tests --test family_capture -- --test-threads=1 --nocapture (with unmodified pinned zerocopy/src at e8b7f4288ee2bd59f2e6bcf63b4f47ade6104484 via ANNEAL_ZEROCOPY_ROOT and live Lean v4.35.0 -DwarningAsError=true elaboration + levelParams check): 5 passed; 0 failed (box_use_retag_parity_and_canary11, lean_elaboration_and_type0_level_params, member_independent_lowering_and_parity_invariants, negative_canaries_and_fail_closed_rejections, real_zerocopy_wrappers_family_capture_and_parity)
  • [real measurement] Local hygiene & markers (ci/check_pr_hygiene.py, ./ci/check_todo.sh, git diff --check): PASS (0 findings, 0 [trusted-citation] warnings, 0 wrap findings)
  • Automated cross-family static review fix-delta round: CLEAN (0 P0 / 0 P1 / 0 P2, 1 non-blocking test-helper advisory; fixes P2 logical_env in tests/rustc-capture/tests/family_capture.rs, fail-closed Lean v4.35.0 module compilation + elaboration + levelParams checks in family_capture.rs, Lean StructLayout/Int.emod/(0 : Int) emission fixes in lean_emit.rs, and pinned upstream rust-lang/rust SHA citations in trusted/rustc-capture/src/family/*.rs).

First-customer zerocopy coverage ([real measurement])

  • Full family lowering + concrete instance parity (u32, bool) + unique instName: zerocopy::util::macro_util::must_use
  • Family lowering + extract_closed_gen_args + instantiate_concrete + unique instName (u32, bool): zerocopy::wrappers::read_only_def::ReadOnly<T>::{new, into_inner, as_mut, as_ref_unchecked}
  • Verified fail-closed gap: zerocopy::wrappers::Unalign<T>::new (#[repr(C, packed)]) fails closed (packed).

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

@joshlf
joshlf force-pushed the joshlf/mir-b1-family-capture branch from b369167 to b37e03a Compare December 6, 2026 03:36

@joshlf joshlf left a comment

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

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

Gate 2 Independent Cross-Family Review — FINDINGS (tier2a_core_tcb, Round 1)

  • Identity: multi:8b73d98158e8fe0863777855ca01f4c4721d0364:b37e03a1884391424cda099c4ae0fe413da9bcf3 (base=8b73d98158e8, head=b37e03a18843, tree=26f2a448b1a7)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 8 inspected, 0 inapplicable, 0 blocked (of 8 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking tcb_and_api_critic completed findings 2 585s
seat2 gemini-frontier-thinking tcb_and_spec_critic completed findings 7 1268s
seat3 gemini-executable-falsifier sandboxed_probe_runner completed findings 5 2838s

Deduplicated Findings

ID Sev Consensus Verification Location Summary
G2-R1-01 P1 3 (seat1, seat2, seat3) probe_confirmed trusted/rustc-capture/src/family/lean_emit.rs:49 Open trust question: the trusted capture emitter generates bodyOf_ declarations typed by Anneal.Generics.GenArgs and hyp_ conjuncts built from 0-TCB theory definitions (ProgramWfV2, copyOkV2, sizedV2, reprCLayout, ReprTransparentOk, x86_64Profile), with no documented trust role. It is safe only while every trusted claim requires concrete hypothesis discharge; the parity design suggests family bodies may later be placed in trusted programs.
G2-R1-02 P1 3 (seat1, seat2, seat3) probe_confirmed trusted/rustc-capture/src/family/lower.rs:978 Public family-capture entry points (lower_family, extract_closed_gen_args, and parity::extract_concrete_body) skip the crate-level admission guards that concrete capture runs before lowering: no tcx.dcx().has_errors() check and no verify_sysroot_only_crates check, even though the module's own alloc-path helpers trust any external crate named alloc.
G2-R1-03 P1 1 (seat3) probe_confirmed trusted/rustc-capture/src/family/lower.rs:932 Closed core::mem::size_of::() lowering checks v2_layout() against rustc layout_of but omits is_sized() and is_supported_v2_local(), accepting types rejected by concrete capture and Lean CoreDispatchV2.
G2-R1-04 P2 2 (seat2, seat3) static_verified trusted/rustc-capture/src/family/lower.rs:550 lower_rvalue silently desugars mir::Rvalue::CopyForDeref into FamilyRvalue::Use instead of failing closed, violating the 1:1 Runtime(PostCleanup) capture contract.
G2-R1-05 P2 2 (seat2, seat3) probe_confirmed trusted/rustc-capture/src/family/parity.rs:183 Parity tripwire normalization erases UnwindAction and type identity on CoreCallOp::MemSizeOf (masking constant-folding and unwind/type bugs), and extract_concrete_body passes an empty local-callee map.
G2-R1-06 P2 1 (seat2) static_verified tests/rustc-capture/tests/family_capture.rs:780 Non-prebuilt Lean compilation fallback in prepare_lean_oleans_paths omits the 7 Trusted/MirSemantics/Step/* submodules present in target_base, breaking lean_elaboration_and_type0_level_params.
G2-R1-07 P2 1 (seat2) static_verified tests/rustc-capture/tests/family_capture.rs:991 Negative Canary #15 (check_dup_canary15_mut_ref_rejected) is vacuous with respect to family capture and hyp_dup emission.
G2-R1-08 P2 1 (seat2) static_verified trusted/rustc-capture/src/family/lower.rs:1714 u128 const generic parameters are admitted by FamilySchema and Lean hyp (0..2^128) but fail closed for values >= 2^127 because FamilyGenArgs.consts stores i128.

G2-R1-01 [P1] (trusted/rustc-capture/src/family/lean_emit.rs:49, Pass 2 §2 (trusted/rustc-capture), probe_confirmed): Open trust question: the trusted capture emitter generates bodyOf_ declarations typed by Anneal.Generics.GenArgs and hyp_ conjuncts built from 0-TCB theory definitions (ProgramWfV2, copyOkV2, sizedV2, reprCLayout, ReprTransparentOk, x86_64Profile), with no documented trust role. It is safe only while every trusted claim requires concrete hypothesis discharge; the parity design suggests family bodies may later be placed in trusted programs.

  • Invariant: Statement-origin separation (verification statements and public types reference only Init.* and Trusted., never Anneal.); capture emission must not let untrusted definitions alter the trusted theorem; two-surface completeness (no unlogged assumptions); docs must be updated for new TCB surfaces.
  • Evidence: lean_emit.rs:45-50 emits public import Anneal.Generics.ClaimShape and public import Anneal.Generics.SymTy. lean_emit.rs:82 emits def bodyOf_<slug> (a : Anneal.Generics.GenArgs) : Trusted.MirAst.Body. lean_emit.rs:94-109, 141-175 and 221-265 build hyp_ from Anneal.Generics definitions whose meaning theory/ controls (e.g. if sizedV2 were redefined to be false, hyp_ becomes vacuous). Today this is contained only because Anneal.Generics.universal_instantiate requires proving hyp at a concrete instance and the concrete trusted claim remains BodyVerifiedV2 over captured bodies. However, the family bodies deliberately keep .useRetag and open MemSizeOf, while concrete capture emits .use and folds size_of (the parity 'ratified normalizations'). So they are never definitionally equal to captured bodies, and transfer requires either a theory equivalence proof or placing family bodies directly in trusted programs. In the latter case trusted claims would depend on Anneal.* definitions. Neither the commit body nor docs/trust-model.md or docs/architecture.md (unchanged) states which design is intended, or that these artifacts must never be admitted as trusted claim components. Resolving check: maintainer disposition documenting the trust role, plus a guard or doc stating that family emission output is theory-only input.

G2-R1-02 [P1] (trusted/rustc-capture/src/family/lower.rs:978, Pass 2 §2 (trusted/rustc-capture), probe_confirmed): Public family-capture entry points (lower_family, extract_closed_gen_args, and parity::extract_concrete_body) skip the crate-level admission guards that concrete capture runs before lowering: no tcx.dcx().has_errors() check and no verify_sysroot_only_crates check, even though the module's own alloc-path helpers trust any external crate named alloc.

  • Invariant: Pass 2 §2: trusted/rustc-capture must fail closed on compiler errors (tcx.dcx().has_errors()) and on unauthenticated sysroot substitutions; path-based sysroot identification is sound only after verify_sysroot_only_crates (documented on extract::calls::core_or_alloc_def_path).
  • Evidence: Concrete capture: capture/lowering.rs collect checks tcx.dcx().has_errors() and then runs verify_session_sysroot, verify_sysroot_only_crates, panic-strategy agreement, check_no_cfg_miri, crate-local lang-item and custom-allocator checks before any lowering. lower_family (lower.rs:978-1047) checks only mir_preserve_ub, target data layout, features, ergonomic_clones, and the lowered body's own tainted_by_errors. That misses errors elsewhere in the crate, for example in callee or struct definitions used by layout_of. extract_closed_gen_args (lower.rs:1161) and extract_concrete_body (parity.rs:36) have no guards at all. lower.rs:2043 is_sysroot_alloc_path and lower.rs:2049 core_or_alloc_def_path accept any non-local crate named alloc. The concrete equivalent documents that this is sound only because verify_sysroot_only_crates already ran, and nothing in the family path establishes that. Any future driver or tool calling these public APIs outside the guarded concrete pipeline could therefore lower bodies from an errored session, or model a non-sysroot alloc::vec::Vec or alloc::boxed::Box as the real sysroot type. Currently latent: only tests call these APIs, and the test harness checks has_errors itself.

G2-R1-03 [P1] (trusted/rustc-capture/src/family/lower.rs:932, Pass 2 §2 (trusted/rustc-capture), probe_confirmed): Closed core::mem::size_of::() lowering checks v2_layout() against rustc layout_of but omits is_sized() and is_supported_v2_local(), accepting types rejected by concrete capture and Lean CoreDispatchV2.

  • Evidence: lower.rs:932-953 omits closed.is_sized() and closed.is_supported_v2_local() checks present in trusted/rustc-capture/src/extract/calls.rs:558-564 and Lean execCoreCallOp's .memSizeOf arm (Step.lean / CoreDispatchV2.lean:348-351: !isSupportedV2LocalTy ty => .error .unsupported), and BodyStaticAdmittedV2 does not inspect MemSizeOf's type arg. Sandboxed rustc_private probe confirmed &mut &mut u32, *const Vec, and [&u32; 2] lower cleanly as closed types with matching layouts (8,3)/(16,3) even though is_supported_v2_local() is false for all three.

G2-R1-04 [P2] (trusted/rustc-capture/src/family/lower.rs:550, Pass 2 §2 (trusted/rustc-capture), static_verified): lower_rvalue silently desugars mir::Rvalue::CopyForDeref into FamilyRvalue::Use instead of failing closed, violating the 1:1 Runtime(PostCleanup) capture contract.

  • Invariant: AGENTS.md:259-263 and skills/trust-review/SKILL.md:209-215 forbid semantic normalization/desugaring in trusted/rustc-capture/ and require hard errors on unsupported MIR rvalues; Trusted.MirAst.Rvalues:296-298 and extract/rvalues.rs:948 treat CopyForDeref as unsupported.
  • Evidence: lower.rs:549-558 rewrites mir::Rvalue::CopyForDeref(p) into FamilyRvalue::Use { operand: Copy/CopyPlace(p), with_retag: false } (backed by a synthetic unit test at lower.rs:2387-2432). By contrast, concrete capture rejects CopyForDeref with Err at trusted/rustc-capture/src/extract/rvalues.rs:948, and Trusted/MirAst/Rvalues.lean:296-298 explicitly classifies CopyForDeref as .unsupported. Additionally, check_nested_mut_ref_copies (lower.rs:1786) inspects only mir::Rvalue::Use(mir::Operand::Copy(_), _), so CopyForDeref would bypass that guard if ever present.

G2-R1-05 [P2] (trusted/rustc-capture/src/family/parity.rs:183, Pass 2 §2 (trusted/rustc-capture), probe_confirmed): Parity tripwire normalization erases UnwindAction and type identity on CoreCallOp::MemSizeOf (masking constant-folding and unwind/type bugs), and extract_concrete_body passes an empty local-callee map.

  • Invariant: AGENTS.md:259-264 and family/parity.rs:15-19 require parity verification to fail closed on any structural difference outside ratified normalizations, and family/lower.rs:18-19,931 forbids folding core::mem::size_of::().
  • Evidence: normalize_blocks (parity.rs:183-211) rewrites ir::Terminator::CoreCall { op: CoreCallOp::MemSizeOf { ty }, args, dst, target: Some(bb), unwind: _ } into Assign(dst, Scalar(size)) + Goto { block: *bb }. Dropping unwind: _ lets a family lowering with wrong UnwindAction (e.g., Continue vs Unreachable vs Terminate) pass compare_normalized_bodies silently; collapsing ty to byte size and rewriting to Assign + Goto masks both wrong same-sized type arguments (e.g., u32 vs i32 or [u8; 4]) and forbidden constant-folding of size_of::() into Assign + Goto. Separately, extract_concrete_body (parity.rs:53) passes &BTreeMap::new() to extracted.resolve(...), causing parity extraction to fail on any family that invokes a local callee (CalleeSlot).

G2-R1-06 [P2] (tests/rustc-capture/tests/family_capture.rs:780, Target Spec (L6), static_verified): Non-prebuilt Lean compilation fallback in prepare_lean_oleans_paths omits the 7 Trusted/MirSemantics/Step/* submodules present in target_base, breaking lean_elaboration_and_type0_level_params.

  • Invariant: Integration tests must compile cleanly against target_base (8b73d98) both with and without prebuilt .olean artifacts.
  • Evidence: Between merge_base (4ad81da) and target_base (8b73d98), trusted/lean/Trusted/MirSemantics/Step.lean was split into a barrel importing Step/{V1Core,PlacesV2,CoreDispatchV2,RvaluesV2,AssignV2,CallsTermV2,EvalStep}. When trusted_prebuilt is None, prepare_lean_oleans_paths (family_capture.rs:779-808) compiles "Trusted/MirSemantics/Step" at line 800 without first compiling those 7 submodules, causing Lean elaboration to fail.

G2-R1-07 [P2] (tests/rustc-capture/tests/family_capture.rs:991, Target Spec (L6), static_verified): Negative Canary #15 (check_dup_canary15_mut_ref_rejected) is vacuous with respect to family capture and hyp_dup emission.

  • Invariant: Negative canaries must fail if the guarded capture/emission check is removed (skills/trust-review/SKILL.md anti-vacuity requirement).
  • Evidence: family_capture.rs:991-992 defines theorem check_dup_canary15_mut_ref_rejected : Anneal.Generics.copyOkV2 (.ref .mut (.int .i32 true)) = false := rfl, which evaluates the theory predicate in isolation and never mentions hyp_dup or genArgs_dup. Deleting BuiltinHyp::CopyOk extraction (hypotheses.rs:124-137) or emission (lean_emit.rs:104-107) still leaves check_dup_canary15_mut_ref_rejected green. Contrast check_const_surrogate_rejected (family_capture.rs:994-1001), which properly proves ¬ hyp_const_echo ....

G2-R1-08 [P2] (trusted/rustc-capture/src/family/lower.rs:1714, Pass 2 §2 (trusted/rustc-capture), static_verified): u128 const generic parameters are admitted by FamilySchema and Lean hyp (0..2^128) but fail closed for values >= 2^127 because FamilyGenArgs.consts stores i128.

  • Invariant: Schema admission, Lean hypothesis domain bounds, and concrete GenArgs extraction must agree on the admitted const parameter value range.
  • Evidence: classify_const_param_ty (lower.rs:1714-1717) admits ty::UintTy::U128 and lean_emit.rs:133-136 emits domain predicate (0 : Int) <= c < 2^128 over Lean Int, but FamilyGenArgs.consts is typed as Vec (ir.rs:175), so extract_const_i128 (lower.rs:1750-1751) rejects every u128 constant in [2^127, 2^128 - 1] with "unsigned const arg exceeds i128::MAX".

Non-blocking advisories (P3, not Gate 2 findings)

These notes do not block merge and do not require another Gate 2 round.

  • G2-R1-A01 [P3] (tests/rustc-capture/tests/family_capture.rs:1078): Families over generic structs (Wrapper, zerocopy ReadOnly) get no instance-parity check, because concrete capture cannot extract those instances. The test named real_zerocopy_wrappers_family_capture_and_parity checks parity only for must_use, and silently passes when the zerocopy source is absent.
  • G2-R1-A02 [P3] (trusted/rustc-capture/src/family/ir.rs:229): Many family IR variants are never produced by lowering but are still instantiated and rendered in TCB code: FamilyTy::Option and Range*, FamilyRvalue::AggregateOption, AggregateRange* and AggregateOrdering, and FamilyCoreCallOp::OptionIsSome, OptionIsNone, OptionTake, OptionUnwrap, DefaultVal, ScalarClone and ArrayEq.
  • G2-R1-A03 [P3] (trusted/rustc-capture/src/family/ir.rs:415): Unconstructed FamilyRvalue, FamilyCoreCallOp, and StructReprKind::ReprCPacked variants add dead code to trusted/rustc-capture.
  • G2-R1-A04 [P3] (trusted/rustc-capture/src/family/lean_emit.rs:77): Non-URL doc comment line exceeds 80 columns (91 characters).
  • G2-R1-A05 [P3] (trusted/rustc-capture/src/family/lower.rs:258): Option lang-item check uses unwrap_or(adt.did()), which tautologically matches when option_type() is None.
  • G2-R1-A06 [P3] (trusted/rustc-capture/src/family/lower.rs:782): Duplicated upstream rustc workaround guards (-Zmir-preserve-ub, ergonomic_clones, CallSource::Use) omit RUSTC-WORKAROUND(#NNNN) tracking anchors.
  • G2-R1-A07 [P3] (trusted/rustc-capture/src/family/lower.rs:1765): Several TCB helpers are duplicated from concrete capture (check_nested_mut_ref_copies, core_or_alloc_def_path, rodata and scalar constant decoders), and lean_emit.rs adds a second Lean MirTy printer, so future fixes to one copy will not reach the other.
  • G2-R1-A08 [P3] (trusted/rustc-capture/src/family/lower.rs:2390): Unit test invokes rustc_driver with Options::default() without explicit sysroot resolution.
  • G2-R1-A09 [P3] (trusted/rustc-capture/src/lib.rs:1): Diff in trusted/rustc-capture/src/lib.rs includes unrelated rustfmt reformatting outside the pub mod family; addition.

Executed Sandbox Probes

  • seat3 bwrap sha256sum --check --strict trusted/root-manifest.sha256 + python3 contract_audit.py CHECK 6 + git ls-tree / git diff --check: outcome=pass (rc=0)
  • seat3 bwrap python3 symbol & constructor scan across lean_emit.rs, Trusted/MirAst/*.lean, and theory/Anneal/Generics/*.lean: outcome=pass (rc=0)
  • seat3 bwrap rustc_private probe.rs on t1.rs (bool/u8/i32 const generics, sibling block fn/struct disambiguators): outcome=pass (rc=0)
  • seat3 bwrap rustc_private pred_probe.rs on t_pred.rs + layout_of on Align16Zst #[repr(C)] structs: outcome=pass (rc=0)
  • seat3 bwrap rustc_private adv_probe.rs on spoof_alloc (--extern alloc=liballoc.rlib), t_adv_cases (Location::caller() const), t_dead (#![deny(dead_code)]), and probe2.rs (-Copt-level=3 -Zmir-opt-level=3 -Cdebug-assertions=yes --cfg miri): outcome=defect_confirmed (rc=0)
  • seat3 bwrap rustc probe_ns_inj.rs + contract_audit.py CHECK 1: outcome=defect_confirmed (rc=0)
  • seat3 bwrap rustc_private adv_probe.rs on closed_size_of_unadmitted + contract_audit.py CHECK 2: outcome=defect_confirmed (rc=0)
  • seat3 bwrap rustc probe_parity_mask.rs + contract_audit.py CHECK 3: outcome=defect_confirmed (rc=0)
  • seat3 bwrap python3 contract_audit.py CHECK 4 + rustc_private probe2.rs Deref snippets: outcome=defect_confirmed (rc=0)
  • seat3 bwrap cargo test --offline on standalone rustc-capture manifest copy: outcome=blocked (rc=101)
  • seat3 git merge-tree --write-tree 8b73d98158e8fe0863777855ca01f4c4721d0364 b37e03a1884391424cda099c4ae0fe413da9bcf3: outcome=pass (rc=0)
  • seat3 Static scope check over pr_meta.json complete changed files (8 files): outcome=inapplicable (rc=0)

public import Trusted.MirAst\n\
public import Trusted.MirAst.TargetProfile\n\
public import Trusted.MirSemantics\n\
public import Anneal.Generics.ClaimShape\n\

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

G2-R1-01 [P1] (probe_confirmed): Open trust question: the trusted capture emitter generates bodyOf_ declarations typed by Anneal.Generics.GenArgs and hyp_ conjuncts built from 0-TCB theory definitions (ProgramWfV2, copyOkV2, sizedV2, reprCLayout, ReprTransparentOk, x86_64Profile), with no documented trust role. It is safe only while every trusted claim requires concrete hypothesis discharge; the parity design suggests family bodies may later be placed in trusted programs.

lean_emit.rs:45-50 emits public import Anneal.Generics.ClaimShape and public import Anneal.Generics.SymTy. lean_emit.rs:82 emits def bodyOf_<slug> (a : Anneal.Generics.GenArgs) : Trusted.MirAst.Body. lean_emit.rs:94-109, 141-175 and 221-265 build hyp_ from Anneal.Generics definitions whose meaning theory/ controls (e.g. if sizedV2 were redefined to be false, hyp_ becomes vacuous). Today this is contained only because Anneal.Generics.universal_instantiate requires proving hyp at a concrete instance and the concrete trusted claim remains BodyVerifiedV2 over captured bodies. However, the family bodies deliberately keep .useRetag and open MemSizeOf, while concrete capture emits .use and folds size_of (the parity 'ratified normalizations'). So they are never definitionally equal to captured bodies, and transfer requires either a theory equivalence proof or placing family bodies directly in trusted programs. In the latter case trusted claims would depend on Anneal.* definitions. Neither the commit body nor docs/trust-model.md or docs/architecture.md (unchanged) states which design is intended, or that these artifacts must never be admitted as trusted claim components. Resolving check: maintainer disposition documenting the trust role, plus a guard or doc stating that family emission output is theory-only input.

.iter()
.map(|stmt| normalize_statement(local_tys, stmt))
.collect::<Result<Vec<_>, _>>()?;
let term = match &blk.terminator {

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

G2-R1-05 [P2] (probe_confirmed): Parity tripwire normalization erases UnwindAction and type identity on CoreCallOp::MemSizeOf (masking constant-folding and unwind/type bugs), and extract_concrete_body passes an empty local-callee map.

normalize_blocks (parity.rs:183-211) rewrites ir::Terminator::CoreCall { op: CoreCallOp::MemSizeOf { ty }, args, dst, target: Some(bb), unwind: _ } into Assign(dst, Scalar(size)) + Goto { block: *bb }. Dropping unwind: _ lets a family lowering with wrong UnwindAction (e.g., Continue vs Unreachable vs Terminate) pass compare_normalized_bodies silently; collapsing ty to byte size and rewriting to Assign + Goto masks both wrong same-sized type arguments (e.g., u32 vs i32 or [u8; 4]) and forbidden constant-folding of size_of::() into Assign + Goto. Separately, extract_concrete_body (parity.rs:53) passes &BTreeMap::new() to extracted.resolve(...), causing parity extraction to fail on any family that invokes a local callee (CalleeSlot).

lean_paths.iter().map(|p| p.to_string_lossy().into_owned()).collect::<Vec<_>>().join(":");

if trusted_prebuilt.is_none() {
let trusted_root = repo_root.join("trusted/lean");

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

G2-R1-06 [P2] (static_verified): Non-prebuilt Lean compilation fallback in prepare_lean_oleans_paths omits the 7 Trusted/MirSemantics/Step/* submodules present in target_base, breaking lean_elaboration_and_type0_level_params.

Between merge_base (4ad81da) and target_base (8b73d98), trusted/lean/Trusted/MirSemantics/Step.lean was split into a barrel importing Step/{V1Core,PlacesV2,CoreDispatchV2,RvaluesV2,AssignV2,CallsTermV2,EvalStep}. When trusted_prebuilt is None, prepare_lean_oleans_paths (family_capture.rs:779-808) compiles "Trusted/MirSemantics/Step" at line 800 without first compiling those 7 submodules, causing Lean elaboration to fail.

| zero => exact False.elim (hj rfl)
| succ _ => nomatch hF

theorem check_dup_canary15_mut_ref_rejected :

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

G2-R1-07 [P2] (static_verified): Negative Canary #15 (check_dup_canary15_mut_ref_rejected) is vacuous with respect to family capture and hyp_dup emission.

family_capture.rs:991-992 defines theorem check_dup_canary15_mut_ref_rejected : Anneal.Generics.copyOkV2 (.ref .mut (.int .i32 true)) = false := rfl, which evaluates the theory predicate in isolation and never mentions hyp_dup or genArgs_dup. Deleting BuiltinHyp::CopyOk extraction (hypotheses.rs:124-137) or emission (lean_emit.rs:104-107) still leaves check_dup_canary15_mut_ref_rejected green. Contrast check_const_surrogate_rejected (family_capture.rs:994-1001), which properly proves ¬ hyp_const_echo ....

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.

1 participant