Skip to content

fix: improve gateway sandbox diagnostics - #88912

Closed
LDMB123 wants to merge 1 commit into
openclaw:mainfrom
LDMB123:codex/upstream-gateway-sandbox-diagnostics
Closed

LDMB123 wants to merge 1 commit into
openclaw:mainfrom
LDMB123:codex/upstream-gateway-sandbox-diagnostics

Conversation

@LDMB123

@LDMB123 LDMB123 commented Jun 1, 2026 •

Copy link
Copy Markdown

Summary

  • Improve gateway status diagnostics for sandbox false negatives such as loopback EPERM and HTTP 000.
  • Preserve host-side gateway status as the authoritative readback when sandbox-local probes cannot reach the local service.
  • Add targeted coverage for the gateway status and port-formatting paths.
  • Use this branch only as a temporary upstream review vehicle; the durable target is upstream openclaw/openclaw.

Verification

  • node scripts/run-vitest.mjs src/cli/daemon-cli/status.gather.test.ts src/gateway/net.test.ts src/infra/ports-format.test.ts
  • git diff --check

Real Behavior Proof

Behavior addressed: Gateway status diagnostics now distinguish sandbox probe false negatives from real gateway failures; strict loopback uses 127.0.0.1; status output avoids same-PID false conflict hints.

Real environment tested: local OpenClaw source checkout on macOS at PR head 548d0d00de6e5f0501224c42ded14710de0fe020. The proof started the branch's source gateway with a redacted temp OpenClaw home, custom launchd label, explicit token auth, --bind loopback, and a random loopback port. No .dev.vars, live credentials, or private config were read.

Exact steps or command run after this patch: started node --import tsx src/entry.ts gateway run --dev --auth token --token <token> --bind loopback --port <port> --allow-unconfigured --verbose with OPENCLAW_HOME=<tmp>/home, OPENCLAW_STATE_DIR=<tmp>/home/.openclaw, OPENCLAW_CONFIG_DIR=<tmp>/home/.openclaw, OPENCLAW_DISABLE_BUNDLED_PLUGINS=1, OPENCLAW_TEST_MINIMAL_GATEWAY=1, and OPENCLAW_LAUNCHD_LABEL=ai.openclaw.proof.gateway; then ran node --import tsx src/entry.ts gateway status --url ws://127.0.0.1:<port> --token <token> --json --require-rpc --timeout 5000 and summarized the redacted JSON/log output.

Evidence after fix: copied terminal output from the current-head temp gateway proof:

proof: temp home=<tmp>/home
proof: child gateway pid=33627
{
  "gateway": {
    "bindMode": "loopback",
    "bindHost": "127.0.0.1",
    "probeUrl": "ws://127.0.0.1:<port>",
    "version": "2026.5.31"
  },
  "rpc": {
    "ok": true,
    "kind": "read",
    "capability": "connected_no_operator_scope",
    "auth": { "role": "operator", "scopes": [], "capability": "connected_no_operator_scope" },
    "version": "2026.5.31",
    "url": "ws://127.0.0.1:<port>"
  },
  "port": {
    "status": "busy",
    "hints": [],
    "listeners": 2
  },
  "service": {
    "loaded": false,
    "runtime": {
      "status": "unknown",
      "detail": "Bad request. Could not find service ai.openclaw.proof.gateway in domain for user gui: 501",
      "missingUnit": true
    },
    "configAuditOk": true
  },
  "extraServices": []
}
proof: gateway log excerpt
[gateway] http server listening (0 plugins, 0.9s)
[ws] ← open remoteAddr=127.0.0.1 ... localAddr=127.0.0.1 localPort=<port>
[ws] ← connect client=gateway-client clientDisplayName=gateway:status version=2026.5.31 mode=backend auth=token
[ws] → hello-ok methods=185 events=27 presence=2 stateVersion=2
[ws] ⇄ res ✓ status 81ms id=<redacted>
[ws] ← connect client=cli version=dev mode=probe clientId=cli platform=darwin auth=token
[ws] → hello-ok methods=185 events=27 presence=3 stateVersion=4

