The luau Plugin loads a Script Headless (#79) #91

Merged
crowmaki merged 3 commits from luau-plugin-loads-a-script-headless into main 2026-09-06 02:54:30 +00:00
Owner

Closes #79. Part of #75.

What

A luau Plugin that stands up Headless, hosts one Luau VM, and runs a Script handed to it as bytes.

  • Publishes cinnabar.script/1 with load(self, name, source: Byte_Span) -> bool and unload(self, name) -> bool. Requires no other Interface.
  • The VM is created in register and closed in shutdown.
  • Each Script is one chunk compiled and run in a fresh environment table whose reads fall through to the shared, sandboxed globals, so two Scripts do not see each other's globals.
  • print and warn are rebound to the engine logger at info and warning. Arguments are rendered without running __tostring, so no Luau error can unwind a callback's Odin frame (ADR-0015).
  • Every entry into the VM goes through pcall with a traceback handler. A compile or runtime failure logs the message and traceback, returns false, and leaves any Script already loaded under that name in force.
  • Every C callback recovers the Plugin State from the VM's thread data and re-establishes context before calling Odin (ADR-0008).
  • plugins/luau joins the justfile packages list.

Tests

tests/luau/plugin_test.odin drives the Plugin with Luau source strings only and covers every acceptance criterion: Headless init/tick/shutdown, print and warn levels, global isolation in both directions, compile failure with the compiler message, runtime failure with a traceback, unload true/false, and replace-on-reload.

just check and just test pass (410 tests across six suites).

Closes #79. Part of #75. ## What A `luau` Plugin that stands up Headless, hosts one Luau VM, and runs a Script handed to it as bytes. - Publishes `cinnabar.script/1` with `load(self, name, source: Byte_Span) -> bool` and `unload(self, name) -> bool`. Requires no other Interface. - The VM is created in `register` and closed in `shutdown`. - Each Script is one chunk compiled and run in a fresh environment table whose reads fall through to the shared, sandboxed globals, so two Scripts do not see each other's globals. - `print` and `warn` are rebound to the engine logger at info and warning. Arguments are rendered without running `__tostring`, so no Luau error can unwind a callback's Odin frame (ADR-0015). - Every entry into the VM goes through `pcall` with a traceback handler. A compile or runtime failure logs the message and traceback, returns false, and leaves any Script already loaded under that name in force. - Every C callback recovers the Plugin State from the VM's thread data and re-establishes `context` before calling Odin (ADR-0008). - `plugins/luau` joins the justfile `packages` list. ## Tests `tests/luau/plugin_test.odin` drives the Plugin with Luau source strings only and covers every acceptance criterion: Headless init/tick/shutdown, `print` and `warn` levels, global isolation in both directions, compile failure with the compiler message, runtime failure with a traceback, `unload` true/false, and replace-on-reload. `just check` and `just test` pass (410 tests across six suites).
A luau Plugin publishes cinnabar.script/1 with load and unload, hosts one
Luau VM created in register and closed in shutdown, and runs each Script as
one chunk in a fresh environment table. print and warn reach the engine
logger; compile and runtime failures are logged with a traceback and leave
any previously loaded Script under that name in force.
print and warn render each argument without running __tostring, so no Luau
error can unwind the callback's Odin frame. The chunkname handed to luau_load
is a real cstring rather than a slice that happened to end on a zero byte.
crowmaki deleted branch luau-plugin-loads-a-script-headless 2026-09-06 02:54:30 +00:00
Sign in to join this conversation.
No reviewers
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
crowmaki/cinnabar!91
No description provided.