Skip to content

test(gateway): retain timed-out fixture ownership - #147844

Merged
steipete merged 3 commits into
mainfrom
fix/gateway-timeout-fixture-ownership-20260914
Sep 15, 2026
Merged

steipete merged 3 commits into
mainfrom
fix/gateway-timeout-fixture-ownership-20260914

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Sep 14, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Gateway tests can keep running after Vitest times out or cancels its wrapper, leaving pending client work and racing fixture cleanup. This completes Vincent Koc's fixture-ownership repair in the existing PR and preserves his original commits.

User Impact

Internal test-only change. The actual asynchronous test body now remains owned until cancellation and cleanup settle. Gateway product behavior, existing test assertions and timeout budgets are unchanged.

Why This Change Was Made

Vitest rejects its wrapper without joining the original body. A narrow test fixture helper routes the five runtime consumers through the existing fixture lifetime, connects cancellation to acquisition/client shutdown, joins asynchronous provider handlers, and retains state when cleanup cannot be verified. Partial acquisition restores the environment synchronously before awaiting verified cleanup. The generic QA fixture and its other consumers keep their current contracts.

Bounded readiness diagnostics and startup tracing remain available for the large-catalog fixture. They do not establish the cause of the historical 60-second readiness failure. Active Memory, Concurrent Streams, Windows cron identity coverage and all 76 ordinary route requests remain intact.

Evidence

  • Original failure: run 34800333833, job 103842868389.
  • The original contributor head's controlled cancellation pair failed on its baseline and passed on the candidate. Its Actions acknowledgment missed the controller budget, so that historical operation's full closeout remains unverified.
  • Integrated commit 2164c12753af1252d45e41301c223b07bf0d87a7 preserves contributor commit 7835e6f4ee345a0fb9619adc7d7afbdf1ea7e153 as its first parent and has the exact reviewed/tested tree ffdff8b5ede8adbca76c0921d3948a7fb50d41cc.
  • The integrated source passed sanitized direct AWS proof: 115 focused tests with one Windows-only skip, the complete changed-file gate, normal build, all six ordinary built-Gateway cases and both exact controlled cancellation/sentinel cases. The source, input packet, phase records and exported proof were independently audited; the task-owned lease was subsequently confirmed released with cleanup complete.
  • Ordinary auth recovery preserved its Gateway generation. Catalog returned 4,400 rows from 400 models across 11 agents, with 11 authenticated RPCs and no upstream requests. Route reuse completed all 76 provider requests and preserved churn/reload behavior. Active Memory and both Concurrent Streams cases passed.
  • The controlled callback submitted one real models.list request, then cancellation stopped the client and closed the incomplete provider request. Its actual body remained pending until the same test released a held finalizer. Exactly one finish hook completed, with no late requests, writes or success markers; the child exited, pipes closed, and its process group and isolated state were absent without supervisor intervention. This case performed no agent turn; the ordinary flows supply separate behavior proof.
  • The first two integrated AWS attempts failed lint after focused tests passed. Their narrow test-only repairs were independently reviewed; the final run passed the complete gate. Fresh managed autoreview found no actionable issue in the final integrated source. Hosted exact-head CI and current review dispositions remain required for landing.

The integrated proof is Linux-only. Native Windows, full generated-output byte provenance, the historical readiness cause and production performance are not established by it. Two generated plugin source-capture scratch trees remained outside the controlled fixture's removed state; they were preserved before lease disposal, so this does not claim automatic cleanup of every temporary file. The existing benchmark stopChild contract still bounds return time without certifying process-group extinction.

@vincentkoc
vincentkoc requested a review from a team as a code owner September 14, 2026 03:53
@vincentkoc vincentkoc self-assigned this Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 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: XL maintainer Maintainer-authored PR labels Sep 14, 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 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 15, 2026, 10:48 AM ET / 14:48 UTC (Revision 4).

ClawSweeper review

What this changes

The PR keeps cancelled Gateway test bodies attached to their cleanup lifecycle, propagates cancellation through fixture acquisition and client requests, and adds cleanup regression coverage and bounded startup diagnostics.

Merge readiness

✅ Ready for maintainer review

The repair remains useful on current main, and no blocking defect was found in the introduced changes. Updated integrated validation addresses the previous review’s closeout concern while preserving the stated limitations of the historical run.

Priority: P2
Reviewed head: 2164c12753af1252d45e41301c223b07bf0d87a7

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent repair with meaningful boundary regressions and detailed reported runtime validation; source review found no blocking defect.
Proof confidence 🐚 platinum hermit (4/6) Not applicable: The ordinary contributor-proof gate does not apply to this MEMBER-authored test repair. The captured body reports integrated Linux Gateway cancellation, held-finalizer drainage, and resource cleanup for the changed owners; native Windows behavior and the earlier controller closeout remain outside that evidence.
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 MEMBER-authored test repair. The captured body reports integrated Linux Gateway cancellation, held-finalizer drainage, and resource cleanup for the changed owners; native Windows behavior and the earlier controller closeout remain outside that evidence.
Evidence reviewed 9 items Pinned source identity: The checkout matches the pinned original head. Its raw commit records parents 7835e6f and 80936b0, and tree ffdff8b5ede8adbca76c0921d3948a7fb50d41cc, matching the integrated tree identified in the captured PR body. The supplied stale test merge was not used to infer removals.
One existing lifetime owner: The new adapter registers fixture cleanup before scheduling the body, retains the original promise through the existing lifetime owner, and records each ordered cleanup as verified work. The existing owner drains admitted work and retains claims after failed cleanup.
Acquisition and cancellation review: Client acquisition distinguishes pending, failed, and handed-off states; cancellation joins failed acquisition cleanup and suppresses late hello callbacks while preserving reconnect callbacks after handoff. Instance acquisition checks cancellation after asynchronous preparation and records rollback failures through the same verifier.
Findings None None.
Security None None.

How this fits together

Gateway integration tests start isolated processes, clients, and synthetic providers to exercise OpenClaw. Their fixture lifecycle must finish outstanding work before releasing processes, ports, and temporary state.

flowchart TD
  A[Test starts or cancels] --> B[Fixture lifetime]
  B --> C[Gateway and client acquisition]
  C --> D[Runtime test body]
  D --> E[Ordered resource cleanup]
  E --> F{Cleanup verified}
  F -->|Yes| G[Release temporary state]
  F -->|No| H[Retain state and report failure]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +5, Tests +2135. Total +2140 across 16 files.

View PR surface stats
Area Files Added Removed Net
Source 1 5 0 +5
Tests 15 2983 848 +2135
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 16 2988 848 +2140

Review metrics

Metric Value Why it matters
Production versus test growth Production +0; test support +190 net lines; tests +1,950 net lines The growth stays in test infrastructure and regression coverage; it adds no shipped runtime or configuration surface.

Technical review

Best possible solution:

Keep cancellation, pending work, and cleanup under the existing fixture lifetime, releasing test state only after its resource owners settle.

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

Yes: the registered route-test callback and held cleanup regressions provide a concrete cancellation path, and current main lacks the corresponding lifetime wiring. This read-only review did not execute that path.

Is this the best way to solve the issue?

Yes: the adapter extends the existing lifetime owner, preserves ordinary assertions and timeout budgets, and handles partial acquisition without introducing a competing cleanup manager.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 3c34fe88c1ac.

Labels

Label justifications:

  • P2: This repairs bounded integration-test lifecycle reliability without changing user-facing Gateway behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit 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 MEMBER-authored test repair. The captured body reports integrated Linux Gateway cancellation, held-finalizer drainage, and resource cleanup for the changed owners; native Windows behavior and the earlier controller closeout remain outside that evidence.

Evidence

What I checked:

  • Pinned source identity: The checkout matches the pinned original head. Its raw commit records parents 7835e6f and 80936b0, and tree ffdff8b5ede8adbca76c0921d3948a7fb50d41cc, matching the integrated tree identified in the captured PR body. The supplied stale test merge was not used to infer removals. (2164c12753af)
  • One existing lifetime owner: The new adapter registers fixture cleanup before scheduling the body, retains the original promise through the existing lifetime owner, and records each ordered cleanup as verified work. The existing owner drains admitted work and retains claims after failed cleanup. (test/helpers/qa-gateway-test-lifetime.ts:12, 2164c12753af)
  • Acquisition and cancellation review: Client acquisition distinguishes pending, failed, and handed-off states; cancellation joins failed acquisition cleanup and suppresses late hello callbacks while preserving reconnect callbacks after handoff. Instance acquisition checks cancellation after asynchronous preparation and records rollback failures through the same verifier. (test/helpers/gateway-client.ts:20, 2164c12753af)
  • Meaningful regression coverage: Coverage exercises a real WebSocket client during cancelled acquisition, holds cleanup completion to detect premature handoff, and invokes the actual registered route-test callback with controlled pending work. Separate process tests cover cancellation during preparation, readiness, CLI execution, and migration-refusal drainage. (src/gateway/gateway-route-model-reuse.lifecycle.test.ts:15, 2164c12753af)
  • Current-main and release comparison: At the fetched main revision, the route-model test still uses the ordinary QA fixture without the new cancellation-aware adapter. The adapter path is absent from both fetched main and v2026.9.4; no verified merged replacement for the central repair was established. (src/gateway/gateway-route-model-reuse.test.ts:85, 3c34fe88c1ac)
  • Updated proof and review continuity: The complete captured body at sourceRevision 743a203609e00d8cea0c0c8a09b1399a1e850cdd5983f67122536f2e8144fe5b reports integrated Linux validation: 115 focused passes with one Windows-only skip, six ordinary built-Gateway cases, and two controlled cancellation/sentinel cases. It records a held finalizer, no late requests or writes, closed child pipes, absent process group/state, and subsequent lease release. These are reported observations, not executions or raw artifacts independently inspected in this review. The earlier controller closeout remains explicitly unverified. (2164c12753af)

Likely related people:

  • vincentkoc: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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 (3 earlier review cycles)
  • reviewed 2026-09-14T04:14:22.627Z sha 7835e6f :: blocked before merge. :: none
  • reviewed 2026-09-14T04:46:46.382Z sha 7835e6f :: blocked before merge. :: none
  • reviewed 2026-09-14T05:17:34.044Z sha 7835e6f :: blocked before merge. :: none

Integrate the existing fixture lifetime across Gateway test bodies and
partial acquisition, joining provider handlers and ordered cleanup.
Preserve assertions, budgets, bounded readiness diagnostics, and the
original contributor history.

Validated the exact integrated tree with 115 focused tests, the complete
changed-file gate and build, six ordinary Gateway cases, and two controlled
cancellation/sentinel cases on sanitized direct AWS. Independent review
passed; the proof lease was released after preserving retained scratch.
@steipete
steipete merged commit 7bdca7d into main Sep 15, 2026
150 of 152 checks passed
@steipete
steipete deleted the fix/gateway-timeout-fixture-ownership-20260914 branch September 15, 2026 15:51
@steipete

Copy link
Copy Markdown
Contributor

Merged via squash.

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 P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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.

2 participants