Skip to content

fix(cli): keep channels status route cold - #117751

Merged
steipete merged 1 commit into
mainfrom
codex/fix-channels-status-eager-load
Aug 2, 2026
Merged

steipete merged 1 commit into
mainfrom
codex/fix-channels-status-eager-load

Conversation

@steipete

@steipete steipete commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

What Problem This Solves

openclaw channels status --json still took ~10 s in production after #117705, which was supposed to make its JSON success path cold. Measured on the production team host running a dist that contains #117705: 9878 ms and 9839 ms on consecutive runs, with a CPU profile showing the identical plugin-module load storm as before that fix (jiti 2579 ms, package_json_reader 924 ms, lstat 604 ms, compile+vm ~980 ms).

Why This Change Was Made

The CLI has two dispatch paths, and #117705 covered only one. Commander's pre-action hook consults bypassConfigGuard — that half worked (the openclaw agent improvement is live in production). But channels status is a route-first command: run-main.ts → route.ts → command-bootstrap.ts → config-guard.ts, and routed commands derive their startup policy from routeConfigGuard, which the entry never set. So the routed path still ran the doctor/config preflight, which reaches state migrations and plugin validation — the ~10 s storm.

The prior cold-import guard passed while production stayed slow because it called channelsStatusCommand directly, bypassing routing and bootstrap entirely — it proved only that the runtime module stayed lazy after a successful gateway response, not that the real path was cold.

The fix is one production line: routeConfigGuard: "always" on the ["channels", "status"] catalog entry (the same policy every other cold routed command already declares). The replacement guard test drives the real tryRouteCli wiring for JSON status with and without --probe, asserts neither the config guard nor the status runtime loads, and fails on the config-guard sentinel if the production line is reverted. The test deliberately never clears the module-load marker set, so an eager import introduced anywhere in the route's own static import graph is also caught (a first review round found that clearing it in beforeEach would have erased exactly that evidence).

Text rendering and the unreachable-gateway fallback still load status.runtime.ts on demand; command matching is unchanged.

User Impact

openclaw channels status --json (success path) drops from ~10 s to sub-second. Local reachable-gateway measurements: 5.45 s / 5.33 s before → 0.69 s / 0.68 s / 0.68 s after, with startup tracing emitting no config/migration stages.

Evidence

  • Task-focused CLI and command tests: 63/63 passed; startup/route policy suite: 151/151 passed; the new guard test passes and fails on revert of the production line.
  • pnpm build passed; no [INEFFECTIVE_DYNAMIC_IMPORT].
  • Autoreview (Codex gpt-5.6-sol, high): first round found the guard-evidence hole (fixed); final round clean, "patch is correct" (0.93).
  • Production LOC delta: +1. Tests: 73 insertions, 49 deletions (replacement of the bypassed-seam test).

Known context: one unrelated logs-fixture test is nondeterministic on the branch base and already fixed upstream (2649903); not mixed into this change.

@openclaw-barnacle openclaw-barnacle Bot added cli CLI command changes commands Command implementations size: S maintainer Maintainer-authored PR labels Aug 2, 2026
@steipete steipete self-assigned this Aug 2, 2026
@steipete
steipete marked this pull request as ready for review August 2, 2026 02:28
@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. labels Aug 2, 2026
@clawsweeper

clawsweeper Bot commented Aug 2, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 10:34 PM ET / August 2, 2026, 02:34 UTC.

ClawSweeper review

What this changes

This PR makes route-first openclaw channels status skip the local config guard and replaces a direct command test with a regression test that drives the real CLI routing path.

Merge readiness

⚠️ Ready for maintainer review - 1 item remains

This PR remains necessary: current main still gives the route-first channels status entry the default route config-guard policy, so it can load the local preflight before making the Gateway request. The proposed one-line catalog policy aligns route-first dispatch with the existing Commander-path bypass and the replacement test exercises the real routing boundary. The maintainer label requires explicit human merge handling, so this review does not recommend an automated close or repair lane.

Priority: P2
Reviewed head: 39878b2d332ee0c1e2a7094b3ed3c57ef5f7857c

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary fix with route-level regression coverage and concrete after-fix command measurements; no actionable correctness or security finding was identified.
Proof confidence 🐚 platinum hermit (4/6) Sufficient (live_output): The PR body provides after-fix reachable-Gateway timing and startup-trace results for the exact command, alongside a route-level regression test; the supplied check context also reports the Real behavior proof check as successful.
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 provides after-fix reachable-Gateway timing and startup-trace results for the exact command, alongside a route-level regression test; the supplied check context also reports the Real behavior proof check as successful.
Evidence reviewed 8 items Current-main gap: Current main has bypassConfigGuard: true for channels status but no route policy override; the default route policy is never, so route-first startup does not skip the local config guard.
Route ownership: Route-first commands resolve startup policy with routeMode: true, then run the shared bootstrap; that bootstrap lazily imports and calls the config guard unless the startup policy sets skipConfigGuard.
Policy semantics: routeConfigGuard: "always" is the established route-first mechanism for setting skipConfigGuard; the PR applies it to the exact channels status catalog entry, matching existing routed cold-command policy.
Findings None None.
Security None None.

How this fits together

The CLI command catalog supplies startup policy to both Commander and lightweight route-first commands. channels status sends a Gateway RPC first; successful JSON output returns the Gateway payload directly, while text formatting and unreachable-Gateway fallback load their local runtime only when needed.

flowchart LR
  A[CLI argv] --> B[Command catalog]
  B --> C[Route-first dispatcher]
  C --> D[Startup policy]
  D --> E[Gateway channels status RPC]
  E --> F[JSON payload]
  E --> G[Text or fallback runtime]
  G --> H[Operator output]
