Skip to content

DECLARE_RUNNERS per-language table + components/ collection root - #615

Merged
apotema merged 2 commits into
mainfrom
feat/declare-runners
Jul 12, 2026
Merged

apotema merged 2 commits into
mainfrom
feat/declare-runners

Conversation

@apotema

@apotema apotema commented Jul 12, 2026 •

Copy link
Copy Markdown
Contributor

The final convergence piece before v0.86.0 — two changes closing the loop on both user decisions from labelle-toolkit/labelle-engine#237:

1. Ruby declare-mode wires into generate

DECLARE_LANGUAGE → the DeclareRunner table (lua → labelle-declare/.lua, ruby → labelle-declare-ruby/.rb, from labelle-scripting v0.9.0), plus a min_pin per row so the absent-tool note stays pointed. Per-row filesystem capability probe — older pins gracefully skip exactly as before; the in-process tool cache keys pkg+step (a lua build can never satisfy a ruby lookup). parseSchema untouched — the scripting repo's cross-runner byte-parity golden is the contract proof.

2. components/hunger.rb next to components/worker.zig

Declare collection = components/*.<ext> union in-script chunk-scope declarations (both feed the runner, components first; the runner owns duplicate attribution with first-declared-in). Components-dir language files are also embedded and registered before scripts — the view constants exist when scripts load (the enabler: EmbedScript.file went target-relative so two convention dirs feed one emission stream; generated bytes unchanged, goldens untouched-passing). Recursive organizational subdirs mirror the Zig component scan; a .ts authoring source in components/ is a pointed error (.d.ts exempt); the legacy-grace path gets components/ declarations too; the policy scan polices both dirs identically.

Verification

+17 tests: the union argv pin (recording fake runner), the ruby declare e2e (components/hunger.rb → generated component + registry + registerScript before scripts/), old-pin graceful skip, transpile-swap prefix preservation, per-row probes with both-row negative controls. Negative-verified: inverted ordering and stubbed components collection each fail exactly the two ordering pins. 1968/1972 clean-HOME, authoritative exit 0.

After this releases (v0.86.0): the scripting examples PR — components/hunger.zig → components/hunger.rb in the ruby game, feed_watcher.rb, all examples to scripts/.

https://claude.ai/code/session_01P7YLw4hXFCCaY2LAUt4G1j

Summary by CodeRabbit

  • New Features

    • Embedded scripts can now be sourced from both components/ and scripts/, with deterministic registration order.
    • Added declaration support for Lua and Ruby scripting workflows.
    • Component declarations are included in generated scripting data and registrations.
    • Improved support for language-specific tooling and graceful handling when tools are unavailable.
  • Bug Fixes

    • Corrected embedded file paths and registration ordering.
    • Added validation for unsupported component source languages and clearer diagnostics.
  • Tests

    • Expanded coverage for Lua, Ruby, TypeScript, component discovery, ordering, and missing-tool scenarios.

Ruby declare-mode wires into generate (labelle-scripting v0.9.0's
tools/declare-ruby): DECLARE_LANGUAGE becomes the DeclareRunner table
(lua -> labelle-declare/.lua, ruby -> labelle-declare-ruby/.rb) with
a min_pin per row so the absent-tool note stays pointed ('pin
labelle-scripting >= 0.9.0'); per-row filesystem capability probe —
older pins gracefully skip exactly as before; the in-process tool
cache keys pkg+step so a lua build can never satisfy a ruby lookup;
non-listed languages get the reworded not-yet-supported note.
parseSchema untouched — the scripting repo's cross-runner byte-parity
golden is the contract proof.

Component declarations live where their kind lives (the engine#237
refinement): declare collection = components/*.<ext> UNION in-script
chunk-scope declarations (both feed the runner, components first —
the runner owns duplicate attribution); components/ language files
are also EMBEDDED and register BEFORE scripts (plain alphabetical,
no ordering prefixes — the view constants exist when scripts load;
the enabler: EmbedScript.file went target-relative so two convention
dirs feed one emission stream, generated bytes unchanged). Recursive
organizational subdirs mirror the Zig component scan; a typescript
authoring source in components/ is a pointed error (.d.ts exempt,
runnable .js embeds); applies on the legacy-grace path too. Policy
scan now polices scripts/ and components/ identically.

+17 tests incl. the union argv pin, the ruby declare e2e (fake
tools/declare-ruby: components/hunger.rb -> generated component +
registry + registered before scripts/), old-pin graceful skip, and
the transpile-swap components-prefix preservation. Negative-verified:
inverted ordering and stubbed components collection each fail exactly
the two ordering pins. 1968/1972 clean-HOME, authoritative exit 0.

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 12, 2026 •

Copy link
Copy Markdown

Review Change Stack

Warning

Review limit reached

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

Next review available in: 51 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: 243efc04-0ff9-4e35-9617-d24bf190e8b3

📥 Commits

Reviewing files that changed from the base of the PR and between 0d01202 and 9e3c717.

📒 Files selected for processing (1)
  • src/root.zig
📝 Walkthrough

Walkthrough

Embedded scripting now collects component declarations alongside script-directory files, uses target-relative embed paths, applies language checks to both shared directories, and supports Lua/Ruby declaration runners with component-first input ordering.

Changes

Scripting pipeline

Layer / File(s) Summary
Shared directory language policy
src/language_policy.zig
Language-policy enforcement scans both scripts/ and components/, generalizes diagnostics, and adds component-directory coverage.
Component and target-relative embed collection
src/scripting_splice.zig, test/scripting_splice_tests.zig
Component embeds are collected and sorted before script embeds; stored file paths include their convention directories, with transpile-source validation and updated fixtures.
Language-specific declaration runners
src/scripting_declare.zig, test/scripting_declare_tests.zig, test/scripting_splice_tests.zig
Declaration extraction selects Lua or Ruby runner rows, resolves runner-specific tools, accepts target-relative files, skips unsupported languages, and tests component-first ordering.
Generation and emitted registration integration
src/root.zig, src/codegen/lifecycle/*.zig, src/scripting_transpile.zig, test/scripting_transpile_tests.zig
Generation combines component and script embeds, preserves component entries across transpilation, passes collected files to declaration mode, and emits target-relative @embedFile paths.

Estimated code review effort: 4 (Complex) | ~60 minutes

Poem

I’m a rabbit with scripts in a neat little row,
Components hop first, then the script files flow.
Lua and Ruby runners answer the call,
Target-relative paths keep embeds on the wall.
Zig files sit quietly, skipped from the spree—
A tidy code garden for every bunny.

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title captures the two main changes: per-language DECLARE_RUNNERS support and making components/ a collection root.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch feat/declare-runners

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.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (1)
src/language_policy.zig (1)

529-532: 🎯 Functional Correctness | 🟡 Minor | ⚡ Quick win

Exclude .d.ts files from shared-directory language buckets.

This classifies declaration-only files as TypeScript because they end in .ts, contradicting the splice contract that .d.ts is not a runnable script. A Lua or script-less project with components/labelle.d.ts currently fails policy validation before collection.

Proposed fix
             else => {
+                if (std.mem.endsWith(u8, entry.name, ".d.ts")) continue;
                 for (SUPPORTED_LANGUAGES, buckets) |lang, *bucket| {
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/language_policy.zig` around lines 529 - 532, Update the shared-directory
matching logic around matches to exclude entries ending in “.d.ts” before
applying scriptExtensions(lang), while preserving normal TypeScript and other
runnable-script classification.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/root.zig`:
- Around line 975-977: In the combined_embeds update, call
scripting_splice.concatEmbeds and store its successful result before freeing the
existing combined_embeds slice. Then free the old slice and assign the new
result, ensuring combined_embeds never retains a freed pointer while
concatEmbeds can fail; preserve the existing s.scripts assignment.

---

Outside diff comments:
In `@src/language_policy.zig`:
- Around line 529-532: Update the shared-directory matching logic around matches
to exclude entries ending in “.d.ts” before applying scriptExtensions(lang),
while preserving normal TypeScript and other runnable-script classification.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 04f3127e-089b-49f0-82fd-f64ed86d68ad

📥 Commits

Reviewing files that changed from the base of the PR and between f7b5417 and 0d01202.

📒 Files selected for processing (10)
  • src/codegen/lifecycle/callback.zig
  • src/codegen/lifecycle/loop.zig
  • src/language_policy.zig
  • src/root.zig
  • src/scripting_declare.zig
  • src/scripting_splice.zig
  • src/scripting_transpile.zig
  • test/scripting_declare_tests.zig
  • test/scripting_splice_tests.zig
  • test/scripting_transpile_tests.zig

Comment thread src/root.zig Outdated
…finding)

Freeing the old slice before the try left combined_embeds dangling
across concatEmbeds — an OOM there would double-free via the deferred
cleanup. The new slice is computed first, then the old freed, then
assigned.

Claude-Session: https://claude.ai/code/session_01P7YLw4hXFCCaY2LAUt4G1j
@apotema
apotema merged commit ab14d95 into main Jul 12, 2026
4 checks passed
@apotema
apotema deleted the feat/declare-runners branch July 12, 2026 04:22

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 9e3c7173fd

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment thread src/root.zig
Comment on lines 575 to +576
if (s.family == .embed) {
scripting_scripts = try scripting_splice.collectEmbedScripts(allocator, game_dir, target_dir, s.*);
s.scripts = scripting_scripts.?;
component_embeds = try scripting_splice.collectComponentEmbeds(allocator, game_dir, s.*);

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge Reject component-dir files for native script languages

For native scripting projects such as rust or crystal, this branch skips collectComponentEmbeds, while the new language-policy scan now treats components/*.rs/*.cr as the declared language and lets them pass. The native path later stages only splice.dir (scripts/ or the legacy language dir) via stageNativeSources, so a file like components/hunger.rs succeeds generation but is neither scanned as a Zig component nor staged/registered as scripting code. Please either reject components/*.<native ext> for native rows or include them in the native staging path.

Useful? React with 👍 / 👎.

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