Skip to content

fix(test): zalo lifecycle suites fail Windows teardown with EBUSY on agent state DB - #119809

Merged
vincentkoc merged 3 commits into
openclaw:mainfrom
wangmiao0668000666:fix/zalo-test-teardown-agent-db-close
Aug 6, 2026
Merged

vincentkoc merged 3 commits into
openclaw:mainfrom
wangmiao0668000666:fix/zalo-test-teardown-agent-db-close

Conversation

@wangmiao0668000666

@wangmiao0668000666 wangmiao0668000666 commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #119796

This PR covers the lifecycle fixtures. The remaining credential, quote-metadata, and doctor fixtures are handled by #119964, so #119796 stays open until both land.

What Problem This Solves

Fixes an issue where contributors running the Zalo extension test suites on a Windows checkout would see 9 of 26 monitor.polling-lifecycle.test.ts cases fail in teardown with EBUSY: resource busy or locked, unlink '...\agents\main\agent\openclaw-agent.sqlite', cascading through every later hook in the file. Surfaced by @Yigtwxx while reviewing #110803 (measurement); Linux CI never sees it because unlinking an open file succeeds there.

Why This Change Was Made

A fully processed inbound update opens the per-agent state database through the real session accessor inside the inbound envelope builder (resolveChannelInboundRouteEnvelope → readSessionUpdatedAt → openOpenClawAgentDatabase), which caches the handle process-wide. The Zalo lifecycle teardown only closed the shared state database before fs.rm, leaving the agent DB handle (and WAL sidecars) live — a live handle, not a slow release, so fs.rm retries alone cannot help.

The fix mirrors the canonical fixture pattern from #113316 (src/test-utils/openclaw-test-state.ts): close cached agent databases via the existing closeOpenClawAgentDatabasesForTest() (already exported through openclaw/plugin-sdk/sqlite-runtime-testing and used by telegram/signal/whatsapp/matrix/slack tests) before closing shared state — agent close releases leases through shared state, so the reverse order can reopen it — and gives the temp-dir removal the same retry budget as the canonical fixture. Test-only change; no production code touched.

User Impact

No end-user impact. Developers on Windows can now run the Zalo polling lifecycle/webhook suites to green locally; #110803's polling-ingress proof file (which amplifies the leak to 25/26 failures) becomes runnable on Windows once it lands on this base.

Evidence

Reproduced the leak cross-platform and verified the fix, on 6e4d387fed (current main), Node 24.18.0:

  • New regression test monitor-mocks-test-support.test.ts opens the per-agent DB the same way the envelope builder does, then asserts resetLifecycleTestState() releases the handle. Without the fix it fails (handle.db.isOpen still true after teardown); with the fix it passes — the exact handle leak that Windows surfaces as EBUSY, observable on any OS.
  • Focused run, all green (48/48):
node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-zalo.config.ts --configLoader runner \
  extensions/zalo/src/monitor.polling-lifecycle.test.ts \
  extensions/zalo/src/monitor.lifecycle.test.ts \
  extensions/zalo/src/webhook-spool.test.ts \
  extensions/zalo/src/test-support/monitor-mocks-test-support.test.ts

Test Files  4 passed (4)
Tests  48 passed (48)
  • Sibling check (corrected after Windows measurement by @Yigtwxx): extensions/zalouser uses the same close-shared-then-rm pattern. ingress.test.ts and monitor.account-scope.test.ts exercise queue mechanics only and are clean, but monitor.group-gating.test.ts asserts on fully built dispatch context (ctx.WasMentioned, ctx.InboundHistory) — the envelope-builder path — and leaks the same handle: 18/26 cases failed with EBUSY on both 6e4d387fed and the previous head. The same three-line teardown fix in extensions/zalouser/src/ingress.test-support.ts turns all three files green (42/42) on Windows, and is included in this PR.
  • Windows proof (exact head, native Windows 11, Node 24.15.0, run by @Yigtwxx): base 9 failed / 38 passed → head 48 passed (48). A mutation run commenting out only the two closeOpenClawAgentDatabasesForTest() calls while keeping the retry budget reproduces the original stall, confirming the agent-DB close carries the fix and the maxRetries/retryDelay bump is hygiene matching the canonical fixture, not the repair.

