Skip to content

refactor(cli): unify gateway RPC transport - #117601

Merged
steipete merged 1 commit into
mainfrom
codex/goal100k-gateway-owner-wave4
Aug 1, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/goal100k-gateway-owner-wave4

Conversation

@steipete

@steipete steipete commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

Gateway-facing CLI flows had accumulated three parallel RPC transports and a redundant credential bridge. Their copies were already drifting in timeout defaults, progress labels, stored-device credentials, local backend auth, config overrides, and connection setup, making future transport and security changes easy to apply inconsistently.

Why This Change Was Made

All CLI-to-Gateway RPC calls now use one lazy transport owner while retaining each caller's explicit timeout, client identity, scopes, progress, and auth behavior. Callers now use the canonical credential resolver directly, and the two approval clients use the shared deferred primitive instead of local first-settlement state machines.

Removed paths:

  • src/cli/gateway-cli/call.ts
  • src/cli/nodes-cli/rpc.runtime.ts
  • src/gateway/connection-auth.ts

The public callGatewayFromCli signature and Plugin SDK exports remain unchanged. No configuration, protocol, schema, dependency, or user-visible command surface changes.

User Impact

No intended user-visible behavior change. Gateway CLI, nodes, devices, session compaction, health checks, node-host startup, and approval handling retain their existing flags, output, authentication precedence, cancellation, timeout, and reconnect behavior with less duplicate production code.

Production LOC: -167 (+153/-320). Tests: +44. Repository total: -123 (+229/-352).

Evidence

  • 276 focused tests passed across CLI, Gateway, credentials, node-host, approval runtime, and real Gateway operator-approval E2E coverage.
  • Full remote pnpm check:changed passed on exact commit a0e337b556a1ed518a2117bddadc94b49c34f2be (19m42s), including core/core-test typechecks, formatting, lint fan-out, dead-export scan, import-cycle guard, plugin boundaries, and Plugin SDK API baseline.
  • Full remote pnpm build passed on the same commit (2m55s), including all 148 public Plugin SDK subpaths and CLI cold-bootstrap import guard.
  • Synthetic no-commit merge into then-current origin/main (c5090b9cf503afebc01a20bc47ac9309d4b3a3e2) completed without conflicts.

No changelog entry: this is an internal refactor with unchanged shipped behavior.

@steipete
steipete requested a review from a team as a code owner August 1, 2026 19:42
@openclaw-barnacle openclaw-barnacle Bot added gateway Gateway runtime cli CLI command changes commands Command implementations size: L maintainer Maintainer-authored PR labels Aug 1, 2026
@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. P2 Normal backlog priority with limited blast radius. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. labels Aug 1, 2026
@clawsweeper

clawsweeper Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 3:49 PM ET / 19:49 UTC.

ClawSweeper review

What this changes

The branch routes Gateway-facing CLI RPCs through one lazy shared transport, removes duplicate node and gateway wrappers, and uses the canonical credential resolver and deferred readiness helper.

Merge readiness

⚠️ Ready for maintainer review - 2 items remain

The refactor appears correct: it centralizes duplicated Gateway CLI transport code while preserving each caller’s timeout, progress, authorization, and client-identity policy. Keep this PR open for the protected maintainer workflow and completion of the in-progress exact-head checks.

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

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) The patch is focused and net-reductive with meaningful behavior and build evidence; the remaining work is protected-label handling and completion of exact-head checks.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body reports focused runtime and operator-approval E2E coverage plus successful remote changed checks and build on the exact head; the supplied real-behavior-proof check also succeeded.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The PR body reports focused runtime and operator-approval E2E coverage plus successful remote changed checks and build on the exact head; the supplied real-behavior-proof check also succeeded.
Evidence reviewed 6 items Transport policy preservation: The shared runtime forwards config, credentials, timeout overrides, local-port overrides, scopes, stored-device authorization, backend shared authorization, client identity, and progress settings to the existing Gateway call owner.
Node caller contract: The node facade retains its invoke-deadline extension, diagnostics fallback order, backend client identity, and approval-method validation while delegating only the common transport.
Readiness first-settlement contract: The replacement deferred helper is a native Promise.withResolvers wrapper, and a direct runtime probe confirmed that a late rejection does not replace an earlier resolution.
Findings None None.
Security None None.

How this fits together

Gateway-facing CLI commands attach command-specific timeout, progress, credentials, scopes, and client identity before sending RPCs to the Gateway. The shared CLI transport then invokes the existing Gateway client and returns command output or approval readiness.

flowchart LR
  A[Gateway CLI commands] --> B[Shared CLI RPC facade]
  C[Node and device commands] --> B
  B --> D[Timeout progress and auth policy]
  D --> E[Gateway call]
  E --> F[Gateway RPC response]
  F --> G[CLI output and approvals]
Loading

Decision needed

Question Recommendation
Should this protected maintainer-labeled Gateway and CLI refactor merge after exact-head checks complete, or should it first be refreshed against the newest main commit? Merge after checks: Merge once the in-progress required checks finish successfully for the reviewed head or its clean refreshed merge result.

Why: No discrete source-level defect was found, but the protected label and in-progress checks require an explicit maintainer merge decision.

Before merge

  • Resolve merge risk (P1) - The branch is behind current main and required checks are still in progress, so merge should wait for the reviewed head or a refreshed merge result to finish validation.
Agent review details

Security

None.

PR surface

Source -167, Tests +44. Total -123 across 23 files.

View PR surface stats
Area Files Added Removed Net
Source 14 153 320 -167
Tests 9 76 32 +44
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 23 229 352 -123

