Description
Spike #371 (tests/spike/010_mvl_refinements/) concluded: rust-refine
(mvl-lang/mvl-rust) works and makes sense to adopt for runtime-enforced
contracts today. Across 6 rounds against successive releases, 5 real
upstream defects were found and fixed same-day by the maintainer. A
DatabaseHeader::parse-shaped postcondition now discharges 3 of 4
obligations at compile-time (L1), plus one pure-arithmetic proof at L4 —
the 4th falls back to a real assert! at every return path, which is
strictly stronger than today's unenforced doc comments.
This ticket adopts that pattern in production, scoped to exactly two
pilot files — not wider, until this closes and is reviewed.
Scope
src/header.rs — DatabaseHeader::parse and usable_page_size,
using the corrected, already-proven annotations from the spike's
src/lib.rs (not the issue's original, syntactically-invalid target
annotation).
src/record/varint.rs — decode_varint: the loop bound 0..8
(already informally documented via
#[allow(clippy::arithmetic_side_effects, reason = "i ranges over the compile-time-constant 0..8, so i + 1 never overflows")]) and the
returned length's 1..=9 range.
Plus:
- Add the
mvl git dependency, pinned to the same rev the spike crate
uses (tests/spike/010_mvl_refinements/Cargo.toml, currently v0.8.0 /
3e3ade7).
deny.toml: allow-git entry for mvl-lang/mvl-rust.
- CI: a build-from-git step for
cargo-mvl, mirroring the existing
mvl-limit gate's pattern in .github/workflows/ci.yml.
Complexity
Estimate: small
Reasoning: Both target functions and their annotations already
exist, verified working, in the spike crate — this is porting proven
annotations into production files plus routine dependency/CI wiring,
not new exploration. Two files only.
Context
See tests/spike/010_mvl_refinements/README.md for the full verdict and
findings.md for the round-by-round evidence. The spike crate stays in
place as the reference implementation — do not delete it when this
ticket lands.
Refs: 010_mvl_refinements spike, #371
Acceptance Criteria
Additional Notes
Not gated on full static proof — parse's 4th obligation stays
runtime-only pending a not-yet-filed upstream gap (same-function
return-site method-call reasoning, distinct from #110). That's fine:
the runtime-enforcement value is unconditional and doesn't need it.
Description
Spike #371 (
tests/spike/010_mvl_refinements/) concluded:rust-refine(mvl-lang/mvl-rust) works and makes sense to adopt for runtime-enforced
contracts today. Across 6 rounds against successive releases, 5 real
upstream defects were found and fixed same-day by the maintainer. A
DatabaseHeader::parse-shaped postcondition now discharges 3 of 4obligations at compile-time (L1), plus one pure-arithmetic proof at L4 —
the 4th falls back to a real
assert!at every return path, which isstrictly stronger than today's unenforced doc comments.
This ticket adopts that pattern in production, scoped to exactly two
pilot files — not wider, until this closes and is reviewed.
Scope
src/header.rs—DatabaseHeader::parseandusable_page_size,using the corrected, already-proven annotations from the spike's
src/lib.rs(not the issue's original, syntactically-invalid targetannotation).
src/record/varint.rs—decode_varint: the loop bound0..8(already informally documented via
#[allow(clippy::arithmetic_side_effects, reason = "i ranges over the compile-time-constant 0..8, so i + 1 never overflows")]) and thereturned length's
1..=9range.Plus:
mvlgit dependency, pinned to the same rev the spike crateuses (
tests/spike/010_mvl_refinements/Cargo.toml, currently v0.8.0 /3e3ade7).deny.toml:allow-gitentry formvl-lang/mvl-rust.cargo-mvl, mirroring the existingmvl-limitgate's pattern in.github/workflows/ci.yml.Complexity
Estimate: small
Reasoning: Both target functions and their annotations already
exist, verified working, in the spike crate — this is porting proven
annotations into production files plus routine dependency/CI wiring,
not new exploration. Two files only.
Context
See
tests/spike/010_mvl_refinements/README.mdfor the full verdict andfindings.mdfor the round-by-round evidence. The spike crate stays inplace as the reference implementation — do not delete it when this
ticket lands.
Refs: 010_mvl_refinements spike, #371
Acceptance Criteria
mvldependency added, pinned,deny.tomlupdatedDatabaseHeader::parse/usable_page_sizeannotated per the spike'sproven form;
cargo mvl prove src/header.rsoutput recorded in thePR description
decode_varintannotated;cargo mvl prove src/record/varint.rsoutput recorded in the PR description
cargo-mvlfrom the pinned rev, same pattern asmvl-limitunit_header/unit_record(or equivalent varint) testsstill pass with the runtime
assert!injections livecargo clippy --all-targets/cargo fmt --checkcleanAdditional Notes
Not gated on full static proof —
parse's 4th obligation staysruntime-only pending a not-yet-filed upstream gap (same-functionreturn-site method-call reasoning, distinct from #110). That's fine:
the runtime-enforcement value is unconditional and doesn't need it.