Skip to content

feat(runtime): add confined CodeMode exec cells #1553

Closed

Description

@Astro-Han

Problem

#1383 accepted a local exec protocol for GPT coding models. The original plan here was to run each cell in a short-lived Node child process under Node's permission model, with the session OS sandbox as the authority ceiling.

Review of that design against the two reference implementations (openai/codex, anomalyco/opencode) and against this repo found the security premise does not hold:

  • Node documents the permission model as a seat belt that "does not provide security guarantees in the presence of malicious code." It also documents that a sandboxed process under --permission can call process._debugProcess(pid) to force any other Node process under the same OS user to open its V8 Inspector — for an Electron/Node host this reopens exactly the blast radius the child process was meant to close.
  • --allow-net was added in Node v25.0.0 (--allow-fs-read and --allow-child-process are v20.0.0). This repo pins engines: node >=22.19.0 and Electron 43.1.1. The clause "no network authority" is not merely unsafe to rely on — on our supported floor the knob does not exist. Network denial can only come from the OS sandbox.
  • With the OS sandbox as the sole real boundary, "fails closed" makes availability platform-conditional. default-sandbox-manager.ts registers Seatbelt and Bubblewrap only; Bubblewrap additionally requires a user-namespace capability probe. CodeMode would be permanently dark on Windows and dark in container CI without userns — which is where the GPT tool-protocol compatibility: ApplyPatch and Code Mode #1383 evaluation runs.

Deny-listing a full Node runtime is also structurally fragile: every builtin must be neutralized, and the list is not enumerable. Both reference implementations reached the opposite design from opposite directions — Codex evaluates cells in a bare V8 isolate with host-injected capabilities and no Node, and OpenCode declines to embed a runtime at all.

Approach

Invert the stack. Instead of an OS sandbox wrapped around a restricted full Node, run a capability-less cell inside the already-sandboxed session process.

The cell evaluates a restricted orchestration subset of TypeScript/JavaScript over a hand-rolled interpreter. There is no ambient capability to revoke: no require, no process, no globalThis escape, no timers, no eval/Function, no dynamic import, no host object references across the boundary. The only effectful operation is the host-injected tools.* bridge, and every call through it lands in the existing ToolRuntime path.

This keeps the authoritative boundary where it already is — ToolRuntime + PermissionEngine — and introduces no second permission language. The cell inherits the session process's OS sandbox by construction, so the authority ceiling is met without a platform lottery.

Rationale for the interpreter over a node:vm isolate: node:vm is documented as not a security mechanism, shares the host heap, cannot preempt async execution, and — decisively — its escape idiom (this.constructor.constructor('return process')()) is widely published and therefore present in model pretraining data. Under a prompt-injection threat model the attacker does not need to write an exploit, only to induce the model to emit one it has already seen. A bespoke interpreter has no such ready-made gadget, and its failure mode is inverted: unsupported syntax returns a loud, recoverable diagnostic, where a node:vm security failure is silent full-host compromise.

Threat model this assumes: cell code is model-authored, and its effects are permission-gated. See Non-goals.

Scope

Add an explicit per-run override with Direct and CodeMode. The default remains Direct.

Naming: @maka/core/orchestration already defines EffectiveOrchestration as default | swarm | graph (agent topology), and ToolRuntime consumes it. This is a different axis and must not reuse the word. Proposed name: toolMode, matching Codex's tool_mode. Needs alignment with #1383.

In CodeMode, the provider sees the active ordinary tools plus direct-only exec. Inside exec, the cell sees only the active nestable projection of the same effective tool surface from #1493.

Deliver one complete vertical path:

  1. Build exec as an ordinary top-level Maka tool.
  2. Evaluate each cell in a fresh interpreter context with no ambient capabilities.
  3. Project the active nestable tool schemas into the cell as tools.*, with full argument schemas.
  4. Route every nested call back through the existing ToolRuntime; never call MakaTool.impl directly.
  5. Record nested dispatch and outcome as non-model-visible durable facts linked to the parent exec operation.
  6. Preserve live and replayed UI activity, permission prompts, telemetry, artifact handling, abort, limits, and recovery semantics for nested calls.

