Reset dir singletons at file boundaries in isolate:false projects#1046
Merged
pavlovic-ivan merged 1 commit intoJul 23, 2026
Merged
Conversation
Under isolate:false (v2-core, v2-integration) files in a worker fork share
one module graph, so bobbit-dir's project root and the agent-dir runtime
state are shared. docker-args.test.ts points the root at memfs fixture paths
and never restores it, so a later file that relies on the defaults resolves
bobbitStateDir() under the leaked root and fails on a real mkdir under
/memfs (mcp-meta-policy: EACCES/ENOENT). The victim moves with worker
sharding, which is why it passed on the dev box but failed on CI, and retry
cannot mask it — the retry reruns in the same fork.
A setup-file beforeAll runs once per worker, not per file, and beforeEach
runs after the file's own beforeAll. onCollectStart runs per file before its
module loads, so the runner resets the baseline there. env is left alone —
the fork-scoped gateway owns BOBBIT_* as intentional fork-wide state.
Repro (fails on master, passes here):
VITEST_MAX_WORKERS=1 vitest run --project v2-core \
tests2/core/docker-args.test.ts tests2/core/mcp-meta-policy.test.ts
dev-milos
marked this pull request as ready for review
July 23, 2026 10:24
Greptile SummaryAdds a custom per-file Vitest runner that resets shared directory state before collecting tests, and enables it for the non-isolated core and integration projects. Confidence Score: 5/5The PR appears safe to merge, with the reset scoped to the two non-isolated Vitest projects that share directory singleton state. The runner restores both implicated in-memory directory states at each file boundary, while projects using module isolation do not require the custom runner. Important Files Changed
Sequence DiagramsequenceDiagram
participant V as Vitest worker
participant R as FileBoundaryRunner
participant D as Directory singletons
participant T as Test file
V->>R: onCollectStart(file)
R->>D: setProjectRoot(BASELINE_CWD)
R->>D: resetAgentDirStateForTests()
R->>V: super.onCollectStart(file)
V->>T: collect and execute file
Reviews (1): Last reviewed commit: "Reset dir singletons at file boundaries ..." | Re-trigger Greptile |
SuuBro
approved these changes
Jul 23, 2026
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.
mcp-meta-policy.test.tsfails intermittently on CI with a realmkdirunder/memfs/...(EACCES/ENOENT), while passing on the dev box.Cause: under
isolate: false(v2-core, v2-integration) files in a worker fork share one module graph, so bobbit-dir's project root and the agent-dir runtime state are shared.docker-args.test.tssets the root to a memfs fixture path and never restores it, so a later file that relies on the default resolvesbobbitStateDir()under the leaked root. Which file loses depends on worker sharding, so it moved between the dev box and CI, andretry: 3can't mask it — the retry reruns in the same fork.Fix: a custom runner resets the project root and agent-dir state in
onCollectStart, the one hook that runs per file before its module loads.beforeAllin a setup file fires once per worker, andbeforeEachfires after the file's ownbeforeAll, so neither works.process.envis left alone — the fork-scoped gateway ownsBOBBIT_*.Deterministic repro (fails on master, passes here):
Full
test:unitgreen at 2 and 3 workers (965 files); no test files or production code changed.