Skip to content

Specializer M-ir: imperative IR — grammar, types, verifier, text format - #24

Merged
claude-agent-ahrzb[bot] merged 3 commits into
claude/duckdb-native-interpreter-36d016from
claude/specializer-m-ir
Jul 25, 2026
Merged

Specializer M-ir: imperative IR — grammar, types, verifier, text format#24
claude-agent-ahrzb[bot] merged 3 commits into
claude/duckdb-native-interpreter-36d016from
claude/specializer-m-ir

Conversation

@claude-agent-ahrzb

Copy link
Copy Markdown

What (TASK-41, milestone m-7 — stacked on #23)

The specializer's imperative IR, per design doc §6 (updated in this PR to the implemented form):

  • src/specializer/ir/mod.rs — the normative spec in module docs + core types. SSA over bare scalars (i1/i64/f64/str); nullability exists only at column/static edges via .opt instruction forms, so a nullable value cannot reach arithmetic by construction.
  • verify.rs — six rule groups (structure, SSA w/ strict block-param crossing, operand types + mandatory/forbidden .opt pairing, static resolution, CFG reachability/acyclicity/branch-arg typing, store-completeness dataflow). No dominance analysis needed by design.
  • print.rs / parse.rs — canonical round-trippable text format: parse(print(p)) == p, bitwise literal equality (NaN/-0.0 survive), quoted column names for SQL-derived output columns.
  • gen.rs — seeded xorshift program generator; 300-seed round-trip fuzz in CI-run tests; reused at M-interp for interpreter-vs-codegen fuzzing.
  • fixtures.rs — five hand-written programs; a meta-test asserts every opcode/terminator appears in at least one.

Verification

  • mise gate-specializer green: cargo 33 passed, pytest 574 passed + 12 xfailed
  • Every verifier rule has a rejecting test; every parser guard has a rejecting text
  • Adversarial workflow (4 attack lenses + 2 review lenses) ran against this; confirmed findings land as follow-up commits on this branch

🤖 Generated with Claude Code

ahrzb and others added 3 commits July 25, 2026 15:17
… (M-ir)

src/specializer/ir/: SSA over bare typed scalars with the null lane split
into explicit i1 flags (.opt instruction forms) so a nullable value cannot
reach arithmetic by construction; strict block-param SSA (no dominance
analysis needed); acyclic CFG; emit/skip/trap terminators carrying the
store-completeness contract (|out|==|in| iff skip unreachable).

verify.rs enforces six rule groups, each with a rejecting test; print/parse
round-trip exactly (parse(print(p)) == p, bitwise literal equality so
nan/-0.0 survive); gen.rs is a seeded xorshift program generator — 300-seed
round-trip fuzz in tests, reused later for interpreter-vs-codegen fuzzing.
Design doc §6 updated to the implemented form. TASK-41.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
… — TASK-41

Six agents (4 attack lenses + 2 reviews) probed the initial IR; every
confirmed finding is fixed and pinned by a regression test:

- reachability DFS made iterative: a ~8k-block legal CFG stack-overflowed
  the process; 50k blocks now verify (deep_cfg_verifies_without_crashing)
- verified programs must print to parseable text: reject empty map static
  signatures (grammar can't express `map() -> ()`) and non-identifier
  function names
- Lit::F64 equality treats all NaNs as one class, matching the text form's
  canonical `nan` token — non-canonical payloads round-trip again
- store dataflow runs over the reachable subgraph: an unreachable cyclic
  island no longer starves a reachable join and masks its store errors
- docs aligned: double stores rejected on ALL paths incl. trap (deliberate),
  grammar EBNF covers store/comments/lenient %names, canonical-form note
- dead Inst::uses/Term::uses deleted; 7 missing rule-coverage tests added
  (entry params, duplicate cols, branch-to-entry, sload-on-map, scalar-static
  .opt pairing both ways, store.opt on non-nullable)

cargo 45 passed; gate green.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
…notes

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@claude-agent-ahrzb
claude-agent-ahrzb Bot merged commit b6b93e4 into claude/duckdb-native-interpreter-36d016 Jul 25, 2026
1 check passed
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