Skip to content

fix(test): nostr doctor and state-store suites fail Windows teardown with EBUSY - #127236

Merged
steipete merged 1 commit into
openclaw:mainfrom
Yigtwxx:fix/nostr-doctor-windows-teardown-ebusy
Aug 23, 2026
Merged

steipete merged 1 commit into
openclaw:mainfrom
Yigtwxx:fix/nostr-doctor-windows-teardown-ebusy

Conversation

@Yigtwxx

@Yigtwxx Yigtwxx commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Related: #119796

What Problem This Solves

Contributors on Windows cannot run the two extensions/nostr suites that write through the
plugin state store: they fail in teardown with EBUSY, so a green local run is impossible even
when every assertion in the suite passes. Both fixtures remove a temporary state directory while
the state database opened underneath it is still cached. On Linux unlinking an open file
succeeds, so CI never sees it.

Error: EBUSY: resource busy or locked, unlink
  'C:\...\Temp\openclaw-nostr-doctor-fNLnDc\state\openclaw.sqlite-shm'
Error: EBUSY: resource busy or locked, unlink
  'C:\...\Temp\openclaw-nostr-5CsTCQ\state\openclaw.sqlite'

Every failure is in teardown, never in an assertion. The exact file named varies between the
database and its -wal / -shm companions, because the removal walks the directory.

Why This Change Was Made

Both fixtures call resetPluginStateStoreForTests() when they set the fixture up and never
again, so the store opened during the test is still cached when the directory is removed:

  • doctor-contract-api.test.ts resets in beforeEach and removes the directory in afterEach.
  • nostr-state-store.test.ts resets inside withTempStateDir before running the body and
    removes the directory in the same helper's finally.

The repair is the ordering the fixtures merged in #126352 now use: reset the plugin state store
immediately before the removal, so the cached handle is released first. Two lines of teardown
plus a comment; tests only, no production file is touched.

User Impact

Contributors on Windows can run both extensions/nostr suites to completion instead of reading a
teardown failure that has nothing to do with the code under test. Behavior on Linux and macOS is
unchanged.

Evidence

Windows 11, Node 24.18.1, origin/main 3ae7ba31946, both arms on the same tree — the second arm
is that tree with only these two files patched.

node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-messaging.config.ts --configLoader runner <target>
target main with this branch
extensions/nostr/doctor-contract-api.test.ts 2 failed (2) 2 passed (2)
extensions/nostr/src/nostr-state-store.test.ts 4 failed / 5 passed (9) 9 passed (9)
extensions/nostr/ 6 failed / 273 passed (279) 279 passed (279)
the whole extension-messaging shard 2 files failed / 132 passed (134) 134 files passed, 1486 passed / 3 skipped

The shard has no other failure on this machine, so these two suites are its only Windows
teardown red.

Both added calls are load-bearing: each suite fails on main with its own removal path, and the
two teardowns are independent.

  • ./node_modules/.bin/tsgo -p test/tsconfig/tsconfig.extensions.test.json --noEmit -> exit 0
  • ./node_modules/.bin/oxlint <the two files> -> exit 0
  • ./node_modules/.bin/oxfmt --check <the two files> -> exit 0

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:

#126352 (merged)  eight extensions/ files: acpx, active-memory, codex, device-pair,
                  memory-core, msteams, alibaba, openai
#119964 (open)    three extensions/zalouser/ files
#127201 (merged)  src/gateway/github-publication.test-support.ts, landed `60ae513bd9c6`
this PR           extensions/nostr/doctor-contract-api.test.ts
                  extensions/nostr/src/nostr-state-store.test.ts

extensions/nostr was found by sweeping every doctor-contract-api.test.ts on main for a
fixture that removes its state directory without releasing the store first; the state-store suite
surfaced when the whole extensions/nostr directory was run. Suites that already reset in their
teardown, such as extensions/voice-call/doctor-contract-api.test.ts, are untouched.

…te dirs

The doctor migration fixture and the temporary-state-dir helper both open the
plugin state store under the fixture's directory and reset it only during setup,
so Windows fails the removal with EBUSY while Linux unlinks the open files and
stays green.

Reset the store immediately before each removal, matching the ordering the
fixtures repaired in openclaw#126352 already use.
@clawsweeper

clawsweeper Bot commented Aug 21, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@openclaw-barnacle openclaw-barnacle Bot added channel: nostr Channel integration: nostr size: XS labels Aug 21, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. labels Aug 21, 2026
@clawsweeper

