Repository navigation
test(workers): reuse launcher readers across cases - #168964
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs maintainer review before merge. What this changesThis PR reuses database reader workers between test cases and shuts them down at suite teardown. Example: Running the worker-turn launcher test suite
Review scores
ProductKind: Test only · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR is a useful test-performance improvement with no actionable findings; it preserves case isolation and resolves the previously reported conflict. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherGateway worker tests use isolated state roots and a shared launcher fixture whose database lifecycle owner drains resources and retires reader workers. flowchart TD
A[Test case] --> B[Isolated state root]
B --> C[Launcher fixture]
C --> D[Per-case resource closure]
D --> E[Retained reader workers]
F[Suite teardown] --> E
Technical reviewBest possible solution: Use the existing fixture option while preserving per-case drains, isolated state roots, and suite-level reader shutdown. Do we have a high-confidence way to reproduce the issue? Source confirms that main closes reader workers after each case; the reported performance improvement was not independently measured here. Is this the best way to solve the issue? The patch applies an established fixture capability and preserves its cleanup owner, avoiding new lifecycle machinery or reduced coverage. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 90f04bfb10df. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceTests +60. Total +60 across 16 files. Added test files: 0. View PR surface stats
Review metrics
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (3 earlier review cycles)Reviewed October 11, 2026, 4:37 AM ET / 08:37 UTC (Revision 4). |
…r-readers # Conflicts: # src/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.ts
## What Problem This Solves Launcher tests repeatedly stop and restart the same database reader workers between cases, adding seconds to each case despite using independent state roots. ## User Impact Faster node/worker test feedback, with the same behavioral coverage and per-case database isolation. No production behavior changes. ## Why This Change Was Made Sixteen launcher, execution, detached-context, transcript-admission, and run-owner suites now opt into the fixture's existing reader-reuse mode. Each case still drains its work and closes its database resources before removing its state; the existing database cleanup owner stops the retained pool after the suite. Detached-context keeps its unjoined-owner guard in both cleanup phases. The terminal-results suite's extra state root, lazy/module-reset tests, and import-boundary tests retain their existing isolation. No assertions, test cases, timeouts, retries, worker settings, production seams, or dependencies change. Production LOC delta: **0**. Sixteen test files, +93/−33 lines. ## Evidence The same 290-test command runs before and after on one AWS machine, with `--maxWorkers=1` and Vitest JSON reporting. Both revisions use the corrected Node test environment from main; the earlier jsdom-contaminated baseline is excluded from the speed comparison. | Command wall | Before | After | Saved | |---|---:|---:|---:| | 290 tests, one worker | 1,755.032 s | 1,089.346 s | 665.686 s / 37.93% | | Summed Vitest file execution | 1,717.203 s | 1,054.089 s | 663.115 s / 38.62% | Both runs passed all 290 tests on AWS `cbx_77c6df7bbddc`, Node 24.19.0. [Paired run](https://crabbox.openclaw.ai/portal/runs/run_71809623ad760587e2a081422f8a6e5c). Independent review has no actionable P0/P1 findings. The tested candidate matches the committed files after repository import formatting. [Final source/static validation](https://crabbox.openclaw.ai/portal/runs/run_f86a2ec39ad898ca0e5ffe33907a437e) passed check:changed, type-aware lint, Knip exports, and export-name collisions. [Pre-integration CI](https://github.com/openclaw/openclaw/actions/runs/38120713206) passed: 489 s elapsed CI wall and 1,082 summed Node-job seconds. [Current-head CI](https://github.com/openclaw/openclaw/actions/runs/38125109973) also passed after preserving main’s remote-handoff regression from openclaw#168946. The timing comparison is pinned to the pre-integration base. Post-integration, both handoff tests passed in 163.877 s; type-aware lint and export-name collisions passed. Full-tree max-lines and Knip checks reproduce two unrelated base failures in `src/web-search/runtime.test.ts` and `src/infra/agent-run-terminal-writes.ts` on exact base `587f0b81b1ce` with unchanged source blobs; no baseline was changed. [Base qualification](https://crabbox.openclaw.ai/portal/runs/run_9922dda00b9c648692a436c8091ac52f). <details> <summary>Exact timed command</summary> ```sh pnpm test \ src/gateway/worker-environments/worker-turn-launcher.test.ts \ src/gateway/worker-environments/worker-turn-launcher-computer.test.ts \ src/gateway/worker-environments/worker-turn-launcher-claim-admission.test.ts \ src/gateway/worker-environments/worker-turn-launcher-initial-setup.test.ts \ src/gateway/worker-environments/worker-turn-launcher-failure-recovery.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reconcile-error.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reconciliation-authority.test.ts \ src/gateway/worker-environments/worker-turn-launcher-media.test.ts \ src/gateway/worker-environments/worker-turn-launcher-build-recovery.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reclaimed-placement.test.ts \ src/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.ts \ src/gateway/worker-environments/worker-turn-launcher.claim-recovery.test.ts \ src/gateway/worker-environments/worker-turn-execution.test.ts \ src/gateway/worker-environments/worker-turn-detached-context.test.ts \ src/gateway/worker-environments/cloud-transcript-write-admission.test.ts \ src/gateway/worker-environments/worker-turn-run-owner.test.ts \ --maxWorkers=1 --reporter=verbose --reporter=json --outputFile=/tmp/launcher.json ``` </details>
First-parent upstream c96fac1..d9eba8a (10 PRs: openclaw#168948 GitHub connection authority to workers, openclaw#168975, openclaw#168772 cron receipt custody removal, openclaw#169012, openclaw#169006, openclaw#169009, openclaw#168283 test batch d042, openclaw#168994, openclaw#168964, openclaw#168855 approval/placement state in workers). Conflicts: - docs/reference/database-schemas/worker-access-inventory.md: took upstream, then regenerated (db:worker-inventory:gen, 633 files / 2449 calls) instead of hand-merging. - src/agents/embedded-agent-runner/compact-reasons.test.ts: upstream openclaw#168283 deleted low-value cases; kept upstream's file plus our own additions only (unknown_model, empty reason, closed-union check and the isCompactionSkipCode block). session-reset-service.ts auto-merged: upstream's awaited placement retirement (assertCurrent) is disjoint from our continuation-cancellation cleanup reason. Refs #1475 Co-Authored-By: Claude Opus 5.5 <[email protected]>
What Problem This Solves
Launcher tests repeatedly stop and restart the same database reader workers between cases, adding seconds to each case despite using independent state roots.
User Impact
Faster node/worker test feedback, with the same behavioral coverage and per-case database isolation. No production behavior changes.
Why This Change Was Made
Sixteen launcher, execution, detached-context, transcript-admission, and run-owner suites now opt into the fixture's existing reader-reuse mode. Each case still drains its work and closes its database resources before removing its state; the existing database cleanup owner stops the retained pool after the suite. Detached-context keeps its unjoined-owner guard in both cleanup phases.
The terminal-results suite's extra state root, lazy/module-reset tests, and import-boundary tests retain their existing isolation. No assertions, test cases, timeouts, retries, worker settings, production seams, or dependencies change.
Production LOC delta: 0. Sixteen test files, +93/−33 lines.
Evidence
The same 290-test command runs before and after on one AWS machine, with
--maxWorkers=1and Vitest JSON reporting. Both revisions use the corrected Node test environment from main; the earlier jsdom-contaminated baseline is excluded from the speed comparison.Both runs passed all 290 tests on AWS
cbx_77c6df7bbddc, Node 24.19.0. Paired run. Independent review has no actionable P0/P1 findings. The tested candidate matches the committed files after repository import formatting. Final source/static validation passed check:changed, type-aware lint, Knip exports, and export-name collisions. Pre-integration CI passed: 489 s elapsed CI wall and 1,082 summed Node-job seconds. Current-head CI also passed after preserving main’s remote-handoff regression from #168946. The timing comparison is pinned to the pre-integration base. Post-integration, both handoff tests passed in 163.877 s; type-aware lint and export-name collisions passed. Full-tree max-lines and Knip checks reproduce two unrelated base failures insrc/web-search/runtime.test.tsandsrc/infra/agent-run-terminal-writes.tson exact base90f04bfb10dfwith unchanged source blobs; no baseline was changed. Base qualification.Exact timed command
pnpm test \ src/gateway/worker-environments/worker-turn-launcher.test.ts \ src/gateway/worker-environments/worker-turn-launcher-computer.test.ts \ src/gateway/worker-environments/worker-turn-launcher-claim-admission.test.ts \ src/gateway/worker-environments/worker-turn-launcher-initial-setup.test.ts \ src/gateway/worker-environments/worker-turn-launcher-failure-recovery.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reconcile-error.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reconciliation-authority.test.ts \ src/gateway/worker-environments/worker-turn-launcher-media.test.ts \ src/gateway/worker-environments/worker-turn-launcher-build-recovery.test.ts \ src/gateway/worker-environments/worker-turn-launcher-reclaimed-placement.test.ts \ src/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.ts \ src/gateway/worker-environments/worker-turn-launcher.claim-recovery.test.ts \ src/gateway/worker-environments/worker-turn-execution.test.ts \ src/gateway/worker-environments/worker-turn-detached-context.test.ts \ src/gateway/worker-environments/cloud-transcript-write-admission.test.ts \ src/gateway/worker-environments/worker-turn-run-owner.test.ts \ --maxWorkers=1 --reporter=verbose --reporter=json --outputFile=/tmp/launcher.json