Skip to content

feat(#593): scripting codegen splice — embed scripts, wire the plugin, drain touchpoint - #596

Merged
apotema merged 1 commit into
mainfrom
feat/593-scripting-splice
Jul 10, 2026
Merged

apotema merged 1 commit into
mainfrom
feat/593-scripting-splice

Conversation

@apotema

@apotema apotema commented Jul 10, 2026

Copy link
Copy Markdown
Contributor

Makes .params = .{ .language = "lua" } projects run their scripts. Closes #593 (epic labelle-toolkit/labelle-engine#237).

  • Detect (feat(#584): .language policy — one script language per project #589's parse + manifest name scripting) → copy lua/ via the scanner machinery → generated main registers each script (@embedFile, sorted, before PluginControllers.setup boots the VM) → build.zig passes .language to the plugin dep → scripting_enabled flag + import alias via module_vars for the template gate.
  • Load-bearing placement discovery: drainEvents rides the assembler's tick_code between the plugin ticks and g.dispatchEvents() — it CANNOT live in backend templates (dispatch is emitted inside the {{tick_code}} hole; a template drain would tap an already-swapped buffer, and the contract forbids post-dispatch taps). Riding tick_code also lands the drain on every backend at once; templates carry only bind (labelle-bgfx companion PR).
  • Script-less projects generate byte-identically (all goldens unchanged). Clean-HOME: 50/50 steps, 1576/1580 (4 skipped, 0 failed).

Companion: labelle-toolkit/labelle-bgfx bind-touchpoint PR. Next: null-template touchpoint + examples/scripting-smoke (labelle-toolkit/labelle-engine#739).

https://claude.ai/code/session_01P7YLw4hXFCCaY2LAUt4G1j

…, drain touchpoint

Makes .params.language projects RUN their scripts (epic
labelle-engine#237; contract labelle-engine#749; plugin
labelle-scripting#1):

- scripting_splice.detect(): the #589-parsed language + manifest name
  'scripting' gate; EMBED_LANGUAGES table (lua -> .lua; native
  languages deliberately absent -> warn, no splice).
- Copy <lang>/ via the prefabs/scenes scanner machinery (sorted stems,
  /-joined subdirs); generated main registers each script
  (scripting.registerScript(stem, @embedfile(...))) BEFORE
  PluginControllers.setup boots the VM — both lifecycle shapes.
- module_vars emit the scripting import alias + scripting_enabled
  flag; build.zig passes .language enum to the plugin dependency.
- drainEvents rides tick_code between the plugin ticks and
  g.dispatchEvents (engine-gated, outside the scaled_dt gate) — NOT
  the backend template: dispatch is emitted inside the tick_code
  hole, so a template drain would tap an already-swapped buffer;
  riding tick_code also lands the drain on every backend at once.
  Templates carry only the bind touchpoint (bgfx PR).
- Tests: 6 zspec (registrations sorted/pre-setup, drain placement,
  whole-main expectAstGenOk, empty-set, no-splice zero-markers,
  build.zig .language) + 7 unit; all byte-identity goldens unchanged
  (script-less projects byte-identical). Clean-HOME: 50/50 steps,
  1576/1580 (4 skipped).

Closes #593

Claude-Session: https://claude.ai/code/session_01P7YLw4hXFCCaY2LAUt4G1j
@gemini-code-assist

Copy link
Copy Markdown

Warning

You have reached your daily quota limit. Please wait up to 24 hours and I will start processing your requests again!

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@apotema, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 29eebeb3-e209-4fe9-b170-6dd08603c851

📥 Commits

Reviewing files that changed from the base of the PR and between df415a0 and a7ea6e0.

📒 Files selected for processing (10)
  • build.zig
  • src/build_files/build_zig.zig
  • src/codegen/context.zig
  • src/codegen/lifecycle/callback.zig
  • src/codegen/lifecycle/loop.zig
  • src/codegen/lifecycle/render.zig
  • src/codegen/main_template.zig
  • src/root.zig
  • src/scripting_splice.zig
  • test/scripting_splice_tests.zig
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/593-scripting-splice

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@apotema
apotema merged commit 27cbb09 into main Jul 10, 2026
4 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.

Language plugins P1: scripting codegen splice — embed scripts, wire the plugin, bind/drain touchpoints

1 participant