AskUserQuestion, Agent/Team tools, load_tools, and exec are direct-only. Ordinary product and supplemental tools are nestable by default. Whether mcp__* tools are nestable must be decided explicitly, along with their in-cell call path.

Cell contract

  • One fresh cell context per exec. No cross-cell state, no REPL, no session-scoped store.
  • The cell has no ambient tool implementations, secrets, provider credentials, or inherited application state. The bridge closure must not leak host functions, prototypes, or object identity into cell-reachable values; only plain data crosses the boundary.
  • The supported language subset is calibrated against GPT-5.6's observed output distribution, not copied from a reference implementation. Unsupported syntax returns a structured diagnostic as data, not a crash.
  • Bound code size, nested-call count, concurrency, result size, output bytes, wall time, and interpreter step count. Cooperative yielding must let wall-time and step bounds preempt a pure compute loop.
  • Cell ownership is scoped to the parent turn. Abort, stop, turn completion, host disconnect, or process exit terminates all owned cells via abort signal.
  • A cell that awaits a nested permission prompt must suspend correctly and settle correctly if the turn is aborted while suspended.
  • An interpreter fault, bound breach, or bridge protocol violation fails the cell without failing the turn or the process.
  • No console. Output is the returned value plus a bounded log buffer.

Fails-closed becomes an enforceable invariant rather than a sandbox-selection check: every tool on the nestable surface must be gateable by PermissionEngine. This holds today; make it a contract test.

Discovery

The cell surface is the activation snapshot at exec start. Deferred activation remains a provider-level act via load_tools; same-cell re-projection is not supported.

The previous clause required nested load_tools to mutate deferred-activation authority from inside the cell. Both reference implementations declined the equivalent: Codex binds deferred tools unconditionally so activation is prompt-rendering only, and OpenCode's $codemode.search is read-only. Neither lets the execution environment write activation state. Discovery is not activation.

Cost: a model that discovers mid-cell that it needs a deferred tool must end the cell, activate at provider level, and re-exec — one extra provider round trip. Bought: a deterministic, replayable, auditable cell surface and no authority write from the execution context. Our deferred set is small enough (four surfaces, two of them desktop-only, one direct-only) that this trade is clearly favorable.

If a nestable MCP surface later exceeds the description budget, add an in-cell read-only search that returns full signatures with schemas — not Codex's schema-less ALL_TOOLS, which forces argument-shape guessing.

History and durability

  • Provider history contains only the exec calls actually returned by the provider.
  • Nested calls use distinct runtime operation identities carrying origin, modelVisibility, and a parent exec reference. Filtering nested events out of replay must be an explicit field consumed by the projection seam (runtimeEventHasModelVisibleContent / includeTools), not an output-layer convention — settleToolCall already constructs RuntimeEvents with role: 'tool'.
  • Nested calls retain durable T1/T2 boundaries and recovery modes but do not emit model-replayable function_call or function_response content.
  • Cell lifecycle events and a bounded output digest are durable. The exec call's own durable record carries the bounded cell source; that is the audit artifact.
  • Restart contract: an in-flight cell cannot survive a restart. On recovery, in-flight cells are terminated and their exec call settles to a terminal interrupted result via the existing recovery resolver. Nested calls are never replayed on resume.
  • The model sees nested results only through the enclosing cell's returned value/output.

Protocol conformance

GPT-5.6's code-mode distribution was shaped by Codex's wire shape. Align where alignment is free — parameter name code, tools.<name>(args) global, no console, terminate by returning a value — and state divergences loudly and early in the exec tool description.

Add a protocol-health panel to the #1383 gate as a blocking check, not a score: exec parse/unsupported-syntax rate, nested unknown-tool rate, and malformed nested argument rate. Prior forced-mode measurement showed the relevant failure class is the model hallucinating protocol identifiers when the surface is unfamiliar or under-specified.

