Repository navigation
Conversation
Previously, Trusted.MirSemantics kept every live local as an immediate
value (LocalSlot.live) and had no memory model, so it could not
represent a local whose bytes live in a stack allocation. rustc and
lean-miri move a local into memory (force_allocation) as soon as a
place expression needs its address, and the projections, references,
and calls that later PRs admit all depend on that representation.
Mirror lean-miri's LocalValue one constructor to one constructor
(LocalSlot.dead | immediate | indirect), carry a deterministic
byte-level MemoryState in State, and add forceAllocation (paths below
are relative to anneal/):
- trusted/lean/Trusted/MirSemantics/Layout.lean (new): TargetEndian,
the profile-v1 byte order (big-endian, matching the data layout that
M_ref passes to lean-miri), LayoutData (size and alignment), and
layoutOfTy for the Day-1 local types (none for enums that
enumAdmitted rejects). These are M_anneal's own choices, so they sit
outside Trusted.MirAst*, which the reference evaluator may import.
- trusted/lean/Trusted/MirSemantics/Memory.lean (new): MemoryState with
a monotonic allocation-id counter (id 1 reserved for the caller-owned
return place, as in lean-miri's callMain) and per-allocation bytes,
alignment, mutability, and liveness; allocateStack, deallocateStack,
readBytes, writeBytes, and writeUninit with rustc's liveness, bounds,
alignment, and mutability checks.
- trusted/lean/Trusted/MirSemantics/Bytes.lean (new): endian-
parameterized integer byte codec (write_target_uint /
read_target_uint), encodeVal / decodeVal for Day-1 values (decoding
through evalConstLit, which moves here so constants and memory reads
share validity checks; encodeVal rejects values that fail checkVal),
and typed loadIndirect / storeIndirect.
- trusted/lean/Trusted/{MirModel,MirSemantics/{State,Step,Enum}}.lean:
MemPlace, the three-constructor LocalSlot, State.mem, indirect reads,
writes, move deinitialization, StorageLive/StorageDead deallocation
(deallocate_local), indirect Return, and forceAllocation. As in
lean-miri, an operand's static type check (primitive readability, or
equality with the destination type) runs before an indirect local's
bytes are read or deinitialized, so an ill-typed use is unsupported
rather than UB; evalOperandToSlot takes the check as tyOk.
No profile-v1 statement forces an allocation (projections,
address-of, and calls are unsupported), so neither machine creates an
indirect local on any execution from entry. Two new locked claims keep
the new definitions exercised and cross-checked:
- CanaryMemoryLifecycleAnnealClaim (Pass 1, 19 -> 20 canaries) applies
forceAllocation between steps of concrete programs and pins, by
kernel evaluation, the allocation id, the stored big-endian bytes,
indirect reads, writes, moves, discriminant reads, and returns,
StorageLive and StorageDead deallocation (a later read through the
stale place is UB), the UB of reading uninitialized indirect bytes,
and the precedence of type checks over memory reads.
- BytesCodecMatchesMiriClaim (Pass 2, 33 -> 34 claims) proves that its
fresh lean-miri allocation exists and, for every integer width and
bit pattern, that encodeVal produces exactly the bytes lean-miri's
Allocation.writeScalar stores, that readScalar and decodeVal read the
same value back, and that uninitialized bytes are rejected by both.
SimulationInv now pins State.mem to entryMemory and slotToMiriLocalValue
lifts .indirect places to LocalValue.live (.indirect _), while
SlotMatchesTy excludes .indirect slots because they are unreachable in
both machines; the indirect lockstep proof belongs to the first PR that
makes them reachable. theory/Anneal/MirWp, theory/Anneal/PureLift/
MirBridge.lean, and correspondence/ are updated for the new State and
LocalSlot shape; all previously locked Pass 1 and Pass 2 claims keep
their statements. trusted/audit/{TrustedBoundary.lean,src/lib.rs,
tests/boundary_audit.rs} lock the two new claims with negative tests,
and docs/{trust-model,mir-correspondence-design}.md record Option 1A
and fix stale claim counts.
No trust-boundary checks or auditor allowlists are relaxed.
Agent-authored-by: AI agent acting on joshlf's behalf
|
Authored by an AI agent acting on joshlf's behalf. Review Receipt (Gate 1)
@codex review |
Codex Review Summary: ✅ CompletedThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Codex Review: Didn't find any major issues. Can't wait for the next one! Reviewed commit: ℹ️ About Codex in GitHubCodex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you
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 Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## joshlf-anneal-mir-completeness-02-exec-machine #3977 +/- ##
===============================================================================
Coverage 92.99% 92.99%
===============================================================================
Files 16 16
Lines 2469 2469
===============================================================================
Hits 2296 2296
Misses 173 173 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Authored by an AI agent acting on joshlf's behalf.
Human review surface
anneal/trusted/lean/):anneal/trusted/lean/Trusted/MirModel.lean: AddedMemPlace, Option 1A three-constructorLocalSlot(dead | immediate | indirect), andQuerymemory model alignment notes (verbatim pinnedrustcquotes).anneal/trusted/lean/Trusted/MirSemantics/Layout.lean(new,candidate:mir_semantics): Target endianness (TargetEndian), profile-v1 byte order (profileTargetEndian := .big),LayoutData,intLayout(with natural vs.lean-miriRuntimeTargetDataLayout.defaultalignment documentation), andlayoutOfTy(gating admitted enums viaenumAdmitted). Placed inTrusted.MirSemantics.*soverifyRefEvaluatorIndependencebarsM_reffrom importing or referencingM_anneallayout rules.anneal/trusted/lean/Trusted/MirSemantics/Memory.lean(new,candidate:mir_semantics): Deterministic byte-levelMemoryStatewith monotonicAllocId(id1reserved inentryMemoryfor the return place),allocateStack,deallocateStack,readBytes,writeBytes, andwriteUninitwith liveness, bounds, alignment, and mutability checks.anneal/trusted/lean/Trusted/MirSemantics/Bytes.lean(new,candidate:mir_semantics): Endian-parameterized integer byte codec (encodeUInt/decodeUInt), type-checkedencodeVal/decodeVal(gatingencodeValoncheckValand movingevalConstLithere so constant and memory reads share validity checks), and typedloadIndirect/storeIndirect/deinitIndirect.anneal/trusted/lean/Trusted/MirSemantics/{Enum,State,Step,CanaryFixtures}.leanandTrusted/MirSemantics.lean: ThreadedState.mem, indirect reads/writes/move deinitialization (tyOktype check before indirect memory access matchinglean-miri'sOperandMachine.evalOperand->MemoryOperand.readImmediate/Place.copyRuntimePlaceNoValidatefault precedence),StorageLive/StorageDeadstack deallocation, indirectReturn,forceAllocation, and new lockedCanaryMemoryLifecycleAnnealClaim(Pass 1 canaries 19 -> 20).anneal/trusted/correspondence/):anneal/trusted/correspondence/Trusted/Correspondence/{State,Simulation,CanaryFixtures}.leanandTrusted/Correspondence.lean: Mapped.indirectinslotToMiriLocalValue, pinneds.mem = entryMemoryinSimulationInv(excluding.indirectfromSlotMatchesTy, as.indirectis unreachable in profile v1 on both machines), and added lockedBytesCodecMatchesMiriClaim(Pass 2 claims 33 -> 34) with an explicit∃ rawAlloc, Allocation.tryNew ... = .ok rawAllocanti-vacuity witness cross-checkingencodeVal/decodeValagainstMiri.Memory.Allocation.{writeScalar,readScalar,writeUninit}for.int.anneal/trusted/audit/{TrustedBoundary.lean,src/lib.rs,tests/boundary_audit.rs}):CanaryMemoryLifecycleAnnealClaim(reqConstsincl.forceAllocation,MemoryState,allocateStack,deallocateStack,loadIndirect,storeIndirect,deinitIndirect,readBytes,writeBytes,writeUninit) andBytesCodecMatchesMiriClaim(reqConstsincl.encodeVal,decodeVal,profileTargetEndian,Allocation.{writeScalar,readScalar,writeUninit}), with matching fixtures and 2 negative tests. No allowlists relaxed.anneal/docs/{trust-model,mir-correspondence-design}.md):evalOperandToSlottwo-stage fault precedence,RuntimeTargetDataLayout.default/Align.ONEalignment notes, and updated locked Pass 1/2 counts (and fixed stale vendor decl count inmir-correspondence-design.md).forceAllocationandallocateStackare reachable from the Pass 1 root set solely via the audit-lockedCanaryMemoryLifecycleAnnealClaimroot (evalStepnever calls them in profile v1).SimulationInvpinss.mem = entryMemoryand excludes.indirectslots (SlotMatchesTyrequires.immediate _, preserving soundness on all Day-1 reachable programs; indirect lockstep is deferred to PR 05 when projections/references make.indirectreachable).none(all TCB and auditor invariants are strictly preserved or strengthened).Summary
Stacks on #3972 (
joshlf-anneal-mir-completeness-02-exec-machine) to introduce Option 1A byte-level stack memory (MemoryState), target layout (Trusted.MirSemantics.Layout), endian-parameterized value byte serialization (Bytes.lean), three-constructorLocalSlot(dead | immediate | indirect), andforceAllocation(Step.lean).All 21 prior Pass 1
MirWpclaims, all 33 prior Pass 2 claims, the new Pass 1CanaryMemoryLifecycleAnnealClaim, and the new Pass 2BytesCodecMatchesMiriClaimcompile and replay cleanly underanneal-audit --require-correspondencewith zerosorry.