Repository navigation
fix(cli): avoid repeated plugin preparation at startup - #131503
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
|
Codex review: needs maintainer review before merge. Reviewed August 28, 2026, 11:23 PM ET / August 29, 2026, 03:23 UTC. ClawSweeper reviewWhat this changesThe branch scopes plugin preparation to one non-Gateway CLI invocation, rebuilding it after lifecycle changes while adding related plugin, Doctor, and stale UI-load coverage. Merge readinessKeep open: the cache-lifetime repair remains absent from current main and no introduced correctness defect was established, but the refreshed head still needs its stated exact-head package/install cold-flow proof and CI before merge. Priority: P2 Review scores
Verification
How this fits togetherThe CLI reads configuration and plugin metadata to register commands before parsing an invocation, then executes the selected command. The changed cache boundary controls whether that startup preparation is reused or refreshed after plugin lifecycle changes. flowchart LR
A[CLI invocation] --> B[Config and plugin metadata]
B --> C[Invocation cache]
C --> D[Plugin command registration]
D --> E[Command parsing]
E --> F[Command action]
C --> G[Plugin replacement or cleanup]
G --> D
Before merge
Agent review detailsSecurityNone. PR surfaceSource +111, Tests +2361, Docs +14, Other -1. Total +2485 across 54 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 the refreshed head demonstrates a cold installed CLI invocation, cleanup/replacement refresh behavior, and green exact-head CI. Do we have a high-confidence way to reproduce the issue? Unclear: the source and focused regression tests identify the stale-preparation path, but this read-only review did not establish a fresh exact-head installed cold-flow reproduction. Is this the best way to solve the issue? Yes for the reviewed cache boundary: invocation-owned caching with lifecycle invalidation matches the caller, loader, and lazy-command ownership paths; final installed-runtime proof remains needed before merge. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 116425e9b304. LabelsLabel justifications:
EvidenceAcceptance criteria:
What 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 (15 earlier review cycles; latest 8 shown)
|
d1dfada to
ce70dfa
Compare
|
Completed source, build, package and installed acceptance for ae4eed872d797b17084b8b72d9a9c1058e5e7064, tree Exact-head CI passed 185 jobs / 12 skipped, including the required gate. Configured Linux Testbox proof passed 784 focused cases, plugin test types and formatting; the lease is stopped. Doctor/discovery reconciliation separately passed 180 cases and types/lint/format. Independent isolated review was scoped-clean at P0 for the full earlier implementation (0.96) and final Doctor integration (0.97); no source changed afterward except the reviewed rebase integration. The full candidate build passed with all 147 SDK subpaths, no ineffective dynamic import, and UI gzip 344,785 under 345,947 bytes. The normalized candidate archive is 61,549,152 bytes / 11,307 members, SHA-256 Normal npm installation with lifecycle scripts enabled passed in a new isolated prefix/cache in 494.006 seconds. The first installation attempt had hit its 900-second limit and was not reused. All eight original installed actions then passed in order: cold metadata 17.322s, inventory 3.638s, config write 3.846s, reread 3.104s, selected alpha 12.327s, rejected unselected beta 7.060s, rejected invalid secondary schema 11.175s, and selected beta after owner change 22.380s. Every child retained its original 30-second bound. Output, isolation, child/port/fixture cleanup and source/archive/installed/Node identities were verified. Eight-action receipt SHA-256: The additional installed MCP error flow passed in 26.502s, with exact exit 1, empty success map, one named diagnostic, useful stderr, no key output and complete cleanup. Receipt SHA-256: The PR body records exact commands, earlier CI corrections, local source timeouts, packaging/install retries, and the inspected real-browser cancellation proof. No deadline/assertion/mock/feature policy was relaxed. UI images remain local because external-upload approval is not established. No operator Gateway, Chrome profile or credentials were changed. The latest exact-head ClawSweeper rank-up requests—installed cold/cleanup/replacement proof and green CI—are now addressed. Native review/prepare/merge follows; this comment does not claim the PR is already merged. |
ce70dfa to
3584f08
Compare
Give explicit post-lease and post-mutation reads a fresh metadata generation without retiring the invoking CLI or Gateway owner. Persist the original workspace index while retaining the complete config-wide validation view. Bind rebased snapshots to their creating cache so later consumers cannot borrow a stale or foreign generation. Replace mocked persistence assertions with real scoped-index, lease, checkpoint, schema and provenance regressions. Follow-up to the installed startup verification for #131503.
Load the existing channel MCP server only for the serve action, and use the already-eager client-runtime import for reload. Registration and probes no longer evaluate the unused serving owner. Initialize the config CLI runtime capture before hoisted mocks. Give the real Doctor checkpoint fixture explicit build provenance and verify durable rows for successful, interrupted, and unidentified builds without changing runtime checkpoint policy. Remove duplicate fixture initialization and avoid dumping captured environments on rejection failures. Refs: #131503 (CLI startup preparation)
Import the canonical runtime context resolver from its new owning module in the CLI lifetime regression. Preserve the existing behavior assertions; the original CI TS2724 reproduces before the import correction and the same type program and 16 lifetime cases pass afterward. Refs: #131503 (CLI startup preparation)
Remove the case that compares the same cached alias object with itself. Keep the stronger identity/no-repeated-filesystem-read test, context-isolation cases, and real source/native loader coverage. No production API or behavior changes. Refs: #131503 (CLI startup preparation)
Preserve main's canonical lazy Usage loading and check the router, transport epoch, and selected agent after the deferred import. Carry the existing route signal to all aggregate requests so obsolete navigation does not start new RPCs or retain client waits. Keep independent preload lifetime intact. Consolidate pending results to absorb the ownership checks with a net reduction of one production line. Real router/Gateway/selection regressions fail before the fix and pass afterward. Browser Back during a held service-worker fetch starts three obsolete Usage requests before the fix and none afterward; a fresh Usage visit still loads normally. This does not claim cancellation of server work already sent. Refs: #131503 (CLI startup preparation and integration repair) Related: #132140 (canonical Usage startup loading)
Keep the waited fresh-result identity and stale-result rejection checks. Remove two redundant assertions that required the old two-argument request shape and rejected the newly forwarded cancellation signal. The same failure appeared in both Control UI and Node CI lanes. Both test entrypoints now pass, along with adjacent Usage/controller coverage, UI test types, lint, and formatting. No production code, mock response, timeout, or stale/fresh data assertion changes. Refs: #131503 (CLI startup and Usage lifecycle integration) CI: https://github.com/openclaw/openclaw/actions/runs/33224402718
|
Merged via squash.
|
Related: independent native relay work and the routed CLI metadata-reuse proposal. This is the generic CLI startup split. iMessage and Browser CLI import reductions stay separate; native relay landing does not depend on them. This uses invocation ownership, not process-global adoption of workspace-scoped snapshots, and does not claim to close the separate latency proposal.
What Problem This Solves
Plugin-backed CLI commands repeat metadata preparation and load writer/runtime/SDK code before the selected action needs it. Reusable package facts and executable registrations also have different lifetimes: a new preparation must not receive registrars captured by a retired generation. Execution must stay within the selected workspace, while config validation still covers every configured workspace.
Installed verification also exposed stale post-write metadata reads and lost snapshot creator-cache provenance, preventing Doctor from verifying a durable registry checkpoint. The repair consumes the original-scope persistence producer rather than a second lookup or a validation union stored under one workspace header.
Why This Change Was Made
One lightweight operation cache spans each non-Gateway CLI invocation through early reads, nested registration, actions and cleanup. Separate preparation records fence executable registrations by exact input/source/workspace identities and lifecycle revisions, then close before actions. Gateway keeps its boot/process owner. The prepared record owns its registry promise and opts out of the lower process-registry cache; other callers keep their existing policy.
The existing config writer, broad plugin runtime and complete SDK aliases load on demand. Late native/Jiti imports retain their creator's facts. The light state facade is adopted by the eventual runtime; only the registry proxy grants stores. MCP client registration no longer imports the serving-only module, which loads inside the selected, validated serving action and existing error boundary.
Current main's canonical owners remain authoritative:
registryIndexdirectly and remove A's redundant leaf lookup. Fresh management generations and snapshot creator binding remain necessary.Main's Usage startup cleanup supersedes A's old module renames, import churn and generated manifest changes. Only the three-file lifecycle residual remains: after deferred import, recheck router cancellation, transport/hello and selected agent before starting requests, then forward the signal to all three requests. Consolidated pending-result construction makes that residual net -1 production line. Independent preloads retain their lifetime. This prevents obsolete RPC startup/client waits, not server work already dispatched; existing result guards already reject stale results.
A duplicate SDK self-comparison test is removed; stronger identity/no-repeated-filesystem-read, context, private-surface and real-load coverage remains. No parallel cache framework, Program entry cache, function-bearing manifest projection, global reset, new configuration/environment option, dependency override, SQLite schema/format, or protocol is introduced. In-memory cache generations are not persistent cache schemas.
User Impact
Plugin-backed commands avoid repeated preparation without broadening which workspace's commands may execute. Config reads avoid the write pipeline, state-only registration avoids the broad runtime, and MCP client commands avoid serving-only imports. Explicit management refreshes observe new facts while retained operations remain internally consistent. Leaving Usage during its deferred load no longer starts obsolete requests afterward.
This does not establish a five-second discovery guarantee or an isolated end-to-end latency improvement. Authenticated Chrome/native acceptance remains with the independent relay feature. No operator Gateway, Chrome profile, credentials or live state was changed. AI-assisted maintainer-requested extraction.
Evidence
Verified candidate:
ae4eed872d797b17084b8b72d9a9c1058e5e7064; treec6be20b07e987e64c10a84aca509c51509fb970f; basebd9eeaebf0836cc3ae840669d4831495953c46fe. The seven-commit rebase is complete and clean. Range-diff changes only Doctor fresh-read placement/comment; six other patches are equivalent. Reviewed Doctor bytes and queued MCP, resolver-import, Usage and final UI-assertion corrections were verified after replay.Exact-head CI and source proof: CI run 33230319786 passed 185 jobs, with 12 skipped and the required
openclaw/ci-gategreen. A canceled ClawSweeper dispatch caused the rollup watcher to report failure; the CI run itself did not fail. Its CLI job explicitly passed the MCP process regression in 2.787 seconds.The configured Linux Testbox run 33231458800, lease
tbx_01m15ryhjj79wj4swtzdq3wpn0, verified the exact input head and clean tracked source, then passed 784 tests across the same 14 selected files, plugin test types and formatting. Test execution took 49.46 seconds; the full command took 160.590 seconds on Node 24.19.0. MCP process and real runtime initialization completed in 3.367 and 12.628 seconds with unchanged limits. The lease was stopped and verified completed. This explicit plugin selection covers the runtime suite that normal full-fallback PR CI treats as release-only.The Doctor/discovery reconciliation separately passed 180 cases: 13 real persistence, 69 migration/automatic-repair, 95 metadata/discovery/checkpoint, and three selected-workspace cases. Core/commands test types and scoped lint/format passed. Those tested Doctor bytes remained unchanged through the final stack. Independent isolated Codex review of the staged integration was scoped-clean at P0, confidence 0.97; prior whole-A review at
40f70309e38ewas P0-clean at 0.96. These are static reviews, not additional test runs.Build and archive: canonical
pnpm buildpassed in 2,201.206 seconds on Node 24.20.0, with all 147 SDK subpaths, no ineffective dynamic-import diagnostic, unchanged source, and UI gzip 344,785 / 345,947 bytes. Actual build ID:2026.8.1-ae4eed872d79-2026-08-29T03-10-56.542Z.The canonical packager produced and normalized the archive. Two full packaging attempts then timed out generating npm's final-archive receipt; neither failed command is called a pass. The same offline npm receipt command succeeded with a task-owned cache in 271.994 seconds under its original 300-second bound. Its SHA-1/SHA-512 and inventory matched the unchanged archive. The remaining canonical validator,
check-openclaw-package-tarball.mjs --require-bundled-workspace-deps, passed in 59.419 seconds under its original bound. This resumes the remaining stages, omits no gate, and fabricates no receipt or build stamp.Final archive: 61,549,152 bytes / 11,307 members, SHA-256
6ffb69469fea55a191d6f355054db03894159e8292bf144b9e3da745693ad6a3.Normal installation and cold-first acceptance: a new isolated npm prefix/cache/HOME, with lifecycle scripts enabled, installed that archive successfully in 494.006 seconds. The unchanged eight-action driver then passed, in its original order and under its original 30,000 ms per-child bound:
There was no native-first warmup. 17.322 seconds is not five-second acceptance. Every action's expected outcome, child quiescence, fixture/port cleanup and absence of synthetic-key output were verified. Source, archive, installed payload and Node identities remained unchanged. Eight-action receipt SHA-256:
dc321801428d15b7c4751e563001ecbbe9cb9708ff98abee77d209820d6cc118.The additional installed MCP failure flow then passed in 26.502 seconds: exact exit 1, empty successful-server map, one named diagnostic, useful stderr, no key output, no retained child or fixture. Receipt SHA-256:
06b2f68c05845cd702d6bb36a3b14c067d99dfb92a3999be5d127426080b5cec.Only afterward, the normal built-Browser import profiler passed: 353.063 MiB peak RSS versus 43.203 MiB baseline. It verified unchanged source/build and cleaned its synthetic state. This is import RSS, not CLI latency or an isolated before/after improvement claim.
Retained failures and limits: the local source MCP test timed out at 30 seconds on its initial run and two unchanged retries; a real runtime-initialization test hit 120 seconds. No local deadline, assertion, mock, environment policy or skip was weakened. The same cases passed in the explicit Linux proof above. A diagnostic child localized most of its own time to imports, but does not establish the exact cause of the earlier timeouts. Packaging's two receipt timeouts remain recorded. A sample showed filesystem operations in npm's extraction cache; isolated-cache success does not prove corruption or a sole cause. The first isolated npm install hit 900 seconds, and its final Git inspection timed out; a separate check confirmed unchanged source. The successful installation used a new prefix/cache, not the partial failed install. No CLI acceptance action ran in the failed installation.
Earlier 5bb CI failed the same stale two-argument Usage assertion in two jobs, plus the aggregate gate. The retained B26 correction removes four redundant call-shape assertion lines while preserving waited fresh-result identity and stale-result rejection. Both original CI entrypoints passed afterward. Older build/install receipts remain bound to their original identities and are not relabeled as candidate proof.
Real-browser proof and media gap: before/after normal UI builds and actual Chromium with synthetic Gateway data preserve Usage totals, Models behavior and byte-identical JSON exports. Holding the normal service-worker-owned deferred module fetch, navigating Back to Chat and releasing it produces three obsolete RPCs before / zero after; revisiting Usage succeeds. The service worker stays enabled. All six successful screenshots and two partial-run captures were inspected, and contexts/servers/ports/temp state cleaned up. These retain their actual precommit bundle identities, not final-commit labels. Images remain local because device classification/external-upload approval is not established; no image was uploaded. This is real rendering with synthetic RPC data, not authenticated provider or native Chrome acceptance.
The ClawSweeper review for this exact head, reviewed 2026-08-29 03:23 UTC, has no actionable source finding. Its rank-up moves—exact-head installed cold/cleanup/replacement proof and green CI—are addressed above. The analogous Models cancellation gap and lightweight tool-metadata extraction are named separate follow-ups, not folded into this PR.
Representative executed commands (the Testbox selection used the same file arguments):
Production LOC: +847/-736 = +111 (28 files). Tests/support: +2,644/-283 = +2,361 (24 files). Docs: +14. Shrink-only assertion ratchet: +1/-2 = -1. Total 54 files, net +2,485; no generated-manifest delta. Remaining production growth expresses observed invocation/preparation/management and creator-provenance ownership on the canonical cache; superseded carriers, lookup paths and UI renames were removed rather than retained as another framework or fallback.