Skip to content

fix(test): session-store suites fail teardown with ENOTEMPTY while agent-database workers are live - #161871

Merged
steipete merged 27 commits into
mainfrom
steipete/session-store-agent-db-drain
Oct 1, 2026
Merged

steipete merged 27 commits into
mainfrom
steipete/session-store-agent-db-drain

Conversation

@steipete

@steipete steipete commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

Related: #161536 (same fix for src/auto-reply/reply/agent-runner-memory.test.ts; that file is untouched here)

What Problem This Solves

Fixes: test suites intermittently fail teardown with ENOTEMPTY (or leave recreated directories behind) when they remove a temp directory that holds a session store while its agent-database Workers are still running.

User Impact

No user-visible change. Removes a class of CI teardown flakes across about 230 test files in core, agents, gateway, commands, cron, plugins, packages, and extensions, and lowers their summed measured test time by about 6%.

No config, default, or stored-data surface changes and no migration. Of the 225 changed files, all are tests or test support except src/plugin-sdk/sqlite-runtime-testing.ts. That file is a local-only, non-production Plugin SDK testing entry (scripts/lib/plugin-sdk-entries.mts), and it gains one test-helper re-export.

Why This Change Was Made

A custom session storePath resolves to an agent SQLite database inside the same directory. Session entry writes schedule reclamation on a mutation Worker, transcript reads retain history Workers, and plugin loading retains source-capture staging tokens. Those owners retire only when their owner is drained. Suites removed the directory while they were live, so an owner could reopen the database mid-removal (quarantineOrphanedSqliteSidecars creates *.sqlite-wal.orphaned-<ts>) and rmdir failed or the directory came back. The synchronous closeOpenClawAgentDatabasesForTest() does not help: it fires revokeAgentDatabaseResources() without awaiting it.

One test owner now handles this teardown. useSessionStoreTempDirs(afterAll, prefix) in src/test-utils/session-state-cleanup.ts hands out case directories under one canonical suite root and, at suite end, awaits closeOpenClawAgentDatabasesAsync(root), then closeStateDatabaseForTest() (agent lease release can reopen shared state), then removes the root. Extensions use the same helper through the private first-party testing subpath openclaw/plugin-sdk/sqlite-runtime-testing; no public SDK surface changes. Shared fixtures (delivery-queue hooks, Doctor SQLite fixture, browser follow-up fixture, Slack/Copilot/QA/Telegram/iMessage fixtures, and others) drain at their owner so every caller is covered.

A suite-level drain is the default because per-case drains wait for each case's Workers; #161536 measured that at about 20 s on a 124-case suite. Two Gateway fixtures keep a per-case awaited drain because each case gets its own Gateway home: useBrowserFollowupFixture (7 suites) and sessions-create.child-custody. The browser fixture also gets a per-case placement store, because the process-local placement fallback kept the previous case's deleted home open and recreated it. No retries, sleeps, longer timeouts, or weakened assertions were added, and no product code changed.

Also fixed in passing: commands-plugin.test.ts removed its plugin fixture parent while plugin-cache retirement still used a source-capture SQLite staging token under it (seen as SQLITE_IOERR_FSTAT); it now disposes the registry and awaits waitForPluginCacheRetirement() first.

Evidence

Root cause, observed per suite. A temporary, uncommitted probe hooks fs.rm/rmSync/promises.rm and records live agent-DB handles, Worker resources, pending opens, and retained closes under each removed directory, plus whether the directory reappears 1.2 s later. Original code (the same suites at the branch point):

  • auto-reply: live owners at removal in 72 cases plus 2 suite-level removals across all 16 fixed suites.
  • config/sessions, plugin SDK, plugins, sessions, packages: 298 cases plus 4 suite-level removals; 24 root-reappearance observations.
  • agents: 196 removal points across 34 suites, 2 roots recreated after removal; 32/32 targeted cases in the tools/sessions-* suites.
  • gateway, infra, commands, cron: 250 removals across 42 suites, including 2 Gateway HOME directories recreated in the chat-send suites and 23/23 cases in sessions-create.child-custody.
  • extensions and root tests: 264 of 1,330 cases; twitch 4/10.
  • commands-plugin: a capture staging token was still present in 7 of 8 parent removals.

Fixed code: zero owners at removal, zero removal errors, and no reappearing roots in every probed suite.

Checks. All changed test files pass (per-area local runs plus all 828 measured Testbox executions). The 9 affected E2E suites pass on a Linux Testbox. Also clean: pnpm tsgo:core:test, pnpm tsgo:extensions:test, oxfmt, oxlint (core and extension configs), plugin SDK export, surface, and boundary checks, node scripts/report-test-temp-creations.mjs (no warnings), and git diff --check. Codex autoreview (P0–P2) is clean for every lane and for the integrated branch after one accepted finding: a Doctor incident fixture closed shared state before the suite agent drain, now fixed.

