Repository navigation
fix: apply Gateway port changes during in-process restarts - #206501
Conversation
Refresh the startup config before reacquiring listener ownership, preserving explicit CLI and launch-time environment overrides. Move the unchanged snapshot reader into its own module and keep restart regressions with config guard tests to satisfy file-size limits. Co-authored-by: daniel-lxs <[email protected]>
Worked on by: - @daniel-lxs Co-authored-by: daniel-lxs <[email protected]> OpenClaw-Publication: cd1692df-a183-48cf-9ab8-2e1253037b84
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: passed. What this changesRefresh the configured Gateway port before an in-process restart reacquires ownership and starts its listener. Example: An unmanaged Gateway changes gateway.port from 19771 to 19772 without a launch override.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review This PR fixes a current-main Gateway restart bug and has sufficient runtime and upgrade evidence; no actionable findings remain. Reviewed head: Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherThe Gateway CLI resolves config and launch overrides, while its run loop closes the previous server, reacquires state custody, and starts the next listener. flowchart TD
A[Saved Gateway config] --> C[CLI port resolution]
B[Launch overrides] --> C
C --> D[Restart recovery]
D --> E[State custody]
E --> F[Gateway listener]
D --> G[Startup failure recovery]
Technical reviewBest possible solution: Land the focused port-refresh repair while preserving launch overrides, shared custody, and existing startup recovery. Do we have a high-confidence way to reproduce the issue? Current-main source retains the captured startup port, matching the linked issue's real CLI reproduction; no target code was executed during this read-only review. Is this the best way to solve the issue? The repair keeps port selection in the CLI, passes one refreshed snapshot into startup, and reuses the existing recovery owner without a parallel lifecycle path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 360e306f454f. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceSource +37, Tests +82, Docs +4. Total +123 across 9 files. Added test files: 0. View PR surface stats
Preflight sourceSource unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified. Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. LabelsLabel changes:
Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReviewed November 27, 2026, 4:53 AM ET / 09:53 UTC (Revision 3). |
Remove the unused extracted type import and preserve the optional test-call boundary before reading its startup snapshot. Co-authored-by: daniel-lxs <[email protected]>
Route restart config-read failures through the existing startup recovery owner after resetting admission. Keep lock-acquisition failures terminal and cover both automatic and external-signal manual recovery. Co-authored-by: daniel-lxs <[email protected]>
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
I verified a real published v2026.11.10 → Redacted upgrade and restart proofAWS I installed The version field is unchanged on this branch; the distinct build IDs identify the published release and PR-head code. I built and integrity-checked the installable package using the repository packer. After each restart, Each candidate run started on 19771, then I saved
Captured config-only sequence: I asserted the original session ID and entire returned messages array were unchanged after the update and every restart, the workspace marker retained exact bytes, and the existing auth, bind, mode, reload, plugins, agents and logging settings matched their pre-update values. Only the requested port changed. The automatic/manual recovery custody regression cases also passed on AWS: 3/3. Two harness issues were corrected before the passing run: an obsolete fixture setting and assertions against outdated console wording. The passing run uses HTTP readiness and the actual native-runtime PID; no product assertion was relaxed. The test Gateways were joined and their isolated state removed. Not verified here: native-supervisor upgrades, other operating systems, live model/channel traffic, or completed full CI. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
Apply saved gateway.port changes when an unmanaged Gateway restarts in process. Preserve explicit launch port overrides and startup recovery. Closes #206498. (cherry picked from commit c47c525) Backport adaptation: Keep the release invalid-config reset tests and add the upstream restart-port cases; do not import the unrelated snapshot-retention test absent on this branch. Production startup-config and lock changes are unchanged. Co-authored-by: RomneyDa <[email protected]>
…206501) Apply saved gateway.port changes when an unmanaged Gateway restarts in process. Preserve explicit launch port overrides and startup recovery. Closes openclaw#206498.
Adapt upstream #206649 (461f650): apply only the stale export cleanup for release backport #206501. Co-authored-by: RomneyDa <[email protected]>
Apply saved gateway.port changes when an unmanaged Gateway restarts in process. Preserve explicit launch port overrides and startup recovery. Closes #206498. (cherry picked from commit c47c525) Follow-up audit: 974d792 update status, 516166c rejected argument exits, 2fca213 debug capture, 9f63c3c restart blockers, e2fcd4d update readiness receipts, af76d15 fixture pruning, and 461f650 startup export guards are independent of overriding the saved in-process restart port. Release adaptation: Keep stable invalid-config reset tests; add only the restart-port cases and omit the unrelated selected-snapshot collection test. Co-authored-by: RomneyDa <[email protected]>
The Z.AI catalog, #208041 subagent stop, #206501 Gateway restart, #203923 backup inventory, #208414 Docker TLS, and reconnect chat-admission backports left six files unformatted after adapting them to stable. Apply the pinned repository formatter without changing behavior. Co-authored-by: RomneyDa <[email protected]>
Closes #206498
What Problem This Solves
Changing
gateway.porton an unmanaged Gateway saves the new setting and triggers an in-process restart, but the listener stays on the old port. The configured address is then unreachable.User Impact
Port changes take effect during the existing automatic restart. Explicit
--portand launch-timeOPENCLAW_GATEWAY_PORTstill win. No new setting or migration is required.Why This Change Was Made
I refresh the startup config before reacquiring listener ownership and keep the listener and owner record on the same port. The Gateway's own exported port is not treated as a launch override.
I keep config-read failures with the existing startup recovery owner, after restart admission resets, so automatic recovery and manual SIGUSR2 recovery remain available. Actual lock-acquisition failures still terminate as before.
I moved the unchanged startup snapshot reader into a sibling module to satisfy the file-size ratchet. The CLI remains the single port owner; no duplicate run-loop port state is added. Simplification pass against main's merge base: production +77/-40, tests +152/-70, docs +6/-2. Most test churn parameterizes the existing real-custody case.
Evidence
Main-vs-fix AWS proof: main
009566554a35kept serving19771; the fix served19772in the same PID and updated the owner record.I replayed the real CLI on AWS through
crabbox-wrapperwith the final source at08c8adeba8854abde7a6865f5139a34bfecad729. Final runtime proof:Three original regressions failed against main and passed with the fix. I also reproduced and fixed the review's config-read recovery regression, including a red-before/green-after manual-admission case. The final production code passed 257 focused tests with one existing skip. After test-only lint corrections, I reran all three real-custody cases; core/config-CLI typechecks, targeted lint and formatting passed. The real CLI build passed.
I verified that all nine changed files on AWS matched the committed source; aggregate SHA-256:
aff0b94a1c6b1020c6f0827c30240bd1396630336190b5b5bde03780a0a81315. I released all task AWS leases and joined the test Gateway processes before removing their temporary state.Independent source review found the recovery issues addressed above. Local Codex autoreview remained blocked at its read-only sandbox preflight. ClawSweeper passed source review on this head with no actionable code findings. I also ran the published v2026.11.10 updater on CrabBox AWS and verified the resulting PR-head Gateway preserved the seeded settings, full session history and workspace file through port rebinding and both launch overrides. Redacted stable-to-head upgrade proof. Full CI and native-supervisor upgrade flows remain unverified. Nothing has been merged or deployed.
Co-authored with @daniel-lxs.
Work sessions
Linked for team reference; these sessions aren’t public.
Worked on by