Skip to content

fix: prevent stale database workers across extension tests - #147986

Merged
steipete merged 4 commits into
mainfrom
codex/extension-worker-fixture-cleanup-main-20260913
Sep 14, 2026
Merged

steipete merged 4 commits into
mainfrom
codex/extension-worker-fixture-cleanup-main-20260913

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Related: #146557

What Problem This Solves

Fixes extension test cleanup that can leave a database worker alive after its temporary database files are deleted, causing a later fixture to fail with a worker identity collision.

User Impact

There is no user-visible runtime change. Tests retire their shared database workers before deleting temporary state; no schema, persistence, or configuration changes are included.

Why This Change Was Made

The existing synchronous test reset clears cached handles and failure latches, but does not await asynchronous worker retirement. The affected fixtures await the existing shared-state close owner after their producers finish and before resetting test state or deleting files. The private test SDK exposes that existing close operation.

This covers 37 verified lifecycle gaps within the maintained extension-worker test inventory, including the voice-call fixture sequence observed in #146557. Test assertions and existing agent-database cleanup ordering are preserved.

The branch now includes main through 6b3e342ddb1e, including the merged Docker CI assertion fix #148129 and the earlier UI fixes #147973, #147869, and #147749. Both normal main merges had no file overlap with this PR; all 38 cleanup/SDK files and the complete patch remain unchanged from b085a6e6e546.

Evidence

  • The earlier 18 selected ordinary cases passed on both this main-based cleanup patch and the KV candidate, covering voice snapshot tailing and persistence, Discord, Nostr, Teams, Matrix, memory, and Telegram state flows. That proof is retained.
  • On the preceding main refresh, the two selected controls affected by newer owner code passed again: voice-call snapshot persistence and explicit provider-none memory indexing. Only those two cases were rerun locally; failure, path, and oversized scenarios were not rerun.
  • Fresh independent P2 review of merge commit 6c7dc49582f7 against the newly captured main found no actionable issues.
  • All 39 canonical scoped checks passed for d18b901a30c7. That proof is retained for the identical cleanup patch: the relevant shared-state/worker owners and dependency contracts are unchanged in this refresh.
  • The original worker identity collision supports the cleanup explanation; deterministic inode reuse was not separately reproduced. Full affected suites remain a CI gate.

CI run 34828735765 on d18b901a30c7 completed all 140 jobs: 123 succeeded, 15 were skipped, and only the known Docker helper assertion plus the aggregate gate failed. Both previous UI blockers passed. This refresh includes merged fix #148129 for that Docker assertion; new-head CI remains the final verification gate. The earlier failed run 34812209212 is retained as historical evidence.

QA attribution fixture follow-up

The marker-attribution fixture now supplies an empty fixture-owned docs root through the renderer’s existing --docs-root option. Its synthetic taxonomy has no docs references, so traversing the repository docs tree was incidental. Both full/slim paths retain the actual producer, importer, scorecard, renderer, assertions, and 60-second deadline.

The original CI run 34837317278 completed all 140 jobs and failed only this full-mode attribution test plus the aggregate gate; earlier UI, lint, and Docker blockers passed. The failed job checked out synthetic merge 55e6a45c57b69a4ffd2ae31801c985213bc4aaea (candidate 6c7dc49582f7a77ee7d4abfd33b1ef96c536a44a into f4ffd8c21fcd9ff9df417fba01c3c1afb1ad3c7a). The log does not identify the slow phase. This follow-up removes incidental work; it does not claim to have diagnosed that timeout.

Focused validation passed exactly the two synthetic marker-attribution full/slim cases (19.7s / 8.8s), with all other cases excluded. All 19 canonical scoped checks passed, including the extension test typecheck, static guards and lint. Fresh independent P2 review is clean. The prior 38-file cleanup qualification remains retained. No installed-package proof is claimed. Current-head CI34844959691 is green: all140 jobs completed,125 passed and15 skipped, including the previously failing QA shard. Native prepare completed successfully at unchanged head 1c920ed3ec1cf8d2d403be61bb37d10d79efda64 using hosted evidence; the final maintainer merge remains outstanding.

