Skip to content

fix(cli): honor gateway --port on the status leaf - #130847

Merged
steipete merged 1 commit into
mainfrom
steipete/gateway-status-port
Aug 27, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/gateway-status-port

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

gateway status was the last RPC sibling that ignored the gateway --port option. openclaw gateway status --port N errored with "unknown option", while openclaw gateway --port N status parsed and then silently reported the config-derived gateway instead of the requested one — the operator reads a status/probe report for the wrong gateway with no indication anything was dropped. This exact invariant (parent options declared on every applicable leaf, both positions honored) has been repaired leaf-by-leaf four times before: #94687 (health/probe), #119046 (call), #126832 (usage-cost/stability), #130513 (logs).

Why This Change Was Made

Rather than a fifth leaf patch, port handling moved into the shared owner: gateway-rpc.ts now exposes the existing auth and local-port resolution to both the gateway and daemon registrations, and one shared status declaration supplies --port to both command groups (daemon status --port N is fixed by the same declaration). Non-default leaf values win over the parent; a leaf default cannot mask an explicit parent value; parsing and --url/--port conflict validation stay owned by gateway-port-option.ts. The refactor deleted the duplicated daemon auth resolver, gateway-local validation, and three empty lazy-loader wrappers (net −5 production LOC). addGatewayClientOptions was deliberately not reused wholesale because it exposes --expect-final, which status cannot implement. Explicit local selection uses the invoking CLI config and remains local when that config selects remote mode; native service details stay diagnostic-only. Both CLI docs updated, including an adjacent incorrect claim about status --url probing.

User Impact

gateway status --port N, gateway --port N status, and daemon status --port N all target the explicitly selected local gateway — summary, port diagnostics, connectivity probe, and the required status RPC included.

Evidence

  • Pre-fix proof: four regression cases failed — both post-leaf forms with unknown option '--port', and the parent form probing wss://127.0.0.1:19001 (service config) instead of the requested ws://127.0.0.1:19002.
  • Post-fix: 489 tests green across 27 files (real gateway/daemon registration, real positional Commander parser, real status runner/gatherer/JSON printer; only host-service and probe transports mocked); focused suites re-run green after rebase onto latest origin/main.
  • Live smoke on a built CLI against a session-owned isolated gateway (port 63734, invoking config pointing at 63735): both option positions, leaf precedence, daemon status, required status RPC, and no-probe JSON all reported the selected port with portSource: cli; five probes rpc.ok: true; gateway stopped cleanly, state removed.
  • Full changed gate exit 0 (typechecks, lint, guards, import cycles); cliStartup build green with bootstrap-import guard. All four historical sibling fixes read; Commander positional parsing and inheritOptionFromParent inspected directly.
  • Fresh Codex autoreview: clean, no accepted/actionable findings.

@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

@openclaw-barnacle openclaw-barnacle Bot added docs Improvements or additions to documentation cli CLI command changes size: M maintainer Maintainer-authored PR labels Aug 27, 2026
@steipete
steipete marked this pull request as ready for review August 27, 2026 08:55
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. 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. labels Aug 27, 2026
@clawsweeper

clawsweeper Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 27, 2026, 5:04 AM ET / 09:04 UTC.

ClawSweeper review

What this changes

The PR makes Gateway and daemon status honor an explicit local Gateway port whether it appears before or after the status subcommand.

Regression provenance

Possible regression — suspected (reviewed change). No predecessor PR is attributed.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this maintainer-owned PR open for normal exact-head CI and maintainer handling. The reviewed source implements the missing leaf option through the shared port resolver, with no blocking correctness finding.

Priority: P2
Reviewed head: aaadcd79f716dda6800599f68e975e29737d3820
Owner decision: Required. See Decision needed.

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The shared repair and boundary coverage are solid; completion of normal exact-head CI remains the merge gate.
Proof confidence 🌊 off-meta tidepool Not applicable: Not applicable to the member-authored PR; its body nevertheless records an isolated built-CLI smoke covering the requested forms.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: Not applicable to the member-authored PR; its body nevertheless records an isolated built-CLI smoke covering the requested forms.
Evidence reviewed 6 items Current-main gap: Current main registers status URL and auth options but not a status-level port option, so the requested leaf form remains absent there.
Shared owner-boundary repair: The branch centralizes parent auth inheritance and local-port resolution, preserving leaf-over-parent precedence and URL/port conflict validation in the existing port module.
Status target propagation: The status gatherer uses an explicit override for target port, loopback host, diagnostic provenance, and the required RPC path while retaining service details as diagnostic-only.
Findings None None.
Security None None.

Live Verification

Command: node scripts/run-vitest.mjs src/cli/daemon-cli/status.gather.test.ts

Result: PASS (completed)

[test] starting test/vitest/vitest.cli.config.ts

 RUN  v4.1.11 /tmp/clawsweeper-live-proof-130847-qbhuLp/target

 ✓  cli  src/cli/daemon-cli/status.gather.test.ts (55 tests | 1 skipped) 281ms

 Test Files  1 passed (1)
      Tests  54 passed | 1 skipped (55)
   Start at  09:04:57
   Duration  5.75s (transform 4.42s, setup 805ms, import 4.37s, tests 281ms, environment 0ms)

[test] passed 1 Vitest shard in 10.69s

Assertions:

  • PASS expect_output: Tests

How this fits together

Gateway and daemon status commands parse operator options, resolve a Gateway endpoint and credentials, then collect service diagnostics and optionally call the Gateway status RPC. The selected endpoint feeds both the diagnostic report and probe result.

flowchart LR
  A[Operator CLI command] --> B[Gateway or daemon status parser]
  B --> C[Port and URL validation]
  C --> D[Local Gateway resolution]
  D --> E[Service diagnostics]
  D --> F[Status RPC probe]
  E --> G[Status output]
  F --> G
Loading

Decision needed

Question Recommendation
Should this maintainer-owned CLI repair be landed once the exact-head checks complete successfully? Land after green checks: Accept the shared status resolver once the queued exact-head checks pass.

Why: The maintainer label and member-authored status require explicit maintainer handling even though no source-level blocker was found.

Before merge

  • Resolve merge risk (P1) - Exact-head checks are still queued or running, so normal CI must complete before landing.
  • Resolve merge risk (P1) - The change relies on Commander option-source behavior; Commander 15 is pinned in the lockfile, but this read-only worktree has no inspectable installed Commander source and could not run pnpm because Corepack could not create its cache directory.
Agent review details

Security

None.

PR surface

Source -5, Tests +125, Docs +5. Total +125 across 11 files.

View PR surface stats
Area Files Added Removed Net
Source 6 76 81 -5
Tests 3 172 47 +125
Docs 2 15 10 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 11 263 138 +125

Review metrics

Metric Value Why it matters
Production versus test delta production +76/-81 (net -5); tests +172/-47 The bug repair absorbs duplicated resolution logic while adding boundary coverage without net production growth.
Status option surface 1 existing --port option added to the shared status declaration This makes the parent Gateway port selection valid at both status leaf positions and for legacy daemon status.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Land the shared resolver and status registration after exact-head CI confirms the existing real-parser coverage on this branch.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Land the shared resolver and status registration after exact-head CI confirms the existing real-parser coverage on this branch.

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

No live current-main reproduction was run because this read-only checkout cannot create Corepack cache state; current main source omits the leaf option and the branch adds real-parser regression coverage for the reported forms.

Is this the best way to solve the issue?

Yes. Moving the shared parent/leaf resolution into the Gateway RPC owner avoids another status-only workaround while preserving the existing port validation boundary.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 1847e9ac9945.

Labels

Label changes:

  • add P2: The defect can make explicit-port status inspect the wrong Gateway, but is limited to CLI status invocations.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to the member-authored PR; its body nevertheless records an isolated built-CLI smoke covering the requested forms.

Label justifications:

  • P2: The defect can make explicit-port status inspect the wrong Gateway, but is limited to CLI status invocations.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: Not applicable to the member-authored PR; its body nevertheless records an isolated built-CLI smoke covering the requested forms.

Evidence

What I checked:

  • Current-main gap: Current main registers status URL and auth options but not a status-level port option, so the requested leaf form remains absent there. (src/cli/daemon-cli/register-service-commands.ts:80, 1847e9ac9945)
  • Shared owner-boundary repair: The branch centralizes parent auth inheritance and local-port resolution, preserving leaf-over-parent precedence and URL/port conflict validation in the existing port module. (src/cli/gateway-rpc.ts:48, aaadcd79f716)
  • Status target propagation: The status gatherer uses an explicit override for target port, loopback host, diagnostic provenance, and the required RPC path while retaining service details as diagnostic-only. (src/cli/daemon-cli/status.gather.ts:605, aaadcd79f716)
  • Boundary-level regression coverage: The added cases exercise actual Gateway and daemon command registration for both option positions, leaf precedence, selected-port probing, and diagnostic-only service targeting. (src/cli/daemon-cli/status.gather.test.ts:499, aaadcd79f716)
  • Feature history: History shows the shared Gateway RPC surface has recently been maintained through prior port-option and transport consolidation work. (src/cli/gateway-rpc.ts:48, 85336be36d26)
  • Release status: No local release tag contains the unmerged PR head; the latest supplied release predates this PR, so it is not already shipped. (aaadcd79f716)

Likely related people:

  • steipete: Authored the current change and the prior shared Gateway port and transport work in the affected RPC owner. (role: recent area contributor; confidence: high; commits: aaadcd79f716, 85336be36d26, 3856b4fa1b35; files: src/cli/gateway-rpc.ts, src/cli/daemon-cli/status.gather.ts)
  • BryanTegomoh: The related merged port-support work established the same parent-and-leaf option invariant for Gateway health and probe. (role: adjacent feature contributor; confidence: medium; commits: 8e4213b1c418; files: src/cli/gateway-rpc.ts, src/cli/gateway-cli/register.ts)

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Let the queued exact-head checks complete before landing.

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
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.

Workflow

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

@steipete
steipete merged commit d3aa4be into main Aug 27, 2026
277 checks passed
@steipete
steipete deleted the steipete/gateway-status-port branch August 27, 2026 09:24
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: M 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