Skip to content

fix(cli): accept --port across automation commands - #125474

Merged
steipete merged 1 commit into
mainfrom
steipete/cron-add-port-flag
Aug 18, 2026
Merged

steipete merged 1 commit into
mainfrom
steipete/cron-add-port-flag

Conversation

@steipete

Copy link
Copy Markdown
Contributor

What Problem This Solves

Fixes an issue where users targeting a non-default local Gateway port from openclaw automations would get OpenClaw does not recognize option "--port", even though the automation commands are Gateway-backed and sibling Gateway commands support local port selection. Shared connection flags also only worked after the leaf subcommand, so parent placement such as automations --token ... list was rejected.

Why This Change Was Made

The shared Gateway CLI option owner now registers and projects --port, while the cron|automations parent declares the same connection options as every Gateway-backed leaf and inherits only non-default parent values. The canonical Gateway connection resolver now treats an explicit local port as authoritative over configured remote URLs and local auth selection, which allowed removal of the older Gateway CLI workaround that rewrote config into local mode.

User Impact

Operators can place --port, --url, --token, --password, --timeout, and --expect-final before or after every automation leaf command. --port <port> reliably selects that local Gateway even when the active profile is configured for a remote Gateway; combining --url and --port fails explicitly.

Evidence

  • Before: openclaw automations add ... --port 65267 --json exited 1 with OpenClaw does not recognize option "--port".
  • Regression-first parser proof: the new real-Commander matrix failed 25 cases on the pre-fix tree, then passed for all 12 Gateway-backed leaves in both parent and leaf positions, including leaf-over-parent precedence.
  • Owner-boundary reproduction: a remote-mode config plus localPortOverride: 19082 incorrectly selected wss://gateway.example/ws before the fix; it now selects ws://127.0.0.1:19082.
  • Source-blind CLI proof: both automations --port 1 status and automations status --port 1 reached ws://127.0.0.1:1 and reported ECONNREFUSED, rather than an unknown-option or configured-remote error. --url plus --port returned the explicit conflict error. No automation state changed.
  • Focused tests: 5 files, 387 tests passed across automation parsing, shared Gateway RPC options, Gateway CLI option collisions, bootstrap, and canonical connection resolution.
  • OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/check-changed.mjs -- <13 changed paths> passed the full core/coreTests/docs plan.
  • pnpm docs:check-mdx passed 776 files; pnpm docs:check-links checked 6,518 internal links with 0 broken.
  • .claude/skills/autoreview/scripts/autoreview --mode uncommitted reported clean with no accepted/actionable findings.
  • LOC: production +52/-22 (net +30); tests +140/-12; docs +5/-0. Production growth is the shared local-port capability and parent inheritance; the obsolete per-command config rewrite was removed.
  • Changelog intentionally unchanged per the maintainer work order.

@clawsweeper

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

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

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

clawsweeper Bot commented Aug 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 17, 2026, 8:34 PM ET / August 18, 2026, 00:34 UTC.

ClawSweeper review

What this changes

The PR adds shared Gateway connection flags to automation commands, accepts them before or after every leaf command, and makes an explicit local port override a configured remote Gateway target.

Merge readiness

⚠️ Ready for maintainer review - 3 items remain

Keep this PR open: current main still lacks automation-level --port parsing and the canonical remote-to-local selection adjustment. The patch follows the repository’s required parent-option inheritance pattern and has no blocking correctness finding; exact-head checks are still running.

Priority: P2
Reviewed head: 5d77832d0abfa7dfc610596f44886cf902a928b9

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch has focused source and terminal proof with broad parser coverage; remaining work is normal exact-head integration validation.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (terminal): The PR body provides after-fix source-blind terminal evidence that both option positions reach the requested loopback port and that --url plus --port fails explicitly.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (terminal): The PR body provides after-fix source-blind terminal evidence that both option positions reach the requested loopback port and that --url plus --port fails explicitly.
Evidence reviewed 6 items Current-main gap: Current main registers shared Gateway URL, token, password, timeout, and final-response flags, but not a port; its automation parent also declares no shared connection flags.
Canonical repair path: The branch adds the shared port option, projects it once in the Gateway runtime, and makes explicit local-port selection authoritative over remote-mode target resolution and auth-surface selection.
Parser and sibling coverage: The added Commander parser matrix covers all 12 Gateway-backed automation leaves in parent and leaf positions, including leaf precedence; Gateway resolution tests cover remote-config bypass.
Findings None None.
Security None None.