Punchcard-Session: calm-willow-river-a9

@openclaw-barnacle openclaw-barnacle Bot added the channel: zalo Channel integration: zalo label Aug 6, 2026
@wangmiao0668000666
wangmiao0668000666 marked this pull request as ready for review August 6, 2026 01:59
@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. labels Aug 6, 2026
@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 6, 2026, 10:38 AM ET / 14:38 UTC.

ClawSweeper review

What this changes

This PR makes Zalo and Zalo-user lifecycle test fixtures close cached per-agent SQLite databases before deleting temporary state directories, and adds regressions for handle release and environment-restore ordering.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

Keep open: current main still has the faulty teardown order, while this PR applies the established lifecycle fix with exact-head native Windows proof and focused regressions. No actionable patch finding was found.

Priority: P2
Reviewed head: a0a652a85f04f09ef0dddd88690d123bad43122d

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong platform-specific proof, owner-boundary regressions, and a narrow test-only implementation support a high-confidence review.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): An exact-head native Windows terminal run demonstrates the repaired files pass after failing on the base, and mutation evidence isolates the handle-close and ordering behavior.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): An exact-head native Windows terminal run demonstrates the repaired files pass after failing on the base, and mutation evidence isolates the handle-close and ordering behavior.
Evidence reviewed 6 items Current-main gap: Current main still closes only shared state before removing the Zalo lifecycle directory, so it has not absorbed this repair.
Lease contract: Closing a cached agent database closes its SQLite handle and then releases its lease through a shared-state write, establishing the required agent-before-shared ordering.
PR-head repair: The PR closes agent databases, then shared state, removes the child directory, and only then restores the parent state environment.
Findings None None.
Security None None.

How this fits together

Zalo and Zalo-user integration tests create temporary OpenClaw state while processing inbound channel events. Those events can open cached per-agent SQLite handles, which the fixture must close before removing the state directory on Windows.

flowchart LR
  Test[Channel lifecycle test] --> Fixture[Temporary state fixture]
  Fixture --> AgentDb[Cached per-agent database]
  Fixture --> SharedDb[Shared state database]
  AgentDb --> Close[Close agent then shared handles]
  SharedDb --> Close
  Close --> Cleanup[Remove temporary state directory]
Loading

Before merge

  • Complete next step (P2) - No repair lane is needed; this is a complete bounded PR awaiting normal maintainer landing checks.
Agent review details

Security

None.

PR surface

Source +16, Tests +61. Total +77 across 5 files.

View PR surface stats
Area Files Added Removed Net
Source 2 19 3 +16
Tests 3 62 1 +61
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 5 81 4 +77

Review metrics

Metric Value Why it matters
Production vs test LOC production +0/-0; test and test-support +81/-4 All changes are fixture and regression coverage, so the repair adds no shipping runtime, configuration, schema, or API surface.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #119796
Summary: This PR repairs two lifecycle fixtures for the canonical Windows SQLite-handle teardown issue; the remaining disjoint fixtures are covered by a separate open PR.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Land this narrow fixture-owner repair, while keeping the remaining disjoint Zalo-user fixtures in #119964.

Do we have a high-confidence way to reproduce the issue?

Yes—current main retains the same close-shared-then-remove path, and the supplied native Windows before/after run plus the clear source path provide a high-confidence reproduction route.

Is this the best way to solve the issue?

Yes—the patch repairs the fixture lifecycle owner rather than relying on removal retries, follows the merged canonical ordering, and covers the Zalo-user environment-ordering sibling.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against f5add8197fa9.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This repairs a deterministic Windows-only contributor test teardown failure without affecting end-user runtime behavior.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): An exact-head native Windows terminal run demonstrates the repaired files pass after failing on the base, and mutation evidence isolates the handle-close and ordering behavior.
  • proof: sufficient: Contributor real behavior proof is sufficient. An exact-head native Windows terminal run demonstrates the repaired files pass after failing on the base, and mutation evidence isolates the handle-close and ordering behavior.

Evidence

What I checked:

Likely related people:

  • vincentkoc: Authored the merged cross-platform SQLite fixture cleanup whose lifecycle ordering this repair follows. (role: canonical fixture-pattern author; confidence: high; commits: 48d65f94a13c; files: src/test-utils/openclaw-test-state.ts)
  • Alix-007: Available shallow history attributes the pre-fix Zalo and Zalo-user fixture lines to this contributor; deeper ownership is unavailable locally. (role: current fixture-history contributor; confidence: medium; commits: 819f92bba5c2; files: extensions/zalo/src/test-support/monitor-mocks-test-support.ts, extensions/zalouser/src/ingress.test-support.ts)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-06T03:11:19.917Z sha 12abccf :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-06T03:36:56.289Z sha 12abccf :: needs real behavior proof before merge. :: none
  • reviewed 2026-08-06T06:47:23.654Z sha 88cf58f :: needs changes before merge. :: [P2] Close fixture handles before restoring its state environment
  • reviewed 2026-08-06T09:37:29.757Z sha a0a652a :: needs maintainer review before merge. :: none

@Yigtwxx

Yigtwxx commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

I filed the Windows measurement behind #119796, so I ran this branch on the box that surfaces the defect. Windows 11, Node 24.15.0, source checkout, four arms, all run by me via node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-zalo.config.ts --configLoader runner <files>.

1. The fix does work on Windows

arm files result
base 6e4d387fed monitor.polling-lifecycle + monitor.lifecycle + webhook-spool 9 failed / 38 passed (47), every failure EBUSY … openclaw-agent.sqlite in teardown
head 12abccfcb7 the same three + the new test-support/monitor-mocks-test-support.test.ts 48 passed (48)

That covers the "Not verified: an actual Windows run (no Windows box here)" line in the body.

2. The agent-DB close carries the fix, not the retry budget

The diff changes two things at once, and only one of them matters. At head I commented out just the two closeOpenClawAgentDatabasesForTest() calls and left maxRetries: 20, retryDelay: 25 in place:

  • test-support/monitor-mocks-test-support.test.ts → 1 failed (handle.db.isOpen still true). The new regression test is load-bearing on Windows too, not only as a Linux-observable proxy.
  • monitor.polling-lifecycle.test.ts alone → still running with no output for 30000ms … no output for 120000ms; terminating stalled Vitest process group.

Retry-only reproduces the exact stall I reported on the issue, so the retry half of the diff is hygiene, not the repair. Worth stating in the body, because it is the half that reads like the fix.

3. The sibling check does not hold — zalouser is affected, through the same handle

The body says zalouser "ingress tests only exercise the queue mechanics (createZalouserIngressMonitor), never the monitor's envelope builder, so no agent DB is opened there and no change is needed." On Windows:

arm files result
base 6e4d387fed zalouser/ingress + monitor.account-scope + monitor.group-gating 18 failed / 24 passed (42)
head 12abccfcb7 same 18 failed / 24 passed (42) — unchanged, this PR does not touch zalouser
head + the patch below same 42 passed (42)

The base and head columns are identical, so this is inherited and not introduced here — same finding shape as my note on #110803. But it is the sibling half of the very defect this PR closes, and the error path names the per-agent DB under zalouser's own fixture directory:

EBUSY: resource busy or locked, unlink
  'C:\Users\Asus\AppData\Local\Temp\openclaw\openclaw-zalouser-ingress-SPlKDz\agents\main\agent\openclaw-agent.sqlite-shm'

The claim is right for two of the three files: ingress.test.ts and monitor.account-scope.test.ts are green. All 18 failures are in monitor.group-gating.test.ts (18 of its 26 cases). That file goes through the same withZalouserIngressTestQueue fixture (extensions/zalouser/src/ingress.test-support.ts:61) but asserts on fully built dispatch context — ctx.WasMentioned (monitor.group-gating.test.ts:589), ctx.InboundHistory (:1002), quote metadata — i.e. the envelope-builder path, not queue mechanics. ingress.test-support.ts:83-84 is the untouched close-shared-then-rm pattern.

This is also the item ClawSweeper left open on the issue ("sibling Zalouser coverage needs resolution before this issue can be considered fixed"), so it is measured either way now.

The analogous change is three lines, and it is exactly what produced the 42 passed (42) row above:

--- a/extensions/zalouser/src/ingress.test-support.ts
+++ b/extensions/zalouser/src/ingress.test-support.ts
@@ -5,6 +5,7 @@ import {
   closeOpenClawStateDatabaseForTest,
   createChannelIngressQueueForTests,
 } from "openclaw/plugin-sdk/plugin-state-test-runtime";
+import { closeOpenClawAgentDatabasesForTest } from "openclaw/plugin-sdk/sqlite-runtime-testing";
 import { resolvePreferredOpenClawTmpDir } from "openclaw/plugin-sdk/temp-path";
 import { expect, vi } from "vitest";
 import type { createZalouserIngressMonitor } from "./ingress.js";
@@ -80,8 +81,9 @@ export async function withZalouserIngressTestQueue<T>(
     } else {
       process.env.OPENCLAW_STATE_DIR = previousStateDir;
     }
+    closeOpenClawAgentDatabasesForTest();
     closeOpenClawStateDatabaseForTest();
-    await fs.rm(stateDir, { recursive: true, force: true });
+    await fs.rm(stateDir, { recursive: true, force: true, maxRetries: 20, retryDelay: 25 });
   }
 }

Whether that lands here or as a follow-up is your call — the scope argument for keeping this PR zalo-only is reasonable. The one thing to avoid is landing the zalo half while the body records the sibling as clean; if you keep it out of scope, narrowing that paragraph to "ingress.test.ts and monitor.account-scope.test.ts do not open an agent DB; monitor.group-gating.test.ts does and is tracked separately" would keep the record accurate. Happy to open it against your branch if that is easier.

Scope of what I did not check: I only ran the zalo project config. I did not sweep the other channel fixtures for the same close-shared-then-rm shape, so there may be further siblings beyond zalouser.

Raw terminal output (native Windows 11, Node 24.15.0, exact head 12abccfcb7376c3b1146fe219df607257ba12234) — for the "Add real behavior proof" checklist item

Control, PR base 6e4d387feda92e456227c1c7b4b44ca3dcf69263:

$ node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-zalo.config.ts --configLoader runner \
    extensions/zalo/src/monitor.polling-lifecycle.test.ts \
    extensions/zalo/src/monitor.lifecycle.test.ts \
    extensions/zalo/src/webhook-spool.test.ts

 FAIL  |extension-zalo| extensions/zalo/src/monitor.polling-lifecycle.test.ts > Zalo polling image handling
 FAIL  |extension-zalo| extensions/zalo/src/monitor.polling-lifecycle.test.ts > Zalo pairing lifecycle
Error: EBUSY: resource busy or locked, unlink 'C:\Users\<redacted>\AppData\Local\Temp\openclaw\openclaw-zalo-lifecycle-zFXnbw\agents\main\agent\openclaw-agent.sqlite'

 FAIL  |extension-zalo| extensions/zalo/src/monitor.polling-lifecycle.test.ts > Zalo reply-once lifecycle
Error: EBUSY: resource busy or locked, unlink 'C:\Users\<redacted>\AppData\Local\Temp\openclaw\openclaw-zalo-lifecycle-zFXnbw\agents\main\agent\openclaw-agent.sqlite-shm'

 Test Files  1 failed | 2 passed (3)
      Tests  9 failed | 38 passed (47)
   Duration  97.63s
[vitest] FAILED (exit 1)

Treatment, exact head 12abccfcb7376c3b1146fe219df607257ba12234, same three files plus the new regression test:

$ node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-zalo.config.ts --configLoader runner \
    extensions/zalo/src/monitor.polling-lifecycle.test.ts \
    extensions/zalo/src/monitor.lifecycle.test.ts \
    extensions/zalo/src/webhook-spool.test.ts \
    extensions/zalo/src/test-support/monitor-mocks-test-support.test.ts

 RUN  v4.1.10 C:/Users/<redacted>/Desktop/OpenClaw/openclaw

 Test Files  4 passed (4)
      Tests  48 passed (48)
   Start at  08:40:48
   Duration  35.43s (transform 47.59s, setup 4.46s, import 44.50s, tests 33.97s, environment 0ms)
$ echo $?
0

Mutation on the exact head — only the two closeOpenClawAgentDatabasesForTest() calls commented out, maxRetries: 20, retryDelay: 25 left in place:

$ node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-zalo.config.ts --configLoader runner \
    extensions/zalo/src/monitor.polling-lifecycle.test.ts

[vitest] still running with no output for 30000ms (...)
[vitest] still running with no output for 60000ms (...)
[vitest] still running with no output for 90000ms (...)
[vitest] no output for 120000ms; terminating stalled Vitest process group (...)
[vitest] FAILED (exit 1)

Sibling, exact head plus the three-line extensions/zalouser/src/ingress.test-support.ts change quoted above:

$ node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-zalo.config.ts --configLoader runner \
    extensions/zalouser/src/ingress.test.ts \
    extensions/zalouser/src/monitor.account-scope.test.ts \
    extensions/zalouser/src/monitor.group-gating.test.ts

 Test Files  3 passed (3)
      Tests  42 passed (42)
   Duration  29.31s
$ echo $?
0

Without that sibling change the same three files give 18 failed / 24 passed (42) on both 6e4d387fed and 12abccfcb7.

Environment: Windows 11 Pro 26200, Node v24.15.0, vitest 4.1.10, clean checkout of each SHA in the same working tree (git checkout --detach <sha>), shared node_modules. Only usernames and the vitest argument echo were redacted; counts, durations and SHAs are verbatim.

@openclaw-barnacle openclaw-barnacle Bot added the channel: zalouser Channel integration: zalouser label Aug 6, 2026
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Update on the two open items, head 88cf58f2ec:

  1. Real behavior proof: @Yigtwxx ran the exact previous head natively on Windows 11 (Node 24.15.0) — base 9 failed / 38 passed, head 48 passed (48) — and a mutation run isolating the agent-DB close as the load-bearing change (comment). This is the Windows proof this review asked for.

  2. Zalouser sibling: the measurement showed my earlier sibling claim was wrong — monitor.group-gating.test.ts builds full dispatch context through the envelope builder and leaked the same handle (18/26 EBUSY failures on both base and head). The same three-line teardown fix is now included in extensions/zalouser/src/ingress.test-support.ts. Verified locally (Linux, Node 24.18.0): extensions/zalouser/src/{ingress,monitor.account-scope,monitor.group-gating}.test.ts → 42 passed (42), matching the Windows result. The zalo suite is unchanged and still 48/48.

The PR body is updated accordingly: the sibling paragraph now records the measured zalouser state, and it states explicitly that the maxRetries/retryDelay bump is hygiene matching the canonical #113316 fixture, not the repair itself (the agent-DB close is, per the mutation run).

@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Aug 6, 2026
…tate env (openclaw#119796)

ClawSweeper re-review finding: the ingress fixture restored
OPENCLAW_STATE_DIR before closing cached per-agent databases, so lease
release could open a shared-state write against the parent fixture env.
Move both closes ahead of the env restore (canonical fixture order) and
add a nested-environment regression asserting the parent state dir stays
untouched.
@wangmiao0668000666

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the P2 finding on the new head a0a652a85f04f09ef0dddd88690d123bad43122d:

  • extensions/zalouser/src/ingress.test-support.ts: both fixture database closes now run before OPENCLAW_STATE_DIR is restored, matching the canonical Zalo teardown order (closes → temp-dir removal → env restore).
  • Added extensions/zalouser/src/ingress.test-support.test.ts: nested-environment regression proving teardown leaves a parent state dir completely untouched (the old order leaked openclaw.sqlite* writes into it).

Proof: new regression passes; full extensions/zalouser + extensions/zalo suites pass except 8 pre-existing setup-surface.test.ts failures that reproduce identically on the base tree without this change (verified on the same runner).

@clawsweeper

clawsweeper Bot commented Aug 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Aug 6, 2026
@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 other 🚨 Merging this PR has meaningful risk outside the owned taxonomy. label Aug 6, 2026
@Yigtwxx

Yigtwxx commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

My earlier proof was taken at head 12abccfcb7, and two revisions have landed since, so I re-ran the measurement on the exact current head a0a652a8. Same box as before: Windows 11, Node 24.15.0, source checkout, everything run by me with node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-zalo.config.ts --configLoader runner. This time I ran the whole shard instead of a file subset, since that config routes both extensions/zalo and extensions/zalouser.

1. The current head still holds

arm test files tests
base 6e4d387fed 5 failed / 47 passed (52) 43 failed / 406 passed (449)
head a0a652a8 3 failed / 51 passed (54) 16 failed / 435 passed (451)

Per file:

file base head
extensions/zalo/src/monitor.polling-lifecycle.test.ts 12 failed passes
extensions/zalouser/src/monitor.group-gating.test.ts 18 failed passes
extensions/zalouser/src/zalo-js.credentials.test.ts 7 failed 7 failed
extensions/zalouser/src/zalo-quote-metadata.test.ts 7 failed 7 failed
extensions/zalouser/doctor-contract-api.test.ts 2 failed 2 failed

Both files this revision adds pass natively: ingress.test-support.test.ts + monitor-mocks-test-support.test.ts, 2 passed (2).

2. The new ordering change is load-bearing

I mutated only the teardown order in extensions/zalouser/src/ingress.test-support.ts on this head — moved the OPENCLAW_STATE_DIR restore back above the two closes, nothing else — and re-ran the new regression:

FAIL extensions/zalouser/src/ingress.test-support.test.ts > withZalouserIngressTestQueue > does not write through the parent state environment during teardown
AssertionError: expected [ 'state' ] to deeply equal []

So the new test pins the close-before-restore order itself, not just the shape of the file.

3. What is still red on this head is not this PR's

The 16 survivors sit in three files this PR does not touch, and they are the same EBUSY teardown class:

FAIL extensions/zalouser/doctor-contract-api.test.ts > moves legacy group-shaped DM sessions to canonical direct keys
Error: EBUSY: resource busy or locked, unlink '...\openclaw-zalouser-doctor-Qjgk6Z\openclaw-agent.sqlite-shm'

That one is literally the handle this PR closes: the fixture calls resetPluginStateStoreForTests(), which closes plugin state and shared state but never the cached agent databases. I checked the same mechanism locally on top of this head (not part of this PR, just to confirm the diagnosis):

  • doctor-contract-api.test.ts: one closeOpenClawAgentDatabasesForTest() before the fs.rm in afterEach -> 5 passed (5)
  • zalo-quote-metadata.test.ts: the same two calls in the single withStoredSession finally -> 7 passed (7)
  • zalo-js.credentials.test.ts: the fixture is inlined at 10 rm(stateDir, ...) sites, so it needs the same pair at each one (or a shared helper)

With those three, the whole shard goes green on Windows: 54 passed (54) files, 451 passed (451) tests.

None of that is a blocker here — this PR fixes its own fixtures and regresses nothing. It just means #119796 is not fully closed by this PR alone; the three siblings above are a separate follow-up.

@Yigtwxx

Yigtwxx commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Follow-up for the three sibling fixtures from my previous comment is open as #119964, so this PR does not need to grow. It touches only doctor-contract-api.test.ts, zalo-js.credentials.test.ts and zalo-quote-metadata.test.ts, so there is no overlap with your diff.

@vincentkoc vincentkoc self-assigned this Aug 6, 2026
@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 Aug 6, 2026
@vincentkoc
vincentkoc merged commit 978f9b1 into openclaw:main Aug 6, 2026
113 of 114 checks passed
@vincentkoc

Copy link
Copy Markdown
Member

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 7, 2026
…agent state DB (openclaw#119809)

* fix(test): close zalo agent state databases before lifecycle temp-dir removal (openclaw#119796)

* fix(test): close zalouser agent state databases before ingress temp-dir removal (openclaw#119796)

* fix(test): close zalouser fixture databases before restoring parent state env (openclaw#119796)

ClawSweeper re-review finding: the ingress fixture restored
OPENCLAW_STATE_DIR before closing cached per-agent databases, so lease
release could open a shared-state write against the parent fixture env.
Move both closes ahead of the env restore (canonical fixture order) and
add a nested-environment regression asserting the parent state dir stays
untouched.
@wangmiao0668000666
wangmiao0668000666 deleted the fix/zalo-test-teardown-agent-db-close branch October 28, 2026 07:42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: zalo Channel integration: zalo channel: zalouser Channel integration: zalouser 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: S 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.

3 participants