Acceptance

  • Direct mode is byte-for-byte unchanged at the provider tool surface.
  • CodeMode exposes direct ordinary tools plus exec, and exposes active nestable tools with schemas inside the cell.
  • Direct-only tools are rejected by nested admission before permission or implementation.
  • Nested permission, denial, sandbox escalation, artifact, error, abort, and recovery paths match direct settlement.
  • Contract test: no tool on the nestable surface is ungateable by PermissionEngine.
  • Escape suite: the cell cannot reach process, require, globalThis, timers, dynamic import, or any host object identity; each is a named test.
  • Provider replay contains no nested function-call records; durable inspection and UI activity still contain the child operations and parent linkage.
  • Recovery test: crash with a cell in flight resumes with a terminal interrupted exec result and no nested replay.
  • Bounds tests: code size, nested-call count, concurrency, result size, output bytes, wall time, interpreter steps — including preemption of a pure compute loop.
  • A controlled Direct versus CodeMode comparison holds the editing surface constant, is paired per task with interleaved scheduling, and reports per-stratum results across fan-out, sequential-dependent, and long-horizon task shapes.
  • Direct remains the default and explicit rollback.

Non-goals

  • Executing user-supplied or third-party-distributed code. The confinement model assumes model-authored code with permission-gated effects. If that assumption changes, the interpreter approach is invalid and this design must be revisited.
  • Memory/RSS containment. No option on the table provides it in v1 — Seatbelt and Bubblewrap do not bound RSS, and a child process only allows post-hoc kill. Step and size bounds mitigate; they do not contain. Stated as known residual risk.
  • Session-scoped cell state (store/load). Ledger-invisible mutable state is an audit hole.
  • Hiding ordinary top-level tools; CodeModeOnly is a later slice — but it changes only provider-surface projection, not the cell, so sequencing should keep it cheap to add.
  • Adding ApplyPatch.
  • Provider-native programmatic calling.
  • A general-purpose scripting platform or persistent JavaScript host.

Open questions

  1. wait / cell_id deferred out of this slice. tool-runtime.ts already pauses the provider idle watchdog during tool execution, so an in-process long-running cell simply leaves the exec call pending; there is no protocol-level need for a yield window. Removing it also removes the observed symbolic-cell_id failure class. This diverges from Codex's wire shape, so if the conformance gate shows GPT-5.6 expecting a yield/wait path, add it back with a generous initial window and a tolerant wait that returns a structured error for unknown or already-terminal IDs. (The two reviews split here: one recommended dropping it from slice 1, the other keeping it calibrated. Repo evidence favors dropping.)
  2. Interpreter versus node:vm. The interpreter is preferred at roughly 0.65–0.75 confidence across two independent reviews. The decisive quantity is measurable: the share of model-generated cells that fall outside the supported subset. If rewrite cost from subset rejections proves material, switch to a hardened node:vm isolate — do not grow the interpreter toward full JavaScript.
  3. Concurrency admission. Can exec run in parallel with a direct tool in the same step? stepAdmissions needs an explicit answer for exec.
  4. Nested live output. Does a cell's Bash live output stream to the UI under the exec call, and under what bound?

Depends on #1493. Part of #1383.


重写说明(中文)

为什么推翻原方案

原方案的安全性建立在 Node permission model 上,这条腿是空的:

  1. Node 官方明写它不防恶意代码。原文是 "It does not provide security guarantees in the presence of malicious code.",并给出具体逃逸路径:--permission 下的进程可以调 process._debugProcess(pid),强制同一 OS 用户下的任意 Node 进程打开 V8 Inspector。对 Electron 宿主,这等于把凭据和全部应用状态交出去 —— 恰好是引入子进程想防的 blast radius。
    (补一句避免误读:它自 v22.13.0 / v23.5.0 起已不再标 experimental,但"不防恶意代码"是设计定位而非成熟度问题,稳定化没有改变它。)

  2. 更硬的一条:Node 22 上根本没有关网络的开关。--allow-net 的 Added in 是 v25.0.0,而 --allow-fs-read / --allow-child-process 都是 v20.0.0。本仓 engines: node >=22.19.0、Electron 43.1.1。所以原文"no network authority"这句,在支持底线上不是"不该依赖",是不存在。断网只能来自 OS sandbox。

  3. 于是 fail-closed 的代价浮出来:真实边界只剩 OS sandbox 时,"拿不到就 fail closed"让特性变成平台抽签。default-sandbox-manager.ts 只注册了 Seatbelt 和 Bubblewrap,后者还要过 user namespace 探测。结果是 Windows 永远变暗、容器化 CI 无 userns 时变暗 —— 而那正是 GPT tool-protocol compatibility: ApplyPatch and Code Mode #1383 跑评测的地方。

