Commit 1ba8538
feat(verify): L13 region-imports codec + self-consistency pass (proposal 0003) (#154)
## Summary
Pre-stages typed-wasm **proposal 0003** (`typedwasm.region-imports`
custom section) behind a new `unstable-l13-imports` cargo feature.
Closes the verifier-pass slice of **#140** bullet 1.
- **Codec** (`section.rs`): `RegionImportEntry` / `ImportedFieldEntry`,
`parse_/build_region_imports_section_payload`, `IMPORT_TABLE_BASE` (=
`0x8000_0000`).
- **Public API** (`lib.rs`): `REGION_IMPORTS_SECTION_NAME`,
`RegionImportsError` enum (5 variants),
`verify_region_imports_from_module` entry point.
- **In-module self-consistency pass** (`verify.rs`):
- `MissingDependentRegions` — region-imports without regions (producer
obligation #1)
- `MissingDependentRegionImports` — regions has import-bit
`target_region` but no region-imports section
- `DuplicateImport` — non-unique `(producer_module_name, region_name)`
pairs
- `PointerInImportNotSupportedInV1` — v1 restriction (producer
obligation #5)
- `ImportTargetOutOfRange` — import-bit `target_region` resolves past
the import-table bounds
## Scope (deliberately partial)
This is the unblocking half of #140 bullet 1. **Out of scope:**
- Cross-module schema agreement (`SchemaSub expected actual` from
`MultiModule.idr`). Defers to a future `verify_link_graph(modules:
&[Module])` pass per proposal 0003 §"Open questions" #4 default option
a.
- Producer codegen for the new section. AffineScript and Ephapax still
emit single-module — codegen for both lands separately (AffineScript
roadmap C3 etc., proposal 0003 §"Coordination with downstream
producers").
- Wiring `examples/02-multi-module.twasm` through the producer — blocked
by #127 (front-end → IR seam), per #140 bullet 3.
## Feature gate
`unstable-l13-imports = ["unstable-l2"]` — implies l2 because the
import-bit convention extends `typedwasm.regions`'s `target_region`
value space. Default verifier surface is unchanged; this is opt-in until
proposal 0003 leaves `[draft]`.
## Test plan
- [x] `cargo check -p typed-wasm-verify` (default features) — clean
- [x] `cargo check -p typed-wasm-verify --all-features` — clean
- [x] `cargo check -p typed-wasm-verify --features unstable-l13-imports`
— clean
- [x] `cargo test -p typed-wasm-verify --features unstable-l13-imports`
— **85 tests pass** (66 baseline + 19 new):
- 9 codec tests (roundtrip, truncation, UTF-8-lossy, version mismatch,
pointer-kinds tolerance, large field counts)
- 10 verifier-pass tests (all 5 error variants + clean path +
NO_TARGET_REGION sentinel safety + empty-table)
- [x] `cargo clippy -p typed-wasm-verify --features
unstable-l13-imports` — clippy-clean for new code (one pre-existing
collapsible-match warning at `verify.rs:323`)
## Refs
Refs #140 (bullet 1 verifier-pass slice), refs #95, refs #50, part of
proposal 0003 §"Acceptance criteria" items 3 + 4.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 1acac8f commit 1ba8538
4 files changed
Lines changed: 835 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
33 | 45 | | |
34 | 46 | | |
35 | 47 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
| 2 | + | |
2 | 3 | | |
3 | 4 | | |
4 | 5 | | |
| |||
31 | 32 | | |
32 | 33 | | |
33 | 34 | | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
34 | 41 | | |
35 | 42 | | |
36 | 43 | | |
| |||
148 | 155 | | |
149 | 156 | | |
150 | 157 | | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
151 | 166 | | |
152 | 167 | | |
153 | 168 | | |
| |||
203 | 218 | | |
204 | 219 | | |
205 | 220 | | |
| 221 | + | |
| 222 | + | |
| 223 | + | |
| 224 | + | |
| 225 | + | |
| 226 | + | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
| 240 | + | |
| 241 | + | |
| 242 | + | |
| 243 | + | |
| 244 | + | |
| 245 | + | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
| 265 | + | |
| 266 | + | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
206 | 277 | | |
207 | 278 | | |
208 | 279 | | |
| |||
260 | 331 | | |
261 | 332 | | |
262 | 333 | | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
| 355 | + | |
| 356 | + | |
| 357 | + | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
263 | 364 | | |
264 | 365 | | |
265 | 366 | | |
| |||
0 commit comments