Review metrics

None.

Stored data model

Persistent data-model change detected: serialized state: src/commands/sessions-compact.test.ts, serialized state: src/commands/sessions-compact.ts. Confirm migration or upgrade compatibility proof before merge.

Merge-risk options

Maintainer options:

  1. Validate the exact merge result (recommended)
    Let the current required checks finish or refresh the branch and re-run them so CLI and authorization behavior is proved on the final merge result.
  2. Accept the already supplied proof
    A maintainer may choose to merge based on the existing remote build and focused Gateway evidence despite the branch being behind main.

Technical review

Best possible solution:

Keep one lazy CLI transport owner and preserve each caller’s explicit timeout, progress, authorization, and client-identity policy; merge after exact-head validation is complete.

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

Not applicable: this PR is an internal behavior-preserving refactor. The relevant verification is source and regression coverage for the existing caller contracts.

Is this the best way to solve the issue?

Yes. The existing lazy CLI Gateway facade is the appropriate canonical boundary because command-specific policy remains at the callers while transport implementation is unified.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 26aa884c6914.

Labels

Label changes:

  • add P2: A shared Gateway CLI transport refactor can affect operator commands but no confirmed user-facing regression is present.
  • add merge-risk: 🚨 compatibility: Several existing CLI command families now share one transport implementation, so a missed caller-specific setting could change behavior after upgrade.
  • add merge-risk: 🚨 auth-provider: The centralized transport now carries stored-device and local backend authorization settings that determine Gateway credential behavior.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports focused runtime and operator-approval E2E coverage plus successful remote changed checks and build on the exact head; the supplied real-behavior-proof check also succeeded.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports focused runtime and operator-approval E2E coverage plus successful remote changed checks and build on the exact head; the supplied real-behavior-proof check also succeeded.

Label justifications:

  • P2: A shared Gateway CLI transport refactor can affect operator commands but no confirmed user-facing regression is present.
  • merge-risk: 🚨 compatibility: Several existing CLI command families now share one transport implementation, so a missed caller-specific setting could change behavior after upgrade.
  • merge-risk: 🚨 auth-provider: The centralized transport now carries stored-device and local backend authorization settings that determine Gateway credential behavior.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🐚 platinum hermit and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The PR body reports focused runtime and operator-approval E2E coverage plus successful remote changed checks and build on the exact head; the supplied real-behavior-proof check also succeeded.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body reports focused runtime and operator-approval E2E coverage plus successful remote changed checks and build on the exact head; the supplied real-behavior-proof check also succeeded.

Evidence

What I checked:

  • Transport policy preservation: The shared runtime forwards config, credentials, timeout overrides, local-port overrides, scopes, stored-device authorization, backend shared authorization, client identity, and progress settings to the existing Gateway call owner. (src/cli/gateway-rpc.runtime.ts:46, a0e337b556a1)
  • Node caller contract: The node facade retains its invoke-deadline extension, diagnostics fallback order, backend client identity, and approval-method validation while delegating only the common transport. (src/cli/nodes-cli/rpc.ts:106, a0e337b556a1)
  • Readiness first-settlement contract: The replacement deferred helper is a native Promise.withResolvers wrapper, and a direct runtime probe confirmed that a late rejection does not replace an earlier resolution. (src/shared/deferred.ts:13, aa2a5c96f69a)
  • Focused coverage: The branch adds tests for caller-specific timeout defaults and specialized authorization context, complementing existing node and operator-approval tests. (src/cli/gateway-rpc.runtime.test.ts:56, a0e337b556a1)
  • Source provenance: Current-main blame attributes the pre-refactor shared CLI transport and operator approval readiness code to Peter Steinberger, identifying the relevant owner boundary. (src/cli/gateway-rpc.runtime.ts:23, aa2a5c96f69a)
  • Current-main integration: No commits after the PR merge base touched the central transport, node RPC, credential bridge, or approval runtime paths; supplied GitHub state reports a clean merge but the branch is behind main. (src/cli/gateway-rpc.runtime.ts:23, 26aa884c6914)

Likely related people:

  • Peter Steinberger: Current-main blame attributes the shared CLI transport and operator approval readiness implementation to this author. (role: current transport and approval-path owner; confidence: high; commits: aa2a5c96f69a; files: src/cli/gateway-rpc.runtime.ts, src/gateway/operator-approvals-client.ts, src/shared/deferred.ts)
  • Dallin Romney: Local history attributes the earlier consolidation of shared deferred construction to this author. (role: shared deferred primitive introducer; confidence: medium; commits: 80d129212cf8; files: src/shared/deferred.ts)

Rank-up moves

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

  • Wait for the in-progress required checks to complete on the reviewed head or a refreshed clean merge result.

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 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor Author

ClawSweeper rank-up move completed: all exact-head hosted checks have finished with zero failures, and gh pr checks 117601 --required exits successfully on reviewed head a0e337b556a1ed518a2117bddadc94b49c34f2be.

@steipete steipete self-assigned this Aug 1, 2026
@steipete
steipete merged commit 3856b4f into main Aug 1, 2026
133 of 147 checks passed
@steipete
steipete deleted the codex/goal100k-gateway-owner-wave4 branch August 1, 2026 21:06
@steipete

steipete commented Aug 1, 2026

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 commands Command implementations gateway Gateway runtime maintainer Maintainer-authored PR merge-risk: 🚨 auth-provider 🚨 May break OAuth, tokens, provider routing, model choice, or credentials. 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. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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