How this fits together

Automation CLI commands send schedule-management requests to the Gateway. Their connection flags are parsed by the CLI, then the shared Gateway client selects the endpoint and appropriate authentication surface before sending the request.

flowchart LR
  A[Automation command] --> B[Shared connection flags]
  B --> C[Parent and leaf option parsing]
  C --> D[Gateway client runtime]
  D --> E[Local or remote target resolution]
  E --> F[Automation Gateway request]
Loading

Before merge

  • Resolve merge risk (P1) - The repair has production +52/-22 lines (net +30); the added parent projection and canonical resolver translation are warranted because no existing shared parent-to-leaf Gateway-option adapter covers this CLI boundary.
  • Resolve merge risk (P1) - The branch is behind current main and exact-head checks remain in progress, so it needs the normal integration refresh if GitHub requires one before landing.
  • Complete next step (P2) - No repair lane is needed: no concrete defect was found, and completing normal exact-head checks is not an automated code-repair task.
Agent review details

Security

None.

PR surface

Source +30, Tests +128, Docs +5. Total +163 across 13 files.

View PR surface stats
Area Files Added Removed Net
Source 8 52 22 +30
Tests 4 140 12 +128
Docs 1 5 0 +5
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 13 197 34 +163

Review metrics

Metric Value Why it matters
Production versus test LOC production +52/-22 (net +30); tests +140/-12; docs +5/-0 The bug fix adds a shared parser-to-resolver path while removing the prior Gateway CLI config rewrite; the test increase exercises parsing and target selection.
Gateway connection option 1 shared flag added; 12 automation leaves covered --port selects a local Gateway even when a profile is configured for a remote target, so its endpoint-selection behavior merits review.

Merge-risk options

Maintainer options:

  1. Decide the mitigation before merge
    Retain the single localPortOverride path through the shared Gateway resolver and land once exact-head checks complete; the obsolete per-command config rewrite should stay removed.
  2. Pause or close
    Do not merge this PR until maintainers decide whether the risk is worth taking.

Technical review

Best possible solution:

Retain the single localPortOverride path through the shared Gateway resolver and land once exact-head checks complete; the obsolete per-command config rewrite should stay removed.

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

Yes—source-reproducible: current main omits --port from shared Gateway flags and provides no automation-parent inheritance path. Local execution could not be rerun because Corepack attempted to create its cache on the read-only filesystem.

Is this the best way to solve the issue?

Yes. The patch fixes parsing at the shared option owner and resolves local-port selection in the canonical Gateway client path rather than preserving the prior per-command config rewrite.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 7e998a367f6a.

Labels

Label changes:

  • add P2: This is a bounded automation CLI defect with a clear repair and limited blast radius.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix source-blind terminal evidence that both option positions reach the requested loopback port and that --url plus --port fails explicitly.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (terminal): The PR body provides after-fix source-blind terminal evidence that both option positions reach the requested loopback port and that --url plus --port fails explicitly.

Label justifications:

  • P2: This is a bounded automation CLI defect with a clear repair and limited blast radius.
  • 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 provides after-fix source-blind terminal evidence that both option positions reach the requested loopback port and that --url plus --port fails explicitly.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix source-blind terminal evidence that both option positions reach the requested loopback port and that --url plus --port fails explicitly.

Evidence

