Registry Mirror
Skip to content

Conversation

@avrabe

@avrabe avrabe commented Aug 13, 2026

Copy link
Copy Markdown
Contributor

verify coverage: close the i32.const hole (#933) and make the denominator reportable (#935)

These two issues compound: #933 is a verification hole (i32.const covered by NEITHER the SMT half nor the Rocq half), #935 is what made the hole invisible (synth verify never reported the rules it applied and declined). They land together so the gap is both closed and could not silently reopen unreported.

#933 — i32_const_correct closed: 592 Qed / 2 Admitted

Contract chosen: (a) — normalize I32Const at the WASM model boundary (exec_wasm_instr (I32Const n) now pushes VI32 (I32.repr n)), plus the small-branch MOVW immediate harmonized to the value's bits (I32.repr (I32.unsigned n)).

Why (a) is a faithful model of wasm semantics, not a convenience (#166 no-weakening gate, argued not silent):

  • A wasm i32.const c immediate is a value of type i32 (spec §2.4.1/§4.4.1): the binary format LEB128-decodes exactly 32 bits, so no real module can carry an out-of-range representative like the counterexample n = 2^32 + 0x10000. Those representatives exist only because the model's shallow embedding I32.int := Z admits them syntactically.
  • Every arithmetic op in the model already quotients junk representatives through I32.repr/I32.unsigned; the raw const push was the one remaining injection point for un-normalized values into the machine. Normalizing there closes the embedding, it does not weaken a claim about any reachable program.
  • The theorem still quantifies over all Z — no hypothesis was added, no instance was excluded (contract (b) would have narrowed the quantifier's effective domain; (a) instead corrects what the model means by I32Const n, which is why (a) is the principled one).
  • Same argument on the ARM side: MOVW's imm16 field is derived from the constant's value bits and the hardware zero-extends it — the shipped Rust encoder cannot emit, and no register can hold, a raw negative/oversized Z. The large branch in Compilation.v was already value-derived (I32.unsigned n); the small branch's raw n was an internal inconsistency, now harmonized.
  • Both changes are identities on the reachable domain (for in-range n, I32.repr n = n and I32.repr (I32.unsigned n) = n) — the compiled instruction sequences are unchanged, and in the Rust half normalization is inherent in the i32 type. No existing Qed about real programs weakens; the proof-suite build (which recompiles every dependent theorem) is green.

The proof itself is two already-Qed facts: the small branch discharges via I32.repr_unsigned, the large branch via i32_const_large_reconstruct (the #166 MOVW+MOVT reconstruction Qed).

Blast radius: I32Const is referenced by 5 .v files; WasmCertBridge.v does not cover const, and the example programs are compiled (vm_compute, unchanged results) but never executed, so only the const theorem itself restates.

Ledger moved with the proof in the same commit: claims.yaml 592 Qed / 2 Admitted, CorrectnessSimple.v admits 1→0; coq/STATUS.md recount + the T3 row moved to the discharged list; CLAUDE.md / README prose; status.json + FEATURE_MATRIX.md regenerated. python3 scripts/claim_check.py claims.yaml → 43/43.

#935 — the full rule inventory: applied / verified / declined-with-reason

run_verification now returns and prints every applied op kind with occurrence counts:

  • verified / failed / unknown — the SMT half, as before;
  • declined — with a machine reason (register-operation / immediate-shift-encoding / unmodeled-op) and, where one exists, the Rocq theorem the decline defers to (rocq_theorem: "i32_const_correct" — the join key the downstream obligation asked for; after this PR all named register-operation theorems are Qed).

Console (per function and module level) now carries the denominator:

  Declined (not SMT-verified; deferred to per-rule Rocq obligations):
  - I32Const × 29: register-operation (Rocq: i32_const_correct)
  ...
Verification summary: 7 applied rule kinds — 3 verified, 0 failed, 0 unknown, 4 declined (7 instructions)

synth verify --emit-verify-report <path> writes a synth-verify-v1 JSON sidecar (the synth-wcet-v1 precedent, #921/#922) with per-function records and a summary including declined_by_reason — mechanically gateable in CI. Rule ids are Debug-derived WasmOp variant names (no hand-maintained mirror to drift, the #682/#890 lesson).

Non-vacuity gate (crates/synth-cli/tests/verify_report_935.rs, wired into the fact-spec CI job): a fixture with KNOWN declines (4× i32.const, 2× local.get, 1× i32.shl) must show them with real counts and reasons, and applied_rule_kinds must equal verified + failed + unknown + declined — a report that only ever prints zeros for declines fails the gate.

Gates

  • bazel test //coq:verify_proofs — PASS (2/2)
  • python3 scripts/claim_check.py claims.yaml — 43/43
  • cargo fmt --check — clean
  • cargo clippy --workspace --all-targets -- -D warnings — exit 0 (also -p synth-cli --features verify, since the inventory code is verify-gated)
  • cargo test --workspace — PASS
  • cargo test -p synth-cli --features verify --test verify_report_935 — 2/2
  • frozen anchors frozen_codegen_bytes — 10/10 (no shipped bytes change; the Rocq model edits are identities on the reachable domain and the reporter is output-only)

Closes #933
Closes #935

🤖 Generated with Claude Code

https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L

avrabe and others added 3 commits August 13, 2026 17:23
…d-with-reason

synth verify previously reported only the rules it verified; declined kinds
(Const/Local/shifts/unmodeled) were skipped WITHOUT reporting, so
'N verified, 0 failed, 0 unknown' read as complete while e.g. 29 i32.const
went unmentioned and no coverage denominator was computable.

- run_verification now returns the FULL per-function inventory: every applied
  op kind as verified/failed/unknown/declined, with occurrence counts, machine
  decline reasons (register-operation / immediate-shift-encoding /
  unmodeled-op), and the Rocq theorem a decline defers to (the #933 join key)
- per-function and module summaries carry the decline half of the denominator
- --emit-verify-report writes a synth-verify-v1 JSON sidecar (the wcet-sidecar
  precedent, #921/#922) for mechanical CI gating
- rule ids are Debug-derived WasmOp variant names (no hand table to drift)
- non-vacuity gate: verify_report_935 test builds a fixture with KNOWN declines
  and asserts they appear with real counts + that applied_rule_kinds equals
  the sum over all four statuses; wired into the fact-spec CI job

Refs #935 #933

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L
… model boundary (592 Qed / 2 Admitted)

The theorem was Admitted because it was FALSE AS STATED: it quantified over
raw un-normalized Z representatives (exec_wasm_instr (I32Const n) pushed
VI32 n raw) while the shipped MOVW+MOVT path necessarily produces the
register-normalized I32.repr (I32.unsigned n) (counterexample:
n = 2^32 + 0x10000). Closed via contract (a) of the documented T3 note —
argued, not silent, per the #166 no-weakening gate:

- WasmSemantics.v: I32Const pushes VI32 (I32.repr n). A wasm i32.const
  immediate IS a value of type i32 (the binary format decodes exactly 32
  bits — no real module carries a junk representative); the shallow
  I32.int := Z embedding admitted junk syntactically and the raw const push
  was the ONE remaining un-normalized injection point (every arithmetic op
  already quotients through repr/unsigned). In the Rust half normalization
  is inherent in the i32 type, so the model now matches what ships.
- Compilation.v: small-branch MOVW immediate is the value's bits
  I32.repr (I32.unsigned n) — harmonizing with the large branch (always
  value-derived) and with the shipped encoder (imm16 = value low bits,
  hardware zero-extends). Identity for every in-range n.
- CorrectnessSimple.v: i32_const_correct restated over the value the WASM
  machine actually pushes (I32.repr n) and QED — small branch via
  I32.repr_unsigned, large branch via the already-proven
  i32_const_large_reconstruct. Both changes are identities on the reachable
  domain, so no existing Qed about real programs weakens.

bazel test //coq:verify_proofs PASSES. Ledger + docs bumped together:
claims.yaml 592 Qed / 2 Admitted, CorrectnessSimple.v admits 1 -> 0;
coq/STATUS.md recount + T3 table row moved to the discharged list;
CLAUDE.md / README.md prose; status.json + FEATURE_MATRIX regenerated
(claim_check 43/43).

Closes #933

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L
@codecov

codecov Bot commented Aug 13, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 0% with 14 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
crates/synth-cli/src/main.rs 0.00% 14 Missing ⚠️

📢 Thoughts on this report? Let us know!

@avrabe
avrabe merged commit 72d9060 into main Aug 13, 2026
58 checks passed
@avrabe
avrabe deleted the fix/i32const-coverage-933-935 branch August 13, 2026 16:03
avrabe added a commit that referenced this pull request Aug 13, 2026
Pulls four merged commits forward into a patch release because the first is a
live vulnerability in a shipped version:

  #959  ARM --safety-bounds mask emitted an IDENTITY mask on (memory 0)
  #961  thumb-2 branch target could land mid-instruction (#930)
  #962  I64Const/I64Ldr/I64Str unpriced in the WCET model (#936)
  #958  synth verify covers i32.const + reports the decline denominator

The ARM mask bug is the headline. The mask path exempted `bytes == 0` from its
power-of-two gate, so `(memory 0)` compiled with exit 0 and `movw r10, #0x0`.
The guard computes `R10 - 1`, and `0 - 1` is `0xFFFFFFFF` — a mask that masks
nothing, in the mode whose whole purpose is to bound accesses. Unbounded OOB
read AND write.

It is the same sentinel/value collision as #953 one release earlier, running
the other way: there `0` meant "unset" and INVENTED a 64 KiB bound, here `0`
meant "no bound needed" and ERASED the real one. That is why the fix landed as
a sweep of the collision class (54 sites, 4 converted, 3 latent defects) and
not another point patch — the v0.53 finding was that we keep fixing instances
rather than mechanisms.

Release surfaces, all four swept to 0.56.2 and checker-confirmed:
  Cargo.toml [workspace.package] + 10 path-dep version= pins
  MODULE.bazel, npm/package.json, Cargo.lock (cargo metadata)
  scripts/check_version_pins.py: OK on all four

Derived artifacts regenerated (--emit-status): artifacts/status.json,
docs/status/FEATURE_MATRIX.md. Claim gate: 43/43.

SCOPE MOVE, logged not silent: RQ-57-SENTINEL, RQ-57-BRTARGET, RQ-57-WCET2OPS,
RQ-57-I32CONST and RQ-57-RULEINV were planned for v0.57 and are re-tagged
release: v0.56.2 / status: implemented. SENTINEL carried the security fix and
the other four were already merged on main, so a tag excluding them did not
exist. rivet error/warning counts are unchanged by the move (50/164 before and
after — pre-existing, unrelated to these artifacts).


Claude-Session: https://claude.ai/code/session_01YJK5LZZEkV5smCY1jKn18L

Co-authored-by: Claude Opus 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant