Repository navigation
refactor(core): separate CLI launcher from JS interpreter (MYWO-8) - #14036
Conversation
Establishes the runtime boundary the Bun migration (MYWO-8 S1) needs before workers, hooks, sandbox helpers and the code-mode host spawn JavaScript children under a future compiled-app flavor: arbitrary-JS child processes resolve their interpreter through one accessor (package manifest first, process.execPath fallback) instead of reading process.execPath directly, Bun detection has a single seam, and the app-launcher contract is documented alongside the full call-site inventory in a bilingual design doc. Adds the same-fixture Node/Bun regression matrix (stdio framing, exit codes, SIGTERM, IPC channel, --expose-gc, --input-type=commonjs --eval).
|
Updated for head Thanks for the PR. The app-launcher vs JS-interpreter distinction is a real one, and the call-site inventory in the design doc is useful reference material regardless of what happens to the code. A few things I want on the record before the line-by-line review. Template ✓ — every required section present, bilingual, both design-doc versions linked and synchronized. Problem. This is honestly framed as preparatory work: the description says the two identities "happen to agree in every shipped layout, so nothing breaks yet". So there is no observable defect today and no before/after to show — the motivation is a future compiled-app flavor that does not exist anywhere in the repo. That is not a Direction — my main concern, and I am escalating it rather than blocking on it. The linked research issue #11607 is still open, labeled Title. The head commit is a well-formed Size. Core paths are touched ( Approach. Two scope questions worth sitting with before anyone reviews line by line:
To be fair to the second commit: it went the right way on scope. It removed the unbounded ancestor Risk. No match against the revert-history high-risk path patterns. But Stage 0 Tier 2 applies to core changes, and I cannot name every downstream consumer with confidence — the inventory misses sites two files away from a migrated one. That alone puts this past the 100%-confidence bar for auto-approval, so this goes to a maintainer rather than to an approve. Code review follows in the next comment. 🔍 中文说明已更新到 head 感谢贡献。app launcher 与 JS interpreter 的区分是真实存在的,设计文档里的调用点清单不论代码最终如何都值得留存。在逐行审查之前,有几点需要先记录下来。 模板 ✓ —— 必需章节齐全,双语,两个设计文档版本均已链接且内容同步。 问题。 本 PR 很坦诚地把自身定位为前置工作:描述中说明两种身份"在所有已发布布局中恰好一致,所以现在还没有东西损坏"。因此今天不存在可观测的缺陷,也没有 before/after 可展示——动机是一个仓库中尚不存在的未来编译产物形态。这不算是缺少复现的 方向 —— 这是我最主要的顾虑,我选择上报而非阻塞。 关联的调研 issue #11607 仍处于 open 状态,带有 标题。 head commit 是规范的 规模。 触及核心路径( 方案。 在逐行审查之前,有两个范围问题值得先想清楚:
对第二个 commit 应当公允地说:它在范围上走对了方向。它移除了我本来会作为阻塞项提出的无界祖先 风险。 与 revert 历史的高风险路径模式无匹配。但 Stage 0 Tier 2 适用于核心改动,而我无法有把握地列出每一个下游消费方——清单遗漏了距已迁移位置仅两个文件之遥的调用点。仅此一点就已超出自动批准所要求的 100% 确信标准,因此本 PR 转交维护者,而不是直接批准。 代码审查见下一条评论。🔍 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
|
Updated for head Resolved by
|
| Check | Conclusion |
|---|---|
arm64 |
⏳ running |
Native Linux CLI boundary |
⏳ running |
Native Windows settings and streams |
⏳ running |
x64 |
⏳ running |
Desktop Shell (ubuntu-22.04) |
🚫 cancelled |
Desktop Shell (windows-2022) |
🚫 cancelled |
Lint & Static (ubuntu-latest, Node 22.x) |
❌ failure |
Test (ubuntu-latest, Node 22.x) |
🚫 cancelled |
web-shell E2E Smoke (ubuntu-latest, Node 22.x) |
🚫 cancelled |
Classify PR |
✅ success |
Integration Tests (no-AK, No Sandbox) |
✅ success |
One row per check name (latest run); skipped checks omitted; failures sort first. / 每个检查名一行(取最新一次运行),省略 skipped,失败项排在最前。
Sandboxed verification would settle part of this: @qwen-code /verify — the central claim is behavioural ("the compiled flavor only changes resolution in one place", "never returns the application binary"), and neither static review nor a green suite substantiates it. Concretely, /verify would show that reverting the four call sites leaves the suite green (nothing pins them today), and would exercise interpreter resolution against a real standalone package layout rather than the synthetic temp dirs the unit tests construct — which is also where the bwrap/landlock relay gap would become observable. Note that a run now needs the rebase first, or the lint lane fails before reaching anything interesting. The author has write access, so this is a normal run rather than a sponsored one. There is no TUI surface here, so /tmux would add nothing.
中文说明
已更新到 head 6e9c2c5a。 我的第一轮针对的是 0320f96f;审查进行中有第二个 commit 落地("fix(core): anchor interpreter resolution to the trusted install root")。下面所有结论都已针对当前 head 重新核实,我原先两个阻塞项中的一个已被修复。以下内容描述的是 6e9c2c5a 的状态,而非本评论早先版本所针对的 commit。
已由 6e9c2c5a 解决。 无界的 manifest.json 向上查找已被移除,且修得很到位。我原先指出解析会向上走六层父目录并接受任何能解析为对象的 manifest.json,因此在 npm 安装下会触达用户项目根目录——而由此得出的值是运行 hook 监督进程、sandbox file worker 与 code-mode host 的二进制。重做后完全取消了向上遍历:packageRoot 现在恰好是 path.dirname(resolveBundleDir(importMetaUrl)),且只有当该根目录同时存在有效的 manifest.json 与 standalone 入口标记 lib/cli-entry.js 时才被信任。parseStandaloneManifest 拒绝非对象、数组,以及任何不恰为 'bun' 或 'node' 的 runtime;interpreter 若存在必须是字符串;isExecutableFile 要求已存在的普通文件,并在 POSIX 上要求可执行位。所有拒绝路径都回退到 process.execPath 且不抛异常。这比我建议的 name 判别字段更强——信任锚是结构性的,而不是某个游离 manifest 可能恰好携带的字段。回归测试覆盖了我提出的每一个场景,包括 ignores an unrelated ancestor manifest in an npm bundle layout 与 ignores an unrelated ancestor manifest for a deep SDK module layout,以及目录/不可执行/二进制缺失/未知 runtime/标记缺失/非对象清单等回退。两份设计文档语言版本在同一 commit 中同步到了校验后的契约。这同时消除了我关于"no standalone manifest exists"测试对不受控祖先链断言否定的意见——它现在只检查测试自己拥有的单个临时目录。
在当前 head 仍然成立的审查结论。 我先只读标题与"为什么需要",在打开 diff 前写下了自己的方案:一个很小的导出解析函数(先环境变量或 manifest,再回退 process.execPath)加四处一行改动,并把 manifest 形态留给编译产物打包阶段,因为只有那部分代码知道解释器在哪。四处调用点改动完全正确——最小化、无附带改动——解析器现在也有了良好防护。下面这条完整性缺口仍是我认为在把它当作 S2–S4 可依赖的边界之前应当解决的。
阻塞项:接缝在它自己迁移的两个子系统内部并不完整。 设计文档把清单描述为完整的("完整调用点清单"),模块也写下了不变量"绝不返回应用二进制"。但 core 生产代码中有三处运行任意 JS 的 spawn 位置在两者中都不存在,且我已确认它们在当前 head 的 PR 文件列表中均不出现。三处都运行任意 JS,因此都属于 interpreter 身份而非 launcher 身份:hooks/hook-command-cgroup.ts:166(executable: process.execPath 配 ['--input-type=commonjs','--eval', LAUNCHER, ...],与本 PR 已迁移的 hookRunner.ts:1257 是同子系统同模式)、sandbox/bwrap-execution.ts:41 与 sandbox/landlock-execution.ts:113(均为 realpathSync(process.execPath),随后作为 executable 运行 bwrap-relay / landlock-relay 这两个 JS 文件)。这不只是"还有活没干完",而是使不变量失效:在编译形态下,已迁移的 file-worker-client.ts 交给 executeSandbox 的是正确的内层解释器,而 bwrap/landlock 仍以 realpathSync(process.execPath)——即无法运行 relay.js 的应用二进制——启动外层 relay。sandbox 写入路径会在触达内层命令之前就在外层断掉,hook 的 cgroup 隔离同样如此。这正是本 PR 声称要防止的"所有 JS 子进程同时、静默失效",且发生在它声称已覆盖的子系统里。要么迁移这三处,要么把文档论断与不变量收缩到实际接入的四处,避免 S2–S4 继承一份读起来完整、实际不完整的清单。
复用:新的运行时检测器落在了已有检测器旁边。 detectRuntime(): Runtime 已存在于 packages/core/src/utils/runtimeFetchOptions.ts:91——同一个 utils/ 目录、同一个包,已从 core 入口导出并被 packages/cli/src/serve/env-snapshot.ts 使用;其 Runtime 为 'node' | 'bun' | 'unknown'。detectRuntime() === 'bun' 与 isBunRuntime() 完全等价,而 JsRuntime = 'node' | 'bun' 是同一联合类型的更窄副本。按"先复用再新增"的约定,应扩展或复用 detectRuntime(),而不是在它旁边再加一个检测器。与此相关且在当前 head 未变:"唯一的运行时检测点"并未落地:isBunRuntime() 只有一个生产调用方(getPty.ts),另有六处裸检测保持原样——cli/src/agent-view/pty-host.ts:263、cli/src/llm.tsx:176、cli/src/serve/daemon-update-restart.ts:34、cli/src/serve/env-snapshot.ts:161、cli/src/ui/opentui/renderer-selection.ts:107、sdk-typescript/src/utils/cliPath.ts:295。文档注释把"renderer selection"列为目标消费方,而 renderer-selection.ts 并未接入。今天的净效果是多了一种检测 Bun 的方式,而非收敛为一种;单调用方的包装函数正是项目简洁性原则所反对的形态。
非阻塞,但建议一并处理。 一、四处迁移没有任何测试固定:hookRunner.test.ts:1147 仍断言 expect(call[0]).toBe(process.execPath) 且继续通过,因为接缝在所有现有布局下都返回 process.execPath;把四处调用点全部还原,整个套件依然全绿,即这些迁移对 CI 不可见。二、232 行矩阵测试测的是平台而非本次改动:runtime-boundary.node-bun.test.ts 从未 import runtime-info.ts,它 spawn 通用 fixture 并断言通用子进程语义,删除新模块不影响其结果;Bun 腿在 PATH 无 bun 时跳过,而本仓库 runner 正是如此,因此在 CI 中它断言的是"Node 表现得像 Node"。设计文档"Bun 兼容事实"整张表因此未被 CI 固定,唯一证据是作者本机 Bun 1.4.0 实测——那是作者的测量,本次运行并未重做。三、SIGTERM 测试存在竞态且落在 CI 腿上:它 await child.on('exit') 之后才在收集到的 stdout lines 中查找 SIGTERM 标记,而 Node 的 'exit' 在进程终止时即触发,子进程 stdio 可能尚未排空,保证输出读完的事件是 'close';fixture 先写 {"got":"SIGTERM"} 再 process.exit(0),因此 expect(termLine).toBeDefined() 会间歇性失败。四、importMetaUrl 参数在首次调用后仍被忽略:if (cachedInterpreter) return cachedInterpreter; 在任何解析之前就短路返回,因此进程生命周期内由第一个调用方的 URL 决定结果——'memoizes the resolution for the process lifetime' 测试正是这样断言的(第二次传入无关 URL 并期望第一次的结果)。文档注释仍写着"传入调用方的 import.meta.url,使分块 bundle 布局能像同级资源一样解析"。取消向上遍历后这在任何布局下都已无害,但签名仍承诺了实现未提供的按调用方语义。五、isBunRuntime 的测试是同义反复(expect(isBunRuntime()).toBe(typeof process.versions['bun'] === 'string') 只是重述实现),并硬编码 .toBe(false),一旦该套件在 Bun 下运行就会失败。
已核实无误的部分。 明确说明我检查过且认为正确的内容:解释器布局映射在两个平台上都与真实打包一致——POSIX 为 <root>/bun/bin/bun 与 <root>/node/bin/node(create-standalone-package.js:1017、:991),Windows 为 <root>\bun\bun.exe 与 <root>\node\node.exe(create-standalone-package.js:1037,并由 install-qwen-standalone.bat:1206 独立校验)。信任锚的层级对 standalone 布局是正确的(<root>/lib/cli-entry.js 或 <root>/lib/chunks/* → 父目录即 <root>)。getPty.ts 中 'bun' in process.versions → isBunRuntime() 保持行为不变。四处迁移的 diff 不含顺手改动,设计文档也确实保持 AGENTS.md 要求的双语同步。
测试证据。 本次为无人值守 CI 运行,按技能规则我没有构建或执行任何源自本 PR 的代码——没有本地测试、构建或 tmux 运行。以下证据来自 PR 自身的 CI,经 API 针对被审查的 commit 6e9c2c5af975ddcfcc1481f0859dde400034eedf 读取。
该 head 上共有 16 个 check-run:4 成功、3 跳过、2 进行中、6 排队、1 失败。仍有 2 个 pull_request 工作流未完成,我没有轮询。真正会覆盖本次改动的 Test (ubuntu-latest, Node 22.x) 与 Integration Tests (no-AK, No Sandbox) 在我读取时仍在运行,因此目前没有可引用的单测结果。
这一处失败并非本 PR 代码的 lint 缺陷。 Lint & Static (ubuntu-latest, Node 22.x) 失败于 check-lint-gate-freshness.mjs 步骤,而非 ESLint 本身。作业日志(job 115226649087)显示:lint 门在本分支最后一次合并之后于 main 上发生了变化,具体是 eslint.legacy-filenames.mjs(commit 2eee9b71,#13331,2026-10-13);该 lane 只检出分支 head,因此其绿色只能证明分支通过"分支自己定义的"门,而上述文件使该门过期,需要把 main 合并或 rebase 进分支后重新推送以在当前门下重新验证。我是依据 check 身份与 diff 而非日志正文做出这一分类的:门所指的 eslint.legacy-filenames.mjs 不在本 PR 改动范围内,且它是今天才在 main 上移动的——因此这是分支落后于 main,任何在该 commit 之前切出的分支都会命中,补救方式是 rebase 而非改代码。但这确实意味着本 PR 的 lint 信号目前是"未经证明"而非"绿色":分支尚未在当前门下被验证过。无论审查结论如何,合并前都值得解决。
未验证项及原因:PR 描述中引用的本地结果(类型检查、134 + 95 个 hook/sandbox/code-mode/getPty 测试、Bun 1.4.0 矩阵)属于作者自述——我没有重跑,本次运行也不允许执行 PR 代码。这些数字也早于 6e9c2c5a,而该 commit 给 runtime-info.test.ts 增加了 108 行,因此它们描述的是前一个 commit。
沙箱验证可以解决其中一部分:@qwen-code /verify —— 本 PR 的核心论断是行为性的("编译形态只需在一处修改解析逻辑"、"绝不返回应用二进制"),静态审查与绿色套件都无法证实。具体而言,/verify 可以证明把四处调用点还原后套件依然全绿(今天没有任何测试固定它们),并在真实的 standalone 包布局下——而非单测构造的临时目录——执行解释器解析;那也正是 bwrap/landlock relay 缺口会变得可观测的地方。注意现在触发前需要先 rebase,否则 lint lane 会在到达任何有意义的内容之前就失败。作者具备 write 权限,因此这是常规运行而非受助运行。此处没有 TUI 界面,/tmux 不会带来额外信息。
— Qwen Code · qwen3.8-max-2026-09-02
Reviewed at 6e9c2c5af975ddcfcc1481f0859dde400034eedf · re-run with @qwen-code /triage
Arbitrary-JS child resolution no longer walks upward looking for a manifest: the only trusted location is the standalone package root — the parent of the caller's bundle directory, which must hold both a manifest.json and the standalone entry marker lib/cli-entry.js — so an unrelated ancestor manifest in npm, source or SDK layouts can never be read. Declarations are validated before use: runtime must be exactly 'bun' or 'node', and the interpreter must be an existing executable regular file; any invalid or missing declaration falls back to process.execPath without throwing (non-string interpreter, directory, non-executable file, unknown runtime, absent binary, missing marker). Adds the regression matrix for unrelated ancestor manifests (npm bundle and deep SDK layouts), object/number/directory interpreters, unknown runtime, missing and non-executable interpreters, and the trust anchor; syncs both design-doc language versions with the validated contract.
|
Fix pushed for both review findings on head F1 (blocker, unrelated ancestor manifest): resolution no longer walks upward at all. The only trusted location is now the standalone package root — the parent of the caller's bundle directory ( F2 (major, unvalidated declarations): every declaration is validated before use under one unified fallback contract — Re-verification evidence (macOS arm64, Node 24.19.0, Bun 1.4.0 as child runtime): |
|
Confidence: 3/5 — the resolver itself is now well-guarded and the four migrations are clean, but the direction behind it is unratified and the boundary the design doc describes is not the boundary this PR actually ships. Going back to what I proposed before reading the diff: I would have written a ~15-line resolver plus four one-line edits and let the compiled-app packaging stage own the manifest shape, since that is the only code that knows where the interpreter lives. This PR is 203 production lines, 483 test lines and 266 doc lines. It exceeds my proposal in rigour — after the second commit the resolution is anchored, validated and genuinely hard to misuse, which is more than my version would have been — and it does not exceed it in economy. I do not think that is automatically wrong; the call-site inventory is real reference value that would have taken the next person a day to reconstruct. But I would have landed the inventory as a doc and deferred the code until S4 gives it something to resolve. The thing that actually holds this back from an approve is not size. It is that the doc says "full call-site inventory" and the module says "never returns the application binary", and neither is true as shipped: On the direction question I am deliberately not the decider. #11607 is open, Two things I want to be fair about. The second commit moved the right way on scope: it deleted an unbounded ancestor What I would cut if this were mine: the 232-line Not approving, and not requesting changes either: the code does not regress anything today, so a block would be about scope and sequencing, which is the maintainer's call to make rather than mine. CI is also still incomplete on this head, and the one red lane is a lint-gate freshness failure that needs a rebase rather than a code fix, so there is no full green signal to weigh yet regardless. ⏸️ Deferring to @yiliang114 — the
Needs a human call on this one. 中文说明确信度:3/5 —— 解析器本身现在防护得当,四处迁移也很干净;但其背后的方向尚未被确认,且设计文档所描述的边界与本 PR 实际交付的边界并不一致。 回到我在读 diff 之前写下的方案:我会写一个约 15 行的解析函数加四处一行改动,并把 manifest 形态交给编译产物打包阶段去定义,因为只有那部分代码知道解释器在哪。本 PR 是 203 行生产代码、483 行测试、266 行文档。它在严谨度上超出我的方案——第二个 commit 之后,解析有了锚点、有了校验、确实很难被误用,这比我的版本做得更多——但在经济性上并没有。我不认为这自动就是错的:调用点清单是实打实的参考价值,下一个人重建它要花上一天。但我自己会把清单作为文档先落地,把代码推迟到 S4 真正给出可解析对象的时候。 真正让它无法被批准的并不是规模,而是:文档写着"完整调用点清单"、模块写着"绝不返回应用二进制",而两者在交付状态下都不成立—— 方向这个问题我刻意不替维护者决定。#11607 处于 open、 有两点我要公允地说。第二个 commit 在范围上走对了方向:它删掉了无界的祖先 如果这是我的 PR,我会砍掉的是那 232 行的 既不批准,也不请求修改:这些代码今天不会造成任何回退,所以阻塞只会是关于范围与顺序的,而那是维护者而非我该做的判断。同时该 head 上的 CI 仍未跑完,唯一红灯的 lane 是 lint 门新鲜度失败,需要 rebase 而非改代码,因此无论如何目前都没有完整的绿色信号可供权衡。 ⏸️ 转交 @yiliang114 —— 依据
这一项需要人来定。 — Qwen Code · qwen3.8-max-2026-09-02 Reviewed at |
Adds the three interpreter-identity call sites the re-review found missing from the call-site inventory (hook-command-cgroup launcher, bwrap-execution and landlock-execution allowlist staging), marks the unwired rows as owned by the S3 migration sweep, and notes platform applicability: the cgroup/bwrap/landlock rows are Linux-only mechanisms validated against the Linux targets of the platform matrix, while the mem0 and pem rows apply on every platform. Both design-doc language versions are updated; no product or test code changes.
|
Docs-only commit pushed to complete the migration-inventory handoff condition: new head Diff vs
What the three missing inventory rows add (both languages):
A note after the table states ownership and platform applicability: rows marked "not yet" are owned by the S3 migration sweep (this table is its checklist); the cgroup/bwrap/landlock rows are Linux-only mechanisms validated against the Linux targets of the platform matrix, while the mem0 and pem rows apply on every platform. No wiring scope was expanded — the three sites remain as-is in code, exactly matching |
doudouOUC
left a comment
There was a problem hiding this comment.
EN
Reviewed at head 3af0736a99 (a merge of main; no conflicts, PR content unchanged by the merge). The seam
itself is sound for every layout that exists today: the shim, the manifest runtime, and the resolved
<root>/bun/bin/bun / <root>/node/bin/node path all agree, the anchor is structural rather than field-level,
and no rejection path can escape to a system runtime of a different version.
One blocking item, and it is not the lint-gate freshness failure reported earlier. That freshness step now
passes after the merge, and the lane proceeds to Prettier, which fails on this PR's own four new files
(docs/design/bun-runtime-boundary.md, bun-runtime-boundary.zh-CN.md,
packages/core/src/utils/runtime-info.test.ts, packages/core/src/utils/runtime-boundary.node-bun.test.ts,
run 38431782127). Prettier and .prettierrc.json are identical between the PR's base and merged main, so
this is not version drift — please run the formatter and push.
Three contract points on the resolver, none of them affecting a shipped layout today, all of them things the
future stages will inherit:
- Every rejection falls back to
process.execPathsilently. In the compiled-app flavor — the only layout
where the deviation branch is reachable —process.execPathis the application binary, so a structurally
valid install whose interpreter file is missing or non-executable hands every worker the app binary with no
diagnostic. The design doc's invariant "never returns the application binary" is not something this code can
enforce; either narrow the invariant to today's layouts or fail loudly when a trusted standalone root is
positively identified but unusable. - The trust anchor is the module's on-disk location, while the manifest the packaging stage is asked to ship
is a launcher-side artifact — nothing consultsprocess.execPath/QWEN_CODE_CLIto find the install root.
For a single-file compiled binary the bundled modules do not live in a real directory, so the manifest may
never be read and resolution lands on the fallback above. Worth pinning down which layout "compiled" means
before the packaging stage depends on this. manifest.interpretercurrently has no producer (writeManifestin the standalone packaging script emits
no such field), so that branch is only exercised by the synthetic fixtures, andpath.resolvewould let an
absolute value point outside the trusted root. LikewiseJsInterpreterCommand.runtimeis set but read
nowhere — the three call sites take onlycommand.
Also still open from the previous round, all re-verified at this head: the SIGTERM assertion awaits'exit'
before reading collected stdout instead of'close'(intermittent on the CI leg); the 232-line matrix never
imports the module under review;hookRunner.test.ts:1147still pinsprocess.execPathso nothing in CI fixes
the four migrations;importMetaUrlis ignored after the first call while the doc comment still promises
per-caller resolution.
Not a verdict call from me on direction: whether this slice should land before the packaging stage exists, and
whether a partial boundary is acceptable as an increment, are sequencing decisions for the owner. Noting for
context that a sibling PR is stacked on this branch, so its baseline moves with any rebase here.
中文
已在 head3af0736a99(与main的合并;无冲突,PR 内容未因合并改变)完成审查。就现有所有布局而言,这条接缝是成立的:shim、manifest 中的runtime与解析出的<root>/bun/bin/bun/<root>/node/bin/node三者一致,信任锚是结构性的而非字段级,且任何拒绝路径都不会悄悄落到版本不同的系统运行时上。
一个阻塞项,且并非此前报告的 lint 门新鲜度失败。合并后该新鲜度步骤已通过,车道继续执行 Prettier 并因本 PR 自己新增的四个文件而失败(docs/design/bun-runtime-boundary.md、bun-runtime-boundary.zh-CN.md、packages/core/src/utils/runtime-info.test.ts、packages/core/src/utils/runtime-boundary.node-bun.test.ts,运行38431782127)。PR 基线与其后合并的main上 Prettier 与.prettierrc.json完全一致,因此不是版本漂移——请格式化后推送。
关于解析器有三点契约问题,今天都不影响任何已发布布局,但都会被后续阶段继承:- 所有拒绝路径都静默回退到
process.execPath。在编译产物形态下——唯一能触达偏离分支的布局——process.execPath就是应用二进制,因此一个结构上合法、但解释器文件缺失或不可执行的安装,会把应用二进制交给每一个 worker,且没有任何诊断。设计文档中"绝不返回应用二进制"这一不变量并非本代码所能保证;建议要么把该不变量收窄到今天的布局,要么在确认了可信 standalone 根却不可用时显式报错。 - 信任锚是模块的磁盘位置,而要求打包阶段交付的 manifest 是启动器侧的产物——没有任何地方通过
process.execPath/QWEN_CODE_CLI去定位安装根。对于单文件编译产物,被打包的模块并不位于真实目录中,因此该 manifest 可能永远不会被读取,解析随即落到上面的回退分支。建议在打包阶段依赖它之前先明确"编译形态"具体指哪种布局。 manifest.interpreter目前没有生产者(standalone 打包脚本的writeManifest不写该字段),因此该分支仅由合成 fixture 覆盖;而path.resolve会允许绝对路径指向可信根之外。同样,JsInterpreterCommand.runtime被赋值但无人读取——三处调用点只取command。
此外,上一轮提出且在此 head 复核仍然成立的问题:SIGTERM 断言等待的是'exit'而非'close'就去读已收集的 stdout(在 CI 腿上会间歇失败);232 行矩阵从未 import 被审查的模块;hookRunner.test.ts:1147仍固定process.execPath,因此 CI 中没有任何东西固定这四处迁移;importMetaUrl在首次调用后被忽略,而文档注释仍承诺按调用方解析。
方向问题我不做裁决:这一片是否应当在打包阶段存在之前落地、部分完成的边界能否作为一个增量,属于负责人的排序判断。另需说明,有兄弟 PR 叠在本分支之上,因此此处任何 rebase 都会带动其基线。
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Partially reviewed — gaps disclosed.
8 Suggestion-level finding(s) this review confirmed are already reported on this PR and are not repeated:
- manifest
interpreterresolved with path.resolve can point outside the trusted package root — already reported (review 5516323783, contract point 3) JsInterpreterCommand.runtimeis set but read by no production caller — already reported (review 5516323783, contract point 3)manifest.interpreterhas no producer; writeManifest emits no such field — already reported (review 5516323783, contract point 3; comment 6142467772)- nothing pins the four migrated call sites; hookRunner.test.ts:1147 still asserts process.execPath — already reported (comment 6142521223; review 5516323783)
- the 232-line cross-runtime matrix never imports runtime-info.ts and its Bun leg skips in CI — already reported (comments 6142521223 and 6142704338; review 5516323783)
importMetaUrlis ignored after the first call while the JSDoc promises per-caller resolution — already reported (comment 6142521223; review 5516323783)isBunRuntime()duplicates the existing exporteddetectRuntime()and the single-detection-point claim is false while raw detection sites remain — already reported (comment 6142521223; review 5516323783)- the
isBunRuntimeunit test is tautological and hardcodes false — already reported (comment 6142521223)
Not reviewed: build-and-test — Agent 7's test phase never ran (the build consumed its call budget and the efficacy probe's baseline vitest was stopped by scripts/vitest-global-setup.js's prerequisite guard before collection), and CI's Test (windows-latest, Node 22.x) and Test (macos-latest, Node 22.x) lanes were skipped at this commit; this review ran the two new suites on Linux only, so the Windows and macOS legs were never executed by any lane.
Not explored to full depth (tool budget reached): "agent 6b": none — no check was cut short by the tool ceiling. (I could not empirically probe Bun's --eval argv/ require semantics: command -v bun returns nothing on t….
Not reviewed: reverse audit — stopped before round 9 by the review time budget.
Test Plan (not a blocker): src/utils/runtime-info.test.ts — no such file or directory; src/utils/runtime-boundary.node-bun.test.ts — no such file or directory.
中文说明
仅完成部分审查,审查缺口已披露。
本轮确认的 8 条建议级发现已在 PR 上报告过,不再重复发布(列表见上方英文部分)。
未审查(原文为英文):build-and-test — Agent 7's test phase never ran (the build consumed its call budget and the efficacy probe's baseline vitest was stopped by scripts/vitest-global-setup.js's prerequisite guard before collection), and CI's Test (windows-latest, Node 22.x) and Test (macos-latest, Node 22.x) lanes were skipped at this commit; this review ran the two new suites on Linux only, so the Windows and macOS legs were never executed by any lane.
未探索到全部深度(达到工具调用预算):"agent 6b":none — no check was cut short by the tool ceiling. (I could not empirically probe Bun's --eval argv/ require semantics: command -v bun returns nothing on t…。
未审查:反向审计——评审时间预算不足,未能开始第 9 轮。
Test Plan(非阻断):src/utils/runtime-info.test.ts — no such file or directory; src/utils/runtime-boundary.node-bun.test.ts — no such file or directory。
— qwen3.8-max via Qwen Code /review (v0.25.1)
| JSON.stringify(options.manifest), | ||
| ); | ||
| if (options.withBun) { | ||
| const bunPath = path.join(root, 'bun', 'bin', 'bun'); |
There was a problem hiding this comment.
[Critical] R1-2: [fails-closed] [new-surface] This fixture only ever builds the POSIX interpreter layout, but interpreterPathForRuntime branches on process.platform === 'win32' and looks for bun/bun.exe / node/node.exe. On the Windows lane the resolver therefore finds nothing, falls back to process.execPath, and the two positive-resolution tests fail their toEqual on every run. Two further cases pass there for the wrong reason: falls back when the declared interpreter is not executable succeeds because bun.exe is missing rather than because the 0o644 chmod was rejected (isExecutableFile returns true for any regular file on win32 and never calls accessSync), and memoizes the resolution memoizes a failed resolution. ci.yml's test_windows lane collects this file — packages/core/vitest.config.ts has no platform-based exclude — and the workflow comments describe the nightly as the only thing keeping macOS and Windows visible at all, so this lands as a red non-Linux lane that says nothing about the code.
Witness:
win32-stub arm (real runtime-info.test.ts / runtime-info.ts / bundlePaths.ts,
only process.platform stubbed after import):
x resolves the bundled Bun interpreter from a trusted bun-flavor layout
-> expected { command: '/usr/bin/node', ...(1) } to deeply equal { ...(2) }
x resolves the bundled Node interpreter from a trusted node-flavor layout
-> expected { command: '/usr/bin/node', ...(1) } to deeply equal { ...(2) }
v falls back when the declared interpreter is not executable
v memoizes the resolution for the process lifetime
Tests 2 failed | 14 passed (16)
unmodified arm, same files, no stub: Tests 16 passed (16)
Declared limitation: this is a model of win32 — only process.platform is stubbed, path separators and chmod stay POSIX. No Windows runner was available. Four review agents converged on this independently.
| const bunPath = path.join(root, 'bun', 'bin', 'bun'); | |
| const bunPath = path.join( | |
| root, | |
| ...(process.platform === 'win32' | |
| ? ['bun', 'bun.exe'] | |
| : ['bun', 'bin', 'bun']), | |
| ); |
Derive the node path the same way, and use that derived path for both the written file and the expected command. Gate the permission-bit case with it.skipIf(process.platform === 'win32') — the convention already used 28 times across packages/core/src/utils/*.test.ts.
The implementation's win32 layout is the correct one and must not be changed to match the test: scripts/create-standalone-package.js emits %ROOT%\bun\bun.exe / %ROOT%\node\node.exe and packages target === 'win-x64' ? path.join('bun','bun.exe') : path.join('bun','bin','bun').
These two tests must be green on a Windows runner; reverting the helper to hardcoded POSIX paths reddens both there while staying green on Linux, which is exactly why the gap survives the PR gate.
中文说明
该 fixture 只会构造 POSIX 的解释器目录布局,但 interpreterPathForRuntime 会依据 process.platform === 'win32' 分支,去找 bun/bun.exe / node/node.exe。因此在 Windows 检查项上,解析器什么都找不到,会回退到 process.execPath,两个「正向解析」测试的 toEqual 每次都会失败。另有两条用例在 Windows 上「以错误的理由通过」:falls back when the declared interpreter is not executable 之所以通过,是因为 bun.exe 不存在,而不是因为 0o644 的 chmod 被拒绝(在 win32 上 isExecutableFile 对任何普通文件都返回 true,根本不会调用 accessSync);memoizes the resolution 则是在缓存一次失败的解析结果。ci.yml 的 test_windows 检查项会收集这个文件——packages/core/vitest.config.ts 没有任何基于平台的排除——而该 workflow 的注释说明 nightly 是让 macOS 与 Windows 保持可见的唯一手段,所以最终表现为一条非 Linux 检查项变红,却完全无法说明代码本身的问题。
已声明的局限:这是对 win32 的「模型」——只 stub 了 process.platform,路径分隔符和 chmod 仍是 POSIX 行为;环境中没有 Windows runner。四个审查 agent 各自独立得出了同一结论。
修复方式:node 路径也用同样方式推导,并把推导出的路径同时用于「写入的文件」和「期望的 command」。权限位相关用例请用 it.skipIf(process.platform === 'win32') 跳过——这一约定在 packages/core/src/utils/*.test.ts 中已被使用 28 次。
约束:实现侧的 win32 布局是正确的,不能为了让测试通过而改它:scripts/create-standalone-package.js 生成的是 %ROOT%\bun\bun.exe / %ROOT%\node\node.exe,并且按 target === 'win-x64' ? path.join('bun','bun.exe') : path.join('bun','bin','bun') 打包。
验收标准:这两个测试必须在 Windows runner 上通过;如果把 helper 改回硬编码的 POSIX 路径,它们在 Windows 上会再次变红,而在 Linux 上仍然是绿的——这正是该缺口能躲过 PR 门禁的原因。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
[Critical] R1-2: [fails-closed] [new-surface] The fixture helper only ever builds the POSIX interpreter layout (bun/bin/bun, node/bin/node), while interpreterPathForRuntime branches on process.platform === 'win32' to bun/bun.exe / node/node.exe, so both positive-resolution cases fail on the Windows lane.
Re-checked at head fed48b85 — still stands, and the two positive cases are still the only ones that fail. This round also measured the knock-on: on win32 the falls back when the declared interpreter is not executable case passes VACUOUSLY (the standard bun.exe path is simply absent) and memoizes the resolution memoizes a failed resolution.
Witness:
win32 MODEL (process.platform stubbed after import; the real unmodified runtime-info.ts driven against fixtures built exactly as writeStandaloneLayout builds them). Windows itself was not run.
ARM1 linux + fixture(POSIX) bun layout: got {command: <root>/bun/bin/bun, runtime: bun} isExecPathFallback: false -> matches the test expectation (PASS)
ARM2 win32 + fixture(POSIX) bun layout: got {command: /usr/bin/node, runtime: node} isExecPathFallback: true -> test expects <root>/bun/bin/bun -> FAIL
ARM3 win32 + fixture(POSIX) node layout: isExecPathFallback: true -> FAIL
ARM4 win32 + real win-x64 archive layout (bun/bun.exe): got {command: <root>/bun/bun.exe, runtime: bun} -> resolves (this is the flip: the platform branch, not fixture existence, is the discriminator)
Per-case: platform=win32 -> bun-flavor FAIL | explicit-interpreter PASS | directory PASS | not-executable PASS (exactly the two standard-location cases fail, at runtime-info.test.ts:105 and :116).
Also measured: ARM5 win32 + today's 0644 fixture -> falls back, so the :198 case passes VACUOUSLY; ARM9 win32 memoization -> first == second == execPath (vacuous).
Lane reach: test_windows (ci.yml:1768) is gated on merge_group || schedule || workflow_dispatch, never pull_request, and packages/core "test:ci" is a bare `vitest run` with no exclusions.
One existing fact the fix must not violate: The fixture must mirror the shipped archive layout, not invent a third one: scripts/create-standalone-package.js:934-936 — target === 'win-x64' ? path.join('bun', 'bun.exe') : path.join('bun', 'bin', 'bun'); :1036 — runtime === 'bun' ? '%ROOT%\\bun\\bun.exe' : '%ROOT%\\node\\node.exe'; :37 — ['win-x64', { outputExtension: 'zip', nodeExecutable: ['node.exe'] }]. Also packages/core/src/utils/runtime-info.ts isExecutableFile: if (process.platform === 'win32') return true; — no Windows fixture can pin the executable-bit rule.
Acceptance criterion: packages/core/src/utils/runtime-info.test.ts → 'resolves the bundled Bun interpreter from a trusted bun-flavor layout' and 'resolves the bundled Node interpreter from a trusted node-flavor layout' must pass on the test_windows leg; reverting the fixture to a fixed POSIX layout reds both there. Please remove the guard again afterwards and confirm that test reds.
中文说明
fixture 辅助函数只会构造 POSIX 的解释器布局(bun/bin/bun、node/bin/node),而 interpreterPathForRuntime 会依据 process.platform === 'win32' 分支去找 bun/bun.exe / node/node.exe,因此在 Windows 检查项上两条「正向解析」用例都会失败。
已在 head fed48b85 复核——问题依然存在,且失败的仍然只有这两条正向用例。本轮还实测了连带影响:在 win32 上,falls back when the declared interpreter is not executable 是空洞地通过(因为标准的 bun.exe 路径根本不存在),而 memoizes the resolution 缓存的是一次失败的解析。
说明:Windows 未被真实运行,这里是对 win32 的模型(导入后仅 stub process.platform);ARM4 是翻转证据——一旦 fixture 镜像真实归档布局(bun/bun.exe),同一平台值即可正确解析,因此判别因素是平台分支而非 fixture 是否存在。
修复方式:让 fixture 按平台的标准位置放置二进制(镜像 interpreterPathForRuntime),并在两条解析用例中期望同一组路径段;权限位用例请用 { skip: process.platform === 'win32' } 跳过,而不是让它以错误的理由通过。
约束:fixture 必须镜像已发布的归档布局,不能自创第三种——scripts/create-standalone-package.js:934-936、:1036、:37;实现侧的 win32 布局是正确的,不能为了让测试通过而改它。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Follow-up against remote head a1ca3f3df5420f3f00170b2fbca3b48391c70356 (14036-T02).
Candidate fixtures now use the platform-specific Bun/Node archive paths, including the explicit interpreter and directory cases; POSIX execute-bit checks explicitly skip Windows. Memoization now starts from a real positive resolution. macOS tests pass; real Windows validation remains missing.
The candidate is a separate local commit and is not part of this PR yet. Standard package-local Vitest returned rc 1 at the missing core/dist/index.js prerequisite; the focused 35-test runs use a disclosed diagnostic configuration. Full build/typecheck, real Linux/Windows and independent cross-review are not claimed. Keep unresolved pending the corresponding remote change and verification.
| const [exitCode, signal] = await new Promise< | ||
| [number | null, string | null] | ||
| >((resolve) => { | ||
| child.on('exit', (code, sig) => resolve([code, sig])); |
There was a problem hiding this comment.
[Critical] R1-3: [fails-closed] [new-surface] The always-run node leg of this SIGTERM test races the fixture's own handler registration. The fixture writes its identity line first and only then registers process.on('SIGTERM'), while the parent kills on the first stdout chunk — arming a libuv signal watcher on first listener is not free, so the signal can land before the handler exists and the default disposition kills the child. All three assertions then fail at once (termLine undefined, exitCode null, signal SIGTERM) with nothing indicating why, which reads at 3 AM as "the runtime broke SIGTERM handling" when only the parent's ordering did. This leg runs on every Linux and macOS core unit run, on runners vitest.config.ts itself describes as heavily oversubscribed, which widens the window.
Witness:
Driving the PR's own test file through vitest:
idle (60 runs of -t 'delivers SIGTERM') pass=60 fail=0
load (32 CPU busy-loops, same 60 runs) pass=52 fail=8 (13.3%)
all 8 failures: expected undefined to be defined (line 150)
Extracted harness, fixture pulled from the real file by regex, N=300:
VARIANT=orig event=exit failures=167 (55.7%)
cats={noTermLine:167, nonzeroExit:167, nonNullSignal:167}
VARIANT=reorder (fixture fixed, still await 'exit') failures=0 (0.0%)
VARIANT=closeonly (original fixture, await 'close') failures=113 (37.7%)
VARIANT=fixed (both) failures=0 (0.0%)
Independent reproduction against the shipped pin Bun 1.3.14:
node leg 4/6 failures (code null, sig SIGTERM, no got:SIGTERM line)
bun leg 6/6 pass
In fixtureSource, move the process.on('SIGTERM', ...) registration above the identity process.stdout.write, and exit from the write callback (process.stdout.write(line, () => process.exit(0))) rather than synchronously. Note that this reorder — not the 'exit' → 'close' change — is the load-bearing half: measured alone the reorder gives 0/300 while 'close' alone still fails 113/300, and a separate 300-run measurement with the reorder applied found no residual drain race on either event. Switching to 'close' remains defensible drain hygiene (the macOS async-pipe leg is unmeasured), but it should not be presented as the fix.
The same fixture is parsed as a single JSON object by the other legs (JSON.parse(result.stdout.trim())), so it must still emit exactly one stdout line when no signal is delivered, the handler must not write anything at registration time, and the exit:7 contract pinned by expect(result.status).toBe(7) must survive.
Restoring the original ordering and running this case in a loop fails roughly one run in four under load (measured 69/300 and 8/60); with the reorder it is 0/300 — so please remove the guard again and confirm the case reds.
中文说明
这条 SIGTERM 测试中「始终运行的 node 分支」与 fixture 自身的 handler 注册存在竞态。fixture 先写出身份行,之后才注册 process.on('SIGTERM');而父进程在收到第一个 stdout 分块时就立即 kill——首次添加监听器时装配 libuv 信号 watcher 并非零成本,因此信号可能在 handler 存在之前送达,由默认处置方式杀死子进程。于是三条断言同时失败(termLine 为 undefined、exitCode 为 null、signal 为 SIGTERM),且没有任何线索说明原因;凌晨三点看到时会被误读为「运行时破坏了 SIGTERM 处理」,而实际上只是父进程的时序问题。该分支在每次 Linux 与 macOS 的 core 单测中都会运行,而 runner 按 vitest.config.ts 自己的描述是严重超订的,这会进一步放大该窗口。
修复方式:在 fixtureSource 中,把 process.on('SIGTERM', ...) 的注册移到身份行 process.stdout.write 之前,并改为在写入回调中退出(process.stdout.write(line, () => process.exit(0))),而不是同步退出。请注意:真正起决定作用的是这个顺序调整,而不是 'exit' 改成 'close'——单独测量时,只做顺序调整为 0/300 失败,只改 'close' 仍有 113/300 失败;另一次在应用顺序调整后进行的 300 次测量显示,两种事件下都不存在残留的排空竞态。改用 'close' 作为排空方面的卫生习惯仍然合理(macOS 异步管道分支未测量),但不应把它当作修复本身。
约束:其它分支会把同一 fixture 当作单个 JSON 对象解析(JSON.parse(result.stdout.trim())),因此在没有信号送达时它必须仍然只输出一行 stdout,handler 在注册时不能写入任何内容,并且由 expect(result.status).toBe(7) 固定的 exit:7 约定必须继续成立。
验收标准:把注册顺序改回原样并在循环中运行该用例,在负载下大约每四次失败一次(实测 69/300 与 8/60);应用顺序调整后为 0/300。请再次移除该保护并确认用例变红。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
[Critical] R1-3: [fails-closed] [new-surface] The always-run node leg of this SIGTERM test races the fixture's own handler registration: the fixture writes its identity line first and only then registers process.on('SIGTERM'), while the parent kills on the first stdout chunk.
Re-checked at head fed48b85 — still stands, and this round measured it inside the project's own vitest harness rather than only in a warm loop: 93/100 failures as written, 0/100 with the handler registered first. As in the previous round, the load-bearing half is the ORDERING, not the exit→close change — awaiting close alone still failed 212/250 under load, and handler-first was 0/300 on either event. Honest bound: the rate is contention-driven (this box read /proc/loadavg 30.92/42.79/56.70 with 27-32 concurrent Runner.Worker processes) and the shipped single-shot form passed 20/20 here, so the CI-visible rate is unmeasured; packages/core/vitest.config.ts:12-15 records that the CI runners are "heavily oversubscribed", which is the condition the failing arms reproduce.
Witness:
The fixture writes its identity line at :34-41 and only registers process.on('SIGTERM') at :49, while the parent kills on the first stdout chunk.
Inside the project's own harness (vitest fork, isMainThread true): asWrittenFailed 93/100 | handlerFirstFailed 0/100.
Warm-loop arms: as-written + 'exit' no added load 244/250 (2/40 in a quieter window); +128 busy procs 183/250, 22/40, 64/100; as-written + 'close' under load 212/250, 25/40 (so awaiting 'close' ALONE does not fix it); handler-first + 'close' 0/250, 0/40, 0/100; handler-first + 'exit' 0/100 idle and 0/100 loaded.
Failure signature observed: termLine undefined, exitCode not 0, signal not null.
Honest attribution: the rate is contention-driven (/proc/loadavg 30.92/42.79/56.70, 27-32 concurrent Runner.Worker processes); the shipped single-shot form passed 20/20 here, and the CI-visible rate is unmeasured. packages/core/vitest.config.ts:12-15 records that the CI runners are "heavily oversubscribed", which is the condition the failing arms reproduce. The load-bearing half is the handler ordering, not the exit->close change.
Acceptance criterion: The same test, '%s: delivers SIGTERM to a handler and exits gracefully', remains the witness for the behaviour it already pins (handler runs, exit code 0, no signal) on both runtimes; the ordering change itself has no deterministic witness — N/A for the race. Please remove the guard again afterwards and confirm that test reds.
中文说明
这条 SIGTERM 测试中「始终运行的 node 分支」与 fixture 自身的 handler 注册存在竞态:fixture 先写出身份行,之后才注册 process.on('SIGTERM'),而父进程在收到第一个 stdout 分块时就立即 kill。
已在 head fed48b85 复核——问题依然存在。本轮不只是在热循环中测量,而是在项目自己的 vitest 框架内实测:按现有写法 100 次失败 93 次,把 handler 注册提前后 100 次失败 0 次。与上一轮结论一致:真正起决定作用的是顺序调整,而不是把 exit 改成 close——只改 close 在负载下仍有 250 次中 212 次失败,而只调整顺序在两种事件下都是 300 次中 0 次失败。
诚实的界限:失败率由机器竞争驱动(本机 /proc/loadavg 为 30.92/42.79/56.70,有 27-32 个并发 Runner.Worker 进程),而交付形态的单次运行在此处 20/20 通过,因此 CI 上的实际失败率未被测量;packages/core/vitest.config.ts:12-15 记录了 CI runner「严重超订」,正是失败分支所复现的条件。
修复方式:在 fixtureSource 中把 process.on('SIGTERM', ...) 的注册移到身份行 process.stdout.write 之前,并改为在写入回调中退出。
约束:其它分支会把同一 fixture 当作单个 JSON 对象解析,因此在没有信号送达时它必须仍然只输出一行 stdout,handler 在注册时不能写入任何内容,并且由 expect(result.status).toBe(7) 固定的 exit:7 约定必须继续成立。
验收标准:把注册顺序改回原样并在循环中运行该用例,在负载下会重新变红;应用顺序调整后为 0 次失败。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
First follow-up at remote head fed48b85c (14036-T03).
Disposition: keep this thread unresolved. Register SIGTERM handling before readiness, bound waits and clean up owned children on failure; preserve all original assertions and verify repeated combined runs.
Evidence boundary: Earlier isolated fixture work is not a fix on this remote head; combined stability remains unverified. No code change or new product test is claimed in this reply. Source changes are being coordinated with the existing consolidation work before updating this PR; an unsubmitted local candidate is not treated as a fix on this head. Resolution requires the corresponding remote change and verification.
There was a problem hiding this comment.
Follow-up against remote head a1ca3f3df5420f3f00170b2fbca3b48391c70356 (14036-T03).
Reproduced the original fixture on macOS arm64: Node 24.19.0 failed 8/10 SIGTERM trials (code null, SIGTERM, no handler line); Bun 1.3.14 passed 10/10. Candidate installs the handler before identity/ready, observes close before signalling, keeps all four original assertions, and adds finite waits/finally cleanup. Independent final fixture checks passed Node/Bun 40/40. The two-file diagnostic Vitest combination passed 35 tests in each of 10 runs; this does not claim the standard package or full PTY combination passed.
The candidate is a separate local commit and is not part of this PR yet. Standard package-local Vitest returned rc 1 at the missing core/dist/index.js prerequisite; the focused 35-test runs use a disclosed diagnostic configuration. Full build/typecheck, real Linux/Windows and independent cross-review are not claimed. Keep unresolved pending the corresponding remote change and verification.
| const type = (message as { type?: string }).type ?? ''; | ||
| types.push(type); | ||
| if (type === 'ready') child.send({ type: 'ping' }); | ||
| if (type === 'pong') child.kill(); |
There was a problem hiding this comment.
[Critical] R1-4: [fails-closed] [new-surface] This IPC test asserts a graceful exitCode === 0 after child.kill(), but on Windows kill() cannot deliver a catchable SIGTERM — the child is terminated directly, the fixture's handler never runs, and the reported code is null with signalCode SIGTERM. So expect(exitCode).toBe(0) fails on every run of the Windows lane for the node row, and for the bun row whenever a Bun binary is present: a permanent, non-diagnostic red on the lane ci.yml designates as the repository's only non-Linux signal. The IPC round-trip itself — the part the test exists to pin — passes. The neighbouring SIGTERM test already opts out with skip: process.platform === 'win32', so this is an inconsistency inside one file rather than a deliberate platform claim.
Witness:
witness: not run — no Windows runner in this review environment.
The platform authority is this repository's own passing win32 assertion,
not a recollection of libuv:
packages/cli/src/serve/cdp-tunnel/acceptance/acceptance-helpers.test.ts:92-97
// Windows has no catchable POSIX signals: kill('SIGTERM') terminates
// the child directly, so stopChild never escalates to SIGKILL there.
expect(child.signalCode).toBe(
process.platform === 'win32' ? 'SIGTERM' : 'SIGKILL',
);
this file: :156-158 options are { timeout: 30_000 } — no skip
:137 sibling is { skip: process.platform === 'win32', ... }
End the child cooperatively so the exit code is a real assertion on every platform — send { type: 'bye' } instead of child.kill() and have the fixture process.exit(0) on that message. If that is too much machinery for this phase, add skip: process.platform === 'win32' to this test's options, matching the sibling.
The in-file convention to follow is the neighbouring test's escape: { skip: process.platform === 'win32', timeout: 30_000 }.
This case must stay green on Windows while still asserting types equals ['ready','pong']; restoring the unconditional child.kill() plus expect(exitCode).toBe(0) reddens the win32 leg.
中文说明
这条 IPC 测试在 child.kill() 之后断言子进程优雅退出(exitCode === 0),但在 Windows 上 kill() 无法投递可捕获的 SIGTERM——子进程会被直接终止,fixture 的 handler 根本不会运行,返回的 code 是 null 且 signalCode 为 SIGTERM。因此在 Windows 检查项上,node 行每次运行都会让 expect(exitCode).toBe(0) 失败;只要存在 Bun 可执行文件,bun 行同样会失败。这会在 ci.yml 认定为「本仓库唯一非 Linux 信号」的检查项上留下一条永久的、无法说明问题的红色。测试真正要固定的 IPC 往返本身(expect(types).toEqual(['ready','pong']))是通过的。相邻的 SIGTERM 测试已经用 skip: process.platform === 'win32' 主动跳过,所以这属于同一文件内的不一致,而不是有意的平台声明。
关于「未运行」的说明:本审查环境没有 Windows runner。平台语义的依据取自本仓库自己已通过的 win32 断言(见上方 acceptance-helpers.test.ts:92-97),而不是对 libuv 的记忆。
修复方式:让子进程以协作方式结束,使退出码在所有平台上都是真实断言——发送 { type: 'bye' } 取代 child.kill(),并让 fixture 在收到该消息时 process.exit(0)。如果本阶段不想引入这些机制,就为本测试的 options 加上 skip: process.platform === 'win32',与相邻测试保持一致。
约束:应遵循的文件内约定就是相邻测试的跳过写法 { skip: process.platform === 'win32', timeout: 30_000 }。
验收标准:该用例在 Windows 上必须保持绿色,同时仍然断言 types 等于 ['ready','pong'];若恢复为无条件的 child.kill() 加 expect(exitCode).toBe(0),win32 分支会重新变红。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
[Critical] R1-4: [fails-closed] [new-surface] This IPC case asserts a graceful exitCode === 0 after a bare child.kill(), but on Windows kill() cannot deliver a catchable SIGTERM, so the assertion fails on every run of the Windows lane while the IPC round-trip it exists to pin keeps passing.
Re-checked at head fed48b85 — still stands; the case still carries no skip while its sibling SIGTERM case at :137 does. No Windows runner was available, so the handler dependency was measured on Linux with SIGKILL (a signal JS cannot catch) as the local model of Windows' uncatchable termination: the IPC round-trip still passed and only the exit-code assertion failed, which is exactly the non-diagnostic red this predicts.
Witness:
No Windows runner available; the handler dependency was measured on Linux using SIGKILL (a signal JS cannot catch) as the local model of Windows' uncatchable TerminateProcess. The exit-code VALUE Windows reports was not measured and the verdict does not need it.
The IPC case's own fixture and parent logic, driven verbatim:
killSignal SIGTERM (child.kill() default) -> types ["ready","pong"] exitCode 0 signal null -> assert exitCode==0 PASS
killSignal SIGKILL (uncatchable) -> types ["ready","pong"] exitCode null signal SIGKILL -> assert exitCode==0 FAIL
So the IPC round-trip the test exists to pin keeps passing and the case surfaces purely as an exit-code mismatch; exitCode===0 is reachable only through the fixture's process.on('SIGTERM') handler calling process.exit(0).
Triangulation from the repo's own conventions: this file :137 already carries { skip: process.platform === 'win32' } on the sibling SIGTERM case while :157-160 carries none; packages/cli/src/agent-view/pty-host.ts:412 `ptyProcess.kill(process.platform === 'win32' ? undefined : 'SIGTERM')`; pty-host.test.ts:499 `it.skipIf(process.platform === 'win32')`; acceptance-helpers.test.ts:92-97 asserts signalCode SIGTERM on win32.
Acceptance criterion: runtime-boundary.node-bun.test.ts → '%s: round-trips messages over the Node IPC channel': on a Windows runner the current form is red and must go green after the fix, while expect(types).toEqual(['ready', 'pong']) must keep passing on all platforms. Please remove the guard again afterwards and confirm that test reds.
中文说明
这条 IPC 用例在 child.kill() 之后断言子进程优雅退出(exitCode === 0),但在 Windows 上 kill() 无法投递可捕获的 SIGTERM,因此该断言在 Windows 检查项上每次运行都会失败,而它真正要固定的 IPC 往返本身却是通过的。
已在 head fed48b85 复核——问题依然存在;本用例仍没有 skip,而同文件中相邻的 SIGTERM 用例(:137)有。环境中没有 Windows runner,因此在 Linux 上用 SIGKILL(JS 无法捕获的信号)作为 Windows 不可捕获终止的本地模型来测量 handler 依赖:IPC 往返仍然通过,只有退出码断言失败——正是本条所预言的那种「无法说明问题」的红色。
修复方式:让子进程以协作方式结束(发送 { type: 'bye' },由 fixture 在收到该消息时 process.exit(0)),使退出码在所有平台上都是真实断言;如果本阶段不想引入这些机制,就为本用例的 options 加上 skip: process.platform === 'win32',与相邻用例保持一致。
约束:应遵循的文件内约定就是相邻用例的写法 { skip: process.platform === 'win32', timeout: 30_000 }。
验收标准:该用例在 Windows 上必须保持绿色,同时仍然断言 types 等于 ['ready','pong'];若恢复为无条件的 child.kill() 加 expect(exitCode).toBe(0),win32 分支会重新变红。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Follow-up against remote head a1ca3f3df5420f3f00170b2fbca3b48391c70356 (14036-T04).
Candidate preserves ready/ping/pong and exit 0 assertions but requests fixture shutdown via IPC instead of using an uncatchable Windows termination signal. Node/Bun real IPC trials pass on macOS. Windows remains unexecuted and is required before resolving this finding.
The candidate is a separate local commit and is not part of this PR yet. Standard package-local Vitest returned rc 1 at the missing core/dist/index.js prerequisite; the focused 35-test runs use a disclosed diagnostic configuration. Full build/typecheck, real Linux/Windows and independent cross-review are not claimed. Keep unresolved pending the corresponding remote change and verification.
| bundled Node, or the private bundled Bun). The resolution never | ||
| guesses at a different binary and never throws. | ||
| - Result memoized per process; `resetJsInterpreterCacheForTests()` clears it. | ||
| - Invariant: **never returns the application binary**. Under a compiled |
There was a problem hiding this comment.
[Critical] R1-5: [certifies-falsely] [new-surface] This Invariant is stated unconditionally, but the fallback this same change ships returns exactly process.execPath on every rejection path — which under a compiled flavor is the application binary — and contract item 3 four lines above documents that silent fallback as intended behaviour. The doc's own remedy ("the manifest must carry the interpreter path") has no producer: writeManifest emits only name, version, target, runtime, nodeArchive and createdAt, and nothing in this repo builds a compiled flavor at all. Replaying the failure story this PR tells about itself against the post-change code, no step changes: the compiled binary launches, resolveBundleDir yields a root with no manifest.json, parseStandaloneManifest returns undefined, and the resolver hands back the application binary, memoized for the process lifetime, with no compiled-flavor detection and no diagnostic. Every migrated site then spawns the app binary. The sandbox path breaks earlier still — bwrap-execution.ts:41 and landlock-execution.ts:113 stage realpathSync(process.execPath) as the outer relay interpreter while the migrated file-worker-client.ts supplies only the inner command inside the bubble, so the outer spawn fails before the correctly-resolved inner command is ever reached; hook-command-cgroup.ts:166 fails the same way. The present-tense cost, independent of any future flavor, is that a document handed to S2/S3/S4 as their contract asserts a property its own code contradicts, and the existing test falls back when the declared interpreter is not executable pins the silent fallback as correct.
Witness:
witness: not run — no `bun` binary on this runner (`which bun` exits 1),
so no compiled flavor could be built. The replay is a line-by-line trace
at head 3af0736a, each file read in the worktree:
runtime-info.ts:159 packageRoot = path.dirname(resolveBundleDir(...))
runtime-info.ts:174-5 cachedInterpreter = { command: process.execPath, ... }
<- returned for EVERY miss, memoized, never throws
bwrap-execution.ts:41 const node = realpathSync(process.execPath); (outer)
bwrap-execution.ts:97 --chdir cwd -- executable ...args (inner)
landlock-execution.ts:113 / :147 / :149 same shape
hook-command-cgroup.ts:166 executable: process.execPath
$ grep -n -- '--compile' scripts/*.js -> no hits
writeManifest -> { name, version, target, runtime, nodeArchive, createdAt }
Pick one and make the doc and the code agree. Minimum honest fix: scope the invariant in both language versions to what the code guarantees — e.g. "never returns a binary other than the declared interpreter or process.execPath; in today's npm, source and standalone layouts process.execPath is always a JS interpreter, so the invariant holds. Under a compiled flavor it holds only once S3 migrates the outer sandbox and hook-cgroup interpreter sites and S4 ships interpreter in the manifest" — and note on the bwrap / landlock / hook-command-cgroup rows that they are the outer interpreter for a path whose inner command this change already migrated, so the two must land together. Stronger alternative: keep the invariant and enforce it, failing loudly when a trusted standalone root is positively identified (valid manifest and entry marker) but the interpreter is unusable.
writeManifest emits no interpreter key, so no fix may assume the field is populated in any shipped archive; the fallback must keep matching the real shim layout bun/bin/bun / node/bin/node (POSIX) and bun\bun.exe / node\node.exe (Windows); and contract item 2.3's "never guesses at a different binary and never throws" means any diagnostic added under the stronger option must be non-throwing.
Under the stronger option, runtime-info.test.ts needs a case building a trusted layout whose interpreter is unusable and asserting the resolver throws rather than equalling execPathFallback(); the existing falls back when the declared interpreter is not executable case asserts the opposite today and must be inverted. Under the doc-only option there is nothing to pin.
中文说明
这条 Invariant 是无条件陈述的,但本次变更所引入的回退路径在每一种拒绝情形下都恰好返回 process.execPath——而在编译产物形态下,它就是应用二进制本身;并且上方四行的接口约定第 3 条,正是把这种「静默回退」写成了预期行为。文档给出的补救办法(「manifest 必须携带解释器路径」)目前没有任何生产者:writeManifest 只写出 name、version、target、runtime、nodeArchive、createdAt,而且本仓库根本没有构建任何编译产物形态。把本 PR 自述的故障场景对照变更后的代码逐步重放,没有任何一步发生变化:编译后的二进制启动,resolveBundleDir 得到的根目录下没有 manifest.json,parseStandaloneManifest 返回 undefined,解析器于是交回应用二进制,并在整个进程生命周期内缓存,既没有编译形态检测,也没有任何诊断信息。随后所有已迁移的调用点都会 spawn 应用二进制。沙箱路径甚至更早就断了——bwrap-execution.ts:41 与 landlock-execution.ts:113 仍以 realpathSync(process.execPath) 作为外层 relay 解释器,而已迁移的 file-worker-client.ts 只提供 bubble 内部的命令,因此外层 spawn 会先失败,根本轮不到那个被正确解析的内层命令;hook-command-cgroup.ts:166 同理。与未来形态无关的当下代价是:一份被交给 S2/S3/S4 当作契约的文档,断言了一条被其自身代码否定的性质,而现有测试 falls back when the declared interpreter is not executable 还把这种静默回退固定为正确行为。
关于「未运行」的说明:本机没有 bun 可执行文件,无法构建编译形态;上述重放是在 head 3af0736 上逐行追踪得到的,每个文件都在 worktree 中实际读过。
修复方式:二选一,并让文档与代码一致。最低限度的诚实修法是:在两个语言版本中,把该不变量限定到代码真正保证的范围——例如「除声明的解释器或 process.execPath 之外不会返回其它二进制;在今天的 npm、源码与 standalone 布局中 process.execPath 始终是 JS 解释器,因此不变量成立。在编译产物形态下,只有当 S3 迁移了沙箱与 hook-cgroup 的外层解释器调用点、且 S4 在 manifest 中提供 interpreter 之后,它才成立」——并在 bwrap / landlock / hook-command-cgroup 三行上注明:它们是某条路径的外层解释器,而该路径的内层命令已被本次变更迁移,因此两者必须一起落地。更强的替代方案是:保留该不变量并强制执行它——当确实识别出可信的 standalone 根(manifest 有效且入口标记存在)但解释器不可用时,显式失败而不是静默返回 process.execPath。
约束:writeManifest 不写 interpreter 字段,因此任何修复都不能假设已发布的归档中该字段有值;回退路径必须继续匹配真实的 shim 布局 bun/bin/bun / node/bin/node(POSIX)与 bun\bun.exe / node\node.exe(Windows);并且接口约定第 2.3 条的「绝不猜测另一个二进制、绝不抛异常」意味着,若采用更强的方案,新增的诊断信息必须是非抛出式的。
验收标准:采用更强方案时,runtime-info.test.ts 需要新增一条用例——构造一个解释器不可用的可信布局,并断言解析器抛异常,而不是等于 execPathFallback();现有的 falls back when the declared interpreter is not executable 用例今天断言的恰恰相反,必须反转。若只改文档,则没有可固定的行为。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Follow-up against remote head a1ca3f3df5420f3f00170b2fbca3b48391c70356 (14036-T05).
Candidate corrects both design documents: supported scope is interpreter-based distributions; rejection still falls back to process.execPath and can return an application binary in a compiled build. No compiled producer, usable-interpreter guarantee or compiled-artifact acceptance is claimed.
The candidate is a separate local commit and is not part of this PR yet. Standard package-local Vitest returned rc 1 at the missing core/dist/index.js prerequisite; the focused 35-test runs use a disclosed diagnostic configuration. Full build/typecheck, real Linux/Windows and independent cross-review are not claimed. Keep unresolved pending the corresponding remote change and verification.
| | `packages/cli/src/serve/pem-certificate-blocks.ts` | helper child spawn | not yet (S3 sweep) | | ||
| | `packages/cli/src/commands/review/test-efficacy.ts` | spawns vitest via `process.execPath` (dev-tooling path) | intentionally not; host-tool identity | | ||
|
|
||
| Rows marked `not yet` are owned by the **S3 migration sweep** (V8/GC/TLS/env |
There was a problem hiding this comment.
[Suggestion] R1-13 This inventory is presented as audited, is designated S3/S4's migration checklist twice, and contract item 1 says the same-interpreter fallback sites "are pinned by the inventory above" — but it covers well under half the production process.execPath sites, and it also omits a spawn site inside a file it does list. A checklist that reads as complete gets trusted as complete, which is precisely how an unmigrated site survives into the compiled flavor.
Two distinct gaps. (a) Omitted files: 38 production files read process.execPath; 15 appear in these tables and 23 appear in neither language version. Two of the omissions are arbitrary-JS --eval sites, the exact shape the migration rule names as its target: packages/cli/src/commands/sandbox.ts:228 passes executable: fs.realpathSync(process.execPath) with args: ['-e', program, inside, outside] through the same executeSandbox as the file-worker-client.ts row that is listed and was migrated; and packages/cli/src/serve/run-qwen-serve.ts:913 is execFile(process.execPath, ['--input-type=module', '--eval', WORKER_TLS_TRUST_PROBE, ...]), structurally identical to the hookRunner and hook-command-cgroup rows that are listed. Also missing: node-repl/src/desktop-relay/runtime.ts:53, cli/src/agent-view/current-cli-argv.ts:27/34, cli/src/serve/session-agents/orchestrator.ts:631 (whose own comment reads "Same entry precedent as currentCliWorkerLaunch" — a row that is listed), cli/src/serve/channel-worker-supervisor.ts:1119, channels/base/src/AcpBridge.ts:141 and acp-bridge/src/spawnChannel.ts:554. (b) Omitted site in a listed file: scripts/cli-entry.js:475-477, spawnSync(process.execPath, ['--expose-gc', cliPath, ...cliArgs]) — the branch taken on every win32 and every Bun launch, and the most-executed process.execPath spawn in the product — appears in neither table, because this file's two existing rows cover only QWEN_CODE_CLI stamping and relaunchAfterUpdate(). A file-keyed sweep marks the file inventoried and never asks whether the spawn site is listed.
The omissions are also inconsistent inside directories the tables do enumerate — packages/cli/src/serve/ has four files inventoried and four omitted — so this is not a package-level scoping decision, and the doc states no scope limit anywhere. Its own convention is to record intended exclusions in the Notes column (test-efficacy.ts reads "intentionally not; host-tool identity"), so a silent omission and a documented exclusion are indistinguishable to the next reader.
Witness:
Completeness sweep at head 3af0736a:
$ git grep -n "process.execPath" -- 'packages/**' (minus *.test.*, __tests__, *.spec.*)
38 production files
15 appear in the doc's tables
23 appear in NEITHER language version
Name-by-name cross-check of all 16 identifiers named above: EN=0 ZH=0 each.
All eight specifically named sites read back verbatim at the cited lines.
(b) confirmed independently: sed -n '468,482p' scripts/cli-entry.js shows the
spawnSync(process.execPath, ['--expose-gc', cliPath, ...cliArgs]) else-branch;
grepping both docs for `cli-entry` returns only the :35 and :40 rows.
Row counts verified equal today: EN 11 / 11 / 5, ZH 11 / 11 / 5.
Add the missing rows to the correct table with their identity classification — interpreter: commands/sandbox.ts, serve/run-qwen-serve.ts (verifyWorkerTlsTrust), node-repl/desktop-relay/runtime.ts (spawnNodeRepl); launcher: scripts/cli-entry.js's own child launch, current-cli-argv.ts, session-agents/orchestrator.ts, channel-worker-supervisor.ts, channels/base/AcpBridge.ts, acp-bridge/spawnChannel.ts — each marked not yet (S3) or not yet (S4) as appropriate. Where a site is deliberately out of scope, say so in the Notes column the way the test-efficacy.ts row does. Alternatively, state the inventory's scope limit explicitly.
docs/design/README.md and AGENTS.md require both versions to cover the full design, and the Chinese twin carries the same tables and is row-for-row identical today, so every row added here must be added to bun-runtime-boundary.zh-CN.md in the same change — including at its :72-73, which makes the identical "pinned" claim.
中文说明
这份清单被表述为「已审计」,两处被指定为 S3/S4 的迁移检查表,而接口约定第 1 条又说同解释器回退的调用点「已被上面的清单固定」——但它覆盖的生产代码 process.execPath 调用点远不到一半,并且还漏掉了一个位于已被列出文件内部的 spawn 调用点。一份看起来完整的检查表会被当作完整的来信任,而这正是一个未迁移调用点得以存活到编译产物形态的方式。
两类不同的缺口。(a) 漏掉的文件: 有 38 个生产文件读取 process.execPath,其中 15 个出现在这些表格里,23 个在两个语言版本中都没有出现。其中两处是任意 JS 的 --eval 调用点,正是迁移规则所指的目标形态:packages/cli/src/commands/sandbox.ts:228 通过同一个 executeSandbox 传入 executable: fs.realpathSync(process.execPath) 与 args: ['-e', program, inside, outside],而已被列出且已迁移的 file-worker-client.ts 行用的就是它;packages/cli/src/serve/run-qwen-serve.ts:913 是 execFile(process.execPath, ['--input-type=module', '--eval', WORKER_TLS_TRUST_PROBE, ...]),与已被列出的 hookRunner、hook-command-cgroup 两行在结构上完全一致。此外还缺:node-repl/src/desktop-relay/runtime.ts:53、cli/src/agent-view/current-cli-argv.ts:27/34、cli/src/serve/session-agents/orchestrator.ts:631(其自身注释写着「Same entry precedent as currentCliWorkerLaunch」,而后者已被列出)、cli/src/serve/channel-worker-supervisor.ts:1119、channels/base/src/AcpBridge.ts:141 与 acp-bridge/src/spawnChannel.ts:554。(b) 已列出文件中被漏掉的调用点: scripts/cli-entry.js:475-477 的 spawnSync(process.execPath, ['--expose-gc', cliPath, ...cliArgs])——这是在每个 win32 启动和每个 Bun 启动时都会走的分支,也是整个产品中执行次数最多的 process.execPath spawn——在两个表格中都没有出现,因为该文件现有的两行只覆盖 QWEN_CODE_CLI 的写入与 relaunchAfterUpdate()。以文件为粒度的扫描会把该文件标记为「已列入清单」,而不会去追问其中的 spawn 调用点是否被列出。
这些遗漏在表格确实枚举过的目录内部也是不一致的——packages/cli/src/serve/ 有四个文件被列入、四个被漏掉——所以这不是包级别的取舍决定,而且文档在任何地方都没有声明范围限制。文档自身的约定是在 Notes 列记录有意的排除(test-efficacy.ts 一行写着「intentionally not; host-tool identity」),因此对下一位读者而言,静默遗漏与有记录的排除是无法区分的。
修复方式:把缺失的行补进正确的表格,并标注其身份归类——解释器类:commands/sandbox.ts、serve/run-qwen-serve.ts(verifyWorkerTlsTrust)、node-repl/desktop-relay/runtime.ts(spawnNodeRepl);启动器类:scripts/cli-entry.js 自身的子进程启动、current-cli-argv.ts、session-agents/orchestrator.ts、channel-worker-supervisor.ts、channels/base/AcpBridge.ts、acp-bridge/spawnChannel.ts——每行按需标记 not yet (S3) 或 not yet (S4)。若某个调用点是有意排除在范围之外,请像 test-efficacy.ts 那一行那样在 Notes 列写明。或者,明确声明该清单的范围限制。
约束:docs/design/README.md 与 AGENTS.md 要求两个版本都覆盖完整设计,而中文孪生文档载有相同的表格、目前逐行完全一致,因此这里新增的每一行都必须在同一次变更中同步加入 bun-runtime-boundary.zh-CN.md——包括其 :72-73,那里做出了完全相同的「已被固定」表述。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
[Suggestion] R1-13: This inventory is presented as audited and is designated S2/S3's migration checklist, but it still omits live production process.execPath spawn sites — including ones that match rows the table already contains.
Re-checked at head fed48b85 — still stands, narrowed by the docs-only commit that added the three S3 rows (hook-command-cgroup.ts, bwrap-execution.ts, landlock-execution.ts), which this round confirms are now present. The remaining gap was re-swept at this head: 33 production files read process.execPath, 17 appear in the tables, 16 appear in neither language version. Honest bound on that count: sdk-typescript, vscode-ide-companion and mobile-mcp run in other processes where process.execPath is the host's binary — a defensible exclusion the document never states — so the in-scope core of this finding is the 11 files in packages/cli, node-repl, acp-bridge and browser-use. Two of those are arbitrary-JS -e/--eval sites, the exact shape the migration rule names: packages/cli/src/commands/sandbox.ts:228 (executable: fs.realpathSync(process.execPath) with args: ['-e', program, inside, outside], through the same executeSandbox as the migrated file-worker-client.ts row) and packages/cli/src/serve/run-qwen-serve.ts:913.
Witness:
Completeness sweep at head fed48b85 (oracle is grep over the real tree, set-differenced against the two doc files as text — not a reimplementation of the audit):
production (non-test, non-comment) files with a process.execPath site: 33
of those, named in the EN or zh-CN inventory tables: 17
ABSENT from the inventory: 16
The 7 absent files inside packages/cli/src — the application the document is about: commands/sandbox.ts:228, serve/channel-worker-supervisor.ts:1119, serve/local-process-runtime-activator.ts:315, serve/run-qwen-serve.ts:913, serve/session-agents/orchestrator.ts:631, ui/utils/updateCheck.ts:148, agent-view/current-cli-argv.ts:27,34; plus acp-bridge/src/spawnChannel.ts:554, browser-use/src/native-host-installer.ts:378, node-repl/src/kernel-manager.ts:567, node-repl/src/desktop-relay/runtime.ts:53, sdk-typescript/src/utils/cliPath.ts:313,340, three vscode-ide-companion files, mobile-mcp/src/server.ts:189.
Four hits spot-checked by reading before quoting the count, e.g. sandbox.ts:228-229 `executable: fs.realpathSync(process.execPath), args: ['-e', program, inside, outside]` — a `-e` snippet, so JS-interpreter identity under the doc's own migration rule (:131-133); orchestrator.ts:620-632 sits under a comment reading "Same entry precedent as `currentCliWorkerLaunch`", i.e. the same shape as a row the table DOES list.
… (trimmed; full witness in the run report)
One existing fact the fix must not violate: packages/cli/src/commands/sandbox.ts:229 — args: ['-e', program, inside, outside] — is what assigns that site to the JS-interpreter table under the doc's own migration rule; do not classify it as a launcher site.
中文说明
这份清单被表述为「已审计」,并被指定为 S2/S3 的迁移检查表,但它仍然遗漏了在用的生产代码 process.execPath spawn 调用点——其中包括与表格已列出行完全同形的调用点。
已在 head fed48b85 复核——问题依然存在,但范围因那次「仅文档」提交而收窄:新增的三行 S3 条目(hook-command-cgroup.ts、bwrap-execution.ts、landlock-execution.ts)本轮确认已存在。剩余缺口在此 head 上重新扫描:33 个生产文件读取 process.execPath,17 个出现在表格中,16 个在两个语言版本中都没有出现。
对该计数的诚实界定:sdk-typescript、vscode-ide-companion 与 mobile-mcp 运行在其它进程中,那里的 process.execPath 是宿主的二进制——这是一个站得住脚的排除,但文档从未声明;因此本条结论的实际范围是 packages/cli、node-repl、acp-bridge 与 browser-use 中的 11 个文件。其中两处是任意 JS 的 -e/--eval 调用点,正是迁移规则所指的目标形态:packages/cli/src/commands/sandbox.ts:228(executable: fs.realpathSync(process.execPath) 配 args: ['-e', program, inside, outside],走的是与已迁移的 file-worker-client.ts 行相同的 executeSandbox)与 packages/cli/src/serve/run-qwen-serve.ts:913。
修复方式:把缺失的行补进正确的表格并标注身份归类(解释器类 / 启动器类),每行按需标记 not yet (S3) 或 not yet (S4);若某个调用点是有意排除在范围之外,请像 test-efficacy.ts 那一行那样在 Notes 列写明,或者明确声明该清单的范围限制。
约束:docs/design/README.md 与 AGENTS.md 要求两个版本都覆盖完整设计,中文孪生文档载有相同的表格,因此这里新增的每一行都必须在同一次变更中同步加入 bun-runtime-boundary.zh-CN.md——包括其做出相同「已被固定」表述的位置。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Published follow-up at 8b4a0a25ea (14036-T10).
Still open. These commits do not complete the process.execPath inventory or reconcile the omitted CLI/node-repl/ACP/browser-use call sites. The existing inventory must not be treated as an exhaustive migration checklist; the saved source sweep is not a completed per-call-site audit.
Validation scope: an independent frozen-lock install and local core build enabled two standard package-config runs on macOS arm64 with Node 24.19.0 hosting Vitest 3.2.7 and Bun 1.3.14 child legs: each 35 passed, 0 failed, 0 skipped, actual rc0. globalSetup/test-setup were retained. Earlier missing-build rc1 is historical, not erased. Full-repository build/typecheck and real Linux/Windows remain unverified; the existing hosted-harness CI failures are not waived. Bun as the Vitest host failed despite rc0 and is not a supported pass. Keep this thread unresolved until its original conditions are met.
There was a problem hiding this comment.
Fixed in b85a12ad48. Both language versions now supplement the conceptual tables with a complete, explicitly scoped audit of executable literal process.execPath reads at fixed parent 8b4a0a25ea2bc570a1a6070e05182f29501a1b7f: 34 source files and 48 occurrences, including every line within files with multiple roles. No production call site was migrated by this documentation follow-up.
The added rows cover the missing CLI sandbox/TLS helpers, current CLI argv, session/channel/local-runtime workers, ACP entry points, node-repl, browser-use, SDK and extension-host consumers. The CLI entry script's own Bun/Windows child launch is explicit (scripts/cli-entry.js:476, with error text at 488), separate from launcher stamping/update discovery. Each row distinguishes launcher, arbitrary-JS interpreter, host Node/tooling or informational use, and identifies pending S3/S4 work or the reason to preserve the host. Mixed roles such as mem0, npm update, SDK defaults/explicit JS and desktop-relay are not collapsed into a blanket private-Bun substitution. Tests, helpers, acceptance/build drivers, comments and aliases have explicit scope notes; the three existing selector consumers remain listed despite no longer directly reading execPath. This is not a claim to have audited every implicit fork, alias or native spawn, or to support compiled applications.
Review evidence has different scopes: one independent reviewer recomputed actual property reads with TypeScript 5.8.3 ASTs from the fixed parent Git objects, obtaining exactly 34 files/48 occurrences with zero ledger differences and matching bilingual locations (actual exit 0). The other independently checked bilingual consistency, internal counts and boundaries, but explicitly did not independently establish external completeness against the whole parent tree. The latter review is not presented as a second AST completeness check.
The same candidate's two test files were independently run with the original core package configuration on Node 24.19.0/Vitest 3.2.7: real Bun 1.3.14 twice 35/35, exit 0; empty-version-only wrapper 34 passed/1 intended failure, exit 1; absent Bun 28 passed/1 skipped, exit 0, with six Bun cases not generated. Those results validate the test increment, not the documented pending migrations. T11 fd3/process-group/full-tree cleanup, cross-platform/native gates and new-head CI remain separate. No thread resolution or approval is implied.
| } | ||
| `; | ||
|
|
||
| const evalFixtureSource = `console.log(JSON.stringify({ eval: true, runtime: process.isBun ? 'bun' : 'node' }));`; |
There was a problem hiding this comment.
[Suggestion] R1-16 The leg titled "runs --input-type=commonjs --eval (hook supervisor contract)" proves only that the flags execute. It never touches the fd-3 status pipe or the process-group signalling that the supervisor this change migrates actually depends on, so the matrix cannot detect a Bun divergence in either — while the design doc hands this matrix to S3 as its checklist, and S3's hook-command-cgroup.ts migration is the same --eval shape.
The dependency is real: hookRunner.ts now spawns SURVIVING_HOOK_SUPERVISOR_SOURCE under the resolved interpreter with stdio: ['ignore','ignore','ignore','pipe'], and that supervisor reports through sendStatus → writeSync(statusFd, ...) with its own failures swallowed (statusFd = 3). The parent resolves supervisorStartedPromise only from the pid: branch of consumeSupervisorStatusLine or from statusStream.on('error', ...) — there is no end/close handler — and startTermination() awaits that promise before terminating the surviving hook group, with finishCancellation() chained after it. So a runtime whose --eval child cannot write a piped fd 3 leaves the promise permanently unsettled and cancelling a MessageDisplay / StopFailure / SessionDelete hook never completes. This file's only fourth-stdio leg uses ['pipe','pipe','pipe','ipc'] — an IPC channel, not a plain pipe — and its only cancellation leg signals the direct child, never a group, while the supervisor relies on process.kill(-hook.pid, signal).
Witness:
Mechanical sweep of the real 232-line matrix (file identical to HEAD):
writeSync 0 stdio[3] 0 statusFd 0 process.kill 0 detached 0
'ignore' 0 ipc 1 spawnSync 7 kill( 2
The named leg spawns via spawnSync(...) with no fourth stdio entry, and the
fixture above writes stdout, not fd 3.
The omitted fd-3 handshake, run on Node reproducing the supervisor's exact
spawn shape:
parent read fd3 line: "pid:1444702"
supervisorStarted raced: pid
pid: arrived (unblocks startTermination): true
group signallable process.kill(-pid,0) : true
Bun arm not measurable here (no `bun` on PATH) — but the claim is that the
matrix CANNOT detect a divergence in these mechanisms, which the sweep
settles by construction. The group-signalling half was separately measured
identical across Node, Bun 1.4.3 and the shipped pin Bun 1.3.14, leaving
fd 3 as the sole unprobed mechanism.
Add two legs to the same fixture: one spawning with stdio: ['ignore','ignore','ignore','pipe'] whose child does require('node:fs').writeSync(3, 'pid:' + process.pid + '\n'), asserting the parent reads it back; and one whose child spawns a detached grandchild, asserting process.kill(-pid, 0) sees the group and process.kill(-pid, 'SIGTERM') reaches it.
SURVIVING_HOOK_SUPERVISOR_SOURCE is a String.raw CommonJS eval body reaching node:fs / node:child_process through require and hardcoding const statusFd = 3, so a mirroring fixture must use require, not import, and must write fd 3 rather than stdout. The existing skip semantics (the spawnSync(bunBin, ['--version'], ...).status === 0 gate) must be preserved so the Bun leg still skips cleanly on CI runners with no bun on PATH.
The fd-3 leg must fail on a runtime whose --eval child cannot write fd 3; deleting the leg is the mutation, and today nothing in the suite touches fd 3 or a negative pid.
中文说明
标题为「runs --input-type=commonjs --eval (hook supervisor contract)」的这一分支,只证明了这些 flag 能被执行。它从未触及本次变更所迁移的 supervisor 真正依赖的 fd 3 状态管道,也从未触及进程组信号,因此该 matrix 无法检测到二者在 Bun 上的任何行为差异——而设计文档把这份 matrix 交给 S3 作为检查表,S3 要迁移的 hook-command-cgroup.ts 正是同样的 --eval 形态。
这种依赖是真实存在的:hookRunner.ts 现在会在解析出的解释器下 spawn SURVIVING_HOOK_SUPERVISOR_SOURCE,并使用 stdio: ['ignore','ignore','ignore','pipe'];该 supervisor 通过 sendStatus → writeSync(statusFd, ...) 上报,且其自身失败被吞掉(statusFd = 3)。父进程只会从 consumeSupervisorStatusLine 的 pid: 分支、或从 statusStream.on('error', ...) 来 resolve supervisorStartedPromise——没有 end/close 处理器——而 startTermination() 会先 await 该 promise,再去终止存活的 hook 进程组,finishCancellation() 又串在其后。因此,如果某个运行时的 --eval 子进程无法写入管道化的 fd 3,该 promise 就永远不会 settle,取消 MessageDisplay / StopFailure / SessionDelete 类 hook 的操作将永远无法完成。本文件唯一使用第四个 stdio 的分支用的是 ['pipe','pipe','pipe','ipc']——是 IPC 通道,不是普通管道;唯一的取消分支只对直接子进程发信号,从不针对进程组,而 supervisor 依赖的是 process.kill(-hook.pid, signal)。
关于「Bun 分支无法测量」的说明:本机 PATH 上没有 bun。但本条结论主张的是该 matrix 无法检测这两种机制上的差异,而这一点由上述扫描在构造层面即可确定。进程组信号这一半已另行在 Node、Bun 1.4.3 与已发布固定版本 Bun 1.3.14 上测得完全一致,因此 fd 3 是唯一未被探测的机制。
修复方式:在同一 fixture 中新增两个分支:一个以 stdio: ['ignore','ignore','ignore','pipe'] spawn,其子进程执行 require('node:fs').writeSync(3, 'pid:' + process.pid + '\n'),并断言父进程能读回该行;另一个让其子进程 spawn 一个 detached 的孙进程,断言 process.kill(-pid, 0) 能看到该进程组、且 process.kill(-pid, 'SIGTERM') 能送达。
约束:SURVIVING_HOOK_SUPERVISOR_SOURCE 是一段 String.raw 的 CommonJS eval 代码,通过 require 访问 node:fs / node:child_process,并硬编码 const statusFd = 3,因此对应的 fixture 必须使用 require 而非 import,且必须写 fd 3 而不是 stdout。现有的跳过语义(spawnSync(bunBin, ['--version'], ...).status === 0 门限)必须保留,以便在 PATH 上没有 bun 的 CI runner 上,Bun 分支仍能干净地跳过。
验收标准:在某个 --eval 子进程无法写 fd 3 的运行时上,该 fd 3 分支必须失败;其变异方式就是删除该分支,而目前整个套件中没有任何代码触及 fd 3 或负数 pid。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
[Suggestion] R1-16: The leg titled "runs --input-type=commonjs --eval (hook supervisor contract)" proves only that the flags execute. It never touches the fd-3 status pipe or the process-group signalling that the supervisor this change migrates actually depends on.
Re-checked at head fed48b85 — the fd-3 / group-signalling half still stands, with the sweep unchanged (writeSync 0, statusFd 0, detached 0, process.kill 0, 'ignore' 0, ipc 1). SCOPE CORRECTION from this round's verification, in the author's favour: a separately-filed process.argv.slice(1) variant of this claim was REFUTED by measurement — Bun 1.3.14 (the shipped pin) and Bun 1.4.3 both slice argv identically to Node v22 for the supervisor's exact --input-type=commonjs --eval SRC shape, inserting no [eval] slot — and the argv contract IS already pinned end-to-end by hook-runner.process.test.ts, which has no vi.mock of child_process and really spawns the supervisor through this diff's own resolver. Please treat only the fd-3 and process-group half as open.
Witness:
Mechanical sweep of the real 232-line matrix at head fed48b85 (counts identical to round 1's, the file being byte-identical):
writeSync 0 | statusFd 0 | detached 0 | process.kill 0 | 'ignore' 0 | ipc 1 | spawnSync 7 | kill( 2
So no leg touches the fd-3 status pipe or negative-pid group signalling. The dependency is real: hookRunner.ts spawns SURVIVING_HOOK_SUPERVISOR_SOURCE with stdio ['ignore','ignore','ignore','pipe'] and the supervisor reports via writeSync(statusFd=3); the parent resolves supervisorStartedPromise ONLY from the `pid:` branch or statusStream.on('error') — there is no end/close handler — and startTermination() awaits it before signalling the group with process.kill(-hook.pid, signal).
SCOPE CORRECTION from this round's verification: the separately-filed `process.argv.slice(1)` variant of this claim was REFUTED by measurement — Bun 1.3.14 (the shipped pin) and Bun 1.4.3 both slice argv identically to Node v22.23.2 for the supervisor's exact `--input-type=commonjs --eval SRC` shape (no `[eval]` slot inserted), and the argv contract IS pinned end-to-end by hook-runner.process.test.ts, which has no vi.mock of child_process and really spawns the supervisor through this diff's getJsInterpreterCommand(...) ("isolates the supervisor from hook NODE_OPTIONS" passed, asserting the 6th argv slot round-trips). Only the fd-3 / group-signalling half of this entry stands.
One existing fact the fix must not violate: The supervisor destructures exactly six fields from process.argv.slice(1) and the spawn passes exactly six args after --eval (packages/core/src/hooks/hookRunner.ts:1257-1268, source at :65) — the assertion must compare process.argv.slice(1), not process.argv, or it will not fail for the shift it exists to catch.
Acceptance criterion: The amended leg in packages/core/src/utils/runtime-boundary.node-bun.test.ts — mutation: delete the toEqual(['A','B']) expectation and nothing in the repo pins the supervisor's argv contract, so a runtime whose -e layout differs passes the suite unchanged. Note the Bun leg only runs when bunAvailable, so the node assertion is what CI enforces today. Please remove the guard again afterwards and confirm that test reds.
中文说明
标题为「runs --input-type=commonjs --eval (hook supervisor contract)」的这一分支,只证明了这些 flag 能被执行。它从未触及本次变更所迁移的 supervisor 真正依赖的 fd 3 状态管道,也从未触及进程组信号。
已在 head fed48b85 复核——fd 3 与进程组信号这一半仍然成立,扫描结果与上一轮一致(writeSync 0、statusFd 0、detached 0、process.kill 0、'ignore' 0、ipc 1)。
本轮核实得出的范围更正(对作者有利):另有一条关于 process.argv.slice(1) 的同位置主张已被实测推翻——Bun 1.3.14(已发布固定版本)与 Bun 1.4.3 在 supervisor 完全相同的 --input-type=commonjs --eval SRC 形态下,argv 切分结果与 Node v22 一致,都不会插入 [eval] 槽位;而且该 argv 约定已由 hook-runner.process.test.ts 端到端固定——该文件没有对 child_process 做 vi.mock,确实通过本 diff 自己的解析器 spawn 了 supervisor。因此请只把 fd 3 与进程组这一半视为待处理。
修复方式:在同一 fixture 中新增两个分支:一个以 stdio: ['ignore','ignore','ignore','pipe'] spawn,其子进程执行 require('node:fs').writeSync(3, 'pid:' + process.pid + '\n'),并断言父进程能读回该行;另一个让其子进程 spawn 一个 detached 的孙进程,断言 process.kill(-pid, 0) 能看到该进程组、且 process.kill(-pid, 'SIGTERM') 能送达。
约束:SURVIVING_HOOK_SUPERVISOR_SOURCE 是一段 String.raw 的 CommonJS eval 代码,通过 require 访问 node:fs / node:child_process,并硬编码 const statusFd = 3,因此对应的 fixture 必须使用 require 而非 import,且必须写 fd 3 而不是 stdout;现有的跳过语义必须保留。
验收标准:在某个 --eval 子进程无法写 fd 3 的运行时上,该 fd 3 分支必须失败;其变异方式就是删除该分支,而目前整个套件中没有任何代码触及 fd 3 或负数 pid。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Published follow-up at 8b4a0a25ea (14036-T11).
Still open. The documentation now explicitly says this fixture does not probe fd-3 status pipes or process-group signalling. That disclosure does not supply the missing real supervisor/process-group regression. The rejected argv-related finding is not reinstated.
Validation scope: an independent frozen-lock install and local core build enabled two standard package-config runs on macOS arm64 with Node 24.19.0 hosting Vitest 3.2.7 and Bun 1.3.14 child legs: each 35 passed, 0 failed, 0 skipped, actual rc0. globalSetup/test-setup were retained. Earlier missing-build rc1 is historical, not erased. Full-repository build/typecheck and real Linux/Windows remain unverified; the existing hosted-harness CI failures are not waived. Bun as the Vitest host failed despite rc0 and is not a supported pass. Keep this thread unresolved until its original conditions are met.
| 2. Within that trusted root every declaration is validated before use: | ||
| `runtime` must be exactly `'bun'` or `'node'`, and the interpreter — | ||
| the `interpreter` field resolved against the package root, else the | ||
| standard `bun/bin/bun` / `node/bin/node` location — must be an existing |
There was a problem hiding this comment.
[Suggestion] R1-17 This sentence promises executability validation, but isExecutableFile short-circuits with if (process.platform === 'win32') return true;, so on the win-x64 target — one of the five archives the packager builds — any existing regular file satisfies "executable regular file". The same contract tells S4 to start writing the interpreter field, so a Windows install whose manifest carries a mistyped interpreter that still names an existing regular file (./manifest.json, ./README.md, ./lib/cli-entry.js, a .dll) passes validation, and every migrated JS child — hook supervisor, sandbox file worker, code-mode host — is spawned against a non-executable image and dies with a raw spawn UNKNOWN/EINVAL instead of taking the documented safe fallback. The pinning test cannot catch it either: runtime-info.test.ts:198 writes the fixture binary to <root>/bun/bin/bun while the win32 branch looks for <root>/bun/bun.exe, so on Windows it passes for the missing-file reason and never exercises the 0o644 chmod. Note the forward-facing trap: making that fixture platform-aware (the fix for the Windows-lane Critical) turns that test red on Windows unless this branch is addressed in the same change.
Witness:
Two-arm probe over the PR's own unmodified runtime-info.ts, five layouts
(win32 arm = process.platform stub; a MODEL of win32, path.sep stays '/'):
L0 control bun/bin/bun 0o755 posix: resolves win32: FALLBACK
L1 fixture bun/bin/bun 0o644 posix: FALLBACK win32: FALLBACK
L2 win32 bun/bun.exe 0o644 posix: FALLBACK win32: RESOLVES 644
L3 interp './README.md' 0o644 posix: FALLBACK win32: RESOLVES 644
L4 interp './lib' (dir) posix: FALLBACK win32: FALLBACK
L3 is this finding's scenario verbatim. L4 shows the doc's "directories ...
reject" half IS accurate on win32 (isFile() precedes the short-circuit) —
only "non-executable files reject" is POSIX-only.
Qualify the claim per platform in both language versions — e.g. "must be an existing regular file; on POSIX it must also carry the executable bit (Windows has no execute bit, so only existence and regular-file shape are checked there)" — mirrored at bun-runtime-boundary.zh-CN.md:80. One correction to the alternative a reviewer might reach for: aligning isExecutableFile with the house pattern at program-probe.ts:50 would change nothing, because that line is if (process.platform !== 'win32') accessSync(file, constants.X_OK); — the same win32 skip, not a tightening. Only the doc qualification, or a genuine extension/shape check, is viable.
The short-circuit itself is deliberate and house-consistent — runtime-info.ts's own JSDoc says "a missing executable bit on POSIX", and the packager's validateBunRuntime/validateNodeRuntime guard their exec-bit check with if (target !== 'win-x64') — so the defect is the doc dropping the platform qualification its own code carries, not the code. Any real win32 check must still accept the resolver's { bun: ['bun','bun.exe'], node: ['node','node.exe'] } segments, which match create-standalone-package.js's windowsRuntime.
Under the doc-only fix there is nothing new to pin. If a real win32 check is added instead, runtime-info.test.ts:198 made platform-aware (writing bun/bun.exe on win32) is the test that must go red when the check is removed.
中文说明
这句话承诺了可执行性校验,但 isExecutableFile 会以 if (process.platform === 'win32') return true; 提前返回,因此在 win-x64 目标(打包脚本构建的五个归档之一)上,任何存在的普通文件都满足「可执行的普通文件」这一要求。同一份契约又要求 S4 开始写入 interpreter 字段,所以一个 Windows 安装如果其 manifest 里的 interpreter 写错了、但仍指向某个存在的普通文件(./manifest.json、./README.md、./lib/cli-entry.js、某个 .dll),就会通过校验;随后所有已迁移的 JS 子进程——hook supervisor、沙箱 file worker、code-mode host——都会以这个不可执行的映像被 spawn,并以原始的 spawn UNKNOWN/EINVAL 直接失败,而不是走文档所规定的安全回退。用于固定该行为的测试同样抓不到:runtime-info.test.ts:198 把 fixture 二进制写在 <root>/bun/bin/bun,而 win32 分支找的是 <root>/bun/bun.exe,所以在 Windows 上它是因文件缺失而通过,从未真正执行到 0o644 的 chmod。请注意这个面向未来的陷阱:如果把该 fixture 改成平台感知(也就是修复 Windows 检查项那条 Critical 的做法),除非在同一次变更中处理这个分支,否则该测试会在 Windows 上变红。
关于「win32 分支为模型」的说明:探测中的 win32 一侧是 stub 了 process.platform 的模型,path.sep 仍为 /;环境中没有真实 Windows runner。
修复方式:在两个语言版本中都按平台限定该表述——例如「必须是存在的普通文件;在 POSIX 上还必须带可执行位(Windows 没有执行位,因此那里只检查存在性与普通文件形态)」——并在 bun-runtime-boundary.zh-CN.md:80 同步。对一种看似可行实则无效的替代做法做一点更正:把 isExecutableFile 与 program-probe.ts:50 的既有写法对齐不会带来任何改变,因为那一行是 if (process.platform !== 'win32') accessSync(file, constants.X_OK);——同样是 win32 跳过,而不是收紧。只有文档限定,或真正的扩展名/形态校验,才是有效做法。
约束:该提前返回本身是有意为之且与仓库既有写法一致——runtime-info.ts 自己的 JSDoc 写的是「在 POSIX 上缺失可执行位」,打包脚本的 validateBunRuntime/validateNodeRuntime 也用 if (target !== 'win-x64') 保护其执行位检查——因此缺陷在于文档丢掉了其自身代码所带的平台限定,而不在代码。任何真正的 win32 校验仍必须接受解析器的 { bun: ['bun','bun.exe'], node: ['node','node.exe'] } 路径段,它们与 create-standalone-package.js 的 windowsRuntime 一致。
验收标准:若只改文档,则没有新的行为可固定。若改为加入真正的 win32 校验,则把 runtime-info.test.ts:198 改成平台感知(在 win32 上写 bun/bun.exe)后,移除该校验时这条测试必须变红。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
[Suggestion] R1-17: This sentence promises executability validation, but isExecutableFile short-circuits with if (process.platform === 'win32') return true;, so on the win-x64 target any existing regular file satisfies "executable regular file" — the guarantee both new design docs state unconditionally holds only on POSIX.
Re-checked at head fed48b85 — still stands. The short-circuit itself is deliberate and house-consistent (this module's own JSDoc says "a missing executable bit on POSIX", and the packager guards its exec-bit check with if (target !== 'win-x64')), so the defect remains the docs dropping the platform qualification their own code carries, at EN :117-119 / :121-123 and zh-CN :80. This round also measured the interaction with the Windows-fixture blocker above: once that fixture is made platform-aware, a 0644 bun.exe RESOLVES on win32 rather than falling back, so the permission-bit case must be gated in the same change.
Witness:
not run — the branch is win32-only so it cannot execute on this Linux host, and no scratch tree was available (scratch-tree returned available:false because the repo-local git config carries an unreadable includeIf chain). The verdict rests on the quoted branch and the quoted doc lines, both read at head fed48b85:
runtime-info.ts:105-114 if (!fs.statSync(candidate).isFile()) return false;
if (process.platform === 'win32') return true; <- returns before any executability check
fs.accessSync(candidate, fs.constants.X_OK);
docs EN :117-119 "must be an existing executable regular file (directories and non-executable files reject)"; :121-123 lists "non-executable file" among the declarations that fall back; zh-CN :80 "非可执行文件均拒绝" — both unconditional.
Corroborating measurement from a sibling verifier on the same branch: a win32-model arm with a real win-x64 archive fixture at mode 0644 RESOLVES bun.exe rather than falling back, while the same 0644 file correctly rejects on Linux.
Acceptance criterion: Add a case to runtime-info.test.ts that declares interpreter: './manifest.json' (an existing, non-executable regular file the fixture already writes) and asserts execPathFallback(). It is red on Windows without the extension check and stays green on POSIX, where X_OK already rejects it — a cross-platform witness for a Windows-only branch. Please remove the guard again afterwards and confirm that test reds.
中文说明
这句话承诺了可执行性校验,但 isExecutableFile 会以 if (process.platform === 'win32') return true; 提前返回,因此在 win-x64 目标上,任何存在的普通文件都满足「可执行的普通文件」这一要求——两份新设计文档无条件陈述的这一保证只在 POSIX 上成立。
已在 head fed48b85 复核——问题依然存在。该提前返回本身是有意为之且与仓库既有写法一致(本模块自己的 JSDoc 写的是「在 POSIX 上缺失可执行位」,打包脚本也用 if (target !== 'win-x64') 保护其执行位检查),因此缺陷仍然在于文档丢掉了其自身代码所带的平台限定,位置为英文 :117-119 / :121-123 与中文 :80。
本轮还实测了它与上面那条 Windows fixture 阻塞项的相互作用:一旦把该 fixture 改成平台感知,一个 0644 的 bun.exe 在 win32 上会被成功解析而不是回退,因此权限位用例必须在同一次变更中一并加上平台跳过。
修复方式:在两个语言版本中都按平台限定该表述——例如「必须是存在的普通文件;在 POSIX 上还必须带可执行位(Windows 没有执行位,因此那里只检查存在性与普通文件形态)」。
约束:把 isExecutableFile 与 program-probe.ts:50 的既有写法对齐不会带来任何改变,因为那一行同样是 win32 跳过而非收紧;只有文档限定,或真正的扩展名/形态校验,才是有效做法。任何真正的 win32 校验仍必须接受解析器的 { bun: ['bun','bun.exe'], node: ['node','node.exe'] } 路径段。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Published follow-up at 8b4a0a25ea (14036-T12).
Both documents now distinguish the implemented validation: POSIX requires execute permission; Windows checks existence of a regular file, not PE validity or actual launchability. Windows default interpreter paths are documented. Real Windows execution is still missing.
Validation scope: an independent frozen-lock install and local core build enabled two standard package-config runs on macOS arm64 with Node 24.19.0 hosting Vitest 3.2.7 and Bun 1.3.14 child legs: each 35 passed, 0 failed, 0 skipped, actual rc0. globalSetup/test-setup were retained. Earlier missing-build rc1 is historical, not erased. Full-repository build/typecheck and real Linux/Windows remain unverified; the existing hosted-harness CI failures are not waived. Bun as the Vitest host failed despite rc0 and is not a supported pass. Keep this thread unresolved until its original conditions are met.
|
|
||
| ## Bun compatibility facts (probed this change) | ||
|
|
||
| Probed with Bun 1.4.0 local vs Node 24.19.0 (same fixture, see |
There was a problem hiding this comment.
[Suggestion] R1-18 This table is headed "probed this change" and cites runtime-boundary.node-bun.test.ts as its source, but two of its seven rows are not reproducible from that fixture: the matrix has no process.execve leg and no @lydell/node-pty leg. The process.execve row is the table's only recorded Bun absence, and it is the fact gating three live relaunch paths the row itself names. The validation plan then tells S5 to "rerun the matrix on the real archives" as its acceptance — so an S5 engineer who reruns the cited fixture gets a green matrix that says nothing about execve or PTY, and would record those two rows as re-verified on the shipped pin when they were never probed at all. A regression reintroducing an unguarded process.execve call under the compiled flavor then ships on the strength of a table row no artifact supports. To be clear, this is a provenance gap rather than a wrong fact: both unsourced rows were spot-checked and are accurate.
Witness:
Settled by running the cited artifact rather than reading it:
$ npx vitest run src/utils/runtime-boundary.node-bun.test.ts --reporter=verbose
Tests 6 passed | 1 skipped (7)
node: reports runtime identity over the stdio protocol
node: propagates child exit codes
node: delivers SIGTERM to a handler and exits gracefully (win32-skipped)
node: round-trips messages over the Node IPC channel
node: exposes gc under --expose-gc (entry child contract)
node: runs --input-type=commonjs --eval (hook supervisor contract)
bun leg records the interpreter version it ran with (skipped)
$ grep -E 'execve|pty|Pty|node-pty|loadPty' runtime-boundary.node-bun.test.ts
No matches found
fixture emits only: runtime, bun, node, hasSend, gcType
=> of the table's 7 rows, 5 map to a leg and 2 have none
spot-checks: relaunch.ts:148 `typeof process.execve === 'function' &&`,
processUtils.ts:67-68 `if (supervisedInProcess && proc.execve)`
Either mark those two rows as not fixture-probed (a third column, or a footnote naming where each was observed), or add the missing legs: emit hasExecve: typeof process.execve === 'function' from the fixture's identity JSON and assert it per runtime, and add a loadPty()-shaped leg for the PTY row.
An execve probe cannot assert "Node: yes" unconditionally — daemon-update-restart.test.ts:228 already carries it.skipIf(!process.execve || ['win32','os400'].includes(process.platform))(, showing the repo treats process.execve as absent on win32/os400, and this matrix runs on the Windows lane. (Line reference corrected: the table spans :141-149.)
A new assertion on the identity record's hasExecve field must go red when the fixture stops emitting it, and on a POSIX lane must report true for Node and false for Bun.
中文说明
这张表的标题是「probed this change(本次变更已探测)」,并引用 runtime-boundary.node-bun.test.ts 作为其来源,但其中七行里有两行无法从该 fixture 复现:matrix 既没有 process.execve 分支,也没有 @lydell/node-pty 分支。process.execve 这一行是表中唯一记录的 Bun 缺失能力,也正是该行自己点名的三条在用重启路径所依赖的事实。随后验证计划又告诉 S5 要「在真实归档上重跑该 matrix」作为验收——于是重跑所引用 fixture 的 S5 工程师会得到一份绿色的 matrix,而它对 execve 与 PTY 一无所知,并会把这两行记录为已在发布固定版本上重新验证过,而它们其实从未被探测。这样一来,若在编译产物形态下重新引入未加保护的 process.execve 调用,就会凭一条没有任何产物支撑的表格行而合入。需要说明的是,这是出处缺口而不是事实错误:两条缺少出处的行都经过抽查,内容准确。
修复方式:或者把这两行标注为「未经 fixture 探测」(增加第三列,或加脚注说明各自是在何处观测到的),或者补上缺失的分支:让 fixture 的身份 JSON 输出 hasExecve: typeof process.execve === 'function' 并按运行时断言,同时为 PTY 行增加一个 loadPty() 形态的分支。
约束:execve 探测不能无条件断言「Node: yes」——daemon-update-restart.test.ts:228 已经带有 it.skipIf(!process.execve || ['win32','os400'].includes(process.platform))(,说明本仓库把 process.execve 视为在 win32/os400 上不存在,而本 matrix 会在 Windows 检查项上运行。(行号更正:表格实际跨越 :141-149。)
验收标准:当 fixture 不再输出 hasExecve 字段时,针对身份记录中该字段的新断言必须变红;并且在 POSIX 检查项上,它对 Node 必须报告 true、对 Bun 报告 false。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
[Suggestion] R1-18: This table is headed "probed this change" and cites runtime-boundary.node-bun.test.ts as its source, but two of its seven rows are not reproducible from that fixture: the matrix has no process.execve leg and no @lydell/node-pty leg.
Re-checked at head fed48b85 — still stands (grep -Ec 'execve|node-pty|loadPty' over the matrix returns 0; running the cited artifact reports 6 passed | 1 skipped, and the fixture emits only runtime, bun, node, hasSend, gcType). This is a provenance gap rather than a wrong fact: both unsourced rows were spot-checked and are accurate.
Witness:
grep -Ec 'execve|node-pty|loadPty' packages/core/src/utils/runtime-boundary.node-bun.test.ts at head fed48b85 -> 0 matches. Running the cited artifact: `vitest run src/utils/runtime-boundary.node-bun.test.ts --reporter=verbose` -> Tests 6 passed | 1 skipped (7), the legs being runtime identity, exit codes, SIGTERM (win32-skipped), Node IPC round-trip, --expose-gc, --input-type=commonjs --eval, plus the skipped bun-version leg; the fixture emits only runtime, bun, node, hasSend, gcType — so of the table's 7 rows, 5 map to a leg and 2 have none. Spot-checks: relaunch.ts:148 `typeof process.execve === 'function' &&`, processUtils.ts:67-68 `if (supervisedInProcess && proc.execve)`.
One existing fact the fix must not violate: An execve probe cannot assert "Node: yes" unconditionally — daemon-update-restart.test.ts:228 already carries it.skipIf(!process.execve || ['win32','os400'].includes(process.platform))(, showing the repo treats process.execve as absent on win32/os400, and this matrix runs on the Windows lane. The table spans :141-149.
Acceptance criterion: A new assertion on the identity record's hasExecve field must go red when the fixture stops emitting it, and on a POSIX lane must report true for Node and false for Bun. Please remove the guard again afterwards and confirm that test reds.
中文说明
这张表的标题是「probed this change(本次变更已探测)」,并引用 runtime-boundary.node-bun.test.ts 作为其来源,但其中七行里有两行无法从该 fixture 复现:matrix 既没有 process.execve 分支,也没有 @lydell/node-pty 分支。
已在 head fed48b85 复核——问题依然存在(对该 matrix 执行 grep -Ec 'execve|node-pty|loadPty' 返回 0;运行所引用的产物报告 6 passed | 1 skipped,且 fixture 只输出 runtime、bun、node、hasSend、gcType)。这是出处缺口而不是事实错误:两条缺少出处的行都经过抽查,内容准确。
风险在于:process.execve 这一行是表中唯一记录的 Bun 缺失能力,也是该行自己点名的三条在用重启路径所依赖的事实;而验证计划又告诉 S5 要「在真实归档上重跑该 matrix」作为验收,于是重跑所引用 fixture 的 S5 工程师会得到一份绿色的 matrix,并把这两行记录为已重新验证。
修复方式:或者把这两行标注为「未经 fixture 探测」(增加第三列,或加脚注说明各自是在何处观测到的),或者补上缺失的分支:让 fixture 的身份 JSON 输出 hasExecve: typeof process.execve === 'function' 并按运行时断言,同时为 PTY 行增加一个 loadPty() 形态的分支。
约束:execve 探测不能无条件断言「Node: yes」——daemon-update-restart.test.ts:228 已带有 it.skipIf(!process.execve || ['win32','os400'].includes(process.platform))(,说明本仓库把 process.execve 视为在 win32/os400 上不存在,而本 matrix 会在 Windows 检查项上运行。
验收标准:当 fixture 不再输出 hasExecve 字段时,针对该字段的新断言必须变红;并且在 POSIX 检查项上,它对 Node 必须报告 true、对 Bun 报告 false。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Published follow-up at 8b4a0a25ea (14036-T13).
The unsupported historical compatibility-results table has been removed in both languages. The text now lists the actual fixture coverage and explicitly separates process.execve/getPty source mechanisms from measured results. Native PTY, fd-3 and process-tree acceptance are not certified by this fixture.
Validation scope: an independent frozen-lock install and local core build enabled two standard package-config runs on macOS arm64 with Node 24.19.0 hosting Vitest 3.2.7 and Bun 1.3.14 child legs: each 35 passed, 0 failed, 0 skipped, actual rc0. globalSetup/test-setup were retained. Earlier missing-build rc1 is historical, not erased. Full-repository build/typecheck and real Linux/Windows remain unverified; the existing hosted-harness CI failures are not waived. Bun as the Vitest host failed despite rc0 and is not a supported pass. Keep this thread unresolved until its original conditions are met.
| manifest: Record<string, unknown>; | ||
| withBun?: boolean; | ||
| withNode?: boolean; | ||
| interpreterTarget?: 'file' | 'directory' | 'non-executable'; |
There was a problem hiding this comment.
[Suggestion] R1-20 This fixture option declares three variants but implements one. Its only read site is the === 'non-executable' ternary inside the withBun branch, so 'file' and 'directory' are inert, and the option is silently dropped for the node flavor, which routes through writeExecutable's unconditional chmodSync(0o755). A maintainer writing the obvious next test against this declared API — { manifest: { runtime: 'node' }, withNode: true, interpreterTarget: 'non-executable' }, or anything using 'directory'/'file' — gets a layout that does not match its name: the node binary is written 0o755, so getJsInterpreterCommand resolves instead of falling back, and the test either fails for a reason unrelated to the behaviour under test or passes while never exercising the rejection it names. Today the non-executable rejection is pinned by exactly one test, the bun-flavor one, and this fixture cannot express the node-flavor equivalent — which matters because that rejection is also the one shown above to be unexercised on the Windows lane.
Witness:
9-row two-arm probe against the real unmodified runtime-info.ts, fixture
helpers spliced in verbatim BY LINE RANGE (sed -n '35,73p;75,76p'), not retyped:
[1] SHIPPED bun + 'non-executable' mode 0o644 -> FELL BACK (reproduces
the passing test at :198, so the harness is sound)
[2] SHIPPED node + 'non-executable' mode 0o755 -> RESOLVED <root>/node/bin/node
[3] FIXED node + 'non-executable' mode 0o644 -> FELL BACK <- FLIP
[4] SHIPPED bun + 'directory' regular 0o755 file -> RESOLVED
[5] FIXED bun + 'directory' isDirectory=true -> FELL BACK <- FLIP
[6a/6b/6c] 'file' is observationally identical to OMITTING the option in
both arms -> it is not a rejection variant at all
$ grep -rn interpreterTarget <worktree> -> 3 hits, all in this new file
:48 declaration :62 sole read :202 sole call site
$ grep -c 0o644 runtime-info.test.ts -> 1
| interpreterTarget?: 'file' | 'directory' | 'non-executable'; | |
| interpreterTarget?: 'non-executable'; |
Narrowing the type is the better of the two options for 'file', which the probe showed is indistinguishable from omitting the option. If you would rather keep all three, implement them in writeStandaloneLayout and apply the mode to both flavors — mkdirSync(bunPath) instead of writeFileSync for 'directory', and route the withNode branch through the same chmod ternary instead of writeExecutable.
runtime-info.ts short-circuits executability on win32, so a chmod-based non-executable assertion cannot hold on the Windows lane; a new node-flavor rejection test needs the skip: process.platform === 'win32' the sibling matrix already uses, or must assert through a missing-file/directory shape instead. Honest bound on the cost: the coverage half is smaller than it looks, since both flavors validate through the same isExecutableFile call and the flavor only selects the path — the durable cost is this misleading fixture API.
If the option is implemented for both flavors, a new it('falls back when the node-flavor interpreter is not executable') goes red against the shipped fixture (measured: the resolver returns <root>/node/bin/node) and red again if the node branch is reverted to writeExecutable. If the type is narrowed instead, the witness is tsc --noEmit rejecting interpreterTarget: 'directory'.
中文说明
这个 fixture 选项声明了三种取值,但只实现了一种。它唯一的读取点是 withBun 分支内部的 === 'non-executable' 三元表达式,因此 'file' 与 'directory' 是无效的;而对 node 形态,该选项被静默丢弃,因为那条路径走的是 writeExecutable,其中 chmodSync(0o755) 是无条件执行的。维护者若按这个已声明的 API 写出最自然的下一条测试——{ manifest: { runtime: 'node' }, withNode: true, interpreterTarget: 'non-executable' },或任何使用 'directory'/'file' 的写法——得到的布局会与其名称不符:node 二进制被写成 0o755,于是 getJsInterpreterCommand 会成功解析而不是回退,测试要么因与被测行为无关的原因失败,要么通过了却从未执行到它所要验证的拒绝逻辑。目前「不可执行」这一拒绝行为只由一条测试固定,即 bun 形态那条,而本 fixture 无法表达 node 形态的等价用例——这一点很重要,因为如上所述,该拒绝行为在 Windows 检查项上同样未被执行。
修复方式:把类型收窄(见上方 suggestion 块)。就 'file' 而言,收窄类型是两种方案中更好的一种,因为探测表明它与「不传该选项」完全无法区分。如果更希望保留三种取值,就在 writeStandaloneLayout 中真正实现它们,并对两种形态都应用文件模式——'directory' 用 mkdirSync(bunPath) 取代 writeFileSync,并让 withNode 分支走同一个 chmod 三元表达式,而不是 writeExecutable。
约束:runtime-info.ts 在 win32 上会提前跳过可执行性检查,因此基于 chmod 的「不可执行」断言在 Windows 检查项上无法成立;新增的 node 形态拒绝测试需要使用同级 matrix 已在用的 skip: process.platform === 'win32',或改为通过「文件缺失/目录」形态来断言。对代价的诚实界定:其中覆盖率这一半比看上去要小,因为两种形态都通过同一个 isExecutableFile 调用进行校验,形态只决定路径——真正持久的代价是这个会造成误解的 fixture API。
验收标准:如果为两种形态都实现了该选项,那么新增的 it('falls back when the node-flavor interpreter is not executable') 在现有 fixture 下会变红(已实测:解析器返回 <root>/node/bin/node),并且当 node 分支被改回 writeExecutable 时会再次变红。如果改为收窄类型,则验收标准是 tsc --noEmit 会拒绝 interpreterTarget: 'directory'。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
[Suggestion] R1-20: This fixture option declares three variants but implements one: its only read site is the === 'non-executable' ternary inside the withBun branch, so 'file' and 'directory' are inert, and the option is silently dropped for node-flavor layouts.
Re-checked at head fed48b85 — still stands: interpreterTarget occurs exactly three times in the file (the :48 declaration, the :62 sole read, the :202 sole call site) with zero comparisons or passes of 'file' or 'directory', and the withNode branch still routes through writeExecutable's unconditional chmodSync(0o755) at :37-41.
Witness:
Sweep of the real population (the file is the authority, no reimplementation) at head fed48b85:
48: interpreterTarget?: 'file' | 'directory' | 'non-executable';
62: options.interpreterTarget === 'non-executable' ? 0o644 : 0o755,
202: interpreterTarget: 'non-executable',
comparisons or passes of 'file' / 'directory': NONE
Exactly three occurrences and zero uses of the two other declared values, so both are dead union members. The second half also holds: the withNode branch calls writeExecutable(), which unconditionally does chmodSync(filePath, 0o755) at :37-41 and never consults the option, so interpreterTarget cannot affect a node layout at all. The directory rejection is expressed independently by passing `interpreter: './bun/bin'` (:191-196).
| interpreterTarget?: 'file' | 'directory' | 'non-executable'; | |
| interpreterTarget?: 'non-executable'; |
Acceptance criterion: If the values are implemented rather than dropped, add a case asserting resolvedFor(root, 'lib/worker.js') equals execPathFallback() when the candidate path is a directory; it must go red when the isFile() check in runtime-info.ts:99 is removed. Please remove the guard again afterwards and confirm that test reds.
中文说明
这个 fixture 选项声明了三种取值,但只实现了一种:它唯一的读取点是 withBun 分支内部的 === 'non-executable' 三元表达式,因此 'file' 与 'directory' 是无效的;而对 node 形态,该选项被静默丢弃。
已在 head fed48b85 复核——问题依然存在:interpreterTarget 在文件中恰好出现三次(:48 声明、:62 唯一读取点、:202 唯一调用点),'file' 与 'directory' 作为被比较或被传入的值出现 0 次;withNode 分支仍然走 writeExecutable,其中 chmodSync(0o755)(:37-41)是无条件执行的。
代价是:维护者若按这个已声明的 API 写出最自然的下一条测试,得到的布局会与其名称不符——node 二进制被写成 0o755,于是解析器成功解析而不是回退,测试要么因与被测行为无关的原因失败,要么通过了却从未执行到它所要验证的拒绝逻辑。
修复方式:把类型收窄为 interpreterTarget?: 'non-executable';(就 'file' 而言这是更好的选项,因为探测表明它与「不传该选项」无法区分);如果更希望保留三种取值,就在 writeStandaloneLayout 中真正实现它们,并对两种形态都应用文件模式。
约束:runtime-info.ts 在 win32 上会提前跳过可执行性检查,因此基于 chmod 的「不可执行」断言在 Windows 检查项上无法成立;新增的 node 形态拒绝测试需要使用同级 matrix 已在用的 skip: process.platform === 'win32',或改为通过「文件缺失/目录」形态来断言。
验收标准:如果为两种形态都实现了该选项,新增的 it('falls back when the node-flavor interpreter is not executable') 在现有 fixture 下会变红,且当 node 分支被改回 writeExecutable 时会再次变红;如果改为收窄类型,则验收标准是 tsc --noEmit 会拒绝 interpreterTarget: 'directory'。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Published follow-up at 8b4a0a25ea (14036-T14).
The inert file/directory fixture variants have been removed. The remaining non-executable setting is applied to both runtime-flavor layouts; separate Bun/Node permission-negative cases run on POSIX and explicitly skip Windows. The standard Node-hosted run executes these assertions; this is not a Windows pass.
Validation scope: an independent frozen-lock install and local core build enabled two standard package-config runs on macOS arm64 with Node 24.19.0 hosting Vitest 3.2.7 and Bun 1.3.14 child legs: each 35 passed, 0 failed, 0 skipped, actual rc0. globalSetup/test-setup were retained. Earlier missing-build rc1 is historical, not erased. Full-repository build/typecheck and real Linux/Windows remain unverified; the existing hosted-harness CI failures are not waived. Bun as the Vitest host failed despite rc0 and is not a supported pass. Keep this thread unresolved until its original conditions are met.
Maintainer verification report — PR #14036Verdict:
中文摘要结论:findings(建议先修复再合并)。 核心改动经 A/B 验证是行为保持的,且接缝本身被证明是承重的;但分支当前未通过 Prettier CI 门禁(4 个文件),若干评审发现经复测仍然成立。
详细数据见下方 Findings 与 Standing review threads 表格。 Central claim and A/B proofCentral claim (from the PR body): every place that spawns an arbitrary-JS child resolves the interpreter through one seam ( A/B cells — behavior preservationIdentical affected-suite invocation on both trees (
Byte-identical outcomes on both arms → no behavior change in current layouts. New suites on head: Load-bearing proof — decoy-interpreter witness (3 arms)A fake standalone layout was planted at the resolver's trust anchor (
Base and mutant oracles are identical → the witness is load-bearing: the seam wiring at the spawn site is what routes the supervisor through the manifest-declared interpreter, and functional behavior (hook completion, via the supervisor's fd-3 status protocol) is identical on all three arms. Mutation matrix (vacuity + traversal reintroduction)All single-point guard mutations in
Traversal reintroductions (measuring standing thread R1-6):
Standing review threads — re-measured at
|
| Thread | Claim | Status | Evidence |
|---|---|---|---|
| R1-1 (Critical) | 4 files fail prettier --check; CI lint lane red |
Stands | node scripts/lint.js --prettier: head EXIT=1 (bun-runtime-boundary.md, .zh-CN.md, runtime-boundary.node-bun.test.ts, runtime-info.test.ts), base EXIT=0 |
| R1-2 (Critical) | fixture builds POSIX layout only; win32 resolver branch uncovered | Stands (static) | writeStandaloneLayout plants bun/bin/bun only; resolver branches to bun/bun.exe on win32. CI's Windows test lane is SKIPPED for this PR |
| R1-3 (Critical) | SIGTERM test races fixture handler registration | Stands — mechanism confirmed; harness-level flake not reproduced | Standalone replication: 178/300 (59%) node children die with raw SIGTERM; same fixture under Bun: 0/300. Real vitest test: 20/20 green (vitest's parent lands kill() late). Speed-correlated latent flake |
| R1-4 (Critical) | IPC leg's exitCode === 0 after kill() cannot hold on Windows |
Not measurable locally (macOS); CI Windows lane SKIPPED | — |
| R1-5 (Critical) | doc invariant "never returns the application binary" contradicts the execPath fallback | Stands (doc wording) | The fallback returns process.execPath, which under a compiled flavor is the app binary — the doc's own contract item 3 says so |
| R1-6 | ancestor-manifest tests cannot detect traversal reintroduction | Confirmed with precision | M7a/M7b/M7c matrix above |
| R1-7 | async matrix tests don't reap children on failure paths | Stands (static) | No afterEach kill / 'error' listener in the two async legs |
| R1-8 | version-record console.info swallowed by silent: true |
Confirmed | packages/core/vitest.config.ts:28 sets silent: true |
| R1-12 | EN "Proposed contract" vs ZH "接口约定" | Confirmed | EN line 88 vs ZH line 68; the ZH twin dropped the qualifier |
| R1-13 | call-site inventory covers under half the production sites | Confirmed — 7 production sites missing | Census below |
| R1-16 | --eval leg never touches the supervisor's fd-3 status pipe |
Partially addressed by this round | The witness drove the real supervisor (fd-3 status protocol) under the decoy interpreter to hook completion; the PR's committed matrix still doesn't pin it |
| R1-17 | win32 isExecutableFile short-circuits to true |
Stands (static) | if (process.platform === 'win32') return true; |
| R1-18 | doc probe table cites rows (execve, PTY) the fixture never exercises | Confirmed | The matrix has no execve/node-pty leg |
| R1-20 | interpreterTarget: 2 of 3 variants inert, dropped for node flavor |
Confirmed (static) | Only === 'non-executable' is read, only under withBun |
R1-13 census (scripted)
grep -rn 'process\.execPath' packages/{core,cli}/src (production files only) cross-checked against the doc's three inventory tables — missing from the inventory (classification mine):
| Site | Identity | Notes |
|---|---|---|
packages/cli/src/commands/sandbox.ts:228 |
JS interpreter | sandbox probe spawn with --eval <program> — exactly the class the seam exists for |
packages/cli/src/serve/run-qwen-serve.ts:913 |
JS interpreter | execFile(execPath, ['--input-type=module','--eval', WORKER_TLS_TRUST_PROBE, …]) |
packages/cli/src/agent-view/current-cli-argv.ts:27,34 |
app launcher | builds [execPath, entrypoint, …] for supervisor spawn |
packages/cli/src/serve/channel-worker-supervisor.ts:1119 |
app launcher | spawnWorker(process.execPath, argv…) |
packages/cli/src/serve/session-agents/orchestrator.ts:631 |
app launcher | session-send-mcp child |
packages/cli/src/serve/local-process-runtime-activator.ts:315 |
app launcher | managed-runtime worker spawn |
packages/cli/src/ui/utils/updateCheck.ts:148 |
update/install | runGlobalNpm default nodePath |
The inventory is designated as S3/S4's migration checklist, so the two missing JS-interpreter sites are the material gap: both spawn --eval snippets and would break silently under a compiled flavor.
Findings
F-1 (blocking, CI): Prettier gate red at head — 4 files
node scripts/lint.js --prettier (the exact CI lane) exits 1 on head, 0 on base. All four offenders are files this PR adds. Repro: git checkout fed48b85c8 && node scripts/lint.js --prettier. Fix: npx prettier --write on the four files. Trivial, but the required "Lint & Static" check cannot go green without it.
F-2 (medium): the no-upward-traversal invariant is not pinned against a guarded traversal
The F1-regression tests kill the naive pre-fix traversal (M7a, 7 red) and a validating traversal without the marker check (M7b, 2 red), but a traversal keeping both guards per ancestor lands 16/16 green (M7c). The residual risk is narrower than the original F1 (the ancestor must also carry lib/cli-entry.js), so this is a coverage finding, not a defect — pin the invariant directly (e.g. a counting-fs wrapper asserting the resolver never stats above the anchored root) or document the accepted boundary.
F-3 (medium): SIGTERM matrix leg is a latent speed-correlated flake (R1-3)
The fixture writes its identity line before registering process.on('SIGTERM'), and the parent kills on the first stdout chunk. Standalone replication: 59% of node children die with the raw signal (178/300); Bun children 0/300. The committed test passed 20/20 in real vitest runs here because the vitest parent is slower to fire kill(); a faster parent or a slower child flips it. One-line fix: register the SIGTERM handler before writing the identity line (or gate the kill on a ready marker written after registration).
F-4 (minor): design-doc inventory misses 7 production process.execPath sites
Including two JS-interpreter-identity sites (commands/sandbox.ts:228, run-qwen-serve.ts:913) — the class most affected by the S4 compiled flavor. Plus the confirmed wording issues from the standing threads: R1-5 (invariant contradicts the fallback), R1-12 (EN "Proposed" qualifier absent in ZH), R1-18 (execve/PTY rows not reproducible from the cited fixture).
Not covered
- Windows-only paths (R1-2 win32 layout branch, R1-4 kill semantics, R1-17 executability short-circuit): not measurable on this macOS host. The PR's CI shows
Test (windows-latest)andTest (macos-latest)as SKIPPED — only the Ubuntu lane runs the new suites, so the win32 gaps currently have no CI coverage anywhere. - Per-site decoy witnesses for
code-mode/host-client.tsandsandbox/file-worker-client.ts: their migration is proven at suite level (identical 278/278 A/B) and the mechanism at the hookRunner site; reverting those call sites is behaviorally invisible in every current layout by construction. - The
getPty.tschange is a detection-helper swap ('bun' in process.versions→isBunRuntime()), covered by the getPty suite in the A/B. - Real standalone-archive / packaging acceptance (S4/S5 scope) and real PTY under Bun (S2 scope) — out of scope per the PR's own Risk & Scope.
- The race-measurement cells (600 iterations) are reported as distributions, not counted in the pass/fail tally.
Methodology
Two throwaway worktrees at the verified head and the merge-base (== origin/main tip), each installed (pnpm install --frozen-lockfile) and built; the base tree received a clonefile copy of the head tree's node_modules (the PR leaves the lockfile untouched) with the workspace-symlink realpath asserted to resolve inside the base tree, so no head code leaks into the control. Harnesses are mock-free: real child processes, the tree's own HookRunner over tsx, a decoy interpreter binary logging argv, vitest with coverage disabled. Mutations used unique-anchor replacement with a count assertion, cp backup/restore, and a git status --porcelain cleanliness gate after every row (all clean). Gates proven live before being cited: ESLint was preceded by a planted unused-variable violation (caught, exit 1); the Prettier gate's base arm is green, proving the gate itself functions. Harness scripts and raw logs are preserved under tmp/pr14036-verify-20261015-080805/.
Evidence captures
01 — Prettier gate A/B (head red / base green):
02 — Decoy-interpreter witness, 3 arms (head / base / mutant):
03 — Mutation matrix (7 guard mutants killed; traversal shapes detected vs evaded):
04 — SIGTERM race replication (300× node, 300× bun) + 20× real vitest runs:
Local maintainer verification by @wenshao's qwen-code verify pipeline. Artifacts: tmp/pr14036-verify-20261015-080805/ (report.md, verdict.txt, assertions.json, harness/, evidence/, raw logs).
qwen-code-review-bot
left a comment
There was a problem hiding this comment.
Partially reviewed — gaps disclosed.
10 Suggestion-level finding(s) this review confirmed are already reported on this PR and are not repeated:
- isBunRuntime duplicating the existing exported detectRuntime — already reported (review 5516323783, Reuse section; comment 6142521223)
- the single-runtime-detection-point claim not shipping — already reported (review 5516323783, contract point 3; comment 6142521223)
- JsInterpreterCommand.runtime having no production reader — already reported (review 5516323783, contract point 3; comment 6142521223)
- importMetaUrl ignored after the first call — already reported (review 5516323783; comment 6142521223)
- manifest.interpreter having no producer — already reported (review 5516323783, contract point 3; comment 6142467772)
- path.resolve letting a declared interpreter escape the trusted root — already reported (review 5516323783, contract point 3)
- nothing pinning the four migrated call sites — already reported (review 5516323783; comment 6142521223)
- the tautological isBunRuntime unit test — already reported (comment 6142521223)
- the Bun leg never executing in a gating CI run — already reported (comment 6142521223; comment 6142704338; review 5516323783)
- the silent fallback carrying no diagnostic — already reported (review 5516323783, contract point 1; comment 6142521223)
Unresolved, please confirm:
- [Critical] docs/design/bun-runtime-boundary.md:127 (R1-5) — every mechanical step of the replay was verified at this head (the resolver returns process.execPath on every rejection path, writeManifest emits no
interpreterkey, and the bwrap/landlock/…
Not reviewed: build-and-test — Test (windows-latest, Node 22.x) was skipped in CI and its suite did not run locally (this review ran the scoped suites on Linux only, so the Windows lane that two confirmed Criticals land on was never executed by any lane).
Not reviewed: build-and-test — Test (macos-latest, Node 22.x) was skipped in CI and its suite did not run locally (the SIGTERM race is platform- and contention-sensitive).
Not reviewed: build-and-test — Integration Tests (CLI, No Sandbox) was skipped in CI and its suite did not run locally (the diff rewires core spawn sites that only the integration suite exercises end to end).
Not reviewed: test-efficacy — Agent 7's probe harness could not be validated (harnessValidated: null; both probes returned no parseable output because the vitest prerequisite guard tripped in the probe's own run), so no mutant-survival or hunk-necessity coverage was measured this round.
Not reviewed: issue-fidelity closing-issue discovery — gh >= 2.72.0 is unavailable on this runner, so the closing-issue set is UNKNOWN rather than empty; Agent 0 performed the incident replay and the root-cause ownership check and fetched #11607 as motivating evidence only.
Not reviewed: reverse audit — stopped before round 5 by the review time budget.
Test Plan (not a blocker): src/utils/runtime-info.test.ts — no such file or directory; src/utils/runtime-boundary.node-bun.test.ts — no such file or directory.
Deferred under the convergence posture (round 2, not a blocker) — recorded, not requested in this round:
docs/design/bun-runtime-boundary.md:78 — [review] the stated archive layout is wrong for the win-x64 target and the contract omits the Windows variant the new code implementspackages/core/src/utils/runtime-boundary.node-bun.test.ts:74 — [review] NODE_TEST_BIN is a dead switch — one read site tree-wide, no setter, and undocumented unlike its BUN_TEST_BIN siblingdocs/design/bun-runtime-boundary.md:92 — [review] the contract's claim that scripts/cli-entry.js is the only writer of QWEN_CODE_CLI is false (dev.js:227 and start.js:47 also stamp it, test-pinned)
中文说明
仅完成部分审查,审查缺口已披露。
本轮确认的 10 条建议级发现已在 PR 上报告过,不再重复发布(列表见上方英文部分)。
未决,请确认:共 1 条(原文未翻译,列表见上方英文部分)。
未审查(原文为英文):build-and-test — Test (windows-latest, Node 22.x) was skipped in CI and its suite did not run locally (this review ran the scoped suites on Linux only, so the Windows lane that two confirmed Criticals land on was never executed by any lane).
未审查(原文为英文):build-and-test — Test (macos-latest, Node 22.x) was skipped in CI and its suite did not run locally (the SIGTERM race is platform- and contention-sensitive).
未审查(原文为英文):build-and-test — Integration Tests (CLI, No Sandbox) was skipped in CI and its suite did not run locally (the diff rewires core spawn sites that only the integration suite exercises end to end).
未审查(原文为英文):test-efficacy — Agent 7's probe harness could not be validated (harnessValidated: null; both probes returned no parseable output because the vitest prerequisite guard tripped in the probe's own run), so no mutant-survival or hunk-necessity coverage was measured this round.
未审查(原文为英文):issue-fidelity closing-issue discovery — gh >= 2.72.0 is unavailable on this runner, so the closing-issue set is UNKNOWN rather than empty; Agent 0 performed the incident replay and the root-cause ownership check and fetched #11607 as motivating evidence only.
未审查:反向审计——评审时间预算不足,未能开始第 5 轮。
Test Plan(非阻断):src/utils/runtime-info.test.ts — no such file or directory; src/utils/runtime-boundary.node-bun.test.ts — no such file or directory。
收敛姿态下延后(第 2 轮,非阻断)——已记录,本轮不要求修改:共 3 条(原文未翻译,列表见上方英文部分)。
— qwen3.8-max via Qwen Code /review (v0.25.1)
| ); | ||
| }); | ||
|
|
||
| it('resolves the bundled Bun interpreter from a trusted bun-flavor layout', () => { |
There was a problem hiding this comment.
[Suggestion] R2-1: No positive-resolution test exercises the lib/chunks/ bundle-dir shape, which is the only shape the three migrated callers actually have in a shipped standalone archive — so the chunk-stripping branch that makes the trust anchor work is unpinned in this file.
In the standalone archive dist entries are relocated under <root>/lib/ (create-standalone-package.js:389 const libDir = path.join(packageRoot, 'lib');, with chunks in both DIST_REQUIRED_PATHS:83 and DIST_ALLOWED_ENTRIES:106) and esbuild emits shared modules at chunks/[name]-[hash] (esbuild.config.js:180,190-191), so runtime-info.ts resolves at runtime from <root>/lib/chunks/<chunk>.js and packageRoot comes out as <root> only because resolveBundleDir strips the trailing chunks segment. Every positive test in the new file passes lib/worker.js, whose basename is lib, so resolveBundleDir is a no-op on it; the single test passing chunks/worker.js (:151) asserts the fallback. Drop the helper at runtime-info.ts:159 — path.dirname(resolveBundleDir(importMetaUrl)) -> path.dirname(fileURLToPath(importMetaUrl)) — and in production a chunk-resident caller computes packageRoot = <root>/lib, <root>/lib/manifest.json does not exist, and every standalone install silently falls back to process.execPath: the boundary this PR exists to create stops existing in the only layout where it is supposed to activate.
Witness:
not run — mutation probe unavailable: `qwen review scratch-tree` returned available:false (the repo-local git config carries an unreadable includeIf chain, so no isolated tree could be created and the shared worktree is read-only). The coverage claim rests on exhaustive reading of all 15 cases in runtime-info.test.ts (absence, not behaviour — a probe adds nothing): the four positive-resolution cases at :110, :121, :132, :245 all pass `lib/worker.js`; the only `chunks/`-shaped paths are :138 and :164, both asserting execPathFallback(). The surviving-regression leg is a deterministic path-arithmetic trace over fixtures the tests themselves write, and the shipped-layout premise was confirmed against create-standalone-package.js:389 / writeManifest:1052-1053 / the `lib/cli-entry.js` marker / esbuild.config.js:180,190-191.
VERIFIER CORRECTION, load-bearing for the fix: the mutant this finding originally named (resolveBundleDir returning moduleDir unconditionally) does NOT keep the suite green — the pre-existing packages/core/src/utils/bundlePaths.test.ts pins exactly that branch at :24 `expect(BUNDLE_CHUNK_DIR).toBe('chunks')` and :37 `expect(resolveBundleDir(fakeChunk)).toBe(distDir)`, and packages/core/vitest.config.ts sets no include/exclude so it runs in the same project. The regression that survives every test in the repo is the runtime-info.ts:159 inlining above.
One existing fact the fix must not violate: bundlePaths.ts's BUNDLE_CHUNK_DIR doc block: "The two files each define their own copy … renaming here requires renaming the BUNDLE_CHUNK_DIR constant in esbuild.config.js in the same commit." The test's module path must be lib/chunks/… relative to the layout root, not chunks/…, because create-standalone-package.js:389 places the dist tree (and therefore chunks/) under <packageRoot>/lib/, and <packageRoot> is where writeManifest writes manifest.json.
Acceptance criterion: The new lib/chunks/worker.js case must go RED when runtime-info.ts:159 stops calling resolveBundleDir (inlining path.dirname(fileURLToPath(importMetaUrl))). Do NOT state the witness against a resolveBundleDir mutant — that one is already covered by bundlePaths.test.ts:37. Please remove the guard again afterwards and confirm that test reds.
中文说明
没有任何「正向解析」用例覆盖 lib/chunks/ 这种 bundle 目录形态,而在已发布的 standalone 归档中,三个已迁移的调用方恰好只可能是这种形态——因此使信任锚点得以成立的那段「剥掉 chunks 末级目录」的分支,在本文件中没有任何测试固定。
具体而言:standalone 归档把 dist 条目搬到 <root>/lib/ 下(create-standalone-package.js:389,且 chunks 同时在 DIST_REQUIRED_PATHS:83 与 DIST_ALLOWED_ENTRIES:106 中),esbuild 以 chunks/[name]-[hash] 输出共享模块(esbuild.config.js:180,190-191),所以 runtime-info.ts 在运行时是从 <root>/lib/chunks/<chunk>.js 解析的,packageRoot 之所以等于 <root>,完全依赖 resolveBundleDir 剥掉末级 chunks。而本文件的四条正向用例传入的都是 lib/worker.js(basename 是 lib,此时 resolveBundleDir 是空操作);唯一传入 chunks/worker.js 的用例(:138)断言的是回退。
失效场景:把 runtime-info.ts:159 的 path.dirname(resolveBundleDir(importMetaUrl)) 改成 path.dirname(fileURLToPath(importMetaUrl)) 后,生产环境中 chunk 内的调用方会算出 packageRoot = <root>/lib,<root>/lib/manifest.json 不存在,于是每一个 standalone 安装都静默回退到 process.execPath——本 PR 要建立的边界,恰恰在它唯一应当生效的布局中失效。
修复时请注意(本轮核实得出的更正,很关键):不要按最初提出的变异(让 resolveBundleDir 无条件返回 moduleDir)来写验收标准——已有的 packages/core/src/utils/bundlePaths.test.ts:24 与 :37 已经固定了那段分支,且 packages/core/vitest.config.ts 没有 include/exclude 覆盖,它与本文件在同一个 vitest project 中运行。真正能躲过仓库内所有测试的回归,是上面那种在 runtime-info.ts:159 处的内联替换。
修复方式:新增一条镜像已发布布局的正向用例——在 writeStandaloneLayout({ manifest: { runtime: 'bun' }, withBun: true }) 之上断言 resolvedFor(root, 'lib/chunks/worker.js') 等于 { command: path.join(root, 'bun', 'bin', 'bun'), runtime: 'bun' },并补上 node 形态的孪生用例(lib/chunks/worker.js → <root>/node/bin/node)。
约束:bundlePaths.ts 的 BUNDLE_CHUNK_DIR 文档块写明「两个文件各自定义一份副本……在此处改名必须在同一次提交中同步修改 esbuild.config.js 的 BUNDLE_CHUNK_DIR 常量」;用例的模块路径必须是相对布局根的 lib/chunks/… 而不是 chunks/…,因为 create-standalone-package.js:389 把 dist 树(以及 chunks/)放在 <packageRoot>/lib/ 下,而 manifest.json 写在 <packageRoot>。
验收标准:当 runtime-info.ts:159 不再调用 resolveBundleDir(内联为 path.dirname(fileURLToPath(importMetaUrl)))时,新增的 lib/chunks/worker.js 用例必须变红。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Published follow-up at 8b4a0a25ea (14036-T15).
Positive resolution now exercises standalone lib/chunks for both runtime flavors. In an isolated diagnostic copy, disabling chunk stripping produces exactly those two failures (real rc1). Both added positives also pass in the unmodified standard package configuration.
Validation scope: an independent frozen-lock install and local core build enabled two standard package-config runs on macOS arm64 with Node 24.19.0 hosting Vitest 3.2.7 and Bun 1.3.14 child legs: each 35 passed, 0 failed, 0 skipped, actual rc0. globalSetup/test-setup were retained. Earlier missing-build rc1 is historical, not erased. Full-repository build/typecheck and real Linux/Windows remain unverified; the existing hosted-harness CI failures are not waived. Bun as the Vitest host failed despite rc0 and is not a supported pass. Keep this thread unresolved until its original conditions are met.
| ): { runtime: JsRuntime; interpreter?: string } | undefined { | ||
| let parsed: unknown; | ||
| try { | ||
| parsed = JSON.parse(fs.readFileSync(manifestPath, 'utf8')); |
There was a problem hiding this comment.
[Suggestion] R2-2: The one rejection branch carrying the documented "never throws" guarantee — a syntactically invalid manifest.json — has no test, so the parse guard is unpinned.
In the field a truncated or partially-written <root>/manifest.json (interrupted archive extraction, a disk-full managed update) makes JSON.parse throw SyntaxError out of getJsInterpreterCommand, which is called unguarded at code-mode/host-client.ts:54 (hostCommand(), reached from executeCodeMode :133) and at sandbox/file-worker-client.ts:39 (inside the executeSandbox payload literal). Every code-mode execution and every sandboxed file write then fails with a SyntaxError instead of silently running the child under process.execPath. The hookRunner.ts site is the only one of the three inside a try, and it rethrows.
Witness:
Exhaustive sweep of every manifest.json write site in runtime-info.test.ts (all 251 lines read) — there are exactly four and none can reach the catch via SyntaxError: L52-53 JSON.stringify(options.manifest); L149-151 JSON.stringify({name,interpreter}); L166-167 JSON.stringify({runtime:bun}); L234 the literal '"just-a-string"', which the real JSON.parse accepts (`parsed OK -> "just-a-string" | typeof: string`) and which is then rejected by `typeof parsed !== 'object'`, not by the catch. Driving the real module confirms the branch is live and correct but unpinned: `CASE3 invalid-JSON result= process.execPath (FALLBACK)` for manifest.json == '{"runtime":"bun"'. Suite baseline: Tests 16 passed (16).
VERIFIER CORRECTION, load-bearing for the fix: the finding's stated mutant (drop the try entirely) does NOT keep the suite green — the same catch also absorbs the ENOENT from readFileSync, because getJsInterpreterCommand calls parseStandaloneManifest with no prior existsSync guard (measured: `CASE1 manifest exists? = false` -> `CASE1 result = process.execPath (FALLBACK)`). So that mutant reds at least `falls back to process.execPath when no standalone manifest exists`, `ignores an unrelated ancestor manifest in an npm bundle layout` and `ignores an unrelated ancestor manifest for a deep SDK module layout`. Only the narrower mutant survives: guard the read, leave the parse unguarded.
One existing fact the fix must not violate: docs/design/bun-runtime-boundary.md contract §2 item 3: "The resolution never guesses at a different binary and never throws." The zh twin states the same ("解析绝不猜测其他二进制,也绝不抛出异常。"). A fix must keep that true for the parse-failure path, not only for the semantic-rejection paths the suite already covers — and must not break the ENOENT fallback the same catch currently provides.
Acceptance criterion: That new case must go red with SyntaxError: Unexpected end of JSON input when the guard around the JSON.parse is narrowed away — state the witness against the narrower mutant (guard the readFileSync, leave JSON.parse(raw) unguarded), NOT against deleting the whole try/catch, which also reds three ENOENT fallback cases and reads as a broken fix. Please remove the guard again afterwards and confirm that test reds.
中文说明
承载文档所承诺「绝不抛出异常」这一保证的那一条拒绝分支——manifest.json 语法非法——没有任何测试覆盖,因此该解析保护没有被固定。
本轮对 runtime-info.test.ts 全部 251 行做了穷尽扫描:文件中写入 manifest.json 的位置恰好有四处,没有一处能让 JSON.parse 抛异常(L52-53、L149-151、L166-167 都是 JSON.stringify(...);L234 是字面量 '"just-a-string"',真实 JSON.parse 会正常解析为字符串,随后被 typeof parsed !== 'object' 拒绝,而不是被 catch 拒绝)。直接驱动真实模块可确认该分支是活的、可达的、行为正确的,只是没有被固定:写入 '{"runtime":"bun"' 时结果为 process.execPath(回退)。
失效场景:现场中一个被截断或只写了一半的 <root>/manifest.json(归档解压中断、受管更新时磁盘写满)会让 JSON.parse 抛出 SyntaxError,并从 getJsInterpreterCommand 中逸出——该函数在 code-mode/host-client.ts:54(hostCommand(),由 executeCodeMode :133 调用)与 sandbox/file-worker-client.ts:39(位于 executeSandbox 的 payload 字面量内)都是无保护调用的。于是每一次 code-mode 执行与每一次沙箱文件写入都会以 SyntaxError 失败,而不是静默地用 process.execPath 运行子进程。三个调用点中只有 hookRunner.ts 那一处在 try 内,而它的 catch 会重新抛出。
修复时请注意(本轮核实得出的更正,很关键):不要按最初提出的变异(完全去掉 try)来写验收标准——同一个 catch 还吸收了 fs.readFileSync 的 ENOENT,因为 getJsInterpreterCommand 调用 parseStandaloneManifest 之前没有 existsSync 保护(已实测:无 manifest 时 manifest exists? = false → 结果为回退)。所以那个变异会额外让三条用例变红(falls back to process.execPath when no standalone manifest exists、以及两条 ancestor-manifest 用例),读起来像是修复本身有问题。真正能存活的变异是更窄的那个:保护读取,但不保护解析。
修复方式:新增一条用例,构造带入口标记的布局但写入非法 manifest,并断言回退:
it('falls back when manifest.json is not parseable JSON', () => {
const root = writeStandaloneLayout({ manifest: { runtime: 'bun' }, withBun: true });
writeFileSync(path.join(root, 'manifest.json'), '{"runtime":"bun"');
expect(resolvedFor(root, 'lib/worker.js')).toEqual(execPathFallback());
});约束:docs/design/bun-runtime-boundary.md 接口约定 §2 第 3 条写明「解析绝不猜测另一个二进制,也绝不抛出异常」,中文孪生文档同样如此表述;修复必须让该性质对解析失败路径也成立,而不只是对套件已覆盖的语义拒绝路径成立——同时不能破坏同一个 catch 目前提供的 ENOENT 回退。
验收标准:当 JSON.parse 外层的保护被收窄掉(保护 readFileSync,但让 JSON.parse(raw) 无保护)时,该新用例必须以 SyntaxError: Unexpected end of JSON input 变红。
— qwen3.8-max via Qwen Code /review (v0.25.1)
There was a problem hiding this comment.
Published follow-up at 8b4a0a25ea (14036-T16).
Three malformed/truncated/empty manifest cases now assert both no throw and the process.execPath fallback, with otherwise valid layouts. Removing the parse guard in an isolated diagnostic copy fails all three new cases (real rc1); these cases also pass in the standard package configuration.
Validation scope: an independent frozen-lock install and local core build enabled two standard package-config runs on macOS arm64 with Node 24.19.0 hosting Vitest 3.2.7 and Bun 1.3.14 child legs: each 35 passed, 0 failed, 0 skipped, actual rc0. globalSetup/test-setup were retained. Earlier missing-build rc1 is historical, not erased. Full-repository build/typecheck and real Linux/Windows remain unverified; the existing hosted-harness CI failures are not waived. Bun as the Vitest host failed despite rc0 and is not a supported pass. Keep this thread unresolved until its original conditions are met.
qqqys
left a comment
There was a problem hiding this comment.
Critical-only scan at fed48b85c8d67172968c51b62cf0c1493dc60665. Not approving. One Critical verified by me directly, a CHANGES_REQUESTED anchored at this exact head, and one ledger-graded Critical that I checked and believe does not hold — recorded here so it does not cost another round.
1. Verified: a required gate is red at this head, caused by these four new files
Lint & Static (ubuntu-latest, Node 22.x) failed in 12m34s. From that job's log:
Run node scripts/lint.js --prettier
Checking formatting...
[warn] docs/design/bun-runtime-boundary.md
[warn] docs/design/bun-runtime-boundary.zh-CN.md
[warn] packages/core/src/utils/runtime-boundary.node-bun.test.ts
[warn] packages/core/src/utils/runtime-info.test.ts
[warn] Code style issues found in 4 files. Run Prettier with --write to fix.
##[error]Process completed with exit code 1.
All four named files are added by this PR, so the failure is unambiguously PR-introduced rather than inherited from main — and the rest of the lane's work passed, since the run reached the prettier step at 00:17:03 and failed there. This is the ledger's R1-1, but I am filing it on the CI log rather than on the ledger: I read the failing job's output myself. npx prettier --write on those four paths should clear it; note that runtime-info.ts is not among them, so the production file is already clean.
Every other lane is green at this head — Test (ubuntu-latest, Node 22.x) (32m9s), Integration Tests (no-AK, No Sandbox), Native Linux CLI boundary, Native Windows settings and streams, arm64, x64, web-shell E2E Smoke, Classify PR, route, assign, label, authorize. So the formatting gate is the only red, and nothing else is masked behind it.
2. The standing CHANGES_REQUESTED is not stale
The round-2 review is anchored at fed48b85 — the current head — so it was filed against exactly the code above, and this repository's ruleset does not dismiss reviews on push. It cannot be treated as superseded by the newer commits, because there are none after it.
3. One ledger Critical I checked and do not believe holds: R1-2
R1-2 is graded C and says the fixture only ever builds the POSIX interpreter layout while interpreterPathForRuntime has a Windows branch. The coverage gap is real — runtime-info.test.ts builds ./bun/bin/bun at lines 129 and 217 and never a win32 layout. But a missing test is not Critical on its own; it is Critical only if the uncovered path contains a provable defect. I went looking for one and did not find it:
const segments =
process.platform === 'win32'
? { bun: ['bun', 'bun.exe'], node: ['node', 'node.exe'] }
: { bun: ['bun', 'bin', 'bun'], node: ['node', 'bin', 'node'] };
return path.join(packageRoot, ...segments[runtime]);That array is a path-segment list spread into one path.join, not an ordered list of candidate filenames. On Windows it produces exactly one path, <root>/bun/bun.exe, which is the right shape for the standalone archive. There is no "tries bun before bun.exe and stops at the first" ordering bug, which is the defect this shape invites you to assume from a grep of line 126 alone — I nearly filed it on that basis.
isExecutableFile is likewise sound on Windows, and not for the reason its win32 line suggests:
if (!fs.statSync(candidate).isFile()) return false; // runs on every platform
if (process.platform === 'win32') return true;
fs.accessSync(candidate, fs.constants.X_OK);The existence-and-is-a-file check runs before the platform branch, so a missing or non-regular candidate is rejected on Windows too; the branch skips only the POSIX execute bit, which is meaningless there. So the documented guarantee — "a directory (or anything non-file) and a missing executable bit on POSIX both reject, so a broken declaration can never reach spawn as EACCES" — matches the code.
The rest of the resolution path is also fail-closed as documented: packageRoot is the parent of the caller's bundle directory with no upward traversal, both manifest.json and the lib/cli-entry.js marker must be present, and any invalid or missing declaration falls back to process.execPath. I found no Critical in runtime-info.ts.
So R1-2 should be a Suggestion — worth adding a win32 fixture case, not worth blocking on. I would rather say that plainly than let a C grade I disagree with stand unchallenged.
4. Ledger Criticals I did not independently verify
R1-3 (the always-run node leg of the SIGTERM test racing the fixture's own handler) and R1-4 (an IPC case asserting a graceful exitCode === 0 after a bare child.kill(), which does not behave that way on Windows) are both graded C at this head and both live in runtime-boundary.node-bun.test.ts. I reached my budget limit after confirming item 1 and checking item 3, so these two are relayed, not reproduced — I have not read the test bodies or confirmed the race and the Windows exit-code claim myself. They are flagged here so they are not lost, and they need an author or maintainer judgement rather than mine. Note that R1-4's premise is at least consistent with the CI picture: no lane on this head runs that file on Windows, so a Windows-only assertion failure would not show up as a red check.
R1-5, the fifth round-1 Critical about an unconditionally stated invariant in the design doc, is absent from the round-2 ledger and I treated it as withdrawn rather than re-verifying it.
Scope disclosure
Read at this head: the complete failing Lint & Static log region; runtime-info.ts in full; the fixture layout and interpreter declarations in runtime-info.test.ts; and the ledger plus review anchoring for all rounds. Not read: runtime-boundary.node-bun.test.ts's test bodies, the two design documents, and the four one-to-three-line call-site edits in code-mode/host-client.ts, hooks/hookRunner.ts, sandbox/file-worker-client.ts and utils/getPty.ts. Those four are the change's actual production blast radius and I have not confirmed what they now call, so this review is not a judgement on them.
Next step: run prettier over the four named paths, then have the round-2 review re-run — that clears item 1, which is the only Critical I can prove. Items in section 4 need a decision from whoever filed them.
中文说明
在 fed48b85 上执行 Critical-only 扫描,不予批准:一条由我直接验证的 Critical、一份锚定在该 head 上的 CHANGES_REQUESTED,以及一条我核过之后认为不成立的 ledger Critical——一并写下,免得再耗一轮。
一、已验证:该 head 上有一条必需门禁是红的,且由本 PR 新增的四个文件造成。 Lint & Static 失败,日志显示 node scripts/lint.js --prettier 报「Code style issues found in 4 files」并逐个列出:两个设计文档(中英)、runtime-boundary.node-bun.test.ts、runtime-info.test.ts。四个文件都由本 PR 新增,因此这次失败明确由本 PR 引入而非继承自 main;该 lane 的其余工作都已完成(运行到 00:17:03 的 prettier 步骤才失败)。对这四个路径执行 prettier --write 即可清除。注意 runtime-info.ts 不在其中,说明生产文件本身格式是干净的。其余 lane 全绿(Test、集成测试、Native Linux/Windows、arm64、x64、web-shell E2E 等),因此这条格式门禁是唯一的红项,没有别的问题被它遮住。这条对应 ledger 的 R1-1,但我依据的是自己读的 CI 日志,不是 ledger。
二、那份 CHANGES_REQUESTED 不是过期结论。 第二轮评审锚定的正是当前 head fed48b85,且本仓库规则集不会因推送而撤销评审;它之后也没有更新的提交,因此不能当作已被超越。
三、我核过之后认为不成立的一条 ledger Critical:R1-2。 它被判为 C,理由是 fixture 只构建 POSIX 解释器布局,而 interpreterPathForRuntime 有 Windows 分支。覆盖缺口是真的(runtime-info.test.ts 第 129、217 行都只建 ./bun/bin/bun),但缺少测试本身不构成 Critical,只有当未覆盖路径里存在可证明的缺陷时才算。我去找了,没找到:那个 win32 数组是被展开进一次 path.join 的路径段列表,不是按顺序尝试的候选文件名列表,在 Windows 上只产出一个路径 <root>/bun/bun.exe,正是标准独立包该有的形状;不存在"先试 bun 再试 bun.exe 并在第一个就停下"的顺序缺陷——而那正是只 grep 第 126 行会诱使人下的判断,我自己差点就这么报上去。isExecutableFile 在 Windows 上也是可靠的,且原因与它那行 win32 判断给人的直觉不同:statSync(...).isFile() 在平台分支之前执行,因此缺失或非普通文件在 Windows 上同样被拒,分支只跳过了在 Windows 上无意义的 POSIX 执行位。所以文档里"目录或非文件、以及 POSIX 上缺执行位都会被拒,坏声明不会以 EACCES 到达 spawn"的保证与代码一致。解析路径其余部分也确实失败即关闭:不做向上遍历、要求 manifest.json 与 lib/cli-entry.js 同时存在、任何无效或缺失声明都回退到 process.execPath。我在 runtime-info.ts 中未发现 Critical。因此 R1-2 应当降为建议项——补一个 win32 fixture 用例值得做,但不值得据此阻塞。与其让一个我不同意的 C 级判定继续挂着,不如直说。
四、我未独立验证的 ledger Critical。 R1-3(SIGTERM 测试中总是运行的 node 分支与 fixture 自身 handler 竞争)与 R1-4(IPC 用例在裸 child.kill() 之后断言 exitCode === 0,而 Windows 上并非如此)都在该 head 上被判为 C,且都位于 runtime-boundary.node-bun.test.ts。我在确认第一条、核完第三条之后到达预算上限,因此这两条是转述而非复现——我没有读测试体,也没有自己确认竞争与 Windows 退出码的说法。列在这里是为了不遗漏,需要作者或维护者判断而非我的判断。R1-4 的前提至少与 CI 现状一致:该 head 上没有 lane 在 Windows 上运行这个文件,因此仅 Windows 触发的断言失败不会表现为红项。第一轮第五条 Critical(R1-5,设计文档中无条件陈述的不变式)未出现在第二轮 ledger 中,我按已撤回处理,未再验证。
审查范围: 在该 head 上读了 Lint & Static 失败日志的相关区段、runtime-info.ts 全文、runtime-info.test.ts 的 fixture 布局与解释器声明,以及各轮的 ledger 与评审锚定。未读:runtime-boundary.node-bun.test.ts 的测试体、两个设计文档,以及 code-mode/host-client.ts、hooks/hookRunner.ts、sandbox/file-worker-client.ts、utils/getPty.ts 四处各一到三行的调用点改动。那四处才是本改动真正的生产影响面,我没有确认它们现在调用的是什么,因此本评审不构成对它们的判断。
下一步: 对日志点名的四个路径跑一次 prettier,再让第二轮评审重跑——这能清掉唯一一条我能证明的 Critical。第四节的条目需要由提出者决定。
qwen-code-dev-bot
left a comment
There was a problem hiding this comment.
REQUEST_CHANGES at head fed48b85c8d6 — one PR-caused required gate is red, and three of the round-2 Criticals hold
Reviewed head: fed48b85c8d67172968c51b62cf0c1493dc60665, state open, author chiga0, base main. Nine files, +961/−6. CI is complete at this head (nothing pending), so this is a decision rather than a hold.
Two things this review adds beyond what is already on the PR: I reproduced three of the round-2 Criticals against the code myself (§2–§4) — the previous Critical-only scan explicitly relayed R1-3 and R1-4 without reproducing them — and I read the four production call-site edits that scan disclosed it had not read, and found them safe (§6). That narrows what actually has to change.
1. Blocking, and independently confirmed from the failing job: the Prettier gate is red because of this PR's own four new files
Lint & Static (ubuntu-latest, Node 22.x), job 116172043111. The lane reached its last lint stage and failed there; ESLint, actionlint, shellcheck and yamllint all passed before it:
##[group]Run node scripts/lint.js --prettier
Running Prettier...
Checking formatting...
[warn] docs/design/bun-runtime-boundary.md
[warn] docs/design/bun-runtime-boundary.zh-CN.md
[warn] packages/core/src/utils/runtime-boundary.node-bun.test.ts
[warn] packages/core/src/utils/runtime-info.test.ts
[warn] Code style issues found in 4 files. Run Prettier with --write to fix.
##[error]Process completed with exit code 1.
All four paths are added by this PR, so the failure is unambiguously PR-introduced rather than inherited. This is the ledger's R1-1, filed here on the job log rather than on the ledger. Fix: npx prettier --write over those four paths (or npm run format). Note runtime-info.ts is not among them — the production file is already clean.
Everything else substantive is green at this head: 475 check-run records (pages 1–4 at 100 each, page 5 at 75, page 6 empty, so the rollup is complete), 11 substantive groups = 7 success / 3 skipped / 1 failure / 0 cancelled / 0 pending, including Test (ubuntu-latest, Node 22.x), Integration Tests (no-AK), Native Linux CLI boundary, Native Windows settings and streams, arm64, x64 and web-shell E2E Smoke. Nothing is masked behind the formatting red.
2. Blocking: R1-3 is a real ordering race in the test this PR adds, and it runs on the always-green Linux lane
I verified the mechanism by reading, not by re-running the filer's measurements.
The fixture writes its identity line to stdout first and registers its handler afterwards — runtime-boundary.node-bun.test.ts:35-42 emits the identity object, and process.on('SIGTERM', …) is not installed until :51. The parent resolves as soon as any non-empty line has arrived:
await new Promise<void>((resolve) => {
child.stdout!.on('data', () => { if (lines.length > 0) resolve(); });
});and then kills immediately (:142-143: const lines = await collectIdentityLines(child); child.kill('SIGTERM');). Arming a libuv signal watcher on the first listener is not free, so the signal can land before the handler exists and the default disposition kills the child. All three assertions then fail together (termLine undefined at :150, exitCode not 0 at :152, signal not null at :153) with nothing pointing at the parent's ordering.
Why this one matters more than the other two: its only guard is { skip: process.platform === 'win32', timeout: 30_000 } at :137, so the node leg executes on every Linux and macOS core unit run. Test (ubuntu-latest) is green at this head, which does not refute the race — it is probabilistic, and the filer's own idle measurement was 60/60 passing before degrading under load. A flake in the one lane that always runs is the worst place to leave one.
Expected fix: have the fixture register process.on('SIGTERM') before writing its identity line, so the identity line is proof the handler is armed. Awaiting 'close' instead of 'exit' is not sufficient on its own — the filer's harness reports that variant still failing.
3. Blocking: R1-4 asserts a graceful exit that Windows cannot produce, and unlike its sibling it does not opt out
runtime-boundary.node-bun.test.ts:157-181. The IPC case spawns with { timeout: 30_000 } and no skip, then does if (type === 'pong') child.kill(); (:171) and asserts expect(exitCode).toBe(0) (:179). On Windows a bare kill() cannot deliver a catchable SIGTERM — the child is terminated directly, the fixture's handler never runs, and the reported code is null with signalCode 'SIGTERM'.
grep -n "process.platform === 'win32'" over this file returns exactly one hit, at :137 — the neighbouring SIGTERM test. So this is an inconsistency inside a single file, not a deliberate platform claim. The platform authority is this repository's own passing assertion in packages/cli/src/serve/cdp-tunnel/acceptance/acceptance-helpers.test.ts:92-97, which documents that kill('SIGTERM') terminates the child directly on Windows.
Expected fix: end the child cooperatively so the exit code is genuinely 0 — send an IPC message the fixture handles by exiting cleanly — rather than skipping, since the IPC round-trip is exactly what this case exists to pin and it does pass on Windows. If a skip is preferred, it must be justified rather than merely matching :137.
4. Blocking: R1-2 — the new positive-resolution tests cannot pass on Windows
The previous scan downgraded this to a coverage Suggestion, arguing that the win32 segment array is a path-segment list spread into one path.join and therefore has no candidate-ordering bug. That refutation is correct, and R1-2 never claimed an ordering bug. Its claim is about the test file, and it holds. I verified both halves:
runtime-info.ts:124-128—process.platform === 'win32' ? { bun: ['bun','bun.exe'], node: ['node','node.exe'] } : { bun: ['bun','bin','bun'], node: ['node','bin','node'] }, spread intopath.join(packageRoot, ...segments[runtime]). On Windows this yields the single path<root>/bun/bun.exe— nobin/segment, which is the correct standalone-archive shape.runtime-info.test.ts:57and:66build onlypath.join(root,'bun','bin','bun')andpath.join(root,'node','bin','node'), and:111/:133assertcommand: path.join(root,'bun','bin','bun').
So on Windows the resolver looks for <root>/bun/bun.exe, the fixture never creates it, isExecutableFile returns false, getJsInterpreterCommand falls back to process.execPath (:174-177), and both positive-resolution assertions fail on every run. Two further cases pass there vacuously: falls back when the declared interpreter is not executable succeeds because the .exe is absent rather than because the 0o644 chmod was rejected — isExecutableFile:107-110 runs statSync().isFile() before the platform branch and then return true on win32 without calling accessSync — and memoizes the resolution memoizes a failed resolution.
I agree with the previous scan that runtime-info.ts itself is sound: no upward traversal, both manifest.json and the lib/cli-entry.js marker required, and every rejection path fail-closed to process.execPath. The defect is that this PR adds tests that are deterministically red on a platform this repository runs. Test (windows-latest, Node 22.x) is skipped at PR level on this head, so PR CI will never show it — it surfaces on the nightly, which the workflow comments describe as the only thing keeping the non-Linux lanes visible. Turning the repository's only Windows signal permanently red, silently, is not a coverage nicety.
Expected fix: build the platform-appropriate layout in the fixture (branch the interpreter path on process.platform the same way interpreterPathForRuntime does), or gate the POSIX-shaped cases and add a win32-shaped one. Whichever is chosen, the two positive-resolution cases must assert a path the resolver on that platform can actually produce.
5. R1-5 was not withdrawn
The previous scan treated R1-5 as withdrawn because it is absent from the round-2 ledger's findings array. It is not withdrawn: the review body carries it under "Unresolved, please confirm" as [Critical], and there is an unresolved thread at docs/design/bun-runtime-boundary.md:127. All 16 threads on this PR are unresolved and none is outdated.
I did not independently verify R1-5 and am not asserting it. Its substance is that the design doc states an invariant unconditionally while the shipped resolver returns process.execPath on every rejection path, that the doc's stated remedy (a manifest interpreter key) has no producer in writeManifest, and that bwrap-execution.ts:41 / landlock-execution.ts:113 stage realpathSync(process.execPath) as the outer relay interpreter while the migrated file-worker-client.ts now supplies only the inner command. I can confirm the last premise's precondition — file-worker-client.ts:39 did change from executable: process.execPath to executable: getJsInterpreterCommand(import.meta.url).command — but I did not read the bwrap/landlock staging code, so the consequence is the filer's claim, not mine. Author: either fix the doc's unconditional wording or have the filer withdraw it. I am not gating on my own reading of it.
6. What I verified as safe — the production blast radius, which nobody had read
The previous scan disclosed it had not read the four call-site edits and therefore offered no judgement on them. They are the whole of this change's production surface (11 lines), and I found no Critical in them:
code-mode/host-client.ts:54resolvesconst { command } = getJsInterpreterCommand(import.meta.url)once and substitutes it forprocess.execPathin all three returns (.ts/tsx branch, siblinghost.js, bundledcodeModeHost.js). Resolving before the branch is harmless: the call is memoized and, in a source layout, falls back toprocess.execPath.hooks/hookRunner.ts:1258andsandbox/file-worker-client.ts:39make the same one-for-one substitution.utils/getPty.ts:46replaces'bun' in process.versionswithisBunRuntime(), which istypeof process.versions['bun'] === 'string'(runtime-info.ts:64-66). That is stricter than theincheck — it also rejects a present-but-non-string value — and agrees with it under both Bun and Node, so the PTY gate is unchanged.
The property that makes all four safe today is getJsInterpreterCommand's fail-closed shape (runtime-info.ts:155-179): packageRoot is the parent of the caller's bundle directory with no upward traversal, both manifest.json and the lib/cli-entry.js marker must be present, the candidate must pass isExecutableFile, and every rejection path returns { command: process.execPath, runtime: isBunRuntime() ? 'bun' : 'node' }. In npm, source and SDK layouts that is exactly the old value, so the substitution is behaviour-preserving. Test (ubuntu-latest) and the four native/platform lanes being green is consistent with that.
Already reported and therefore not repeated here: path.resolve(packageRoot, manifest.interpreter) at :167 letting an absolute declared interpreter escape the trusted root, and isBunRuntime overlapping the existing detectRuntime. Both are in the round-2 review's already-reported list; neither is exploitable today because nothing produces an interpreter key.
7. Not my gate
The round-2 ledger's ten sev:"S" findings (R1-6, R1-7, R1-8, R1-12, R1-13, R1-16, R1-17, R1-18, R1-20, R2-1, R2-2) are test-quality, fixture-API and design-doc-accuracy items. I am not adjudicating them and not adding to them. Two are worth the author's attention while the test files are open anyway — R1-7 (neither async matrix leg reaps its spawned child on a failure path) and R1-8 (the console.info this test exists to emit never reaches a run log) — but they are not conditions of my approval.
What I need to submit APPROVE
npx prettier --writeon the four named paths soLint & Staticgoes green (§1).- R1-3's fixture ordering fixed (§2) — this is the one that can flake the always-run lane.
- R1-4's IPC case ending the child cooperatively, or a justified skip (§3).
- R1-2's fixture made platform-correct so the two positive-resolution cases can pass on Windows (§4).
- R1-5 either addressed in the design doc's wording or withdrawn by its filer (§5).
Items 1–4 are all in files this PR adds, so none of them touches the production surface, which I found sound. With those done and CI green at the new head, re-verified at submit time, I will APPROVE.
Fixes the failing Lint & Static lane: `prettier --experimental-cli --check .` ([email protected], the lockfile resolution) rejects the two bun-runtime-boundary design docs and the two runtime-info test files introduced by the runtime boundary change. Formatting only — markdown table alignment, emphasis markers and code line wrapping; no content or behavior changes.
qwen-code-dev-bot
left a comment
There was a problem hiding this comment.
Gate re-check at head b85a12ad48c3 — no verdict submitted (every substantive CI lane is cancelled)
Reviewed head: b85a12ad48c3e7aaed4cf46f20e2cba1659a72f2, state open, author chiga0, base main. Nine files, +1202/−6. This supersedes my REQUEST_CHANGES 5532548670, which was pinned to fed48b85c8d6.
This is a COMMENT, not a decision. Four of the five items I gated on are fixed and I verified each in the code at this head (§2); the fifth is applied but cannot be confirmed because nothing ran (§1). I am not submitting APPROVE because CI is cancelled, and not submitting REQUEST_CHANGES because there is no longer a code blocker to request changes against. The single outstanding action is to re-run the cancelled workflows.
1. Every substantive lane at this head is cancelled — there is no CI evidence at all
84 check-run records, page 2 empty (fetch complete). Excluding bot/automation groups: 11 substantive groups = 0 success / 3 skipped / 0 failure / 8 cancelled / 0 pending.
Two whole runs were cancelled roughly ninety seconds after starting, both at this head, both attempt=1, both event: pull_request:
| Run | Workflow | Conclusion | Started | Groups it carried |
|---|---|---|---|---|
38760685365 |
Qwen Code CI |
cancelled |
15:28:51Z | Test (ubuntu), Lint & Static, Integration Tests (no-AK), web-shell E2E Smoke |
38760685361 |
Verify Landlock helper |
cancelled |
15:28:51Z | Native Linux CLI boundary, Native Windows settings and streams, arm64, x64 |
Qwen Autofix (run 38761063427, triggered by pull_request_review) was cancelled too. The bot/automation runs on this head all succeeded, so this is specific to the substantive workflows. The head has not moved since, so the cancellations were not caused by a newer commit on this PR; I cannot determine the actor from the API and am not guessing.
Two consequences worth stating plainly:
- My item 1 (Prettier) is now unverifiable. Commit
6bfa0a2fdb76is titledstyle: apply prettier to the bun boundary docs and runtime tests, which is the right fix for the four[warn]paths I quoted from job116172043111. But the lane that would confirm it —Lint & Static— is cancelled, and I will not run Prettier myself and present that as the gate. So this item is addressed by the author, unconfirmed by CI. - My cancelled-lane blind spot is worth recording: my red-lane filter matches
failure|timed_out|action_required|startup_failureand does not matchcancelled, so an aggregate "0 failures" reading of this head would have been misleading. The per-group listing is what shows0 success / 8 cancelled. Gate 3 treats cancelled as not-green regardless.
2. Four of my five blocking items are fixed — verified in code, not inferred from commit titles
Item 2 — R1-3, the SIGTERM ordering race. Fixed, and on both sides of the race. The fixture now registers its handler before announcing itself:
process.on('SIGTERM', () => { // :34
process.stdout.write(JSON.stringify({ got: 'SIGTERM' }) + '\n');
process.exit(0);
});
const runtime = process.isBun ? 'bun' : 'node';
process.stdout.write(JSON.stringify({ runtime, … })); // :39 identity lineSo the identity line the parent waits on is now proof the handler is armed, which was exactly the invariant I asked for. The parent side is fixed too: const closed = waitForClose(child); is subscribed before child.kill('SIGTERM') (:210-212), removing the second half of the race — awaiting a promise created after the kill could miss the event. The case keeps skip: process.platform === 'win32' and still asserts all four properties (termLine defined, payload {got:'SIGTERM'}, exitCode === 0, signal === null).
The supporting rewrite is also sound. collectIdentityLines (:121-157) buffers partial lines, and routes four termination paths through one done() — child/stdout/stderr error, stdout close before an identity line ('Child closed before identity line'), a 5 s timer ('Timed out waiting for child identity'), and the first complete line — where done() clears the timer and removes every listener, so it cannot double-settle or leak. That converts a silent hang into a diagnosable failure, which is what commit 8b4a0a25ea2b claims. waitForClose (:85-97) bounds itself with AbortSignal.timeout(5000) and forwards stream errors to the child's error event, detaching in .finally().
Item 3 — R1-4, the IPC case asserting a graceful exit after child.kill(). Fixed the better of the two ways I offered. The child is now ended cooperatively: if (type === 'pong') child.send({ type: 'shutdown' }); (:237), and the fixture handles it — if (message && message.type === 'shutdown') process.exit(0); (:50). So expect(exitCode).toBe(0) is true on every platform rather than only where SIGTERM is catchable, and a new expect(signal).toBeNull() was added. Crucially the case still carries no win32 skip ({ timeout: 30_000 } only), so the IPC round-trip — the thing the test exists to pin — remains covered on Windows instead of being skipped away. child.kill() no longer appears in this file's IPC path at all.
Item 4 — R1-2, the POSIX-only fixture. Fixed, and it matches the resolver exactly. runtime-info.test.ts:36-37 now builds process.platform === 'win32' ? path.join(root, runtime, \${runtime}.exe`) : …, which is precisely the single path interpreterPathForRuntime produces on Windows (path.join(packageRoot, 'bun','bun.exe') — a segment list spread into one join, not a candidate list). The declared-interpreter cases branch the same way (:133 './bun/bun.exe'vs'./bun/bin/bun', :220 './bun'vs'./bun/bin'), and the chmod-based case now carries { skip: process.platform === 'win32' } (:229) — which is the honest treatment, since isExecutableFilereturnstruefor any regular file on win32 without callingaccessSync`, so that case could only ever pass vacuously there. The two positive-resolution assertions can now pass on Windows instead of failing on every run.
Item 5 — R1-5, the unconditionally stated invariant. Addressed by scope limitation, which was one of the two options I gave. docs/design/bun-runtime-boundary.md:189-194 now reads:
Supported scope: interpreter-based Node/Bun distributions. Rejection returns
process.execPath, which would be the application binary in a compiled build. This PR does not support compiled applications or provide a compiled-artifact producer. That future flavor needs explicit interpreter packaging and separately verified failure behavior before adoption; the present fallback does not guarantee a usable interpreter in that flavor.
That retracts the exact over-claim the finding named. The inventory was corrected to match: bwrap-execution.ts:41, landlock-execution.ts:113 and hook-command-cgroup.ts:166 are each listed as not migrated (S3) with their platform guard named, and runtime-info.ts:175 as "Interpreter resolver fallback: host executable on rejected/missing manifest; implemented S1, compiled flavor unsupported". The doc no longer certifies a property the code does not provide.
Item 1 — Prettier. Commit 6bfa0a2fdb76 applies it to the docs and runtime tests. Unconfirmed, for the reason in §1.
Also fixed, though I had listed it as non-blocking: R1-7's unreaped children. Both async cases now wrap their body in try { … } finally { await cleanupChild(child); }, and cleanupChild (:100-119) SIGKILLs only when pid !== undefined && exitCode === null && signalCode === null, awaits close with a 2 s bound, then destroys all three stdio streams and disconnects the IPC channel.
3. The production surface is byte-identical, so my previous clearance carries over validly
I did not assume this. Comparing fed48b85c8d6...b85a12ad48c3 and filtering to the five production paths (code-mode/host-client.ts, hooks/hookRunner.ts, sandbox/file-worker-client.ts, utils/getPty.ts, utils/runtime-info.ts) yields zero differing files. Everything that changed is test code and design docs. So §6 of my previous review still holds on evidence rather than by assumption: the four call-site substitutions are behaviour-preserving because getJsInterpreterCommand (runtime-info.ts:155-179) is fail-closed to process.execPath on every rejection path, and isBunRuntime() (typeof process.versions['bun'] === 'string') is stricter than the 'bun' in process.versions it replaced.
No new Critical in the ~124 new test lines or ~119 new doc lines either. The runtimes array now includes 'bun' only when spawnSync(bunBin, ['--version']) succeeds, so the Bun leg still does not execute in a gating CI run — that is the previously-reported Suggestion about the Bun leg, unchanged in substance, and not something I am gating on.
4. Thread state, and what I am not adjudicating
16 threads: 1 resolved, 15 unresolved, 10 outdated. The outdated count is expected — four fix commits moved the anchored lines. I have not re-adjudicated the ten round-2 sev:"S" findings (R1-6, R1-8, R1-12, R1-13, R1-16, R1-17, R1-18, R1-20, R2-1, R2-2); my previous review already recorded them as author's and maintainer's discretion rather than conditions of my approval, and nothing in this round changes that. Two of them (R1-7's reaping, and the doc-accuracy family R1-12/R1-13/R1-18) appear to have been addressed in passing by 3553ca57be25 and b85a12ad48c3, but I have not verified each and am not claiming it.
5. What I need to submit APPROVE
- Re-run the two cancelled workflows —
Qwen Code CI(run38760685365) andVerify Landlock helper(run38760685361) — and let them complete.Lint & Staticis the one that settles my item 1;Test (ubuntu)is the one that exercises the reordered SIGTERM fixture on the always-run lane. - Head still
b85a12ad48c3when they land, re-verified at submit time.
Nothing else. On the code, items 2–5 are verified fixed and I found no Critical, so a green re-run is the only thing standing between this head and an APPROVE. Note for merge planning: /packages/core/ is CODEOWNERS-covered (@wenshao @tanzhenxin @yiliang114 @LaZzyMan @doudouOUC @qqqys) and qwen-code-dev-bot is not in that list, so my approval will not by itself move reviewDecision to APPROVED — and @wenshao's CHANGES_REQUESTED from 5422df5b46f9 still stands and is theirs to clear.
qqqys
left a comment
There was a problem hiding this comment.
APPROVE at head b85a12ad48c3e7aaed4cf46f20e2cba1659a72f2 — the five blocking items carried at fed48b85c8 are all resolved, and an independent Critical-only scan of this head found none.
Everything below was verified against the current head's file contents, not against thread state. Note that 15 of this PR's 16 review threads still read isResolved: false, but every one of the five Criticals among them is in fact fixed; the remaining unresolved threads are Suggestions, which are not a gate here.
1. Prettier gate (R1-1) — fixed
Ran the repository's own Prettier (3.5.3 per package.json, with .prettierrc.json) over all four previously-flagged added files plus runtime-info.ts, fetched at this head:
Checking formatting...
All matched files use Prettier code style!
6bfa0a2fdb applied the formatting, and the three later test-only commits did not reintroduce a violation. CI cannot corroborate this at this head — see §7 — so this was checked directly rather than inferred from a lane.
2. SIGTERM ordering race (R1-3) — fixed
The fixture now installs its handler before emitting the identity line, so the identity line is proof the handler is armed:
process.on('SIGTERM', () => {
process.stdout.write(JSON.stringify({ got: 'SIGTERM' }) + '\n');
process.exit(0);
});
const runtime = process.isBun ? 'bun' : 'node';
process.stdout.write(JSON.stringify({ runtime, /* … */ }) + '\n');The test also stops racing close: it registers const closed = waitForClose(child) before child.kill('SIGTERM') and awaits it. And collectIdentityLines no longer resolves silently on a dead child — it rejects on child error, on stdout error, on stdout closing before any identity line, and on a 5 s timeout, with all four listeners removed in done(). cleanupChild in finally reaps the child with SIGKILL if it is still live. This removes the flake from the node leg that runs on every Linux and macOS core unit run.
3. IPC graceful exit (R1-4) — fixed
The child now ends cooperatively instead of being killed. The fixture handles message with {type:'shutdown'} → process.exit(0) and replies pong to ping; the parent sends ping on ready and shutdown on pong, then asserts types === ['ready','pong'], exitCode === 0, signal === null. No bare child.kill() remains in that case, so the assertion no longer depends on a POSIX exit-code shape that Windows does not provide.
4. Platform-correct fixture layout (R1-2) — fixed
runtime-info.test.ts now builds the layout the resolver actually looks for on each platform, mirroring interpreterPathForRuntime:
const interpreterPath = (root: string, runtime: 'bun' | 'node'): string =>
process.platform === 'win32'
? path.join(root, runtime, `${runtime}.exe`)
: path.join(root, runtime, 'bin', runtime);Both positive-resolution cases (resolves the bundled Bun interpreter…, …Node interpreter…) assert command: interpreterPath(root, …) rather than a hardcoded POSIX path, and the lib/chunks matrix case does the same. The explicit-interpreter case and the directory case branch on platform too.
Critically, falls back when the declared %s interpreter is not executable is now gated { skip: process.platform === 'win32' }. That case relied on a 0o644 chmod being rejected, which cannot happen on Windows: isExecutableFile runs statSync().isFile() first and then return true on win32 without ever calling accessSync. Previously it passed there vacuously — because the .exe was absent, not because the permission was refused. Gating it is the correct resolution, and the two positive cases can now genuinely pass on a Windows runner instead of being deterministically red on the nightly.
5. Design-doc invariant (R1-5) — addressed
The invariant is no longer stated unconditionally. docs/design/bun-runtime-boundary.md §2 now scopes it:
Supported scope: interpreter-based Node/Bun distributions. Rejection returns
process.execPath, which would be the application binary in a compiled build. This PR does not support compiled applications or provide a compiled-artifact producer. That future flavor needs explicit interpreter packaging and separately verified failure behavior before adoption; the present fallback does not guarantee a usable interpreter in that flavor.
That covers both halves of the finding. The absent interpreter producer is now disclosed rather than implied — the doc no longer presents a manifest remedy this PR cannot emit. And the sandbox relay premise is pinned in the inventory as not migrated: sandbox/bwrap-execution.ts:41 and sandbox/landlock-execution.ts:113 are both listed as "Interpreter: realpath staging for JS relay; not migrated (S3)", so the doc does not claim a completed boundary across the outer relay while only the inner command was rewired. §2.2 also now states the Windows validation limit explicitly ("Windows checks regular-file existence only, not PE validity or launchability"), which is exactly what isExecutableFile implements.
6. Independent Critical-only scan at this head — no Critical
I read the whole production surface (11 lines across four call sites, plus the new 186-line resolver) rather than relying on the earlier verification of it.
runtime-info.ts is fail-closed on every path:
parseStandaloneManifestwrapsreadFileSync/JSON.parseintry/catchand returnsundefined, then rejects non-objects,null, arrays, anyruntimeother than exactly'bun'/'node', and a non-stringinterpreter.packageRoot = path.dirname(resolveBundleDir(importMetaUrl))— no upward traversal, so an unrelated ancestormanifest.jsoncan never be adopted.- Both
manifest.jsonand thelib/cli-entry.jsmarker must be present. isExecutableFilerequires a regular file, plusX_OKon POSIX.- Every rejection path returns
{ command: process.execPath, runtime: isBunRuntime() ? 'bun' : 'node' }.
The four call sites are behaviour-preserving substitutions, and because of that fail-closed shape they return exactly the previous value in npm, source and SDK layouts:
code-mode/host-client.ts:54resolvesconst { command } = getJsInterpreterCommand(import.meta.url)once, before the branch, and substitutes it into all three returns (.ts/tsx branch, siblinghost.js, bundledcodeModeHost.js). Resolving early is harmless — the call is memoized and the source layout falls back.hooks/hookRunner.ts:1258andsandbox/file-worker-client.ts:39are one-for-one replacements ofprocess.execPath.utils/getPty.ts:46replaces'bun' in process.versionswithisBunRuntime(), i.e.typeof process.versions['bun'] === 'string'. That is strictly narrower — it also rejects a present-but-non-string value — and agrees with the old check under both Node and Bun, so the PTY gate is unchanged.
Two already-reported items remain Suggestions and I am not gating on them: path.resolve(packageRoot, manifest.interpreter) at :167 would honour an absolute declared path escaping the trusted root, but the declaring manifest must already sit inside that root beside the entry marker (so it confers no privilege the writer does not already have) and nothing produces an interpreter key today; and the memoization ignores importMetaUrl after the first call, which is harmless while all three migrated callers live in packages/core and share one package root.
7. CI at this head — cancelled, no signal, not a gate
Both substantive runs for b85a12ad48 — 38760685365 and 38760685361, created 2026-10-15T15:28:51Z — completed with conclusion cancelled; the later pull_request_review runs are skipped. So no lane executed this head, and the fail entries a checks listing shows for it are cancellation artifacts, not test failures. I did not wait for, poll, or re-trigger CI, and a cancellation is not attributable to this PR.
Flagging for the author, non-blocking: since no lane ran this head, the two new suites are unexecuted by CI here. A green CI run would be the natural confirmation before merge, and would independently corroborate §1.
yiliang114
left a comment
There was a problem hiding this comment.
APPROVE at head b85a12ad48c3e7aaed4cf46f20e2cba1659a72f2
No P0/P1 findings. I took each standing Critical and checked it against the code as it stands at this head, and I ran the two new test files rather than reasoning about them.
1. The four round-2 Criticals are all fixed at this head
| ID | Claim (at fed48b85) |
State at b85a12ad |
|---|---|---|
| R1-1 | Four added files fail prettier --check, red required gate |
Fixed. Repo-locked prettier 3.6.1 --check over all nine changed files: All matched files use Prettier code style! |
| R1-2 | Fixture only builds the POSIX layout, so the win32 positive-resolution tests cannot pass | Fixed. interpreterPath in runtime-info.test.ts:39-42 is now platform-aware and matches interpreterPathForRuntime on both branches. |
| R1-3 | SIGTERM test races the fixture's own handler registration | Fixed, and by the prescribed mechanism. The fixture now installs process.on('SIGTERM', …) as its first statement, before writing the identity line, and the parent awaits collectIdentityLines(child) before child.kill('SIGTERM'). The identity line is therefore proof the handler is armed. |
| R1-4 | IPC case asserts exitCode === 0 after a bare child.kill(), which Windows cannot produce |
Fixed, cooperatively rather than by skipping. The bare kill() is gone; the test sends {type:'shutdown'} and the fixture exits via process.exit(0), so the asserted code is genuinely produced on every platform. |
Round-2 Suggestions R2-1 and R2-2 are covered too — resolves %s from a standalone lib/chunks entry exercises the bundle-dir shape the three migrated callers actually have, and falls back on malformed manifest %j covers the branch carrying the "never throws" guarantee.
For R1-2 I checked the producer, not just the consumer, because that is the half that decides whether the resolver is right: scripts/create-standalone-package.js writes bun/bun.exe / node/node.exe for win-x64 (lines 935, 973, 1036) and bun/bin/bun / node/bin/node for POSIX (lines 991, 1017), and writeManifest emits runtime at the package root (line 1060) next to the lib/cli-entry.js marker (line 1029). interpreterPathForRuntime's segment arrays match that layout exactly on all four combinations. Per AGENTS.md, a missing test is a Suggestion rather than a Critical in any case — but here the coverage now exists.
2. Executed evidence
CI on this head is cancelled, not failed — run 38760685365 (Qwen Code CI, created 15:28:51Z, closed 15:30:40Z) has every substantive lane cancelled or skipped. gh pr checks renders those as fail, so I went to the check-runs API for the real conclusion. A cancelled lane is absent signal, not a red light, and it is not a code finding — but it does mean nothing upstream certifies these tests, so I ran them myself at this head:
✓ src/utils/runtime-info.test.ts (22 tests) 31ms
[runtime-boundary] bun leg ran with bun 1.4.2
✓ src/utils/runtime-boundary.node-bun.test.ts (13 tests) 2627ms
Test Files 2 passed (2)
Tests 35 passed (35)
The Bun leg actually executed rather than skipping, which is the part worth having: JSON framing, exit-code propagation, SIGTERM, the IPC round-trip, --expose-gc and --input-type=commonjs --eval all matched across Node and Bun 1.4.2. I ran these through a config scoped to the two added files; neither imports a workspace package through its built dist/, which is the only thing packages/core's globalSetup guard protects, so nothing was bypassed that bears on these results.
3. Why I am satisfied the production blast radius is safe
The four call-site edits are the whole production surface, so I checked whether any of them can change behaviour today. In every layout that actually ships, the resolved interpreter is process.execPath:
- standalone:
bin/qwenexecs$ROOT/bun/bin/bun(or$ROOT/node/bin/node) on$ROOT/lib/cli-entry.js, soprocess.execPathis already that same bundled binary — the resolver returns the path the process was launched with; - npm / source / SDK: no
manifest.jsonbesidelib/cli-entry.jsat the package root, so it falls back toprocess.execPath.
The resolver is also fail-closed on every input I could reach: packageRoot is dirname(resolveBundleDir(...)) with no upward traversal, both the manifest and the entry marker must be present, runtime must be exactly 'bun' or 'node', and isExecutableFile runs statSync(...).isFile() before the win32 branch — so a directory or a missing file rejects on Windows too, and the branch skips only the POSIX execute bit. Nothing invalid reaches spawn.
That makes this a boundary refactor that does not yet move any boundary, which is what the description claims. The remaining inline notes are forward-looking precision, not blockers.
中文说明
在 head b85a12ad 上批准,无 P0/P1。
一、四条 round-2 Critical 在本 head 全部已修。 R1-1:用仓库锁定的 prettier 3.6.1 对九个改动文件跑 --check,全部通过。R1-2:runtime-info.test.ts:39-42 的 interpreterPath 已按平台分支,与 interpreterPathForRuntime 两侧一致;我另外核了生产侧——create-standalone-package.js 对 win-x64 写 bun/bun.exe/node/node.exe(935、973、1036 行),POSIX 写 bun/bin/bun/node/bin/node(991、1017 行),writeManifest 在包根写 runtime(1060 行)并与 lib/cli-entry.js 标记(1029 行)共存,四种组合与解析器完全对得上。R1-3:fixture 现在把 process.on('SIGTERM') 放在写身份行之前,父进程先 await collectIdentityLines 再 kill——正是评审要求的修法,身份行成了 handler 已装载的证明。R1-4:裸 child.kill() 已删除,改为发 {type:'shutdown'} 由 fixture process.exit(0),断言的退出码在每个平台都真实产生,而不是靠 skip 绕过。R2-1、R2-2 两条 Suggestion 也已补上用例。
二、实跑取证。 本 head 的 CI 是 cancelled 而非 failed(run 38760685365,每条实质 lane 都是 cancelled/skipped),gh pr checks 会把它渲染成 fail,所以我读的是 check-runs API 的真实结论。被取消的车道是「没有信号」,不是红灯,也不构成代码缺陷;但既然上游没有任何东西为这两个测试作证,我在本 head 自己跑了一遍:两个文件 35 条全绿,且 Bun 那条腿是真跑(bun 1.4.2)而不是 skip——JSON 分帧、退出码传播、SIGTERM、IPC 往返、--expose-gc、--input-type=commonjs --eval 在 Node 与 Bun 上一致。我用的是只圈这两个新增文件的 config;它们都不通过 workspace 包的 dist/ 导入任何东西,而那正是 core 的 globalSetup 守卫唯一防的东西,所以没有绕过任何与结果相关的门禁。
三、生产影响面为什么可以放心。 四个调用点就是全部生产改动。在今天真实存在的每一种布局里,解析出来的解释器就是 process.execPath:standalone 的 bin/qwen 本来就用 $ROOT/bun/bin/bun(或 $ROOT/node/bin/node)exec $ROOT/lib/cli-entry.js,所以 process.execPath 已经是同一个内置二进制;npm/源码/SDK 布局下包根没有 manifest.json 与 lib/cli-entry.js 共存,直接回退。解析器在我能触达的每种输入上都是 fail-closed:packageRoot 无向上遍历、manifest 与入口标记必须同时在、runtime 必须恰为 'bun' 或 'node',而 isExecutableFile 把 statSync(...).isFile() 放在 win32 分支之前,因此目录与缺失文件在 Windows 上同样被拒,该分支只跳过 POSIX 执行位。无效声明到不了 spawn。
也就是说这是一次「先把边界画出来、暂时不移动边界」的重构,与 PR 正文的自述一致。行内几条都是面向后续阶段的精确性提醒,不阻塞合并。
| /** Absolute path of a binary that can run arbitrary JS files. */ | ||
| command: string; | ||
| /** Which runtime the command will execute the child with. */ | ||
| runtime: JsRuntime; |
There was a problem hiding this comment.
[P3, non-blocking] One thing I noticed here: runtime has no production read site. All three migrated callers destructure command only (host-client.ts:54, file-worker-client.ts:39, hookRunner.ts:1258), so today the field is written and asserted by tests but never consumed.
Not asking you to remove it — it is the obvious handle for the S3 sandbox work and for the launcher/interpreter divergence this doc is written around. Just flagging it against the repo's own "grep the read sites of every added field" rule, so it lands as a deliberate forward declaration rather than something a later reader has to reverse-engineer. If S3 is where it gets consumed, saying so in the field comment would close the loop.
There was a problem hiding this comment.
Implemented in 0f4c38242c, directly on top of e5270fbc.
Clarified the returned runtime field as metadata: all three current production callers consume only command. Runtime-specific consumer behavior, including any future S3 use, is not implemented here. The English and Chinese design docs now state the same boundary.
This is the unchanged four-file documentation/comment increment reviewed independently by two agents; it is being delivered on top of the current PR history. Four reviewed post-images match exactly, both source files have identical non-comment tokens, and project Prettier plus diff checks returned 0. No suite/build rerun was needed for this comment-only change. Current-head CI acceptance and the existing runtime/platform gates remain pending; leaving this thread unresolved.
| fs.existsSync(path.join(packageRoot, ...STANDALONE_ENTRY_MARKER.split('/'))) | ||
| ) { | ||
| const candidate = manifest.interpreter | ||
| ? path.resolve(packageRoot, manifest.interpreter) |
There was a problem hiding this comment.
[P3, non-blocking] Might be worth tightening the wording, not the code. path.resolve(packageRoot, manifest.interpreter) returns an absolute interpreter verbatim, so a value like /opt/other/bin/node is honoured as-is. The doc comment above says "the interpreter field resolved against the package root", which reads as containment that path.resolve does not actually provide.
I want to be explicit that I do not think this is a security hole and I am not requesting a guard: the manifest only counts when it sits at the caller's own installation root and lib/cli-entry.js is beside it, and anyone who can write that manifest can equally replace bun/bin/bun. There is no privilege boundary being crossed. It is purely that the sentence promises an anchoring the call does not enforce — either say "resolved against the package root, or used as-is when absolute" or clamp it. Your call.
There was a problem hiding this comment.
Implemented in 0f4c38242c, directly on top of e5270fbc.
Took the wording-only option: the function comment and both design docs now explicitly say absolute interpreter paths are used as-is, without containment. Relative paths are resolved against the installation root. No guard or runtime behavior was changed, and this is not being treated as a security fix.
The four-file increment has two independent reviews, exact reviewed post-images, identical non-comment source tokens, and project Prettier/diff-check rc0. This does not establish current-head CI or artifact compatibility; existing gates remain pending and this thread stays unresolved.
| * regular file. Any invalid or missing declaration falls back to | ||
| * `process.execPath` rather than guessing at another binary. | ||
| * | ||
| * The result is memoized per process; pass the caller's `import.meta.url` |
There was a problem hiding this comment.
[P3, non-blocking] The signature takes importMetaUrl per caller but cachedInterpreter is module-global, so the first caller's URL decides the answer for the whole process and later callers' URLs are silently ignored. Three different modules pass three different URLs.
This is correct for every layout that ships — all three callers live in packages/core and land in the same bundle, so resolveBundleDir yields the same root — and the doc comment does say "memoized per process", plus memoizes the resolution for the process lifetime pins it. Noting it only because the parameter shape invites a reader to assume per-caller resolution that the memo does not honour.
There was a problem hiding this comment.
Implemented in 0f4c38242c, directly on top of e5270fbc.
The function comment and both design docs now spell out the process-wide cache: the first caller URL determines resolution and later caller URLs are ignored. They also retain why the first caller passes its URL and note the shared installation root of current production callers. Cache behavior is unchanged.
The four-file increment has two independent reviews, exact reviewed post-images, identical non-comment source tokens, and project Prettier/diff-check rc0. Current-head CI acceptance and the existing runtime/platform gates remain pending; leaving this thread unresolved.
| policy, | ||
| { | ||
| executable: process.execPath, | ||
| executable: getJsInterpreterCommand(import.meta.url).command, |
There was a problem hiding this comment.
[P3, non-blocking — a handoff note for S3, not a change request for this diff] This call site now spawns the resolved interpreter, but the two sandbox executors still build their allowlist from process.execPath:
// bwrap-execution.ts:41
const node = realpathSync(process.execPath);
// landlock-execution.ts:113
const node = realpathSync(process.execPath);I checked whether the two can diverge today and they cannot, which is why this is not blocking: the standalone shim execs the bundled runtime directly (create-standalone-package.js:1017,1029 — exec "$ROOT/bun/bin/bun" "$ROOT/lib/cli-entry.js"), so process.execPath is the binary this resolver returns, and npm/source layouts fall back to process.execPath anyway. The allowlist and the spawned executable are the same file in every shipping layout.
They diverge the moment a compiled launcher lands — which is precisely the flavor this PR is preparing for — and at that point a sandboxed file write would exec a binary the allowlist never staged. Your design doc already carries bwrap-execution.ts and landlock-execution.ts as "not yet (S3)", so the sequencing is disclosed and deliberate; I am writing this down here so the coupling is anchored at the call site that creates it rather than only in the inventory table.
There was a problem hiding this comment.
Implemented in 0f4c38242c, directly on top of e5270fbc.
Added the handoff directly above the file-worker executable selection and synchronized both design docs: bwrap/landlock still stage process.execPath, and the S3 allowlist migration is not implemented. The docs do not claim support for layouts where the resolved interpreter differs from the staged binary. No sandbox policy or executable selection changed.
The four-file increment has two independent reviews, exact reviewed post-images, identical non-comment source tokens, and project Prettier/diff-check rc0. This does not replace native/platform or current-head CI validation; existing gates remain pending and this thread stays unresolved.
updated
yiliang114
left a comment
There was a problem hiding this comment.
APPROVE at head 0f4c3824
Delta re-review, not a fresh pass. My earlier approval (5542297486) was dismissed by the push, so this is a new vote at the current head — but the code it certifies is the code I already read and executed tests against at b85a12ad.
What moved since then:
| Commit | Shape | Effect on the reviewed diff |
|---|---|---|
e5270fbc |
Merge branch 'main' |
none — all nine PR files are blob-identical to b85a12ad, and main touched none of the four production call sites (each is still last modified by this PR's own 0320f96f) |
0f4c3824 |
comments + design docs | none — every changed line in runtime-info.ts (+10/−4) and file-worker-client.ts (+2/−0) sits inside a JSDoc block or a // comment |
No production token changed, which is why I did not re-run a full pass or re-dispatch scouts. It is also why the executed evidence from my previous review still describes this head: both test files are blob-identical here, so the earlier runtime-info.test.ts + runtime-boundary.node-bun.test.ts run (35 tests green, Bun leg genuinely executing on bun 1.4.2 rather than skipping) still applies.
The four notes I left are now documented. I checked each claim against the code instead of taking the commit message for it:
runtimehas no production read site — confirmed.host-client.ts:54destructures{ command }only;hookRunner.ts:1258andfile-worker-client.ts:41both take.command.getPty.tsnever calls the resolver at all — it usesisBunRuntime(), so it is not a fourth consumer.- an absolute
interpreterescapes containment — now stated as intended behaviour rather than left implicit. Confirmed:path.resolve(packageRoot, manifest.interpreter)returns an absolute value verbatim. - the memo is process-global, so the first caller's URL wins — confirmed.
cachedInterpreteris module-scoped andif (cachedInterpreter) return cachedInterpreter;is the function's first statement. - sandbox allowlists still stage
process.execPath— the S3 handoff comment is accurate. Confirmed atsandbox/bwrap-execution.ts:41andsandbox/landlock-execution.ts:113(const node = realpathSync(process.execPath);), plushooks/hook-command-cgroup.ts:166(executable: process.execPath).
EN and zh-CN design docs took the same three clarifications, so the twins stay structurally aligned.
The resolver itself is unchanged and still fail-closed on every input I can reach: isExecutableFile runs statSync(...).isFile() before the win32 branch, so directories and missing files reject on Windows too and that branch only skips the POSIX execute bit; packageRoot has no upward traversal; both manifest.json and the lib/cli-entry.js marker must be present; runtime must be exactly 'bun' or 'node'. Nothing invalid reaches spawn.
One non-blocking note for later stages, not for this diff: the expanded JSDoc earns its place because it records constraints a future caller would otherwise rediscover the hard way (process-wide memo, absolute-path escape, no runtime consumer). Worth resisting the pull toward letting it become a running log of review-thread replies as S3 lands — the allowlist coupling belongs in the design doc's migration inventory, which already carries it.
CI on this head is still in flight (Test (ubuntu) and Lint & Static in progress, native lanes queued). That is absent signal rather than a red light and not a code finding; I am flagging it only so this approval is not read as a claim that the lanes finished.
中文说明
在 head 0f4c3824 上重新批准。这是一次增量复审,不是重跑全量:我上一张批准(5542297486)被这次 push 抹掉了(reviewDecision 回到 REVIEW_REQUIRED),所以需要重新投票;但它认证的代码,就是我在 b85a12ad 上已经读过并实跑过测试的那份。
之后的两次变动都不改生产代码:
e5270fbc是Merge branch 'main'。九个 PR 文件的 blob 与b85a12ad逐个相同,且 main 没碰四个生产调用点中的任何一个(它们最后一次修改仍是本 PR 自己的0320f96f)。0f4c3824改的是注释与设计文档。runtime-info.ts(+10/−4)与file-worker-client.ts(+2/−0)里每一条变动行都落在 JSDoc 块或//注释内。
生产 token 零变化,所以我没有重跑全量、也没有重派 scout。同理,上一轮的实跑证据在本 head 依然成立:两个测试文件的 blob 完全一致,runtime-info.test.ts + runtime-boundary.node-bun.test.ts 35 条全绿、且 Bun 那条腿是真跑(bun 1.4.2)而非 skip。
我留的四条提醒现在都写进文档了,每条我都回代码核过,而不是照抄提交说明:
runtime没有生产读点:host-client.ts:54只解构{ command },hookRunner.ts:1258、file-worker-client.ts:41都取.command;getPty.ts根本不调用解析器(用的是isBunRuntime()),所以不存在第四个消费者。- 绝对路径
interpreter原样采用、不做包根限制:path.resolve(packageRoot, manifest.interpreter)确实如此,现在被明确写成预期行为而不是隐含事实。 - 记忆是进程级的,首次调用方的 URL 决定结果:
cachedInterpreter是模块级变量,且if (cachedInterpreter) return cachedInterpreter;是函数第一条语句。 - 沙箱 allowlist 仍暂存
process.execPath:sandbox/bwrap-execution.ts:41、sandbox/landlock-execution.ts:113均为const node = realpathSync(process.execPath);,另有hooks/hook-command-cgroup.ts:166的executable: process.execPath。这条 S3 交接注释是准确的。
中英文设计文档拿到的是同样三条澄清,双语孪生结构仍然对齐。
解析器本体未变,在我能触达的每种输入上依旧 fail-closed:isExecutableFile 把 statSync(...).isFile() 放在 win32 分支之前,因此目录与缺失文件在 Windows 上同样被拒,该分支只跳过 POSIX 执行位;packageRoot 无向上遍历;manifest.json 与 lib/cli-entry.js 标记必须同时存在;runtime 必须恰为 'bun' 或 'node'。无效声明到不了 spawn。
一条不阻塞的提醒,针对后续阶段而非本 diff:这次扩写的 JSDoc 值得留,因为它记的是未来调用方否则要踩坑才知道的约束(进程级记忆、绝对路径逃逸、runtime 无消费者)。但 S3 落地时别让它变成评审线程回复的流水账——allowlist 这层耦合应该留在设计文档的迁移清单里,那儿已经记着了。
本 head 的 CI 还在跑(Test (ubuntu) 与 Lint & Static in progress,native 车道排队)。这是「没有信号」而不是红灯,也不构成代码缺陷;写出来只是为了避免把这张批准读成「车道已跑完」。
qqqys
left a comment
There was a problem hiding this comment.
APPROVE at head 0f4c38242ccd8eb6c76450b8e51a58cd500916be — a fresh pass at this head, not a restatement of my earlier approval, which the push to e5270fbc/0f4c3824 dismissed. All five blocking items from the fed48b85 round are resolved here, and the delta since introduces no production change.
1. The delta is comments and documentation only — verified two ways
Two commits landed since b85a12ad: e5270fbc (merge from main) and 0f4c38242c (docs(core): clarify interpreter metadata and resolution boundaries).
I did not take the commit message or the concurrent approval for it. First, blob comparison of this PR's seven code files across the two heads:
IDENTICAL packages/core/src/utils/runtime-boundary.node-bun.test.ts
IDENTICAL packages/core/src/utils/runtime-info.test.ts
IDENTICAL packages/core/src/code-mode/host-client.ts
IDENTICAL packages/core/src/hooks/hookRunner.ts
IDENTICAL packages/core/src/utils/getPty.ts
CHANGED packages/core/src/utils/runtime-info.ts c168505b -> 2538e813
CHANGED packages/core/src/sandbox/file-worker-client.ts b3913d9a -> 420c3c14
Second, for the two that changed, I read the 0f4c38242c patch line by line and then stripped every comment line from both revisions of runtime-info.ts and compared the remainder: code-only-identical=true. The +10/-4 in runtime-info.ts is the runtime field's JSDoc and two edits inside getJsInterpreterCommand's JSDoc block; the +2/-0 in file-worker-client.ts is a two-line // comment above the unchanged executable: getJsInterpreterCommand(import.meta.url).command. No executable statement moved.
So the resolver body and all four call sites are behaviourally identical to the code I already read and found fail-closed, and both test files are byte-identical to the versions I verified. The main merge touched none of them.
2. The five blockers, re-checked at this head
Prettier (R1-1) — fixed. Ran the repository's own Prettier (3.5.3, .prettierrc.json) over the two design docs and all three added source files as they stand at 0f4c38242c: All matched files use Prettier code style! Lint & Static (ubuntu-latest, Node 22.x) also passes at this head (15m42s), corroborating it in-lane.
Windows fixture layout (R1-2) — fixed. runtime-info.test.ts is blob-identical to the version whose interpreterPath branches on process.platform (<root>/<runtime>/<runtime>.exe on win32 vs <root>/<runtime>/bin/<runtime> elsewhere), whose positive-resolution cases assert that platform-reachable path, and whose 0o644 chmod case is gated { skip: process.platform === 'win32' } because isExecutableFile returns true after statSync().isFile() on win32 without calling accessSync.
SIGTERM ordering race (R1-3) — fixed. runtime-boundary.node-bun.test.ts is blob-identical to the version where the fixture installs process.on('SIGTERM', …) before writing its identity line, where the parent registers waitForClose(child) before child.kill('SIGTERM'), and where collectIdentityLines rejects on child/stdout error, on stdout closing before identity, and on a 5 s timeout. Test (ubuntu-latest, Node 22.x) passes at this head (28m3s), so the always-run node leg is green here.
IPC graceful exit (R1-4) — fixed. Same blob. The child exits cooperatively on a {type:'shutdown'} message rather than being killed, so the exitCode === 0 / signal === null assertions no longer depend on a POSIX exit shape Windows does not provide.
Design-doc invariant (R1-5) — addressed, and now more thoroughly than before. 0f4c38242c strengthens exactly the disclosure this finding asked for. Beyond the existing scope limit ("Supported scope: interpreter-based Node/Bun distributions … the present fallback does not guarantee a usable interpreter in that flavor"), both language twins now state that absolute interpreter paths are used as-is with no containment enforced, that runtime is metadata with no current production read site, that memoization means the first caller's URL wins and later ones are ignored, and that bwrap/landlock still stage realpathSync(process.execPath) so this PR "does not establish support for layouts where the resolved interpreter differs from the staged binary".
I checked each of those new claims against the code rather than accepting them, including the three sites outside this PR:
sandbox/bwrap-execution.ts:41→const node = realpathSync(process.execPath);✓sandbox/landlock-execution.ts:113→const node = realpathSync(process.execPath);✓hooks/hook-command-cgroup.ts:166→executable: process.execPath,✓- no containment:
path.resolve(packageRoot, manifest.interpreter)returns an absolute declaration verbatim ✓ runtimeunread:host-client.ts:54destructures{ command }only, andhookRunner.ts/file-worker-client.tsboth take.command;getPty.tsusesisBunRuntime()and never calls the resolver, so it is not a fourth consumer ✓- first-caller-wins:
if (cachedInterpreter) return cachedInterpreter;is the function's first statement, withcachedInterpretermodule-scoped ✓
So the doc now describes what ships, including the gaps, instead of certifying a boundary this PR does not complete.
3. Independent Critical-only scan at this head — no Critical
The production surface is unchanged from what I read in full earlier, and I re-confirmed its shape rather than relying on that reading: parseStandaloneManifest wraps readFileSync/JSON.parse in try/catch and rejects non-objects, null, arrays, any runtime other than exactly 'bun'/'node', and a non-string interpreter; packageRoot = path.dirname(resolveBundleDir(importMetaUrl)) with no upward traversal; both manifest.json and the lib/cli-entry.js marker required; isExecutableFile requires a regular file plus X_OK on POSIX, with statSync().isFile() running before the win32 branch so directories and missing files reject there too; and every rejection path returns { command: process.execPath, runtime: isBunRuntime() ? 'bun' : 'node' }. In npm, source and SDK layouts that is exactly the value the four call sites used before, so the substitution is behaviour-preserving. getPty.ts's isBunRuntime() is strictly narrower than the 'bun' in process.versions it replaced and agrees with it under both runtimes.
The two items previously reported as Suggestions are now documented as intended behaviour rather than left implicit — the non-containment of an absolute interpreter, and the process-global memo. Neither is a Critical: the declaring manifest must already sit inside the trusted root beside the entry marker, so an absolute path confers no privilege its writer lacks, and nothing produces an interpreter key today; and all three migrated callers live in packages/core and share one installation root, so first-caller-wins cannot currently diverge. Both are correctly recorded as constraints on future S3/S4 work.
Since the delta adds no production token, it introduces no new surface for a Critical, and I found none.
4. CI
Verified as belonging to this head rather than an earlier one: runs 38843055495 and 38843055881, both head_sha=0f4c38242c, the latter conclusion=success. Passing at this head: Test (ubuntu-latest, Node 22.x) 28m3s, Lint & Static 15m42s, Integration Tests (no-AK, No Sandbox) 8m38s, Native Linux CLI boundary 8m13s, Native Windows settings and streams 9m57s, x64 58s, arm64 1m1s. web-shell E2E Smoke is still pending; I did not wait on it, and it is unrelated to this change's surface. No failure is attributable to this PR, so CI forms no part of this verdict.
Test (windows-latest, Node 22.x) is skipping at PR level, so R1-2's fix is verified by code reading and blob identity rather than by an executed Windows lane — worth knowing, though the fixture is now platform-correct by construction and the case that could only pass vacuously on Windows is gated off there.
5. Note on my previous approval
My approval of b85a12ad (review 5542244907) was dismissed by the subsequent push and is not the basis for this one. Everything above was re-established at 0f4c38242c from live data. I also read the concurrent approval by yiliang114 at this head; where it overlaps my checks I verified independently rather than inheriting it, and the blob comparison, comment-stripped diff, Prettier run and the three out-of-PR sandbox/cgroup sites above are my own.
… evidence Empty commit: no code change is warranted by the deterministic gate's test-weakening rejection. The merge ddc7666 resolved packages/core/src/utils/runtime-info.test.ts and packages/core/src/utils/runtime-boundary.node-bun.test.ts to main's reviewed versions from #14036 (2eab3cc), replacing the older stacked draft copies this branch carried while the prerequisite was unmerged. Both files are byte-identical to origin/main (empty merge- base diff: this PR no longer modifies them), and main's versions are strictly richer (19/16 vs 16/15 expect() calls), so no assertion coverage is lost. The per-file evidence is recorded in the round's test-weakening.json; restoring the drafts would revert the reviewed suites and re-introduce the stacked duplicates the merge correctly eliminated. Co-authored-by: Qwen-Coder <[email protected]>
|
Released in v0.25.3. |
* feat(core): separate app launcher and JS interpreter runtime boundary
Establishes the runtime boundary the Bun migration (MYWO-8 S1) needs
before workers, hooks, sandbox helpers and the code-mode host spawn
JavaScript children under a future compiled-app flavor: arbitrary-JS
child processes resolve their interpreter through one accessor (package
manifest first, process.execPath fallback) instead of reading
process.execPath directly, Bun detection has a single seam, and the
app-launcher contract is documented alongside the full call-site
inventory in a bilingual design doc. Adds the same-fixture Node/Bun
regression matrix (stdio framing, exit codes, SIGTERM, IPC channel,
--expose-gc, --input-type=commonjs --eval).
* fix(core): anchor interpreter resolution to the trusted install root
Arbitrary-JS child resolution no longer walks upward looking for a
manifest: the only trusted location is the standalone package root —
the parent of the caller's bundle directory, which must hold both a
manifest.json and the standalone entry marker lib/cli-entry.js — so an
unrelated ancestor manifest in npm, source or SDK layouts can never be
read. Declarations are validated before use: runtime must be exactly
'bun' or 'node', and the interpreter must be an existing executable
regular file; any invalid or missing declaration falls back to
process.execPath without throwing (non-string interpreter, directory,
non-executable file, unknown runtime, absent binary, missing marker).
Adds the regression matrix for unrelated ancestor manifests (npm
bundle and deep SDK layouts), object/number/directory interpreters,
unknown runtime, missing and non-executable interpreters, and the
trust anchor; syncs both design-doc language versions with the
validated contract.
* docs(design): complete the migration inventory handoff
Adds the three interpreter-identity call sites the re-review found
missing from the call-site inventory (hook-command-cgroup launcher,
bwrap-execution and landlock-execution allowlist staging), marks the
unwired rows as owned by the S3 migration sweep, and notes platform
applicability: the cgroup/bwrap/landlock rows are Linux-only
mechanisms validated against the Linux targets of the platform
matrix, while the mem0 and pem rows apply on every platform. Both
design-doc language versions are updated; no product or test code
changes.
* feat(core): add a real PTY backend for the Bun runtime
Under Bun, @lydell/node-pty's wrapper pumps the PTY master fd through a
tty.ReadStream, and Bun surfaces the nonblocking fd's EAGAIN as an error
event instead of "no data yet", destroying the stream and closing the
master: onData never fires, resize fails with EBADF, and the shell tool
and web terminal hang. Reproduced on Bun 1.3.14 and 1.4.0.
getPty() now loads a qwen-bun-pty backend under Bun (non-Windows) that
drives the same native addon directly with a main-thread async fs.read
pump: EAGAIN retries on a short timer instead of erroring, EIO/EBADF end
the pump and close the fd, writes queue through an async fs.write with
EAGAIN retries, and exit waits briefly for the drained fd so data is
never truncated behind onExit. The wrapper's observable contract (env
sanitizing, flow-control bytes, encoding, resize validation, IPty
lifecycle) is mirrored, and the pump starts in the constructor so an
unpumped fd can never hold the event loop open.
Packaging stages the node-pty addon for both runtime flavors, since Bun
installs now load it through this backend. The Windows-under-Bun gate
stays honest (explicit load error), and the runtime-boundary design docs
point at the new backend doc for the mechanism and evidence.
Tests: unit coverage for the backend lifecycle (output, write, resize,
kill, pause/resume, flow control, raw encoding), getPty selection under
Bun/Windows, and a cross-runtime regression that runs the same fixture
through the real getPty() seam under both Node and Bun when a bun binary
is present.
* fix(core): keep PTY exit detection alive while paused
The pinned node-pty addon fires its native exit callback only around
master-fd read activity (isolated-probe evidence, identical on Node and
Bun), so the old pause() that stopped the pump lost onExit entirely:
pause then child exit left the master fd open and the host unable to
drain — the same mechanism behind the XOFF-then-cancel FD residue under
handleFlowControl.
pause() now buffers output into a bounded hold (1 MiB) that resume()
flushes, while reads continue so exit detection rides on the pump.
On end of life the hold is discarded for wrapper parity: onExit arrives
exactly once and the fd is released, but resume-after-exit replays
nothing, matching the wrapper's destroyed paused socket. Docs are
synced to the actual main-thread async fs.read pump (the earlier
worker-threads/blocking-read sketch is documented as abandoned), and
regressions cover pause-at-exit, hold overflow, and XOFF-cancel on both
runtimes.
* fix(core): make the Bun PTY pause hold lossless and exits leak-free
Serializes master-fd reads behind an in-flight guard (a resume chaining
into a read that is still outstanding would cross-observe the shared
64 KiB buffer), holds paused output without a cap so nothing is ever
silently dropped, and routes every end-of-life path through one cleanup
that flushes the decoder, stops the retry timer, closes the master fd
and fires onExit exactly once — including the 500 ms fallback, which is
now ref'd so exit delivery cannot depend on a droppable timer. Pins all
of it with byte/line-exact regressions: no-gap pause/resume storms and
a ~1.9 MB flood resumed byte-for-byte, cross-runtime.
* fix(core): cap the Bun PTY pause hold and terminate on overflow
The lossless pause hold could grow without bound while a consumer
stays paused. The hold now copies chunks into fixed 64 KiB blocks
under a per-pty byte ledger (4 MiB default) inside a process-wide
budget (32 MiB total hold, 8 active ptys, 1 MiB write queue), so the
bound holds for any producer chunk pattern.
Reaching a cap terminates that pty (SIGTERM then SIGKILL) and emits
one structured PtyLimitError — never a success result and never a
fabricated native exit; the real signal death lands only in
stats.nativeExitRecord. Shell executions converge the error into
{error, exitCode: null, signal: null}; web terminals mark the session
failed and the /terminal route sends an error control frame followed
by close 4001. Node behavior is unchanged.
Design docs corrected per review: the drip "kernel corruption" claim
is withdrawn, and exit detection wording no longer overstates when
exits are observed.
* fix(core): harden post-termination pty edges per review
Dual-review follow-ups on the bounded hold: resize() joins write() in
treating a terminated/closed pty as a no-op instead of throwing EBADF
from the addon; a read that was in flight when the limit termination
closed the fd no longer delivers or re-charges its late bytes; and a
resume() replay stops at the first data listener that terminates the
pty, so no held bytes flow after the structured error.
* fix(core): detach pty error subscriptions by observed shape, not assumed Disposable
node-pty's Terminal.prototype.on proxies the listener to its master socket
and returns undefined, while an EventEmitter-based pty (the Bun backend)
returns the emitter itself. The registry stored that return value as a
Disposable and called dispose() on release, so every Bun release, natural
exit, or backend failure path threw TypeError from the route/registry and
could take the whole serve process down (server exit 1, client saw 1006
instead of the explicit close).
Store the subscription return as unknown and detach by observed shape: a
real { dispose } is used as-is, otherwise off/removeListener removes the
listener, and undefined (node-pty's actual return) keeps the previous
no-dispose behavior unchanged.
Covered by two registry unit tests on the mocked shapes plus a real-serve
lifecycle probe (release 4004 / exit 4000 / backend over-limit 4001 with
failed-session reconnect replay, server alive throughout) run under Bun
1.3.14, Bun 1.4.0, and Node.
* fix(core): close Bun PTY fds only after in-flight ops settle
Review round on #14046:
- bun-pty closeFd() ran closeSync() while libuv fs.read/fs.write ops could
still own the master fd, so the recycled descriptor number could take a
queued write into an unrelated session. fdClosed now flips and the
process-wide admission slot is released immediately, but the real close
is deferred until the last outstanding op settles, with witnesses for
both the read-held and write-held arms.
- A write-side EIO/EBADF (child already gone) is the expected teardown
race and is no longer reported, matching the wrapper's swallowed EIO;
other write errors keep their errno code so the entry classifier and
getPtyLimitMessage can recognize them instead of escaping as an
uncaught exception. The pump's emit dispatch runs under try/finally so
a throwing error listener can never strand the pump.
- The web-terminal registry's pty error subscription no longer re-throws:
a throw there leaves the backend's fs callback as an uncaught exception
and kills the serve daemon. EIO/EAGAIN races are swallowed and other
non-limit errors go to the diagnostic sink.
- Failed sessions no longer count against the web-terminal admission cap,
and release() no longer fabricates a 143/15 exit frame for them.
- processPtyBudget.maxActivePtys is 64 (headroom over the eight-slot
web-terminal cap so a full house cannot starve the shell tool), with
the per-pty vs process-wide cap relationship documented.
- ShellExecutionResult.executionMethod declares 'qwen-bun-pty', its
error-field contract documents resource-limit termination, and the two
casts that hid the Bun backend name are dropped.
- getPty tests that assert the Bun arm loads now pin a POSIX platform so
they pass on Windows hosts; docs and the packaging help text are
aligned (correct smoke-runtime.js path, boundary-doc PTY row now cites
the bun-pty fixture, node-pty staging applies to both runtimes).
* chore: re-verify S1 boundary test-file merge resolution with recorded evidence
Empty commit: no code change is warranted by the deterministic gate's
test-weakening rejection. The merge ddc7666 resolved
packages/core/src/utils/runtime-info.test.ts and
packages/core/src/utils/runtime-boundary.node-bun.test.ts to main's
reviewed versions from #14036 (2eab3cc), replacing the older
stacked draft copies this branch carried while the prerequisite was
unmerged. Both files are byte-identical to origin/main (empty merge-
base diff: this PR no longer modifies them), and main's versions are
strictly richer (19/16 vs 16/15 expect() calls), so no assertion
coverage is lost. The per-file evidence is recorded in the round's
test-weakening.json; restoring the drafts would revert the reviewed
suites and re-introduce the stacked duplicates the merge correctly
eliminated.
Co-authored-by: Qwen-Coder <[email protected]>
* fix(core): preserve PTY failure output and bounded settlement
* fix(core): deliver reaped PTY exits on limit trips, replay failed scrollback
Review round on the Bun PTY backend:
- terminateResourceFailure no longer signals a pid it already reaped
(pendingExit parked): the real exit is delivered and the structured
limit error reported, instead of SIGTERM/SIGKILL at a recycled pid.
- The failed-reconnect branch of the terminal WS route replays the
retained scrollback through the backpressure guard before the error
frame, matching the exited path.
- QWEN_PTY_ACTIVE_LIMIT no longer claims a termination that never
happened, and acceptedBytes stays a byte count (0 at refusal).
- sanitizeEnv also applies when options.env is omitted, matching the
wrapper's resolved-env rule.
- The arithmetically unreachable paused-hold-segments cap is deleted.
- Tests: the live-failure route test now reaches a live session; the
registry limit test is parametrized over both limit codes; the
paused-exit fixture gains a withheld-tail oracle so it cannot pass
without a real pause; the bounded-hold tests get afterEach failure
isolation; the process-wide write-queue budget is exercised; and the
stale throw-propagation assertion is reconciled with the deliberate
reportListenerError containment (un-breaks the core test lane).
* docs(core): clarify pending PTY close validation
* docs(core): fix PTY validation checklist indentation
* fix(pty): make resource failures the terminal event
Co-authored-by: Qwen-Coder <[email protected]>
* test(cli): raise ps maxBuffer for loaded CI shards
The managed-runtime process probe lists the whole process table with execFileSync. On a loaded CI shard that output exceeds the 1 MiB default and the probe fails with ENOBUFS; raise the cap to 16 MiB.
Co-authored-by: Qwen-Coder <[email protected]>
* docs(core): name the PTY fd-lifetime tests
Point the deferred-close validation entry at the two exact fd-lifetime tests in both design languages.
Co-authored-by: Qwen-Coder <[email protected]>
* fix(cli): release failed terminal replay sessions safely
* test(web-shell): verify failed terminal replay protocol
* test(cli): pin failure listener cleanup on terminal exit
* fix(core): preserve failure precedence across terminal exits
* fix(core): isolate terminal failure notifications and verify release
* fix(core): preserve PTY write and admission failure diagnostics
* test(core): assert PTY cleanup drains every budget
* test(core): verify production PTY refunds start with charged budgets
* fix(core): stop late PTY signals and integrate cleanup refund tests
* test(core): witness PTY subscriber delivery and document native loading
* test(core): reclaim captured PTYs when fd race assertions fail
* test(core): verify exit diagnostics with a real PTY child
* fix(core): avoid signalling reaped PTY leaders during fallback
* test(core): pin paused PTY boundaries and isolate loader probes
* fix(core): verify PTY ownership and target-specific packaging
* fix(core): refuse oversized terminal input before the pty cap
* fix(core): park paused PTY reads at the hold cap instead of killing the tree
Under the Bun backend the shell tool passes handleFlowControl: true, so a
single Ctrl+S (XOFF) byte calls pause(). The pump kept reading into the
paused hold and, once the 4 MiB per-pty (or 32 MiB process-wide) hold was
full, terminated the child process tree with QWEN_PTY_OUTPUT_LIMIT. During
a flood that killed the command about a second after one keystroke.
Size each paused read to the room left in the hold and, once there is
none, stop issuing reads until resume(). The kernel pty buffer then fills
and the child blocks on write, which is the backpressure the node-pty
wrapper's paused socket applies. Nothing is dropped or killed, and
resume() replays the hold and restarts the reads; pty.stats.readParked
exposes the state. QWEN_PTY_OUTPUT_LIMIT and the paused-hold limit kinds
are removed together with the consumer branches that handled them. The
write-queue and admission limits are unchanged.
While parked, a child that dies with output undrained may only finish
exiting on macOS once the master is read again, so the shell tool's
cancel now calls resume() before it signals the process group.
The design docs also get the live-pty cap right (64, not 8) and no longer
describe a block-count cap that the hold never had.
* test(core): run the PTY drain-window witness on Linux only
The real-child test for a write-limit trip after the native exit relies
on a HUP-ignoring grandchild keeping the pty slave open after the session
leader exits. macOS ends the master side right away (a plain-pty probe on
Darwin reads EOF about 70 ms after the leader exits), so the pump closes
the fd before the write and the case failed 3/3 there. Skip it off Linux;
bun-pty-failure-order.test.ts still pins the same guard on every platform
with a mocked native exit.
* fix(core): reap a PTY's whole session on a resource-limit termination
terminateResourceFailure signalled only the leader and the leader's
process group. An interactive shell runs each foreground job in its own
group, so a job that ignores SIGTERM and SIGHUP outlived the termination:
the failure was reported and the budgets refunded while the job kept
running, reparented to init. Reproduced on Linux and macOS.
List what the pty owns with ps while the leader is still unreaped: its
descendants, plus every process in its session (Linux sid) or on its
controlling tty (macOS tdev). Signal each of them as well as the group.
The SIGKILL pass after the grace period lists the tree again. It keeps
an earlier member only while that member's start time still matches, so
a recycled pid is never signalled. It reuses the scope only where the
scope still names the session: macOS drops the tty with the leader, and
Linux keeps the sid unless the pid now leads a new process.
The web terminal registry's killPtyTree already walked the same ps
listing; both now share collectPtyProcessTree.
* test(core): tolerate the pty's CR jitter in paused-flood oracles
macOS's pty driver occasionally inserts an extra CR before LF; a plain script(1) probe reproduces it without this project's code. The paused-flood tests compared the stream byte-for-byte and waited for pausedBytes to equal the logical byte count, so a jittered stream could never satisfy the predicate.
Wait for pausedBytes >= the logical size, derive the process-wide case's expected hold from the observed hold, and compare the resumed stream with runs of CR before LF collapsed. Every line's content, order and count is still asserted, so loss and duplication remain caught.
---------
Co-authored-by: gary.gq <[email protected]>
Co-authored-by: qwen-code-autofix <qwen-code-autofix@localhost>
Co-authored-by: Qwen-Coder <[email protected]>
Co-authored-by: qwen-code-dev-bot <[email protected]>
Co-authored-by: qwen-code-dev-bot <[email protected]>
Co-authored-by: Qwen Autofix <[email protected]>
Co-authored-by: wenshao <[email protected]>




What this PR does
Separates the executable used to launch Qwen Code from the interpreter used to run JavaScript children. Hook supervision, sandbox file writes and code-mode execution now resolve an interpreter from the caller's standalone installation; source and npm installations keep the current interpreter. This prepares those features for a launcher that cannot itself execute arbitrary JavaScript, without switching the CLI's default runtime.
Why it's needed
When a packaged application's executable is reused to start a JavaScript worker, the worker can relaunch the application instead of executing its script. Previously these callers used the application's executable directly. The new resolver accepts a recognized runtime manifest beside the installation's entry marker, validates the declared interpreter as an executable file, and falls back to the current interpreter for invalid or missing declarations. Users should retain working hooks, sandbox writes and code-mode children when packaging separates the launcher and interpreter.
Reviewer Test Plan
How to verify
fed48b85c8d67172968c51b62cf0c1493dc60665. Exercise source/npm layouts and valid Node/Bun standalone layouts. Source/npm children should use the current interpreter; standalone children should use the installation's declared executable, not an unrelated ancestor manifest.Evidence (Before & After)
N/A — no TUI change. The diff replaces direct executable selection at the three core child-launching areas and adds layout and cross-runtime regressions; the Bun PTY gate remains disabled here. Earlier macOS arm64 validation of predecessor
6e9c2c5acovered the fixed Node/Bun pair and invalid-layout controls. Those results predate the main-branch merges in this head and are historical evidence, not a fresh full-head/preflight pass. The current GitHub review still requests changes; this description update does not resolve those findings.Reproduce the focused checks after the repository's normal dependency setup, then run the required preflight separately:
Tested on
Environment (optional)
Historical independent comparison: Node 24.19.0 and Bun 1.3.14 on macOS arm64. Earlier author testing also used Bun 1.4.0; it does not substitute for the pinned 1.3.14 leg. No tests were executed for this description-only edit.
Risk & Scope
Design pair: English / 简体中文. Both are included in the diff; remaining compatibility and acceptance work must stay visible in both languages.
Linked Issues
Related: #11607. Prerequisite for #14046; this boundary refactor does not complete the runtime migration or auto-close its tracking issue.
中文说明
本 PR 做了什么
分离启动 Qwen Code 的可执行文件与运行 JavaScript 子进程的解释器。hook 监督、sandbox 文件写入和 code-mode 执行现在从调用方的 standalone 安装中解析解释器;源码和 npm 安装继续使用当前解释器。这为启动器本身不能执行任意 JavaScript 的布局准备边界,不切换 CLI 默认运行时。
为什么需要
打包应用的可执行文件若被用于启动 JavaScript worker,可能重新启动应用而非执行脚本。此前这些调用方直接使用应用可执行路径。新解析器要求受支持的运行时清单与安装入口标记共存,验证声明的解释器确为可执行文件;声明缺失或无效时回退当前解释器。这样,当打包分离启动器和解释器时,用户的 hook、sandbox 写入与 code-mode 子进程仍应正常工作。
审阅者测试计划
如何验证
fed48b85c8d67172968c51b62cf0c1493dc60665,覆盖源码/npm及有效 Node/Bun standalone 布局。源码/npm 子进程应使用当前解释器;standalone 应使用安装内声明的解释器,不读取无关祖先清单。证据(Before & After)
N/A — 无 TUI 变化。diff 替换 core 内三个子进程启动领域的直接路径选择,增加布局与跨运行时回归;此 PR 仍禁用 Bun PTY。此前 macOS arm64 对前序
6e9c2c5a的验证覆盖固定 Node/Bun 及非法布局对照,但早于当前 head 的 main 合入,只算历史证据,不是当前完整 head/preflight 新通过。GitHub 当前仍为请求修改,本次描述更新不关闭审查发现。按仓库正常安装流程准备依赖后,可复现定向检查,再单独运行必需的 preflight:
测试平台
环境(可选)
历史独立对照为 macOS arm64、Node24.19.0/Bun1.3.14;早期作者也测试 Bun1.4.0,但不替代固定1.3.14。本次只改描述,未执行测试。
风险与范围
设计文档:English / 简体中文。两份均在 diff 内,剩余兼容与验收工作须在两种语言中保持可见。
关联 Issue
相关:#11607。本 PR 是 #14046 的前置;边界重构不代表运行时迁移完成,也不自动关闭迁移 issue。