Skip to content

fix(update): clear active status when CLI initialization fails - #139288

Merged
steipete merged 4 commits into
openclaw:mainfrom
TheAngryPit:fix/update-cli-initialization-terminal-state
Sep 7, 2026
Merged

steipete merged 4 commits into
openclaw:mainfrom
TheAngryPit:fix/update-cli-initialization-terminal-state

Conversation

@TheAngryPit

@TheAngryPit TheAngryPit commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139284. This is the CLI initialization workstream; it does not close the umbrella.

What Problem This Solves

Resolves a problem where a failed CLI update can leave configuration controls suspended when initialization throws before update execution begins. The command exits, but its admitted update run remains active.

Why This Change Was Made

Bring progress creation and failure-triage preparation under the existing update-run failure owner. Initialization errors finish the admitted run before being rethrown; progress is disposed only if it was created. Already-terminal runs keep their outcome, and a command that transferred ledger ownership to migrated finalization does not reopen the old database.

This changes no schema, recovery command, configuration selector, or service policy. It does not recover a killed updater or explain the original interruption in the umbrella issue. The existing parent/child and migrated-finalization owners remain responsible for those paths.

User Impact

Failed initialization leaves a terminal failed update report instead of an active run that can indefinitely suspend configuration writes. The original error remains visible. Neither reproduced initialization failure starts update, configuration, service, or plugin work.

Evidence

Current head: 6d6f74cafa4f3fa8215ecf5fa2e0233ffb19c7b2.

Rollback ownership follow-up

The review correctly identified that the outer catch could overwrite helper-pending recovery with a terminal failure. The outer boundary now handles only failures before execution starts; the existing execution owner retains rollback and migrated-finalization responsibility. No helper, service policy, or ledger schema changed.

  • The added regression invokes updateCommand with the real isolated ledger and a typed helper-pending finalization failure. Before the fix it failed because the run was already failed; after the fix the run stays running and accepts the helper's later rolled-back outcome. Finalization is stubbed in this regression; it is not represented as native helper proof.
  • On byte-identical final source, Linux/WSL with Node 24.18.0 and the pinned pnpm 12.3.4 passed 77 tests through the repository wrapper: 4 outer CLI regressions, 65 rollback/recovery tests, 2 ledger-owner tests, and 6 native-helper lifecycle cases. The filtered runs excluded 407 and 158 other tests respectively. The helper cases execute the real helper process with synthetic systemd/launchd executables; they are not operator-service tests.
  • Commands: node scripts/run-vitest.mjs src/cli/update-cli.test.ts -t 'leaves restored-generation completion|finishes the admitted run|does not reopen the ledger after migrated' --reporter=dot; node scripts/run-vitest.mjs src/cli/update-cli/update-command-run.test.ts src/cli/update-cli/update-command-rollback.test.ts src/cli/update-cli/update-command-post-update-recovery.test.ts --reporter=dot; node scripts/run-vitest.mjs src/infra/update-managed-service-handoff-lifecycle.test.ts -t 'restores the verified previous.*generation after updater exit 79' --reporter=dot.
  • The canonical wrapper built the required runtime. An earlier raw-Vitest attempt omitted that build and placed temporary CommonJS fixtures under the ESM package; those harness errors disappeared after correcting preparation, without changing source. Test state and temporary directories were task-isolated; no operator service or installation was changed.
  • Fresh independent autoreview reported no actionable P0–P2 findings. Core and relevant CLI-test typechecks, targeted lint, formatting, and diff checks passed. Source hashes were checked again after the commit hook and matched the Linux-tested files.

