Skip to content

feat(platform-bun): add an isolated microVM CodeExecutor - #84

Merged
systemfsoftware-bot merged 5 commits into
mainfrom
feat/node-code-executor
Dec 5, 2026
Merged

systemfsoftware-bot merged 5 commits into
mainfrom
feat/node-code-executor

Conversation

@systemfsoftware-maker

@systemfsoftware-maker systemfsoftware-maker commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

What

Adds a new public package, @systemfsoftware/agent-platform-bun, whose ./code-executor subpath implements the library's CodeExecutor port for hosts running on Bun. Each pass runs the model-written program on Bun inside a fresh hardware-isolated microVM.

Why a new package

The repository separates platforms by package (platform-cloudflare, platform-node). platform-node names and depends on Node host services (@effect/platform-node, @effect/sql-sqlite-node), so a Bun consumer should not import its subpath. The new Bun package is the platform boundary for Bun hosts; the executor moved there in this PR rather than shipping from platform-node.

Bun on both sides

  • Guest: the default image is oven/bun:1-alpine and the harness is started with bun; the generated program runs on Bun.
  • Host: the adapter's module graph imports no node: module (the built bundle contains node: only inside the guest harness template). It uses Web APIs, Effect, the N-API microsandbox binding, and Effect Random for sandbox names.
  • The conformance suite runs on the Bun host via pnpm --filter @systemfsoftware/agent-platform-bun test:conformance-bun.

Mechanism

Each pass boots one ephemeral microVM whose network device is disabled before boot, so NetworkDisabled is enforced by the virtualization boundary, not generated JavaScript. microsandbox is used directly rather than @systemfsoftware/effect-microsandbox: the wrapper's spec leaves public egress on when host access is off, and its job API has no streaming stdin for host callbacks. Rejected alternatives: node:vm, worker_threads, a child process, global shadowing, and an in-process fallback.

Minimum isolation

Property How it is enforced Scenario that shows it
Network disabled at the VM boundary disableNetwork() before boot; the guest reports no non-loopback interface and its own stack refuses egress A generated program has no network interface and cannot reach the network
Read-only root with one writable scratch directory A one-time root provisioning step remounts / and /dev/shm ro; the only remaining writable filesystem is the tmpfs at /scratch, chowned to the workload with mode 0700 The guest root is read-only and the scratch directory is the only writable place
Unprivileged user inside Harness and generated program run as uid/gid 65534; scratch is owned by that user The guest runs as an unprivileged user with no host environment
No host credential or environment passed in The builder passes no environment, secrets, host bind mounts, or credentials; exec sets only HOME/TMPDIR to /scratch, and the test shows the host PATH is absent The guest runs as an unprivileged user with no host environment
Host mounts pinned libraries read-only readOnlyMounts bind mounts each host directory with readonly, noexec, nosuid, nodev A pinned library directory mounts read-only

The host process needs the virtualization device (/dev/kvm on Linux), not root. The in-guest provisioning step runs once as root before the workload; it only chowns scratch and changes mount flags, and no generated code runs in it.

Boundary protocol

A fixed guest harness evaluates the single async-function expression, captures bounded logs, and exchanges newline-delimited JSON with the host over guest stdin/stdout. The host admits every call against maxHostCalls before dispatch, decodes host outcomes against CodeHostCallResult, enforces argument and result byte budgets, and forwards success/failure envelopes. maxHostCallConcurrency server fibers preserve dispatch order for sequential programs. Interrupting the pass interrupts an in-flight host call and destroys the VM through the Scope finalizer.

Limits and failure modes

  • NetworkAllowlist → CodeExecutorUnsupportedError (network); cpuMillis → CodeExecutorUnsupportedError (cpu-limit); a console or duplicate namespace → CodeExecutorUnsupportedError (namespaces).
  • A host that cannot start a VM (no virtualization, unpullable image, image without sh/mount) fails with CodeExecutorStartError; there is no in-process run.
  • maxWallTime starts when the harness reports ready, so image pull and boot are not charged against the program.

Verification

  • Shared CodeExecutorConformance (16 cases) on Bun: pnpm --filter @systemfsoftware/agent-platform-bun test:conformance-bun → 16/16 passed.
  • Isolation feature packages/platform-bun/tests/code-executor.integration.test.ts, 4 live scenarios, each twice on fresh services → 4/4 passed with the Bun guest.
  • Start-failure probe on a Bun host: unpullable image → CodeExecutorStartError.
  • typecheck for both platform packages; build and check:pack for both; pnpm check:exports (12 public packages); pnpm check:package-purity; oxlint --type-aware and dprint check on the touched files.

Changeset

New package @systemfsoftware/agent-platform-bun at 0.0.0 with a minor changeset: the release PR publishes it as 0.1.0.

