Skip to content

fix(test): doctor and auth fixtures fail Windows teardown with EBUSY - #126352

Merged
vincentkoc merged 1 commit into
openclaw:mainfrom
Yigtwxx:fix/windows-teardown-remaining-fixtures
Aug 21, 2026
Merged

vincentkoc merged 1 commit into
openclaw:mainfrom
Yigtwxx:fix/windows-teardown-remaining-fixtures

Conversation

@Yigtwxx

@Yigtwxx Yigtwxx commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

What Problem This Solves

Contributors on Windows cannot run eight extension test suites: they fail in teardown with
EBUSY, so a green local run is impossible even when every assertion in the suite passes.
Each fixture removes a temporary state directory while a SQLite handle 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-codex-doctor-HL4p5j\fixed-sessions\openclaw-agent.ops.sqlite'
Error: EBUSY: resource busy or locked, unlink
  'C:\...\Temp\openclaw-alibaba-wan-auth-2J4maB\openclaw-agent.sqlite'

Every failure is in teardown, never in an assertion.

Why This Change Was Made

Two entry points open a database under the fixture directory and neither existing cleanup call
releases it:

  • Doctor state migrations open per-agent databases plus the shared state database.
    resetPluginStateStoreForTests() releases plugin state and shared state only, so the
    per-agent handles stay cached.
  • saveAuthProfileStore(..., agentDir, ...) opens the per-agent database under the temporary
    agent dir. clearRuntimeAuthProfileStoreSnapshots() drops the in-memory snapshots but does not
    close it.

The repair is the ordering the zalo and zalouser fixtures already use:
closeOpenClawAgentDatabasesForTest() before the removal, and before
resetPluginStateStoreForTests() where both apply — the agent close releases leases through
shared state, so the reverse order can reopen it.

Tests only; no production file is touched.

User Impact

Contributors on Windows can run these eight 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 22.23.2, one suite per run, both arms on the same tree — origin/main
b24430fd042 and that tree with only these eight files patched.

suite main with this branch
extensions/acpx/doctor-contract-api.test.ts 3 failed / 3 passed (6) 6 passed
extensions/active-memory/doctor-contract-api.test.ts 2 failed / 1 passed (3) 3 passed
extensions/codex/doctor-contract-api.test.ts 17 failed / 15 passed (32) 32 passed
extensions/device-pair/doctor-contract-api.test.ts 1 failed / 1 passed (2) 2 passed
extensions/memory-core/doctor-contract-api.test.ts 48 failed / 10 passed / 2 skipped (60) 58 passed / 2 skipped
extensions/msteams/doctor-contract-api.test.ts 5 failed / 6 passed (11) 11 passed
extensions/alibaba/video-generation-provider.test.ts 2 failed / 16 passed (18) 18 passed
extensions/openai/video-generation-provider.test.ts 1 failed / 30 passed (31) 31 passed

79 failing cases on main, none after. Each row's main arm was measured by checking out
origin/main's copy of that single file into the patched tree, so nothing else in the run differs
between arms.

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

Relationship to #119964

This does not overlap the open repair. #119964 owns exactly three files, all under
extensions/zalouser/:

extensions/zalouser/doctor-contract-api.test.ts
extensions/zalouser/src/zalo-js.credentials.test.ts
extensions/zalouser/src/zalo-quote-metadata.test.ts

The eight files here are disjoint from those three. I wrote on #119796 on 6 August that the issue
was "fully covered once #119964 lands"; that was measured against the extension-zalo shard and is
too narrow for the defect class — these eight fixtures reproduce the same teardown failure on
current main today, outside that shard. Both branches can land in either order.

Linked issue: #119796.

…e state dirs

Doctor migrations and auth-profile writes open per-agent and shared state
databases under the fixture's temporary directory. Clearing the plugin
state store or the runtime auth snapshots does not release those handles,
so Windows fails the directory removal with EBUSY while Linux unlinks the
open files and stays green.

Close the cached databases before each removal, matching the ordering the
zalouser and zalo fixtures already use.
@clawsweeper

clawsweeper Bot commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@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 19, 2026
@clawsweeper

clawsweeper Bot commented Aug 19, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 19, 2026, 4:21 PM ET / 20:21 UTC.

ClawSweeper review

What this changes

This PR updates eight extension test teardowns to close cached SQLite state before removing temporary fixture directories, preventing Windows EBUSY failures.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

Keep open: current main still lacks this teardown cleanup, while the patch follows the existing SQLite-close ordering and has strong native-Windows before/after proof. No blocking patch defect found; land only from a green current merge result because the branch is behind main.

Priority: P2
Reviewed head: 464b0d10d97052ff86955d7eef557979ac41eb89

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) Strong platform-specific proof supports a focused test-only repair with no blocking review finding.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body contains native Windows before/after terminal evidence for all eight changed fixtures, showing the EBUSY failures disappear after the cleanup change.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body contains native Windows before/after terminal evidence for all eight changed fixtures, showing the EBUSY failures disappear after the cleanup change.
Evidence reviewed 8 items Shared-state cleanup owner: The existing reset helper closes the plugin-state database and shared OpenClaw state database, matching the five doctor fixtures that only use plugin state.
Per-agent cleanup owner: The agent-database test helper closes every cached handle and releases its lease before cleanup; the auth fixtures now invoke it before removing their temporary agent directories.
Auth path reaches the agent database: saveAuthProfileStore writes through runAuthProfileWriteTransaction, which selects the per-agent transaction for an agent directory; this supports the explicit close in the OpenAI and Alibaba fixtures.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-codex.config.ts --configLoader runner extensions/codex/doctor-contract-api.test.ts