Await the existing shared-state close owner before test store resets and
temporary-state removal in 37 verified extension fixtures. Expose that
existing operation through the private test SDK barrel. Preserve producer
completion, synchronous failure-latch resets, and all test assertions.

Eighteen selected ordinary cases, all 39 canonical scoped checks, and an
independent P2 review of the complete fixture packet pass.
@clawsweeper

clawsweeper Bot commented Sep 14, 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.

@steipete
steipete marked this pull request as ready for review September 14, 2026 06:08
@openclaw-barnacle openclaw-barnacle Bot added channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nostr Channel integration: nostr channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: zalouser Channel integration: zalouser extensions: memory-core Extension: memory-core extensions: device-pair extensions: acpx channel: reef Channel integration: reef channel: buzz extensions: active-memory plugin: visitor-access size: S maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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 Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 14, 2026, 10:22 AM ET / 14:22 UTC (Revision 5).

ClawSweeper review

What this changes

Extension tests await shared database worker shutdown before removing temporary state, and the QA attribution fixture uses its own empty docs directory.

Merge readiness

✅ Ready for maintainer review

The cleanup remains useful on current main. No actionable patch defect was found, and the pinned head’s CI completed successfully; this maintainer-protected PR should remain a landing candidate.

Priority: P2
Reviewed head: 1c920ed3ec1cf8d2d403be61bb37d10d79efda64

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused lifecycle repair with preserved assertions, appropriate private support, and successful pinned-head CI.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored test-support change is exempt from external contributor runtime proof; retained fixture runs and verified pinned-head CI support validation, without claiming deterministic collision or installed-package proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored test-support change is exempt from external contributor runtime proof; retained fixture runs and verified pinned-head CI support validation, without claiming deterministic collision or installed-package proof.
Evidence reviewed 9 items Existing shutdown owner provides the required ordering: The asynchronous close joins registered resource shutdown before retiring native handles. Successful lifecycle closure also forgets database identity records; synchronous test closure only closes native handles and clears terminal failure latches.
Worker retirement is awaited: The shared-state worker owner registers its close operation with the database lifecycle and joins retiring stores with Promise.allSettled, preserving cleanup errors.
Fixture ordering preserves producer settlement: The voice-call fixture releases held writes, stops its manager, settles persistence work, then awaits database closure before resetting state and removing its directory. Memory fixtures retain agent-before-shared-database closure.
Findings None None.
Security None None.

How this fits together

Extension tests exercise OpenClaw’s shared SQLite state through temporary databases. Their teardown must finish producers and retire database workers before deleting fixtures so later tests start with independent state.

flowchart TD
  A[Extension test fixtures] --> B[Finish producers]
  B --> C[Await shared database close]
  C --> D[Retire workers and native handles]
  D --> E[Reset test state]
  E --> F[Delete temporary files]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +1, Tests +95. Total +96 across 39 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 38 119 24 +95
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 39 120 24 +96

Review metrics

None.

Technical review

Best possible solution:

Keep fixture shutdown with the existing shared database lifecycle owner, preserving producer settlement, failure-latch resets, and independent temporary directories.

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

No deterministic collision reproduction was established in this review. Source confirms that synchronous reset can return before worker retirement; the PR explicitly acknowledges that inode reuse was not separately reproduced.

Is this the best way to solve the issue?

Yes. Awaiting the existing shutdown owner repairs teardown ordering without introducing another lifecycle implementation, and the QA fixture uses an already-supported isolation option.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 10d67c803047.

Labels

Label justifications:

  • P2: This repairs bounded test lifecycle failures that interfere with extension validation without changing user runtime behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The maintainer-authored test-support change is exempt from external contributor runtime proof; retained fixture runs and verified pinned-head CI support validation, without claiming deterministic collision or installed-package proof.

Evidence

