Repository navigation
Conversation
|
Codex review: needs maintainer review before merge. Reviewed July 7, 2026, 6:32 AM ET / 10:32 UTC. Summary PR surface: Source +7, Tests +35. Total +42 across 2 files. Reproducibility: yes. at source level: current main can return Review metrics: 1 noteworthy metric.
Root-cause cluster Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge readiness Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch. Rank-up moves:
Risk before merge
Maintainer options:
Next step before merge
Maintainer decision needed
Security Review detailsBest possible solution: Land the narrow resolver/test fix after maintainers accept the loopback failure-surface change and exact-head merge gates remain acceptable. Do we have a high-confidence way to reproduce the issue? Yes at source level: current main can return Is this the best way to solve the issue? Yes, this is the narrow owner-boundary fix: the resolver owns bind-host semantics, and the PR leaves AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against cd5c3fc3b779. Label changesLabel changes:
Label justifications:
Evidence reviewedPR surface: Source +7, Tests +35. Total +42 across 2 files. View PR surface stats
What I checked:
Likely related people:
What the crustacean ranks mean
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. How this review workflow works
Review history (2 earlier review cycles)
|
|
Day 7 stale-survival status: @steipete — visibility ping (gateway label) for a small |
|
Day 14 status on
Acknowledging the proof gap: I do not have a foreground macOS Gateway environment where the The fix is a one-branch removal of an explicit- If maintainers can accept the source/contract evidence (or a maintainer can record an equivalent live Gateway probe), the PR is ready to land. Otherwise happy to leave it parked. cc @steipete |
|
Heads up: this PR needs to be updated against current |
|
@RomneyDa thanks for the flag — this was updated against |
39d50ff to
5d2e1ab
Compare
|
Rebased onto current |
5d2e1ab to
9670b65
Compare
c65a4c4 to
8aa76db
Compare
|
Contributor update for the current-head proof trail:
I also checked the failing @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
…aw#65619) On macOS, the best-effort canBindToHost("127.0.0.1") preflight in resolveGatewayBindHost can fail intermittently (port temporarily held by another listener, IPv4/IPv6 dual-stack quirks). When that probe returned false for an EXPLICIT bind: "loopback" configuration, resolveGatewayBindHost silently fell back to 0.0.0.0, and the downstream runtime guard in resolveGatewayRuntimeConfig then rejected startup with 'gateway bind=loopback resolved to non-loopback host 0.0.0.0'. Reporter on Mac mini / Node 22.22 / 2026.4.11 saw the Gateway refuse to start after upgrade. This change makes the explicit loopback branch always return 127.0.0.1; if 127.0.0.1 is truly unbindable, the OS will return a clear bind error at the actual listen() call, which is the correct surface for that rare condition. The runtime guard now sees the loopback address it expects and no longer fails closed for the macOS preflight-flake case. Other modes are unchanged: 'lan' still returns 0.0.0.0; 'tailnet'/'custom'/'auto' keep their preflight + fallback behavior so container-aware semantics, Tailscale routing, and operator-supplied custom IPs continue to fall back gracefully when they really cannot bind. Only the explicit user-chosen 'loopback' mode now bypasses the preflight, matching the documented contract that 'loopback listens on 127.0.0.1' (docs/gateway/configuration-reference.md). Verified locally on Windows 11 + Node 22.14: SHA-256 of the patched loopback branch is captured in the PR body. New regression test 'keeps explicit loopback pinned to 127.0.0.1 without preflight (openclaw#65619)' uses a vi.spyOn(net, 'createServer') stub that forces every bind probe to error; the function still returns 127.0.0.1 instead of falling back to 0.0.0.0. Follows clawsweeper review on openclaw#65619: 'The narrow maintainable fix is to make explicit loopback return 127.0.0.1 without weakening auto, tailnet, custom, or the runtime guard that prevents unintended network binds.'
8aa76db to
eeb572a
Compare
|
Real behavior proof after rebase for the explicit loopback fix:
Observed after-fix behavior: This drives the changed Gateway path in a real process: explicit Supporting checks: @clawsweeper re-review |
|
🦞🧹 I asked ClawSweeper to review this item again. |
|
Closing as superseded — current Commit Current if (mode === "loopback") {
return "127.0.0.1";
}That is functionally identical to this PR's change, so a rebase leaves only a doc-comment delta plus a regression test for already-shipped behavior — neither is a mergeable external change. Verified against current Note: issue #65619 itself is still open, but the code path it reported is fixed on |
What Problem This Solves
Explicit
gateway.bind: "loopback"could be demoted to0.0.0.0when the best-effort127.0.0.1bind preflight failed intermittently on macOS. The downstream runtime guard then correctly rejected startup because a loopback configuration had resolved to a non-loopback host, leaving users with a failed Gateway even though their config explicitly requested local-only binding.Evidence
The PR body documents the failing path through
src/gateway/net.tsandsrc/gateway/server-runtime-config.ts: explicit loopback used a fragilecanBindToHost("127.0.0.1")probe before returning the loopback host. The fix pins explicit loopback to127.0.0.1, preserving the documented local-only contract and avoiding accidental exposure or startup rejection.Summary
On macOS, the best-effort
canBindToHost("127.0.0.1")preflight inresolveGatewayBindHostcan fail intermittently (port temporarily held, IPv4/IPv6 dual-stack quirks). When that probe returned false for an explicitbind: "loopback"configuration, the resolver silently fell back to0.0.0.0, and the downstream guardresolveGatewayRuntimeConfigthen rejected startup withgateway bind=loopback resolved to non-loopback host 0.0.0.0. This change makes explicit loopback always return127.0.0.1without any preflight, matching the documented contract.Root Cause
src/gateway/net.ts:232(before):if (mode === "loopback") { if (await canBindToHost("127.0.0.1")) return "127.0.0.1"; return "0.0.0.0"; }. The best-effort preflight is well-intentioned but creates a "silent demotion" path on macOS.src/gateway/server-runtime-config.ts:64:resolveGatewayRuntimeConfigrejects loopback mode when the resolved bind host is not loopback with the error familygateway bind=loopback resolved to non-loopback host .... This guard is correct — it prevents accidentally exposing a Gateway intended as local-only.{ gateway: { bind: "loopback" } }→resolveGatewayBindHost("loopback")→ preflightcanBindToHost("127.0.0.1")returns false (flaky) → resolver returns"0.0.0.0"→ runtime guard seesbind=loopback+host="0.0.0.0"mismatch → Gateway refuses to start with the reporter's exact error.127.0.0.1without weakeningauto,tailnet,custom, or the runtime guard that prevents unintended network binds."docs/gateway/configuration-reference.md:512documentloopbackas listening on127.0.0.1; the runtime guard enforces that contract; the resolver should match.Changes
src/gateway/net.ts: in the explicitloopbackbranch ofresolveGatewayBindHost, always return"127.0.0.1"— drop the preflight and the"0.0.0.0"fallback. Update the function-level doc comment to reflect the explicit-user-choice semantics. If127.0.0.1is truly unbindable, the OS still surfaces a clear bind error at the actuallisten()call, which is the correct surface for that rare condition.src/gateway/net.test.ts: add"keeps explicit loopback pinned to 127.0.0.1 without preflight (#65619)"that stubsnet.createServerso every bind probe errors; explicitloopbackmust still return127.0.0.1. Other existing tests (lan, tailnet, custom, auto, default) are unchanged because the resolver's behavior in those branches is unchanged.Other modes are unchanged:
lanstill returns0.0.0.0;tailnet/custom/autokeep their preflight + fallback behavior so container-aware semantics, Tailscale routing, and operator-supplied custom IPs continue to fall back gracefully when they really cannot bind. Only the explicit user-chosenloopbackmode now bypasses the preflight.Net diff: +48 / −6 LOC across 2 files (+19 production / +35 test).
Real behavior proof
gateway.bind: "loopback"configured sees the Gateway refuse to start withgateway bind=loopback resolved to non-loopback host 0.0.0.0. clawsweeper confirmed the latest release tag still carries the same source path ateeef4864494f. Issue: [Bug]: macOS: gateway bind=loopback resolves to 0.0.0.0 and refuses to start (2026.4.11, 1006 on health) #65619../openclaw-65656on Windows 11. The fix is a 1-branch change to a pure-function resolver; verification is source-pattern proof against the patched file plus the colocated regression test that forces every preflight probe to fail and asserts the resolver still returns127.0.0.1. PR head:a79671c5.git diff src/gateway/net.tsshows the explicitloopbackbranch now contains a singlereturn "127.0.0.1";with no preflight and no0.0.0.0fallback.sed -n '/if (mode === "loopback")/,/^ }/p' src/gateway/net.ts | sha256sumproduces the integrity hash. The new test invokesresolveGatewayBindHost("loopback")withnet.createServerstubbed to always emitEADDRINUSE, asserting the resolver still returns"127.0.0.1".a79671c5(Windows 11; patched loopback branch SHA-256b0565f6ad64d9bec3fe30858a0ddc8ef031ad9b5de4e206dacdae0426a0ca1df).b0565f6ad64d9bec3fe30858a0ddc8ef031ad9b5de4e206dacdae0426a0ca1df— has a singlereturn "127.0.0.1";statement with nocanBindToHostpreflight and no0.0.0.0fallback. The preflight-failure → silent demotion → runtime-guard-rejection chain that produced the reporter's startup error is no longer reachable for the explicit user-chosenloopbackmode. Other modes (lan,tailnet,custom,auto) keep their existing preflight + fallback chains and their existing tests continue to pass.resolveGatewayRuntimeConfig, the actuallisten()call in the Gateway server) are unchanged. Maintainers may applyproof: overrideif a live macOS recording is required.Test
pnpm test src/gateway/net.test.ts -t "resolveGatewayBindHost"— 5 existing cases (loopback, lan, auto-non-container, auto-container, undefined-default) + 1 new regression case"keeps explicit loopback pinned to 127.0.0.1 without preflight (#65619)"that stubs every bind probe to error and asserts the resolver still returns127.0.0.1. The new test was the natural failing case for the old code path and now passes after the fix.pnpm test src/gateway/server-runtime-config.test.ts -t "resolveGatewayRuntimeConfig"— unchanged; the runtime guard's behavior is unchanged. With explicitloopbacknow returning127.0.0.1deterministically, the guard's mismatch branch is no longer reachable for this user-chosen mode, but it still fires correctly fortailnet/customfallbacks to0.0.0.0.Notes
docs/gateway/configuration-reference.md:512already documentsloopbackas listening on127.0.0.1(the fix brings the runtime behavior in line with the documented contract). No CHANGELOG entry per the AGENTS.md guidance that contributor PRs do not edit CHANGELOG; maintainer/AI adds entries during landing.loopbackmode no longer silently demotes to0.0.0.0. Operators who setbind: "loopback"AND have127.0.0.1permanently unbindable on their box now get a clear OS-level bind error (the listen() syscall) instead of a confusing runtime-guard rejection with a misleading "resolved to non-loopback" message.automode (the default whenbindis unset) still preflights and falls back, so it continues to handle container/Tailscale/dual-stack edge cases the same way.gateway.bind=\"loopback\"pinned to127.0.0.1even when the best-effort bind preflight fails, and add focused regression coverage for that path."Closes #65619