Skip to content

fix(qa): stop shutdown from leaving bus poll timers - #124463

Merged
steipete merged 3 commits into
mainfrom
fix/autoqa-qa-bus-lifecycle-v2
Aug 16, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/autoqa-qa-bus-lifecycle-v2

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where source-checkout QA runs could leave pending QA bus long-poll waiters and timers alive when the standalone bus or combined QA Lab server stopped. That could delay process exit and leave lifecycle state beyond the scenario that owned it.

Why This Change Was Made

The combined lab still completes embedded Gateway shutdown before touching the shared HTTP bus. The HTTP server now fences new requests first, then terminally resets the bus waiter owner so active polls settle and already-admitted late request bodies cannot register a new timer. The standalone bus uses the same terminal shutdown path; ordinary scenario resets remain reusable.

Production code is net +7 lines. No changelog entry is needed because QA Lab and QA Channel are private, source-checkout-only surfaces.

User Impact

QA operators get deterministic shutdown, restart, and scenario isolation without lingering poll timers, handler work, state, or ports. Standard builds and published packages remain unchanged and continue to omit QA Lab and QA Channel.

Evidence

  • Pre-fix negative controls failed for both combined-lab shutdown and a standalone delayed-body poll: the waiter remained unsettled after stop (standalone stop completed in about 307 ms).
  • The fixed standalone probe completed in about 252 ms with the late waiter settled; the combined Gateway-before-bus ordering regression also passed.
  • Focused lifecycle and isolation gate: 8 files, 118 tests passed. An additional 7 parity-cleanup tests also passed.
  • Blacksmith Testbox tbx_01m04p2nzfqdf51x2v0h1t8sdg / run https://github.com/openclaw/openclaw/actions/runs/31932900181: private-QA build passed; source-checkout self-check passed 1 scenario, 3/3 steps, 8 events, zero failures; standard build omitted QA Lab/QA Channel; scoped check:changed passed assertion-safety, types, lint, formatting, plugin boundaries, dead exports, database-first guards, and import cycles.
  • Fresh whole-branch autoreview reported no accepted or actionable findings.
  • Duplicate search found no competing QA Lab bus shutdown issue or pull request.

@clawsweeper

clawsweeper Bot commented Aug 16, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

@steipete
steipete marked this pull request as ready for review August 16, 2026 07:17
@steipete steipete self-assigned this Aug 16, 2026
@clawsweeper clawsweeper Bot added merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. P2 Normal backlog priority with limited blast radius. 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 Aug 16, 2026
@clawsweeper

clawsweeper Bot commented Aug 16, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 16, 2026, 3:39 AM ET / 07:39 UTC.

ClawSweeper review

What this changes

The PR makes QA Lab shutdown settle pending long polls and reject late poll or write activity after the server begins stopping.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

No blocking findings. The final head resolves the prior late-write concern by fencing mutations at the shared QA bus state owner; keep this maintainer-authored PR open for exact-head CI and normal review.

Priority: P2
Reviewed head: 95163cb90a0f6a64d24944d3b7b228e520a27f65

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is a focused owner-boundary repair with targeted delayed-request coverage and no remaining actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This maintainer-authored PR reports focused source-checkout and Testbox behavior evidence; the external-contributor proof gate does not apply.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This maintainer-authored PR reports focused source-checkout and Testbox behavior evidence; the external-contributor proof gate does not apply.
Evidence reviewed 6 items Current-main behavior: Current main closes HTTP connections but does not pass the bus state into the close path, leaving the state reusable while admitted requests can finish their bodies.
Owner-boundary repair: The PR head makes terminal reset reject new snapshots and state mutations; message creation, existing-message mutation, thread creation, and poll-cursor registration all cross that owner boundary.
Delayed-request coverage: The standalone and combined-lab tests hold a poll and an inbound request body open across shutdown, then assert the waiter settles and no messages or events survive.
Findings None None.
Security None None.

How this fits together

QA Lab is a source-checkout testing environment whose HTTP bus receives test messages and long-poll requests. Shutdown must retain the bus through embedded Gateway shutdown, then terminate waiter and mutation ownership before connections finish.

flowchart LR
  A[QA scenario] --> B[QA Lab HTTP bus]
  B --> C[Bus state owner]
  C --> D[Long-poll waiters]
  B --> E[Inbound message writes]
  F[Server shutdown] --> G[Terminal shutdown fence]
  G --> C
  G --> D
  G --> E
Loading

Before merge

  • Resolve merge risk (P1) - Production code is net +13 lines; the growth is justified by a terminal state-owner fence that closing HTTP sockets alone cannot provide.
  • Resolve merge risk (P1) - Shared QA bus state now becomes permanently terminal during server stop, so the remaining exact-head QA lifecycle checks should finish before merge.
  • Complete next step (P2) - This maintainer-authored PR is protected from automated cleanup and only needs normal exact-head CI completion and maintainer handling.
Agent review details

Security

None.

PR surface

Source +13, Tests +106. Total +119 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 4 24 11 +13
Tests 2 109 3 +106
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 133 14 +119

Review metrics

Metric Value Why it matters
Production versus test delta production +24/-11, tests +109/-3 The source increase implements the terminal owner-state fence; the test increase exercises delayed poll and delayed write shutdown paths.

Stored data model

Persistent data-model change detected: serialized state: extensions/qa-lab/src/bus-server.test.ts, serialized state: extensions/qa-lab/src/lab-server.test.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Land after QA lifecycle verification (recommended)
    Accept the bounded source-checkout QA state change once the remaining exact-head checks are green.

Technical review

Best possible solution:

Keep one terminal shutdown path that first preserves the embedded Gateway ordering, then fences the QA bus owner; the small production increase is warranted because every delayed mutation and waiter must share that owner boundary.

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

Yes, by source. Current main closes the HTTP server without terminally closing the bus owner, while the PR's delayed-body tests directly cover the pending poll and late-write race.

Is this the best way to solve the issue?

Yes. Fencing at the state owner is the narrowest canonical repair because both standalone HTTP requests and combined-lab routes use that owner; socket-only cleanup leaves admitted handlers outside the invariant.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • 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: This maintainer-authored PR reports focused source-checkout and Testbox behavior evidence; the external-contributor proof gate does not apply.
  • remove rating: 🦐 gold shrimp: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: The defect affects QA Lab source-checkout lifecycle isolation rather than the published runtime.
  • merge-risk: 🚨 session-state: The PR changes terminal semantics for the shared in-memory bus state and its long-poll waiters.
  • 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: This maintainer-authored PR reports focused source-checkout and Testbox behavior evidence; the external-contributor proof gate does not apply.

Evidence

What I checked:

  • Current-main behavior: Current main closes HTTP connections but does not pass the bus state into the close path, leaving the state reusable while admitted requests can finish their bodies. (extensions/qa-lab/src/bus-server.ts:290, a2e27de59344)
  • Owner-boundary repair: The PR head makes terminal reset reject new snapshots and state mutations; message creation, existing-message mutation, thread creation, and poll-cursor registration all cross that owner boundary. (extensions/qa-lab/src/bus-state.ts:89, 95163cb90a0f)
  • Delayed-request coverage: The standalone and combined-lab tests hold a poll and an inbound request body open across shutdown, then assert the waiter settles and no messages or events survive. (extensions/qa-lab/src/bus-server.test.ts:115, 95163cb90a0f)
  • Prior finding addressed: The final commit adds the missing state-owner write fence identified in the previous review cycle, rather than only rejecting waiter snapshots. (extensions/qa-lab/src/bus-state.ts:126, 95163cb90a0f)
  • Feature provenance: Current main's bus-state and lab-stop implementation lines blame to the recent QA Lab lifecycle work, making its author the strongest routing contact. (extensions/qa-lab/src/bus-state.ts:82, a6cb2fbc9f8c)
  • Current-main-only check: The PR head is not an ancestor of current main, so this remains a needed open repair rather than an implementation already present on main. (95163cb90a0f)

Likely related people:

  • steipete: The current QA bus state and combined-lab shutdown path both trace to Peter Steinberger's recent lifecycle implementation, and this PR continues that work. (role: feature owner and recent area contributor; confidence: high; commits: a6cb2fbc9f8c, 95163cb90a0f; files: extensions/qa-lab/src/bus-state.ts, extensions/qa-lab/src/bus-server.ts, extensions/qa-lab/src/lab-server.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Wait for the remaining exact-head QA and build checks to complete successfully.

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-16T07:23:53.508Z sha 8bfe42b :: found issues before merge. :: [P2] Fence terminal state against late writes

@clawsweeper clawsweeper Bot added 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. and removed 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 Aug 16, 2026
@steipete
steipete merged commit c1622d0 into main Aug 16, 2026
120 checks passed
@steipete
steipete deleted the fix/autoqa-qa-bus-lifecycle-v2 branch August 16, 2026 12:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 17, 2026
* fix(qa): settle bus polls during shutdown

* fix(qa): fence late bus waiters during shutdown

* fix(qa): reject writes after bus shutdown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

extensions: qa-lab maintainer Maintainer-authored PR merge-risk: 🚨 session-state 🚨 May lose, corrupt, stale, or mis-associate session, agent, or context state. 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.

1 participant