Repository navigation
test(fence): 四个写数据目录的测试文件在围栏外直接拒跑 - #3047
Merged
Merged
Conversation
mojo-skill-injection-modes、scheduler-silent-execute、 trigger-session-root-message、dashboard-ipc 没有导入数据目录围栏守卫。 绕过 setupFiles 运行时(例如 0 字节 vitest 配置)它们照常跑完,并把 mojo-containment-handles.json、prompt-ctx、async-triggers、queues、 session-stores、bots/<appId>/schedules.json 写进继承来的 SESSION_DATA_DIR, 在 botmux 会话里就是线上数据目录。 四个文件把 ./helpers/require-fenced-data-dir.js 作为第一个 import; mojo 文件额外断言 mojo 隔离工作区根在围栏内,dashboard-ipc 额外断言 homedir() 在围栏内。
deepcoldy
requested review from
47seek,
LucasIcarus,
xiaoxueSunn and
xiongz-c
as code owners
November 7, 2026 11:36
This was referenced Nov 7, 2026
|
🚀 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.
Fixes #2998
症状
用 0 字节 vitest 配置(绕过
setupFiles)单跑下面四个文件时,它们照常全部跑完,并把数据写进继承来的SESSION_DATA_DIR。在 botmux 会话里,这个变量指向线上的~/.botmux/data。在临时 HOME 里复现到的写入:
test/mojo-skill-injection-modes.test.tsdata/mojo-containment-handles.jsontest/scheduler-silent-execute.test.tsdata/prompt-ctx/sess-live/*、bots/cli_app_test/schedules.jsontest/trigger-session-root-message.test.tsdata/async-triggers/sess_existing.jsontest/dashboard-ipc.test.tsdata/queues/*、data/session-stores/test-app/sessions.db*、data/read-isolation/*、bots/cli_ipc_test_bot001/schedules.json根因
这四个文件没有导入
test/helpers/require-fenced-data-dir.ts。围栏只通过setupFiles生效,绕过它时没有任何东西阻止文件运行。它们也没有 mocknode:fs,所以test-hygiene的 fs-mock 扫描覆盖不到。修法
和 #2997 同一做法:
./helpers/require-fenced-data-dir.js作为第一个 import。围栏没生效时整个文件在导入阶段就失败。mojo-skill-injection-modes断言 mojo 隔离工作区根在__TEST_DATA_DIR_FENCE里。这个根取BOTMUX_MOJO_WORKSPACE_ROOT,未设置时由homedir()推导。dashboard-ipc断言homedir()在围栏里。只改测试文件,不动 src 和 helper。
验证
所有命令都经
scripts/fenced-run.ts在临时 HOME 和私有 tmux socket 下运行,PATH 里去掉了~/.botmux,并清掉了BOTMUX_*环境变量。refusing to run: data-dir fence not active,no tests,临时 HOME 里没有写入任何文件。__TEST_DATA_DIR_FENCE和SESSION_DATA_DIR、HOME 仍在围栏外时:refusing to run: mojo workspace … is not inside the test fence。refusing to run: HOME … is not inside the test fence。vitest run四个文件:549 passed,3 skipped。test/test-hygiene.test.ts:28 passed。bun run build(含 tsc)通过。