Observed result after fix: the branch gateway bound to strict loopback (127.0.0.1), gateway status --json --require-rpc reached the temp gateway successfully with rpc.ok=true, status reported no port conflict hints (hints: []) for the loopback listener case, and the custom launchd label prevented the proof from relying on the user's installed service.

What was not tested: no real Codex Desktop sandbox was forced to emit loopback EPERM during this proof; the live host-side gateway/status path was exercised with redacted temp state, while focused tests cover the sandbox-false-negative diagnostic classification.

@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes size: S triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 1, 2026
@clawsweeper

clawsweeper Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed June 1, 2026, 4:50 PM ET / 20:50 UTC.

Summary
The branch pins explicit loopback gateway binds to 127.0.0.1, suppresses same-service PID port hints in gateway status, and adds focused gateway/status/port tests.

PR surface: Source +43, Tests +66. Total +109 across 6 files.

Reproducibility: no. high-confidence live sandbox reproduction was run here. The source path is clear: current main can downgrade bind=loopback to 0.0.0.0 after a failed bind probe, and current runtime config rejects that non-loopback result.

Review metrics: 1 noteworthy metric.

  • Gateway Bind Fallback: 1 removed. The PR removes the explicit loopback fallback to 0.0.0.0, which is a compatibility-relevant startup/error behavior change.

Merge readiness
Overall: 🐚 platinum hermit
Proof: 🦞 diamond lobster
Patch quality: 🐚 platinum hermit
Result: ready for maintainer review.

Overall follows the weaker of proof and patch quality, so missing proof can cap an otherwise strong patch.

Rank-up moves:

  • [P2] Get maintainer acceptance of the strict loopback failure-mode tradeoff before merge.

Risk before merge

  • [P2] Merging removes the bind=loopback preflight fallback path, so rare environments where loopback truly cannot bind will see the actual startup/listen failure instead of the current fallback/refusal behavior.
  • [P1] The supplied real proof exercises a host-side temp gateway/status path; the exact Codex Desktop sandbox EPERM false-negative is covered by source inspection and focused tests rather than a forced live sandbox reproduction.

Maintainer options:

  1. Accept Strict Loopback (recommended)
    Land as-is if maintainers agree explicit bind=loopback must always stay on 127.0.0.1 and rare true bind failures should surface at startup/listen time.
  2. Preserve A Compatibility Path
    Revise before merge if maintainers want to keep a fallback or opt-in mode for environments where 127.0.0.1 cannot bind.
  3. Prefer The Narrower PR
    Pause or close this PR if maintainers want only the loopback resolver fix from the narrower open PR and not the additional status diagnostics.

Next step before merge

  • [P2] The remaining action is maintainer acceptance or rejection of the compatibility tradeoff, not a narrow mechanical repair for ClawSweeper to attempt.

Security
Cleared: No concrete security or supply-chain regression was found; the diff does not touch dependencies, workflows, secrets, or package execution paths, and it removes a network-bind fallback for loopback mode.

Review details

Best possible solution:

Land the combined strict-loopback and status-diagnostic fix only after maintainers accept that bind=loopback should never downgrade to a network bind; otherwise use the narrower loopback-only path from #81306 or preserve an explicit compatibility mode.

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

No high-confidence live sandbox reproduction was run here. The source path is clear: current main can downgrade bind=loopback to 0.0.0.0 after a failed bind probe, and current runtime config rejects that non-loopback result.

Is this the best way to solve the issue?

Yes, with a maintainer caveat. The changed owner boundaries are appropriate for gateway bind resolution and daemon status diagnostics, but the stricter loopback failure mode needs explicit maintainer acceptance before merge.

AGENTS.md: found and applied where relevant.

Codex review notes: model gpt-5.5, reasoning high; reviewed against f8d5f162a129.

Label changes

Label justifications:

  • P2: This is a bounded gateway/CLI diagnostics fix with limited blast radius but real compatibility implications.
  • merge-risk: 🚨 compatibility: The diff changes the behavior of explicit loopback bind resolution and its upgrade/startup failure mode.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body supplies redacted terminal output from a real macOS source gateway/status run showing the changed loopback and port-hint behavior, though not a forced live Codex Desktop sandbox EPERM case.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body supplies redacted terminal output from a real macOS source gateway/status run showing the changed loopback and port-hint behavior, though not a forced live Codex Desktop sandbox EPERM case.