Earlier initialization evidence

  • Revalidated against official main cb4c06ee78fb61891b87ff95b288efb24df55dee. The two failure-first regressions failed on that unmodified production implementation: both retained running / requested instead of a terminal failed run. They pass with the repair, using the real isolated update ledger.
  • Focused regressions also cover phase ordering, the post-core parent/child boundary, and the current migrated-finalization handoff. A new handoff regression verifies that failure after ownership transfer does not reopen the original ledger.
  • Built the repository's qaRuntime profile and exercised the actual built openclaw.mjs update --dry-run --no-restart --yes entry point twice, in separate synthetic homes. A task-local loader injected one exception at progress creation or triage preparation without modifying the built files. Both commands exited 1 with the original diagnostic; a subsequent uninstrumented update status --json reported no active run and a retained finished / failed / update-failed result, with no step left in progress. No operator installation, configuration, or service was changed.
  • Fresh independent repository autoreview of the final source diff reported no P0–P2 findings. This is scoped review evidence, not a guarantee.
  • Native proof candidate before the subsequent lint-only cleanup: 3e2a5843aa993febc1cd320c59e8ec485c056e80. macOS arm64, Node 26.8.1, pnpm 12.3.4, Vitest 5.0.0: node scripts/run-vitest.mjs src/cli/update-cli.test.ts src/cli/update-cli/update-command.test.ts --reporter=dot passed 461 tests across 2 files, with no skips. SHA-256 checks confirmed both tested files were byte-identical to that candidate. This ran through Crabbox's SSH provider in a task-only directory, not through an operator's installed Gateway or OCM. The proof directory was moved to Trash afterward.
  • Previous publication candidate: e5401c52041994914e85605a04c1d13662e5eaf8. Hosted lint on the previous candidate found the production file two lines above its limit. Removing the redundant async/await callback wrapper preserves the returned promise and failure/cleanup ordering, while satisfying the existing limit. Targeted type-aware lint and formatting passed. A fresh independent review found no actionable P0–P2 findings for this cleanup. 49 selected Windows tests passed, 412 were filtered out, covering initialization, triage preparation, ledger/migrated finalization, phases, and post-core paths. The native full run was not repeated after this source cleanup and is not presented as byte-identical proof of the new head.
  • Windows core and core-test typechecks, targeted type-aware lint, formatting, and the remaining native-state/database/media/sidecar/import-cycle/webhook/auth ownership checks passed. The complete Windows CLI run did not pass: 300 failed, 160 passed, 1 skipped. Representative failures are unchanged-main Windows npm-argument and stdio expectation mismatches; cleanup errors cascaded, and not every failing case was separately attributed. The broad changed-check runner stopped at Knip with a cache collision, a production-scan timeout, and a Windows configuration-path defect that drops the real importer of a reported export. No check or baseline was weakened to hide these failures.

These results are not claims that the full build, full repository test suite, native UI, or hosted CI passed. The macOS run is native source-test evidence; the separate instrumented built-CLI run proves the reported initialization boundary. Current-head hosted CI remains a separate gate.

Maintainer update

  • Rebased onto main 6aa09cbadb594c3d46d5bd49a28c514df1b256b0 while preserving the contributor's authored commits and merge history. The final two-file patch has the same stable patch ID as the contributor's head; no behavior rewrite was needed.
  • Reproduced both initialization regressions on main b4ce0df975fab5f1a5bc234ad9643c6de40c9eb0: progress initialization and triage preparation each retained requested/running instead of finished/failed. The same run passed helper-owned rollback, migrated-finalization ownership, and both existing post-core ownership cases. The two update files are unchanged between that main revision and the rebase base.
  • Both previous failing checks had one cause: check-lint-core-1 reported File has too many lines (704) in update-command.ts; openclaw/ci-gate reported check-lint-hosted-core-shard finished with failure (selected=true). Current main's existing simplifications bring the rebased file to 698 counted lines. Changed-file lint and the complete pnpm check:changed now pass without weakening a rule.
  • All 637 focused tests across 8 files passed on 6d6f74cafa4f3fa8215ecf5fa2e0233ffb19c7b2: CLI orchestration, command, run owner, rollback, post-update recovery, post-core continuation, triage, and the real ledger. The repository test wrapper also completed its required runtime build. Fresh Codex autoreview against the exact merge base found no actionable P0–P2 findings.
  • Exact-head CI: run 34149042053, attached with the bounded repository watcher. The watcher reported GREEN, and the completed run confirms success for the CI gate, the previously failing lint job, and Docker seed E2E. This PR is not merged. Abandoned-run reconciliation remains outside this patch.

@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review complete

ClawSweeper finished reviewing this revision. The review result is being finalized.

View the workflow run.

@openclaw-barnacle openclaw-barnacle Bot added the cli CLI command changes label Sep 5, 2026
@TheAngryPit
TheAngryPit marked this pull request as ready for review September 5, 2026 18:35
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 5, 2026
@clawsweeper

clawsweeper Bot commented Sep 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 7, 2026, 2:26 PM ET / 18:26 UTC.

ClawSweeper review

What this changes

The CLI updater records initialization failures as finished failed runs while preserving execution-owned recovery and disposing successfully initialized progress reporting.

Merge readiness

✅ Ready for maintainer review