还有个结构性问题:对完整 Node 做 deny-list,要求把每个内置能力逐个中和,而这个清单是列不完的。两个参考实现从相反方向得出同一结论 —— Codex 在裸 V8 isolate 里跑(无 Node、无 fs、无网络、无 console,能力由宿主注入),OpenCode 干脆不引入运行时。

为什么是自研解释器,而不是 node:vm

node:vm 看着更省事:真 JS 语义、贴合 GPT-5.6 训练分布、零新依赖。但:

  • 官方同样明示它不是安全机制;与宿主共享堆(无内存上限);async 执行无法抢占
  • 决定性的一条:它的逃逸写法(this.constructor.constructor('return process')())遍布安全博客,必然在模型预训练语料里。一旦威胁模型包含 prompt injection,攻击者不需要自己写 exploit,只要诱导模型把它早就见过的那段原样吐出来。自研解释器没有这个属性 —— 语料里不存在针对它的现成 gadget。
  • 两者失败模式相反:解释器遇到子集外语法返回响亮可恢复的诊断(模型改了重来),node:vm 的安全失败是静默的全宿主失陷。

顺带说明:per-cell 固定成本不是这次的决策变量。本地实测显示模型倾向于每个原子调用各发一个 exec 而不打包,子进程启动成本因此摊不薄 —— 但即使摊得薄,决策依据也是失败模式和可用性矩阵,不是那几十毫秒。

关于内存

三种方案在 v1 都给不了 RSS 上限:Seatbelt 和 bwrap 不管内存,node:vm 共享宿主堆,解释器跑在宿主堆上,子进程也只能事后 kill 而非预防。所以"选子进程是为了内存安全"是个错觉。已写进 Non-goals 作为已知残余风险,靠步数上限和数据尺寸上限缓解。

关于 load_tools

原文要求嵌套 load_tools 变更 deferred 激活权威并对同一个 cell 生效。两个问题:

  • 本仓 tool-availability.ts 写明激活"takes effect in the next Runtime request projection",所以"同一个 cell 内生效"在现有架构下没有语义
  • 更重要的是,即使能实现也不该做:Codex 把 deferred 工具无条件绑定(激活只影响 prompt 渲染,压根没有权威变更),OpenCode 的 search 只读。没有任何一方让沙箱内的执行环境去写激活状态。 这是双方的收敛点

代价算清楚了写在正文里:中途才发现需要 deferred 工具,得终结 cell、provider 层激活、重新 exec,多一次往返。换来 cell 表面确定性。我们 deferred 集合只有四个 surface(两个仅 desktop、一个 direct-only),这笔交易明显划算。

还没定的

Open questions 里第一条是两份独立评审唯一分歧的地方:wait / cell_id 要不要进第一个 slice。一方主张删(活动部件少、消掉已观察到的符号化 ID 失败类别),一方主张留但调宽窗口(贴合 GPT-5.6 的 Codex 先验)。我按仓内证据选了删 —— tool-runtime.ts 在工具执行期间已经暂停 provider idle watchdog,注释明写长任务不该触发 idle timeout,所以进程内长 cell 只是让 exec 一直 pending,协议层不需要 yield 窗口。如果一致性门禁显示 5.6 确实期待 wait 路径,再按 open question 里写的方式加回。

第二条是解释器 vs node:vm 的最终裁决,取决于一个可测量的量:模型生成的 cell 有多大比例落在受限子集外。超过阈值就换 node:vm,而不是把解释器一点点扩成完整 JS —— 那是陷阱,OpenCode 锁定决策里那句 "the model only needs orchestration syntax, not a full runtime" 就是在防这个。

结论的适用前提

整套推理只在"cell 代码由模型生成、其副作用经权限门控"这个前提下成立。哪天要跑用户直接粘贴的代码或第三方分发的 cell,作者即攻击者,解释器方案立刻失效,得翻回真进程隔离或真 isolate。这条已写进 Non-goals 第一项。