clawsweeper Bot commented Aug 21, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 23, 2026, 11:33 AM ET / 15:33 UTC.

ClawSweeper review

What this changes

This test-only PR releases the Nostr plugin-state store before two temporary state directories are deleted, preventing Windows SQLite EBUSY teardown failures.

Regression provenance

Possible regression — suspected (reproduction). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still removes both Nostr fixture directories without releasing the cached plugin-state database, while the proposed calls release that exact owner before removal. No blocking patch defect found; likely related people are Peter Steinberger (high confidence) and Vincent Koc (medium confidence).

Priority: P2
Reviewed head: 182c2a8e1ba771f5ef2b3dd00cc2dc2eae428ff1

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A minimal owner-boundary cleanup with concrete Windows before/after proof; only rebase and exact-head verification remain.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (terminal): The PR body supplies native Windows terminal evidence showing the two changed suites and their shard fail before the cleanup and pass afterward.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body supplies native Windows terminal evidence showing the two changed suites and their shard fail before the cleanup and pass afterward.
Evidence reviewed 6 items Current main still has the teardown gap: Current main removes the doctor fixture directory and the temporary state directory without a preceding reset; the PR adds the reset at each of these exact teardown boundaries.
The reset closes the owning cached database: The test helper closes the plugin-state database and shared state database before clearing test-local option signatures, so it releases the handle opened by these fixtures rather than masking removal errors.
Both Nostr paths open only plugin state under their fixture directory: The state-store tests route Nostr reads and writes through createPluginStateKeyedStoreForTests with the temporary directory, and doctor migrations receive the same store through their context.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-messaging.config.ts --configLoader runner extensions/nostr/doctor-contract-api.test.ts extensions/nostr/src/nostr-state-store.test.ts

Result: PASS (completed)

node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-messaging.config.ts --configLoader runner extensions/nostr/doctor-contract-api.test.ts ext
ensions/nostr/src/nostr-state-store.test.ts
runner@runnervm76f27:/tmp/clawsweeper-live-proof-127236-XQ5Qm0/target$ node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-messaging.config.ts
 --configLoader runner extensions/nostr/doctor-contract-api.test.ts extensions/nostr/src/nostr-state-store.test.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-127236-XQ5Qm0/target

node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-messaging.config.ts --configLoader runner extensions/nostr/doctor-contract-api.test.ts ext
ensions/nostr/src/nostr-state-store.test.ts
 ✓  extension-messaging  extensions/nostr/doctor-contract-api.test.ts (2 tests) 533ms
     ✓ imports legacy bus and profile state into plugin state  368ms
 ✓  extension-messaging  extensions/nostr/src/nostr-state-store.test.ts (9 tests) 887ms
     ✓ persists and reloads state across restarts  440ms

 Test Files  2 passed (2)
      Tests  11 passed (11)
   Start at  15:34:39
   Duration  5.04s (transform 5.92s, setup 2.39s, import 5.26s, tests 1.42s, environment 0ms)

runner@runnervm76f27:/tmp/clawsweeper-live-proof-127236-XQ5Qm0/target$ node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-messaging.config.ts
 --configLoader runner extensions/nostr/doctor-contract-api.test.ts extensions/nostr/src/nostr-state-store.test.ts






























Assertions:

  • PASS expect_output: passed

How this fits together

Nostr tests create temporary OpenClaw state directories and open the shared SQLite-backed plugin-state store through the Nostr runtime or doctor migration context. Teardown must close that cached database before recursive removal so Windows can delete the database and its WAL sidecars.

flowchart LR
  A[Nostr test fixture] --> B[Temporary state directory]
  B --> C[SQLite-backed plugin state]
  C --> D[Test and migration operations]
  D --> E[Release cached database]
  E --> F[Remove temporary directory]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; GitHub reports it cleanly mergeable, but it needs a rebase and exact-head checks before landing.
  • Complete next step (P2) - No repair lane is needed; the remaining work is routine rebase and exact-head verification before maintainer landing.
Agent review details

Security

None.

PR surface

Tests +4. Total +4 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 2 4 0 +4
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 4 0 +4

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +4/-0 The repair changes only fixture cleanup and adds no runtime or public-surface code.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the two teardown releases after rebasing, leaving each temporary fixture directory with no cached SQLite handle at removal time.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the two teardown releases after rebasing, leaving each temporary fixture directory with no cached SQLite handle at removal time.

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

Yes. The PR provides a native Windows command and before/after results, and current main source still omits both required teardown releases.

Is this the best way to solve the issue?

Yes. The existing reset is the owner-provided way to close the cached plugin and shared state databases; placing it immediately before removal fixes the leaked-handle boundary without retries or new production code.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This fixes a deterministic Windows-only contributor test workflow failure without changing production behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies native Windows terminal evidence showing the two changed suites and their shard fail before the cleanup and pass afterward.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies native Windows terminal evidence showing the two changed suites and their shard fail before the cleanup and pass afterward.

Evidence

What I checked:

  • Current main still has the teardown gap: Current main removes the doctor fixture directory and the temporary state directory without a preceding reset; the PR adds the reset at each of these exact teardown boundaries. (extensions/nostr/doctor-contract-api.test.ts:43, c4e0c003a406)
  • The reset closes the owning cached database: The test helper closes the plugin-state database and shared state database before clearing test-local option signatures, so it releases the handle opened by these fixtures rather than masking removal errors. (src/plugin-state/plugin-state-store.ts:521, 182c2a8e1ba7)
  • Both Nostr paths open only plugin state under their fixture directory: The state-store tests route Nostr reads and writes through createPluginStateKeyedStoreForTests with the temporary directory, and doctor migrations receive the same store through their context. (extensions/nostr/src/nostr-state-store.test.ts:28, 182c2a8e1ba7)
  • Merged sibling repair supports the teardown ordering: The merged fixture repair uses the same reset-before-removal pattern for a plugin-state-only doctor fixture; this PR applies that established owner-boundary cleanup to disjoint Nostr files. (extensions/zalouser/doctor-contract-api.test.ts:63, ff83e3efe811)
  • Feature-history ownership: History shows Peter Steinberger introduced the Nostr plugin and later moved the affected Nostr state and doctor files to SQLite; Vincent Koc later maintained the Nostr state-store/test surface. (extensions/nostr/src/nostr-state-store.ts:1, 33c246dbbaaa)
  • After-fix Windows behavior proof: The PR body records native Windows before/after runs: both changed suites and the extension-messaging shard fail only during teardown on the base and pass with these calls. (182c2a8e1ba7)

Likely related people:

  • Peter Steinberger: Introduced the Nostr plugin and authored the SQLite migration that touched both the Nostr state-store and doctor-contract surfaces. (role: feature owner and major state-storage refactor author; confidence: high; commits: 7b6cbf58697c, 33c246dbbaaa, 8cb53c7b5572; files: extensions/nostr/doctor-contract-api.ts, extensions/nostr/doctor-contract-api.test.ts, extensions/nostr/src/nostr-state-store.ts)
  • Vincent Koc: Recent Nostr state-account cleanup changed the state-store and its test alongside the account-ID owner. (role: recent adjacent Nostr state contributor; confidence: medium; commits: 22bdda25551e; files: extensions/nostr/src/nostr-state-store.ts, extensions/nostr/src/nostr-state-store.test.ts, extensions/nostr/src/state-account-id.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Rebase onto current main and rerun the stated Windows Nostr test command on the exact head.

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 (5 earlier review cycles)
  • reviewed 2026-08-21T15:26:48.147Z sha 182c2a8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T15:54:43.491Z sha 182c2a8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-21T16:26:19.229Z sha 182c2a8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T20:41:19.270Z sha 182c2a8 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-22T20:54:30.413Z sha 182c2a8 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. labels Aug 22, 2026
@steipete

Copy link
Copy Markdown
Contributor

Skipping the optional rebase and fresh Windows rerun: this branch is cleanly mergeable, repository policy does not rebase solely for mainline drift, and the current two Nostr fixtures still match the reviewed patch. Existing native Windows before/after proof covers both fixtures, all 279 Nostr tests, and the 1,486-test messaging shard; fresh exact-head isolated proof passes both affected suites (11 tests).

@steipete
steipete merged commit 8f3fdd8 into openclaw:main Aug 23, 2026
195 checks passed
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

@Yigtwxx
Yigtwxx deleted the fix/nostr-doctor-windows-teardown-ebusy branch August 23, 2026 21:14
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 24, 2026
…te dirs (openclaw#127236)

The doctor migration fixture and the temporary-state-dir helper both open the
plugin state store under the fixture's directory and reset it only during setup,
so Windows fails the removal with EBUSY while Linux unlinks the open files and
stays green.

Reset the store immediately before each removal, matching the ordering the
fixtures repaired in openclaw#126352 already use.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: nostr Channel integration: nostr P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XS 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.

2 participants