Loading

Before merge

  • Complete next step (P2) - A maintainer should make the protected-label merge decision after required checks finish; this review found no discrete code or test repair for an automated worker.
Agent review details

Security

None.

PR surface

Source +1, Tests +26. Total +27 across 4 files.

View PR surface stats
Area Files Added Removed Net
Source 1 1 0 +1
Tests 3 75 49 +26
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 76 49 +27

Review metrics

None.

Technical review

Best possible solution:

Keep one declarative startup-policy rule on the channels status catalog entry and preserve the route-level cold-import regression test, then land only after the protected maintainer review and required checks complete.

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

Yes. A packaged openclaw channels status --json invocation with a reachable Gateway exercises the route-first path; current source shows that the default route policy calls the config guard before the RPC, while the proposed policy skips it. This read-only review did not run the command locally.

Is this the best way to solve the issue?

Yes. The catalog is the authoritative startup-policy owner, and routeConfigGuard: "always" uses the existing route-first mechanism rather than adding another lazy-loading path. The new test is better than the removed direct-command test because it covers the actual dispatcher and bootstrap boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label changes:

  • add P2: This repairs a default CLI status path that can impose a substantial local startup delay, but it does not indicate data loss, security bypass, message loss, or an unavailable core runtime.
  • add proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix reachable-Gateway timing and startup-trace results for the exact command, alongside a route-level regression test; the supplied check context also reports the Real behavior proof check as successful.
  • 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 provides after-fix reachable-Gateway timing and startup-trace results for the exact command, alongside a route-level regression test; the supplied check context also reports the Real behavior proof check as successful.

Label justifications:

  • P2: This repairs a default CLI status path that can impose a substantial local startup delay, but it does not indicate data loss, security bypass, message loss, or an unavailable core runtime.
  • 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 provides after-fix reachable-Gateway timing and startup-trace results for the exact command, alongside a route-level regression test; the supplied check context also reports the Real behavior proof check as successful.
  • proof: sufficient: Contributor real behavior proof is sufficient. The PR body provides after-fix reachable-Gateway timing and startup-trace results for the exact command, alongside a route-level regression test; the supplied check context also reports the Real behavior proof check as successful.

Evidence

What I checked:

  • Current-main gap: Current main has bypassConfigGuard: true for channels status but no route policy override; the default route policy is never, so route-first startup does not skip the local config guard. (src/cli/command-catalog.ts:485, b8865942db84)
  • Route ownership: Route-first commands resolve startup policy with routeMode: true, then run the shared bootstrap; that bootstrap lazily imports and calls the config guard unless the startup policy sets skipConfigGuard. (src/cli/route.ts:52, b8865942db84)
  • Policy semantics: routeConfigGuard: "always" is the established route-first mechanism for setting skipConfigGuard; the PR applies it to the exact channels status catalog entry, matching existing routed cold-command policy. (src/cli/command-startup-policy.ts:48, 39878b2d332e)
  • Lazy output boundary: The channel-status command writes successful JSON immediately after the Gateway response; only text rendering and error fallback import status.runtime.ts. This supports keeping the successful JSON route cold without removing fallback behavior. (src/commands/channels/status.ts:43, b8865942db84)
  • Regression coverage: The new test invokes tryRouteCli for both probe variants, asserts the Gateway payload is written, and records module-load sentinels without clearing them, catching eager static-route imports as well as a restored config guard. (src/cli/channels-status-cold-imports.test.ts:9, 39878b2d332e)
  • Current-main and merge status: The PR head is not an ancestor of the checked-out current main, and a three-way merge inspection applies all four changes cleanly; no later main change touched the affected implementation paths after the PR base. (src/cli/command-catalog.ts:485, b8865942db84)

Likely related people:

  • steipete: Recent current-main history attributes the preceding route/startup cold-path repair to Peter Steinberger, and this PR extends that same catalog-policy seam rather than introducing a separate subsystem. (role: recent CLI cold-start feature owner; confidence: high; commits: 681e8c5ab193, 39878b2d332e; files: src/cli/command-catalog.ts, src/cli/command-startup-policy.ts, src/commands/channels/status.ts)

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 2, 2026

Copy link
Copy Markdown
Contributor Author

Land-ready at 39878b2d332ee0c1e2a7094b3ed3c57ef5f7857c.

  • Exact-head CI: run 30728927357 completed successfully, including openclaw/ci-gate.
  • Landing verification: git diff --check origin/main...HEAD; node scripts/watch-pr-ci.mjs 117751 39878b2d332ee0c1e2a7094b3ed3c57ef5f7857c; scripts/pr review-validate-artifacts 117751; OPENCLAW_TESTBOX=1 scripts/pr prepare-run 117751 — all passed.
  • Hosted gate mode: hosted_exact_or_recent_parent; the prepared head and PR head are identical, so no code or branch rewrite was needed.
  • Behavior proof: the PR records reachable-Gateway timings improving from 5.45/5.33 s to 0.69/0.68/0.68 s, plus a route-level regression that fails when the catalog policy is reverted.
  • Proof gap: no additional live timing run was repeated during landing; the landing used the recorded live measurements, focused test/build results, ClawSweeper review, and exact-head hosted CI.

No review findings remain. CHANGELOG.md is intentionally unchanged under the repository's release-generation policy.

@steipete
steipete merged commit 5cb0c9d into main Aug 2, 2026
190 of 200 checks passed
@steipete
steipete deleted the codex/fix-channels-status-eager-load branch August 2, 2026 02:43
@steipete

steipete commented Aug 2, 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 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: S 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