Activity

  1. added
    enhancement
    on Jul 28, 2026
  2. Nyvo-io commented on Jul 29, 2026

    @Nyvo-io
    Contributor

    I would like to take this now that #1493 has landed through #1583.

    I plan to deliver the complete CodeMode vertical path as one cohesive PR:

    • project the per-run Direct / CodeMode override over the authoritative effective tool surface, including direct-only and nestable admission;
    • run each exec cell in a short-lived Node child under the existing OS sandbox ceiling plus Node permission restrictions, with a data-only parent broker;
    • route every nested call back through ToolRuntime, preserve parent-linked non-model-visible durable facts, and support same-cell load_tools activation;
    • implement bounded exec / wait lifecycle, cancellation and turn teardown, protocol/crash/resource-limit failures, and retained-cell limits;
    • add focused contract coverage and a controlled Direct-versus-CodeMode comparison while keeping Direct as the default rollback.

    I will re-check the issue and maintainer guidance before implementation and again before submission, then run the full review/test workflow before opening the PR. Please assign me if this scope is available.

  3. Astro-Han commented on Jul 29, 2026

    @Astro-Han
    ContributorAuthor

    Thanks for the detailed plan @Nyvo-io — the scope you laid out matches the issue as written, which is exactly why I'd like you to hold before opening a PR.

    Two things are under review and both may change this issue materially.

    Isolation. The current contract mandates one short-lived Node child process per exec with Node's permission model plus an OS sandbox ceiling. Neither shipped reference implementation takes that shape. openai/codex (codex-rs/code-mode, code-mode-host, code-mode-protocol) reuses a host process and isolates per cell in a fresh V8 isolate, with a deliberately bare runtime — no Node, no filesystem, no network, no console — so capabilities are injected rather than revoked. anomalyco/opencode on branch execute-code-mode-v2 goes further and removes the runtime entirely: packages/codemode is a hand-rolled tree-walking interpreter over acorn ASTs with no QuickJS/V8/sandbox-engine dependency, on the stated reasoning that the model needs orchestration syntax, not a full runtime. If we adopt either, the child process lifecycle, the Node permission clause, and the stdio broker protocol in this issue are dead or substantially different.

    Protocol shape. We want compatibility, not just parity. GPT coding models were trained against Codex's exec/wait wire shape, so our surface needs to be checked against it rather than designed independently — including the cell_id and yield-window semantics, and affordances we currently lack such as Codex's store/load for cross-cell state and its // @exec: pragma for model-declared yield and output budgets. In-cell discovery is also unsettled: Codex exposes deferred tools through an ALL_TOOLS array with names and descriptions but no schemas, while opencode's $codemode.search returns full JSDoc-annotated TypeScript signatures. That choice affects nested load_tools in this issue directly.

    What should survive either way: the effective tool surface projection, routing every nested call back through ToolRuntime, the durability and audit facts, direct-only admission, and Direct staying the default with a clean rollback.

    I'm collecting review input now and will post the outcome here with the issue text updated before assigning. If you'd rather help decide than wait, I'd welcome your view — the two variables that settle the isolation question are the actual threat model and the per-cell fixed cost.

  4. changed the title [-]feat(runtime): add brokered CodeMode exec and wait[/-] [+]feat(runtime): add confined CodeMode exec cells[/+] on Jul 29, 2026
  5. Astro-Han commented on Jul 29, 2026

    @Astro-Han
    ContributorAuthor

    Review is in and the issue text is rewritten. Summary of what changed and why, plus where the work splits — @Nyvo-io, the scope you proposed is still the right shape, but two of its five bullets are now different.

    Outcome

    Two independent reviews, run separately against this repo and against both reference implementations, converged: reject the one-Node-child-per-exec design (0.95 / 0.90 confidence) and prefer a hand-rolled restricted interpreter over an isolate (0.75 / 0.65). Their reasoning paths differed, which is the part that makes it persuasive — one argued from "deny-listing a full runtime is structurally fragile", the other from implementability and platform availability.

    Three findings carried the decision:

    1. Node documents the permission model as not a security boundary — "It does not provide security guarantees in the presence of malicious code." It further documents that a process under --permission can call process._debugProcess(pid) to force any Node process under the same OS user to open its V8 Inspector. For an Electron host that reopens precisely the blast radius the child process was meant to close. (It is no longer experimental as of v22.13.0/v23.5.0 — but that is a maturity change, not a scope change.)

    2. --allow-net was added in Node v25.0.0, while --allow-fs-read and --allow-child-process are v20.0.0. We pin engines: node >=22.19.0 and Electron 43.1.1. So the clause "no network authority" is not merely unsafe to rely on — on our supported floor the knob does not exist. Network denial can only ever come from the OS sandbox.

    3. With the OS sandbox as the only real boundary, "fails closed" makes availability platform-conditional. default-sandbox-manager.ts registers Seatbelt and Bubblewrap only, and Bubblewrap additionally requires a user-namespace probe. CodeMode would be permanently dark on Windows and dark in container CI without userns — which is where the GPT tool-protocol compatibility: ApplyPatch and Code Mode #1383 evaluation runs.

    I should correct my own framing above: I said the two deciding variables were the threat model and the per-cell fixed cost. The threat model was decisive; the per-cell fixed cost was not. Local measurement shows models tend to emit one exec per atomic call rather than batching, so process startup does not amortize — but even if it did, the decision rests on failure mode and availability, not on tens of milliseconds.

    I was also too soft on one point: I said the durability facts "should survive either way". The intent survives; the clauses did not. Nested events now need explicit origin / modelVisibility / parent-reference fields consumed by the projection seam, because settleToolCall already constructs RuntimeEvents with role: 'tool' — an output-layer convention is not enough. The restart contract was missing entirely and is now specified.

    What replaces it

    A capability-less cell inside the already-sandboxed session process, evaluating a restricted orchestration subset. Nothing to revoke: no require, process, globalThis escape, timers, eval/Function, or dynamic import. The only effectful operation is the host-injected tools.* bridge, and every call through it lands in the existing ToolRuntime. The authoritative boundary stays where it already is, and no second permission language is introduced.

    On interpreter versus node:vm: node:vm is documented as not a security mechanism, shares the host heap, cannot preempt async execution, and — decisively — its escape idiom is widely published and therefore present in model pretraining data. Under a prompt-injection threat model the attacker does not need to write an exploit, only to induce the model to emit one it has already seen. A bespoke interpreter has no ready-made gadget, and its failure mode is inverted: unsupported syntax returns a loud recoverable diagnostic, where a node:vm security failure is silent full-host compromise.

    Two more changes worth calling out:

    • load_tools is now direct-only. Both reference implementations declined the equivalent — Codex binds deferred tools unconditionally so activation is prompt-rendering only, opencode's $codemode.search is read-only. Neither lets the execution environment write activation state. Beyond that, tool-availability.ts states activation "takes effect in the next Runtime request projection", so same-cell activation has no meaning in this architecture. Discovery is not activation.
    • Naming. @maka/core/orchestration already defines EffectiveOrchestration as default | swarm | graph, and ToolRuntime consumes it. The new axis needs a different name; the issue proposes toolMode, matching Codex's tool_mode. This needs alignment with GPT tool-protocol compatibility: ApplyPatch and Code Mode #1383.

    Slicing

    @Nyvo-io — your instinct to deliver one cohesive vertical PR was right, and it survives the rewrite. Two PRs total:

    PR 1 — the CodeMode feature, default off. Interpreter and integration together: the toolMode axis, exec, nestable/direct-only admission, the bridge into ToolRuntime, durability fields and replay filtering, restart/suspend/abort contracts, the language subset, the escape suite, and bounds.

    We considered splitting the interpreter out and decided against it. A subset-limited interpreter is not a milestone anyone can stop at — a cell that can only do sequential await does nothing Direct cannot, and is exactly the workload Anthropic measured as costing ~8% more. Both halves would land behind the same default-off flag, so there is no incremental value to capture. What we do recommend is commit ordering inside the PR: get a walking skeleton end to end first, with the full integration contract in place but a minimal subset, then grow the subset. That surfaces any contract error after a few hundred lines instead of a few thousand.

    One thing that must not be split across PRs: "nested calls settle identically to direct calls and are invisible at replay". Nested settlement, durability fields, replay filtering, and recovery look like four things but are four faces of one decision, and a reviewer cannot check the invariant end to end if they arrive separately. PR 1 will be large; that is deliberate.

    The interpreter should still be its own package with no knowledge of maka — a module boundary, not a PR boundary.

    PR 2 — the evaluation gate, parallelizable. Paired A/B with interleaved scheduling, stratified task shapes (fan-out, sequential-dependent, long-horizon) reported per stratum, and a protocol-health panel as a blocking check. This lives in maka-eval, has a different reviewer concern, and decides the default flip — it should not be gated behind the feature PR.

    Where to help

    The scope is yours if you want it, with the caveat that PR 1 now needs a decision on the four open questions at the bottom of the issue — particularly concurrency admission for exec and whether mcp__* tools are nestable. Those are contract questions, best settled before implementation rather than during.

    If you would rather take a bounded piece first, two are well-defined and separable as work even though they land in the same PR: the escape suite (process, require, globalThis, timers, dynamic import, host object identity — each a named test) and the bounds tests, including preemption of a pure compute loop. PR 2 is also available and genuinely standalone.

    Say which you would like and I will assign.

  6. Nyvo-io commented on Jul 29, 2026

    @Nyvo-io
    Contributor

    I would like to take the complete PR 1 scope. I re-checked the rewritten issue against the current Runtime, recovery, MCP, availability, and evidence contracts. My decisions for the open questions are:

    1. Defer wait / cell_id from PR 1. An in-process cell can keep the top-level exec pending while the existing provider idle watchdog is paused for tool execution. I will also keep cross-cell store / load out of this slice. If the separate protocol gate later demonstrates a real model dependency, those can be added from evidence rather than assumed compatibility.
    2. Use a restricted AST interpreter, not node:vm. It will live in an independent package with no Maka Runtime dependency, accept only the orchestration subset needed by the feature, expose no ambient capabilities, supervise every promise/tool call, and return structured unsupported-syntax diagnostics.
    3. Make exec exclusive_step. The existing stepAdmissions boundary is the natural owner, so an exec call cannot share one provider step with direct tool calls. This preserves deterministic ordering, permission suspension, abort, and audit semantics.
    4. Allow active MCP tools to be nestable. The cell receives only the active snapshot captured at exec start. Every MCP call still re-enters ToolRuntime, retains the existing network_send permission classification and abort/timeout path, crosses a plain-data copy boundary, and gets an additional per-result byte bound. load_tools, Agent/Team tools, AskUserQuestion, and exec remain direct-only.
    5. Project nested live output as child activity under the parent exec. It will reuse the existing runtime redaction and 4 KB chunk limit plus the renderer 200-chunk / 16 KB bounds, with a cell-level aggregate output bound. Child activity remains visible to UI/audit but is excluded from provider replay by explicit origin / modelVisibility / parent-operation fields.

    For restart, I will extend the canonical RuntimeEvent recovery bundle and the existing RecoveryResolver path rather than introduce another recovery authority. Startup recovery will append a terminal interrupted outcome for the outer exec; nested operations retain their own direct-equivalent T1/T2 recovery classification and are never replayed to finish a dead cell.

    I will deliver the full default-off vertical feature as one cohesive PR, using a walking-skeleton-first internal commit order, then complete the escape, bounds, permission-suspend, abort, replay, and crash tests before submission. Please assign #1553 to me if these contract decisions match the intended scope.

  7. Astro-Han commented on Jul 29, 2026

    @Astro-Han
    ContributorAuthor

    Assigned!

  8. Astro-Han commented on Aug 9, 2026

    @Astro-Han
    ContributorAuthor

    Closing as delivered, with the evaluator implementation subsequently simplified.

    • feat(runtime): add restricted CodeMode execution #1648 shipped the complete default-off CodeMode vertical path: per-run toolMode, exec, nested ToolRuntime dispatch, permissions, durability, replay filtering, recovery, limits, and focused contract coverage.
    • feat(code-mode): replace Self with QuickJS #2549 replaced the hand-written interpreter with the QuickJS-backed @ai-sdk/code-mode executor, removed the superseded implementation, and completed the resource, lifecycle, and failure-boundary hardening.
    • Direct remains the default and explicit rollback.

    Model-specific rollout policy and a user-facing settings preference are separate follow-ups under #1383; they are not missing implementation from this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

enhancement

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions