Skip to content

fix: avoid foreign-listener race in Gateway acquisition proof - #166930

Merged
RomneyDa merged 1 commit into
mainfrom
openclaw/whether-gateway-pr-166883-should-land-on-main
Oct 8, 2026
Merged

RomneyDa merged 1 commit into
mainfrom
openclaw/whether-gateway-pr-166883-should-land-on-main

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #166883 (release-branch fix, now forward-ported to main).

What Problem This Solves

Fixes: Gateway acquisition validation can fail after correct fixture cleanup when an unrelated listener occupies the released TCP port.

User Impact

User impact: no production or user-visible behavior changes. Automated validation now checks the fixture's own reservation rather than mistaking a foreign listener for its Gateway.

Why This Change Was Made

Forward-port the exact test-only fix from #166883 onto main. Observe the reserved server directly, exercise a real competing listener through stop, and preserve both independent cooperative port-claim checks and post-cleanup reacquisition. No runtime changes, retries, or timeout increases.

Evidence

Validated on main baseline 301e372903de4e9e04e17da018a1ac2ffdb4c2ff with this patch:

  • Before: a controlled real competing listener makes the original acquisition assertion fail with expected busy to be free. The fixture and listener were cleaned up; the control was removed afterward.
  • After: pnpm test test/helpers/openclaw-test-instance.acquisition.test.ts --maxWorkers=1 — 18 passed; 8.01 s wrapper wall time with cached compiled workers; changed scenario 37 ms.
  • Sibling: pnpm test src/test-utils/ports.test.ts --maxWorkers=1 — 20 passed; 6.66 s wrapper wall time.
  • node scripts/check-changed.mjs --timed --base 301e372903de4e9e04e17da018a1ac2ffdb4c2ff -- test/helpers/openclaw-test-instance.acquisition.test.ts — all 20 selected checks passed, including root-test typechecks, formatting, lint, and guards.
  • Fresh independent P0 autoreview: scoped-clean, no actionable findings. git diff --check passed.
  • Scope: one test file, +37/-5; production delta 0. Patched file is byte-identical to the release fix (blob a740fc28048a11e4ad411cd77ac2c3b11158a010).
  • Hosted CI run 37722501015 passed on exact head aa6157bee0b1da514ab0b1e4ac8753d53e56e3ff; all 46 jobs finished successfully or were intentionally skipped, and openclaw/ci-gate is green. In the changed-test job, the changed scenario took 31 ms; its containing 13-file lane took 118.62 s (not per-file or incremental PR cost).
  • ClawSweeper follow-up: 20/20 additional standalone acquisition-suite runs passed, 18 cases each (360 test-case executions). Wrapper wall times were 6.06–28.23 s. The existing 20-passing-case port-owner sibling result remains valid.
  • ClawSweeper follow-up: 3/3 complete current-head replays of the original 56-file inventory passed on Blacksmith Testbox run 37725736406. Each replay accounted for all 56 files: 1,240 passed tests and five reported skips, with zero failures. Source and test-owner coverage were checked explicitly; no source changes or assertions were weakened.
Historical-shard replay qualification and recovery

The original failure was run 37706290335, job 113081546328. Its 56-file inventory is retained without omissions, partitioned into the current main owners: 53 tooling, two tooling-isolated, and one infra. This is a current-head replay of that inventory, not restoration of the older shared-worker topology.

An initial local selection stopped before the Gateway case on an unchanged security-workflow fixture (install.json absent). Diagnostics traced this to host Bash startup prepending /usr/bin ahead of the fixture's synthetic npm. That attempt is a failure, not a clean replay; its initial owner selection also needed correction. Temporary diagnostic edits were restored, with no source changes retained.

The unchanged security fixture then passed 38/38 tests, no skips, on a clean Blacksmith Testbox: run 37723808269, verified source aa6157bee0b1, tree cbb86a000322270cba469420e73e93b5892b51f3, Node 24.19.0; 2.09 s test-wrapper wall time. This diagnoses the host-specific failure; it is not a full-shard pass. The old release job used Node 24.21.0.

A queued full-replay attempt was interrupted by a Gateway restart before executing tests and is not counted. The recovered one-shot run completed all three repetitions against verified source aa6157bee0b1da514ab0b1e4ac8753d53e56e3ff and tree cbb86a000322270cba469420e73e93b5892b51f3. Each repetition used the repository CI shard runner, two workers, and serialized owner groups; its completion record reported three completed invocations and zero failures. An additional check required discovery of every expected file under its correct owner, rejecting omissions, extras, and duplicate owners.

Replay Files accounted for Passed tests Skipped tests Vitest duration: tooling / isolated / infra
1 56 1,240 5 151.07 / 5.45 / 96.15 s
2 56 1,240 5 136.09 / 5.58 / 98.25 s
3 56 1,240 5 134.82 / 6.00 / 96.26 s

