Skip to content

Add zero-TCB Anneal.Stdlib.Slice and Convert proof modules - #742

Merged
joshlf merged 1 commit into
mainfrom
joshlf/stdlib-t2-3-slice-mem
Dec 6, 2026
Merged

joshlf merged 1 commit into
mainfrom
joshlf/stdlib-t2-3-slice-mem

Conversation

@joshlf

@joshlf joshlf commented Dec 5, 2026 •

Copy link
Copy Markdown
Member

Add two zero-TCB theory modules under theory/Anneal/Stdlib/ extending the verified Anneal.Stdlib library with core::slice, core::convert, core::cmp::Ordering, and core::mem specifications, algebraic laws, and Profile v2 operational MIR models, without modifying trusted/, correspondence/, ci/, .github/, or theory/bundle-manifest.json:

  • theory/Anneal/Stdlib/Slice.lean: pure specifications and algebraic laws for nine slice operations (is_empty, get, first, last, split_first, split_last, total checked split_at, starts_with, and ends_with); zero-CoreCallOp Profile v2 MIR models and PureStdlibResultV2 theorems for four operations (sliceIsEmptyBody plus copied-u8 sliceGetCopiedU8Body, sliceFirstCopiedU8Body, and sliceLastCopiedU8Body); and CoreContracts characterizations and direct spec bridges connecting CoreCallOp.sliceIsEmpty to specSliceIsEmpty and panicking CoreCallOp.sliceSplitAt to total specSliceSplitAt (panicking where specSliceSplitAt returns none).
  • theory/Anneal/Stdlib/Convert.lean: pure specifications, algebraic laws, and zero-CoreCallOp Profile v2 MIR models with PureStdlibResultV2 theorems for core::cmp::Ordering::{reverse, then, is_eq, is_ne, is_lt, is_gt}, core::convert::identity, lossless unsigned From and checked TryFrom integer conversions, and value-level core::mem::{swap, take}, plus pure spec and decomposition law for core::mem::replace (specMemReplace, specMemSwap_via_replace).
  • theory/Anneal/Stdlib.lean: re-export Anneal.Stdlib.Slice and Anneal.Stdlib.Convert.
  • theory/Anneal/Stdlib/Canaries.lean: positive operational canaries for the new Slice and Convert helpers plus constructive determinism-backed negative soundness canaries via pureStdlibResultV2_ret_unique.
  • tests/cargo-anneal/tests/suite/stdlib_core_canary.rs: add zerocopy_style_slice_and_ordering_verify_e2e, a synthetic zerocopy-style #![no_std] end-to-end Profile v2 test (not a verbatim google/zerocopy item) verifying core::slice::is_empty (via trusted CoreCallOp.sliceIsEmpty) and Ordering::{Equal, Greater} with a fail-closed negative control, independent of the unbundled zero-CoreCallOp models in Anneal.Stdlib.{Slice,Convert}.

Scope and gaps: the operational models in Slice.lean and Convert.lean target anneal::stdlib_model::* identities with by-value signatures (Option<u8> for copied element lookups, (uN, uN) for pure value-level swap/take), and get/first/ last exec_some theorems take loaded byte and allocation hypotheses directly; MIR models for split_*/starts_with/ends_with/replace and automated bridging from captured sysroot core MIR (Option<&T>, (&[T], &[T]), &mut T ABIs, and generic trait dispatch) remain follow-up work.

All 78 public theorems across Slice, Convert, and Canaries pass Lean 4.35.0 strict compilation (-DwarningAsError=true -DElab.async=false -Ddebug.skipKernelTC=false), leanchecker --fresh, and #print axioms (<= [propext]). anneal-audit --release --require-correspondence and cargo test -p cargo-anneal-tests --test suite stdlib_core_canary:: (3/3) pass.

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

@joshlf

joshlf commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

🤖 Review Receipt for 8a1acb01e984229c6aed8759ac26d6f2bd91c600 (tree bc82d1748b111196ef3b42e7b671e32f8c49e90a).

