Skip to content

test(workers): reuse launcher readers across cases - #168964

Merged
steipete merged 2 commits into
mainfrom
test/nodew-r4-launcher-readers
Oct 11, 2026
Merged

steipete merged 2 commits into
mainfrom
test/nodew-r4-launcher-readers

Conversation

@steipete

@steipete steipete commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

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. 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 in src/web-search/runtime.test.ts and src/infra/agent-run-terminal-writes.ts on exact base 90f04bfb10df with 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

@clawsweeper

clawsweeper Bot commented Oct 11, 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 gateway Gateway runtime size: S labels Oct 11, 2026
@clawsweeper clawsweeper Bot added P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@steipete
steipete marked this pull request as ready for review October 11, 2026 07:14
@clawsweeper

clawsweeper Bot commented Oct 11, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR reuses database reader workers between test cases and shuts them down at suite teardown.

Example: Running the worker-turn launcher test suite

  • Before: Each case closes the reader pool, so subsequent cases restart its workers.
  • After: Each case closes its database resources while retaining readers until suite teardown.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The patch is focused and source-consistent; performance evidence remains author-reported and final CI is incomplete.
Proof confidence 🦐 gold shrimp (3/6) This test-only PR changes fixture lifecycle rather than shipped behavior; paired suite results are reported, and current-head CI is pending.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
User problem: Developers wait for repeated reader-worker startup during launcher tests.
Reason: The patch extends an owner-established optimization without changing assertions or production behavior.

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
Reviewed head: 3ab731b7f23dfcc9f92b52f80543c439addd97cb

Before merge

None.

Findings

None.

Agent review details

How this fits together

Gateway 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
Loading

Technical review

Best 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

  • Reader reuse and cleanup ownership keeps the original intent (24150a2: Retain reader processes between cases while closing each case's database resources, as verified in the predecessor's body and commit patch.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Tests +60. Total +60 across 16 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 16 93 33 +60
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 93 33 +60

Review metrics

Metric Value Why it matters
Production versus test LOC Production +0; tests +93/−33. Growth supplies cleanup hooks without adding cases or production seams.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P3: This improves developer test feedback without changing shipped behavior.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/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.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only; repair and merge need explicit maintainer commands such as @clawsweeper autofix or @clawsweeper automerge.

History

Review history (3 earlier review cycles)
  • reviewed 2026-10-11T07:13:50.114Z sha 06aab01 :: needs changes before merge. :: none
  • reviewed 2026-10-11T07:21:04.821Z sha 06aab01 :: needs maintainer review before merge. :: none
  • reviewed 2026-10-11T08:12:35.571Z sha 06aab01 :: needs changes before merge. :: none

Reviewed October 11, 2026, 4:37 AM ET / 08:37 UTC (Revision 4).

@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 11, 2026
…r-readers

# Conflicts:
#	src/gateway/worker-environments/worker-turn-launcher-remote-handoff.test.ts
@clawsweeper clawsweeper Bot added status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Oct 11, 2026
@steipete
steipete merged commit 89c406e into main Oct 11, 2026
117 of 119 checks passed
@steipete
steipete deleted the test/nodew-r4-launcher-readers branch October 11, 2026 08:59
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
## 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>
scribe-dandelion-cult added a commit to karmaterminal/openclaw that referenced this pull request Oct 18, 2026
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]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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