Per repetition, tooling had 53 passing files and 1,193 passing / four skipped tests; tooling-isolated had two passing files and 31 passing tests; infra had one passing file and 16 passing / one skipped test. The five skips were the native metadata scan in openclaw-live-updater.test.ts, three native installer scenarios in install-ps1.release.test.ts, and the full cold/warm provisioning case in pr-worktree-provision.test.ts. They are not claimed as executed coverage.

Runtime was Node 24.19.0 on Linux; the historical release run used Node 24.21.0. Current canonical isolation is preserved rather than restoring obsolete shared-worker placement. Native Testbox receipt: exitCode: 0, signal: null, settled: true. The lease stopped automatically and its completed state was verified. The backing Actions job can show cancellation during delegated lease cleanup; the native command receipt establishes this proof, separately from the green PR CI run above.

Contributor credit: @RomneyDa for the original release fix and the requested main forward-port.

Work sessions

Forward-port the test-only fix from #166883 onto main. Observe the fixture-owned reservation while preserving cooperative port claims and real competing-listener coverage.

Co-authored-by: RomneyDa <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 8, 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.

@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: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Oct 8, 2026
@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed October 8, 2026, 12:26 AM ET / 04:26 UTC (Revision 4).

ClawSweeper review

What this changes

The branch changes Gateway fixture validation to observe its own closed listener while exercising a competing TCP listener and preserving port-claim checks.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) The focused correction has no actionable findings and completes its required validation; evidence remains fixture-harness proof rather than a shipped product entry point.
Proof confidence 🦐 gold shrimp (3/6) Not applicable: This bot-authored, test-only PR is outside the external-contributor proof gate. Reported validation exercises the actual fixture with real TCP listeners, includes a failing-base control, and completes the required standalone, sibling, and inventory replay coverage. No stored-data contract changes.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Test only · Worth it: Yes · Fix scope: Complete
Reason: The existing assertion can falsely fail release validation despite correct fixture cleanup. The correction preserves the intended contract without production changes.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary on current main and has no actionable patch findings. The updated evidence satisfies the prior replay requirement; no additional review blocker remains.

Priority: P3
Reviewed head: aa6157bee0b1da514ab0b1e4ac8753d53e56e3ff

Before merge

None.

Findings

None.

Agent review details

How this fits together

OpenClaw’s automated tests create isolated Gateway fixtures with TCP listeners and cooperative port claims. This acquisition test checks listener release, retained claims, and final cleanup.

flowchart TD
 A[Acquire isolated fixture] --> B[Reserve listener and port claims]
 B --> C[Release owned listener]
 C --> D[Bind competing listener]
 D --> E[Verify owned listener stays closed]
 E --> F[Verify both claims remain held]
 F --> G[Clean up and reacquire claims]
Loading

Technical review

Best possible solution:

Keep listener identity separate from cooperative port ownership and retain the controlled competing-listener regression on main.

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

Yes: a foreign listener makes the original TCP probe return busy after the fixture correctly releases its reservation. Source establishes the mechanism and the body reports a controlled failing-base run; this review did not execute it.

Is this the best way to solve the issue?

Yes: observing the owned server removes the incorrect listener-identity assumption while preserving stop, independent claim-retention, and cleanup coverage.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness. Added test files: 1.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 709a00d adds test/helpers/openclaw-test-instance.acquisition.test.ts:38 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 709a00d0bf46; files: test/helpers/openclaw-test-instance.acquisition.test.ts)
  • RomneyDa: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

PR surface

Tests +32. Total +32 across 1 file.

View PR surface stats
Area Files Added Removed Net
Source 0 0 0 0
Tests 1 37 5 +32
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 1 37 5 +32

Root-cause cluster

Relationship: same_root_cause
Canonical: #166883
Summary: This PR forward-ports the merged release-branch correction; the two branches require separate landing.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Labels

Label changes:

No label changes.

Label justifications:

  • P3: This focused test-reliability correction changes no production or user-visible 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-08T03:09:33.710Z sha aa6157b :: needs changes before merge. :: none
  • reviewed 2026-10-08T03:27:16.569Z sha aa6157b :: needs changes before merge. :: none
  • reviewed 2026-10-08T04:19:46.344Z sha aa6157b :: needs changes before merge. :: none

@RomneyDa
RomneyDa marked this pull request as ready for review October 8, 2026 03:23
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Oct 8, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@RomneyDa
RomneyDa merged commit 4859d33 into main Oct 8, 2026
147 checks passed
@RomneyDa
RomneyDa deleted the openclaw/whether-gateway-pr-166883-should-land-on-main branch October 8, 2026 07:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 9, 2026
…aw#166930)

Forward-port the test-only fix from openclaw#166883 onto main. Observe the fixture-owned reservation while preserving cooperative port claims and real competing-listener coverage.

Co-authored-by: roboclaw-bot <[email protected]>
Co-authored-by: RomneyDa <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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