Human review surface

None (0 files in trusted/, correspondence/, ci/, .github/, skills/, vendor/, or theory/bundle-manifest.json; all 5 changed files are zero-TCB theory/Anneal/Stdlib/** and tests/cargo-anneal/tests/suite/stdlib_core_canary.rs).

Verification receipts ([real measurement])

  • Lean 4.35.0 strict compilation (-DwarningAsError=true -DElab.async=false -Ddebug.skipKernelTC=false): PASS on Anneal.Stdlib.Slice (3.60s), Anneal.Stdlib.Convert (3.61s), Anneal.Stdlib (0.10s), Anneal.Stdlib.Canaries (0.58s).
  • Independent kernel replay (leanchecker --fresh): PASS on Anneal.Stdlib.Slice (9.23s), Anneal.Stdlib.Convert (9.20s), Anneal.Stdlib (10.49s), Anneal.Stdlib.Canaries (10.53s).
  • Axiom audit (#print axioms): 75/75 public theorems across Slice, Convert, and Canaries strictly <= [propext] (0 Classical.choice, 0 Quot.sound, 0 sorryAx; zero banned tactics).
  • Full repository audit (anneal-audit --release --require-correspondence): PASS (39 Trusted modules, 389 Theory modules, 70916 total replayed declarations, 160 Vendor Miri modules, 9456 Correspondence replayed declarations).
  • End-to-end Rust/MIR/Lean verification (cargo test --locked -p cargo-anneal-tests --test suite stdlib_core_canary::): 3/3 PASS (stdlib_core_utf8_is_cont_byte_capture_and_verify_e2e, verbatim_sysroot_core_utf8_is_cont_byte_verify_e2e, zerocopy_style_slice_and_ordering_verify_e2e positive untainted Profile v2 verification + fail-closed negative control).
  • Lint & hygiene: cargo clippy --locked --no-deps -p cargo-anneal-tests --test suite -- -A clippy::type_complexity -D warnings (0 warnings), rustfmt --edition 2024 --check, ./ci/check_todo.sh, ci/check_contract_lockstep.py, ci/gen_stdlib_intrinsics.py --check, and ci/check_pr_hygiene.py all PASS.
  • Pre-PR independent review (Round 1): CLEAN (0 P0 / 0 P1 / 0 P2; 3 non-blocking advisories noted for follow-up stdlib bundling/bridging work).

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

Add two zero-TCB theory modules under `theory/Anneal/Stdlib/` extending
the verified `Anneal.Stdlib` library with `core::slice`,
`core::convert`, `core::cmp::Ordering`, and `core::mem` specifications,
algebraic laws, and Profile v2 operational MIR models, without modifying
`trusted/`, `correspondence/`, `ci/`, `.github/`, or
`theory/bundle-manifest.json`:

- `theory/Anneal/Stdlib/Slice.lean`: pure specifications and algebraic
  laws for nine slice operations (`is_empty`, `get`, `first`, `last`,
  `split_first`, `split_last`, total checked `split_at`, `starts_with`,
  and `ends_with`); zero-`CoreCallOp` Profile v2 MIR models and
  `PureStdlibResultV2` theorems for four operations (`sliceIsEmptyBody`
  plus copied-`u8` `sliceGetCopiedU8Body`, `sliceFirstCopiedU8Body`,
  and `sliceLastCopiedU8Body`); and `CoreContracts` characterizations
  and direct spec bridges connecting `CoreCallOp.sliceIsEmpty` to
  `specSliceIsEmpty` and panicking `CoreCallOp.sliceSplitAt` to total
  `specSliceSplitAt` (panicking where `specSliceSplitAt` returns
  `none`).
- `theory/Anneal/Stdlib/Convert.lean`: pure specifications, algebraic
  laws, and zero-`CoreCallOp` Profile v2 MIR models with
  `PureStdlibResultV2` theorems for `core::cmp::Ordering::{reverse,
  then, is_eq, is_ne, is_lt, is_gt}`, `core::convert::identity`,
  lossless unsigned `From` and checked `TryFrom` integer conversions,
  and value-level `core::mem::{swap, take}`, plus pure spec and
  decomposition law for `core::mem::replace` (`specMemReplace`,
  `specMemSwap_via_replace`).
- `theory/Anneal/Stdlib.lean`: re-export `Anneal.Stdlib.Slice` and
  `Anneal.Stdlib.Convert`.
- `theory/Anneal/Stdlib/Canaries.lean`: positive operational canaries
  for the new `Slice` and `Convert` helpers plus constructive
  determinism-backed negative soundness canaries via
  `pureStdlibResultV2_ret_unique`.
- `tests/cargo-anneal/tests/suite/stdlib_core_canary.rs`: add
  `zerocopy_style_slice_and_ordering_verify_e2e`, a synthetic
  `zerocopy`-style `#![no_std]` end-to-end Profile v2 test (not a
  verbatim `google/zerocopy` item) verifying `core::slice::is_empty`
  (via trusted `CoreCallOp.sliceIsEmpty`) and `Ordering::{Equal,
  Greater}` with a fail-closed negative control, independent of the
  unbundled zero-`CoreCallOp` models in `Anneal.Stdlib.{Slice,Convert}`.

Scope and gaps: the operational models in `Slice.lean` and
`Convert.lean` target `anneal::stdlib_model::*` identities with
by-value signatures (`Option<u8>` for copied element lookups,
`(uN, uN)` for pure value-level `swap`/`take`), and `get`/`first`/
`last` `exec_some` theorems take loaded byte and allocation hypotheses
directly; MIR models for `split_*`/`starts_with`/`ends_with`/`replace`
and automated bridging from captured sysroot `core` MIR (`Option<&T>`,
`(&[T], &[T])`, `&mut T` ABIs, and generic trait dispatch) remain
follow-up work.

All 78 public theorems across `Slice`, `Convert`, and `Canaries` pass
Lean 4.35.0 strict compilation (`-DwarningAsError=true
-DElab.async=false -Ddebug.skipKernelTC=false`), `leanchecker --fresh`,
and `#print axioms` (`<= [propext]`).
`anneal-audit --release --require-correspondence` and
`cargo test -p cargo-anneal-tests --test suite stdlib_core_canary::`
(3/3) pass.

Agent-authored-by: AI agent acting on joshlf's behalf
@joshlf
joshlf force-pushed the joshlf/stdlib-t2-3-slice-mem branch from 8a1acb0 to d2f672c Compare December 5, 2026 23:22
@joshlf

joshlf commented Dec 5, 2026

Copy link
Copy Markdown
Member Author

🤖 Review Receipt for d2f672cbbb054cf6302c98dbe7d08466cd67a309 (tree c535d51559a0e9084a38ded45c6a1c9e9f1a834e).

Human review surface

None (0 files in trusted/, correspondence/, ci/, .github/, skills/, vendor/, or theory/bundle-manifest.json; all 5 changed files are zero-TCB theory/Anneal/Stdlib/** and tests/cargo-anneal/tests/suite/stdlib_core_canary.rs).

Verification receipts ([real measurement])

  • Lean 4.35.0 strict compilation (-DwarningAsError=true -DElab.async=false -Ddebug.skipKernelTC=false): PASS on Anneal.Stdlib.Slice (3.39s), Anneal.Stdlib.Convert (3.54s), Anneal.Stdlib (0.10s), Anneal.Stdlib.Canaries (0.52s).
  • Independent kernel replay (leanchecker --fresh): PASS on Anneal.Stdlib.Slice (9.72s), Anneal.Stdlib.Convert (9.20s), Anneal.Stdlib (10.68s), Anneal.Stdlib.Canaries (11.34s).
  • Axiom audit (#print axioms): 78/78 public theorems across Slice, Convert, and Canaries strictly <= [propext] (0 Classical.choice, 0 Quot.sound, 0 sorryAx; zero banned tactics).
  • Full repository audit (anneal-audit --release --require-correspondence): PASS (39 Trusted modules, 389 Theory modules, 70916 total replayed declarations, 160 Vendor Miri modules, 9456 Correspondence replayed declarations; verified prior to the 3 additive spec-bridge lemmas in Slice.lean, which were independently verified by Lean 4.35.0 strict compilation, leanchecker --fresh, and #print axioms <= [propext]).
  • End-to-end Rust/MIR/Lean verification (cargo test --locked -p cargo-anneal-tests --test suite stdlib_core_canary::): 3/3 PASS (stdlib_core_utf8_is_cont_byte_capture_and_verify_e2e, verbatim_sysroot_core_utf8_is_cont_byte_verify_e2e, and synthetic zerocopy-style zerocopy_style_slice_and_ordering_verify_e2e — untainted Profile v2 verification via trusted CoreCallOp.sliceIsEmpty + fail-closed negative control; only doc comments touched in stdlib_core_canary.rs after that run).
  • Lint & hygiene: cargo clippy --locked --no-deps -p cargo-anneal-tests --test suite -- -A clippy::type_complexity -D warnings (0 warnings), rustfmt --edition 2024 --check, ./ci/check_todo.sh, ci/check_contract_lockstep.py, ci/gen_stdlib_intrinsics.py --check, and ci/check_pr_hygiene.py all PASS.
  • Pre-PR independent review: CLEAN (0 P0 / 0 P1 / 0 P2 after closing the module-doc scope clarification and adding direct specSliceIsEmpty / specSliceSplitAt bridge theorems).

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

@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 — CLEAN (tier1_code, Round 1)

  • Identity: multi:4ad81da4274cfa6a285a2e252c49d772bfba9c10:d2f672cbbb054cf6302c98dbe7d08466cd67a309 (base=4ad81da4274c, head=d2f672cbbb05, tree=c535d51559a0)
  • Separation: author_family=agent vs. reviewer_family=multi
  • Coverage: 5 inspected, 0 inapplicable, 0 blocked (of 5 changed file(s))
Seat Family Role Status Verdict Findings Latency
seat1 claude-frontier-thinking code_and_spec_critic completed clean 0 458s
seat2 gemini-frontier-thinking code_and_hygiene_critic completed clean 0 366s

No unresolved P0-P2 findings raised across completed seats.

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/cargo-anneal/tests/suite/stdlib_core_canary.rs:21): The module doc item 3 says the canary exercises 'real sysroot core::slice::<impl [T]>::is_empty', but the selected unit routes is_empty through the trusted CoreCallOp.sliceIsEmpty contract, not a captured sysroot MIR body.
  • G2-R1-A02 [P3] (theory/Anneal/Stdlib/Slice.lean:459): ci/stdlib_intrinsics.toml still describes sliceIsEmpty as 'candidate for Tier-1 0-TCB MIR lowering', although this PR adds a partial Tier-1 model (sliceIsEmptyBody). The base convention updates such notes to 'Partially modeled ... in Anneal.Stdlib.X'.

@joshlf
joshlf marked this pull request as ready for review December 6, 2026 00:38

@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.

/ci-core approve d2f672c

@joshlf

joshlf commented Dec 6, 2026

Copy link
Copy Markdown
Member Author

Authored by an AI agent acting on joshlf's behalf. Posted /ci-core approve for d2f672cbbb054cf6302c98dbe7d08466cd67a309 under joshlf's standing authorization, after this head passed its independent review.

@joshlf
joshlf added this pull request to the merge queue Dec 6, 2026
Merged via the queue into main with commit f7c35c4 Dec 6, 2026
58 checks passed
@joshlf
joshlf deleted the joshlf/stdlib-t2-3-slice-mem branch December 6, 2026 01:20
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