Result: FAIL (failed) — step 1 run node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-codex.config.ts --configLoader runner extensions/codex/doctor-contract-api.test.ts: terminal command did not produce output within 20 seconds: "node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-codex.config.ts --configLoader runner extensions/codex/doctor-contract-api.test.ts"

node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-codex.config.ts --configLoader runner extensions/codex/doctor-contract-api.test.ts
runner@runnervmzvulz:/tmp/clawsweeper-live-proof-126352-rf32LE/target$ node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-codex.config.ts --c
onfigLoader runner extensions/codex/doctor-contract-api.test.ts

 RUN  v4.1.10 /tmp/clawsweeper-live-proof-126352-rf32LE/target

node scripts/run-vitest.mjs run --config test/vitest/vitest.extension-codex.config.ts --configLoader runner extensions/codex/doctor-contract-api.test.ts












































Assertions:

  • FAIL expect_output: Test Files

How this fits together

Doctor-migration and provider-auth tests create temporary OpenClaw state, which can open shared or per-agent SQLite caches. Their teardown must release the relevant cache before deleting the temporary directory on Windows.

flowchart LR
A[Extension test fixture] --> B[Doctor migration or auth write]
B --> C[Shared or agent SQLite cache]
C --> D[Test teardown]
D --> E[Temporary directory removal]
E --> F[Windows test result]
Loading

Before merge

  • Resolve merge risk (P1) - The branch is behind current main; merge only after GitHub produces a green result for the current merge commit and exact head.
  • Complete next step (P2) - No repair job is needed: the submitted patch is coherent; maintainers only need a green current merge result.
Agent review details

Security

None.

PR surface

Tests +22. Total +22 across 8 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 8 49 27 +22
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 8 49 27 +22

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +49/-27 All changes are test-fixture teardown cleanup; no runtime, config, schema, or dependency surface changes.

Stored data model

Persistent data-model change detected: migration/backfill/repair: extensions/codex/doctor-contract-api.test.ts, unknown-data-model-change: extensions/codex/doctor-contract-api.test.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #119796
Summary: This PR is a disjoint fixture-level candidate repair for the canonical Windows SQLite teardown report.

Members:

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

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Keep the explicit, fixture-owned cache release immediately before directory removal, preserving agent-before-shared ordering where both caches are involved.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Keep the explicit, fixture-owned cache release immediately before directory removal, preserving agent-before-shared ordering where both caches are involved.

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

Yes—source establishes the cached-handle path, and the PR provides native Windows before/after runs for all eight fixtures. This review did not rerun the Windows-only failure locally.

Is this the best way to solve the issue?

Yes—the patch closes the state owner each fixture actually opens before deletion, rather than masking the live-handle problem with filesystem retries.

AGENTS.md: found and applied where relevant.

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

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 contributor test-workflow failure without changing shipped 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): The PR body contains native Windows before/after terminal evidence for all eight changed fixtures, showing the EBUSY failures disappear after the cleanup change.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body contains native Windows before/after terminal evidence for all eight changed fixtures, showing the EBUSY failures disappear after the cleanup change.

Evidence

What I checked:

Likely related people:

  • Alex Knight: Introduced the recent state-lifecycle work that owns cached agent-database closing behavior. (role: agent-database lifecycle contributor; confidence: high; commits: bd4d4c0d3170; files: src/state/openclaw-agent-db.ts)
  • wangmiao0668000666: Authored the merged Zalo test repair for the same cache-close-before-removal invariant. (role: sibling Windows teardown repair author; confidence: high; commits: 978f9b15eb82; files: extensions/zalo/src/monitor.lifecycle.test.ts)
  • Peter Steinberger: Recent history spans the agent database, Doctor contract tests, and the affected Codex/Zalo test surfaces. (role: recent SQLite and doctor-area contributor; confidence: high; commits: 8cb53c7b5572, 710efc9a86de, ec06118f8331; files: src/state/openclaw-agent-db.ts, extensions/codex/doctor-contract-api.test.ts, extensions/zalo/src/monitor.lifecycle.test.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 (1 earlier review cycle)
  • reviewed 2026-08-19T16:18:47.061Z sha 464b0d1 :: needs maintainer review before merge. :: none

@openclaw-barnacle openclaw-barnacle Bot removed the triage: needs-pr-context Candidate: external PR body lacks required problem context or evidence. label Aug 19, 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 19, 2026
@vincentkoc vincentkoc self-assigned this Aug 21, 2026
@vincentkoc
vincentkoc merged commit ff83e3e into openclaw:main Aug 21, 2026
228 of 229 checks passed
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 22, 2026
…e state dirs (openclaw#126352)

Doctor migrations and auth-profile writes open per-agent and shared state
databases under the fixture's temporary directory. Clearing the plugin
state store or the runtime auth snapshots does not release those handles,
so Windows fails the directory removal with EBUSY while Linux unlinks the
open files and stays green.

Close the cached databases before each removal, matching the ordering the
zalouser and zalo fixtures already use.
@Yigtwxx
Yigtwxx deleted the fix/windows-teardown-remaining-fixtures branch August 23, 2026 15:39
steipete pushed a commit that referenced this pull request Aug 23, 2026
…te dirs (#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 #126352 already use.
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: msteams Channel integration: msteams extensions: acpx extensions: active-memory extensions: alibaba extensions: codex extensions: device-pair extensions: memory-core Extension: memory-core extensions: openai 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.

2 participants