Evidence reviewed

PR surface:

Source +43, Tests +66. Total +109 across 6 files.

View PR surface stats
Area Files Added Removed Net
Source 3 51 8 +43
Tests 3 70 4 +66
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 6 121 12 +109

What I checked:

  • PR diff: PR head changes the explicit loopback branch to return 127.0.0.1 without the canBindToHost probe/fallback and adds PID-aware status hint suppression. (src/gateway/net.ts:268, 62014e003d0f)
  • Current main fallback path: Current main still probes 127.0.0.1 for bind=loopback and can return 0.0.0.0 when the probe fails. (src/gateway/net.ts:268, f8d5f162a129)
  • Runtime guard: Current main already rejects a non-loopback resolved host for bind=loopback, so the PR moves the failure toward the actual loopback listen path instead of preserving a working network-bind fallback. (src/gateway/server-runtime-config.ts:68, f8d5f162a129)
  • Status hint path: Current main passes the raw daemon port summary through; the PR adds a narrow suppression only when every listener matches the running gateway service PID and expected bind address. (src/cli/daemon-cli/status.gather.ts:536, f8d5f162a129)
  • Port hint contract: Current main classifies listener hints from command/address shape; the PR adds a separate PID-aware helper rather than weakening the existing generic hint classifier. (src/infra/ports-format.ts:137, f8d5f162a129)
  • Real behavior proof: The PR body includes redacted terminal proof from a macOS source checkout showing strict loopback, successful gateway status --json --require-rpc, and empty same-PID port hints; the current PR labels include proof: sufficient. (62014e003d0f)

Likely related people:

  • Vincent Koc: Blame and recent log entries tie the current gateway bind, daemon status, and port-format surfaces to the same recent mainline commit, though the repository history available here is shallow/squashed. (role: recent area contributor; confidence: medium; commits: a8bc1716ddc6, f8d5f162a129; files: src/gateway/net.ts, src/cli/daemon-cli/status.gather.ts, src/infra/ports-format.ts)
What the crustacean ranks mean
  • 🦀 challenger crab: rare, exceptional readiness with strong proof, clean implementation, and convincing validation.
  • 🦞 diamond lobster: very strong readiness with only minor maintainer review expected.
  • 🐚 platinum hermit: good normal PR, likely mergeable with ordinary maintainer review.
  • 🦐 gold shrimp: useful signal, but proof or patch confidence is still limited.
  • 🦪 silver shellfish: thin signal; proof, validation, or implementation needs work.
  • 🧂 unranked krab: not merge-ready because proof is missing/unusable or there are serious correctness or safety concerns.
  • 🌊 off-meta tidepool: rating does not apply to this item.

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
  • 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.

@clawsweeper clawsweeper Bot added rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. labels Jun 1, 2026
@openclaw-barnacle openclaw-barnacle Bot added proof: supplied External PR includes structured after-fix real behavior proof. and removed triage: needs-real-behavior-proof Candidate: external PR needs after-fix proof from a real setup. labels Jun 1, 2026
@LDMB123

LDMB123 commented Jun 1, 2026

Copy link
Copy Markdown
Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Can't wait for the next one!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@LDMB123

LDMB123 commented Jun 1, 2026

Copy link
Copy Markdown
Author

@clawsweeper re-review

PR body now includes current-head redacted host-side gateway status proof for 548d0d00de: strict loopback bindHost 127.0.0.1, RPC ok true over ws://127.0.0.1:, empty port hints, and custom launchd label proving it did not rely on the installed service.

@clawsweeper

clawsweeper Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@clawsweeper clawsweeper Bot added proof: sufficient ClawSweeper judged the real behavior proof convincing. 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. and removed rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Jun 1, 2026
@openclaw-barnacle openclaw-barnacle Bot removed the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 1, 2026
@LDMB123

LDMB123 commented Jun 1, 2026

Copy link
Copy Markdown
Author

@codex review
@clawsweeper re-review

