Skip to content

feat: rules_verus Bazel integration + verify_contracts target#70

Merged
avrabe merged 3 commits intomainfrom
feat/verus-contracts
Mar 28, 2026
Merged

feat: rules_verus Bazel integration + verify_contracts target#70
avrabe merged 3 commits intomainfrom
feat/verus-contracts

Conversation

@avrabe
Copy link
Copy Markdown
Contributor

@avrabe avrabe commented Mar 28, 2026

Summary

  • rules_verus @ a49f72ef added to MODULE.bazel (latest — bundled sysroot, no rules_rust conflicts)
  • //crates:verify_contracts — Verus SMT verification of contracts.rs
  • //crates:contracts_plain — verus_strip output for plain Rust tooling
  • contracts.rs updated with actual verus! {} blocks + no-op fallback macro

Test plan

  • cargo test --workspace — 895 tests, 0 failures
  • cargo clippy — clean
  • bazel test //crates:verify_contracts — Verus verification (CI)

🤖 Generated with Claude Code

avrabe and others added 3 commits March 28, 2026 15:26
Formal specification contracts for synth's critical subsystems,
designed for future Verus integration via rules_verus + verus_strip.

contracts.rs — 4 specification modules:
- regalloc: reserved register exclusion (R9/R10/R11), allocation
  validation, index bounds checking
- encoding: Thumb-16/32 byte count, MOVW/MOVT imm16 range,
  register bit-field range
- memory: access size validation (1/2/4/8), bounds check with size
- division: trap guard sequence length (CMP+BNE+UDF+xDIV >= 4)

Runtime checks inserted at 13 critical sites:
- alloc_reg: pre/post allocation validation
- index_to_reg: allocatable register check
- generate_*_with_bounds_check: access_size precondition (4 sites)
- I32Div*/I32Rem* trap guard: sequence length check (4 sites)
- encode_thumb32_movw/movt: register + immediate range
- SDIV/UDIV encoding: register range + output size

9 unit tests including #[should_panic] for contract violations.
VG-001 and VG-006 status updated to in-progress.

895 tests (was 885), clippy clean, fmt clean.

Implements: VG-001
Implements: VG-006
Trace: skip

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
The contracts module now contains real Verus spec functions inside
verus! {} blocks. Three compilation modes:

1. Plain cargo: #[cfg(not(verus_keep_ghost))] no-op macro strips specs
2. Verus verification: verus! {} enables machine checking
3. verus_strip (rules_verus @ 24d5ddb5): removes blocks entirely

debug_assert! runtime checks remain alongside the formal specs.
Added #![allow(unexpected_cfgs)] for verus_keep_ghost.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Added rules_verus @ a49f72ef (latest, includes verus_strip + bundled
sysroot) to MODULE.bazel. Bazel targets:

- //crates:verify_contracts — verus_test for contracts.rs (SMT/Z3)
- //crates:contracts_plain — verus_strip output for plain Rust

rules_verus provides:
- Pre-built Verus binaries with bundled Rust nightly sysroot
- No rules_rust version conflicts (PR #8 fix)
- verus_strip for annotation removal

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
@codecov
Copy link
Copy Markdown

codecov bot commented Mar 28, 2026

Codecov Report

❌ Patch coverage is 95.55556% with 6 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/synth-synthesis/src/contracts.rs 93.47% 6 Missing ⚠️

📢 Thoughts on this report? Let us know!

@avrabe avrabe merged commit b8f03da into main Mar 28, 2026
9 checks passed
@avrabe avrabe deleted the feat/verus-contracts branch March 28, 2026 20:06
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