Spec amendment 3 — full carrier dissolution + pragma plugin contract (Phase P, load-bearing)#84
Merged
StarGazerM merged 1 commit intoMay 20, 2026
Conversation
…+ architectural precedent § 3.2.1.1 — Full carrier dissolution scope: context.py (543 LOC) dissolves entirely. Field-by-field bucket assignment for CodeGenContext (38 fields), CodeGenHooks (10 callable slots), RunnerGenState (14 fields), plus 30+ ctx-taking helpers. § 3.2.1.2 — Self-audit on the proposed solution. 5 risks that would have rebuilt the anti-pattern one layer up + their fixes: typed-key Services dict, MLIR-style attribute dict on Ops, sharpened bucket-2 boundary, per-Compiler registries, Ops as typed shells. § 3.2.1.3 — The pragma plugin contract (Phase P, load-bearing). Today's @pragma_handler is a constrained materialization-handler, NOT a plugin. A pragma cannot contribute IR ops, run as a general pass, bundle lowerings + renders, or declare dependencies. Without a real pragma plugin contract, every other phase shuffles code without changing the extensibility surface. Specifies the PragmaPlugin schema (typed Pragma + new_ops + new_attributes + passes + lowerings + renders + requires_services + produces_ops + consumes_ops + preserves) and the atomic compiler.register_pragma_plugin(plugin) API. § 6.0 — PR-P series (highest priority, ahead of PR-2/3/4): - PR-P0: framework primitives (~2500 LOC, serial, blocks P1-P4) - PR-P1/P2/P3/P4: per-pragma migrations (BG, WS, DedupHash, FanOut) ~1000-1500 LOC each, parallel + file-disjoint - PR-P5: context cleanup as consequence (~800 LOC, mostly deletion) § 11 — Architectural precedent. The shape we are converging on has 40 years of validation: relational query compilation (Volcano 1993 → Cascades → Calcite → DuckDB 2024); MLIR (dialects + typed Op attributes + conversion patterns); LLVM (analyses via getAnalysis<T>()); FRP UI (React/Solid components as data, hooks lexical, Context Providers carry services not feature accumulators). § 10.3 — Amendment log entry. Includes entropy retrospective: ~10% of work to date was entropy (reverted PR-1d), ~30% was useful-but-out-of-order (B/A3 series — useful as inputs to Phase P), ~60% was load-bearing (PR-1a/b foundation, C-pragma typed classes, declarative kernel-body lowerings). Triggered by user review of the design after PR-1d revert + the anti-pattern audit findings. Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
StarGazerM
merged commit May 20, 2026
71c05e4
into
feat/spec-amendment-2-no-context-principle
3 checks passed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Three big additions + an entropy retrospective. Headline finding: today's pragma surface is not a plugin, and without fixing that, every other phase of the redesign is shuffling code without changing the extensibility surface. Phase P (pragma plugin contract) becomes the new top priority, ahead of Phase R / T / B2.
Builds on PR #83 (Amendment 2). Merge order: #83 → this PR.
What changes
§ 3.2.1.1 — Full carrier dissolution scope
The audit revealed the dissolution scope is broader than
LoweringCtxalone. The entiresrc/srdatalog/ir/codegen/cuda/context.py(543 LOC) dissolves under the no-context principle. Field-by-field bucket assignment forCodeGenContext(38 fields),CodeGenHooks(10 callable slots),RunnerGenState(14 fields), + 30+ ctx-taking helpers.§ 3.2.1.2 — Self-audit on the proposed solution
Five risks that would have rebuilt the anti-pattern one layer up:
Servicesbecomes a named-field carrierservices.get[T](T) → Top.attributes[T]typed attribute dict**scopekwargs become stack-allocated context@register_Xdecorators are module-global mutable stateCompilerregistries; decorators are sugarattributes§ 3.2.1.3 — The pragma plugin contract (Phase P, LOAD-BEARING)
Today's
@pragma_handleris a constrained materialization-handler primitive, NOT a plugin. A pragma cannot:The four built-in pragmas (BlockGroup, WorkStealing, DedupHash, FanOut) work today only by leaking knowledge into the framework. Without fixing this, every other phase shuffles code without changing the contract.
Specifies the
PragmaPluginschema (typedPragma+new_ops+new_attributes+passes+lowerings+renders+requires_services+produces_ops+consumes_ops+preserves) and the atomiccompiler.register_pragma_plugin(plugin)API.§ 6.0 — PR-P series (highest priority)
After PR-P series lands, the existing PR-2/3/4/5/6 plan re-applies with reduced scope — most dissolution work is already done as Phase P consequences.
§ 11 — Architectural precedent
The shape has 40 years of validation across 4 domains: relational query compilation (Volcano 1993 → Cascades → Calcite → DuckDB), MLIR, LLVM, FRP UI (React/Solid). Per-domain mapping table. Future contributors can pattern-match against existing literature rather than re-derive design choices.
§ 10.3 — Amendment log + entropy retrospective
Of PR work to date:
The original PR-2/3/4 (RIR) plan is NOT entropy but is BLOCKED by Phase P — running it first would design RIR ops around the wrong plugin contract.
Test plan
Spec-only, no code changes. Reviewers focus:
PragmaPluginschema cover every "feature" that a pragma plugin might want to ship?PR #68 jaccard demo audit (included in this amendment)
Concurrent audit found PASS-WITH-CAVEATS: zero edits to existing files (ACID-test letter satisfied), but the demo uses
ctx.dedup_hashbool-field flip + imports private_lower_insert_into. Cannot yet be cited as proof of the additive contract. Four follow-ups identified. Phase P cleans up the framework side; the demo updates separately.🤖 Generated with Claude Code