This PR remains necessary: current main still exposes both initialization failure gaps. The earlier rollback finding is resolved, and no actionable correctness or security findings remain.

Priority: P2
Reviewed head: 6d6f74cafa4f3fa8215ecf5fa2e0233ffb19c7b2

Review scores

Measure Result What it means
Overall readiness 🦞 diamond lobster (5/6) A focused lifecycle repair with relevant real CLI evidence, meaningful regression coverage, and the prior rollback defect resolved.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The supplied built-CLI observations exercise both changed initialization boundaries in isolated homes and verify terminal failure through an uninstrumented status command; current-head regressions supplement that historical proof for rollback and migrated-state ownership.
Patch quality 🦞 diamond lobster (5/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The supplied built-CLI observations exercise both changed initialization boundaries in isolated homes and verify terminal failure through an uninstrumented status command; current-head regressions supplement that historical proof for rollback and migrated-state ownership.
Evidence reviewed 9 items Verified patch boundary: The complete host introduction evidence and local merge-base comparison identify only CLI orchestration and its regression tests as introduced changes; unrelated base-branch changes are excluded.
Current main still needs this repair: Current main creates progress outside the outer try and confines failure bookkeeping to the execution callback. Progress creation or triage preparation can therefore fail after admission without finishing the run.
Completion ownership preserved: The outer catch only finishes runs before executionStarted. Execution retains typed-result completion, helper-pending rollback handling, and the ledgerHandoffOwned fence protecting migrated databases.
Findings None None.
Security None None.

How this fits together

The CLI updater records progress and outcomes in OpenClaw's shared update ledger. Status commands and the Control UI consume those records to display updates and determine whether configuration controls remain suspended.

flowchart TD
  A[CLI update request] --> B[Admit update run]
  B --> C[Initialize progress and triage]
  C -->|Initialization fails| D[Record terminal failure]
  C -->|Initialization succeeds| E[Execute update and recovery]
  E --> F[Existing completion owner]
  D --> G[Status and configuration controls]
  F --> G
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +7, Tests +117. Total +124 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 44 37 +7
Tests 1 117 0 +117
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 161 37 +124

Review metrics

None.

Root-cause cluster

Relationship: fixed_by_candidate
Canonical: #139284
Summary: This PR implements the initialization workstream of the broader tracker; late observation and legacy continuation admission are distinct paths.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Finish pre-execution failures through the existing ledger owner while leaving rollback and migrated-state completion with their established owners.

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

Yes: current-main source exposes both failure paths after ledger admission, and the supplied failed-first evidence exercises them. This review verified the source mechanism without running target code.

Is this the best way to solve the issue?

Yes: extending the existing failure boundary is a narrow repair, and the execution-start guard preserves the recovery ownership that the earlier review identified.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 8aa070eec3f3.

Labels

Label changes:

  • add rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • remove rating: 🐚 platinum hermit: Current PR rating is rating: 🦞 diamond lobster, so this older rating label is no longer current.

Label justifications:

  • P2: This is a bounded updater lifecycle repair for initialization exceptions that otherwise leave misleading active status.
  • rating: 🦞 diamond lobster: Overall readiness is 🦞 diamond lobster; proof is 🦞 diamond lobster and patch quality is 🦞 diamond lobster.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Sufficient (live_output): The supplied built-CLI observations exercise both changed initialization boundaries in isolated homes and verify terminal failure through an uninstrumented status command; current-head regressions supplement that historical proof for rollback and migrated-state ownership.
  • proof: sufficient: Contributor real behavior proof is sufficient. The supplied built-CLI observations exercise both changed initialization boundaries in isolated homes and verify terminal failure through an uninstrumented status command; current-head regressions supplement that historical proof for rollback and migrated-state ownership.

Evidence

What I checked:

  • Verified patch boundary: The complete host introduction evidence and local merge-base comparison identify only CLI orchestration and its regression tests as introduced changes; unrelated base-branch changes are excluded. (src/cli/update-cli/update-command.ts:114, 6d6f74cafa4f)
  • Current main still needs this repair: Current main creates progress outside the outer try and confines failure bookkeeping to the execution callback. Progress creation or triage preparation can therefore fail after admission without finishing the run. (src/cli/update-cli/update-command.ts:114, 8aa070eec3f3)
  • Completion ownership preserved: The outer catch only finishes runs before executionStarted. Execution retains typed-result completion, helper-pending rollback handling, and the ledgerHandoffOwned fence protecting migrated databases. (src/cli/update-cli/update-command.ts:157, 6d6f74cafa4f)
  • Existing terminalization contract: failUpdateCommandRun ignores terminal records and uses the existing ledger owner; finishUpdateRun closes active steps and preserves the first terminal outcome. No schema, retention, configuration, or plugin API changes are introduced. (src/cli/update-cli/update-command-run.ts:102, 6d6f74cafa4f)
  • Focused regression coverage: The four added cases check both initialization failures against a real isolated ledger, absence of update/service/config/plugin effects, later helper-owned rollback completion, and no ledger reread after migrated finalization takes ownership. The supplied body reports 637 focused tests passing on the reviewed head; this read-only review did not execute them. (src/cli/update-cli.test.ts:4912, 6d6f74cafa4f)
  • Real CLI behavior proof: The complete supplied PR body, captured under sourceRevision 1878a32221d3dfc8513ccaaa2413302cd136d7e7692f2cab23b4f01df595ce00, reports two built openclaw.mjs update runs in isolated synthetic homes with injected initialization exceptions. Both exited 1 with the original diagnostic; subsequent uninstrumented update status --json showed no active run and a retained finished/failed/update-failed result. This is historical production-entrypoint evidence, supplemented by current-head regressions, not a claim of a new reviewer execution.

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

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.

History

Review history (6 earlier review cycles)
  • reviewed 2026-09-05T18:41:49.482Z sha ce64c933b6af9f6744efbc89ff84207cfa7d576b :: needs real behavior proof before merge. :: none
  • reviewed 2026-09-06T21:11:21.320Z sha 3e2a5843aa993febc1cd320c59e8ec485c056e80 :: blocked before merge. :: [P1] Preserve helper-owned rollback completion during outer unwind
  • reviewed 2026-09-06T21:37:49.579Z sha e5401c5 :: blocked before merge. :: [P1] Preserve helper-owned rollback completion during outer unwind
  • reviewed 2026-09-06T22:49:39.978Z sha e127dca :: needs maintainer review before merge. :: none
  • reviewed 2026-09-06T23:42:19.513Z sha acbb7f0c72f2e1a5863cf28b047f775b5a9eff3d :: needs maintainer review before merge. :: none
  • reviewed 2026-09-07T17:53:07.311Z sha 6d6f74c :: needs maintainer review before merge. :: none

@TheAngryPit
TheAngryPit force-pushed the fix/update-cli-initialization-terminal-state branch from ce64c93 to 3e2a584 Compare September 6, 2026 21:04
@clawsweeper clawsweeper Bot added merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. and removed rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. labels Sep 6, 2026
@TheAngryPit
TheAngryPit force-pushed the fix/update-cli-initialization-terminal-state branch from 3e2a584 to e5401c5 Compare September 6, 2026 21:31
@TheAngryPit

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Addressed the helper-pending rollback finding in e127dcac5d56c2a305c11ee56e02d001ee9a3a74. The outer catch now terminalizes only pre-execution initialization failures; execution retains its existing completion owner. The new updateCommand regression failed on the previous implementation and passes with the repair.

The PR body now records 77 passing Linux tests on byte-identical final source, including six real native-helper process cases with synthetic supervisors, plus the scoped independent review and limitations. No helper contract or safety check was weakened. Please reassess this head and the updated evidence.

@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event exact_review_queue).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@clawsweeper clawsweeper Bot added 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. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. merge-risk: 🚨 availability 🚨 May cause crashes, hangs, restart loops, stalls, or process outages. status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. labels Sep 6, 2026
@steipete
steipete force-pushed the fix/update-cli-initialization-terminal-state branch from acbb7f0 to 6d6f74c Compare September 7, 2026 17:47
@clawsweeper clawsweeper Bot added rating: 🦞 diamond lobster Very strong PR readiness with only minor maintainer review expected. and removed rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. labels Sep 7, 2026
@steipete
steipete merged commit 10af653 into openclaw:main Sep 7, 2026
116 checks passed
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 8, 2026
…law#139288)

* fix(update): release failed initialization runs from active status

* fix(update): preserve helper-owned rollback completion

---------

Co-authored-by: TheAngryPit <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes P2 Normal backlog priority with limited blast radius. proof: sufficient ClawSweeper judged the real behavior proof convincing. rating: 🦞 diamond lobster Very strong PR readiness with only minor 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.

2 participants