What I checked:

  • Existing shutdown owner provides the required ordering: The asynchronous close joins registered resource shutdown before retiring native handles. Successful lifecycle closure also forgets database identity records; synchronous test closure only closes native handles and clears terminal failure latches. (src/state/openclaw-state-db-cache.ts:589, 1c920ed3ec1c)
  • Worker retirement is awaited: The shared-state worker owner registers its close operation with the database lifecycle and joins retiring stores with Promise.allSettled, preserving cleanup errors. (src/state/openclaw-state-worker-store.ts:77, 1c920ed3ec1c)
  • Fixture ordering preserves producer settlement: The voice-call fixture releases held writes, stops its manager, settles persistence work, then awaits database closure before resetting state and removing its directory. Memory fixtures retain agent-before-shared-database closure. (extensions/voice-call/src/manager.async-store.test.ts:112, 1c920ed3ec1c)
  • Export stays outside the published plugin API: sqlite-runtime-testing is classified as private local-only and non-production; package.json excludes its JavaScript and declarations. The added export reuses an existing lifecycle operation without changing a shipped plugin contract. (scripts/lib/plugin-sdk-entries.mts:63, 1c920ed3ec1c)
  • QA fixture isolation preserves coverage: The synthetic taxonomy has no docs references. Passing a fixture-owned docs root avoids the renderer’s recursive repository scan while retaining the producer/importer/scorecard/rendering assertions and original 60-second deadline. (extensions/qa-lab/src/test-file-scenario-runner.coverage.test.ts:224, 1c920ed3ec1c)
  • Still necessary on main: Inspection of fetched main 10d67c8 found the voice-call teardown still using synchronous reset before removal and the private barrel lacking the asynchronous export. The v2026.9.4 barrel also lacks it. The related merged UI and Docker fixes do not implement this cleanup. (extensions/voice-call/src/manager.async-store.test.ts:112, 10d67c803047)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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-09-14T06:31:01.689Z sha b085a6e :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T09:48:03.223Z sha d18b901 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T11:33:35.520Z sha 6c7dc49 :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T12:55:53.227Z sha 1c920ed :: needs maintainer review before merge. :: none

Refresh PR #147986 onto main 5c12872 so its independent cleanup
prerequisite includes the current UI performance and lint fixes.

The merge has no overlap with the 38-file cleanup patch; all prerequisite
source bytes and assertions remain unchanged. Preserve the previous
18-case ordinary proof and failed CI result. Recheck the positive voice
snapshot and provider-none memory controls against the newer owners.
Merge main 6b3e342, including Docker assertion fix #148129,
into PR #147986 while preserving its existing cleanup patch.

All 38 prerequisite source files and the complete patch remain identical
to the qualified d18 candidate. Preserve its terminal 140-job CI evidence,
including the known Docker failure, and the existing local checks and
selected ordinary controls. No runtime or package proof is added here.
@steipete
steipete merged commit ddd91ef into main Sep 14, 2026
200 of 202 checks passed
@steipete
steipete deleted the codex/extension-worker-fixture-cleanup-main-20260913 branch September 14, 2026 15:27
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…147986)

* test: drain shared workers before extension fixture cleanup

Await the existing shared-state close owner before test store resets and
temporary-state removal in 37 verified extension fixtures. Expose that
existing operation through the private test SDK barrel. Preserve producer
completion, synchronous failure-latch resets, and all test assertions.

Eighteen selected ordinary cases, all 39 canonical scoped checks, and an
independent P2 review of the complete fixture packet pass.

* test(qa): scope attribution renderer to fixture docs
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

channel: buzz channel: discord Channel integration: discord channel: imessage Channel integration: imessage channel: matrix Channel integration: matrix channel: msteams Channel integration: msteams channel: nostr Channel integration: nostr channel: reef Channel integration: reef channel: telegram Channel integration: telegram channel: voice-call Channel integration: voice-call channel: zalouser Channel integration: zalouser extensions: acpx extensions: active-memory extensions: device-pair extensions: memory-core Extension: memory-core maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: visitor-access rating: 🐚 platinum hermit Good normal PR readiness with ordinary 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.

1 participant