Repository navigation
[PR] Running tests locally writes test sessions into the real ~/.local/billion-context — preload sandboxes the default direct | 本地跑测试会把测试会话写进真实的 ~/.local/billion-context——预载把默认目录沙箱化(Fixes #5114) - #5115
Conversation
Suites that build stores/servers without pinning a directory resolve
through the XDG defaults into the developer's real ~/.local/{share,state,
cache}/billion-context — envelopes, index.db rows, and state bookkeeping
land beside production data (found triaging #5082: a local run of
tests/anthropic-cache-control.test.ts wrote sess-1639-* rows and
sessions/anthropic/127.0.0.1_* envelopes into the live sessions dir; the
legacy storage baseline stops the SQLite rows but not the files).
The preload now points XDG_DATA_HOME/XDG_STATE_HOME/XDG_CACHE_HOME at a
per-run temp tree via ||= (empty counts as unset, matching the lock
script's XDG handling); explicit env and tests pinning their own dirs win
unchanged. Contract pinned by tests/preload-sandbox-dirs.test.ts;
reference/testing.md documents the recommended targeted-run form.
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6734-pr.5115.46f057cThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5115.tgz
npm install -g packageInstall instructions are refreshed on each push. |
The new contract test spawns a child node process, so the run-ci-tests SPAWN_RE tripwire requires a LIVE_FILES entry (#1248 discipline).
(ai: vllm/qwen3.8-27b) 查重: 不重复。 与 #5091(已合并,#5082 的二次进程告警修复)同源于一次调查,但机制不同:#5091 修的是「第二个进程打开 index.db 被误报为损坏」的告警逻辑;本 PR 修的是「未钉目录的测试走 XDG 默认路径写进真实目录」的路径解析问题。两者无代码交集。另核对了 GitHub API:本 PR 的 标签: bug + scope/ci + p2(测试基建缺陷:本地跑测试污染生产存储,有绕行——自钉目录的套件不受影响;非 p1,不属缓存泄露/不可用类)。 审核进行中:已拉取分支 |
(ai: vllm/qwen3.8-27b) 审核结论:可合入。 独立复现 + 定向验证均通过,CI 全绿(30/30,failed 0 / pending 0,含 kernel-guard、config-surface-guard、windows 车道)。以下为八问。 1. 是什么问题:本地跑测试时,没钉目录的 store/server 构造走 XDG 默认路径解析,把测试会话(envelope、index.db 行、state 簿记文件、缓存)写进开发者真实的 billion-context 目录,生产存储被测试数据污染。 2. 什么原因导致的:三层缺口叠加——①共享预载 3. 影响范围与严重程度:所有在开发机跑套件的人——生产库累积数百个假会话,面板把测试会话当真会话展示,#4323 drift 采样被干扰。终端用户不受影响(纯测试基建);p2 定位准确。 4. 怎么修复的:在共享预载里把三个 XDG 默认根(data/state/cache)指到 per-run mkdtemp 临时树,用 5. 是否有回归问题——逐项审过的既有行为:
6. 是否破坏缓存:不涉及(未触碰任何缓存/重试/游标逻辑)。 7. 是否改了设计方向:不涉及——纯测试基建加固,无架构变化,未触碰 kernel/(kernel-guard 绿)。 8. 是否引入了新的配置:没有——PR 明确不新增 env var,显式设 XDG_* 即表达「故意用真实目录」;config surface 零变化(config-surface-guard 绿)。 我的独立验证记录(非转述作者表格):
边界处理认可:生产库存量脏数据(364+ 测试行/envelope)属对生产数据的写操作,留在本 PR 之外待你确认后单独清理,处置正确。 判定:可合入,等你合并(我不代合)。 |
📦 Merged Build PublishedThis merge to master was published as npm install -g billion-context@0.0.903-master.9628bb5 # this exact build
npm install -g billion-context@master # always the newest merged build
|
…ad (#5107) The preload pointed BILI_SESSIONS_DIR/XDG_* at mkdtemp subdirs that were never created. An explicit BILI_SESSIONS_DIR pointing at a MISSING dir is not the pristine default layout — #2180/#1937 keep that loud on purpose: walkSessionFiles' top-level ENOENT propagates out of refreshIndex and /__bili/overview 500s with 'failed to load session data'. Every suite that boots a proxy and reads the web overview or sessions index failed deterministically — CI run 40841436177 went red on all 10 shards; local repro of shard 1/3 found exactly this signature (log line: overview failed: Error: ENOENT scandir <tmp>/bili-test-*/sessions) in tests/issue2645-pck-probe.test.ts (undefined pckSuppressions -> TypeError reading 'length') and tests/upstream-alerts.test.ts (#1682 rows: 500 !== 200, banner timeout). Create the five advertised dirs at preload time: an existing EMPTY dir is the normal 'no sessions yet' state the read paths already handle, while the override stays explicit (loud-on-misconfig semantics untouched). A/B evidence: issue2645 file 1 fail -> 8/8 pass post-patch; upstream-alerts + web-storage-banner + preload-sandbox-dirs (#5115 contract) + test-suite-lock (leak guard) = 46/46 pass; typecheck clean.
#4599) Master red at 1fad21d (run 40852517737, 6 shards): two mechanisms, both in the #5107/#5115/#5120 hermetic data-root cluster. 1. preload-test-env.mjs pinned BILI_CONFIG_FILE to an absent file. configFile() (src/paths.ts) consults that env BEFORE the XDG default, so the pin shadowed every fixture that re-points XDG_CONFIG_HOME at its own dir and writes the default config path: the claude-native attach-gate / lane-priority / policy / url file-layer assertions failed on all shards, and the #3436 compat checks resolved mitm.domains=[] -> spawn path -> 60s fake-child timeout. The XDG_CONFIG_HOME pin already keeps the default config path inside the throwaway root; DELETE the env instead of pinning so fixtures are un-shadowed AND a developer's ambient pin is dropped. The isolation probe now asserts configFile() resolves UNDER the sandboxed XDG_CONFIG_HOME (same property, sibling-check style) instead of equality with the removed pin. 2. test-suite-lock.mjs snapshotSessionsTree keyed entries by raw path.relative(): Windows yields 'anthropic\\s.json' while the diff, the banner and the tests all compare '/'-separated paths (4 failures on the windows s2 shards). Normalize keys to '/' at the source. Verified locally with the CI preload chain (targeted): claude-native + #3436 + test-suite-lock suites 96/96 pass, 0 fail. Windows separator behavior holds by construction (split(path.sep).join('/')); full verdict = remote CI.
(ai: zhipuai-lb/glm-5.2)
Fixes #5114(发现于 #5082 调查,与已合并的 #5091 是同一调查的两个独立问题)。
什么东西坏了
本地跑测试时,凡是没钉目录的 store/server 构造走默认 XDG 路径解析,直接写进真实的
~/.local/{share,state,cache}/billion-context:tests/anthropic-cache-control.test.ts一个文件就往生产sessions/index.db写sess-1637/1639/1876-*行、往sessions/anthropic/写127.0.0.1_*.jsonenvelope、改写 state 目录的prefix-affinity.json/rollout-id.json/proxy-origin。生产库混进 364+ 测试会话,面板/诊断把测试会话当真会话,#4323 drift 采样也被干扰。为什么没拦住
npm test/CI 都加载tests/preload-storage-baseline.mjs,但它只定了BILI_STORAGE_UNIFIED=legacy(挡住 SQLite 行写入);envelope、state、cache 文件照走真实目录。裸 targeted 跑(node --import tsx --test …)连预载都不加载,行+文件全写。怎么修的
预载里把三个 XDG 默认指到 per-run 临时树(
$TMPDIR/bili-test-dirs-*/{data,state,cache}):||=赋值:显式设置的 CI 容器、自钉目录的测试(launcher/claude-native/doctor 等大量自设 XDG 的套件)完全不受影响;空串视同未设置,与scripts/test-suite-lock.mjs的 XDG 处理口径一致。XDG_CONFIG_HOME不动——配置读取行为不变。tests/preload-sandbox-dirs.test.ts钉住两方向:默认进沙箱 + 显式环境永远赢(负断言)。reference/testing.md:targeted 跑法统一推荐带预载链的形式。验证
npm run typecheck已知本地噪音(与本改动无关):
tests/doctor.test.ts在本机带不带预载都同样失败(mock registry 断言),以 CI 为准(§7.2)。边界