Repository navigation
perf(cli): keep read-only commands on cold paths - #117932
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 2, 2026, 5:37 AM ET / 09:37 UTC. ClawSweeper reviewWhat this changesThe branch keeps nine read-only CLI commands cold by skipping unnecessary plugin validation and loading, reusing a single plugin metadata snapshot for channel listings, and returning the first Merge readinessThis PR remains necessary: it extends the recently merged CLI cold-path work to additional read-only commands and removes command-local metadata rediscovery. The manifest-first snapshot design matches the repository’s hot-path guidance, and no concrete patch defect was established, but the Priority: P2 Review scores
Verification
How this fits togetherThe CLI’s startup policy decides whether a command performs local config and plugin work before dispatching to a local projection or the running Gateway. This PR keeps read-only commands on manifest-backed control-plane data and lets the Gateway own cached usage-summary refreshes. flowchart LR
CLI[Read-only CLI command] --> Policy[Startup policy]
Policy --> Config[Core config projection]
Config --> Metadata[Plugin metadata snapshot]
Metadata --> Local[Local list or status projection]
Gateway[Gateway RPC] --> Usage[Usage summary]
Local --> Output[JSON or text output]
Usage --> Output
Decision needed
Why: This is an operator-visible compatibility choice: the branch intentionally changes latency and freshness semantics, and supported high-volume all-agent deployments determine whether the shorter default is safe. Before merge
Agent review detailsSecurityNone. PR surfaceSource +26, Tests +282. Total +308 across 30 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Merge only after a maintainer confirms the one-RPC usage-cost timeout behavior is acceptable for supported all-agent deployments and a reviewer with the sibling Codex checkout verifies the lazy runtime-availability contract; otherwise retain the manifest-first cold-path changes and narrow only the affected command behavior. Do we have a high-confidence way to reproduce the issue? Yes for the code-path change: current main polls Is this the best way to solve the issue? Mostly yes: the prepared metadata snapshot follows the repository’s manifest-first, process-stable metadata model, but the shorter usage-cost default timeout and Codex runtime contract need explicit confirmation before this is the best complete solution. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c4810336d575. LabelsLabel changes:
Label 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
|
|
Maintainer landing review resolved the ClawSweeper rank-up moves on head
Exact-head CI run 30741974645 passed 70/70 jobs. No code or changelog changes were made during landing review. |
|
Merged via squash.
|
* origin/main: (59 commits) fix(agents): reject false success from delegated file mutations (openclaw#117938) fix(macos): reopen AI choice, fix daemon error text, hand onboarding off to the dashboard custodian (openclaw#117921) fix(qa): tolerate expected Matrix sync long-poll deadlines (openclaw#117807) feat(cli): support --json across reporting commands (openclaw#117928) perf(cli): keep read-only commands on cold paths (openclaw#117932) fix: prevent fractional chunk limits from stalling text splitting (openclaw#117727) fix(qqbot): add heartbeat-ACK liveness watchdog (openclaw#114902) chore(openai): defer release note to release flow fix(pr): join worktree discovery subprocesses test(gateway): widen aggregate event-loop budget (openclaw#117931) fix: refresh Buzz room targets after reconnect (openclaw#117927) fix: invalidate removed Buzz mention members fix: align Buzz explicit mention semantics test: split Buzz mention delivery coverage fix: preserve Buzz reply session threads refactor: keep Buzz mention helpers internal fix: invalidate stale Buzz room targets fix: tighten Buzz mention disambiguation perf: keep Buzz plain sends on the fast path fix: reject unresolved Buzz mention text ...
* perf(cli): keep read-only commands on cold paths * perf(channels): reuse list metadata snapshot
What Problem This Solves
A full read-only CLI sweep on a production host (48 cores, ~150 installed plugins, warm jiti cache) found nine commands taking 9.7–48 s that should take about a second:
gateway usage-cost --days 1 --jsonchannels list --jsonmodels status --jsonapprovals pending --jsonskills list --jsonagents bindings --jsonskills check --jsongateway stability --jsoncommitments --jsonBaselines on the same host:
openclaw --version43 ms,gateway call health1.83 s,sessions --json2.06 s,channels status --json1.16 s.CPU profiles showed the familiar plugin-module load storm (jiti ~2.5 s,
package_json_reader~0.9 s, compile/vm ~1 s) — plus, forchannels list, an additional ~5.7 s of filesystem walking (lstat 3.8 s). And a decisive measurement forusage-cost: the underlying RPCgateway call usage.cost --params '{"days":1}'returned in 1.77 s while the CLI command took 48.2 s.This continues the cold-path work in #117705 / #117751 / #117880 / #117900.
Why This Change Was Made
Each command was audited rather than blanket-patched, and two of them turned out not to be another catalog-declaration bug:
Startup declarations (6 commands).
approvals pendingandgateway stabilityare gateway RPC reads → skip config validation and plugin loading.agents bindingsis a local config projection → still reads config, skips plugin validation (route bindings do not consume plugin runtime).commitmentsreads the shared SQLite store → its unnecessary config load was removed outright.skills list/checkgenuinely need skill/manifest metadata → they skip plugin config validation while keeping the gateway-first, manifest fallback; no plugin module execution.channels list(17.2 s) — declaration was already effective. The real costs were command-local:requireValidConfigperformed plugin validation; JSON listing entered setup-backed fallback logic meant for human credential/status output; and manifest projection, trusted-catalog construction, and installed-ID calculation each rediscovered the same plugin filesystem graph. JSON now stays on manifest-backed projections and one immutable metadata snapshot is carried into the read-only channel plugin reader, trusted catalog, and discovery. Human text output keeps setup-backed snapshots, because removing them would change credential/status output.Notably, the cross-dispatch parity guard added in #117880 could not have caught this: it proves both resolvers interpret the catalog identically, not that a command-local path is cold. The new fixtures close that gap by executing the real route.
models status(15.3 s) — also command-local.loadModelsConfigre-ran plugin validation inside the command; status eagerly imported payload-validation support; and catalog ownership rediscovered providers broadly. The non-probe path now skips plugin validation, imports payload smoke validation only inside actual Codex runtime-availability evaluation, and carries the complete provider/auth use set into the prepared catalog owner.--probedeliberately keeps full validation and live provider probing.gateway usage-cost(48.2 s) — not startup at all. The CLI was pollingusage.cost, waiting forcacheStatusto become fresh, with reconnect and exponential delay. The gateway intentionally serves cached/in-flight summaries and owns background refresh, and cross-agent aggregation is server-side. The CLI now performs exactly oneusage.costRPC and renders the response.Per the repository's Codex gate, the sibling Codex contract was inspected directly for the
models statuschange:account/readin../codex/codex-rs/app-server-protocol/src/protocol/common.rs:1192, dispatch at../codex/codex-rs/app-server/src/message_processor.rs:1372, and account state ownership at../codex/codex-rs/app-server/src/request_processors/account_processor.rs:121,1010. The lazy payload check and provider scoping do not alter it.User Impact
gateway usage-costchannels listmodels statusapprovals pendingskills list/checkagents bindingsgateway stabilitycommitments*no local gateway service was available, so these measure full cold startup plus the failure path rather than live RPC latency; the one-RPC assertions are the behavioral proof forusage-cost. On a comparable local bundled-catalog repro,channels listwent 9.71 s → 3.12 s andmodels status10.91 s → 3.92 s (1.04 s / 1.46 s with bundled plugins disabled). This checkout cannot reproduce the host's ~150-plugin topology, so the real-route module markers are the scale-independent proof.No output shapes changed;
--probeand human rendering paths are preserved.Evidence
src/clidirectory composition has known order-dependent contamination).channels list --json/models status --jsonroutes, verify output, and prove the runtime never executed.usage.costcall across fresh, refreshing, and stale cache-status responses.pnpm tsgo:core,pnpm build(2m50s, CLI bootstrap guard, no[INEFFECTIVE_DYNAMIC_IMPORT]),git diff --check: passed.gpt-5.6-sol, high): clean, correctness 0.99, no actionable findings.+173/-147(net +26 — a prepared-metadata ownership seam replacing repeated filesystem discovery); tests net +282.