Skip to content

[zerocopy] Split endian and sized-DST Kani proofs - #3981

Merged
joshlf merged 1 commit into
mainfrom
joshlf-ci-perf-01-kani-harnesses
Nov 20, 2026
Merged

joshlf merged 1 commit into
mainfrom
joshlf-ci-perf-01-kani-harnesses

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

  • Kani proof harnesses (zerocopy/src/layout.rs, zerocopy/src/byteorder.rs):
    • Added any_valid_sized_dst_layout in zerocopy/src/layout.rs enforcing the exact same size <= DstLayout::MAX_SIZE and Layout::from_size_align(size, align.get()).is_ok() assumptions as the SizeInfo::Sized arm of any_valid_dst_layout, and switched prove_dst_layout_pad_to_align_sized to call it directly instead of constructing and assuming away the SizeInfo::SliceDst arm.
    • Split #[cfg_attr(kani, kani::proof)] fn test_endian in zerocopy/src/byteorder.rs under #[cfg(kani)] into test_endian_unsigned, test_endian_signed, and test_endian_float calling the shared test_endian_roundtrip helper over call_for_unsigned_types!, call_for_signed_types!, and call_for_float_types! (preserving exact 1:1 coverage across all 12 types and both endiannesses, and preserving #[cfg(test)] fn test_endian unchanged).
  • Intentional policy relaxations: none.

Summary

Bottom PR of the CI performance optimization stack.

  • Eliminates dead TrailingSliceLayout minimum-size bit-blasting in prove_dst_layout_pad_to_align_sized, cutting Kani verification time for that harness from 234.4s to 21.5s (10.9x faster).
  • Splits byteorder::tests::test_endian under #[cfg(kani)] into three per-family proofs (unsigned, signed, float), cutting peak CBMC memory from 5,251 MB to 1,865 MB (2.8x lower RSS) and reducing parallel verification latency from 129.1s to 35.0s (3.7x faster under -j 4).

Two Kani proofs in `zerocopy` construct unnecessarily large CBMC SAT
instances:

1. `layout::proofs::prove_dst_layout_pad_to_align_sized` generates an
   arbitrary `DstLayout` via `any_valid_dst_layout` and discards the
   `SizeInfo::SliceDst` variant with `kani::assume(false)`. Because
   CBMC merges control-flow paths before solving rather than pruning
   infeasible branches eagerly, it still bit-blasts the entire
   `TrailingSliceLayout` minimum-size alignment formula into CNF. Add
   `any_valid_sized_dst_layout` with the identical `SizeInfo::Sized`
   bounds (`size <= DstLayout::MAX_SIZE` and
   `Layout::from_size_align(size, align.get()).is_ok()`) and call it
   directly from `prove_dst_layout_pad_to_align_sized`.

2. `byteorder::tests::test_endian` inlines round-trip checks across all
   12 unsigned, signed, and IEEE-754 floating-point byte-order types in
   both native and non-native endianness into one harness, producing a
   single >5 GiB CBMC goto-program. Keep the unified `#[test]` entry
   point for `cargo test` and Miri, and split the `#[cfg(kani)]` proof
   into `test_endian_unsigned`, `test_endian_signed`, and
   `test_endian_float` sharing the same generic round-trip helper so
   each family is verified in an independent smaller CBMC instance.

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

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.99%. Comparing base (ec75fb4) to head (8eacd0e).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #3981   +/-   ##
=======================================
  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 commented Nov 20, 2026

Copy link
Copy Markdown
Member Author

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

Review Receipt

  1. Comparison tuple: (ec75fb464cda7b18581faa83a6a82d0dfdf422d9, ec75fb464cda7b18581faa83a6a82d0dfdf422d9, 8eacd0e8cab3d762bdfabdfebac2d509595cf90f) (main..joshlf-ci-perf-01-kani-harnesses).
  2. Risk and refinement rationale: Standard / Kani proof-harness surface (zerocopy/src/layout.rs, zerocopy/src/byteorder.rs); Pass 2 inapplicable (untouched TCB surface). Verified exact mathematical equivalence of proof assumptions and assertions before pushing.
  3. Grouped coverage:
    • zerocopy/src/layout.rs (any_valid_sized_dst_layout, prove_dst_layout_pad_to_align_sized): inspected — verified identical size <= DstLayout::MAX_SIZE and Layout::from_size_align(size, align.get()).is_ok() assumptions and unchanged postcondition assertions with zero vacuity.
    • zerocopy/src/byteorder.rs (test_endian_roundtrip, test_endian, test_endian_{unsigned,signed,float}): inspected — verified exact disjoint-union coverage of all 24 (ByteOrderType, Endianness) pairs under #[cfg(kani)] and unchanged #[cfg(test)] execution.
  4. Realized capability and isolation: Host-enforced read-only fresh-context reviewer running against clean <target_base> sources (single-family; holdouts none, pure proof-harness equivalence refactoring).
  5. Checks and probes: ./ci/check_todo.sh, ./githooks/pre-push (check_actions.sh, check_fmt.sh, check_job_dependencies.sh, check_all_toolchains_tested.sh, check_readme.sh, check_stale_stderr.sh, check_versions.sh, check_msrv_is_minimal.sh), cargo test --manifest-path zerocopy/Cargo.toml --lib -- byteorder::tests::test_endian (pass), and cargo kani across all four touched harnesses (prove_dst_layout_pad_to_align_sized, test_endian_unsigned, test_endian_signed, test_endian_float — 4/4 verified, 0 failures). Full cross-target and Miri matrices run in CI.
  6. Findings and blockers: Zero local findings; zero open trust questions; pending CI (Gate 3), Codex review (Gate 2), and human maintainer approval (Gate 5).

@joshlf
joshlf added this pull request to stack #3989 November 20, 2026 19:52
@joshlf
joshlf marked this pull request as ready for review November 20, 2026 20:05
@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:07:36.292620Z 8eacd0e 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.

@joshlf
joshlf added this pull request to the merge queue Nov 20, 2026
Merged via the queue into main with commit 7a3a28d Nov 20, 2026
123 checks passed
@joshlf
joshlf deleted the joshlf-ci-perf-01-kani-harnesses branch November 20, 2026 21:08
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