Repository navigation
test(fence): 写真实 HOME 的五个测试在围栏没生效时拒跑 - #2997
Merged
Merged
Conversation
这五个文件会按 homedir() 往 HOME 下写东西,全靠 setupFiles/preload 把 HOME 换成临时目录。 绕过围栏的运行(如 0 字节 vitest 配置)里,写入会落到真实 HOME: - session-lifecycle-start:经 ensureCliSkills 装 ~/.config/opencode/plugin/botmux-ask.js、 ~/.trae/traecli.toml、~/.codex/config.toml;2026-11-06 真实的 opencode 插件就是这样被改写的; - worker-codex-model-migration-picker:写 ~/.zshrc、~/.botmux,假 codex 子进程往 ~/.codex 写 history.jsonl 和 sessions(当天真实的 Codex 历史被追加了 4 行;~/.zshrc 的写入是之后加的, 再来一次会直接覆盖); - recall-frozen-cards:写 ~/.claude/projects 下的会话转录; - durable-lark-canonical-dispatch、durable-session-primary:在 ~/temp 下建 SQLite 临时目录。 每个文件: - 以 require-fenced-data-dir 作为第一个 import:数据目录围栏没执行时整文件拒跑; - import 之后立即确认 homedir() 在本文件的测试围栏里,否则加载阶段就抛错,一个文件都不写。 Co-Authored-By: Claude Opus 5.5 <[email protected]>
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 08:54
This was referenced Nov 7, 2026
…des #3026 switch-confirm race fix)
|
🚀 Released in v3.59.0 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
2026-11-06 一次绕过
setupFiles的全量运行(0 字节 vitest 配置)里,测试按homedir()写的文件落到了真实 HOME。本 PR 补上另外五个同类文件的围栏,做法和 #2976、#2977、#2996 一致。test/session-lifecycle-start.test.tsensureCliSkills改写~/.config/opencode/plugin/botmux-ask.js,往~/.codex/config.toml、~/.trae/traecli.toml追加 MCP 段落,写~/.botmux/usagetest/worker-codex-model-migration-picker.integration.test.ts~/.zshrc,往~/.codex/history.jsonl追加、写~/.codex/sessions/rollout-*.jsonl,建~/.botmuxtest/recall-frozen-cards.test.ts~/.claude/projects/<cwd>/usage-fresh-sid.jsonltest/durable-lark-canonical-dispatch.test.ts~/temp及其下的 SQLite 临时目录test/durable-session-primary.test.ts11-06 当天已经发生的:opencode 插件被改写成指向评审 worktree 的版本、Codex 历史被追加 4 行测试夹具、
~/.claude/projects和~/temp多出测试目录(均已备份后还原/删除)。~/.zshrc的写入是之后 #2925 加进来的,当天没覆盖,但在现在的 master 上再来一次就会覆盖。改动
每个文件:
./helpers/require-fenced-data-dir.js作为第一个 import:数据目录围栏没执行时整文件拒跑;homedir()在__TEST_DATA_DIR_FENCE里,否则加载阶段就抛错,一个文件都不写。只改测试,不改生产代码。
验证
正常运行(均在 isolate-run 里):
vitest run --project unit五个文件:5/5 文件、507/507 用例通过;bun test --timeout=180000(bun 腿只包含其中三个:迁移选择器和两个 durable;另外两个按bun-leg-selectors交给 vitest):58/58 通过。复现事故运行:
scripts/fenced-run.ts给临时 HOME,预先放好~/.zshrc、opencode 插件、~/.codex/history.jsonl、~/.codex/config.toml、~/.trae/traecli.toml五个哨兵文件,再用 0 字节 vitest 配置逐个跑:.zshrc被覆盖、Codex 历史被追加、多出 sessions 文件~/.claude/projects/...~/temp~/temp另单独验证了第二道检查:数据目录在围栏内、HOME 指向围栏外时,
durable-session-primary和recall-frozen-cards报refusing to run: HOME ... is not inside the test fence。未包含
扫描时还发现几个写
~/.botmux数据目录(不是 HOME 下其他配置)的文件:mojo-skill-injection-modes、scheduler-silent-execute、trigger-session-root-message、dashboard-ipc。它们不在本 PR 范围内,记在 #2998。本 PR 不发版、不部署。
🤖 Generated with Claude Code