Skip to content

Spec amendment 1: typed RIR semantics + D21 (no string-tagged dispatch)#75

Merged
StarGazerM merged 1 commit into
design/redesign-packagefrom
feat/spec-amendment-1-typed-rir-semantics
May 19, 2026
Merged

Spec amendment 1: typed RIR semantics + D21 (no string-tagged dispatch)#75
StarGazerM merged 1 commit into
design/redesign-packagefrom
feat/spec-amendment-1-typed-rir-semantics

Conversation

@StarGazerM

Copy link
Copy Markdown
Collaborator

Summary

First spec refinement after PR #74 (the redesign baseline). Addresses 8 semantic gaps in the RIR vocabulary where operational meaning was hidden behind string-tagged fields instead of typed ops. Expands RIR from ~10 op families to 30 typed ops + 5 carrier dataclasses.

What's new

§ 1 ACID sub-clause

Every operational semantic — termination, cross-stratum deps, delta-variant ordering, multi-head emission, kernel fusion, pragma compatibility — must be expressed as typed IR ops or typed metadata, not as string-tagged dispatch in renderers. Renderers may dispatch on op TYPE, never on op string fields.

§ 3.1.1.1 expanded RIR vocabulary (30 typed ops, 5 carriers)

Group Count Notable ops
Structure 4 RunnerStruct, StepDispatch, FixpointLoop, Step (with explicit deps: tuple[StepId, ...] DAG edges)
Termination (new typed union) 4 ConvergenceCheck, MaxIterationFuel, EitherFirst, AndAll
Scheduling 5 KernelLaunch + 4 schedulers
Kernel bodies (was string-tagged phase) 3 CountKernelDef, MaterializeKernelDef, FusedKernelDef
Variant ordering 1 DeltaVariantSet(ordering=Sequential|Independent|Fusable)
Multi-head 1 MultiHeadInsert(heads, ordering=Sequential|Concurrent)
Dedup 1 DedupTable
Maintenance (was 1 string-lump) 11 distinct typed ops: ComputeDeltaCall, MergeIndexCall, RebuildIndexCall, CheckSizeCall, etc.

Plus carriers: HeadSpec, ViewBinding, ComposabilityMeta, VariantOrdering, HeadOrdering.

§ 7.1 D21 discipline rule

No @register_render body may dispatch on a string field of its op. AST scan of render modules; fail on if op.kind == ... / match op.kind: patterns.

§ 10 Amendment log

Acknowledges the spec is a living document during the redesign; subsequent amendments are PR-shaped and reviewed.

Two corrections surfaced during review

  1. Maintenance op count was wrong — the original spec said "14 maintenance ops" but actual count from orchestrator.py:506-588 is 11 (verified against mir/types.py). The spec conflated ExecutePipeline + ParallelGroup + a duplicate branch into the count. Now corrected throughout.
  2. KernelDef(name, phase: KernelPhase, body) is superseded — replaced by 3 typed ops. Old code block left intact with a supersession callout, per the "don't rename/move existing headers; expand instead" rule.

PR-2 split: YES (6 → 7 PRs total)

With 30 typed ops + 11 lowerings to maintenance ops, PR-2's scope ballooned past comfortable. Split:

  • PR-2a = framework + structural (4) + scheduling (5) + kernel-body (3) + dedup (1) = ~2400 LOC
  • PR-2b = maintenance (11) + termination (4) + variant ordering (1) + multi-head (1) + view bindings = ~2100 LOC

Both gate on verify_runner_completeness (WARN in 2a, HARD in 2b).

Final ledger: PR-1 → PR-2a → PR-2b → PR-3 → PR-4 → PR-5 → PR-6. Strictly serial.

Test plan

  • sphinx -W build succeeded
  • ruff check + format (CI v0.9.10): clean
  • No markdown links to local .md files in doc body (only the existing example of the forbidden pattern in a code span at line 14)

🤖 Generated with Claude Code

…tch gaps)

User review of merged PR #74 surfaced 8 places where the proposed RIR
vocabulary still expressed operational meaning as string-tagged dispatch
or implicit list ordering, in violation of the spec's own ACID test.
This amendment fills them by promoting each concern to typed IR ops or
typed metadata: 11 typed maintenance ops (replacing one MaintenanceCall
with kind:str), typed TerminationCheck union, typed Step.deps DAG edges,
typed DeltaVariantSet + VariantOrdering, typed MultiHeadInsert +
HeadOrdering, three typed kernel-def ops (Count/Materialize/Fused
replacing KernelDef.phase:str), typed ComposabilityMeta on Pragma, and
typed ViewBinding carrier. RIR op count grows ~10 to 30; PR-2 splits to
PR-2a + PR-2b; total ledger 6 to 7 PRs. D21 discipline (no string
dispatch in renderer bodies) added. PR-1 scope unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@StarGazerM
StarGazerM merged commit 27ff43c into design/redesign-package May 19, 2026
3 checks 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