Repository navigation
fix(cli): gateway health JSON connects before loading presentation code - #115244
Conversation
|
Codex review: needs real behavior proof before merge. Reviewed July 28, 2026, 12:36 PM ET / 16:36 UTC. ClawSweeper reviewWhat this changesThis PR adds a route-first path for Merge readiness⛔ Blocked until real behavior proof is added - 4 items remain Keep this PR open. The proposed JSON-only route appears to preserve the normal text path while removing presentation imports from the successful machine-readable health path, but the current head still lacks the required after-fix live behavior proof and has an unresolved production-typecheck failure in the supplied check state. Likely related people
Priority: P2 Review scores
Verification
How this fits togetherThe CLI command catalog identifies routable commands before the usual Commander command registration finishes loading. For machine-readable Gateway health probes, this PR sends parsed connection options to a small route module, which calls the Gateway and emits JSON; unsuccessful calls and non-JSON output still use the existing diagnostic and presentation paths. flowchart LR
A[CLI arguments] --> B[Command catalog]
B --> C[JSON health route parser]
C --> D[Gateway health route]
D --> E[Gateway RPC]
E --> F[JSON result]
E --> G[Diagnostic error handling]
F --> H[Script or monitor]
G --> H
Before merge
Agent review detailsSecurityNone. PR surfaceSource +171, Tests +227. Total +398 across 9 files. View PR surface stats
Review metrics
Root-cause clusterRelationship: Members:
Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything. Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the focused route-first implementation, add a redacted after-fix exact-head Gateway health transcript or timing artifact that demonstrates earlier connection and unchanged JSON/error behavior, then resolve the production typecheck failure against current Do we have a high-confidence way to reproduce the issue? No high-confidence reproduction was independently run in this review. The linked report gives a concrete loaded-host, SSH-tunneled Gateway scenario and the proposed source path clearly explains how eager imports can delay the first connection. Is this the best way to solve the issue? Yes, provisionally. Routing the already-supported JSON health invocation before presentation loading is narrower than changing Gateway readiness or agent runtime behavior, but it still needs real after-fix proof because it introduces a separate CLI initialization path. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against a88c4283ad48. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rank-up movesOptional improvements that raise the rating; they are not merge blockers.
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (3 earlier review cycles) |
|
@clawsweeper re-review |
|
🦞👀 Command router queued. I will update this comment with the next step. |
|
Merged via squash.
|
…de (openclaw#115244) * fix(gateway): start one-shot CLI clients immediately Closes openclaw#115243 * fix(cli): defer gateway health presentation imports * style(cli): format gateway health loader * test(cli): match gateway health call shape * perf(cli): route gateway health JSON before Commander * fix(cli): preserve routed health output contract * test(cli): match routed JSON indentation * fix(cli): guard routed health config resolution * perf(cli): avoid duplicate health config bootstrap
Closes #115243
What Problem This Solves
openclaw gateway health --jsonspent seconds in local CLI startup before opening its first socket, even when the live Gateway answered the health RPC quickly. This made machine-readable health probes feel unusably slow on a loaded host.Why This Change Was Made
The successful JSON path does not need Commander registration or text health presentation modules. It now uses a JSON-only routed command, while text output and unsupported argument shapes continue through Commander.
Profiling also showed that routing alone was not enough: the route still ran the generic startup config/state guard, then the Gateway call performed the config work it actually owns. The routed JSON health command now follows the existing routed gateway-status ownership pattern and lets the call path perform that single config read. This removes duplicated startup initialization without changing the Gateway, its readiness, the RPC handshake, authentication, payloads, or the text command.
User Impact
Machine-readable Gateway health probes open their connection about a second earlier and complete roughly twice as fast in the measured loaded-host scenario. Text output, invalid-argument handling, local-port projection, authentication diagnostics, and structured transport errors retain their existing paths.
Release note: reduce startup latency for
gateway health --jsonby routing machine-readable probes before duplicate CLI config and presentation initialization.Evidence
cd9895adf0c06422cadaaaf1f90e1f59c423482e: min 2792.8 ms, p50 3521.4 ms, p90 5103.8 mscf967a9c3c91d6cb31096151df6070f7a676600d: min 1375.0 ms, p50 1624.3 ms, p90 2347.0 mssocket.connect: 1891.5 mssocket.connect: 876.3 msgateway_transport_error, WebSocket code 1008, the same top-level JSON keys, and no stdout corruptiongateway healthcompleted successfully, confirming Commander fallback remains intact.PERF_OK_4response with 38,656 prompt-cache read tokenscf967a9c3c91d6cb31096151df6070f7a676600d; package integrity and smoke acceptance succeeded.git diff --check: clean.AI-assisted: yes, with Codex. The investigation used live Gateway and agent-turn timings, V8 CPU profiling, first-socket instrumentation, exact-package A/B runs, focused regression tests, exact-head hosted CI, and full caller/callee inspection. Two plausible fixes were rejected by measurement before the final config-owner boundary produced a stable improvement.