What I checked:

  • Current-main gap: Current main registers shared Gateway URL, token, password, timeout, and final-response flags, but not a port; its automation parent also declares no shared connection flags. (src/cli/gateway-rpc.ts:24, 7e998a367f6a)
  • Canonical repair path: The branch adds the shared port option, projects it once in the Gateway runtime, and makes explicit local-port selection authoritative over remote-mode target resolution and auth-surface selection. (src/cli/gateway-rpc.runtime.ts:40, 5d77832d0abf)
  • Parser and sibling coverage: The added Commander parser matrix covers all 12 Gateway-backed automation leaves in parent and leaf positions, including leaf precedence; Gateway resolution tests cover remote-config bypass. (src/cli/cron-cli.test.ts:365, 5d77832d0abf)
  • Documentation alignment: The CLI reference accurately documents the new local-port versus explicit-URL conflict and both supported flag positions. Public docs: docs/cli/cron.md. (docs/cli/cron.md:21, 5d77832d0abf)
  • Feature history: The automation alias dates to the merged alias work, making its author an adjacent historical owner; current Gateway transport and connection history is predominantly maintained by steipete. (src/cli/cron-cli/register.ts:20, b82a59a7987b)
  • Diff hygiene: The focused declared PR paths have no whitespace errors. (src/cli/cron-cli/register.ts:49, 5d77832d0abf)

Likely related people:

  • steipete: Recent main history contains the Gateway transport unification and connection-resolution refactors as well as this repair. (role: recent area contributor; confidence: high; commits: 3856b4fa1b35, 52a76313e8c2, 5d77832d0abf; files: src/cli/gateway-rpc.ts, src/gateway/call.ts, src/gateway/client-bootstrap.ts)
  • Omar Shahine: The merged automation-alias change is the nearby historical command-surface introduction. (role: introduced automation alias; confidence: medium; commits: b82a59a7987b; files: src/cli/cron-cli/register.ts, docs/cli/cron.md)

Rank-up moves

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

  • Let the remaining exact-head checks complete, then refresh against main only if GitHub requires it.

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

Copy link
Copy Markdown
Contributor Author

Land-ready verification for 5d77832d0abfa7dfc610596f44886cf902a928b9:

  • Root cause: the automation parent did not declare shared Gateway options, the shared option owner omitted --port, and the canonical connection resolver let configured remote URLs outrank an explicit local port.
  • Canonical fix: register --port with shared Gateway options; inherit only non-default automation parent options into every Gateway-backed leaf; make localPortOverride authoritative in Gateway connection/bootstrap ownership; remove the older Gateway CLI config-rewrite workaround.
  • Focused proof: node scripts/run-vitest.mjs src/gateway/call.test.ts src/gateway/client-bootstrap.test.ts src/cli/gateway-cli/register.option-collisions.test.ts src/cli/gateway-rpc.runtime.test.ts src/cli/cron-cli.test.ts --reporter=dot — 5 files, 387 tests passed.
  • Changed gate: OPENCLAW_HEAVY_CHECK_LOCK_SCOPE=worktree node scripts/check-changed.mjs -- <13 changed paths> — core, coreTests, and docs plan passed.
  • Docs: pnpm docs:check-mdx passed 776 files; pnpm docs:check-links checked 6,518 links with 0 broken.
  • Behavior: source-blind parent/leaf placement probes both selected ws://127.0.0.1:1; combined --url/--port failed explicitly; no automation state changed.
  • Review: fresh uncommitted autoreview clean; native review artifacts validated READY FOR /prepare-pr with 0 findings.
  • CI: exact-head run 32084507361 is green.
  • LOC: production +52/-22, tests +140/-12, docs +5/-0.

ClawSweeper skip state: the latest comment is still the review started placeholder from 2026-08-18 00:30:42 UTC, so no Rank-up moves: have been published to apply or skip individually. This is the only remaining proof gap; a late publisher update is non-blocking under the repository policy, and I will re-read it immediately before merge.

@steipete
steipete merged commit 85336be into main Aug 18, 2026
281 checks passed
@steipete
steipete deleted the steipete/cron-add-port-flag branch August 18, 2026 00:39
@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 gateway Gateway runtime maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. 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