Skip to content

Revert PR-1d: CudaRenderCtx was the same anti-pattern reskinned#82

Merged
StarGazerM merged 1 commit into
design/redesign-packagefrom
revert/pr-1d-cuda-render-ctx
May 20, 2026
Merged

Revert PR-1d: CudaRenderCtx was the same anti-pattern reskinned#82
StarGazerM merged 1 commit into
design/redesign-packagefrom
revert/pr-1d-cuda-render-ctx

Conversation

@StarGazerM

Copy link
Copy Markdown
Collaborator

Why revert

PR-1d (#81) moved 10 CUDA-render-private fields from LoweringCtx into a new CudaRenderCtx dataclass. The shape is the anti-pattern — a fixed-schema attribute carrier where adding any new CUDA render feature (a new tile mode, a new gate, a new ballot variant) requires editing lower_ctx.py to add a field.

This is the same shape as the original bool-field anti-pattern (ep.work_stealing / ep.dedup_hash / ep.bg_enabled) that A3-1/2/3 already removed, and the same shape as the runner monolith that Phase R targets. We just moved the problem from one named carrier to another.

Per the user: it's a clear ACID-test violation (spec § 1).

What needs to change

Spec amendment 2 (separate PR) replaces "split LoweringCtx → CudaRenderCtx" (§ 3.2.1) with a no-context principle:

  • Cross-pass through-state (e.g. view_specs, iir, name maps that pass A sets and pass B reads): becomes IR ops. Information flows only via the IR.
  • Intra-pass scratch (fresh-name counters, lexically-scoped valid_vars threaded into one render call): becomes function-local state, no ctx parameter.
  • Services (compiler, name_gen, plugin_registry): explicit kwargs or a Services handle that is never mutated.

After the rewrite, LoweringCtx, CudaRenderCtx, KernelCtx, InitialProg all dissolve.

What stays / what comes back

Test plan

  • ruff check + format: clean
  • mypy: 147 errors / 39 files — unchanged from baseline
  • byte-equivalence (3 suites): 532 passed, 2 skipped

🤖 Generated with Claude Code

@StarGazerM
StarGazerM merged commit 69a3468 into design/redesign-package May 20, 2026
3 checks passed
StarGazerM added a commit that referenced this pull request May 20, 2026
Replaces § 3.2.1 ("Split LoweringCtx from CudaRenderCtx") with
"Dissolve LoweringCtx (no-context principle)". Adds a sub-clause
to § 1 (ACID test) codifying the three-bucket discipline:

1. Cross-pass data → typed IR op
2. Intra-pass scratch → function-local / explicit kwarg
3. Services → immutable Services handle

Adds amendment-log entry § 10.2. Refers forward to discipline rule
D22 (strict monotonic decrease of ctx-field count; to be codified
in code_discipline.md per the standard cadence).

Triggered by user review of merged PR-1d (#81) which introduced
CudaRenderCtx with 10 fixed-schema fields — the same anti-pattern
the redesign is supposed to eliminate. PR-1d reverted in #82.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
StarGazerM added a commit that referenced this pull request May 20, 2026
Replaces § 3.2.1 ("Split LoweringCtx from CudaRenderCtx") with
"Dissolve LoweringCtx (no-context principle)". Adds a sub-clause
to § 1 (ACID test) codifying the three-bucket discipline:

1. Cross-pass data → typed IR op
2. Intra-pass scratch → function-local / explicit kwarg
3. Services → immutable Services handle

Adds amendment-log entry § 10.2. Refers forward to discipline rule
D22 (strict monotonic decrease of ctx-field count; to be codified
in code_discipline.md per the standard cadence).

Triggered by user review of merged PR-1d (#81) which introduced
CudaRenderCtx with 10 fixed-schema fields — the same anti-pattern
the redesign is supposed to eliminate. PR-1d reverted in #82.

Co-authored-by: Claude Opus 4.7 (1M context) <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

Development

Successfully merging this pull request may close these issues.

1 participant