Cost. Same-lease A/B on three Blacksmith Testbox leases (Linux, 8 vCPU). The original variant is the complete forward patch reversed on the same lease, with source hashes verified per trial. Each file ran --maxWorkers=1, one discarded warm-up per variant, then O1/F1/O2/F2. Per-file vitest duration covers tests plus hooks, excluding transform.

  • Summed per-file means across 207 changed test files: 903.8 s → 846.2 s (−6.4%). Summed lease walls: O1 2220 s / F1 2128 s / O2 2364 s / F2 1943 s.
  • 20 files exceed the budget flag (F − O > max(1 s, 5%)). 9 are consistent, with both fixed samples slower than both originals by 1–4 s. These are short suites whose final drain now joins reclamation and history Workers that the old teardown abandoned mid-flight. Closing the database cancels pending quiet-window timers, so the drain only waits for work that was already running. The other 11 overlap or flip sign between trials.
  • Six files moved from a project lane into unit-fast because the planner classifies by source text and they no longer call fs directly. They passed there in all trials.
  • Per-case-drain fixtures (useBrowserFollowupFixture's 7 suites plus sessions-create.child-custody) are not changed test files, so a separate same-lease A/B measured them: 55.4 s → 65.4 s (+18%). That result is noisy (pair 1 −1.2 s, pair 2 +21.3 s). Child-custody was slower in all three pairs, +2.0 s mean (+11%). A suite-level alternative passed all 127 tests, but the probe caught 16 recreated Gateway HOMEs. The Gateway test harness removes each case's HOME, and external store leases kept to suite end reopened shared state under it. So the per-case drain is required in those two fixtures.
  • CI seconds: see this PR's checks.

Telegram album E2E in CI. checks-node-changed-2 failed twice on this branch in extensions/telegram/src/bot.media.downloads-media-file-path-no-file-download.e2e.test.ts > "preserves captions and a later mention from every message in a forum album". The reply contained only the second album caption. Investigation on Linux Testbox (8 vCPU, the same size as the CI runner):

  • Natural runs passed on this branch, on the original harness, and on main (29/29 branch, 28/28 original, 20/20 main).
  • Traced replay-dedupe lookups found no leaked claim.
  • A temporary barrier that delays message 302 until the album timer flushes message 301 (about 20 ms) reproduces the failure on both harnesses. The timing race itself therefore predates this change, and it is tracked separately.

Because this branch had deferred the media harness's per-case drains to suite end, earlier cases' agent-database Workers could keep running during later wall-clock-sensitive album cases. The harness now drains each case's store and closes shared state in afterEach (directory removal stays with the suite helper), which restores the original per-case isolation. No timeouts, retries, or assertions changed.

Not covered. Key-gated *.live.test.ts suites were not edited or run. A root-vs-canonical path mismatch in closeOpenClawAgentDatabasesAsync(root) makes raw /var/folders roots miss /private/var databases on macOS. Linux CI is unaffected, so it is tracked separately; this PR only uses canonical roots in the suites it converts. One local run saw an unrelated agent.wait CLIENT_TIMEOUT in chat.abort-live-proof.test.ts under host load around 50. It did not recur, and it was left unchanged rather than masked. Cost numbers were measured at 40f715d. Later commits are merges with main plus small ordering and import fixes.

Cost by project cohort (Testbox, --maxWorkers=1, mean of 2 trials per variant)
Project cohort Files O sum (s) F sum (s) Δ (s) Δ %
agents-core 13 38.568 25.762 -12.806 -33.20%
agents-embedded-agent 4 3.570 3.862 +0.292 +8.19%
agents-embedded-agent-run 4 14.011 8.717 -5.294 -37.78%
agents-support 5 64.210 29.915 -34.294 -53.41%
agents-tools 5 13.816 14.913 +1.097 +7.94%
auto-reply 13 67.503 66.259 -1.244 -1.84%
channels 2 1.155 0.904 -0.250 -21.65%
cli 1 8.882 7.725 -1.157 -13.03%
commands 9 30.899 40.880 +9.980 +32.30%
contracts-plugin 3 4.234 7.166 +2.932 +69.26%
cron 5 15.611 21.154 +5.543 +35.51%
extension-codex 11 13.880 16.207 +2.327 +16.76%
extension-database-workers 11 178.458 156.422 -22.036 -12.35%
extension-discord 2 1.294 1.547 +0.252 +19.51%
extension-matrix 3 2.174 2.643 +0.469 +21.55%
extension-mattermost 1 0.419 1.036 +0.616 +146.84%
extension-qa 9 19.649 8.994 -10.654 -54.22%
extension-slack 8 4.791 3.946 -0.844 -17.62%
extension-telegram 3 1.772 2.426 +0.655 +36.95%
extension-whatsapp 1 0.485 0.842 +0.357 +73.79%
extensions 4 10.102 6.639 -3.463 -34.28%
gateway-core 2 3.117 3.408 +0.291 +9.35%
gateway-database-workers 6 72.815 79.736 +6.921 +9.50%
gateway-methods 5 27.223 38.264 +11.042 +40.56%
gateway-server 5 59.222 56.330 -2.892 -4.88%
hooks 1 1.006 1.161 +0.155 +15.40%
infra 22 121.903 102.829 -19.074 -15.65%
plugin-sdk 1 0.274 0.776 +0.502 +183.73%
plugins 2 28.172 29.628 +1.456 +5.17%
runtime-config 21 69.930 71.900 +1.970 +2.82%
tooling 1 1.231 1.828 +0.597 +48.50%
unit 9 15.233 23.777 +8.544 +56.09%
unit-fast 12 4.363 3.391 -0.972 -22.28%
unit-fast-isolated 3 3.808 5.161 +1.353 +35.55%
Overall 207 903.780 846.152 -57.628 -6.38%
Flagged files (F − O > max(1 s, 5%))
File O1 / O2 (s) F1 / F2 (s) Reading
src/sessions/session-diff-baseline.test.ts 3.89 / 5.49 8.33 / 8.31 consistent: suite drain now joins in-flight Workers
src/model-picker/apply-session-model-selection.test.ts 6.10 / 5.31 7.32 / 7.52 consistent: suite drain now joins in-flight Workers
src/skills/runtime/tool-dispatch.test.ts 2.73 / 2.27 5.01 / 5.50 consistent: suite drain now joins in-flight Workers
packages/ai/src/transports/openai-responses-client.continuation.test.ts 0.76 / 0.63 1.96 / 2.24 consistent: suite drain now joins in-flight Workers
src/plugins/contracts/host-hooks.contract.test.ts 1.87 / 2.66 3.37 / 3.28 consistent: suite drain now joins in-flight Workers
src/plugins/contracts/session-attachments.contract.test.ts 1.10 / 1.11 2.27 / 1.96 consistent: suite drain now joins in-flight Workers
src/config/sessions/conversation-delivery-store.test.ts 4.60 / 4.66 6.32 / 10.44 consistent: suite drain now joins in-flight Workers
src/config/sessions/transcript.test.ts 4.46 / 6.73 5.27 / 8.16 noise: samples overlap or deltas flip sign
src/config/sessions/session-accessor.sqlite-cleanup-generation-race.test.ts 3.32 / 4.09 3.13 / 7.21 noise: samples overlap or deltas flip sign
src/plugins/host-hook-cleanup.session-store.test.ts 6.69 / 5.25 8.25 / 6.16 noise: samples overlap or deltas flip sign
src/gateway/worker-environments/placement-store.turn-claim-closure.test.ts 29.39 / 36.95 41.60 / 29.49 noise: samples overlap or deltas flip sign
src/gateway/worker-environments/live-events.test.ts 14.39 / 20.75 22.06 / 16.04 noise: samples overlap or deltas flip sign
src/gateway/server-methods/chat.abort-live-proof.test.ts 7.79 / 13.36 17.80 / 8.11 noise: samples overlap or deltas flip sign
src/gateway/server-methods/sessions-create.child-custody.test.ts 17.56 / 20.04 31.91 / 19.55 noise: samples overlap or deltas flip sign (per-case drain; see focused A/B)
src/gateway/server-methods/chat-history-omission-request.test.ts 4.28 / 4.84 7.73 / 6.06 consistent: suite drain now joins in-flight Workers
src/cron/isolated-agent/run.session-lifecycle.test.ts 6.40 / 8.04 12.57 / 8.64 consistent: suite drain now joins in-flight Workers
src/commands/doctor-session-sqlite.targets.test.ts 7.24 / 8.91 14.12 / 7.95 noise: samples overlap or deltas flip sign
src/commands/doctor-session-transcripts.incident.test.ts 4.28 / 5.86 9.35 / 4.39 noise: samples overlap or deltas flip sign
src/commands/doctor-session-sqlite.shared-store.test.ts 4.06 / 5.02 7.31 / 4.17 noise: samples overlap or deltas flip sign
src/commands/status.summary-read-only.test.ts 4.20 / 4.71 8.14 / 4.15 noise: samples overlap or deltas flip sign
Per-file cost, all 207 changed test files
File O mean (s) F mean (s) Δ (s) Δ %
extensions/active-memory/index.test.ts 17.138 15.127 -2.011 -11.73%
extensions/agentsapi/agentsapi-attempt.test.ts 5.428 2.856 -2.572 -47.39%
extensions/codex/harness.session-runtime-ownership.test.ts 0.563 0.615 0.051 +9.15%
extensions/codex/harness.test.ts 0.917 1.286 0.369 +40.24%
extensions/codex/src/app-server/compact.cancellation.test.ts 0.616 0.639 0.023 +3.81%
extensions/codex/src/app-server/compact.test.ts 4.381 4.569 0.188 +4.28%
extensions/codex/src/app-server/request.test.ts 1.185 1.389 0.204 +17.26%
extensions/codex/src/app-server/side-question.test.ts 31.622 27.542 -4.080 -12.90%
extensions/codex/src/app-server/thread-lifecycle.adoption.test.ts 1.166 1.505 0.339 +29.13%
extensions/codex/src/app-server/trajectory.test.ts 0.857 1.050 0.194 +22.58%
extensions/codex/src/app-server/transcript-mirror.user-idempotency.test.ts 0.552 0.567 0.014 +2.63%
extensions/codex/src/app-server/upstream-session-fork-continuation.test.ts 0.596 0.698 0.102 +17.13%
extensions/codex/src/conversation-binding.test.ts 1.551 1.832 0.280 +18.08%
extensions/codex/src/conversation-control.test.ts 1.496 2.058 0.561 +37.49%
extensions/copilot/src/attempt-active-run.test.ts 1.609 1.402 -0.206 -12.84%
extensions/copilot/src/attempt-session.integration.test.ts 0.520 0.497 -0.023 -4.51%
extensions/copilot/src/attempt-transcript-journal.test.ts 2.545 1.884 -0.661 -25.97%
extensions/discord/src/monitor/message-handler.context-history.test.ts 0.627 0.829 0.202 +32.22%
extensions/discord/src/monitor/native-command.model-picker.test.ts 0.667 0.718 0.050 +7.57%
extensions/imessage/src/monitor.last-route.test.ts 8.041 7.633 -0.408 -5.08%
extensions/matrix/src/exec-approvals.test.ts 0.213 0.550 0.338 +158.45%
extensions/matrix/src/matrix/monitor/handler.test.ts 1.405 1.491 0.087 +6.16%
extensions/matrix/src/session-route.test.ts 0.556 0.601 0.044 +8.00%
extensions/mattermost/src/mattermost/model-picker.test.ts 0.419 1.036 0.616 +146.84%
extensions/memory-core/src/session-ingestion.test.ts 0.352 0.546 0.195 +55.33%
extensions/qa-lab/src/runtime-parity-cache-diagnostics.test.ts 0.477 0.585 0.107 +22.51%
extensions/qa-lab/src/runtime-parity-forced-runtime.test.ts 0.359 0.569 0.210 +58.50%
extensions/qa-lab/src/runtime-parity-session-selection.test.ts 0.209 0.562 0.354 +169.78%
extensions/qa-lab/src/runtime-tool-fixture.known-gap.test.ts 0.014 0.012 -0.002 -17.24%
extensions/qa-lab/src/runtime-tool-fixture.mock-linking.test.ts 0.019 0.017 -0.003 -15.38%
extensions/qa-lab/src/runtime-tool-fixture.nested.test.ts 2.362 0.614 -1.748 -74.01%
extensions/qa-lab/src/runtime-tool-fixture.test.ts 9.145 2.898 -6.247 -68.31%
extensions/qa-lab/src/runtime-tool-fixture.transcript.test.ts 4.591 1.359 -3.232 -70.40%
extensions/qa-lab/src/suite-runtime-agent-session.test.ts 2.471 2.378 -0.093 -3.74%
extensions/slack/src/approval-native.test.ts 0.159 0.138 -0.020 -12.93%
extensions/slack/src/monitor/events/agent.test.ts 2.053 1.510 -0.543 -26.46%
extensions/slack/src/monitor/message-handler/prepare-room-history.test.ts 0.525 0.487 -0.038 -7.24%
extensions/slack/src/monitor/message-handler/prepare-thread-context.test.ts 0.065 0.061 -0.004 -5.43%
extensions/slack/src/monitor/message-handler/prepare.bot-threads.test.ts 0.200 0.174 -0.026 -12.75%
extensions/slack/src/monitor/message-handler/prepare.rejection-records.test.ts 0.084 0.102 0.018 +21.43%
extensions/slack/src/monitor/message-handler/prepare.test.ts 0.797 0.779 -0.018 -2.26%
extensions/slack/src/monitor/slash.test.ts 0.909 0.696 -0.214 -23.49%
extensions/telegram/src/approval-native.test.ts 0.268 0.573 0.305 +113.81%
extensions/telegram/src/bot-message-context.body.test.ts 56.938 49.097 -7.841 -13.77%
extensions/telegram/src/bot-message-context.bot-threads.test.ts 10.851 9.122 -1.729 -15.93%
extensions/telegram/src/bot-message-context.dm-session.test.ts 23.907 21.269 -2.638 -11.03%
extensions/telegram/src/bot-message-context.prompt-context.test.ts 10.824 10.104 -0.720 -6.65%
extensions/telegram/src/exec-approvals.test.ts 0.192 0.621 0.429 +223.18%
extensions/telegram/src/model-callback.loopback.integration.test.ts 1.312 1.232 -0.079 -6.02%
extensions/telegram/src/telegram-ingress-callback.integration.test.ts 6.490 5.034 -1.457 -22.44%
extensions/tlon/src/monitor/index.test.ts 8.039 7.114 -0.925 -11.51%
extensions/twitch/src/monitor.test.ts 4.256 3.833 -0.424 -9.96%
extensions/whatsapp/src/auto-reply/monitor/group-activation.test.ts 0.485 0.842 0.357 +73.79%
packages/ai/src/transports/openai-responses-client.continuation.test.ts 0.693 2.102 1.409 +203.54%
packages/memory-host-sdk/src/host/session-files-yield.test.ts 0.105 0.664 0.558 +529.38%
packages/memory-host-sdk/src/host/session-files.windows-ownership.test.ts 0.491 1.075 0.585 +119.27%
src/agents/agent-command-execution-identity.test.ts 1.038 1.045 0.007 +0.67%
src/agents/agent-command-recovery-owner.test.ts 2.108 1.671 -0.437 -20.71%
src/agents/agent-tools.create-openclaw-coding-tools.test.ts 1.335 1.613 0.278 +20.82%
src/agents/bash-tools.exec-approval-followup.test.ts 0.521 0.562 0.041 +7.77%
src/agents/bootstrap-files.test.ts 6.893 4.445 -2.448 -35.51%
src/agents/cli-runner.reliability.test.ts 5.264 2.849 -2.416 -45.89%
src/agents/cli-runner/cli-run-transcript.test.ts 0.351 0.615 0.264 +75.07%
src/agents/cli-runner/history-boundary.test.ts 1.821 1.786 -0.035 -1.92%
src/agents/command/attempt-execution.shared.test.ts 0.333 0.181 -0.152 -45.50%
src/agents/command/attempt-execution.test.ts 1.808 1.743 -0.066 -3.65%
src/agents/command/session.yielded-parent-reuse.test.ts 0.197 0.054 -0.143 -72.34%
src/agents/command/transcript-persistence.test.ts 0.326 0.102 -0.224 -68.71%
src/agents/conversation-capability-profile.test.ts 0.405 0.570 0.164 +40.44%
src/agents/embedded-agent-runner.run-embedded-agent.finalization-scope.test.ts 13.246 7.191 -6.055 -45.71%
src/agents/embedded-agent-runner/cli-backend-dispatch.test.ts 0.312 0.607 0.294 +94.24%
src/agents/embedded-agent-runner/compact.auth-preparation.test.ts 2.003 1.541 -0.462 -23.07%
src/agents/embedded-agent-runner/run.cli-dispatch-lane.test.ts 0.136 0.545 0.409 +301.10%
src/agents/embedded-agent-runner/run/attempt-native-video-transcript.test.ts 0.208 0.612 0.404 +194.23%
src/agents/embedded-agent-runner/run/attempt-phase-lifecycle.test.ts 3.540 1.136 -2.404 -67.91%
src/agents/embedded-agent-runner/run/attempt-prompt-phase.admission.test.ts 0.368 0.592 0.224 +60.73%
src/agents/embedded-agent-runner/run/attempt.llm-boundary.cache-stability.test.ts 0.777 0.622 -0.155 -19.95%
src/agents/embedded-agent-runner/run/attempt.sessions-yield.test.ts 0.428 0.660 0.232 +54.21%
src/agents/embedded-agent-runner/run/attempt.spawn-workspace.context-engine.test.ts 9.894 6.377 -3.517 -35.54%
src/agents/embedded-agent-runner/tool-result-truncation.test.ts 1.119 1.169 0.050 +4.51%
src/agents/embedded-agent-subscribe.handlers.compaction.test.ts 0.430 0.572 0.142 +32.91%
src/agents/exec-defaults.test.ts 0.423 0.619 0.196 +46.34%
src/agents/harness/context-engine-turn-attempt.test.ts 15.286 9.566 -5.720 -37.42%
src/agents/harness/native-hook-relay.test.ts 9.606 7.987 -1.619 -16.86%
src/agents/internal-session-effects.test.ts 4.485 3.387 -1.098 -24.48%
src/agents/main-session-recovery/main-session-restart-recovery-marking.test.ts 11.066 8.494 -2.573 -23.25%
src/agents/openclaw-tools.requester-yield.test.ts 3.050 2.888 -0.162 -5.30%
src/agents/openclaw-tools.sessions.test.ts 16.174 10.649 -5.525 -34.16%
src/agents/requester-tool-policy.test.ts 2.018 1.536 -0.482 -23.88%
src/agents/run-session-target.test.ts 1.115 1.071 -0.044 -3.90%
src/agents/sandbox.resolveSandboxContext.test.ts 1.244 1.227 -0.016 -1.33%
src/agents/sandbox/tool-policy.test.ts 0.127 0.105 -0.022 -17.32%
src/agents/session-tool-result-guard.visibility.test.ts 0.951 0.650 -0.301 -31.65%
src/agents/subagents/spawn/subagent-spawn.fork-cleanup.test.ts 35.698 9.499 -26.199 -73.39%
src/agents/tools/sessions-spawn-cloud.test.ts 2.547 2.717 0.170 +6.67%
src/agents/tools/sessions-spawn-tool.test.ts 8.246 8.376 0.130 +1.58%
src/agents/tools/sessions-tool.self-archive.test.ts 0.964 1.203 0.238 +24.73%
src/agents/tools/sessions-tool.test.ts 0.948 1.279 0.331 +34.99%
src/agents/tools/sessions.test.ts 1.111 1.338 0.227 +20.38%
src/agents/watched-sessions-prompt.test.ts 0.707 0.639 -0.068 -9.62%
src/agents/worktrees/service.source-only-filters.test.ts 9.352 5.200 -4.152 -44.39%
src/auto-reply/inbound.test.ts 0.485 0.412 -0.073 -14.96%
src/auto-reply/reply/agent-runner-memory.preflight-stale-tokens.test.ts 2.414 2.655 0.241 +9.98%
src/auto-reply/reply/agent-runner-result-accounting.fallback.test.ts 0.790 0.816 0.025 +3.16%
src/auto-reply/reply/agent-runner-result-accounting.persistence.test.ts 36.130 34.811 -1.320 -3.65%
src/auto-reply/reply/commands-goal.test.ts 0.666 0.475 -0.191 -28.75%
src/auto-reply/reply/commands-name.test.ts 0.333 0.231 -0.101 -30.38%
src/auto-reply/reply/commands-plugin.test.ts 5.252 4.675 -0.577 -10.99%
src/auto-reply/reply/commands-reset-hooks.test.ts 0.180 0.525 0.345 +191.67%
src/auto-reply/reply/commands-session-store.test.ts 0.568 0.594 0.026 +4.58%
src/auto-reply/reply/commands-status.test.ts 14.964 13.512 -1.452 -9.70%
src/auto-reply/reply/dispatch-from-config.pending-final.test.ts 0.191 0.141 -0.050 -26.18%
src/auto-reply/reply/get-reply-inline-actions.skip-when-config-empty.test.ts 2.508 2.381 -0.127 -5.06%
src/auto-reply/reply/queue.collect.test.ts 0.359 0.641 0.282 +78.30%
src/auto-reply/reply/reply-state.test.ts 0.564 0.617 0.053 +9.49%
src/auto-reply/reply/session-fork.test.ts 2.422 3.284 0.862 +35.57%
src/auto-reply/reply/session-reset-model.test.ts 5.424 5.318 -0.106 -1.95%
src/auto-reply/reply/session.init-conflict-retry.test.ts 0.695 0.695 -0.001 -0.07%
src/channels/session-envelope.test.ts 0.097 0.056 -0.041 -41.97%
src/channels/turn/pending-delivery-notice.integration.test.ts 0.488 0.211 -0.277 -56.81%
src/channels/turn/pending-delivery-notice.test.ts 0.666 0.694 0.027 +4.13%
src/cli/agent-cli-recovery.process.test.ts 8.882 7.725 -1.157 -13.03%
src/commands/doctor-heartbeat-session-target.test.ts 0.156 0.533 0.377 +241.67%
src/commands/doctor-main-session-recovery.test.ts 1.572 1.653 0.081 +5.15%
src/commands/doctor-session-sqlite.shared-store.test.ts 4.543 5.738 1.195 +26.30%
src/commands/doctor-session-sqlite.targets.test.ts 8.075 11.032 2.956 +36.60%
src/commands/doctor-session-state-providers.test.ts 3.780 4.453 0.673 +17.79%
src/commands/doctor-session-transcripts.incident.test.ts 5.068 6.870 1.802 +35.56%
src/commands/sandbox-explain.test.ts 0.326 0.739 0.413 +126.69%
src/commands/sessions-tail.test.ts 2.921 3.716 0.795 +27.23%
src/commands/status.summary-read-only.test.ts 4.457 6.146 1.689 +37.88%
src/config/sessions/cleanup-service.cap-archive.test.ts 1.306 1.184 -0.122 -9.34%
src/config/sessions/cleanup-service.fix-missing.test.ts 9.751 9.156 -0.595 -6.10%
src/config/sessions/conversation-delivery-store.test.ts 4.630 8.381 3.751 +81.02%
src/config/sessions/lifecycle.test.ts 0.772 0.431 -0.341 -44.14%
src/config/sessions/session-accessor.compaction-boundary.test.ts 0.512 0.451 -0.061 -12.00%
src/config/sessions/session-accessor.parent-fork.test.ts 1.373 1.402 0.029 +2.11%
src/config/sessions/session-accessor.question-answer-transcript.test.ts 3.967 4.850 0.882 +22.24%
src/config/sessions/session-accessor.recovery.test.ts 0.367 0.286 -0.081 -22.04%
src/config/sessions/session-accessor.reply-init-concurrency.test.ts 2.236 2.757 0.521 +23.27%
src/config/sessions/session-accessor.sqlite-archive.byte-limit.test.ts 0.734 0.594 -0.141 -19.20%
src/config/sessions/session-accessor.sqlite-cleanup-generation-race.test.ts 3.707 5.170 1.463 +39.48%
src/config/sessions/session-accessor.sqlite-cleanup-race.test.ts 17.864 17.390 -0.474 -2.65%
src/config/sessions/session-accessor.sqlite-data-version.test.ts 2.503 2.043 -0.460 -18.36%
src/config/sessions/session-accessor.sqlite-entry-inventory.test.ts 0.184 0.114 -0.070 -38.04%
src/config/sessions/session-accessor.sqlite-export-budget.test.ts 1.192 1.365 0.173 +14.47%
src/config/sessions/session-accessor.sqlite-maintenance-writer.test.ts 5.505 5.864 0.358 +6.50%
src/config/sessions/session-accessor.sqlite-transcript-parent.test.ts 0.754 0.573 -0.181 -24.06%
src/config/sessions/session-canonical-key.test.ts 1.597 1.438 -0.159 -9.98%
src/config/sessions/session-suggestion-store.test.ts 4.745 1.194 -3.551 -74.84%
src/config/sessions/session-transcript-projection-catchup.test.ts 0.628 0.539 -0.089 -14.09%
src/config/sessions/transcript.test.ts 5.598 6.716 1.118 +19.98%
src/cron/isolated-agent/run-session-state.test.ts 1.218 1.530 0.313 +25.71%
src/cron/isolated-agent/run.session-lifecycle.test.ts 7.216 10.607 3.390 +46.98%
src/cron/isolated-agent/run.terminal-error-identity.test.ts 0.507 1.064 0.557 +109.86%
src/cron/isolated-agent/session.latest-read.test.ts 0.129 0.822 0.694 +539.69%
src/cron/service.wake-now-real-heartbeat.test.ts 6.542 7.131 0.590 +9.02%
src/gateway/health/collector.session-store-path.test.ts 1.951 1.919 -0.032 -1.67%
src/gateway/server-methods/agent.create-event.test.ts 0.435 0.980 0.544 +124.91%
src/gateway/server-methods/chat-history-omission-request.test.ts 4.562 6.893 2.330 +51.07%
src/gateway/server-methods/chat.abort-live-proof.test.ts 10.574 12.955 2.381 +22.52%
src/gateway/server-methods/chat.abort-persistence.test.ts 1.783 2.451 0.668 +37.46%
src/gateway/server-methods/session-catalog-selection.test.ts 1.603 2.125 0.522 +32.55%
src/gateway/server-methods/sessions-create.child-custody.test.ts 18.800 25.730 6.930 +36.86%
src/gateway/server-methods/skills-library.test.ts 0.474 1.066 0.592 +124.79%
src/gateway/server-plugins.test.ts 2.531 2.846 0.315 +12.42%
src/gateway/server-restart-sentinel-notice.test.ts 28.000 24.617 -3.383 -12.08%
src/gateway/server-runtime-services.delivery-recovery.test.ts 1.971 2.264 0.293 +14.86%
src/gateway/server.chat-adopted-failure.test.ts 7.755 8.535 0.780 +10.06%
src/gateway/server.chat.acp-completion.test.ts 18.965 18.067 -0.898 -4.73%
src/gateway/session-lifecycle-state.persistence.test.ts 9.114 9.288 0.174 +1.91%
src/gateway/session-transcript-readers.markers.test.ts 2.780 2.688 -0.092 -3.31%
src/gateway/tool-resolution.exclude.test.ts 0.337 0.720 0.383 +113.97%
src/gateway/worker-environments/live-events.test.ts 17.570 19.047 1.477 +8.40%
src/gateway/worker-environments/placement-store.turn-claim-closure.test.ts 33.170 35.548 2.378 +7.17%
src/hooks/bundled/session-memory/capture.test.ts 1.006 1.161 0.155 +15.40%
src/infra/exec-approval-session-target.test.ts 0.675 0.639 -0.036 -5.33%
src/infra/outbound/delivery-queue.test-helpers.test.ts 0.159 0.128 -0.031 -19.56%
src/infra/outbound/message-action-send.mirror-order.test.ts 0.556 0.661 0.105 +18.97%
src/infra/outbound/outbound-session.integration.test.ts 0.791 1.159 0.368 +46.52%
src/infra/session-cost-usage.test.ts 10.007 6.935 -3.072 -30.70%
src/infra/state-migrations.workspace-setup-sandbox.test.ts 3.350 2.574 -0.776 -23.18%
src/mcp/openclaw-tools-serve.test.ts 0.195 0.742 0.547 +280.77%
src/model-picker/apply-session-model-selection-placement.test.ts 1.105 1.930 0.825 +74.71%
src/model-picker/apply-session-model-selection.test.ts 5.708 7.419 1.711 +29.96%
src/plugin-sdk/session-store-history-boundary.test.ts 0.295 0.135 -0.160 -54.24%
src/plugin-sdk/session-store-runtime.maintenance.test.ts 2.836 3.796 0.961 +33.89%
src/plugin-sdk/session-store-runtime.recovery.test.ts 0.274 0.776 0.502 +183.73%
src/plugin-sdk/session-store-runtime.test.ts 13.019 12.430 -0.589 -4.53%
src/plugin-sdk/session-store-runtime.writer-claim.test.ts 0.334 0.206 -0.128 -38.38%
src/plugin-sdk/session-transcript-mirror-runtime.test.ts 1.326 1.645 0.319 +24.10%
src/plugin-sdk/session-transcript-runtime-visible-delta.test.ts 1.468 1.633 0.165 +11.28%
src/plugin-sdk/session-transcript-runtime.read-fence.test.ts 10.034 8.271 -1.763 -17.57%
src/plugins/contracts/host-hooks.contract.test.ts 2.263 3.324 1.061 +46.86%
src/plugins/contracts/session-attachments.contract.test.ts 1.110 2.116 1.007 +90.76%
src/plugins/contracts/session-entry-projection.contract.test.ts 0.862 1.726 0.865 +100.41%
src/plugins/host-hook-cleanup.session-store.test.ts 5.970 7.203 1.233 +20.64%
src/plugins/runtime/runtime-agent.test.ts 22.202 22.425 0.224 +1.01%
src/sessions/session-diff-baseline.test.ts 4.690 8.319 3.629 +77.38%
src/sessions/session-upstream-monitor.test.ts 20.360 15.360 -5.000 -24.56%
src/sessions/user-turn-transcript.persistence.test.ts 5.611 5.333 -0.278 -4.95%
src/sessions/user-turn-transcript.test.ts 2.025 1.718 -0.307 -15.14%
src/skills/runtime/tool-dispatch.test.ts 2.501 5.257 2.756 +110.20%
src/state/database-runtime-schema-checks.test.ts 0.298 0.827 0.528 +176.88%
src/state/openclaw-agent-pending-inputs-schema.test.ts 0.462 0.882 0.420 +91.12%
src/trajectory/runtime-store.sqlite.test.ts 3.870 3.621 -0.249 -6.45%
test/copilot-tool-policy-handoff.integration.test.ts 1.231 1.828 0.597 +48.50%

… roots

Session entry writes kick deferred maintenance Workers and transcript reads
retain history Workers on the store's agent database. Suites removed the
store directory while those owners were live, so an owner could reopen the
database mid-removal and fail rmdir with ENOTEMPTY.

Add useSessionStoreTempDirs: case directories under one canonical suite
root, drained once with closeOpenClawAgentDatabasesAsync before removal.
Suites with an existing suite root drain it inline.
…e parent

withDeclaredCommandPlugin reset the plugin runtime synchronously and removed
its parent while the loaded registry and cache retirement still released a
source-capture SQLite staging token under <parent>/state. The removal could
race that retirement (seen as SQLITE_IOERR_FSTAT). Dispose the registry and
await cache retirement, asserting no cleanup failures, before removal.
Releasing agent leases can reopen shared-state handles, and cases may keep
their shared state under the suite root. Follow cleanupSessionStateForTest
ordering: drain agent databases, close shared state, then remove.
Session writes and transcript reads retain maintenance and history Workers.
Synchronous close does not join retirement, so recursive teardown can race a
database reopening and leave new SQLite sidecars.

Keep case stores under canonical suite roots and use the shared awaited
agent and shared-state cleanup before removal. Fix shared history and local
store fixtures, preserve explicit cold-read and schema closes, and drain the
case-owned Windows fixture before removal.
…drain

The suite already awaited its per-case agent drain; root canonicalization
for macOS matching belongs with the lifecycle owner, not this change.
Session writes and transcript reads retain agent database resources after
test bodies settle. Synchronous cache closes do not join Worker retirement,
so removing temporary roots can race with owners reopening SQLite files.

Keep case roots until suite teardown and await the agent database drain
before removal. Canonicalize roots used by existing fixture drains so they
match native database paths on macOS. Preserve callback-owned cleanup and
cover the native transcript-preparation handles behind mocked sessions.
Let the shared suite helper own agent and shared-state drainage before
removing roots. Remove ordering wrappers and redundant per-case closes,
while preserving incognito cleanup, restart simulation, and other fixtures.

Move the five remaining session-tool store fixtures to suite-owned roots.
Restore canonicalization-only changes for the separate lifecycle-owner
path-matching follow-up, and attach the existing temp-dir allowance to its
nested allocation.
… roots

Session writes and transcript reads retain maintenance and history Workers.
Synchronous database closure does not join those resources, so deleting their
roots can race a reopened database and fail with ENOTEMPTY.

Retain isolated case stores beneath canonical suite roots and await agent
database drainage before removal through existing SDK testing contracts.
Keep shared state alive until agent retirement completes, and route Telegram
context stores through their existing draining state fixture.
Session writes and transcript reads retain agent database resources after
synchronous close. Removing their temp roots before retirement settles can
reopen SQLite files during removal and race rmdir with ENOTEMPTY.

Keep case stores under canonical suite roots and await one agent database
drain before removal. Fix the shared queue, Doctor, heartbeat, and Gateway
fixtures at their owners. Browser fixtures retain per-case drainage and
bind placement state to their request context so later replies cannot reopen
a previous Gateway home.

The original probe observed live owners at 250 removals across 42 suites.
Fixed observations across 72 suites and 1,220 cases contain no live owners
at removal or unexpected directory recreation. Focused tests, formatting,
lint, selected type checks, and Codex review passed. Same-lease cost trials
remain unmeasured because the Testbox workflow was cancelled during warm-up.
…ch/tlon

Expose the existing session-store fixture through the private first-party
SQLite testing facade, replace the duplicate Codex helper, and consolidate
Copilot, Slack, and Telegram suite teardown on the shared owner.

Drain agent Workers, await shared-state closure, then remove canonical roots.
Cover Twitch and Tlon dispatch stores, including Twitch envelope reads that
otherwise open the default session database outside the fixture root.

Retire the side-question provider fixture before shared-state cleanup by
registering its suite-root cleanup first at the same hook scope.
Use the shared suite cleanup's agent-then-state shutdown ordering and remove
redundant per-case cache closes. Preserve the queue media temp parent and
Doctor's explicit physical /tmp fixtures, with their own ordered joins.
Revert canonicalization-only changes to three already-draining fixtures;
root matching belongs to the lifecycle-owner follow-up.

Join retained stores in status summary, catalog selection, child custody,
and late-abort Gateway proof fixtures. Keep per-case release where Gateway
HOME teardown requires it. Prepare the existing agent.wait handler before
the late-abort fixture's timed assertion without changing request deadlines.

The supplied probe covers 76 suites and 1,256 cases with zero agent owners
at removal. Original proof ran only the four new suites in a detached
28a8620 worktree, which was removed afterward. Normal tests, formatting,
lint, selected type lanes, and Codex review passed. Preserve the initial
agent.wait timeout and its unresolved attribution in the lane report;
a passing replay is not treated as a fix. Cost A/B remains coordinator-owned.
The agent.wait handler pre-warm addressed one unexplained CLIENT_TIMEOUT
without an established cause; it is unrelated to the teardown change.
The per-case plugin-state reset closed shared state while the case's agent
workers could still hold shared-state admission; the suite helper now closes
it after draining agents.
…e-agent-db-drain

Conflict resolutions:
- tlon monitor: retain main's awaited per-case drain and queued-maintenance regression unchanged.
- sessions-spawn-cloud: preserve main's long-task/schema assertions with suite-owned session directories.
- database-runtime-schema-checks: preserve main's admission APIs and cases; move both new fixtures to the suite cleanup helper.

The both-sides probe also found an incognito handle outside the Codex suite root; drain all of that isolated suite's agent handles before its test home is removed.
Incognito fixtures retain a cached agent handle under the isolated test home, outside the session-store suite root. Await the isolated suite agent-database drain before test-env removes that home.

Validation: all 94 conversation-binding tests pass. The removal probe changed from one retained handle to zero, with no reappearing roots. Scoped formatting and lint pass; resolution review found no actionable issues.
@clawsweeper

clawsweeper Bot commented Sep 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: whatsapp-web Channel integration: whatsapp-web gateway Gateway runtime extensions: memory-core Extension: memory-core cli CLI command changes commands Command implementations docker Docker and sandbox tooling agents Agent runtime and tooling channel: twitch Channel integration: twitch labels Sep 30, 2026
Preserve the retired whole-session-store APIs and deleted tests from main. Keep suite-root asynchronous database teardown for the surviving SDK history and runtime cases, dropping obsolete imports and the compatibility suite name.
Album cases depend on a ~20 ms wall-clock media-group window. Deferring
every case's agent-database drain to suite end let earlier cases'
maintenance and history Workers run during later album cases. Drain each
case root and close shared state before the next case; directory removal
stays with the suite helper.
Keep main test removals and API changes in compact and host-hook contracts. Retain suite-owned session-store directories for surviving cases and remove the obsolete global-state fixture prefix argument.
Keep main’s consolidated session-cost usage cases and API changes. Use the shared suite-root helper to drain agent and state databases before removing their temporary directories.
Keep main's test consolidation and API changes; retain suite-owned
session-store roots until agent database owners and state workers drain.

- agentsapi-attempt: preserve PDF steering coverage; use suite teardown.
- matrix handler: retain test-fixtures imports; drain notice stores.
- slack slash: preserve extracted harnesses; drain metadata stores.
- internal-session-effects: retain consolidated cases; replace withTestDir.
- status summary: preserve scan/projection cases; retain store roots.
- health collector: preserve async summary cases; drain all fixture stores.
- chat-history omission: retain expectDefined; defer directory removal.
- transcript read-fence: preserve consolidated seedHistory and cases.
- upstream monitor: preserve async/owner tests; drain suite roots last.

Audited six automatic merges, including new cases and the per-case
child-custody drain; no additional cleanup changes needed.
Keep main's Telegram coalescing mocks and deterministic windows, then
retain suite-root session-store cleanup in telegram-ingress-coalescing.
Keep bot.media's per-case agent database drain before shared-state close.

Preserve main's deleted question-answer case and consolidated SQLite
export-budget cases; their remaining stores use suite-owned directories.
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Oct 1, 2026
@steipete
steipete merged commit 57e0aaa into main Oct 1, 2026
156 checks passed
@steipete
steipete deleted the steipete/session-store-agent-db-drain branch October 1, 2026 17:10
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 2, 2026
…ent-database workers are live (openclaw#161871)

* test(auto-reply): drain agent databases before removing session-store roots

Session entry writes kick deferred maintenance Workers and transcript reads
retain history Workers on the store's agent database. Suites removed the
store directory while those owners were live, so an owner could reopen the
database mid-removal and fail rmdir with ENOTEMPTY.

Add useSessionStoreTempDirs: case directories under one canonical suite
root, drained once with closeOpenClawAgentDatabasesAsync before removal.
Suites with an existing suite root drain it inline.

* test(auto-reply): settle plugin capture owners before removing fixture parent

withDeclaredCommandPlugin reset the plugin runtime synchronously and removed
its parent while the loaded registry and cache retirement still released a
source-capture SQLite staging token under <parent>/state. The removal could
race that retirement (seen as SQLITE_IOERR_FSTAT). Dispose the registry and
await cache retirement, asserting no cleanup failures, before removal.

* test: close shared state before removing session-store suite roots

Releasing agent leases can reopen shared-state handles, and cases may keep
their shared state under the suite root. Follow cleanupSessionStateForTest
ordering: drain agent databases, close shared state, then remove.

* test(sessions): drain agent databases before removing fixture roots

Session writes and transcript reads retain maintenance and history Workers.
Synchronous close does not join retirement, so recursive teardown can race a
database reopening and leave new SQLite sidecars.

Keep case stores under canonical suite roots and use the shared awaited
agent and shared-state cleanup before removal. Fix shared history and local
store fixtures, preserve explicit cold-read and schema closes, and drain the
case-owned Windows fixture before removal.

* test(sessions): keep archive-worker teardown on its existing awaited drain

The suite already awaited its per-case agent drain; root canonicalization
for macOS matching belongs with the lifecycle owner, not this change.

* test(agents): drain agent databases before removing session-store roots

Session writes and transcript reads retain agent database resources after
test bodies settle. Synchronous cache closes do not join Worker retirement,
so removing temporary roots can race with owners reopening SQLite files.

Keep case roots until suite teardown and await the agent database drain
before removal. Canonicalize roots used by existing fixture drains so they
match native database paths on macOS. Preserve callback-owned cleanup and
cover the native transcript-preparation handles behind mocked sessions.

* test(agents): simplify session-store teardown and cover remaining suites

Let the shared suite helper own agent and shared-state drainage before
removing roots. Remove ordering wrappers and redundant per-case closes,
while preserving incognito cleanup, restart simulation, and other fixtures.

Move the five remaining session-tool store fixtures to suite-owned roots.
Restore canonicalization-only changes for the separate lifecycle-owner
path-matching follow-up, and attach the existing temp-dir allowance to its
nested allocation.

* test(extensions): drain agent databases before removing session-store roots

Session writes and transcript reads retain maintenance and history Workers.
Synchronous database closure does not join those resources, so deleting their
roots can race a reopened database and fail with ENOTEMPTY.

Retain isolated case stores beneath canonical suite roots and await agent
database drainage before removal through existing SDK testing contracts.
Keep shared state alive until agent retirement completes, and route Telegram
context stores through their existing draining state fixture.

* test(session-store): drain agent databases before removing temp roots

Session writes and transcript reads retain agent database resources after
synchronous close. Removing their temp roots before retirement settles can
reopen SQLite files during removal and race rmdir with ENOTEMPTY.

Keep case stores under canonical suite roots and await one agent database
drain before removal. Fix the shared queue, Doctor, heartbeat, and Gateway
fixtures at their owners. Browser fixtures retain per-case drainage and
bind placement state to their request context so later replies cannot reopen
a previous Gateway home.

The original probe observed live owners at 250 removals across 42 suites.
Fixed observations across 72 suites and 1,220 cases contain no live owners
at removal or unexpected directory recreation. Focused tests, formatting,
lint, selected type checks, and Codex review passed. Same-lease cost trials
remain unmeasured because the Testbox workflow was cancelled during warm-up.

* test(extensions): share the session-store suite helper and cover twitch/tlon

Expose the existing session-store fixture through the private first-party
SQLite testing facade, replace the duplicate Codex helper, and consolidate
Copilot, Slack, and Telegram suite teardown on the shared owner.

Drain agent Workers, await shared-state closure, then remove canonical roots.
Cover Twitch and Tlon dispatch stores, including Twitch envelope reads that
otherwise open the default session database outside the fixture root.

Retire the side-question provider fixture before shared-state cleanup by
registering its suite-root cleanup first at the same hook scope.

* test(session-store): simplify teardown and cover remaining suites

Use the shared suite cleanup's agent-then-state shutdown ordering and remove
redundant per-case cache closes. Preserve the queue media temp parent and
Doctor's explicit physical /tmp fixtures, with their own ordered joins.
Revert canonicalization-only changes to three already-draining fixtures;
root matching belongs to the lifecycle-owner follow-up.

Join retained stores in status summary, catalog selection, child custody,
and late-abort Gateway proof fixtures. Keep per-case release where Gateway
HOME teardown requires it. Prepare the existing agent.wait handler before
the late-abort fixture's timed assertion without changing request deadlines.

The supplied probe covers 76 suites and 1,256 cases with zero agent owners
at removal. Original proof ran only the four new suites in a detached
28a8620 worktree, which was removed afterward. Normal tests, formatting,
lint, selected type lanes, and Codex review passed. Preserve the initial
agent.wait timeout and its unresolved attribution in the lane report;
a passing replay is not treated as a fix. Cost A/B remains coordinator-owned.

* test(gateway): keep abort live-proof timing unchanged

The agent.wait handler pre-warm addressed one unexplained CLIENT_TIMEOUT
without an established cause; it is unrelated to the teardown change.

* test(doctor): close incident shared state after the suite agent drain

The per-case plugin-state reset closed shared state while the case's agent
workers could still hold shared-state admission; the suite helper now closes
it after draining agents.

* test(codex): drain incognito agent handles before home cleanup

Incognito fixtures retain a cached agent handle under the isolated test home, outside the session-store suite root. Await the isolated suite agent-database drain before test-env removes that home.

Validation: all 94 conversation-binding tests pass. The removal probe changed from one retained handle to zero, with no reappearing roots. Scoped formatting and lint pass; resolution review found no actionable issues.

* test(codex): remove obsolete teardown import after merge

* test(telegram): drain media harness stores per case

Album cases depend on a ~20 ms wall-clock media-group window. Deferring
every case's agent-database drain to suite end let earlier cases'
maintenance and history Workers run during later album cases. Drain each
case root and close shared state before the next case; directory removal
stays with the suite helper.
amittell added a commit to amittell/openclaw that referenced this pull request Oct 9, 2026
…removed

Main's test lifecycle now fails a file whose agent or state database
outlives its fixture directory, and openclaw#163045 moved the active-stats read
this branch's snapshot test used into a test-support module. After the
merge that left three of the branch's own suites red:

- transcript-grounding.test.ts and
  session-accessor.sqlite-conversation-snapshot.test.ts passed their cases
  and then failed teardown with "Agent database close failed" (ENOENT on
  the removed state/openclaw.sqlite). Both now await the agent and state
  database closes in afterEach, as
  session-accessor.sqlite-active-events.test.ts does.
- The snapshot test called readSessionTranscriptActiveStats, which no
  longer exists; it reads the same count through readActiveTranscriptStats.
- embedded-agent-subscribe.tools.media.test.ts closed its databases
  synchronously. Its case stores now sit under one suite root from
  useSessionStoreTempDirs, drained once before removal (openclaw#161871).

No assertion changes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: mattermost Channel integration: mattermost channel: slack Channel integration: slack channel: telegram Channel integration: telegram channel: twitch Channel integration: twitch channel: whatsapp-web Channel integration: whatsapp-web cli CLI command changes commands Command implementations docker Docker and sandbox tooling extensions: active-memory extensions: agentsapi extensions: codex extensions: copilot extensions: memory-core Extension: memory-core extensions: qa-lab gateway Gateway runtime P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. size: XL status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant