Prototype LLRT native executor and package#14
Draft
robinbraemer wants to merge 1 commit into
Draft
Conversation
Rationale: Explore LLRT as the preferred lightweight execution runtime by adding a standalone TypeScript-friendly @robinbraemer/llrt package, napi-rs native bridge, codemode executor adapter, native packaging workflow, and benchmark/stress evidence. Rejected: Do not replace the fallback executors yet; LLRT still needs a real GitHub Actions native matrix run and artifact inspection before production-default adoption. Do not embed LLRT directly into codemode; the standalone package keeps native packaging and runtime API reusable. Risk: Introduces a new Rust/native package and release workflow. The prototype is intentionally JSON-safe and fresh-VM-per-call, which is safer but may leave reusable-VM performance for later. Tested: mise exec -- task ci; mise exec actionlint -- actionlint .github/workflows/*.yml; mise exec -- pnpm --filter @robinbraemer/llrt run verify:native-artifacts; mise exec -- npm pack --dry-run from packages/llrt; benchmark:executors report generation. Not-tested: Real GitHub Actions native matrix run across macOS and Linux runners; publishing to npm; CNAP repository consumption of the published package.
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
This PR prototypes an LLRT-first execution path for codemode and prepares a standalone TypeScript-friendly
@robinbraemer/llrtpackage.It includes:
packages/llrtpackage with a napi-rs Rust binding around LLRT's Rust VM API.LlrtRuntime.callJson<TInput, TOutput>()API with typed success/failure results, memory/wall-time/stack options, host callbacks, fresh VM per call, and tests for errors, isolation, callbacks, memory, timeout, and stress behavior.LlrtNativeExecutor,createExecutor()preference for LLRT when installed, and fallback executors left in place.llrt-native,isolated-vm, and QuickJS WASM.internal/superpowers/.Verification run locally
mise exec -- task cimise exec actionlint -- actionlint .github/workflows/*.ymlmise exec -- pnpm --filter @robinbraemer/llrt run verify:native-artifactsmise exec -- npm pack --dry-runfrompackages/llrtmise exec -- pnpm --filter @robinbraemer/codemode run benchmark:executors -- --report internal/superpowers/reports/2026-06-10-llrt-executor-benchmark.md --json internal/superpowers/reports/2026-06-10-llrt-executor-benchmark.jsonCurrent verdict
LLRT is a strong default candidate, but this PR intentionally does not claim the production migration is complete. The local prototype proves the core feasibility: importable TypeScript API, napi-rs bridge, fresh VM isolation, JSON-safe host callbacks, resource controls, codemode executor compatibility, and competitive local benchmark behavior.
The remaining hard gate is a real GitHub Actions run of
.github/workflows/llrt-native.ymlacross the four native runners, followed by artifact inspection and packed install smoke results from CI.Handoff prompt for the next AI agent
You are continuing the LLRT-first runtime adoption work in the
cnap-tech/codemoderepository. Start from this PR branch:codex/llrt-executor-poc.Goal: finish proving whether LLRT can become codemode's default executor, then prepare the follow-up path to consume the package from CNAP. Preserve the current direction unless evidence contradicts it: standalone
@robinbraemer/llrtpackage first, codemode consumes it through a thin adapter, fallback engines remain available for rollback.Context already completed in this PR:
packages/llrtexists as a standalone Node/TypeScript package backed by a Rust napi-rs addon.LlrtRuntime.callJson<TInput, TOutput>()with typedLlrtResult<TOutput>.memoryMB,wallTimeMs,cpuTimeMsplaceholder, andmaxStackBytes.TIMEOUT,MEMORY_LIMIT,SERIALIZATION_ERROR,EVALUATION_ERROR,NATIVE_LOAD_ERROR, andRUNTIME_DISPOSED.LlrtNativeExecutor;createExecutor()prefers LLRT when@robinbraemer/llrtis installed, falls back only when the LLRT package itself is missing, and fails loudly when installed LLRT is broken.isolated-vm, QuickJS WASM, andLlrtProcessExecutorremain available.packages/llrt/npm/*for darwin/linux arm64/x64..github/workflows/llrt-native.ymldefines the native prebuild/package/publish workflow.verify:native-artifactsvalidates optional native package manifests; strict mode also requires.nodefiles after artifacts are downloaded.smoke:packed-installpacks main + current native package and tests import/execution from a temporary consumer project.packages/codemode/scripts/benchmark-executors.ts, with a saved report atinternal/superpowers/reports/2026-06-10-llrt-executor-benchmark.md.internal/superpowers/specs/2026-06-10-standalone-llrt-typescript-runtime-design.mdandinternal/superpowers/plans/2026-06-10-standalone-llrt-calljson.md.Important local caveats:
mise exec -- ...for verification so Node stays at the pinned Node 24 ABI. Running rawtask ciunder Node 26 can fail becauseisolated-vmwas built for Node 24..codex/is unrelated and should not be committed.dist/,node_modules/,packages/llrt/vendor/,packages/llrt/native/target/,*.node, and*.tgzare intentionally ignored.pnpm.onlyBuiltDependencies; do not chase it unless you choose to clean package-manager config as a separate scoped change.Recommended next steps:
.github/workflows/llrt-native.ymlon this branch.macos-15foraarch64-apple-darwinmacos-15-intelforx86_64-apple-darwinubuntu-24.04forx86_64-unknown-linux-gnuubuntu-24.04-armforaarch64-unknown-linux-gnullrt-native-*artifacts, runsverify:native-artifacts:strict, dry-run-packs every optional package, and passessmoke:packed-install.internal/superpowers/specs/2026-06-10-standalone-llrt-typescript-runtime-design.mdwith the actual run URL, job conclusions, and artifact names.@robinbraemer/llrtor first consume it via workspace/git dependency for one CNAP integration test.Suggested verification commands before changing this PR from draft to ready:
Do not mark the larger adoption goal complete until the actual native matrix run and downstream consumption plan are verified with current evidence.