Repository navigation
test(memory-core): release cached databases before removing fixture state dirs - #128310
Conversation
…re dirs Six memory-core fixtures remove their temporary state directory while the per-agent or shared SQLite handles opened underneath it are still cached, so Windows fails the removal with EBUSY while Linux unlinks the open files and stays green. Release both handles before each removal, in the ordering merged for this class: the agent close releases its leases through shared state and reopens it, so the shared store has to be released after it.
…ss and cli teardown
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 2:43 PM ET / 18:43 UTC. ClawSweeper reviewWhat this changesThe PR closes cached per-agent and shared SQLite test databases before Memory Core fixtures delete their temporary state directories, preventing Windows EBUSY teardown failures. Merge readiness✅ Ready for maintainer review Keep this PR open: it is a focused, test-only repair for current-main fixture cleanup, and no patch defect was found. The ordered calls match the existing SQLite cache contracts and the merged gateway teardown precedent. Priority: P2 Review scores
Verification
How this fits togetherMemory Core tests create temporary OpenClaw state directories containing shared and per-agent SQLite databases. Teardown must release cached handles before removing the directory so Windows can unlink database and WAL files. flowchart LR
A[Memory Core test fixture] --> B[Temporary state directory]
B --> C[Cached agent database]
B --> D[Cached shared state database]
C --> E[Ordered handle cleanup]
D --> E
E --> F[Remove fixture directory]
Before mergeNone. Agent review detailsSecurityNone. PR surfaceSource +8, Tests +36. Total +44 across 8 files. View PR surface stats
Review metrics
Technical reviewBest possible solution: Merge the existing test-only cleanup at the fixture owners, preserving the agent-handle then shared-state-handle order and its focused Windows proof. Do we have a high-confidence way to reproduce the issue? Yes—source-reproducible: current main deletes fixture roots while the relevant agent and shared-state caches can remain open, and the PR supplies a concrete native-Windows before/after command and mutation evidence. Is this the best way to solve the issue? Yes: existing helpers already own agent-cache and shared-state cleanup, and calling them at each directory owner preserves production code while matching the merged ordering precedent. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against d91627261791. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
…tate dirs (openclaw#128310) * test(memory-core): release cached state handles before removing fixture dirs Six memory-core fixtures remove their temporary state directory while the per-agent or shared SQLite handles opened underneath it are still cached, so Windows fails the removal with EBUSY while Linux unlinks the open files and stays green. Release both handles before each removal, in the ordering merged for this class: the agent close releases its leases through shared state and reopens it, so the shared store has to be released after it. * test(memory-core): release cached handles in the shared fixture harness and cli teardown
Related: #119796
Additional instructions
MUST: Keep Allow edits from maintainers enabled for this PR so maintainers
can help update the branch when needed.
What Problem This Solves
Fixes an issue where contributors on Windows cannot get a green local run of
extensions/memory-core:eleven suites in the
extension-memoryshard fail in teardown withEBUSY: resource busy or locked,never in an assertion. Each fixture removes its temporary state directory while a SQLite handle
opened underneath it is still cached, so the removal fails and the suite is reported as failed even
though every assertion in it passed. On Linux, unlinking an open file succeeds, so CI never sees it.
The file named varies between the shared state database, the per-agent database and their
-wal/-shmcompanions, because the removal walks the directory.Why This Change Was Made
Each fixture now releases the databases it actually leaves open, immediately before the removal,
in the ordering merged for this class in #127201: close the cached per-agent databases first, then
the shared state store.
The order is load-bearing, not decoration. The agent close releases its leases through shared
state, which reopens it, so releasing shared state first only moves the lock from
openclaw-agent.sqlitetostate\openclaw.sqlite-wal.src/test-helpers.tsis the shared harness: itsafterAllremoved the fixture root withoutreleasing anything, which is why four suites that never touch a state path of their own
(
dreaming-narrative,dreaming-phases,redaction-product-boundaries,session-backfill)failed at suite level. One teardown covers all four.
manager-sync-ops.startup-catchup.test.tsanddreaming-startup-cleanup.test.tsalready closedthe agent databases and never released the shared store, so only the store release was added.
manager.reindex-recovery.test.ts,manager.fts-only-reindex.test.ts,manager.self-heal-missing-identity.test.ts,manager.watcher-config.test.tsandcli.test.tsreleased neither at the removal point, so both calls were added in that order.
Tests only; no production file is touched.
User Impact
Contributors on Windows can run the
extensions/memory-coresuites to completion instead of readingteardown failures that have nothing to do with the code under test. Behavior on Linux and macOS is
unchanged.
Evidence
Windows 11, Node 24.18.1. Base arm measured twice on
main, at8e04df0205c(this branch's base)and again at
bca206d794b, with identical results; the branch arm is that same tree with only theseeight files patched.
extensions/memory-coremainEBUSYoccurrencesThe four remaining failures are pre-existing on
mainand are notEBUSY: a stale-sqlite-lockcase in
short-term-promotion, a watcher glob case inmanager.watcher-config, a status-output casein
cli, and a timezone case inindex. They are separate Windows defects and this branch does nottouch them.
Both calls are load-bearing. Measured on the five suites that go through the shared harness and the
CLI fixture, same command and same tree, only the teardown mutated:
main(bca206d794b)EBUSYEBUSY(the one failure is the pre-existingclicase)closeOpenClawAgentDatabasesForTest()EBUSYonopenclaw-agent.sqliteresetPluginStateStoreForTests()EBUSYonopenclaw.sqliteThe same mutation pair on the four
src/memory/fixtures that received both calls: dropping theagent close leaves 6 failed / 7
EBUSYonopenclaw-agent.sqlite; dropping the store release leaves9 failed / 10
EBUSYonopenclaw.sqlite../node_modules/.bin/tsgo -p test/tsconfig/tsconfig.extensions.test.json --noEmit-> byte-identicaloutput to
main(the same six pre-existingextensions/acpxerrors, none in these files)./node_modules/.bin/oxlint <the eight files>-> exit 0./node_modules/.bin/oxfmt --check <the eight files>-> exit 0One local note that is not a code issue: once the teardown failures stop, the shard goes quiet for
longer than
scripts/run-vitest.mjs's 120s no-output watchdog allows, so the branch arm was run withOPENCLAW_VITEST_NO_OUTPUT_TIMEOUT_MS=600000. The run itself finishes in the same wall-clock time asthe base arm.
Relationship to the other repairs in this class
Disjoint from every open or merged repair of the same Windows teardown class, so they can land in any
order:
extensions/memory-corewas swept after #127236 landed.doctor-contract-api.test.tsin the samedirectory was repaired by #126352, is green on
main, and is untouched here; the failures thatremained are the ones whose fixtures release nothing, or release only the agent databases, at the
point where they remove their directory.