Skip to content

fix(gateway): isolate startup sidecars between test cases - #120503

Merged
vincentkoc merged 3 commits into
mainfrom
fix/startup-sidecar-test-cleanup-20260808
Aug 8, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
fix/startup-sidecar-test-cleanup-20260808

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Aug 8, 2026 •

Copy link
Copy Markdown
Member

Related history:

What Problem This Solves

Fixes an order-dependent failure in src/gateway/server-startup-post-attach.test.ts where startup sidecars could outlive their test case and fire after a later case had installed fake timers or reset shared mocks.

Why This Change Was Made

The fixture tracked published sidecars but did not model ownership transfer. Tests that manually stopped a handle left it registered for teardown, and a transferred handle could be reacquired when the production publisher emitted it again. Direct startGatewaySidecars() results also bypassed fixture tracking.

This test-only repair:

  • tracks gateway-lifetime and post-ready handles separately;
  • adopts direct startGatewaySidecars() results;
  • transfers ownership before every manual stop;
  • tombstones transferred handles so republishing cannot reacquire them;
  • drains every tracked handle during teardown, resets fixture state even after a stop failure, then rethrows the first cleanup error;
  • adds one-shot republish and drain-after-failure regressions.

Owner boundary: the repair is entirely in the startup test fixture. Production startup and shutdown behavior are unchanged.

Diff classification:

  • Production: +0/-0
  • Tests: +211/-44
  • Runtime behavior change: none

User Impact

No runtime or operator-visible behavior changes. Maintainers get deterministic startup test isolation without weakening timing or lifecycle assertions.

Evidence

Exact identities:

  • Merge base: ea50fe84538e8f4f91ef211d2e54bb16b3bb17c8
  • Head: 07cebf272fe42543348105ec5f9965030fdc3b1a
  • Tree: 70c47ec26490c9347b5be46e326101f444c5bec3
  • Current main at refresh: 295c8dfe6eb7522eb905e31114362d24bf2392b5
  • Signed CI correction commit: 07cebf272fe42543348105ec5f9965030fdc3b1a
  • Commit attestation: att_01KZGQ417GEE38HNXZRP89Q04H
  • PR attestation: att_01KZGQXTHX3CBNMV2ARMKQDF2A
  • Session marker: Punchcard-Session: amber-workshop-workshop-36

Focused validation on Node v26.7.0:

  • node scripts/run-vitest.mjs src/gateway/server-startup-post-attach.test.ts: 71/71 passed
  • node scripts/run-tsgo.mjs -p test/tsconfig/tsconfig.core.test.json --incremental --tsBuildInfoFile .artifacts/tsgo-cache/core-test-pr120503.tsbuildinfo
  • node scripts/run-oxlint.mjs --type-aware src/gateway/server-startup-post-attach.test.ts
  • pnpm exec oxfmt --check src/gateway/server-startup-post-attach.test.ts
  • git diff --check
  • branch autoreview against origin/main: clean, no findings, 0.99 confidence

Hosted evidence:

  • Exact-head CI run 31258105170 on 4562051f93c2 exposed only two fixture-local defects: Vitest reset callbacks returned VitestUtils, and teardown could rethrow a non-Error value.
  • Head 07cebf272fe4 fixes only those diagnosed lines with void-returning blocks and first-error normalization. Exact-head CI run 31258426709 completed successfully with no failed jobs.

Current-main overlap:

  • No commit from the merge base through current origin/main changes src/gateway/server-startup-post-attach.test.ts.
  • GitHub reports the exact head mergeable; hosted exact-head CI and ClawSweeper re-review remain the landing gates.

No changelog entry: this is test-only and has no user-visible or runtime behavior change.

AI Assistance

The exact branch received independent audit, plan review, implementation review, focused validation, and branch-wide autoreview. All reported evidence above was verified on the exact head.

Punchcard-Session: amber-workshop-workshop-36
@vincentkoc vincentkoc self-assigned this Aug 8, 2026
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime size: S maintainer Maintainer-authored PR labels Aug 8, 2026
@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. P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. labels Aug 8, 2026
@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 8, 2026, 9:43 AM ET / 13:43 UTC.

ClawSweeper review

What this changes

The PR updates the Gateway startup test fixture to track, transfer, tombstone, and drain sidecar stop handles between test cases.

Regression provenance

Possible regression — probable (reviewed change; failure trace). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This maintainer-authored, protected PR remains necessary: current main retains the untracked sidecar-handle fixture paths, while the branch repairs them without changing production behavior. No blocking findings were identified; it needs ordinary human landing judgment.

Priority: P3
Reviewed head: 07cebf272fe42543348105ec5f9965030fdc3b1a
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused, production-neutral test repair with strong lifecycle coverage and no remaining actionable finding.
Proof confidence 🌊 off-meta tidepool Not applicable: This member-authored test-only PR has no user-visible runtime change; focused fixture regression coverage and exact-head CI are the relevant proof.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: This member-authored test-only PR has no user-visible runtime change; focused fixture regression coverage and exact-head CI are the relevant proof.
Evidence reviewed 6 items Current-main gap: The existing fixture resets timers and other shared state but owns no sidecar-handle collection; it also manually stops handles and directly invokes sidecar startup, leaving the order-dependent cleanup gap present on main.
Fixture ownership repair: The branch tracks publisher-delivered and direct startup handles, transfers ownership before explicit stops, and snapshots/clears tracked state before draining it so teardown does not stop a handle twice.
Production lifecycle contract: Production publishes separate gateway-lifetime and post-ready handles, while normal lifecycle cleanup clears registered collections before stopping them; the fixture mirrors that ownership boundary rather than changing runtime behavior.
Findings None None.
Security None None.

How this fits together

Gateway startup creates background sidecars and publishes stop handles to its lifecycle owner. This test fixture intercepts those handles so test-case cleanup cannot leak a sidecar into later fake-timer or mock state.

flowchart LR
  A[Gateway startup] --> B[Sidecar stop handles]
  B --> C[Test fixture tracking]
  C --> D[Ownership transfer]
  D --> E[Case teardown]
  E --> F[Isolated next case]
Loading

Decision needed

Question Recommendation
Should the Gateway owner land this test-only fixture repair, which has no remaining mechanical finding and preserves the production sidecar lifecycle contract? Land the fixture repair: Accept the exact-head test-only ownership cleanup and its focused regression coverage.

Why: The PR is authored by a repository member and carries the protected maintainer label, so ordinary human landing authority is required even though the patch is correct.

Before merge

None.

Agent review details

Security

None.

PR surface

Tests +167. Total +167 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 211 44 +167
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 211 44 +167

Review metrics

Metric Value Why it matters
Production versus test LOC production +0/-0; tests +211/-44 The added complexity is confined to test lifecycle ownership and is justified by explicit regressions for double-stop, republish, and cleanup-failure paths.

Technical review

Best possible solution:

Keep production sidecar ownership unchanged and land the fixture-only cleanup after the designated maintainer confirms the current exact head.

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

Yes, from source: current main's fixture directly starts and manually stops sidecars but teardown tracks no such handles, making the order-dependent leak path clear; this read-only review did not execute the suite.

Is this the best way to solve the issue?

Yes. Tracking ownership in the test fixture is the narrowest maintainable fix because production already owns and drains the same two sidecar classes correctly.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P3: This is bounded Gateway test-isolation maintenance with no runtime or operator-visible 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: This member-authored test-only PR has no user-visible runtime change; focused fixture regression coverage and exact-head CI are the relevant proof.

Evidence

What I checked:

Likely related people:

  • steipete: Authored the merged production sidecar-lifecycle work that established the handle model exercised by this fixture. (role: recent gateway-startup owner; confidence: high; commits: 1b8411958b4d; files: src/gateway/server-startup-post-attach.ts, src/gateway/server-lifecycle.ts)
  • fuller-stack-dev: Recent current-main work covers adjacent post-ready Gateway startup behavior and context-cache lifecycle paths. (role: adjacent post-ready startup contributor; confidence: medium; commits: 65f3e42f2433, a67ad03eea4b; files: src/gateway/server-startup-post-attach.ts)
  • vincentkoc: Has adjacent current-main Gateway work and authored this focused fixture repair. (role: recent area contributor; confidence: medium; commits: ebf121af6ab5, 07cebf272fe4; files: src/gateway/server-startup-post-attach.test.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.

History

Review history (4 earlier review cycles)
  • reviewed 2026-08-08T07:44:00.809Z sha c841012 :: needs maintainer review before merge. :: none
  • reviewed 2026-08-08T09:49:52.245Z sha c841012 :: needs changes before merge. :: [P2] Ensure test sidecars stop only once
  • reviewed 2026-08-08T11:43:18.962Z sha c841012 :: found issues before merge. :: [P2] Make fixture sidecar cleanup one-shot
  • reviewed 2026-08-08T13:37:07.906Z sha 07cebf2 :: needs maintainer review before merge. :: none

@clawsweeper clawsweeper Bot added 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. and removed 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 Aug 8, 2026
Punchcard-Session: amber-workshop-workshop-36
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Command router queued. I will update this comment with the next step.

@vincentkoc
vincentkoc marked this pull request as ready for review August 8, 2026 12:49
Punchcard-Session: amber-workshop-workshop-36
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Aug 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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 8, 2026
@vincentkoc vincentkoc changed the title test(gateway): stop startup sidecars between cases fix(gateway): isolate startup sidecars between test cases Aug 8, 2026
@vincentkoc
vincentkoc merged commit 7f9364c into main Aug 8, 2026
121 checks passed
@vincentkoc
vincentkoc deleted the fix/startup-sidecar-test-cleanup-20260808 branch August 8, 2026 14:08
@vincentkoc

Copy link
Copy Markdown
Member Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Aug 9, 2026
…20503)

* test(gateway): stop startup sidecars between cases

Punchcard-Session: amber-workshop-workshop-36

* test(gateway): make sidecar cleanup one-shot

Punchcard-Session: amber-workshop-workshop-36

* test(gateway): satisfy cleanup type contracts

Punchcard-Session: amber-workshop-workshop-36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gateway Gateway runtime maintainer Maintainer-authored PR P3 Low-priority cleanup, docs, polish, ergonomics, or speculative work. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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