Rebased onto current upstream main and force-with-lease pushed refreshed head .

Verification after rebase:

RUN v4.1.7 /Users/louisherman/Projects/openclaw-wt-gateway-sandbox

Test Files 1 passed (1)
Tests 18 passed (18)
Start at 06:32:06
Duration 63ms (transform 5ms, setup 0ms, import 10ms, tests 3ms, environment 0ms)

RUN v4.1.7 /Users/louisherman/Projects/openclaw-wt-gateway-sandbox

Test Files 1 passed (1)
Tests 125 passed (125)
Start at 06:32:07
Duration 152ms (transform 60ms, setup 55ms, import 12ms, tests 27ms, environment 0ms)

RUN v4.1.7 /Users/louisherman/Projects/openclaw-wt-gateway-sandbox

Test Files 1 passed (1)
Tests 25 passed (25)
Start at 06:32:09
Duration 282ms (transform 113ms, setup 55ms, import 32ms, tests 137ms, environment 0ms) (18 unit-fast + 125 gateway + 25 CLI tests)

@clawsweeper

clawsweeper Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@LDMB123

LDMB123 commented Jun 1, 2026

Copy link
Copy Markdown
Author

Correction to the previous rebase note: shell backticks in the inline body were interpreted locally before posting.

Actual refreshed head: 0fbb3bba0b.
Verification after rebase:

  • git diff --check
  • node scripts/run-vitest.mjs src/cli/daemon-cli/status.gather.test.ts src/gateway/net.test.ts src/infra/ports-format.test.ts (18 unit-fast + 125 gateway + 25 CLI tests)

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. 🚀

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@openclaw-barnacle openclaw-barnacle Bot added the app: web-ui App: web-ui label Jun 1, 2026
@LDMB123

LDMB123 commented Jun 1, 2026

Copy link
Copy Markdown
Author

@codex review
@clawsweeper re-review

Added the same test-only CI stabilizers already proven on #88911 after the rebase exposed shared upstream CI failures on this PR:

  • media-ui gateway chat refresh expectation alignment
  • watch-node mock child exit handling for file-safety shard completion

Refreshed head: 825bbf686a.
Local verification:

  • node scripts/run-vitest.mjs ui/src/ui/app-gateway.node.test.ts src/infra/watch-node.test.ts (15 infra + 61 UI tests)
  • earlier branch verification after rebase: git diff --check; node scripts/run-vitest.mjs src/cli/daemon-cli/status.gather.test.ts src/gateway/net.test.ts src/infra/ports-format.test.ts (18 unit-fast + 125 gateway + 25 CLI tests)

@clawsweeper

clawsweeper Bot commented Jun 1, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: the existing ClawSweeper review comment will be edited in place when the review finishes.

Re-review progress:

@chatgpt-codex-connector

Copy link
Copy Markdown
Contributor

Codex Review: Didn't find any major issues. Swish!

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@clawsweeper clawsweeper Bot added the proof: sufficient ClawSweeper judged the real behavior proof convincing. label Jun 1, 2026
@LDMB123

LDMB123 commented Jun 1, 2026

Copy link
Copy Markdown
Author

Status check:

  • Current head: 825bbf686af261c626851dbd7bc0460293039d96
  • mergeStateStatus: CLEAN
  • Checks: 162 total, 130 SUCCESS, 31 SKIPPED, 1 NEUTRAL, 0 failing
  • Review threads: none unresolved

I attempted to merge, but GitHub rejected it with: LDMB123 does not have the correct permissions to execute MergePullRequest.

@openclaw-barnacle openclaw-barnacle Bot removed the app: web-ui App: web-ui label Jun 1, 2026
@LDMB123

LDMB123 commented Jun 1, 2026

Copy link
Copy Markdown
Author

Superseded by consolidated fork-main PR #89224, which carries this branch payload on top of current upstream main.

@LDMB123 LDMB123 closed this Jun 1, 2026
@LDMB123
LDMB123 deleted the codex/upstream-gateway-sandbox-diagnostics branch June 1, 2026 21:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes gateway Gateway runtime merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. proof: supplied External PR includes structured after-fix real behavior proof. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: S 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.

1 participant