Repository navigation
refactor(cli): make update help and planning faster - #133698
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. |
37f2b3b to
c3dfde9
Compare
|
Codex review: needs maintainer review before merge. Reviewed August 30, 2026, 9:55 PM ET / August 31, 2026, 01:55 UTC. ClawSweeper reviewWhat this changesThis PR lazily loads update execution code and consolidates read-only update planning so CLI help and dry-run avoid unnecessary startup work. Merge readinessKeep open for maintainer review: this is a distinct active follow-up to the merged updater repair, has no supported introduced correctness finding, and carries the protected Priority: P3 Review scores
Verification
How this fits togetherThe update CLI registers help, status, repair, and update commands for operators. Read-only planning chooses an install and service context before the mutable updater performs package or Git changes and post-update recovery. flowchart LR
A[Operator update command] --> B[CLI registration and help]
B --> C{Help or execution}
C -->|Help| D[Rendered command help]
C -->|Execution| E[Read-only update planning]
E --> F[Preloaded update runtime]
F --> G[Package or Git update]
G --> H[Service recovery and result]
Decision needed
Why: The branch is a maintainer-owned, protected-label refactor and current-main updater source could not be fully inspected from this partial checkout. Before merge
Agent review detailsSecurityNone. PR surfaceSource -15, Tests +119, Docs +5. Total +109 across 37 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Rebase the refactor onto current main, retain the pre-mutation runtime preload and independent service revalidation, then validate help, dry-run, package update, and recovery on the exact head. Do we have a high-confidence way to reproduce the issue? Not applicable: this is a performance refactor, not a defect report; the review was read-only, while the added process-level guards target the claimed help and planning paths. Is this the best way to solve the issue? Yes, conditionally: lazy registration plus a pre-mutation execution preload preserves the required recovery boundary, but current-main rebase validation remains necessary. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against c29f34dc5312. 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
HistoryReview history (1 earlier review cycle)
|
|
Merged via squash.
|
* perf(cli): speed up update startup and planning * fix(cli): align update import contracts and process fixtures
What Problem This Solves
Update help and previews spend time loading doctor, restart, and plugin-repair code that they do not use. Planning also collects Git status that is discarded and repeats service/package-manager discovery. This makes a read-only preview unnecessarily slow before an operator can see the plan.
Follow-up to the update CLI cleanup in #133622, requested by a maintainer.
Why This Change Was Made
Separate command registration and read-only planning from update execution. The execution, finalization, and resume graph is still loaded together before package replacement, so recovery never depends on importing old chunks after they have been removed. Service root and Node selection use one inspection; stop/restart ownership checks still revalidate independently.
Reuse canonical Git-root ownership without collecting unused history/worktree status, and skip a package-manager root query when the installation owner already supplies the root. Full
update status, ambiguous package layouts, schema checks, recovery, flags, and output contracts remain intact. Remove the old forwarding exports and duplicated planning paths.User Impact
Help and dry-run return sooner. Measured dry-run stdout and stderr are byte-identical; rebuilt help differs only in the expected build SHA banner. These are startup/planning gains; download, installation, and build time were not benchmarked. No new flags, configuration, environment options, dependencies, or schema changes.
Evidence
Built CLI, isolated home/config/state per invocation, one warmup plus three measured runs on the same machine and Node runtime:
update --helpupdate status --helpupdate --dry-run --no-restartupdate --dry-run --no-restart --jsonHost load and caches affect wall time: an earlier candidate batch measured 0.40s help and 1.76s dry-run. The structural reductions are deterministic: profiled dry-run loads 2,011 modules instead of 2,615 and runs one Git ownership probe instead of six Git subprocesses. Service planning reads once instead of twice; known npm roots omit the redundant root probe while retaining the lifecycle/version probe.
node scripts/run-vitest.mjs src/cli/update-cli.test.ts src/cli/update-cli.startup.test.ts src/infra/update-check-install-kind.test.ts src/infra/update-check-status.test.ts src/infra/update-check.test.ts.OPENCLAW_RUN_NODE_SKIP_DTS_BUILD=1 pnpm buildpassed; built execution/finalization/resume exports were loaded from an isolated home.env -u OPENCLAW_TESTBOX node scripts/check-changed.mjspassed again on the final candidate, including production/test types, lint, dead exports, storage/loader guards, and zero runtime import cycles. An initial lonely-if lint finding was fixed before the successful rerun.a1ce54709c85:CI=1 pnpm test:docker:multi-node-updatepassed in Testbox run 33348712160, exit 0. The actual self-update retained the original Node and installation prefix, preserved the service entrypoint, and passed the real Gateway health probe. The one-shot Testbox stopped after success; its backing Actions session can show cancellation because the lease lifecycle owns completion. This uses the packaged CLI and real Gateway with a service-manager fixture.a1ce54709c85cddb425f39629f0649ab0e864848.Production LOC: +562/-571 (net -9); tests/support: +142/-29 (net +113); docs: +5. Most source churn extracts existing owners into planning and execution modules.
Maintainer review follow-through
The latest ClawSweeper review on
a1ce54709c85identified no correctness/security findings. Its remaining risk and optional Rank-up move request a current-main refresh because its partial checkout could not load source blobs. Checked current main85ec67d66fab32cb0a858c80caf53019592d6510directly: none of the 37 PR paths changed upstream since base67433ff43813.git merge-tree --write-treesucceeds without conflicts, and every PR path in the resulting tree is byte-identical to reviewed/tested heada1ce54709c85. We therefore skip the optional no-op rebase and preserve the exact head with green CI and packaged-update proof. The earlier overlapping invocation-relative profile fix was already integrated and tested.The stored-data warnings are import-only changes: fresh-doctor imports its environment helpers from their canonical service-env owner; package-update-steps drops a forwarding type export; update-runner-types imports that advisory type directly from its owner. No migration, schema, or persisted-data semantics changed. Fresh full-candidate Codex review is clean, and the native merge flow rechecks the current PR/main state before landing.