Skip to content

test(worker): 修复 dispatch-user-route 夹具缺失沙盒叶子刷新标识符导致的 master 红 - #3590

Merged
deepcoldy merged 1 commit into
masterfrom
fix/dispatch-user-route-scope-stub
Nov 19, 2026
Merged

deepcoldy merged 1 commit into
masterfrom
fix/dispatch-user-route-scope-stub

Conversation

@deepcoldy

Copy link
Copy Markdown
Owner

现象

master 678251d3e(#3569 合入)的 bun-test (1/4) 中,test/dispatch-user-route.test.ts 有 5 个用例失败:

ReferenceError: refreshSandboxedCliLeafAttestation is not defined

CI run:https://github.com/deepcoldy/botmux/actions/runs/44454508741

根因

#3569 在 markPromptReady 中新增了 refreshSandboxedCliLeafAttestation?.()。该测试的 screenReady 夹具把 markPromptReady 的源码切片放进裸 with (scope)(普通对象)里执行,scope 没有提供这个标识符。

可选链 ?. 只能拦截值为 nullish 的取值,挡不住标识符解析本身——with 在普通对象上找不到该名字时直接抛 ReferenceError,所以 5 个走 screenReady 的用例全部失败。

同样切片 worker 源码的 worker-function-harness 不受影响:它的 scope 是声明了全部标识符的 Proxy,未提供的名字回退为 undefined 而非抛错(#3569 自己的 find-launched-cli-pid 套件也已在 scope 中显式提供该桩)。

#3569 的最后 head 是 fork 提交、CI 需批准未运行即被合入,所以这个夹具缺口没有被拦住。

改动

仅测试,一行桩:在 screenReady 的 scope 中补 refreshSandboxedCliLeafAttestation: undefined,与相邻的 currentCodexObservedPid 桩(markPromptReady 中两者调用点相邻)同形态。真实沙盒叶子证明路径仍由 find-launched-cli-pid 套件覆盖,本夹具只测生命周期/派发边界。

验证

  • 修复前本地复现:dispatch-user-route.test.ts 5 failed / 61 passed,错误与 CI 逐字一致;修复后 66/66 passed。
  • 相关套件:dispatch-user-route + find-launched-cli-pid + worker-codex-execution-root + worker-busy-ready-recovery,4 文件 187 passed。
  • bun run typecheck 通过。

🤖 Generated with Claude Code

#3569 在 markPromptReady 中新增 refreshSandboxedCliLeafAttestation?.(),
dispatch-user-route 的 screenReady 用裸 with(scope) 跑该函数源码,scope
里没有这个标识符;可选链只挡 nullish 值、挡不住未声明标识符,5 个用例
报 ReferenceError。在 scope 中补 undefined 桩,与相邻的
currentCodexObservedPid 桩一致;真实沙盒叶子路径由 find-launched-cli-pid
套件覆盖。

Co-Authored-By: Claude Fable 5 <[email protected]>

@deepcoldy deepcoldy left a comment

Copy link
Copy Markdown
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

结论:可合,无阻断项。

核对 head 962499bc6:仅 test/dispatch-user-route.test.ts 增加 4 行注释/桩,未改生产代码。根因成立:screenReady 在普通对象上执行裸 with(scope),而 markPromptReady 会解析 refreshSandboxedCliLeafAttestation;?. 只能处理已解析标识符的 nullish 值,不能避免未声明标识符的 ReferenceError。补 undefined 与生产中非沙盒状态一致,不影响其它 CLI 或真实叶子证明路径。

本机验证:

  • 相关 4 文件:187/187 passed。
  • bun run typecheck:通过。
  • 变异复验:移除该桩后稳定复现 5 failed / 61 passed,失败均为 ReferenceError: refreshSandboxedCliLeafAttestation is not defined;还原后 dispatch-user-route 66/66 passed,工作树恢复 PR 原样。
  • 其它 markPromptReady 源码切片调用方走 worker-function-harness 的 Proxy scope,缺失名字回退为 undefined,不需要同样补桩。

非阻断的后续建议:裸 with(scope) 夹具长期仍会随新增可选 worker 全局而变脆,可另起改动统一成 Proxy scope;不必在这次 master 红修复中扩大范围。

当前 CI 尚未全绿,合入仍以首跑全绿为准。

🤖 Generated with Claude Code

@github-actions

Copy link
Copy Markdown

🚀 Released in v3.59.22

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant