Repository navigation
fix(test): prove gateway retry and drain ordering - #132402
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 29, 2026, 1:43 AM ET / 05:43 UTC. ClawSweeper reviewWhat this changesThe branch makes shared Gateway test-instance coverage deterministically prove delayed refusal classification and stale-child drain ordering with real child processes. Merge readinessKeep open for normal maintainer handling: the PR adds a focused, non-duplicative regression proof that current main lacks, and no introduced correctness or security defect was found. Priority: P3 Review scores
Verification
How this fits togetherThe shared test-instance helper starts Gateway child processes for integration tests and owns readiness, retries, output streams, and teardown. These tests drive synthetic child processes through that boundary and verify whether a retry or replacement is permitted. flowchart LR
A[Lifecycle test] --> B[Shared test helper]
B --> C[Gateway child process]
C --> D[Exit and stream events]
D --> E[Retry or drain decision]
E --> F[Startup error or replacement child]
Decision needed
Why: The protected maintainer label and member authorship require explicit maintainer handling even though the narrow test change has no identified defect. Before merge
Agent review detailsSecurityNone. PR surfaceTests +65. Total +65 across 1 file. View PR surface stats
Review metrics
Technical reviewBest possible solution: Retain the controlled real-process tests as the canonical regression coverage for retry admission and stale-child ownership, then land through the normal maintainer gate once exact-head checks finish. Do we have a high-confidence way to reproduce the issue? Not applicable as an end-user issue: the PR strengthens a regression test. Its body supplies a concrete real-subprocess and loopback scenario, while this read-only review did not execute it. Is this the best way to solve the issue? Yes. The assertions sit at the shared lifecycle owner boundary and distinguish exit from fully drained stdio without adding a production seam or duplicating the existing deadline-drain case. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c3ff7f98d58e. LabelsLabel changes:
Label justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
|
|
Land-ready maintainer verification for commit 5f14acde5915641da0f5927d461c6a006233b8b9. Exact-head CI run 33236537081 completed successfully. The latest ClawSweeper review found no correctness/security defects; its remaining next step and rank-up move were green exact-head checks followed by normal maintainer landing. Those checks are now green, and the explicit maintainer landing request is being handled through the native workflow. No re-review is needed for the unchanged head. The architectural owner remains the test fixture/control, not production lifecycle policy. This removes the timer-based late-stderr assumption and adds a completed held-owner restart rejection before release. Production/shared-helper LOC is zero; tests are +92/-27. Original assertions and startup/stop values, the TERM-resistant fixture/test, refusal-drain and intervening-stop remain preserved. Real-process proof ran the full 26-test file, serial and non-isolated, with real Node children/pipes/signals and loopback HTTP in fresh credential-free synthetic state: node scripts/run-vitest.mjs test/helpers/openclaw-test-instance.test.ts --maxWorkers=1 --no-file-parallelism --no-isolateNode 24.20.0 passed 26/26. Node 26.7.0 passed 26/26 on one bounded unchanged-source recheck after the documented pre-existing replacement-readiness timeout. Both final negative controls fail for the intended non-timeout reasons: premature classification loses the retry, and skipped stale-owner stop wrongly resolves the blocked start. All recorded PID checks and root-removal checks passed. This is not a claim that all short-startup flakes are eliminated, nor authenticated product Gateway proof. Final formatting, diff checks, root test types, lint and guards passed: node scripts/check-changed.mjs -- test/helpers/openclaw-test-instance.test.tsFresh Codex autoreview of the frozen candidate was scoped-clean at its default P0 threshold; direct owner/caller/callee/history and Node dependency-contract review also completed. The reviewed source was restored byte-for-byte after mutation testing. No timeout increase, weaker original assertion, production seam, dependency or changelog change is included. |
|
Merged via squash.
|
Related: #120089 — shared Gateway migration retry, #131890 — Gateway readiness and lifecycle cleanup.
Additional instructions
Maintainer-owned branch; maintainers can update the branch. AI-assisted, explicitly maintainer-requested test repair.
What Problem This Solves
Resolves a problem where the shared Gateway lifecycle tests could pass without proving the event ordering they claim to protect. The delayed-refusal case assumed a descendant's 50 ms timer would run after the leader exited, while the terminal-drain case released its inherited pipe before asking the helper to restart. Controlled negative tests demonstrated that those assertion flows could miss early stderr classification and skipped stale-owner cleanup.
Why This Change Was Made
The delayed writer now waits on the existing loopback control and is released only after the test observes the leader's native exit. The test also verifies that stderr remains open and the refusal has not arrived before release, then retains the original real-readiness, identical-launch-state and replacement-ownership assertions.
The terminal case now attempts a restart while the old pipe is deliberately held, requires the existing stop-deadline error and retained owner, and verifies that no second attempt was recorded. It then releases the holder, observes native closure and completes the original successful replacement/stop proof. Listener registration precedes release, but filesystem setup is outside the close-observation clock. This case uses its existing attempt trace rather than adding an HTTP launch round-trip inside its 300 ms startup budget.
All existing startup/stop values and original assertions remain. The shared instance helper and managed-child implementation are unchanged. Automatic startup-failure cleanup is not replaced by explicit-stop coverage.
User Impact
No production Gateway, configuration, dependency or public API change. Maintainers get stronger real-process regression coverage for late startup diagnostics and retained child ownership. The separate TERM-resistant case and its fixture, refusal-drain case, and intervening-stop case remain byte-identical.
This is an ordering/coverage repair, not a claim to eliminate every scheduler-sensitive startup under the existing short deadlines.
Evidence
Real subprocess and loopback HTTP proof: full 26-test file, original declaration order, one worker, no file parallelism and no isolation. Every run used fresh synthetic HOME/state/config/TMP/XDG, a literal credential-free environment and the existing external PID registry. These are real Node children, inherited pipes and process-group signals—not mocked ChildProcess objects. No operator Gateway, live credentials, provider or channel was used.
Regression controls: controlled schedules retaining the old assertions passed against artifact-only helper copies that classified stderr before draining or skipped stale-owner stop. With the final assertions, both deliberately broken variants fail for the intended reason: the late refusal loses its retry (209 ms, code-1 exit—not timeout), and the blocked terminal restart incorrectly resolves instead of rejecting (497 ms—not timeout). The other 24 cases were unselected in this focused mutation run; it is not counted as a full-file pass. The tracked helper was never mutated and the temporary test import was restored exactly.
Cleanup: all post-run recorded PID checks were absent; all synthetic roots were removed after verification. No global/manual kill was needed. Recorded-PID absence is the precise claim; child-side receipts are not a complete OS-spawn ledger.
Static checks and review: focused oxfmt,
git diff --check, and the complete changed gate passed, including root test typechecking and scripts lint.Codex autoreview of the final uncommitted candidate and owner evidence completed scoped-clean at its default P0 threshold. Manual owner/caller/callee/history review and direct Node 24/26 exit/close and synchronous-receipt contract inspection also completed.
Production/shared-owner LOC: 0. Tests: +92/-27 (net +65), including existing assertions moved into failure-safe
try/finallyblocks. No build/package or authenticated product Gateway proof is claimed for this test-only change.