- Run each Code Mode pass in a fresh hardware-isolated microVM with its network device disabled before boot, so NetworkDisabled is enforced by the isolation boundary; a NetworkAllowlist, cpuMillis, or a console namespace is refused as a typed unsupported error, and an unstartable VM is a CodeExecutorStartError.
- Cross the boundary with a line-delimited host-call protocol over guest stdin/stdout: the host admits every call against its caps before dispatch, decodes the host result at the protocol boundary, bounds argument/result bytes, and interrupts in-flight calls with the pass.
- Depend on microsandbox directly because the Effect test-container wrapper exposes neither a disabled network device nor streaming guest stdin; the rejected alternatives are node:vm, worker_threads, a child process, and effect-microsandbox as shipped.
- Add the executor module and the microsandbox catalog entry the first commit referenced.
- Each pass boots one ephemeral microVM, disables its network device before boot, streams host calls over guest stdin/stdout, enforces caps and byte budgets host-side, and maps start/termination to typed errors.
@mergify

mergify Bot commented Dec 5, 2026

Copy link
Copy Markdown

Merge Protections

🔴 2 of 4 protections blocking · waiting on 👀 reviews and 🙋 you

Protection Waiting on
🔴 Merge authority 👀 reviews and 🙋 you
🔴 🚦 Auto-queue 👀 reviews and 🙋 you
🟢 Conventional PR title —
🟢 Hold label —

🔴 Merge authority

Waiting for any of

  • approved-reviews-by = kiro-systemf[bot]
  • approved-reviews-by = systemfsoftware-bot
This rule is failing.

A PR merges only after the review app approves it (phase 1) or the review bot's review-gate passes (phase 2). A Dependabot patch or minor bump skips the review gate; a major bump still needs it.

  • any of:
    • all of:
      • author = dependabot[bot]
      • any of:
        • dependabot-update-type = version-update:semver-minor
        • dependabot-update-type = version-update:semver-patch
        • title ~= (?i)\bthe [a-z0-9@/._-]*(minor|patch)[a-z0-9@/._-]* group\b
      • dependabot-update-type != version-update:semver-major
    • any of:
      • approved-reviews-by = kiro-systemf[bot]
      • approved-reviews-by = systemfsoftware-bot
  • #changes-requested-reviews-by = 0

🔴 🚦 Auto-queue

Waiting for any of

  • approved-reviews-by = kiro-systemf[bot]
  • approved-reviews-by = systemfsoftware-bot
This rule is failing.

When all merge protections are satisfied and these conditions match, this pull request will be queued automatically.

  • any of:
    • all of:
      • author = dependabot[bot]
      • any of:
        • dependabot-update-type = version-update:semver-minor
        • dependabot-update-type = version-update:semver-patch
        • title ~= (?i)\bthe [a-z0-9@/._-]*(minor|patch)[a-z0-9@/._-]* group\b
      • dependabot-update-type != version-update:semver-major
    • any of:
      • approved-reviews-by = kiro-systemf[bot]
      • approved-reviews-by = systemfsoftware-bot
  • -draft
  • -label = hold

Show 2 satisfied protections

🟢 Conventional PR title

The squash commit takes the PR title, so the title must be a conventional commit.

  • title ~= ^(build|chore|ci|docs|feat|fix|perf|refactor|revert|style|test)(\([^)]+\))?!?: \S

🟢 Hold label

The hold label keeps a PR out of the default branch.

  • -label = hold

- Run the guest workload as uid/gid 65534 with the root filesystem remounted read-only, exactly one writable tmpfs scratch directory at /scratch, and host library directories mounted read-only; pass no host environment or credentials.
- Prove each boundary property in a live Gherkin feature: no non-loopback interface and refused egress, read-only root and shared memory with a writable scratch, unprivileged identity without the host PATH, and a read-only pinned-library mount.
- Adopt the repository test runner for the new feature and raise vitest to the version its peer range requires.
- Move the microVM executor out of the Node platform package into a new Bun platform package: the guest image and harness run on Bun, and the host path imports no node: modules, so a Bun host can run the adapter and the conformance suite under Bun.
- Keep the sealed isolation boundary and its live integration scenarios, now executing the model-written program on Bun inside the microVM.
@systemfsoftware-maker systemfsoftware-maker changed the title feat(platform-node): add an isolated microVM CodeExecutor feat(platform-bun): add an isolated microVM CodeExecutor Dec 5, 2026
@systemfsoftware-bot

Copy link
Copy Markdown
Contributor

Merged directly by the maintainer; no merge-queue draft ran on this head.

@systemfsoftware-bot
systemfsoftware-bot merged commit 018d2a4 into main Dec 5, 2026
10 of 16 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.

2 participants