From 4e479cf20d97872ec0d54b267669952e65a955b4 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Sat, 5 Dec 2026 05:33:09 +0000 Subject: [PATCH 1/5] feat(platform-node): add isolated microVM CodeExecutor - 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. --- .changeset/node-microvm-code-executor.md | 9 + docs/src/content/docs/guide/sandbox.md | 6 +- packages/platform-node/package.json | 8 +- packages/platform-node/src/index.ts | 1 + .../src/internal/code-executor-guest.ts | 209 ++++++++++++++++++ .../src/internal/code-executor.schema.ts | 72 ++++++ pnpm-workspace.yaml | 1 + 7 files changed, 304 insertions(+), 2 deletions(-) create mode 100644 .changeset/node-microvm-code-executor.md create mode 100644 packages/platform-node/src/internal/code-executor-guest.ts create mode 100644 packages/platform-node/src/internal/code-executor.schema.ts diff --git a/.changeset/node-microvm-code-executor.md b/.changeset/node-microvm-code-executor.md new file mode 100644 index 000000000..169a2ce67 --- /dev/null +++ b/.changeset/node-microvm-code-executor.md @@ -0,0 +1,9 @@ +--- +"@systemfsoftware/agent-platform-node": patch +--- + +Add `microVmCodeExecutorLayer` to the Node platform package: each pass runs in a fresh hardware-isolated microVM whose network device is disabled before boot, so `NetworkDisabled` is enforced by the isolation boundary. A host without hardware virtualization fails the pass with `CodeExecutorStartError`, while `NetworkAllowlist`, `cpuMillis`, and a namespace named `console` are refused with `CodeExecutorUnsupportedError`. + +```ts +import { microVmCodeExecutorLayer } from '@systemfsoftware/agent-platform-node/node-code-executor' +``` diff --git a/docs/src/content/docs/guide/sandbox.md b/docs/src/content/docs/guide/sandbox.md index 8f4040521..fcf9bca91 100644 --- a/docs/src/content/docs/guide/sandbox.md +++ b/docs/src/content/docs/guide/sandbox.md @@ -13,7 +13,11 @@ JavaScript over allowlisted tools and [browser services](/guide/browser/) for we `CodeExecutor` gives one generated program a narrow host-call capability; it does not grant a shell. The Cloudflare adapter runs each pass in a fresh Dynamic Worker with ambient network -access disabled. Calls into application tools still require the host's current authorization. +access disabled. The Node adapter runs each pass in a fresh hardware-isolated microVM whose +network device is disabled before boot; it requires hardware virtualization (KVM on Linux, +Hypervisor.framework on Apple Silicon, or Windows Hypervisor Platform), pulls its guest image +on first use, and fails the pass with `CodeExecutorStartError` when the host cannot start a VM. +Calls into application tools still require the host's current authorization. Browser adapters own network access and page lifetimes separately. Their configuration controls which destinations and browser capabilities a session can use. Keep credentials and resource diff --git a/packages/platform-node/package.json b/packages/platform-node/package.json index 2250aba6f..b2a8e99f1 100644 --- a/packages/platform-node/package.json +++ b/packages/platform-node/package.json @@ -16,6 +16,7 @@ "sideEffects": [], "exports": { ".": "./src/index.ts", + "./node-code-executor": "./src/NodeCodeExecutor.ts", "./node-durable-agent-runtime": "./src/NodeDurableAgentRuntime.ts", "./node-durable-host": "./src/NodeDurableHost.ts", "./node-scheduling": "./src/NodeScheduling.ts", @@ -29,6 +30,10 @@ "types": "./dist/index.d.mts", "default": "./dist/index.mjs" }, + "./node-code-executor": { + "types": "./dist/NodeCodeExecutor.d.mts", + "default": "./dist/NodeCodeExecutor.mjs" + }, "./node-durable-agent-runtime": { "types": "./dist/NodeDurableAgentRuntime.d.mts", "default": "./dist/NodeDurableAgentRuntime.mjs" @@ -62,7 +67,8 @@ "@effect/platform-node": "catalog:", "@effect/sql-sqlite-node": "catalog:", "@systemfsoftware/agent": "workspace:*", - "@systemfsoftware/agent-storage-sqlite": "workspace:*" + "@systemfsoftware/agent-storage-sqlite": "workspace:*", + "microsandbox": "catalog:" }, "devDependencies": { "@arethetypeswrong/cli": "catalog:", diff --git a/packages/platform-node/src/index.ts b/packages/platform-node/src/index.ts index f17f66d42..6de16c9c2 100644 --- a/packages/platform-node/src/index.ts +++ b/packages/platform-node/src/index.ts @@ -1,3 +1,4 @@ +export * as NodeCodeExecutor from './NodeCodeExecutor' export * as NodeDurableAgentRuntime from './NodeDurableAgentRuntime' export * as NodeDurableHost from './NodeDurableHost' export * as NodeScheduling from './NodeScheduling' diff --git a/packages/platform-node/src/internal/code-executor-guest.ts b/packages/platform-node/src/internal/code-executor-guest.ts new file mode 100644 index 000000000..919810201 --- /dev/null +++ b/packages/platform-node/src/internal/code-executor-guest.ts @@ -0,0 +1,209 @@ +/** @internal */ +export const codeExecutorGuestSource = String.raw` +import fs from 'node:fs' + +const config = JSON.parse(fs.readFileSync(process.argv[2], 'utf8')) +const limits = config.limits + +const MAX_LOG_LINES = 4096 +const MAX_LOG_LINE_CHARACTERS = 16000 +const MAX_THROWN_CHARACTERS = 4000 + +const utf8 = (text) => new TextEncoder().encode(text).byteLength + +const safeText = (value) => { + try { + if (value instanceof Error) return (value.name + ': ' + value.message).slice(0, MAX_THROWN_CHARACTERS) + if (typeof value === 'string') return value.slice(0, MAX_THROWN_CHARACTERS) + const encoded = JSON.stringify(value) + return (encoded === undefined ? String(value) : encoded).slice(0, MAX_THROWN_CHARACTERS) + } catch { + return '[unserializable value]' + } +} + +const safeJson = (value) => { + try { + const encoded = JSON.stringify(value) + if (encoded === undefined) return safeText(value) + if (encoded.length <= MAX_THROWN_CHARACTERS) return JSON.parse(encoded) + return safeText(value) + } catch { + return safeText(value) + } +} + +const logs = [] +let logBytes = 0 +let fatal = null + +const boundedLogs = () => logs.slice(0, MAX_LOG_LINES) + +const writeLog = (...values) => { + const joined = values.map(safeText).join(' ') + const line = joined.length > MAX_LOG_LINE_CHARACTERS ? joined.slice(0, MAX_LOG_LINE_CHARACTERS - 1) + '…' : joined + const bytes = utf8(line) + if (logs.length >= MAX_LOG_LINES || logBytes + bytes > limits.maxLogBytes) { + fatal = fatal ?? { t: 'log-limit', observed: logBytes + bytes, logs: boundedLogs() } + throw new Error('code executor log limit exceeded') + } + logs.push(line) + logBytes += bytes +} + +const emit = (message, done) => { + process.stdout.write(JSON.stringify(message) + '\n', done) +} + +const finish = (message) => { + emit(message, () => process.exit(0)) +} + +const pending = new Map() +let nextId = 1 +let buffer = '' + +const receive = (line) => { + let message + try { + message = JSON.parse(line) + } catch { + return + } + if (message === null || typeof message !== 'object' || message.t !== 'response') return + const entry = pending.get(message.id) + if (entry === undefined) return + pending.delete(message.id) + if (message.ok) { + entry.resolve(message.value) + return + } + const error = message.error + if (error !== null && typeof error === 'object') { + try { + Object.defineProperty(error, Symbol.toPrimitive, { value: () => JSON.stringify(error) }) + } catch {} + } + entry.reject(error) +} + +process.stdin.setEncoding('utf8') +process.stdin.on('data', (chunk) => { + buffer += chunk + let index = buffer.indexOf('\n') + while (index >= 0) { + const line = buffer.slice(0, index) + buffer = buffer.slice(index + 1) + if (line !== '') receive(line) + index = buffer.indexOf('\n') + } +}) + +const call = (namespace, method, argument) => new Promise((resolve, reject) => { + if (fatal !== null) { + reject(new Error('the pass is closing')) + return + } + let encoded + try { + encoded = JSON.stringify(argument) + } catch { + encoded = undefined + } + if (encoded === undefined) { + reject(new TypeError('host call arguments must be JSON values')) + return + } + const id = nextId + nextId += 1 + pending.set(id, { resolve, reject }) + emit({ t: 'call', id, namespace, method, argument: JSON.parse(encoded) }) +}) + +const namespaces = {} +for (const namespace of config.namespaces) { + const methods = {} + for (const method of namespace.methods) { + methods[method] = (argument) => call(namespace.name, method, argument) + } + namespaces[namespace.name] = methods +} + +const consoleShim = { log: writeLog, info: writeLog, warn: writeLog, error: writeLog, debug: writeLog } + +emit({ t: 'ready' }) + +const classify = (thrown, evaluation) => ({ + t: 'failed', + reason: evaluation || thrown instanceof Error ? 'threw' : 'rejected', + thrown: safeJson(thrown), + message: safeText(thrown), + logs: boundedLogs(), +}) + +const run = async () => { + let factory + try { + factory = new Function( + 'console', + ...config.namespaces.map((namespace) => namespace.name), + '"use strict";\nreturn (' + config.source + ');', + ) + } catch (error) { + finish({ t: 'source-invalid', message: safeText(error), logs: boundedLogs() }) + return + } + let candidate + try { + candidate = factory(consoleShim, ...config.namespaces.map((namespace) => namespaces[namespace.name])) + } catch (error) { + finish(fatal ?? classify(error, true)) + return + } + if (typeof candidate !== 'function') { + finish({ t: 'source-not-a-function', actual: typeof candidate, logs: boundedLogs() }) + return + } + let value + try { + value = await candidate() + } catch (error) { + finish(fatal ?? classify(error, false)) + return + } + if (fatal !== null) { + finish(fatal) + return + } + let encoded + try { + encoded = JSON.stringify(value) + } catch { + encoded = undefined + } + if (encoded === undefined) { + finish({ + t: 'failed', + reason: 'non-json-result', + thrown: null, + message: 'The program must return a JSON value', + logs: boundedLogs(), + }) + return + } + const resultBytes = utf8(encoded) + if (resultBytes > limits.maxResultBytes) { + finish({ t: 'result-limit', observed: resultBytes, logs: boundedLogs() }) + return + } + finish({ + t: 'completed', + value: JSON.parse(encoded), + logs: boundedLogs(), + logBytes, + resultBytes, + }) +} + +run() +` diff --git a/packages/platform-node/src/internal/code-executor.schema.ts b/packages/platform-node/src/internal/code-executor.schema.ts new file mode 100644 index 000000000..c11dc35d4 --- /dev/null +++ b/packages/platform-node/src/internal/code-executor.schema.ts @@ -0,0 +1,72 @@ +import * as Schema from 'effect/Schema' + +/** @internal */ +export const GuestLogs = Schema.Array(Schema.String).check(Schema.isMaxLength(4_096)) + +/** @internal */ +export const GuestCall = Schema.Struct({ + t: Schema.Literal('call'), + id: Schema.Natural, + namespace: Schema.String, + method: Schema.String, + argument: Schema.Json, +}) + +/** @internal */ +export const GuestReady = Schema.Struct({ t: Schema.Literal('ready') }) + +/** @internal */ +export const GuestOutcome = Schema.Union([ + Schema.Struct({ + t: Schema.Literal('completed'), + value: Schema.Json, + logs: GuestLogs, + logBytes: Schema.Natural, + resultBytes: Schema.Natural, + }), + Schema.Struct({ + t: Schema.Literal('failed'), + reason: Schema.Literals(['threw', 'rejected', 'non-json-result']), + thrown: Schema.Json, + message: Schema.String, + logs: GuestLogs, + }), + Schema.Struct({ t: Schema.Literal('source-invalid'), message: Schema.String, logs: GuestLogs }), + Schema.Struct({ t: Schema.Literal('source-not-a-function'), actual: Schema.String, logs: GuestLogs }), + Schema.Struct({ t: Schema.Literal('log-limit'), observed: Schema.Natural, logs: GuestLogs }), + Schema.Struct({ t: Schema.Literal('result-limit'), observed: Schema.Natural, logs: GuestLogs }), +]) + +/** @internal */ +export const GuestMessage = Schema.Union([GuestCall, GuestReady, GuestOutcome]) + +/** @internal */ +export const GuestResponse = Schema.Struct({ + t: Schema.Literal('response'), + id: Schema.Natural, + ok: Schema.Boolean, + value: Schema.optionalKey(Schema.Json), + error: Schema.optionalKey(Schema.Json), +}) + +/** @internal */ +export const GuestConfig = Schema.Struct({ + source: Schema.String, + namespaces: Schema.Array( + Schema.Struct({ name: Schema.String, methods: Schema.Array(Schema.String) }), + ), + limits: Schema.Struct({ + maxLogBytes: Schema.Natural, + maxResultBytes: Schema.Natural, + maxHostCallArgumentBytes: Schema.Natural, + }), +}) + +/** @internal */ +export type GuestCall = typeof GuestCall.Type +/** @internal */ +export type GuestOutcome = typeof GuestOutcome.Type +/** @internal */ +export type GuestResponse = typeof GuestResponse.Type +/** @internal */ +export type GuestConfig = typeof GuestConfig.Type diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 0ecf097f1..530a806ee 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -59,6 +59,7 @@ catalog: "diff": "8.0.4" "@systemfsoftware/effect-cf": "0.60.0" "lucide-react": "1.27.0" + "microsandbox": "^0.7.8" "miniflare": "5.20260811.1-alpha" "puppeteer-core": "25.18.1" "streamdown": "2.5.0" From 2f4806003f833d581bd0e2ff0f793028c9015834 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Sat, 5 Dec 2026 05:33:23 +0000 Subject: [PATCH 2/5] feat(platform-node): implement the microVM CodeExecutor - 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. --- .../platform-node/src/NodeCodeExecutor.ts | 767 ++++++++++++++++++ pnpm-lock.yaml | 6 + 2 files changed, 773 insertions(+) create mode 100644 packages/platform-node/src/NodeCodeExecutor.ts diff --git a/packages/platform-node/src/NodeCodeExecutor.ts b/packages/platform-node/src/NodeCodeExecutor.ts new file mode 100644 index 000000000..e87b0b35a --- /dev/null +++ b/packages/platform-node/src/NodeCodeExecutor.ts @@ -0,0 +1,767 @@ +import { + type CodeExecutionError, + CodeExecutionHost, + CodeExecutionProtocolError, + type CodeExecutionRequest, + CodeExecutionResourceUse, + CodeExecutionResult, + CodeExecutionTimeoutError, + CodeExecutor, + type CodeExecutorExecute, + CodeExecutorStartError, + CodeExecutorTerminatedError, + CodeExecutorUnsupportedError, + CodeHostCall, + CodeHostCallLimitError, + CodeHostCallResult, + CodeOutputLimitError, + CodeProgramFailedError, + CodeSourceError, + type JsIdentifier, +} from '@systemfsoftware/agent/code-executor' +import { SANDBOX_DIAGNOSTIC_MAX_LENGTH, SandboxImplementation } from '@systemfsoftware/agent/sandbox' +import * as Clock from 'effect/Clock' +import * as Deferred from 'effect/Deferred' +import * as Duration from 'effect/Duration' +import * as Effect from 'effect/Effect' +import * as HashSet from 'effect/HashSet' +import * as Layer from 'effect/Layer' +import * as Match from 'effect/Match' +import * as Option from 'effect/Option' +import * as Queue from 'effect/Queue' +import * as Schema from 'effect/Schema' +import type * as Scope from 'effect/Scope' +import * as Semaphore from 'effect/Semaphore' +import type { ExecEvent, ExecHandle, ExecSink, Sandbox as MicroSandbox } from 'microsandbox' + +import { codeExecutorGuestSource } from './internal/code-executor-guest' +import { + type GuestCall, + type GuestConfig, + GuestConfig as GuestConfigSchema, + GuestMessage, + type GuestOutcome, + type GuestResponse, + GuestResponse as GuestResponseSchema, +} from './internal/code-executor.schema' + +export const microVmCodeExecutorImplementation = SandboxImplementation.make({ + isolation: 'isolated', + identity: 'node-microvm-javascript', +}) + +const GUEST_DIR = '/opt/code-executor' +const GUEST_HARNESS_PATH = `${GUEST_DIR}/harness.mjs` +const GUEST_CONFIG_PATH = `${GUEST_DIR}/pass.json` +const DEFAULT_IMAGE = 'node:22-alpine' +const GUEST_READY_TIMEOUT = Duration.seconds(60) +const MAX_PROTOCOL_LINE_BYTES = 16 * 1024 * 1024 +const RESERVED_NAMESPACE = 'console' + +const reservedNamespaces = HashSet.fromIterable([RESERVED_NAMESPACE]) +const decodeGuestLine = Schema.decodeUnknownOption(Schema.fromJsonString(GuestMessage)) +const encodeGuestResponse = Schema.encodeOption(Schema.fromJsonString(GuestResponseSchema)) +const encodeGuestConfig = Schema.encodeOption(Schema.fromJsonString(GuestConfigSchema)) +const encodeJson = Schema.encodeOption(Schema.fromJsonString(Schema.Json)) + +const utf8ByteLength = (value: string): number => new TextEncoder().encode(value).byteLength + +const boundedMessage = (value: string): string => value.slice(0, SANDBOX_DIAGNOSTIC_MAX_LENGTH) + +const jsonText = (value: Schema.Json): Option.Option => encodeJson(value) + +const protocolError = (message: string): CodeExecutionProtocolError => + CodeExecutionProtocolError.make({ + implementation: microVmCodeExecutorImplementation, + message: boundedMessage(message), + }) + +const terminatedError = (detail: string): CodeExecutorTerminatedError => + CodeExecutorTerminatedError.make({ + implementation: microVmCodeExecutorImplementation, + message: boundedMessage(`The guest harness stopped without a program result: ${detail}`), + }) + +const startError = (message: string): CodeExecutorStartError => + CodeExecutorStartError.make({ + implementation: microVmCodeExecutorImplementation, + message: boundedMessage(message), + }) + +const unsupported = ( + feature: 'network' | 'cpu-limit' | 'namespaces', + message: string, +): CodeExecutorUnsupportedError => + CodeExecutorUnsupportedError.make({ + implementation: microVmCodeExecutorImplementation, + feature, + message, + }) + +export interface MicroVmCodeExecutorOptions { + readonly image?: string +} + +const checkNetwork = ( + request: CodeExecutionRequest, +): Effect.Effect => + Match.value(request.network).pipe( + Match.tag('NetworkDisabled', () => Effect.void), + Match.tag('NetworkAllowlist', () => + Effect.fail( + unsupported( + 'network', + 'The microVM executor boots with its network device disabled; it cannot enforce an egress allowlist, so only NetworkDisabled is accepted', + ), + )), + Match.exhaustive, + ) + +const checkCpu = ( + request: CodeExecutionRequest, +): Effect.Effect => + request.limits.cpuMillis === undefined + ? Effect.void + : Effect.fail( + unsupported( + 'cpu-limit', + 'A microVM exposes a vCPU count, not a CPU-millisecond budget; this executor cannot enforce cpuMillis', + ), + ) + +const reservedCollision = (name: JsIdentifier): string | undefined => + HashSet.has(reservedNamespaces, name) ? 'the harness console' : undefined + +const duplicateCollision = ( + seen: HashSet.HashSet, + name: JsIdentifier, +): string | undefined => HashSet.has(seen, name) ? 'another namespace' : undefined + +const collisionOf = ( + seen: HashSet.HashSet, + name: JsIdentifier, +): string | undefined => { + const reserved = reservedCollision(name) + + return reserved === undefined ? duplicateCollision(seen, name) : reserved +} + +const refuseCollision = ( + name: JsIdentifier, + collision: string | undefined, +): Effect.Effect => + collision === undefined + ? Effect.void + : Effect.fail(unsupported('namespaces', `Namespace ${name} collides with ${collision}`)) + +const checkNamespaces = ( + request: CodeExecutionRequest, +): Effect.Effect => + Effect.gen(function*() { + let seen = HashSet.empty() + + for (const namespace of request.namespaces) { + yield* refuseCollision(namespace.name, collisionOf(seen, namespace.name)) + seen = HashSet.add(seen, namespace.name) + } + }) + +const checkSourceSize = ( + request: CodeExecutionRequest, +): Effect.Effect => + Effect.gen(function*() { + const sourceBytes = utf8ByteLength(request.source) + + if (sourceBytes <= request.limits.maxSourceBytes) return + return yield* CodeSourceError.make({ + implementation: microVmCodeExecutorImplementation, + reason: 'oversized', + message: boundedMessage( + `Source is ${sourceBytes} bytes; the request allows ${request.limits.maxSourceBytes}`, + ), + }) + }) + +const validateRequest = ( + request: CodeExecutionRequest, +): Effect.Effect => + Effect.gen(function*() { + yield* checkNetwork(request) + yield* checkCpu(request) + yield* checkNamespaces(request) + yield* checkSourceSize(request) + }) + +interface GuestPatch { + mkdir(path: string): GuestPatch + text(path: string, content: string): GuestPatch +} + +interface GuestProcess { + readonly handle: ExecHandle + readonly sink: ExecSink +} + +interface PassCounter { + calls: number +} + +let sandboxSequence = 0 + +const guestPatch = (configText: string) => (patch: GuestPatch): GuestPatch => + patch + .mkdir('/opt') + .mkdir(GUEST_DIR) + .text(GUEST_HARNESS_PATH, codeExecutorGuestSource) + .text(GUEST_CONFIG_PATH, configText) + +const createSandbox = async (config: GuestConfig, image: string): Promise => { + const { Sandbox } = await import('microsandbox') + + sandboxSequence += 1 + const configText = Option.getOrElse(encodeGuestConfig(config), () => '') + + return await Sandbox.builder(`effect-agent-code-executor-${process.pid}-${sandboxSequence}`) + .image(image) + .ephemeral(true) + .disableNetwork() + .patch(guestPatch(configText)) + .create() +} + +const launchSandbox = ( + config: GuestConfig, + image: string, +): Effect.Effect => + Effect.tryPromise({ + try: () => createSandbox(config, image), + catch: (cause) => + startError( + cause instanceof Error ? `The microVM could not start: ${cause.message}` : 'The microVM could not start', + ), + }) + +const stopSandbox = (sandbox: MicroSandbox): Effect.Effect => + Effect.tryPromise({ + try: () => sandbox.destroy({ force: true }), + catch: () => 'the microVM teardown failed', + }).pipe(Effect.ignore) + +const openGuestProcess = (sandbox: MicroSandbox): Effect.Effect => + Effect.gen(function*() { + const handle = yield* Effect.tryPromise({ + try: () => + sandbox.execStreamWith('node', (builder) => builder.arg(GUEST_HARNESS_PATH).arg(GUEST_CONFIG_PATH).stdinPipe()), + catch: () => startError('The guest harness could not start'), + }) + const sink = yield* Effect.tryPromise({ + try: () => handle.takeStdin(), + catch: () => startError('The guest harness stdin could not be opened'), + }) + + if (sink === null) return yield* startError('The guest harness stdin is unavailable') + return { handle, sink } + }) + +const guestConfigOf = (request: CodeExecutionRequest): GuestConfig => ({ + source: request.source, + namespaces: request.namespaces.map((namespace) => ({ + name: namespace.name, + methods: namespace.methods, + })), + limits: { + maxLogBytes: request.limits.maxLogBytes, + maxResultBytes: request.limits.maxResultBytes, + maxHostCallArgumentBytes: request.limits.maxHostCallArgumentBytes, + }, +}) + +const hostCallLimit = (request: CodeExecutionRequest): CodeHostCallLimitError => + CodeHostCallLimitError.make({ + implementation: microVmCodeExecutorImplementation, + limit: request.limits.maxHostCalls, + logs: [], + }) + +const surfaceLimit = ( + request: CodeExecutionRequest, +): Record<'logs' | 'result' | 'host-call-argument' | 'host-call-result', number> => ({ + logs: request.limits.maxLogBytes, + result: request.limits.maxResultBytes, + 'host-call-argument': request.limits.maxHostCallArgumentBytes, + 'host-call-result': request.limits.maxHostCallResultBytes, +}) + +const outputLimit = ( + surface: 'logs' | 'result' | 'host-call-argument' | 'host-call-result', + request: CodeExecutionRequest, + observed: number, +): CodeOutputLimitError => + CodeOutputLimitError.make({ + implementation: microVmCodeExecutorImplementation, + surface, + limit: surfaceLimit(request)[surface], + observed, + logs: [], + }) + +interface PassContext { + readonly request: CodeExecutionRequest + readonly host: CodeExecutionHost['Service'] + readonly process: GuestProcess + readonly ready: Deferred.Deferred + readonly terminal: Deferred.Deferred + readonly hostCalls: Queue.Queue + readonly writePermit: Semaphore.Semaphore + readonly counter: PassCounter + readonly failPass: (error: CodeExecutionError) => Effect.Effect +} + +const makeFailPass = ( + ready: Deferred.Deferred, + terminal: Deferred.Deferred, +) => +(error: CodeExecutionError): Effect.Effect => + Deferred.fail(terminal, error).pipe( + Effect.andThen(Deferred.fail(ready, error)), + Effect.asVoid, + ) + +const routeMessage = (context: PassContext, message: typeof GuestMessage.Type): Effect.Effect => + Match.value(message).pipe( + Match.discriminator('t')('call', (call) => Queue.offer(context.hostCalls, call).pipe(Effect.asVoid)), + Match.discriminator('t')('ready', () => Deferred.succeed(context.ready, undefined).pipe(Effect.asVoid)), + Match.discriminator('t')('completed', (outcome) => Deferred.succeed(context.terminal, outcome).pipe(Effect.asVoid)), + Match.discriminator('t')('failed', (outcome) => Deferred.succeed(context.terminal, outcome).pipe(Effect.asVoid)), + Match.discriminator('t')( + 'source-invalid', + (outcome) => Deferred.succeed(context.terminal, outcome).pipe(Effect.asVoid), + ), + Match.discriminator('t')( + 'source-not-a-function', + (outcome) => Deferred.succeed(context.terminal, outcome).pipe(Effect.asVoid), + ), + Match.discriminator('t')('log-limit', (outcome) => Deferred.succeed(context.terminal, outcome).pipe(Effect.asVoid)), + Match.discriminator('t')( + 'result-limit', + (outcome) => Deferred.succeed(context.terminal, outcome).pipe(Effect.asVoid), + ), + Match.exhaustive, + ) + +const handleLine = (context: PassContext, text: string): Effect.Effect => + Effect.gen(function*() { + const message = decodeGuestLine(text) + + if (Option.isNone(message)) { + return yield* context.failPass(protocolError('The guest produced a value outside the pass protocol')) + } + yield* routeMessage(context, message.value) + }) + +const consumeLine = (context: PassContext, text: string): Effect.Effect => + text === '' ? Effect.void : handleLine(context, text) + +const drainLines = (context: PassContext, state: { line: string }): Effect.Effect => + Effect.gen(function*() { + let index = state.line.indexOf('\n') + + while (index >= 0) { + const complete = state.line.slice(0, index) + state.line = state.line.slice(index + 1) + yield* consumeLine(context, complete) + index = state.line.indexOf('\n') + } + }) + +const appendStdout = (context: PassContext, state: ReadState, data: Uint8Array): Effect.Effect => + Effect.gen(function*() { + state.line += state.decoder.decode(data, { stream: true }) + + if (state.line.length > MAX_PROTOCOL_LINE_BYTES) { + return yield* context.failPass(protocolError('The guest exceeded the pass protocol line bound')) + } + yield* drainLines(context, state) + }) + +const appendStderr = (state: ReadState, data: Uint8Array): Effect.Effect => + Effect.sync(() => { + state.stderr = (state.stderr + state.decoder.decode(data, { stream: true })).slice( + -SANDBOX_DIAGNOSTIC_MAX_LENGTH, + ) + }) + +const applyEvent = (context: PassContext, state: ReadState, event: ExecEvent): Effect.Effect => + Match.value(event).pipe( + Match.discriminator('kind')('started', () => Effect.void), + Match.discriminator('kind')('stdout', (chunk) => appendStdout(context, state, chunk.data)), + Match.discriminator('kind')('stderr', (chunk) => appendStderr(state, chunk.data)), + Match.discriminator('kind')('exited', (exit) => + Effect.sync(() => { + state.exitCode = exit.code + })), + Match.exhaustive, + ) + +const exitDetail = (state: ReadState): string => + state.exitCode === undefined ? 'the event stream closed' : `exit ${state.exitCode} ${state.stderr}` + +const finishRead = (context: PassContext, state: ReadState): Effect.Effect => + Effect.gen(function*() { + const done = yield* Deferred.isDone(context.terminal) + + if (done) return + yield* context.failPass(terminatedError(exitDetail(state))) + }) + +const nextEvent = (context: PassContext, handle: ExecHandle): Effect.Effect => + Effect.tryPromise({ + try: () => handle.recv(), + catch: () => 'the event stream failed', + }).pipe(Effect.catch((detail) => context.failPass(terminatedError(detail)).pipe(Effect.as(null)))) + +interface ReadState { + line: string + stderr: string + exitCode: number | undefined + readonly decoder: TextDecoder +} + +const readEvents = (context: PassContext, handle: ExecHandle): Effect.Effect => + Effect.gen(function*() { + const state: ReadState = { + line: '', + stderr: '', + exitCode: undefined, + decoder: new TextDecoder(), + } + let event: ExecEvent | null = yield* nextEvent(context, handle) + + while (event !== null) { + yield* applyEvent(context, state, event) + event = yield* nextEvent(context, handle) + } + yield* finishRead(context, state) + }) + +const respond = (context: PassContext, message: GuestResponse): Effect.Effect => + Effect.gen(function*() { + const text = encodeGuestResponse(message) + + if (Option.isNone(text)) { + return yield* context.failPass(protocolError('The host response could not be encoded')) + } + yield* context.writePermit.withPermits(1)( + Effect.tryPromise({ + try: () => context.process.sink.write(`${text.value}\n`), + catch: () => 'the host response could not be written', + }).pipe(Effect.catch((detail) => context.failPass(terminatedError(detail)))), + ) + }) + +const admitCallCount = (context: PassContext): Effect.Effect => + Effect.gen(function*() { + context.counter.calls += 1 + + if (context.counter.calls <= context.request.limits.maxHostCalls) return true + yield* context.failPass(hostCallLimit(context.request)) + return false + }) + +const admitArgumentBytes = (context: PassContext, call: GuestCall): Effect.Effect => + Effect.gen(function*() { + const bytes = Option.match(jsonText(call.argument), { onNone: () => 0, onSome: utf8ByteLength }) + + if (bytes <= context.request.limits.maxHostCallArgumentBytes) return true + yield* context.failPass(outputLimit('host-call-argument', context.request, bytes)) + return false + }) + +const admitCall = (context: PassContext, call: GuestCall): Effect.Effect => + Effect.gen(function*() { + const counted = yield* admitCallCount(context) + + if (!counted) return false + return yield* admitArgumentBytes(context, call) + }) + +const respondSuccess = ( + context: PassContext, + call: GuestCall, + value: Schema.Json, +): Effect.Effect => + Effect.gen(function*() { + const bytes = Option.match(jsonText(value), { onNone: () => 0, onSome: utf8ByteLength }) + + if (bytes > context.request.limits.maxHostCallResultBytes) { + return yield* context.failPass(outputLimit('host-call-result', context.request, bytes)) + } + yield* respond(context, { t: 'response', id: call.id, ok: true, value }) + }) + +const settleHostOutcome = ( + context: PassContext, + call: GuestCall, + outcome: CodeHostCallResult, +): Effect.Effect => + Match.value(outcome).pipe( + Match.tag('CodeHostCallFailure', (failure) => + respond(context, { t: 'response', id: call.id, ok: false, error: failure.error })), + Match.tag('CodeHostCallSuccess', (success) => + respondSuccess(context, call, success.value)), + Match.exhaustive, + ) + +const serveHostCall = (context: PassContext, call: GuestCall): Effect.Effect => + Effect.gen(function*() { + const admitted = yield* admitCall(context, call) + + if (!admitted) return + yield* relayHostCall(context, call) + }) + +const relayHostCall = (context: PassContext, call: GuestCall): Effect.Effect => + Effect.gen(function*() { + const outcome = yield* context.host.call( + CodeHostCall.make({ namespace: call.namespace, method: call.method, argument: call.argument }), + ) + const decoded = Schema.decodeOption(CodeHostCallResult)(outcome) + + if (Option.isNone(decoded)) { + return yield* context.failPass( + protocolError('The execution host returned a value outside the CodeHostCallResult schema'), + ) + } + yield* settleHostOutcome(context, call, decoded.value) + }) + +const serveHostCalls = (context: PassContext): Effect.Effect => + Effect.forever(Queue.take(context.hostCalls).pipe(Effect.flatMap((call) => serveHostCall(context, call)))) + +const resultLimit = (request: CodeExecutionRequest, observed: number): CodeOutputLimitError => + CodeOutputLimitError.make({ + implementation: microVmCodeExecutorImplementation, + surface: 'result', + limit: request.limits.maxResultBytes, + observed, + logs: [], + }) + +const encodedResultBytes = (value: Schema.Json): Effect.Effect => + Option.match(jsonText(value), { + onNone: () => Effect.fail(protocolError('The guest program value could not be re-encoded')), + onSome: (text) => Effect.succeed(utf8ByteLength(text)), + }) + +const withinResultLimit = ( + request: CodeExecutionRequest, + bytes: number, +): Effect.Effect => + bytes <= request.limits.maxResultBytes + ? Effect.succeed(bytes) + : Effect.fail(resultLimit(request, bytes)) + +const measureResult = ( + request: CodeExecutionRequest, + value: Schema.Json, +): Effect.Effect => + Effect.gen(function*() { + const bytes = yield* encodedResultBytes(value) + return yield* withinResultLimit(request, bytes) + }) + +const resourceUse = ( + startedAt: number, + finishedAt: number, + counter: PassCounter, + logBytes: number, + resultBytes: number, +): CodeExecutionResourceUse => + CodeExecutionResourceUse.make({ + wallTime: Duration.millis(Math.max(0, finishedAt - startedAt)), + hostCalls: counter.calls, + logBytes, + resultBytes, + }) + +const completePass = ( + context: PassContext, + outcome: Extract, + startedAt: number, + finishedAt: number, +): Effect.Effect => + Effect.gen(function*() { + const resultBytes = yield* measureResult(context.request, outcome.value) + + return CodeExecutionResult.make({ + implementation: microVmCodeExecutorImplementation, + value: outcome.value, + logs: outcome.logs, + resourceUse: resourceUse( + startedAt, + finishedAt, + context.counter, + outcome.logBytes, + resultBytes, + ), + }) + }) + +const settleOutcome = ( + context: PassContext, + outcome: GuestOutcome, + startedAt: number, + finishedAt: number, +): Effect.Effect => + Match.value(outcome).pipe( + Match.discriminator('t')('completed', (completed) => completePass(context, completed, startedAt, finishedAt)), + Match.discriminator('t')('failed', (failed) => + Effect.fail( + CodeProgramFailedError.make({ + implementation: microVmCodeExecutorImplementation, + reason: failed.reason, + thrown: failed.thrown, + message: boundedMessage(failed.message), + logs: failed.logs, + }), + )), + Match.discriminator('t')('source-invalid', (invalid) => + Effect.fail( + CodeSourceError.make({ + implementation: microVmCodeExecutorImplementation, + reason: 'invalid', + message: boundedMessage(invalid.message), + }), + )), + Match.discriminator('t')('source-not-a-function', (notAFunction) => + Effect.fail( + CodeSourceError.make({ + implementation: microVmCodeExecutorImplementation, + reason: 'not-a-function', + message: boundedMessage( + `The source expression evaluated to ${notAFunction.actual}; it must evaluate to one async function`, + ), + }), + )), + Match.discriminator('t')('log-limit', (limit) => + Effect.fail( + CodeOutputLimitError.make({ + implementation: microVmCodeExecutorImplementation, + surface: 'logs', + limit: context.request.limits.maxLogBytes, + observed: limit.observed, + logs: limit.logs, + }), + )), + Match.discriminator('t')('result-limit', (limit) => + Effect.fail( + CodeOutputLimitError.make({ + implementation: microVmCodeExecutorImplementation, + surface: 'result', + limit: context.request.limits.maxResultBytes, + observed: limit.observed, + logs: limit.logs, + }), + )), + Match.exhaustive, + ) + +const makePassContext = ( + request: CodeExecutionRequest, + host: CodeExecutionHost['Service'], + process: GuestProcess, +): Effect.Effect => + Effect.gen(function*() { + const ready = yield* Deferred.make() + const terminal = yield* Deferred.make() + + return { + request, + host, + process, + ready, + terminal, + hostCalls: yield* Queue.unbounded(), + writePermit: yield* Semaphore.make(1), + counter: { calls: 0 }, + failPass: makeFailPass(ready, terminal), + } + }) + +const awaitReady = (ready: Deferred.Deferred): Effect.Effect => + Deferred.await(ready).pipe( + Effect.timeoutOrElse({ + duration: GUEST_READY_TIMEOUT, + orElse: () => startError('The guest harness did not report ready'), + }), + ) + +const awaitOutcome = ( + request: CodeExecutionRequest, + terminal: Deferred.Deferred, +): Effect.Effect => + Deferred.await(terminal).pipe( + Effect.timeoutOrElse({ + duration: request.limits.maxWallTime, + orElse: () => + CodeExecutionTimeoutError.make({ + implementation: microVmCodeExecutorImplementation, + kind: 'wall-clock', + maxWallTime: request.limits.maxWallTime, + logs: [], + }), + }), + ) + +const runGuestPass = ( + request: CodeExecutionRequest, + host: CodeExecutionHost['Service'], + process: GuestProcess, +): Effect.Effect => + Effect.gen(function*() { + const context = yield* makePassContext(request, host, process) + const concurrency = request.limits.maxHostCallConcurrency ?? 4 + + yield* readEvents(context, process.handle).pipe(Effect.forkScoped) + yield* Effect.forEach( + Array.from({ length: concurrency }, () => serveHostCalls(context)), + (server) => server, + { concurrency, discard: true }, + ).pipe(Effect.forkScoped) + + yield* awaitReady(context.ready) + const startedAt = yield* Clock.currentTimeMillis + const outcome = yield* awaitOutcome(request, context.terminal) + const finishedAt = yield* Clock.currentTimeMillis + + return yield* settleOutcome(context, outcome, startedAt, finishedAt) + }) + +const makeExecute = (options: MicroVmCodeExecutorOptions): CodeExecutorExecute => + Effect.fnUntraced(function*( + request, + ): Effect.fn.Return< + CodeExecutionResult, + CodeExecutionError, + Scope.Scope | CodeExecutionHost + > { + yield* validateRequest(request) + + const host = yield* CodeExecutionHost + const sandbox = yield* Effect.acquireRelease( + launchSandbox(guestConfigOf(request), options.image ?? DEFAULT_IMAGE), + stopSandbox, + ) + const process = yield* openGuestProcess(sandbox) + + return yield* runGuestPass(request, host, process) + }) + +export const microVmCodeExecutorLayer = ( + options: MicroVmCodeExecutorOptions = {}, +): Layer.Layer => Layer.succeed(CodeExecutor)(CodeExecutor.of({ execute: makeExecute(options) })) + +export const NodeCodeExecutor = { + layer: microVmCodeExecutorLayer, + implementation: microVmCodeExecutorImplementation, +} as const diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index c2fcdbfa9..8e6071bc6 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -317,6 +317,9 @@ catalogs: memfs: specifier: 4.71.0 version: 4.71.0 + microsandbox: + specifier: ^0.7.8 + version: 0.7.8 miniflare: specifier: 5.20260811.1-alpha version: 5.20260811.1-alpha @@ -1073,6 +1076,9 @@ importers: '@systemfsoftware/agent-storage-sqlite': specifier: workspace:* version: link:../storage-sqlite + microsandbox: + specifier: 'catalog:' + version: 0.7.8 devDependencies: '@arethetypeswrong/cli': specifier: 'catalog:' From 1549c10706ba85293091c6131b4ab75cf02e2b80 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Sat, 5 Dec 2026 06:05:56 +0000 Subject: [PATCH 3/5] feat(platform-node): seal the microVM executor boundary - 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. --- .changeset/node-microvm-code-executor.md | 2 +- docs/src/content/docs/guide/sandbox.md | 5 +- packages/platform-node/package.json | 2 + .../platform-node/src/NodeCodeExecutor.ts | 104 ++++++- .../__fixtures__/code-executor.schema.ts | 28 ++ .../tests/code-executor.integration.test.ts | 221 +++++++++++++ packages/platform-node/tsconfig.test.json | 3 +- pnpm-lock.yaml | 293 +++++++++++------- pnpm-workspace.yaml | 7 +- 9 files changed, 530 insertions(+), 135 deletions(-) create mode 100644 packages/platform-node/tests/__fixtures__/code-executor.schema.ts create mode 100644 packages/platform-node/tests/code-executor.integration.test.ts diff --git a/.changeset/node-microvm-code-executor.md b/.changeset/node-microvm-code-executor.md index 169a2ce67..2224fe2dc 100644 --- a/.changeset/node-microvm-code-executor.md +++ b/.changeset/node-microvm-code-executor.md @@ -2,7 +2,7 @@ "@systemfsoftware/agent-platform-node": patch --- -Add `microVmCodeExecutorLayer` to the Node platform package: each pass runs in a fresh hardware-isolated microVM whose network device is disabled before boot, so `NetworkDisabled` is enforced by the isolation boundary. A host without hardware virtualization fails the pass with `CodeExecutorStartError`, while `NetworkAllowlist`, `cpuMillis`, and a namespace named `console` are refused with `CodeExecutorUnsupportedError`. +Add `microVmCodeExecutorLayer` to the Node platform package: each pass runs in a fresh hardware-isolated microVM whose network device is disabled before boot, so `NetworkDisabled` is enforced by the isolation boundary. Inside the guest the workload runs as an unprivileged user on a read-only root with one writable scratch directory, receives no host environment or credentials, and reads only host directories mounted read-only through `readOnlyMounts`. A host without hardware virtualization fails the pass with `CodeExecutorStartError`, while `NetworkAllowlist`, `cpuMillis`, and a namespace named `console` are refused with `CodeExecutorUnsupportedError`. ```ts import { microVmCodeExecutorLayer } from '@systemfsoftware/agent-platform-node/node-code-executor' diff --git a/docs/src/content/docs/guide/sandbox.md b/docs/src/content/docs/guide/sandbox.md index fcf9bca91..f5da46964 100644 --- a/docs/src/content/docs/guide/sandbox.md +++ b/docs/src/content/docs/guide/sandbox.md @@ -17,7 +17,10 @@ access disabled. The Node adapter runs each pass in a fresh hardware-isolated mi network device is disabled before boot; it requires hardware virtualization (KVM on Linux, Hypervisor.framework on Apple Silicon, or Windows Hypervisor Platform), pulls its guest image on first use, and fails the pass with `CodeExecutorStartError` when the host cannot start a VM. -Calls into application tools still require the host's current authorization. +Inside the Node guest the workload runs as an unprivileged user on a read-only root with one +writable scratch directory, receives no host environment or credentials, and can read only the +library directories the host mounts read-only. Calls into application tools still require the +host's current authorization. Browser adapters own network access and page lifetimes separately. Their configuration controls which destinations and browser capabilities a session can use. Keep credentials and resource diff --git a/packages/platform-node/package.json b/packages/platform-node/package.json index b2a8e99f1..de9bd1a24 100644 --- a/packages/platform-node/package.json +++ b/packages/platform-node/package.json @@ -73,6 +73,8 @@ "devDependencies": { "@arethetypeswrong/cli": "catalog:", "@effect/vitest": "catalog:", + "@systemfsoftware/effect-gherkin-spec": "catalog:", + "@systemfsoftware/vitest": "catalog:", "effect": "catalog:", "esbuild": "catalog:", "tsdown": "catalog:", diff --git a/packages/platform-node/src/NodeCodeExecutor.ts b/packages/platform-node/src/NodeCodeExecutor.ts index e87b0b35a..7825395a9 100644 --- a/packages/platform-node/src/NodeCodeExecutor.ts +++ b/packages/platform-node/src/NodeCodeExecutor.ts @@ -53,7 +53,14 @@ export const microVmCodeExecutorImplementation = SandboxImplementation.make({ const GUEST_DIR = '/opt/code-executor' const GUEST_HARNESS_PATH = `${GUEST_DIR}/harness.mjs` const GUEST_CONFIG_PATH = `${GUEST_DIR}/pass.json` +const GUEST_SCRATCH = '/scratch' +const SCRATCH_UID = 65_534 +const SCRATCH_GID = 65_534 +const GUEST_USER = `${SCRATCH_UID}:${SCRATCH_GID}` +const DEFAULT_SCRATCH_MIB = 64 const DEFAULT_IMAGE = 'node:22-alpine' +const PROVISION_SCRIPT = + `chown ${SCRATCH_UID}:${SCRATCH_GID} ${GUEST_SCRATCH} && chmod 700 ${GUEST_SCRATCH} && mount -o remount,ro / && mount -o remount,ro /dev/shm` const GUEST_READY_TIMEOUT = Duration.seconds(60) const MAX_PROTOCOL_LINE_BYTES = 16 * 1024 * 1024 const RESERVED_NAMESPACE = 'console' @@ -98,8 +105,15 @@ const unsupported = ( message, }) +export interface ReadOnlyMount { + readonly host: string + readonly guest: string +} + export interface MicroVmCodeExecutorOptions { readonly image?: string + readonly scratchMiB?: number + readonly readOnlyMounts?: ReadonlyArray } const checkNetwork = ( @@ -193,8 +207,14 @@ const validateRequest = ( }) interface GuestPatch { - mkdir(path: string): GuestPatch - text(path: string, content: string): GuestPatch + mkdir(path: string, opts?: { readonly mode?: number }): GuestPatch + text(path: string, content: string, opts?: { readonly mode?: number }): GuestPatch +} + +interface SandboxSetup { + readonly image: string + readonly scratchMiB: number + readonly readOnlyMounts: ReadonlyArray } interface GuestProcess { @@ -208,39 +228,84 @@ interface PassCounter { let sandboxSequence = 0 +const imageOf = (options: MicroVmCodeExecutorOptions): string => options.image ?? DEFAULT_IMAGE +const scratchOf = (options: MicroVmCodeExecutorOptions): number => options.scratchMiB ?? DEFAULT_SCRATCH_MIB +const mountsOf = (options: MicroVmCodeExecutorOptions): ReadonlyArray => options.readOnlyMounts ?? [] + +const setupOf = (options: MicroVmCodeExecutorOptions): SandboxSetup => ({ + image: imageOf(options), + scratchMiB: scratchOf(options), + readOnlyMounts: mountsOf(options), +}) + const guestPatch = (configText: string) => (patch: GuestPatch): GuestPatch => patch - .mkdir('/opt') - .mkdir(GUEST_DIR) - .text(GUEST_HARNESS_PATH, codeExecutorGuestSource) - .text(GUEST_CONFIG_PATH, configText) + .mkdir('/opt', { mode: 0o755 }) + .mkdir(GUEST_DIR, { mode: 0o755 }) + .text(GUEST_HARNESS_PATH, codeExecutorGuestSource, { mode: 0o444 }) + .text(GUEST_CONFIG_PATH, configText, { mode: 0o444 }) + +interface GuestPackageMount { + tmpfs(): GuestPackageMount + size(mib: number): GuestPackageMount + bind(host: string): GuestPackageMount + readonly(): GuestPackageMount + noexec(): GuestPackageMount + nosuid(): GuestPackageMount + nodev(): GuestPackageMount +} -const createSandbox = async (config: GuestConfig, image: string): Promise => { +const createSandbox = async (config: GuestConfig, setup: SandboxSetup): Promise => { const { Sandbox } = await import('microsandbox') sandboxSequence += 1 const configText = Option.getOrElse(encodeGuestConfig(config), () => '') - - return await Sandbox.builder(`effect-agent-code-executor-${process.pid}-${sandboxSequence}`) - .image(image) + const builder = Sandbox.builder(`effect-agent-code-executor-${process.pid}-${sandboxSequence}`) + .image(setup.image) .ephemeral(true) .disableNetwork() + .volume(GUEST_SCRATCH, (mount: GuestPackageMount) => mount.tmpfs().size(setup.scratchMiB)) .patch(guestPatch(configText)) - .create() + + for (const mount of setup.readOnlyMounts) { + builder.volume( + mount.guest, + (volume: GuestPackageMount) => volume.bind(mount.host).readonly().noexec().nosuid().nodev(), + ) + } + + return await builder.create() } const launchSandbox = ( config: GuestConfig, - image: string, + setup: SandboxSetup, ): Effect.Effect => Effect.tryPromise({ - try: () => createSandbox(config, image), + try: () => createSandbox(config, setup), catch: (cause) => startError( cause instanceof Error ? `The microVM could not start: ${cause.message}` : 'The microVM could not start', ), }) +const provisionSandbox = (sandbox: MicroSandbox): Effect.Effect => + Effect.tryPromise({ + try: async () => { + const result = await sandbox.exec('sh', ['-c', PROVISION_SCRIPT]) + + if (result.code !== 0) { + throw new Error(`provisioning exited ${result.code}: ${result.stderr()}`) + } + }, + catch: (cause) => + startError( + cause instanceof Error + ? `The microVM could not be sealed: ${cause.message}` + : 'The microVM could not be sealed', + ), + }) + const stopSandbox = (sandbox: MicroSandbox): Effect.Effect => Effect.tryPromise({ try: () => sandbox.destroy({ force: true }), @@ -251,7 +316,15 @@ const openGuestProcess = (sandbox: MicroSandbox): Effect.Effect - sandbox.execStreamWith('node', (builder) => builder.arg(GUEST_HARNESS_PATH).arg(GUEST_CONFIG_PATH).stdinPipe()), + sandbox.execStreamWith('node', (builder) => + builder + .arg(GUEST_HARNESS_PATH) + .arg(GUEST_CONFIG_PATH) + .cwd(GUEST_SCRATCH) + .user(GUEST_USER) + .env('HOME', GUEST_SCRATCH) + .env('TMPDIR', GUEST_SCRATCH) + .stdinPipe()), catch: () => startError('The guest harness could not start'), }) const sink = yield* Effect.tryPromise({ @@ -749,9 +822,10 @@ const makeExecute = (options: MicroVmCodeExecutorOptions): CodeExecutorExecute = const host = yield* CodeExecutionHost const sandbox = yield* Effect.acquireRelease( - launchSandbox(guestConfigOf(request), options.image ?? DEFAULT_IMAGE), + launchSandbox(guestConfigOf(request), setupOf(options)), stopSandbox, ) + yield* provisionSandbox(sandbox) const process = yield* openGuestProcess(sandbox) return yield* runGuestPass(request, host, process) diff --git a/packages/platform-node/tests/__fixtures__/code-executor.schema.ts b/packages/platform-node/tests/__fixtures__/code-executor.schema.ts new file mode 100644 index 000000000..6bcfe5cfd --- /dev/null +++ b/packages/platform-node/tests/__fixtures__/code-executor.schema.ts @@ -0,0 +1,28 @@ +import * as Schema from 'effect/Schema' + +export const NetworkObservation = Schema.Struct({ + nonLoopback: Schema.Array(Schema.String), + fetchFailed: Schema.Boolean, +}) + +export const FilesystemObservation = Schema.Struct({ + rootOptions: Schema.String, + etc: Schema.String, + tmp: Schema.String, + shm: Schema.String, + scratch: Schema.String, + cwd: Schema.String, +}) + +export const IdentityObservation = Schema.Struct({ + uid: Schema.Natural, + gid: Schema.Natural, + home: Schema.NullOr(Schema.String), + tmpdir: Schema.NullOr(Schema.String), + path: Schema.String, +}) + +export const LibraryObservation = Schema.Struct({ + read: Schema.String, + write: Schema.String, +}) diff --git a/packages/platform-node/tests/code-executor.integration.test.ts b/packages/platform-node/tests/code-executor.integration.test.ts new file mode 100644 index 000000000..240e3ed6b --- /dev/null +++ b/packages/platform-node/tests/code-executor.integration.test.ts @@ -0,0 +1,221 @@ +import * as NodeFileSystem from '@effect/platform-node/NodeFileSystem' +import * as NodePath from '@effect/platform-node/NodePath' +import { + microVmCodeExecutorLayer, + type MicroVmCodeExecutorOptions, +} from '@systemfsoftware/agent-platform-node/node-code-executor' +import { + CodeExecutionHost, + CodeExecutionLimits, + CodeExecutionRequest, + CodeExecutor, +} from '@systemfsoftware/agent/code-executor' +import { NetworkDisabled } from '@systemfsoftware/agent/sandbox' +import { Gherkin, it, makeFeature, Then, When } from '@systemfsoftware/effect-gherkin-spec' +import * as Config from 'effect/Config' +import * as ConfigProvider from 'effect/ConfigProvider' +import * as Duration from 'effect/Duration' +import * as Effect from 'effect/Effect' +import * as FileSystem from 'effect/FileSystem' +import * as Layer from 'effect/Layer' +import * as Path from 'effect/Path' +import * as Schema from 'effect/Schema' +import type * as Scope from 'effect/Scope' + +import { + FilesystemObservation, + IdentityObservation, + LibraryObservation, + NetworkObservation, +} from './__fixtures__/code-executor.schema' + +const host: CodeExecutionHost['Service'] = { + call: () => Effect.die('this pass makes no host call'), +} + +const limits = CodeExecutionLimits.make({ + maxSourceBytes: 64 * 1024, + maxWallTime: Duration.seconds(30), + maxLogBytes: 16 * 1024, + maxResultBytes: 64 * 1024, + maxHostCalls: 8, + maxHostCallArgumentBytes: 16 * 1024, + maxHostCallResultBytes: 32 * 1024, +}) + +const runProgram = ( + source: string, + options: MicroVmCodeExecutorOptions = {}, +): Effect.Effect => + Effect.gen(function*() { + const executor = yield* CodeExecutor + const result = yield* executor.execute( + CodeExecutionRequest.make({ + language: 'javascript', + source, + namespaces: [], + network: NetworkDisabled.make(), + limits, + }), + ).pipe(Effect.provideService(CodeExecutionHost, CodeExecutionHost.of(host))) + + return result.value + }).pipe( + Effect.scoped, + Effect.provide(microVmCodeExecutorLayer(options)), + ) + +const runObserved = ( + schema: S, + source: string, + options: MicroVmCodeExecutorOptions = {}, +) => + runProgram(source, options).pipe( + Effect.flatMap((value) => Schema.decodeEffect(schema)(value)), + ) + +const withPinnedLibrary = ( + use: (mount: { readonly host: string; readonly guest: string }) => Effect.Effect, +): Effect.Effect< + A, + E | import('effect/PlatformError').PlatformError, + R | Scope.Scope | FileSystem.FileSystem | Path.Path +> => + Effect.gen(function*() { + const fs = yield* FileSystem.FileSystem + const path = yield* Path.Path + const directory = yield* fs.makeTempDirectoryScoped({ prefix: 'agent-code-executor-library-' }) + const pinned = path.join(directory, 'pinned.js') + + yield* fs.chmod(directory, 0o755) + yield* fs.writeFileString(pinned, "export const pinned = 'v1'\n", { mode: 0o444 }) + yield* fs.chmod(pinned, 0o444) + + return yield* use({ host: directory, guest: '/opt/libraries/pinned' }) + }) + +const Feature = makeFeature({ it }) + +Feature('Executing generated JavaScript in the Node CodeExecutor', { timeout: 300_000 }) + .live('each pass boots a real microVM and waits on its guest process') + .withLayer(Layer.merge(NodeFileSystem.layer, NodePath.layer)) + .body(({ scenario }) => { + scenario( + 'A generated program has no network interface and cannot reach the network', + Gherkin.Do.pipe( + When('a program lists its interfaces and tries to fetch an address')('observed', () => + runObserved( + NetworkObservation, + 'async () => {\n' + + " const os = await import('node:os')\n" + + " const nonLoopback = Object.keys(os.networkInterfaces()).filter((name) => name !== 'lo')\n" + + ' let fetchFailed = false\n' + + " try { await fetch('http://1.1.1.1', { signal: AbortSignal.timeout(5000) }) } catch { fetchFailed = true }\n" + + ' return { nonLoopback, fetchFailed }\n' + + '}', + )), + Then('the observation shows only loopback and a refused request')((scope, expect) => + expect(scope.observed).toEqual({ nonLoopback: [], fetchFailed: true }) + ), + ), + ) + + scenario( + 'The guest root is read-only and the scratch directory is the only writable place', + Gherkin.Do.pipe( + When('a program probes the root mount and writes to several paths')('observed', () => + runObserved( + FilesystemObservation, + 'async () => {\n' + + " const fs = await import('node:fs')\n" + + " const probe = (path) => { try { fs.writeFileSync(path, 'x'); return 'wrote' } catch (error) { return error.code ?? 'error' } }\n" + + " const root = fs.readFileSync('/proc/mounts', 'utf8').split('\\n').find((line) => line.split(' ')[1] === '/') ?? ''\n" + + ' return {\n' + + " rootOptions: (root.split(' ')[3] ?? '').split(',')[0],\n" + + " etc: probe('/etc/code-executor-probe'),\n" + + " tmp: probe('/tmp/code-executor-probe'),\n" + + " shm: probe('/dev/shm/code-executor-probe'),\n" + + " scratch: probe('/scratch/code-executor-probe'),\n" + + ' cwd: process.cwd(),\n' + + ' }\n' + + '}', + )), + Then('the root and shared memory are read-only while scratch accepts writes')((scope, expect) => + expect(scope.observed).toEqual({ + rootOptions: 'ro', + etc: 'EROFS', + tmp: 'EROFS', + shm: 'EROFS', + scratch: 'wrote', + cwd: '/scratch', + }) + ), + ), + ) + + scenario( + 'The guest runs as an unprivileged user with no host environment', + Gherkin.Do.pipe( + When('a program reports its identity and environment')('observed', () => + Effect.gen(function*() { + const hostPath = yield* Config.String('PATH').parse(ConfigProvider.fromEnv()) + const guest = yield* runObserved( + IdentityObservation, + 'async () => ({\n' + + ' uid: process.getuid(),\n' + + ' gid: process.getgid(),\n' + + ' home: process.env.HOME ?? null,\n' + + ' tmpdir: process.env.TMPDIR ?? null,\n' + + " path: process.env.PATH ?? '',\n" + + '})', + ) + + return { ...guest, hostPath } + })), + Then('the identity is unprivileged and the host PATH is absent')((scope, expect) => + expect({ + uid: scope.observed.uid, + gid: scope.observed.gid, + home: scope.observed.home, + tmpdir: scope.observed.tmpdir, + hostPathVisible: scope.observed.path === scope.observed.hostPath, + }).toEqual({ + uid: 65_534, + gid: 65_534, + home: '/scratch', + tmpdir: '/scratch', + hostPathVisible: false, + }) + ), + ), + ) + + scenario( + 'A pinned library directory mounts read-only', + Gherkin.Do.pipe( + When('a program reads the pinned file and tries to add one beside it')( + 'observed', + () => + withPinnedLibrary((mount) => + runObserved( + LibraryObservation, + 'async () => {\n' + + " const fs = await import('node:fs')\n" + + " const read = fs.readFileSync('/opt/libraries/pinned/pinned.js', 'utf8')\n" + + ' let write\n' + + " try { fs.writeFileSync('/opt/libraries/pinned/added.js', 'x'); write = 'wrote' } catch (error) { write = error.code ?? 'error' }\n" + + ' return { read, write }\n' + + '}', + { readOnlyMounts: [mount] }, + ) + ), + ), + Then('the pinned file is readable and the directory refuses writes')((scope, expect) => + expect(scope.observed).toEqual({ + read: "export const pinned = 'v1'\n", + write: 'EROFS', + }) + ), + ), + ) + }) diff --git a/packages/platform-node/tsconfig.test.json b/packages/platform-node/tsconfig.test.json index 8d5ee0cdc..a44ab3fdf 100644 --- a/packages/platform-node/tsconfig.test.json +++ b/packages/platform-node/tsconfig.test.json @@ -8,7 +8,8 @@ "tsBuildInfoFile": "node_modules/.cache/tsconfig.test.tsbuildinfo" }, "include": [ - "test/**/*.ts" + "test/**/*.ts", + "tests/**/*.ts" ], "references": [ { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 8e6071bc6..0052e21b5 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -239,12 +239,18 @@ catalogs: '@systemfsoftware/effect-cf': specifier: 0.60.0 version: 0.60.0 + '@systemfsoftware/effect-gherkin-spec': + specifier: ^8.4.3 + version: 8.4.3 '@systemfsoftware/effect-microsandbox': specifier: ^6.1.0 version: 6.1.0 '@systemfsoftware/effect-readiness': specifier: ^1.1.4 version: 1.1.4 + '@systemfsoftware/vitest': + specifier: ^4.4.0 + version: 4.4.0 '@tailwindcss/vite': specifier: 4.3.3 version: 4.3.3 @@ -374,7 +380,7 @@ overrides: '@effect/platform-node': 4.1.5 '@effect/vitest': 4.1.5 effect: 4.1.5 - vitest: 5.0.3 + vitest: 5.1.2 importers: @@ -435,8 +441,8 @@ importers: specifier: 'catalog:' version: typescript@6.0.3 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) docs: dependencies: @@ -560,7 +566,7 @@ importers: version: link:../../packages/storage-cloudflare '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) effect: specifier: 4.1.5 version: 4.1.5 @@ -585,7 +591,7 @@ importers: version: 5.20261026.1 '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) '@types/node': specifier: 'catalog:' version: 26.1.2 @@ -611,8 +617,8 @@ importers: specifier: 'catalog:' version: 7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1) vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) wrangler: specifier: 'catalog:' version: 4.123.0(@cloudflare/workers-types@5.20261026.1) @@ -639,7 +645,7 @@ importers: version: link:../../packages/platform-cloudflare '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) '@types/node': specifier: 'catalog:' version: 26.1.2 @@ -681,7 +687,7 @@ importers: version: link:../../packages/storage-cloudflare '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) '@types/node': specifier: 'catalog:' version: 26.1.2 @@ -732,13 +738,13 @@ importers: version: link:../../packages/platform-cloudflare '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) '@systemfsoftware/ui': specifier: workspace:* version: link:../../packages/ui '@yielded/sandbox': specifier: 0.9.0 - version: 0.9.0(effect-cf@0.59.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5))(effect@4.1.5) + version: 0.9.0(effect-cf@0.59.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5))(effect@4.1.5) drizzle-orm: specifier: 'catalog:' version: 1.0.0-rc.4(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(@effect/sql-sqlite-node@4.1.5(effect@4.1.5))(@electric-sql/pglite@0.3.15)(@libsql/client@0.17.4)(effect@4.1.5)(valibot@1.2.0(typescript@7.0.2))(zod@4.6.7) @@ -796,7 +802,7 @@ importers: dependencies: '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) '@yielded/auth': specifier: 'catalog:' version: 0.1.0-beta.47(effect@4.1.5) @@ -847,7 +853,7 @@ importers: version: link:../../packages/testing '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@0.13.0-next.830.1)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@0.13.0-next.830.1)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) '@systemfsoftware/ui': specifier: workspace:* version: link:../../packages/ui @@ -893,7 +899,7 @@ importers: version: 4.1.5(effect@4.1.5)(redis@6.3.1) '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) '@tailwindcss/vite': specifier: 'catalog:' version: 4.3.3(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) @@ -928,8 +934,8 @@ importers: specifier: 'catalog:' version: 7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1) vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) packages/ai-decision: devDependencies: @@ -941,7 +947,7 @@ importers: version: 4.1.5(effect@4.1.5) '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) effect: specifier: 4.1.5 version: 4.1.5 @@ -952,8 +958,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/effect-agent: dependencies: @@ -975,7 +981,7 @@ importers: version: 4.1.5(effect@4.1.5)(redis@6.3.1) '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) effect: specifier: 4.1.5 version: 4.1.5 @@ -986,8 +992,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/platform-cloudflare: dependencies: @@ -1024,7 +1030,7 @@ importers: version: 0.18.5 '@cloudflare/vitest-plugin': specifier: 'catalog:' - version: 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) '@cloudflare/workers-types': specifier: 'catalog:' version: 5.20261026.1 @@ -1036,13 +1042,13 @@ importers: version: 4.1.5(effect@4.1.5) '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) '@systemfsoftware/agent-testing': specifier: workspace:* version: link:../testing '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) effect: specifier: 4.1.5 version: 4.1.5 @@ -1059,8 +1065,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/platform-node: dependencies: @@ -1085,7 +1091,13 @@ importers: version: 0.18.5 '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + '@systemfsoftware/effect-gherkin-spec': + specifier: 'catalog:' + version: 8.4.3(@systemfsoftware/vitest@4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + '@systemfsoftware/vitest': + specifier: 'catalog:' + version: 4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) effect: specifier: 4.1.5 version: 4.1.5 @@ -1099,8 +1111,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/pr-review: dependencies: @@ -1113,7 +1125,7 @@ importers: version: 0.18.5 '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) effect: specifier: 4.1.5 version: 4.1.5 @@ -1124,8 +1136,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/pr-review-action: dependencies: @@ -1147,7 +1159,7 @@ importers: devDependencies: '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) '@types/node': specifier: 'catalog:' version: 26.1.2 @@ -1158,8 +1170,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/storage-cloudflare: dependencies: @@ -1181,13 +1193,13 @@ importers: version: 0.18.5 '@cloudflare/vitest-plugin': specifier: 'catalog:' - version: 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) '@cloudflare/workers-types': specifier: 'catalog:' version: 5.20261026.1 '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) '@systemfsoftware/agent-testing': specifier: workspace:* version: link:../testing @@ -1201,8 +1213,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/storage-memory: dependencies: @@ -1218,7 +1230,7 @@ importers: version: 4.1.5(effect@4.1.5)(redis@6.3.1) '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) effect: specifier: 4.1.5 version: 4.1.5 @@ -1229,8 +1241,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/storage-postgres: dependencies: @@ -1252,7 +1264,7 @@ importers: version: 4.1.5(effect@4.1.5) '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) '@systemfsoftware/effect-microsandbox': specifier: 'catalog:' version: 6.1.0(effect@4.1.5)(redis@6.3.1)(typescript@7.0.2) @@ -1269,8 +1281,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/storage-sql: dependencies: @@ -1283,7 +1295,7 @@ importers: version: 0.18.5 '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) effect: specifier: 4.1.5 version: 4.1.5 @@ -1294,8 +1306,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/storage-sqlite: dependencies: @@ -1317,7 +1329,7 @@ importers: version: 0.18.5 '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) effect: specifier: 4.1.5 version: 4.1.5 @@ -1328,8 +1340,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/testing: dependencies: @@ -1354,7 +1366,7 @@ importers: version: 4.1.5(effect@4.1.5) '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) '@systemfsoftware/agent-ai-decision': specifier: workspace:* version: link:../ai-decision @@ -1386,8 +1398,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) packages/ui: dependencies: @@ -1435,8 +1447,8 @@ importers: specifier: 'catalog:' version: 7.0.2 vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) tooling/browser-run-worker-proof: dependencies: @@ -1464,7 +1476,7 @@ importers: version: 5.20261026.1 '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) '@types/node': specifier: 'catalog:' version: 26.1.2 @@ -1484,8 +1496,8 @@ importers: specifier: 'catalog:' version: 7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1) vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) wrangler: specifier: 'catalog:' version: 4.123.0(@cloudflare/workers-types@5.20261026.1) @@ -1506,7 +1518,7 @@ importers: version: link:../../packages/storage-cloudflare '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) effect: specifier: 4.1.5 version: 4.1.5 @@ -1555,7 +1567,7 @@ importers: version: link:../../packages/platform-node '@systemfsoftware/effect-cf': specifier: 'catalog:' - version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + version: 0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) effect: specifier: 4.1.5 version: 4.1.5 @@ -1585,8 +1597,8 @@ importers: specifier: 'catalog:' version: 7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1) vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) wrangler: specifier: 'catalog:' version: 4.123.0(@cloudflare/workers-types@5.20261026.1) @@ -1611,7 +1623,7 @@ importers: devDependencies: '@effect/vitest': specifier: 4.1.5 - version: 4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) + version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) '@systemfsoftware/agent-testing': specifier: workspace:* version: link:../../packages/testing @@ -1625,8 +1637,8 @@ importers: specifier: 'catalog:' version: 7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1) vitest: - specifier: 5.0.3 - version: 5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) tooling/semantic-memory-eval: dependencies: @@ -2202,7 +2214,7 @@ packages: '@cloudflare/vitest-plugin@1.4.0': resolution: {integrity: sha512-SgIhyhpVH+2MVSJxidG8gosqrpzF25IwKevQhPykwulTgAFe4s0Nkj71pNzqCkwV2+A4NKkHJP2ReyyRsoIxsg==} peerDependencies: - vitest: 5.0.3 + vitest: 5.1.2 '@cloudflare/workerd-darwin-64@1.20260811.1': resolution: {integrity: sha512-i5jqz+ywtOefr0AJbiAc8qxBLfSim/B0WJG7aW3B+pWnoVfMJdUQvi+BWcFKZJ0MoCci3KadTx6g31VfuEEqpQ==} @@ -2704,7 +2716,7 @@ packages: resolution: {integrity: sha512-18u1013wkJtSelk1ZYLc/5aUnluTQyDfi2hAemkJW1GQ9qXw4mtPSiSf0AXZPhesmGCvG1Dk2C4JYD2sz+R72w==} peerDependencies: effect: 4.1.5 - vitest: 5.0.3 + vitest: 5.1.2 '@electric-sql/pglite@0.3.15': resolution: {integrity: sha512-Cj++n1Mekf9ETfdc16TlDi+cDDQF0W7EcbyRHYOAeZdsAe8M/FJg18itDTSwyHfar2WIezawM9o0EKaRGVKygQ==} @@ -5500,6 +5512,13 @@ packages: just-bash: optional: true + '@systemfsoftware/effect-gherkin-spec@8.4.3': + resolution: {integrity: sha512-Wkzg+BtDlgaIGH93uFmE8mmUnaHLFe+6aHFn7Gqe7vZp7t4kfFjRt27Z4bYv7tZXJMjbwAKYwAb3zeOyiHjxIA==} + peerDependencies: + '@systemfsoftware/vitest': ^4.4.0 + effect: 4.1.5 + vitest: 5.1.2 + '@systemfsoftware/effect-microsandbox@6.1.0': resolution: {integrity: sha512-YTeMvbwzVdz0FyKXRKo0IqXIWz7P5NKLVu9fMTEiE69sKyh1qvC20ZOd42QWGOBaxAvuE4rp3BNVR2TkZnOBwQ==} peerDependencies: @@ -5512,6 +5531,19 @@ packages: effect: 4.1.5 typescript: '>=7.0.0' + '@systemfsoftware/effect-sim-kernel@2.1.1': + resolution: {integrity: sha512-iOYNsa32d7p2VwV7Rlc3qghW7oqlcfMAVCVLHEnGr4JyxS8KHcjC8fCIdwyMqTz4FpxRiOx6fXvrtQ6bw2iCLA==} + engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0} + peerDependencies: + effect: 4.1.5 + + '@systemfsoftware/effect-spec-runtime@1.4.3': + resolution: {integrity: sha512-AQQ+S4P1NJiVHdRA7sGTg2lyvfdlgxItdWyzn0cO3v77F01rogDZoa0i8mR8dI9bGZzIG4xg5CIbtx9wl1I2pQ==} + peerDependencies: + '@systemfsoftware/vitest': ^4.4.0 + effect: 4.1.5 + vitest: 5.1.2 + '@systemfsoftware/oxlint-config-cell-architecture@6.0.5': resolution: {integrity: sha512-rju0BG6XXU81WZrfzeOIHYEAkLGFKNf3AoeM7xaq3/b59DrGFQWFUlpDu8W9IcrjbKCiE2f2lOdELJvjwhoVMQ==} peerDependencies: @@ -5573,6 +5605,13 @@ packages: effect: 4.1.5 typescript: '>=5.0.0' + '@systemfsoftware/vitest@4.4.0': + resolution: {integrity: sha512-dgYxolRzI21ABlNflBa1UXTrjZ/UH8TUAAQ9NfjICn6UWy1UIj5uqL9DHHTSlHeBUgPs3SjwQzkDEYN17OPfHQ==} + engines: {node: ^22.19.0 || ^24.0.0 || >=26.0.0} + peerDependencies: + effect: 4.1.5 + vitest: 5.1.2 + '@tailwindcss/node@4.3.3': resolution: {integrity: sha512-/T8IKEsf9VTU6tLjgC7+sv2mOPtQxzE2jMw7u4Tt40Tx+QSZxpzh95/H6cMKoja9XuW7iMdLJYBB0o9G1CaAgg==} @@ -6181,10 +6220,10 @@ packages: babel-plugin-react-compiler: optional: true - '@vitest/mocker@5.0.3': - resolution: {integrity: sha512-T8sWAIbkSyAjkwTcaEc3Iu0o9A27X1/kdXrizhZkGuSKScRQtRzclfAMpOTcGdXCsqxeWlpGy3XjqaW8CpLORg==} + '@vitest/mocker@5.1.2': + resolution: {integrity: sha512-UGc97wUIy0Ji2+9GxzHEJiOhiwkaukgE7VYcUNnjpX3sWnwQ8XogmNXX4WyOukxYgKb8Nh2XFa7KId0ZjpmVhQ==} peerDependencies: - msw: ^2.4.9 + msw: ^2.4.9 || ^3.0.0 vite: ^6.0.0 || ^7.0.0 || ^8.0.0 peerDependenciesMeta: msw: @@ -6192,8 +6231,8 @@ packages: vite: optional: true - '@vitest/spy@5.0.3': - resolution: {integrity: sha512-XhFysQTB8AZ+P4gMi+Lpo99vg2AZi0qKpaB9yXQl37+CaMEAPO3iH/wGVnSyL5MPERiLezpqTVtrR6UZH5GCXg==} + '@vitest/spy@5.1.2': + resolution: {integrity: sha512-PQl0/3+p9GaY71+MHywN6oyHfLhVDD5kcbm7oNRldA2F0ExMU3S8RQdnpteJ9gFAdK5P6KCgE6LqCpUgy57KzA==} '@volar/language-core@2.4.30': resolution: {integrity: sha512-73fjwEV8wat6aOZ6U/y/hqtE30ocrIWECg67b0txGczOMNw+MffLmvJ5fnFfN9drVUEYZzLdaNo6VAy6G6avMw==} @@ -8434,10 +8473,6 @@ packages: resolution: {integrity: sha512-NuAESUOUMrlIXOfHKzD6bpPu3tYt3xvjNdRIQ+FeT0lNb4K8WR70CaDxhuNguS2XG+GjkyMwOzsN5ZktImfhLA==} engines: {node: '>= 0.4'} - obug@2.2.1: - resolution: {integrity: sha512-XrsrhT5sybtKI6wakr2SPOlGZWWYbUXZ7a0jT8/QOeAPau+1X/bSegNe5YR75oJmEZQbKningirmGOEJCIk61Q==} - engines: {node: '>=12.20.0'} - obug@3.0.0: resolution: {integrity: sha512-5vvB5+W7ePv+p3uqxi+RcW1XAzLW0/hxt3/4X4Lc4qHudzOhmBiBwOY6DRob4WnanAEGvNcLjF+KNOufrUoEQw==} engines: {node: '>=12.20.0'} @@ -9597,20 +9632,20 @@ packages: vite: optional: true - vitest@5.0.3: - resolution: {integrity: sha512-xMw97S3rjdtj5dkVat7jCsqWBpvchs3RlpQctUqwJD0KkERk40vz2fJ77lDwW/Vzh/pk18eItYAzkodhSes3jQ==} + vitest@5.1.2: + resolution: {integrity: sha512-VIa2wXV208WraXUbzH+dQUrGcFpPuaiRA8HlhXS8R6/sy9cynw6OMqGj8fmAlH1hot7huTCtWUE14+FdXU3eLw==} engines: {node: ^22.12.0 || ^24.0.0 || >=26.0.0} hasBin: true peerDependencies: '@edge-runtime/vm': '*' '@opentelemetry/api': ^1.9.0 '@types/node': ^22.0.0 || >=24.0.0 - '@vitest/browser-playwright': 5.0.3 - '@vitest/browser-preview': 5.0.3 + '@vitest/browser-playwright': 5.1.2 + '@vitest/browser-preview': 5.1.2 '@vitest/browser-webdriverio': ^5.0.0-beta.5 || >=5.0.0 - '@vitest/coverage-istanbul': 5.0.3 - '@vitest/coverage-v8': 5.0.3 - '@vitest/ui': 5.0.3 + '@vitest/coverage-istanbul': 5.1.2 + '@vitest/coverage-v8': 5.1.2 + '@vitest/ui': 5.1.2 happy-dom: '*' jsdom: '*' vite: ^6.4.0 || ^7.0.0 || ^8.0.0 @@ -10470,12 +10505,12 @@ snapshots: optionalDependencies: workerd: 1.20261026.1 - '@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)))': + '@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)))': dependencies: cjs-module-lexer: 1.2.3 esbuild: 0.28.2 miniflare: 5.20261006.1-alpha(@types/node@26.1.2) - vitest: 5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) + vitest: 5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) wrangler: 4.149.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2) zod: 4.6.5 transitivePeerDependencies: @@ -10485,12 +10520,12 @@ snapshots: - utf-8-validate optional: true - '@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)))': + '@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)))': dependencies: cjs-module-lexer: 1.2.3 esbuild: 0.28.2 miniflare: 5.20261006.1-alpha(@types/node@26.1.2) - vitest: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + vitest: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) wrangler: 4.149.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2) zod: 4.6.5 transitivePeerDependencies: @@ -10907,15 +10942,15 @@ snapshots: '@effect/tsgo-win32-arm64': 0.73.4 '@effect/tsgo-win32-x64': 0.73.4 - '@effect/vitest@4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)))': + '@effect/vitest@4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)))': dependencies: effect: 4.1.5 - vitest: 5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) + vitest: 5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) - '@effect/vitest@4.1.5(effect@4.1.5)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)))': + '@effect/vitest@4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)))': dependencies: effect: 4.1.5 - vitest: 5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + vitest: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) '@electric-sql/pglite@0.3.15': optional: true @@ -12927,7 +12962,7 @@ snapshots: dependencies: effect: 4.1.5 - '@systemfsoftware/effect-cf@0.60.0(@cloudflare/sandbox@0.13.0-next.830.1)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5)': + '@systemfsoftware/effect-cf@0.60.0(@cloudflare/sandbox@0.13.0-next.830.1)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5)': dependencies: '@effect/platform-browser': 4.1.0(effect@4.1.5) '@effect/sql-d1': 4.1.5(effect@4.1.5) @@ -12935,11 +12970,11 @@ snapshots: effect: 4.1.5 optionalDependencies: '@cloudflare/sandbox': 0.13.0-next.830.1 - '@cloudflare/vitest-plugin': 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) + '@cloudflare/vitest-plugin': 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) '@cloudflare/workers-types': 5.20261026.1 '@effect/sql-pg': 4.1.5(effect@4.1.5) - '@systemfsoftware/effect-cf@0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5)': + '@systemfsoftware/effect-cf@0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5)': dependencies: '@effect/platform-browser': 4.1.0(effect@4.1.5) '@effect/sql-d1': 4.1.5(effect@4.1.5) @@ -12947,11 +12982,11 @@ snapshots: effect: 4.1.5 optionalDependencies: '@cloudflare/sandbox': 1.0.3 - '@cloudflare/vitest-plugin': 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) + '@cloudflare/vitest-plugin': 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) '@cloudflare/workers-types': 5.20261026.1 '@effect/sql-pg': 4.1.5(effect@4.1.5) - '@systemfsoftware/effect-cf@0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5)': + '@systemfsoftware/effect-cf@0.60.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5)': dependencies: '@effect/platform-browser': 4.1.0(effect@4.1.5) '@effect/sql-d1': 4.1.5(effect@4.1.5) @@ -12959,10 +12994,17 @@ snapshots: effect: 4.1.5 optionalDependencies: '@cloudflare/sandbox': 1.0.3 - '@cloudflare/vitest-plugin': 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + '@cloudflare/vitest-plugin': 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) '@cloudflare/workers-types': 5.20261026.1 '@effect/sql-pg': 4.1.5(effect@4.1.5) + '@systemfsoftware/effect-gherkin-spec@8.4.3(@systemfsoftware/vitest@4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)))': + dependencies: + '@systemfsoftware/effect-spec-runtime': 1.4.3(@systemfsoftware/vitest@4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + '@systemfsoftware/vitest': 4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + effect: 4.1.5 + vitest: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + '@systemfsoftware/effect-microsandbox@6.1.0(effect@4.1.5)(redis@6.3.1)(typescript@7.0.2)': dependencies: '@effect/platform-node': 4.1.5(effect@4.1.5)(redis@6.3.1) @@ -12987,6 +13029,17 @@ snapshots: - redis - utf-8-validate + '@systemfsoftware/effect-sim-kernel@2.1.1(effect@4.1.5)': + dependencies: + effect: 4.1.5 + + '@systemfsoftware/effect-spec-runtime@1.4.3(@systemfsoftware/vitest@4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)))': + dependencies: + '@systemfsoftware/effect-sim-kernel': 2.1.1(effect@4.1.5) + '@systemfsoftware/vitest': 4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + effect: 4.1.5 + vitest: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + '@systemfsoftware/oxlint-config-cell-architecture@6.0.5(effect@4.1.5)(oxlint@1.94.0(oxlint-tsgolint@7.0.2008))(typescript@7.0.2)': dependencies: '@systemfsoftware/oxlint-config-rule-authoring': 3.0.3(oxlint@1.94.0(oxlint-tsgolint@7.0.2008))(typescript@7.0.2) @@ -13079,6 +13132,16 @@ snapshots: oxc-parser: 0.159.0 typescript: 7.0.2 + '@systemfsoftware/vitest@4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)))': + dependencies: + '@effect/platform-node': 4.1.5(effect@4.1.5)(redis@6.3.1) + effect: 4.1.5 + vitest: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + transitivePeerDependencies: + - bufferutil + - redis + - utf-8-validate + '@tailwindcss/node@4.3.3': dependencies: '@jridgewell/remapping': 2.3.5 @@ -13697,25 +13760,25 @@ snapshots: '@rolldown/pluginutils': 1.1.1 vite: 7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1) - '@vitest/mocker@5.0.3(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))': + '@vitest/mocker@5.1.2(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))': dependencies: '@jridgewell/trace-mapping': 0.3.31 - '@vitest/spy': 5.0.3 + '@vitest/spy': 5.1.2 estree-walker: 3.0.3 magic-string: 1.4.5 optionalDependencies: vite: 7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1) - '@vitest/mocker@5.0.3(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))': + '@vitest/mocker@5.1.2(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))': dependencies: '@jridgewell/trace-mapping': 0.3.31 - '@vitest/spy': 5.0.3 + '@vitest/spy': 5.1.2 estree-walker: 3.0.3 magic-string: 1.4.5 optionalDependencies: vite: 8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1) - '@vitest/spy@5.0.3': {} + '@vitest/spy@5.1.2': {} '@volar/language-core@2.4.30': dependencies: @@ -13763,11 +13826,11 @@ snapshots: '@yielded/jose': 0.1.0-beta.47(effect@4.1.5) effect: 4.1.5 - '@yielded/sandbox@0.9.0(effect-cf@0.59.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5))(effect@4.1.5)': + '@yielded/sandbox@0.9.0(effect-cf@0.59.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5))(effect@4.1.5)': dependencies: '@cloudflare/sandbox': 1.0.3 effect: 4.1.5 - effect-cf: 0.59.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) + effect-cf: 0.59.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5) '@yielded/starlight-theme@0.2.2(@astrojs/starlight@0.42.4(astro@7.3.5(@types/node@26.1.2)(aws4fetch@1.0.20)(jiti@2.7.0)(yaml@2.9.1))(supports-color@10.2.2)(typescript@6.0.3))(astro@7.3.5(@types/node@26.1.2)(aws4fetch@1.0.20)(jiti@2.7.0)(yaml@2.9.1))(supports-color@10.2.2)': dependencies: @@ -14651,7 +14714,7 @@ snapshots: es-errors: 1.3.0 gopd: 1.2.0 - effect-cf@0.59.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5): + effect-cf@0.59.0(@cloudflare/sandbox@1.0.3)(@cloudflare/vitest-plugin@1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))))(@cloudflare/workers-types@5.20261026.1)(@effect/sql-d1@4.1.5(effect@4.1.5))(@effect/sql-pg@4.1.5(effect@4.1.5))(@effect/sql-sqlite-do@4.1.5(effect@4.1.5))(effect@4.1.5): dependencies: '@effect/platform-browser': 4.1.5(effect@4.1.5) '@effect/sql-d1': 4.1.5(effect@4.1.5) @@ -14659,7 +14722,7 @@ snapshots: effect: 4.1.5 optionalDependencies: '@cloudflare/sandbox': 1.0.3 - '@cloudflare/vitest-plugin': 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) + '@cloudflare/vitest-plugin': 1.4.0(@cloudflare/workers-types@5.20261026.1)(@types/node@26.1.2)(vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1))) '@cloudflare/workers-types': 5.20261026.1 '@effect/sql-pg': 4.1.5(effect@4.1.5) @@ -16262,8 +16325,6 @@ snapshots: object-keys@1.1.1: {} - obug@2.2.1: {} - obug@3.0.0: {} ofetch@1.5.1: @@ -17594,15 +17655,15 @@ snapshots: optionalDependencies: vite: 8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1) - vitest@5.0.3(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)): + vitest@5.1.2(@types/node@26.1.2)(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)): dependencies: '@types/chai': 5.2.3 - '@vitest/mocker': 5.0.3(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) + '@vitest/mocker': 5.1.2(vite@7.3.8(@types/node@26.1.2)(jiti@2.7.0)(lightningcss@1.33.0)(yaml@2.9.1)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 magic-string: 1.4.5 - obug: 2.2.1 + obug: 3.0.0 picomatch: 4.0.7 std-env: 4.3.0 tinybench: 6.2.4 @@ -17615,15 +17676,15 @@ snapshots: transitivePeerDependencies: - msw - vitest@5.0.3(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)): + vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)): dependencies: '@types/chai': 5.2.3 - '@vitest/mocker': 5.0.3(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + '@vitest/mocker': 5.1.2(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) chai: 6.3.0 es-module-lexer: 2.3.2 expect-type: 1.4.0 magic-string: 1.4.5 - obug: 2.2.1 + obug: 3.0.0 picomatch: 4.0.7 std-env: 4.3.0 tinybench: 6.2.4 diff --git a/pnpm-workspace.yaml b/pnpm-workspace.yaml index 530a806ee..f8cf29372 100644 --- a/pnpm-workspace.yaml +++ b/pnpm-workspace.yaml @@ -16,6 +16,9 @@ minimumReleaseAgeExclude: - "@systemfsoftware/oxlint-plugin-test-discipline" - "@systemfsoftware/oxlint-config-rule-authoring@3.0.3" - "@systemfsoftware/effect-cf@0.60.0" + - "@systemfsoftware/effect-gherkin-spec@8.4.3" + - "@systemfsoftware/effect-spec-runtime@1.4.3" + - "@systemfsoftware/vitest@4.4.0" packages: - packages/* - examples/* @@ -41,7 +44,7 @@ catalog: "@types/node": "26.1.2" "typescript": "7.0.2" "typescript-twoslash": "npm:typescript@6.0.3" - "vitest": "5.0.3" + "vitest": "5.1.2" "@base-ui/react": "1.6.0" "@cloudflare/vitest-plugin": "1.4.0" "@cloudflare/workers-types": "5.20261026.1" @@ -52,6 +55,8 @@ catalog: "@effect/sql-sqlite-do": "4.1.5" "@systemfsoftware/effect-microsandbox": "^6.1.0" "@systemfsoftware/effect-readiness": "^1.1.4" + "@systemfsoftware/effect-gherkin-spec": "^8.4.3" + "@systemfsoftware/vitest": "^4.4.0" "@types/react": "19.2.17" "@types/react-dom": "19.2.3" "class-variance-authority": "0.7.1" From 78f4b8ffd7d53e203a9bb73b7236cfd1df768801 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot Date: Sat, 5 Dec 2026 06:26:10 +0000 Subject: [PATCH 4/5] refactor(platform-bun): run the CodeExecutor on Bun - 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. --- .changeset/bun-microvm-code-executor.md | 9 +++ .changeset/node-microvm-code-executor.md | 9 --- docs/src/content/docs/guide/sandbox.md | 11 ++-- packages/platform-bun/package.json | 61 +++++++++++++++++++ .../src/CodeExecutor.ts} | 29 ++++++--- packages/platform-bun/src/index.ts | 1 + .../src/internal/code-executor-guest.ts | 7 ++- .../src/internal/code-executor.schema.ts | 0 .../__fixtures__/code-executor.schema.ts | 0 .../tests/__fixtures__/conformance-runner.ts | 49 +++++++++++++++ .../tests/code-executor.integration.test.ts | 4 +- packages/platform-bun/tsconfig.app.json | 19 ++++++ packages/platform-bun/tsconfig.build.json | 12 ++++ packages/platform-bun/tsconfig.json | 11 ++++ packages/platform-bun/tsconfig.test.json | 22 +++++++ packages/platform-bun/tsdown.config.ts | 15 +++++ packages/platform-bun/vitest.config.ts | 15 +++++ packages/platform-node/package.json | 10 +-- packages/platform-node/src/index.ts | 1 - packages/platform-node/tsconfig.test.json | 3 +- pnpm-lock.yaml | 49 ++++++++++++--- tsconfig.json | 3 + 22 files changed, 294 insertions(+), 46 deletions(-) create mode 100644 .changeset/bun-microvm-code-executor.md delete mode 100644 .changeset/node-microvm-code-executor.md create mode 100644 packages/platform-bun/package.json rename packages/{platform-node/src/NodeCodeExecutor.ts => platform-bun/src/CodeExecutor.ts} (97%) create mode 100644 packages/platform-bun/src/index.ts rename packages/{platform-node => platform-bun}/src/internal/code-executor-guest.ts (96%) rename packages/{platform-node => platform-bun}/src/internal/code-executor.schema.ts (100%) rename packages/{platform-node => platform-bun}/tests/__fixtures__/code-executor.schema.ts (100%) create mode 100644 packages/platform-bun/tests/__fixtures__/conformance-runner.ts rename packages/{platform-node => platform-bun}/tests/code-executor.integration.test.ts (98%) create mode 100644 packages/platform-bun/tsconfig.app.json create mode 100644 packages/platform-bun/tsconfig.build.json create mode 100644 packages/platform-bun/tsconfig.json create mode 100644 packages/platform-bun/tsconfig.test.json create mode 100644 packages/platform-bun/tsdown.config.ts create mode 100644 packages/platform-bun/vitest.config.ts diff --git a/.changeset/bun-microvm-code-executor.md b/.changeset/bun-microvm-code-executor.md new file mode 100644 index 000000000..c9fc64831 --- /dev/null +++ b/.changeset/bun-microvm-code-executor.md @@ -0,0 +1,9 @@ +--- +"@systemfsoftware/agent-platform-bun": minor +--- + +Add `microVmCodeExecutorLayer` to a Bun platform package: each pass runs model-written JavaScript on Bun in a fresh hardware-isolated microVM whose network device is disabled before boot, so `NetworkDisabled` is enforced by the isolation boundary. Inside the guest the workload runs as an unprivileged user on a read-only root with one writable scratch directory, receives no host environment or credentials, and reads only host directories mounted read-only through `readOnlyMounts`. A host without hardware virtualization fails the pass with `CodeExecutorStartError`, while `NetworkAllowlist`, `cpuMillis`, and a namespace named `console` are refused with `CodeExecutorUnsupportedError`. + +```ts +import { microVmCodeExecutorLayer } from '@systemfsoftware/agent-platform-bun/code-executor' +``` diff --git a/.changeset/node-microvm-code-executor.md b/.changeset/node-microvm-code-executor.md deleted file mode 100644 index 2224fe2dc..000000000 --- a/.changeset/node-microvm-code-executor.md +++ /dev/null @@ -1,9 +0,0 @@ ---- -"@systemfsoftware/agent-platform-node": patch ---- - -Add `microVmCodeExecutorLayer` to the Node platform package: each pass runs in a fresh hardware-isolated microVM whose network device is disabled before boot, so `NetworkDisabled` is enforced by the isolation boundary. Inside the guest the workload runs as an unprivileged user on a read-only root with one writable scratch directory, receives no host environment or credentials, and reads only host directories mounted read-only through `readOnlyMounts`. A host without hardware virtualization fails the pass with `CodeExecutorStartError`, while `NetworkAllowlist`, `cpuMillis`, and a namespace named `console` are refused with `CodeExecutorUnsupportedError`. - -```ts -import { microVmCodeExecutorLayer } from '@systemfsoftware/agent-platform-node/node-code-executor' -``` diff --git a/docs/src/content/docs/guide/sandbox.md b/docs/src/content/docs/guide/sandbox.md index f5da46964..6d09277a6 100644 --- a/docs/src/content/docs/guide/sandbox.md +++ b/docs/src/content/docs/guide/sandbox.md @@ -13,11 +13,12 @@ JavaScript over allowlisted tools and [browser services](/guide/browser/) for we `CodeExecutor` gives one generated program a narrow host-call capability; it does not grant a shell. The Cloudflare adapter runs each pass in a fresh Dynamic Worker with ambient network -access disabled. The Node adapter runs each pass in a fresh hardware-isolated microVM whose -network device is disabled before boot; it requires hardware virtualization (KVM on Linux, -Hypervisor.framework on Apple Silicon, or Windows Hypervisor Platform), pulls its guest image -on first use, and fails the pass with `CodeExecutorStartError` when the host cannot start a VM. -Inside the Node guest the workload runs as an unprivileged user on a read-only root with one +access disabled. The Bun adapter (`@systemfsoftware/agent-platform-bun/code-executor`) runs each +pass in a fresh hardware-isolated microVM whose network device is disabled before boot; it +requires hardware virtualization (KVM on Linux, Hypervisor.framework on Apple Silicon, or +Windows Hypervisor Platform), pulls its guest image on first use, and fails the pass with +`CodeExecutorStartError` when the host cannot start a VM. +Inside the Bun guest the workload runs as an unprivileged user on a read-only root with one writable scratch directory, receives no host environment or credentials, and can read only the library directories the host mounts read-only. Calls into application tools still require the host's current authorization. diff --git a/packages/platform-bun/package.json b/packages/platform-bun/package.json new file mode 100644 index 000000000..f76fe3758 --- /dev/null +++ b/packages/platform-bun/package.json @@ -0,0 +1,61 @@ +{ + "name": "@systemfsoftware/agent-platform-bun", + "version": "0.0.0", + "description": "Bun platform adapters for Effect Agent: an isolated microVM CodeExecutor for generated JavaScript.", + "license": "MIT", + "repository": { + "type": "git", + "url": "git+https://github.com/systemfsoftware/agent.git", + "directory": "packages/platform-bun" + }, + "files": [ + "dist", + "src" + ], + "type": "module", + "sideEffects": [], + "exports": { + ".": "./src/index.ts", + "./code-executor": "./src/CodeExecutor.ts" + }, + "publishConfig": { + "access": "public", + "exports": { + ".": { + "types": "./dist/index.d.mts", + "default": "./dist/index.mjs" + }, + "./code-executor": { + "types": "./dist/CodeExecutor.d.mts", + "default": "./dist/CodeExecutor.mjs" + } + }, + "provenance": true + }, + "scripts": { + "build": "tsdown", + "typecheck": "tsc -b", + "test": "vitest run --passWithNoTests", + "test:conformance-bun": "bun run tests/__fixtures__/conformance-runner.ts", + "check:pack": "pnpm pack --pack-destination .pack && attw .pack/*.tgz --profile esm-only; s=$?; rm -rf .pack; exit $s" + }, + "dependencies": { + "@systemfsoftware/agent": "workspace:*", + "microsandbox": "catalog:" + }, + "devDependencies": { + "@arethetypeswrong/cli": "catalog:", + "@effect/platform-bun": "catalog:", + "@effect/platform-node": "catalog:", + "@systemfsoftware/agent-testing": "workspace:*", + "@systemfsoftware/effect-gherkin-spec": "catalog:", + "@systemfsoftware/vitest": "catalog:", + "effect": "catalog:", + "tsdown": "catalog:", + "typescript": "catalog:", + "vitest": "catalog:" + }, + "peerDependencies": { + "effect": "^4.1.0" + } +} diff --git a/packages/platform-node/src/NodeCodeExecutor.ts b/packages/platform-bun/src/CodeExecutor.ts similarity index 97% rename from packages/platform-node/src/NodeCodeExecutor.ts rename to packages/platform-bun/src/CodeExecutor.ts index 7825395a9..71d382e24 100644 --- a/packages/platform-node/src/NodeCodeExecutor.ts +++ b/packages/platform-bun/src/CodeExecutor.ts @@ -29,6 +29,7 @@ import * as Layer from 'effect/Layer' import * as Match from 'effect/Match' import * as Option from 'effect/Option' import * as Queue from 'effect/Queue' +import * as Random from 'effect/Random' import * as Schema from 'effect/Schema' import type * as Scope from 'effect/Scope' import * as Semaphore from 'effect/Semaphore' @@ -47,7 +48,7 @@ import { export const microVmCodeExecutorImplementation = SandboxImplementation.make({ isolation: 'isolated', - identity: 'node-microvm-javascript', + identity: 'bun-microvm-javascript', }) const GUEST_DIR = '/opt/code-executor' @@ -58,7 +59,7 @@ const SCRATCH_UID = 65_534 const SCRATCH_GID = 65_534 const GUEST_USER = `${SCRATCH_UID}:${SCRATCH_GID}` const DEFAULT_SCRATCH_MIB = 64 -const DEFAULT_IMAGE = 'node:22-alpine' +const DEFAULT_IMAGE = 'oven/bun:1-alpine' const PROVISION_SCRIPT = `chown ${SCRATCH_UID}:${SCRATCH_GID} ${GUEST_SCRATCH} && chmod 700 ${GUEST_SCRATCH} && mount -o remount,ro / && mount -o remount,ro /dev/shm` const GUEST_READY_TIMEOUT = Duration.seconds(60) @@ -228,6 +229,12 @@ interface PassCounter { let sandboxSequence = 0 +const nextSandboxName = (entropy: number, second: number): string => { + sandboxSequence += 1 + + return `agent-code-executor-${entropy}-${second}-${sandboxSequence}` +} + const imageOf = (options: MicroVmCodeExecutorOptions): string => options.image ?? DEFAULT_IMAGE const scratchOf = (options: MicroVmCodeExecutorOptions): number => options.scratchMiB ?? DEFAULT_SCRATCH_MIB const mountsOf = (options: MicroVmCodeExecutorOptions): ReadonlyArray => options.readOnlyMounts ?? [] @@ -255,12 +262,15 @@ interface GuestPackageMount { nodev(): GuestPackageMount } -const createSandbox = async (config: GuestConfig, setup: SandboxSetup): Promise => { +const createSandbox = async ( + config: GuestConfig, + setup: SandboxSetup, + name: string, +): Promise => { const { Sandbox } = await import('microsandbox') - sandboxSequence += 1 const configText = Option.getOrElse(encodeGuestConfig(config), () => '') - const builder = Sandbox.builder(`effect-agent-code-executor-${process.pid}-${sandboxSequence}`) + const builder = Sandbox.builder(name) .image(setup.image) .ephemeral(true) .disableNetwork() @@ -280,9 +290,10 @@ const createSandbox = async (config: GuestConfig, setup: SandboxSetup): Promise< const launchSandbox = ( config: GuestConfig, setup: SandboxSetup, + name: string, ): Effect.Effect => Effect.tryPromise({ - try: () => createSandbox(config, setup), + try: () => createSandbox(config, setup, name), catch: (cause) => startError( cause instanceof Error ? `The microVM could not start: ${cause.message}` : 'The microVM could not start', @@ -316,7 +327,7 @@ const openGuestProcess = (sandbox: MicroSandbox): Effect.Effect - sandbox.execStreamWith('node', (builder) => + sandbox.execStreamWith('bun', (builder) => builder .arg(GUEST_HARNESS_PATH) .arg(GUEST_CONFIG_PATH) @@ -821,8 +832,10 @@ const makeExecute = (options: MicroVmCodeExecutorOptions): CodeExecutorExecute = yield* validateRequest(request) const host = yield* CodeExecutionHost + const entropy = yield* Random.nextInt + const second = yield* Random.nextInt const sandbox = yield* Effect.acquireRelease( - launchSandbox(guestConfigOf(request), setupOf(options)), + launchSandbox(guestConfigOf(request), setupOf(options), nextSandboxName(entropy, second)), stopSandbox, ) yield* provisionSandbox(sandbox) diff --git a/packages/platform-bun/src/index.ts b/packages/platform-bun/src/index.ts new file mode 100644 index 000000000..b40015c77 --- /dev/null +++ b/packages/platform-bun/src/index.ts @@ -0,0 +1 @@ +export * as CodeExecutor from './CodeExecutor' diff --git a/packages/platform-node/src/internal/code-executor-guest.ts b/packages/platform-bun/src/internal/code-executor-guest.ts similarity index 96% rename from packages/platform-node/src/internal/code-executor-guest.ts rename to packages/platform-bun/src/internal/code-executor-guest.ts index 919810201..4c7832717 100644 --- a/packages/platform-node/src/internal/code-executor-guest.ts +++ b/packages/platform-bun/src/internal/code-executor-guest.ts @@ -51,8 +51,13 @@ const writeLog = (...values) => { logBytes += bytes } +let outbox = Promise.resolve() + const emit = (message, done) => { - process.stdout.write(JSON.stringify(message) + '\n', done) + const text = JSON.stringify(message) + '\n' + + outbox = outbox.then(() => Bun.write(Bun.stdout, text)) + if (done !== undefined) outbox = outbox.then(done) } const finish = (message) => { diff --git a/packages/platform-node/src/internal/code-executor.schema.ts b/packages/platform-bun/src/internal/code-executor.schema.ts similarity index 100% rename from packages/platform-node/src/internal/code-executor.schema.ts rename to packages/platform-bun/src/internal/code-executor.schema.ts diff --git a/packages/platform-node/tests/__fixtures__/code-executor.schema.ts b/packages/platform-bun/tests/__fixtures__/code-executor.schema.ts similarity index 100% rename from packages/platform-node/tests/__fixtures__/code-executor.schema.ts rename to packages/platform-bun/tests/__fixtures__/code-executor.schema.ts diff --git a/packages/platform-bun/tests/__fixtures__/conformance-runner.ts b/packages/platform-bun/tests/__fixtures__/conformance-runner.ts new file mode 100644 index 000000000..41ce89820 --- /dev/null +++ b/packages/platform-bun/tests/__fixtures__/conformance-runner.ts @@ -0,0 +1,49 @@ +import { BunRuntime } from '@effect/platform-bun' +import { + type CodeExecutorConformanceCase, + codeExecutorConformanceCases, +} from '@systemfsoftware/agent-testing/code-executor-conformance' +import * as Console from 'effect/Console' +import * as Effect from 'effect/Effect' +import * as Exit from 'effect/Exit' +import * as Schema from 'effect/Schema' + +import { + microVmCodeExecutorImplementation, + microVmCodeExecutorLayer, +} from '@systemfsoftware/agent-platform-bun/code-executor' + +class ConformanceFailed + extends Schema.TaggedError()('ConformanceFailed', { + failures: Schema.Array(Schema.String), + }) +{ + get message() { + return `${this.failures.length} conformance case(s) failed: ${this.failures.join(', ')}` + } +} + +const layer = microVmCodeExecutorLayer() + +const runCase = (conformanceCase: CodeExecutorConformanceCase): Effect.Effect => + conformanceCase.run.pipe( + Effect.provide(layer), + Effect.exit, + Effect.map((exit) => (Exit.isSuccess(exit) ? undefined : conformanceCase.name)), + ) + +const report = Effect.gen(function*() { + const cases = codeExecutorConformanceCases({ + implementation: microVmCodeExecutorImplementation, + }) + const results = yield* Effect.forEach(cases, runCase, { concurrency: 1 }) + const failures = results.filter((name): name is string => name !== undefined) + + if (failures.length === 0) { + return yield* Console.log(`CodeExecutorConformance passed ${cases.length}/${cases.length} cases on Bun`) + } + + return yield* new ConformanceFailed({ failures }) +}) + +BunRuntime.runMain(report) diff --git a/packages/platform-node/tests/code-executor.integration.test.ts b/packages/platform-bun/tests/code-executor.integration.test.ts similarity index 98% rename from packages/platform-node/tests/code-executor.integration.test.ts rename to packages/platform-bun/tests/code-executor.integration.test.ts index 240e3ed6b..0b98d796b 100644 --- a/packages/platform-node/tests/code-executor.integration.test.ts +++ b/packages/platform-bun/tests/code-executor.integration.test.ts @@ -3,7 +3,7 @@ import * as NodePath from '@effect/platform-node/NodePath' import { microVmCodeExecutorLayer, type MicroVmCodeExecutorOptions, -} from '@systemfsoftware/agent-platform-node/node-code-executor' +} from '@systemfsoftware/agent-platform-bun/code-executor' import { CodeExecutionHost, CodeExecutionLimits, @@ -96,7 +96,7 @@ const withPinnedLibrary = ( const Feature = makeFeature({ it }) -Feature('Executing generated JavaScript in the Node CodeExecutor', { timeout: 300_000 }) +Feature('Executing generated JavaScript in the Bun CodeExecutor', { timeout: 300_000 }) .live('each pass boots a real microVM and waits on its guest process') .withLayer(Layer.merge(NodeFileSystem.layer, NodePath.layer)) .body(({ scenario }) => { diff --git a/packages/platform-bun/tsconfig.app.json b/packages/platform-bun/tsconfig.app.json new file mode 100644 index 000000000..1dedcc164 --- /dev/null +++ b/packages/platform-bun/tsconfig.app.json @@ -0,0 +1,19 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "composite": true, + "noEmit": false, + "emitDeclarationOnly": true, + "outDir": "node_modules/.cache/tsc/app", + "tsBuildInfoFile": "node_modules/.cache/tsconfig.app.tsbuildinfo" + }, + "include": [ + "src/**/*.ts" + ], + "references": [ + { + "path": "../effect-agent/tsconfig.app.json" + } + ] +} diff --git a/packages/platform-bun/tsconfig.build.json b/packages/platform-bun/tsconfig.build.json new file mode 100644 index 000000000..51a35ed4b --- /dev/null +++ b/packages/platform-bun/tsconfig.build.json @@ -0,0 +1,12 @@ +{ + "extends": "./tsconfig.app.json", + "compilerOptions": { + "composite": false, + "noEmit": true, + "emitDeclarationOnly": false + }, + "include": [ + "src" + ], + "references": [] +} diff --git a/packages/platform-bun/tsconfig.json b/packages/platform-bun/tsconfig.json new file mode 100644 index 000000000..7ddf2dcb4 --- /dev/null +++ b/packages/platform-bun/tsconfig.json @@ -0,0 +1,11 @@ +{ + "files": [], + "references": [ + { + "path": "./tsconfig.app.json" + }, + { + "path": "./tsconfig.test.json" + } + ] +} diff --git a/packages/platform-bun/tsconfig.test.json b/packages/platform-bun/tsconfig.test.json new file mode 100644 index 000000000..133957ed7 --- /dev/null +++ b/packages/platform-bun/tsconfig.test.json @@ -0,0 +1,22 @@ +{ + "extends": "../../tsconfig.base.json", + "compilerOptions": { + "rootDir": ".", + "composite": true, + "noEmit": false, + "emitDeclarationOnly": true, + "outDir": "node_modules/.cache/tsc/test", + "tsBuildInfoFile": "node_modules/.cache/tsconfig.test.tsbuildinfo" + }, + "include": [ + "tests/**/*.ts" + ], + "references": [ + { + "path": "../effect-agent/tsconfig.app.json" + }, + { + "path": "./tsconfig.app.json" + } + ] +} diff --git a/packages/platform-bun/tsdown.config.ts b/packages/platform-bun/tsdown.config.ts new file mode 100644 index 000000000..fe2db1d79 --- /dev/null +++ b/packages/platform-bun/tsdown.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'tsdown' + +import manifest from './package.json' with { type: 'json' } + +// The source tree is the development surface: every `exports` entry names one source file, and each is one bundle +// entry. `publishConfig.exports` swaps them for the built files when the package is packed. +export default defineConfig({ + entry: Object.values(manifest.exports), + format: 'esm', + dts: true, + // The solution root owns no files, so declaration emit reads the app role directly. + tsconfig: 'tsconfig.build.json', + sourcemap: true, + fixedExtension: true, +}) diff --git a/packages/platform-bun/vitest.config.ts b/packages/platform-bun/vitest.config.ts new file mode 100644 index 000000000..5457bbbc3 --- /dev/null +++ b/packages/platform-bun/vitest.config.ts @@ -0,0 +1,15 @@ +import { defineConfig } from 'vitest/config' + +export default defineConfig({ + // Vite replaces its defaults when conditions are set, so the defaults are listed back and the + // workspace source condition is appended for both the client and SSR resolvers. + resolve: { conditions: ['module', 'browser', 'development|production', '@systemfsoftware/source'] }, + ssr: { + resolve: { conditions: ['module', 'node', 'development|production', '@systemfsoftware/source'] }, + }, + test: { + cache: false, + silent: 'passed-only', + testTimeout: 30_000, + }, +}) diff --git a/packages/platform-node/package.json b/packages/platform-node/package.json index de9bd1a24..2250aba6f 100644 --- a/packages/platform-node/package.json +++ b/packages/platform-node/package.json @@ -16,7 +16,6 @@ "sideEffects": [], "exports": { ".": "./src/index.ts", - "./node-code-executor": "./src/NodeCodeExecutor.ts", "./node-durable-agent-runtime": "./src/NodeDurableAgentRuntime.ts", "./node-durable-host": "./src/NodeDurableHost.ts", "./node-scheduling": "./src/NodeScheduling.ts", @@ -30,10 +29,6 @@ "types": "./dist/index.d.mts", "default": "./dist/index.mjs" }, - "./node-code-executor": { - "types": "./dist/NodeCodeExecutor.d.mts", - "default": "./dist/NodeCodeExecutor.mjs" - }, "./node-durable-agent-runtime": { "types": "./dist/NodeDurableAgentRuntime.d.mts", "default": "./dist/NodeDurableAgentRuntime.mjs" @@ -67,14 +62,11 @@ "@effect/platform-node": "catalog:", "@effect/sql-sqlite-node": "catalog:", "@systemfsoftware/agent": "workspace:*", - "@systemfsoftware/agent-storage-sqlite": "workspace:*", - "microsandbox": "catalog:" + "@systemfsoftware/agent-storage-sqlite": "workspace:*" }, "devDependencies": { "@arethetypeswrong/cli": "catalog:", "@effect/vitest": "catalog:", - "@systemfsoftware/effect-gherkin-spec": "catalog:", - "@systemfsoftware/vitest": "catalog:", "effect": "catalog:", "esbuild": "catalog:", "tsdown": "catalog:", diff --git a/packages/platform-node/src/index.ts b/packages/platform-node/src/index.ts index 6de16c9c2..f17f66d42 100644 --- a/packages/platform-node/src/index.ts +++ b/packages/platform-node/src/index.ts @@ -1,4 +1,3 @@ -export * as NodeCodeExecutor from './NodeCodeExecutor' export * as NodeDurableAgentRuntime from './NodeDurableAgentRuntime' export * as NodeDurableHost from './NodeDurableHost' export * as NodeScheduling from './NodeScheduling' diff --git a/packages/platform-node/tsconfig.test.json b/packages/platform-node/tsconfig.test.json index a44ab3fdf..8d5ee0cdc 100644 --- a/packages/platform-node/tsconfig.test.json +++ b/packages/platform-node/tsconfig.test.json @@ -8,8 +8,7 @@ "tsBuildInfoFile": "node_modules/.cache/tsconfig.test.tsbuildinfo" }, "include": [ - "test/**/*.ts", - "tests/**/*.ts" + "test/**/*.ts" ], "references": [ { diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 0052e21b5..d6db9e5f9 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -995,6 +995,46 @@ importers: specifier: 5.1.2 version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + packages/platform-bun: + dependencies: + '@systemfsoftware/agent': + specifier: workspace:* + version: link:../effect-agent + microsandbox: + specifier: 'catalog:' + version: 0.7.8 + devDependencies: + '@arethetypeswrong/cli': + specifier: 'catalog:' + version: 0.18.5 + '@effect/platform-bun': + specifier: 'catalog:' + version: 4.1.5(effect@4.1.5) + '@effect/platform-node': + specifier: 4.1.5 + version: 4.1.5(effect@4.1.5)(redis@6.3.1) + '@systemfsoftware/agent-testing': + specifier: workspace:* + version: link:../testing + '@systemfsoftware/effect-gherkin-spec': + specifier: 'catalog:' + version: 8.4.3(@systemfsoftware/vitest@4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + '@systemfsoftware/vitest': + specifier: 'catalog:' + version: 4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) + effect: + specifier: 4.1.5 + version: 4.1.5 + tsdown: + specifier: 'catalog:' + version: 0.23.7(@arethetypeswrong/core@0.18.5)(@vue/language-core@3.3.14)(tsrs@0.18.0-ts7.1.0-dev.20260929)(typescript@7.0.2) + typescript: + specifier: 'catalog:' + version: 7.0.2 + vitest: + specifier: 5.1.2 + version: 5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1)) + packages/platform-cloudflare: dependencies: '@cloudflare/codemode': @@ -1082,9 +1122,6 @@ importers: '@systemfsoftware/agent-storage-sqlite': specifier: workspace:* version: link:../storage-sqlite - microsandbox: - specifier: 'catalog:' - version: 0.7.8 devDependencies: '@arethetypeswrong/cli': specifier: 'catalog:' @@ -1092,12 +1129,6 @@ importers: '@effect/vitest': specifier: 4.1.5 version: 4.1.5(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) - '@systemfsoftware/effect-gherkin-spec': - specifier: 'catalog:' - version: 8.4.3(@systemfsoftware/vitest@4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))))(effect@4.1.5)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) - '@systemfsoftware/vitest': - specifier: 'catalog:' - version: 4.4.0(effect@4.1.5)(redis@6.3.1)(vitest@5.1.2(@types/node@26.1.2)(vite@8.3.8(@types/node@26.1.2)(esbuild@0.28.1)(jiti@2.7.0)(yaml@2.9.1))) effect: specifier: 4.1.5 version: 4.1.5 diff --git a/tsconfig.json b/tsconfig.json index 45f61deb2..b08d1a918 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -10,6 +10,9 @@ { "path": "./packages/effect-agent" }, + { + "path": "./packages/platform-bun" + }, { "path": "./packages/platform-cloudflare" }, From 684751c67574c72b9c2d057943221fb241c05670 Mon Sep 17 00:00:00 2001 From: systemfsoftware-bot <318394648+systemfsoftware-bot@users.noreply.github.com> Date: Sat, 5 Dec 2026 01:32:19 -0500 Subject: [PATCH 5/5] docs(agents): the package inventory names agent-platform-bun --- AGENTS.md | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AGENTS.md b/AGENTS.md index 2bbbe0458..5d9ba3668 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -1,8 +1,8 @@ # agent -Effect-native agents with durable Threads, published as eleven packages: `@systemfsoftware/agent`, -`@systemfsoftware/agent-ai-decision`, `@systemfsoftware/agent-platform-cloudflare`, -`@systemfsoftware/agent-platform-node`, `@systemfsoftware/agent-pr-review`, +Effect-native agents with durable Threads, published as twelve packages: `@systemfsoftware/agent`, +`@systemfsoftware/agent-ai-decision`, `@systemfsoftware/agent-platform-bun`, +`@systemfsoftware/agent-platform-cloudflare`, `@systemfsoftware/agent-platform-node`, `@systemfsoftware/agent-pr-review`, `@systemfsoftware/agent-storage-cloudflare`, `@systemfsoftware/agent-storage-memory`, `@systemfsoftware/agent-storage-postgres`, `@systemfsoftware/agent-storage-sql`, `@systemfsoftware/agent-storage-sqlite` and `@systemfsoftware/agent-testing`, beside the private