test(memory): isolate the global config dir per test file (CI fix) - #237
Merged
Conversation
Second dev-CI failure investigation (run 31648866555) with the identity-fixture fix in place: the same assertion still failed, still with no visible warning. Verified root cause: bun test runs all files in ONE process, sequentially, sharing one XDG_CONFIG_HOME. A file that runs before this one and triggers global-memory initialization (memory.test prepare, or instance boot via bootstrap.ts memory.init) leaves a VALID global memory.jsonc whose model this file's fake provider does not know. writeGlobal then silently no-ops over the valid file (config.ts returns false), configuration() loads the foreign model, resolveModel fails (the warning is captured by TestConsole and never reaches CI logs), and search fails closed with "unavailable". R1-00's identical flow passes because R1-07's finalizer removes the global file in between. CI-only because bun's file order is deterministic per filesystem state and the fresh CI checkout orders a contaminator before this file. Fix: pin a private OPENCODE_CONFIG_DIR per file (beforeAll/afterAll, live env getter — globalConfigDir reads it at call time) so the global file can never be contaminated by earlier files, plus a tripwire assertion after writeGlobal that the loaded global config carries the expected model. Registered separately (product hardening): writeGlobal should log when it declines to overwrite an existing valid config. Co-Authored-By: Claude <noreply@anthropic.com>
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.
第二轮 CI 调查确认根因:bun test 单进程顺序执行共享一个 XDG 配置目录——先前文件触发全局 memory 初始化留下含外来 model 的有效 memory.jsonc → writeGlobal 静默 no-op → load 外来 model → resolveModel 失败(警告被 TestConsole 吞)→ search 静默 "unavailable"。修复:per-file 钉死 OPENCODE_CONFIG_DIR + writeGlobal 后 tripwire 断言 model。产品加固(writeGlobal 拒绝覆盖时应打日志)登记为独立项。
Fixes #233
🤖 Generated with Claude Code