Repository navigation
test(sessions): close SQLite fixtures before cleanup - #113074
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 4, 2026, 1:06 AM ET / 05:06 UTC. ClawSweeper reviewWhat this changesThe PR closes cached agent and shared SQLite test databases before four session-test fixtures delete their temporary roots. Merge readinessKeep open for maintainer handling: the test-cleanup need remains on current main, but the branch is dirty because one target test was removed and the other three were substantially rewritten. Priority: P3 Review scores
Verification
How this fits togetherSession tests create temporary state directories that session accessors back with cached agent and shared SQLite handles. Teardown must release those handles before removing the fixture root so later tests and Windows cleanup remain isolated. flowchart LR
A[Session test] --> B[Temporary fixture root]
B --> C[Cached agent database]
B --> D[Shared state database]
C --> E[Teardown closes handles]
D --> E
E --> F[Fixture root removal]
Decision needed
Why: The maintainer label prevents automated cleanup, and preserving the useful cleanup requires deciding how to adopt it across current-main test rewrites. Before merge
Agent review detailsSecurityNone. PR surfaceTests +18. Total +18 across 4 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Recreate the two close calls in the three surviving current-main teardowns, omit the deleted normalization test, and rerun the focused suites on the rebased code. Do we have a high-confidence way to reproduce the issue? Yes, at source level: the three current suites remove fixture roots while cached database close helpers are absent; a focused run after rebasing can exercise the teardown order. Is this the best way to solve the issue? No: the four-file stale branch is not the best landing shape because one target was deleted; a three-file current-main patch is the narrowest maintainable repair. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 5a1daf81a554. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
395137e to
4b27783
Compare
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
4b27783 to
1bd736a
Compare
1bd736a to
ae08601
Compare
|
Merged via squash.
|
What Problem This Solves
Session tests removed fixture roots while process-cached agent and shared-state SQLite handles could still own files below those roots. The leaked owners contaminate later tests and can make Windows directory removal fail with
EBUSY.The three surviving original suites remain repaired. The stale fourth original target was deleted from
mainand stays omitted. A current-main sibling in the entry-freshness suite is repaired under the same invariant.Why This Change Was Made
Every affected teardown now closes cached agent databases first, closes the shared-state database second, and only then removes tracked fixture roots. The order is required because closing an agent database releases its durable lease through a shared-state write transaction; closing shared state first would let the agent close reopen it.
Temporary roots are registered by their producers and removed through the canonical
cleanupTempDirshelper, matching #113342.createFixtureSuitenow owns that policy for all of its consumers instead of maintaining a second removal implementation.The sequential regression opens the real agent and shared-state cache owners, then proves the next test observes both owners closed and the prior root removed.
User Impact
Developers and CI workers get deterministic SQLite fixture teardown without stale cached handles. Production behavior and persisted schemas are unchanged.
The PR is currently blocked from landing because current
mainfails the core-test typecheck in an unrelated file:src/sessions/user-turn-transcript.test.ts:548references an undefinedcreateTempDir. This PR does not touch that file, and no gate is bypassed.Evidence
node scripts/run-vitest.mjs src/config/sessions/session-accessor.test.ts -- -t 'session database teardown boundary'):Test Files 1 failedTests 1 failed | 1 passed | 105 skipped[vitest] FAILED (exit 1)Test Files 1 passedTests 2 passed | 105 skipped[test] passed 1 Vitest shard in 4.23snode scripts/run-vitest.mjs src/config/sessions/ambient-transcript-watermark.test.ts src/config/sessions/entry-freshness.test.ts src/config/sessions/session-accessor.test.ts src/config/sessions/session-registry-maintenance.test.ts src/config/sessions/store.pruning.test.tsTest Files 5 passedTests 176 passed[test] passed 1 Vitest shard in 32.20snode scripts/check-changed.mjs):tbx_01kzkav12v0k8g6tt67j85ge96src/sessions/user-turn-transcript.test.ts:548:19withTS2304: Cannot find name 'createTempDir'[check:changed] FAILED (exit 1); landing intentionally stopped under the red-main rulegit diff --check: passed.1bd736ac6065: clean after one round; no accepted/actionable findings, confidence 0.99.AI-assisted: yes.