Repository navigation
[PR] test: sandbox XDG base dirs in the suite preload so bare runs stop writing real $HOME (#5116) - #5119
[PR] test: sandbox XDG base dirs in the suite preload so bare runs stop writing real $HOME (#5116)#5119ranxianglei wants to merge 1 commit into
Conversation
…iting real $HOME (#5116) - tests/test-sandbox-env.mjs: unset/empty XDG_DATA/STATE/CACHE/CONFIG_HOME -> per-process mkdtemp root (data/state/cache/config subdirs); an explicitly set non-empty value always wins; root reported as BILI_TEST_XDG_ROOT - preload-storage-baseline.mjs applies it, covering every invocation point (npm test via test-suite-lock, scripts/run-ci-tests.mjs, measure-test-durations) - tests/test-sandbox-env.test.ts: resolver semantics matrix + live-process contract (bili default path resolutions never land in the real home tree; fails on a bare run that skipped the preload) - docs: canonical targeted-run form always carries the preload (AGENTS.md, reference/testing.md, UNIFIED_LOOP_SPEC.md); BILI_TEST_XDG_ROOT documented in reference/env-vars.md
📦 Built Package ArtifactBranch: Latest build — install this exact versionnpm install -g billion-context@0.0.6740-pr.5119.4a9905eThis exact version is immutable and reproducible. The rolling Recent builds (commit → version)
Download artifact
tar xzf billion-context-pr5119.tgz
npm install -g packageInstall instructions are refreshed on each push. |
|
(ai: vllm-qwen/qwen3.8-27b) Heads-up — overlapping PR: PR #5120 (issue #5107, opened earlier, same mechanism: test runs resolving the real XDG defaults instead of sandboxed roots) also lands a preload that redirects the four XDG roots. Both preloads cannot merge as-is — they'd fight over the same env vars. Comparison + recommendation (keep #5120 as the base for its leak guard — the explicit acceptance item of #5107 — plus e2e/CI wiring; optionally absorb this PR's |
(ai: vllm-qwen/qwen3.8-27b) 查重结论更新(修正我首条回复「合并 #5119」的建议):我首轮扫描后 #5120 才开出来(08:16Z,对应 #5107 —— 三个 issue 里最早的一个,#5107 < #5116,同症状同机制)。三方关系:
对 #5119 本身的独立审核结论(我逐行读了代码,不复述他处结论):机制成立——修在 runner 入口层(疏不堵);四个 XDG key 清单完整覆盖 但横向对比的判定与 #5116 线程一致:#5120 是更强的主体,三条独立理由:
#5119 值得吸收进 #5120 的独有贡献:① 诚实边界:我对 #5120 的评估基于其 PR 描述 + #5107 线程的详细披露(机制级),逐行 diff 审核因出站网络故障暂做不了——#5120 合并前应有一份完整 diff review,网络恢复后我来补或另派。两 issue 严重度标注不一致(#5107 p3 / #5116 p2),同一机制,终局由你定。 八问(决策请求)
选项对比:A(推荐)= #5120 主体 + 吸收 #5119 的 ①②③,退役 #5119/#5115;B = 合 #5119,#5120 的守卫与 e2e 接线作废(#5107 验收项落空);C = 都合(预载冲突,不建议);D = 全部 hold(污染持续累积)。 我的建议:A。所有关闭动作等你一句话——我不自行关闭任何条目。 |
(ai: vllm-qwen/qwen3.8-27b) 局势更新(取代我此前的选项建议):裁决期间 #5115 已合入 master(9628bb5,08:28Z)——止血版先行落地。我已按 9628bb5 逐项核对它实际带来的内容: master 现已覆盖:预载 #5120 对照(open,base 仍是旧的 885b948):文件清单已核——覆盖 ①②③(无条件重定向四个根 + BILI_SESSIONS_DIR/BILI_CONFIG_FILE、守卫、e2e 接线),不覆盖 ④(不碰 AGENTS.md/UNIFIED_LOOP_SPEC),也不碰 preload-storage-baseline.mjs(与 #5115 的内联沙箱共存; 对本 PR 的影响:我的 rebase head 若推出,会与 #5115 的内联代码对同一组 env var 双重沙箱——冲突的重复机制,因此不再推送(更正我之前「网络恢复即推」的说法)。本 PR 的独有贡献现在只剩:④ 文档(修法已备好,四处改动)与 BILI_TEST_XDG_ROOT 观测(可选,#5115 的临时根可用 已执行动作:本 PR 打 八问(决策请求)
选项:A(推荐)= #5120 rebase+review+合并 + ④ 文档修入(并入或独立,你选)+ 退役本 PR;B = 只留止血,放弃守卫/e2e;C = 保活本 PR 与 #5120 竞争语义。 等你一句话:A/B/C + 本 PR 关闭确认。选 A 的话我立即执行 ④ 文档修(四处改动的 diff 已在我手上)。 |
(ai: vllm-qwen/qwen3.8-27b) 查重: 重复 #5115(已合入 master 9628bb5)——沿用 floor 3/6/7 的结论:同症状同机制,#5115 止血版先合,本 PR 已打 本轮冲突处理(attempt 1/2):非机械冲突,不硬救。 查证结果:
已执行动作:按 owner policy 2026-10-25(禁止静默等待),把 floor 7 的 A/B/C 选项升级为可跟踪的 p1 决策项 → decision request #5126(p1、scope/ci):A(推荐)= 以 #5120 为主体(rebase + 完整 diff review + 合并,覆盖 CONFIG 洞 / 泄漏守卫 / e2e 入口)+ 本 PR 文档修并入或独立小 follow-up + 退役本 PR;B = 只留 #5115 止血(#5107 验收项悬空);C = 双预载保活竞争(不建议)。未推送新 head,未关闭任何条目(关闭权在你)。 八问
判定:本轮冲突处理到此为止——不推、不关;决策项 #5126 等你 A/B/C 拍板(含本 PR 关闭确认)。拍板后我立即按所选选项执行。 |
|
(ai: vllm-qwen/qwen3.8-27b) Merge-guard outcome: stopped before pushing — this conflict needs an owner design decision, not a mechanical merge. Merging Opened decision request #5194 (p1) with options A/B/C plus a recommendation (Option B: adopt this PR\u0027s 4-dir module as the bare-run layer, keep #5107 for the full suite, drop the now-redundant #5082 inline block). Holding this PR until that is decided — no push made. |
|
(ai: vllm-qwen/qwen3.8-27b) Merge-guard re-trigger: still held, no push. Updated decision request #5194 — both competing PRs (#5115, #5120) have since merged to master ( |
[ework] CI fix verified green ✓ |
5 similar comments
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
🔶 需要决策 No change since my 🔶 需要决策 above — still holding for your A/B/C call. Re-verified live this run:
The conflict is still the same non-mechanical mechanism choice (PR's 4-dir |
[bot] 🏷 Status — PR #5119 CI lane (attempt 1/3), holding on a decision. (ai: vllm-qwen/qwen3.8-27b) What I did this run:
Current state: blocked awaiting your A/B/C — nothing to fix mechanically on the auto-fix lane. This run: no push, no close, no new issue. Once you pick, I'll execute (A = rebase resolving toward the 4-dir module + union the docs, force-push; B/C = report only, you close). Live re-check moments ago confirms still no owner decision posted after my escalation. |
[ework] CI fix verified green ✓ |
[bot] 🏷 Still holding — no owner decision yet. (ai: vllm-qwen/qwen3.8-27b) Re-verified live this run:
No push, no close, no new issue. Awaiting your call: A keep-&-rebase (adopt the 4-dir module, supplant #5115, ship |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
[bot] 🏷 Still blocked on your A/B/C call — a full day with no decision yet. (ai: vllm-qwen/qwen3.8-27b) Re-verified live this run:
The conflict stays a design decision, not a mechanical fix: PR's 4-dir Need your pick: A keep-&-rebase (adopt 4-dir, supplant #5115, ship the knob) / B close-as-superseded / C docs-only salvage. I'll act immediately on whichever you choose. No push, no close, no new issue meanwhile. |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
[bot] 🏷 Still blocked on your A/B/C call — two days, no decision yet. (ai: vllm-qwen/qwen3.8-27b) Re-verified live this run:
The conflict is a design decision, not a mechanical fix: PR's 4-dir Need your pick: A keep-&-rebase (adopt 4-dir, supplant #5115, ship the knob) / B close-as-superseded / C docs-only salvage. I'll act immediately on whichever you choose. No push, no close, no new issue meanwhile. |
[ework] CI fix verified green ✓ |
[bot] 🏷 Still blocked on your A/B/C call — three days, no decision yet. (ai: vllm-qwen/qwen3.8-27b) Re-verified live this run:
The conflict is a design decision, not a mechanical fix: PR's 4-dir Need your pick: A keep-&-rebase (adopt 4-dir, supplant #5115, ship the knob) / B close-as-superseded / C docs-only salvage. I'll act immediately on whichever you choose. No push, no close, no new issue meanwhile. |
[bot] 🏷 No change — still blocked on your A/B/C (PR open / non-mergeable at |
[ework] CI fix verified green ✓ |
2 similar comments
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
[bot] 🏷 No change — still blocked on your A/B/C (PR open / non-mergeable at |
[ework] CI fix verified green ✓ |
[bot] 🏷 No change — still blocked on your A/B/C (PR open / non-mergeable at |
[ework] CI fix verified green ✓ |
2 similar comments
[ework] CI fix verified green ✓ |
[ework] CI fix verified green ✓ |
[bot] 🏷 No change — still blocked on your A/B/C (PR open / non-mergeable at |
[ework] CI fix verified green ✓ |
[bot] 🏷 No change — still blocked on your A/B/C (PR open / non-mergeable at |
[ework] CI fix verified green ✓ |
[bot] 🏷 No change — still blocked on your A/B/C (PR open / non-mergeable at |
[ework] CI fix verified green ✓ |
1 similar comment
[ework] CI fix verified green ✓ |
[bot] 🏷 No change — still blocked on your A/B/C (PR open / non-mergeable at |
[ework] CI fix verified green ✓ |
[bot] 🏷 No change — still blocked on your A/B/C (PR open / non-mergeable at |
[ework] CI fix verified green ✓ |
Closes #5116
What & why
Local test runs were writing into the real
$HOME: bare targeted runs (node --import tsx --test tests/<file>.test.ts) skipped the preload entirely, and even the suite preload only pinnedBILI_STORAGE_UNIFIED— so any test that did not pin its own XDG dirs landedsessions/index.dbrows, session envelopes, and state files in the production~/.local/.../billion-contexttree.The fix sits at the runner entry point (the preload), not per-test-file band-aids: the preload now sandboxes the four XDG base dirs to a per-process temp root. Explicit values always win, so every existing test that pins its own dirs (the large majority) is untouched; tests that delete a dir before asserting the homedir fallback still work (deletion happens after the preload).
Changes
tests/test-sandbox-env.mjs(new):sandboxXdgEnv(env)— unset-or-emptyXDG_DATA_HOME/XDG_STATE_HOME/XDG_CACHE_HOME/XDG_CONFIG_HOME→ onemkdtemproot underos.tmpdir()withdata|state|cache|configsubdirs; non-empty explicit values always win; root reported asBILI_TEST_XDG_ROOT; no auto-cleanup (OS tmp reaping + inspectable on failure).tests/preload-storage-baseline.mjs: applies the sandbox — covers every invocation point (npm testvia test-suite-lock,scripts/run-ci-tests.mjs,measure-test-durations).tests/test-sandbox-env.test.ts+tests/test-sandbox-env.d.mts(new): resolver semantics matrix (unset→tmp / empty-string→tmp / set→wins / all-pinned→no-op) plus a live-process contract: bili's default path resolutions (dataDir/sessionsDir/stateDir/cacheDir/configDir/defaultLogFile) never land in the real home tree. Verified as negative control: running the test bare (no preload) fails both live assertions.BILI_TEST_XDG_ROOTdocumented in reference/env-vars.md under the test-infra escape hatches.Behavior changes (disclosure)
~/.config/billion-context/billion-context.json.XDG_CONFIG_HOMEwas added to the sandbox beyond the issue's DATA/STATE/CACHE list — same mechanism family, and it closes the hermeticity hole where local runs picked up the developer's live config while CI runners never did. Old: config-unpinned tests read whatever was on the machine (non-deterministic across machines). New: tests see an empty config dir, matching CI.BILI_TEST_XDG_ROOT— written by the preload, read by the contract test, tells you where a given test process's artifacts landed. Not a product knob; product code never reads it.os.tmpdir()/bili-test-xdg-*(one root per test-file process; not auto-cleaned).src/untouched; no runtime behavior change for users.Verification
anthropic-cache-control.test.ts): without preload →index.db+ envelopes + state files written into home (bug reproduced); with preload → 0 files under home, identical layout under.tmp/bili-test-xdg-*.