Commit 582bdf6
feat: Verus-style contracts with runtime debug_assert! checking (#69)
* feat: Verus-style contracts with debug_assert! runtime checking
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>
* feat: convert contracts to actual verus! {} blocks with no-op fallback
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>
---------
Co-authored-by: Claude Opus 4.6 (1M context) <noreply@anthropic.com>1 parent 41d651b commit 582bdf6
5 files changed
Lines changed: 448 additions & 17 deletions
File tree
- artifacts
- crates
- synth-backend/src
- synth-synthesis/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
12 | 12 | | |
13 | 13 | | |
14 | 14 | | |
15 | | - | |
16 | | - | |
17 | | - | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
18 | 21 | | |
19 | 22 | | |
20 | 23 | | |
| |||
122 | 125 | | |
123 | 126 | | |
124 | 127 | | |
125 | | - | |
126 | | - | |
127 | | - | |
128 | | - | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
129 | 137 | | |
130 | 138 | | |
131 | 139 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| 7 | + | |
7 | 8 | | |
8 | 9 | | |
9 | 10 | | |
| |||
1538 | 1539 | | |
1539 | 1540 | | |
1540 | 1541 | | |
1541 | | - | |
| 1542 | + | |
| 1543 | + | |
| 1544 | + | |
1542 | 1545 | | |
1543 | 1546 | | |
1544 | 1547 | | |
| |||
1631 | 1634 | | |
1632 | 1635 | | |
1633 | 1636 | | |
| 1637 | + | |
| 1638 | + | |
| 1639 | + | |
1634 | 1640 | | |
1635 | 1641 | | |
1636 | 1642 | | |
| |||
1641 | 1647 | | |
1642 | 1648 | | |
1643 | 1649 | | |
| 1650 | + | |
1644 | 1651 | | |
1645 | 1652 | | |
1646 | 1653 | | |
| |||
1649 | 1656 | | |
1650 | 1657 | | |
1651 | 1658 | | |
| 1659 | + | |
| 1660 | + | |
| 1661 | + | |
1652 | 1662 | | |
1653 | 1663 | | |
1654 | 1664 | | |
1655 | 1665 | | |
1656 | 1666 | | |
1657 | 1667 | | |
1658 | 1668 | | |
| 1669 | + | |
1659 | 1670 | | |
1660 | 1671 | | |
1661 | 1672 | | |
| |||
5832 | 5843 | | |
5833 | 5844 | | |
5834 | 5845 | | |
| 5846 | + | |
| 5847 | + | |
| 5848 | + | |
| 5849 | + | |
| 5850 | + | |
| 5851 | + | |
| 5852 | + | |
5835 | 5853 | | |
5836 | 5854 | | |
| 5855 | + | |
5837 | 5856 | | |
5838 | 5857 | | |
5839 | 5858 | | |
| |||
5848 | 5867 | | |
5849 | 5868 | | |
5850 | 5869 | | |
| 5870 | + | |
5851 | 5871 | | |
5852 | 5872 | | |
5853 | 5873 | | |
5854 | 5874 | | |
| 5875 | + | |
| 5876 | + | |
| 5877 | + | |
| 5878 | + | |
| 5879 | + | |
| 5880 | + | |
5855 | 5881 | | |
5856 | 5882 | | |
5857 | 5883 | | |
| |||
5861 | 5887 | | |
5862 | 5888 | | |
5863 | 5889 | | |
| 5890 | + | |
| 5891 | + | |
5864 | 5892 | | |
5865 | 5893 | | |
5866 | 5894 | | |
| |||
6165 | 6193 | | |
6166 | 6194 | | |
6167 | 6195 | | |
| 6196 | + | |
| 6197 | + | |
| 6198 | + | |
| 6199 | + | |
| 6200 | + | |
| 6201 | + | |
6168 | 6202 | | |
| 6203 | + | |
| 6204 | + | |
6169 | 6205 | | |
6170 | 6206 | | |
6171 | 6207 | | |
| |||
6179 | 6215 | | |
6180 | 6216 | | |
6181 | 6217 | | |
| 6218 | + | |
6182 | 6219 | | |
6183 | 6220 | | |
6184 | 6221 | | |
6185 | 6222 | | |
| 6223 | + | |
| 6224 | + | |
| 6225 | + | |
| 6226 | + | |
| 6227 | + | |
| 6228 | + | |
6186 | 6229 | | |
| 6230 | + | |
| 6231 | + | |
6187 | 6232 | | |
6188 | 6233 | | |
6189 | 6234 | | |
| |||
6197 | 6242 | | |
6198 | 6243 | | |
6199 | 6244 | | |
| 6245 | + | |
6200 | 6246 | | |
6201 | 6247 | | |
6202 | 6248 | | |
| |||
0 commit comments