Skip to content

fix(test): retire shared read pools between files - #154206

Merged
roboclaw-bot merged 1 commit into
mainfrom
openclaw/fix-shared-read-test-generation
Sep 21, 2026
Merged

roboclaw-bot merged 1 commit into
mainfrom
openclaw/fix-shared-read-test-generation

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Sep 21, 2026 •

Copy link
Copy Markdown
Collaborator

Closes #154205
Related: #154160

What Problem This Solves

Shared Vitest workers could carry a mocked read pool into another test file, causing real workspace snapshot reads to receive fleet.list replies.

User Impact

No production behavior changes. The fix removes an order-dependent CI failure without weakening workspace validation, authority checks, or test assertions.

Why This Change Was Made

The read pool registers cleanup callbacks only when its global singleton is first created. Test teardown retired its state-database lifecycle but not the pool singleton, so later pools could lose their cleanup owner. Add that existing singleton to the existing drain-before-retire map.

The expanded native regression walks three reader generations and reaches the actual workspace snapshot consumer. It fails with the same CI exception before the mapping and passes afterward. This repairs the owning test infrastructure rather than changing the downstream readiness tests.

A direct main hotfix was attempted after qualification and refused by GH013 (changes must be made through a pull request); no bypass was used.

Evidence

  • Landed through native guarded merge: exact head 78d6474dad01ff081ae2e5a1b0a687a3b5b4c0b7 passed hosted CI 35547821032. Native review, hosted preparation, and merge completed; merge 93d69d5a747432362027bbdf71eb06c96aac6eb6 is on current main. All three landed files equal the reviewed head, both human coauthors are preserved, issue Shared read mocks survive SQLite test lifecycle retirement #154205 is closed, and the retained native receipt is complete.
  • Native fail-before/pass-after: the third reader generation throws Unexpected workspace state snapshot result before the mapping; all five ordered fixture files pass afterward.
  • 20/20 independent regression invocations pass, 77s total. One complete local invocation is 3.01s wall (2.26s Vitest, including 1.93s native child proof); no new wait budget or persistent worker pin.
  • Blacksmith Testbox proof, lease tbx_01m30n55w5nbc83bvbvy3vh710: original 218-file failing cohort passes 3/3 runs; each has 216 passed files / 2 skipped, 2,841 passed cases / 16 skipped. Vitest walls: 114.36s, 103.07s, 104.02s. Existing runner/lifecycle siblings also pass (two files, three outer cases; 15.44s command wall). Command exit 0; lease readback confirms completed.
  • The trusted source capsule binds the synchronized checkout; all three modified source hashes were asserted remotely before execution.
  • Targeted check-changed passes root test types, lint, formatting, dead exports and guards. Fresh isolated P1 review has no actionable findings; git diff --check passes.
  • No production/config/schema/retention/permission changes.

Worked on by

Work sessions


View the OpenClaw team session

Retire the shared state-read worker singleton with its state database lifecycle after drain. Otherwise a new file can reuse a pool whose cleanup callback belongs to a retired lifecycle and leak a mocked fleet reply into real workspace snapshots.

Extend the native ordered lifecycle regression with three reader generations. It reproduces the exact workspace snapshot failure before the mapping and passes afterward; 20 standalone qualification runs pass. Production behavior and persistent state are unchanged.

Co-authored-by: steipete <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
@clawsweeper

clawsweeper Bot commented Sep 21, 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 size: S maintainer Maintainer-authored PR labels Sep 21, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review September 21, 2026 00:28
@roboclaw-bot roboclaw-bot self-assigned this Sep 21, 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 21, 2026
@clawsweeper

clawsweeper Bot commented Sep 21, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 20, 2026, 8:39 PM ET / September 21, 2026, 00:39 UTC.

ClawSweeper review

What this changes

Retires shared database read pools between test files and extends the ordered regression to catch mocked replies leaking into workspace reads.

Merge readiness

✅ Ready for maintainer review

The repair remains necessary on current main. The patch fixes the test lifecycle owner without weakening downstream assertions, and no actionable correctness or security finding was identified.

Priority: P2
Reviewed head: 78d6474dad01ff081ae2e5a1b0a687a3b5b4c0b7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-level repair with meaningful ordered regression coverage and no identified blocking defect.
Proof confidence 🌊 off-meta tidepool Not applicable: The ordinary contributor proof gate does not apply to this bot-authored internal repair. The native regression exercises the actual test runner and shared-read owner with a mocked transport; reported cohort qualification is supplemental, with linked logs inaccessible to this reviewer.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The ordinary contributor proof gate does not apply to this bot-authored internal repair. The native regression exercises the actual test runner and shared-read owner with a mocked transport; reported cohort qualification is supplemental, with linked logs inaccessible to this reviewer.
Evidence reviewed 7 items Pinned introduced change: The merge-base-to-head diff adds the read-pool singleton to the existing retirement map and extends the existing native regression. It introduces no production, dependency, permission, schema, or workflow changes.
Source-supported lifecycle defect: The read pool registers database cleanup callbacks only inside its singleton initializer. Retaining that singleton while retiring its database lifecycle prevents subsequent generations from registering their cleanup owner. The existing runner drains singleton resources before deleting evaluated publications.
Current-main necessity and release check: Fetched main still omits the read-pool retirement mapping. The lifecycle helper does not exist at the supplied latest-release commit, so no shipped implementation of this repair was established.
Findings None None.
Security None None.

How this fits together

OpenClaw’s shared Vitest workers reuse a process across test files. Their teardown must drain database resources and retire cached owners so each subsequent file receives its own transport and cleanup callbacks.

flowchart TD
 A[Test file reads shared state] --> B[Shared read pool]
 B --> C[Database lifecycle callbacks]
 C --> D[Drain resources after file]
 D --> E[Retire pool and lifecycle]
 E --> F[Next file creates fresh owners]
 F --> G[Workspace read receives matching reply]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +64. Total +64 across 3 files.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 3 69 5 +64
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 3 69 5 +64

Review metrics

Metric Value Why it matters
Regression execution cost Reported 3.01s wall; 1.93s native child The cross-file regression reuses one existing child invocation and stays within the documented test-time target.

Technical review

Best possible solution:

Keep read-pool retirement within the existing drain-before-retire lifecycle and preserve the ordered consumer regression.

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

Yes, source establishes the three-generation failure path: retire the database lifecycle, reuse the surviving read singleton, then request a workspace snapshot through the preceding mocked pool. The reported failing regression was not rerun here.

Is this the best way to solve the issue?

Yes. Extending the existing retirement map fixes the owner mismatch without changing production reads, suppressing errors, or adding another cleanup mechanism.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2969f4becc06.

Labels

Label changes:

  • add P2: This is a bounded test-infrastructure defect with no production behavior change.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The ordinary contributor proof gate does not apply to this bot-authored internal repair. The native regression exercises the actual test runner and shared-read owner with a mocked transport; reported cohort qualification is supplemental, with linked logs inaccessible to this reviewer.

Label justifications:

  • P2: This is a bounded test-infrastructure defect with no production behavior change.
  • 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 ordinary contributor proof gate does not apply to this bot-authored internal repair. The native regression exercises the actual test runner and shared-read owner with a mocked transport; reported cohort qualification is supplemental, with linked logs inaccessible to this reviewer.

Evidence

What I checked:

  • Pinned introduced change: The merge-base-to-head diff adds the read-pool singleton to the existing retirement map and extends the existing native regression. It introduces no production, dependency, permission, schema, or workflow changes. (test/sqlite-test-lifecycle.ts:19, 78d6474dad01)
  • Source-supported lifecycle defect: The read pool registers database cleanup callbacks only inside its singleton initializer. Retaining that singleton while retiring its database lifecycle prevents subsequent generations from registering their cleanup owner. The existing runner drains singleton resources before deleting evaluated publications. (src/state/openclaw-state-read-worker.ts:36, 78d6474dad01)
  • Current-main necessity and release check: Fetched main still omits the read-pool retirement mapping. The lifecycle helper does not exist at the supplied latest-release commit, so no shipped implementation of this repair was established. (test/sqlite-test-lifecycle.ts:18, 2969f4becc06)
  • Behavioral regression coverage: Three sequential reader generations exercise the real shared-read owner and workspace snapshot consumer with controlled transport replies. The last generation checks both prior pool closures and its own reply; the existing child-process fixture and worker pin are reused. (test/non-isolated-runner.sqlite-fixtures.ts:169, 78d6474dad01)
  • Reported qualification and inspection limits: The captured PR body reports fail-before/pass-after behavior, 20 standalone passes, three original-cohort passes, and sibling validation. The linked Testbox carrier run reports cancelled; its job-log redirect was blocked by the review host’s network allowlist, so the detailed execution results were not independently inspected. This is a reviewer limitation, not evidence that the reported tests failed. No tests were executed during this read-only review.
  • Relevant merged history: History identifies Peter Steinberger’s prior work on the lifecycle retirement map and runner. The raw commit records parent 3ec1caf; inspection of that parent confirms the helper was absent. (test/sqlite-test-lifecycle.ts:18, 33f18c3dc131)

Likely related people:

  • Peter Steinberger: Raw commit 33f18c3 adds test/sqlite-test-lifecycle.ts:18 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 33f18c3dc131; files: test/sqlite-test-lifecycle.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.

@roboclaw-bot
roboclaw-bot merged commit 93d69d5 into main Sep 21, 2026
185 checks passed
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

@roboclaw-bot
roboclaw-bot deleted the openclaw/fix-shared-read-test-generation branch September 21, 2026 00:47
roboclaw-bot added a commit that referenced this pull request Sep 21, 2026
Incorporate the owning fix from #154206 before revalidating #154192.

Co-authored-by: steipete <[email protected]>
steipete added a commit that referenced this pull request Sep 21, 2026
Merge main 5941d99 with the landed shared read-pool retirement fix from
PR #154206. Preserve the external rebase ancestry, selected-agent reader
behavior, all reader postimages, and the unchanged extraction patch.

Qualify the material shared tab-strip integration with 49 focused tests,
UI production types, current browser close/reopen flow, fresh P2 review,
and the paired startup budget at 364652 gzip bytes without budget changes.
Earlier reader-suite proof remains bound to its qualified source revision.
@steipete

Copy link
Copy Markdown
Contributor

Supplemental F50 verification for main run 35546216851, head aa5c648ca793aeb940955100febf148533e837f0, job 106172913100 (checks-node-compact-large-5, core-unit-src-security-3).

The original 218-file cohort reproduced all three readiness failures on Linux with the retirement mapping removed: 215 passed files, 1 failed, 2 skipped; 2,838 passed cases, 3 failed, 16 skipped. The readiness file passed alone before the fix. Diagnostic-only logging captured this exact reply for every failed snapshot request:

{"ok":true,"type":"fleet.list","sourceAdmitted":true,"cells":[]}

The error-mapping fixture reported completion shortly before the readiness failures, as in the original log; the logs do not record per-worker dispatch. The captured reply and the deterministic three-generation regression establish that the surviving read-pool singleton retained a mock whose cleanup callback belonged to a retired state-database lifecycle. The native three-generation regression also failed before the mapping with the same snapshot exception.

After restoring the fix:

  • The native ordered regression passed (3.31 s command wall), along with 63 sibling cases across five files.
  • src/claws/update-plan-readiness.test.ts passed 20/20 fresh invocations, 60/60 cases, at OPENCLAW_VITEST_MAX_WORKERS=8; total wall 162.18 s, median 8.20 s per invocation.
  • node scripts/check-changed.mjs, oxfmt --check, git diff --check, and explicit type-aware Oxlint passed. The canary was correctly rejected by typescript/no-floating-promises.
  • Independent P0–P2 review of landed commit 93d69d5a747432362027bbdf71eb06c96aac6eb6 returned no actionable findings.

Proof used Blacksmith Testbox, lease tbx_01m30s2jc984gmvyap7cemkwwa, run 35550843658, Node 24.19.0. The supplemental replay used base 21688de06dae3c44fdff7b3eaa54a6a889eb460b with all three fix files verified byte-identical to the landed commit before and after execution; the PR's existing evidence supplies the three passing post-fix cohort runs and exact-head hosted CI. The final validation command exited 0, and the lease is stopped/completed.

An initial lease expired during local source staging before tests began. An auxiliary ordering probe used an unsupported Vitest CLI sequencer option and ran no tests; the permanent native ordered regression supplied that proof. Neither was counted as a test result. Diagnostic logging was removed, and the production snapshot guard, timeouts, and retry behavior were unchanged.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 21, 2026
Retire the shared state-read worker singleton with its state database lifecycle after drain. Otherwise a new file can reuse a pool whose cleanup callback belongs to a retired lifecycle and leak a mocked fleet reply into real workspace snapshots.

Extend the native ordered lifecycle regression with three reader generations. It reproduces the exact workspace snapshot failure before the mapping and passes afterward; 20 standalone qualification runs pass. Production behavior and persistent state are unchanged.

Co-authored-by: steipete <[email protected]>
Co-authored-by: fuller-stack-dev <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. 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.

Shared read mocks survive SQLite test lifecycle retirement

2 participants