Skip to content

fix(update): avoid stuck history after upgrades from older releases - #139608

Closed
TheCrazyLex wants to merge 1 commit into
openclaw:mainfrom
TheCrazyLex:fix/legacy-update-run-ownership
Closed

TheCrazyLex wants to merge 1 commit into
openclaw:mainfrom
TheCrazyLex:fix/legacy-update-run-ownership

Conversation

@TheCrazyLex

@TheCrazyLex TheCrazyLex commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Related: #139284

What Problem This Solves

Fixes an issue where users upgrading from 2026.9.1 can finish plugin finalization but retain a permanently running update-history entry. The entry also reports the newly installed version as the starting version, obscuring what actually happened during the upgrade.

Why This Change Was Made

The older updater starts finalization in the new package without passing a run ID. Skip new-run admission for that legacy continuation: its parent cannot finish a ledger entry it never created. Modern continuations still reuse their parent's run through the existing admission path. This prevents new orphan records without adding history recovery or changing the ledger schema.

User Impact

Upgrades from parents predating the ledger no longer invent a running history entry during finalization. Modern updates retain their original version, target, and parent-owned completion behavior.

Evidence

  • Extended the existing post-core CLI test into a two-case table, using its established mocked external boundaries and a real isolated update ledger. It checks successful plugin-result output and the complete retained ledger state for both legacy and modern handoffs.
  • Before the production change, the legacy case failed with an extra requested / running row, before.version: 2026.9.2, and an empty target. The inherited-run case passed and retained the original 2026.9.1 starting version and target. The focused regression run had 1 failed, 1 passed, and 361 unselected tests.
  • After the fix, all 380 tests passed in src/cli/update-cli.test.ts and src/cli/update-cli/update-command-post-core.test.ts using node scripts/run-vitest.mjs, including both ownership cases, normal update phases, rejected preflights, and post-core failures.
  • Targeted formatting, git diff --check, and required autoreview passed. The PR CI gate passed for head 825ffb9a8f21a33a1dda292d28a4d40fbbdda794.
  • Installed-updater proof passed for both ownership paths: a published pre-ledger parent completed finalization without creating a row; a modern parent completed its single inherited row with the original before version and target retained. Both installed Gateways passed real health and version checks.
Installed legacy and modern handoff proof

Successful hosted run.

Full evidence artifact.

Exact product head: 825ffb9a8f21a33a1dda292d28a4d40fbbdda794.
Proof branch head: b732aefcbad385ed9b197ba1a2ecb3461bb66424.

Actual installed update CLI result / plugin finalization All retained history Live Gateway
Published 2026.8.2 → exact candidate 2026.9.2 ok / ok, exit 0 Zero rows; no invented run ID Health and status RPC pass; version 2026.9.2, build identifies 825ffb9
Candidate 2026.9.2 → existing future fixture 2026.9.99-first-hop.0 ok / ok, exit 0 Exactly one succeeded / finished row; parent result ID matches retained ID; original before/target preserved Health and status RPC pass; version 2026.9.99-first-hop.0

The modern row ID is cc2e18a5-a6d8-4036-8e34-7fbd36284ec4. Its before version is 2026.9.2, after version is 2026.9.99-first-hop.0, and target remains {channel: stable, tag: /tmp/openclaw-update-first-hop-future.tgz, kind: package}. Every retained step is completed, including post-update verification. There are no other rows, unfinished runs, or transaction residues. All three successive service process IDs differ.

The first-hop missing-bridge negative control also reproduced its expected failure (exit 1, shared-Y6bNiw2w.js). That is the existing compatibility-control case; the failed-first ledger regression remains the separately recorded CLI/SQLite test.

Package checksums:

  • Published 2026.8.2 SHA-256: 20e9c2f16742dfcebfb21504e51067d31e000a19577126ff4fab117e5e87dbe2.
  • Canonically packed exact candidate SHA-256: d485c26afe341492e5b95d4a3016428c6bacd9579ddf005a3c5ebf6d53b0d8a1.
  • Uploaded artifact digest from GitHub: sha256:37d531d231c60b1a22a8090822ab9f20f0bc0bff5bbbbdef323d144e78603302.

The product was packed before harness instrumentation. Installed build-info matches the selected package at each hop, and the first live RPC observation was recorded before the future hop replaced the candidate. History observation opened the existing SQLite database read-only and read all rows; no fixture admission, terminalization, or manual history mutation was used.

Scope: this uses the existing isolated Docker updater harness, including its systemd-control shim, with real installed CLI binaries, package replacement, Gateway processes, and RPC calls. Published 2026.8.2 supplies the pre-ledger parent contract through an already-supported compatibility bridge; the future fixture is derived from the candidate by the existing fixture generator. It is not a native systemd-host or macOS proof, and no operator Gateway or private configuration was used.

Actual observation summaries from the run:

{
  "stage": "positive-first",
  "before": "2026.8.2",
  "after": "2026.9.2",
  "finalization": "ok",
  "historyRows": 0,
  "runId": null,
  "gatewayVersion": "2026.9.2",
  "gatewayHealthy": true
}
{
  "stage": "positive-second",
  "before": "2026.9.2",
  "after": "2026.9.99-first-hop.0",
  "finalization": "ok",
  "historyRows": 1,
  "runId": "cc2e18a5-a6d8-4036-8e34-7fbd36284ec4",
  "gatewayVersion": "2026.9.99-first-hop.0",
  "gatewayHealthy": true
}

Maintainer update

  • Verified the shipped v2026.9.1 post-core spawn contract: it supplies post-core context without an update run ID, so the original defect mechanism is valid.
  • Current main already contains the repair in fix(update): finish npm upgrades from 2026.9.1 #139660, merged as 53b3ac0831350ad868cb0ca25daf691bbbd8e1f4, including Alex Naidis's co-author credit. Post-core children now return before top-level run admission, and the existing two-case regression checks successful plugin output and unchanged complete ledger contents with and without a forwarded parent run.
  • Both current-main ownership cases passed on b4ce0df975fab5f1a5bc234ad9643c6de40c9eb0 in the combined run node scripts/run-vitest.mjs src/cli/update-cli.test.ts -t 'finishes the admitted run|restored-generation completion|does not reopen the ledger after migrated|post-core resume children' --reporter=dot (4 passed; the two expected initialization failures belong to fix(update): clear active status when CLI initialization fails #139288). There is no red-on-current-main result for this already-fixed defect.
  • Fresh Codex autoreview of the original branch against its merge base found no actionable P0–P2 findings. The bounded exact-head CI watcher confirmed run 34004865581 is green for 825ffb9a8f21a33a1dda292d28a4d40fbbdda794; this is the existing run, not new CI.
  • No branch rewrite or redundant production change was pushed. Leaving this PR open for the landing lead's disposition; the original evidence above remains historical evidence for the contributor's patch.

Older updater parents resume post-core work in the installed package
without passing a run ID. Admitting a new row in that child records the
already-updated version and leaves a running entry nobody can complete.

Skip admission for that legacy continuation while retaining the existing
parent-owned admission path for modern handoffs. Keep failure completion
guarded when no run exists.

Extend the existing post-core CLI test with isolated real-ledger checks
for legacy and inherited-run continuations.
@clawsweeper

clawsweeper Bot commented Sep 6, 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 cli CLI command changes size: S labels Sep 6, 2026
@TheCrazyLex
TheCrazyLex marked this pull request as ready for review September 6, 2026 01:49
Copilot AI lite review requested due to automatic review settings September 6, 2026 01:49

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 Approval recommended

The change is narrowly scoped to post-core resume admission, and the updated table-driven test suite directly exercises both legacy and modern handoff behavior against a real isolated ledger.

Pull request overview

This PR prevents post-core update finalization (run by a newly installed package after an upgrade) from creating an orphan “running” update-ledger entry when the upgrading parent release didn’t provide an update run ID (notably upgrades from 2026.9.1). It preserves modern behavior where post-core finalization continues under the parent’s existing run ID and avoids changing ledger schema or adding recovery behavior.

Changes:

  • Skip admitUpdateCommandRun() during post-core resume when OPENCLAW_UPDATE_RUN_ID is absent, preventing creation of a new ledger row in legacy handoffs.
  • Make controlPlaneUpdateSentinelMeta.runId optional when no run is admitted (run?.runId).
  • Extend the existing post-core CLI test into a two-case table to assert ledger behavior for both legacy (no run) and modern (inherited run) handoffs.
File summaries
File Description
src/cli/update-cli/update-command.ts Avoids admitting a new update run during legacy post-core resumes without a run ID, preventing orphan “running” history entries.
src/cli/update-cli.test.ts Adds table-driven coverage asserting post-core resume doesn’t invent a ledger entry, and preserves inherited-run ownership when provided.
Review details
  • Files reviewed: 2/2 changed files
  • Comments generated: 0
  • Review effort level: Lite

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@TheCrazyLex

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

The Evidence section now includes the successful hosted CI gate for the current head, alongside the red/green CLI tests with real ledger storage. The previous review receipt says complete, but its durable review comment still contains the starting placeholder. Please reassess the current branch and 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 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 6, 2026
@clawsweeper

clawsweeper Bot commented Sep 6, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge. Reviewed September 5, 2026, 11:24 PM ET / September 6, 2026, 03:24 UTC.

ClawSweeper review

What this changes

Prevent upgrade finalization started by older releases from creating an unfinished update-history entry, while preserving modern parent-owned history.

Merge readiness

✅ Ready for maintainer review

The fix remains necessary on current main. No actionable patch defects were found, and the added installed-updater observations satisfy the previous review’s proof request.

Priority: P2
Reviewed head: 825ffb9a8f21a33a1dda292d28a4d40fbbdda794

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused owner-boundary repair with meaningful regression coverage and installed proof for both legacy and modern handoffs.
Proof confidence 🦞 diamond lobster (5/6) Sufficient (live_output): The captured installed-CLI observations exercise the changed admission boundary: a published pre-ledger parent leaves zero rows, while a modern parent finishes its single inherited row with original metadata preserved. Real Gateway RPC checks pass at both hops; the disclosed Docker service shim does not replace the CLI or ledger behavior under review.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Verified Sufficient (live_output): The captured installed-CLI observations exercise the changed admission boundary: a published pre-ledger parent leaves zero rows, while a modern parent finishes its single inherited row with original metadata preserved. Real Gateway RPC checks pass at both hops; the disclosed Docker service shim does not replace the CLI or ledger behavior under review.
Evidence reviewed 8 items Introduced patch verified: The pinned merge-base-to-head diff contains only the admission guard and corresponding legacy/modern ledger assertions; unrelated endpoint drift is excluded.
Current main still admits legacy child runs: Inspected fetched main: updateCommand unconditionally admits a run before taking its post-core continuation path. That continuation returns plugin results without completing a newly invented history row. No merged replacement is established by the supplied related context. Release source inspection was unavailable, so no shipped-fix claim is made.
Existing parent ownership remains intact: Modern post-core spawning forwards the parent run ID. Admission passes that ID to createUpdateRun, which returns an existing row unchanged. Resume finalization does not require opts.run, and disabled progress already accepts an absent run.
Findings None None.
Security None None.

How this fits together

The updater replaces OpenClaw’s package and delegates plugin finalization to the newly installed CLI. Its shared history ledger supplies update status and completion reports to operators and clients.

flowchart TD
  A[Parent updater] --> B[Newly installed CLI]
  B --> C{Inherited run ID?}
  C -->|Yes| D[Reuse parent history]
  C -->|No| E[Skip child history admission]
  D --> F[Finalize plugins]
  E --> F
  F --> G[Return result to parent]
Loading

Before merge

None.

Agent review details

Security

None.

PR surface

Source +6, Tests +20. Total +26 across 2 files.

View PR surface stats
Area Files Added Removed Net
Source 1 13 7 +6
Tests 1 36 16 +20
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 49 23 +26

Review metrics

None.

Technical review

Best possible solution:

Keep history admission with the update owner, allowing legacy children to return finalization results without inventing an unfinishable run.

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

Yes, source establishes the failure: a post-core continuation without an inherited run ID creates a running row that its older parent cannot complete. The contributor also records a failing pre-fix regression; this review did not execute it.

Is this the best way to solve the issue?

Yes. Skipping admission only for legacy continuations repairs the producer boundary and preserves existing modern admission, completion, and storage contracts.

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning medium; reviewed against 2d6191a80e9a.

Labels

Label changes:

  • add proof: sufficient: Contributor real behavior proof is sufficient. The captured installed-CLI observations exercise the changed admission boundary: a published pre-ledger parent leaves zero rows, while a modern parent finishes its single inherited row with original metadata preserved. Real Gateway RPC checks pass at both hops; the disclosed Docker service shim does not replace the CLI or ledger behavior under review.
  • add rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 captured installed-CLI observations exercise the changed admission boundary: a published pre-ledger parent leaves zero rows, while a modern parent finishes its single inherited row with original metadata preserved. Real Gateway RPC checks pass at both hops; the disclosed Docker service shim does not replace the CLI or ledger behavior under review.
  • remove rating: 🦪 silver shellfish: Current PR rating is rating: 🐚 platinum hermit, so this older rating label is no longer current.
  • remove status: 📣 needs proof: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P2: This is a bounded upgrade-history correctness repair for legacy updater handoffs.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🦞 diamond lobster 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 captured installed-CLI observations exercise the changed admission boundary: a published pre-ledger parent leaves zero rows, while a modern parent finishes its single inherited row with original metadata preserved. Real Gateway RPC checks pass at both hops; the disclosed Docker service shim does not replace the CLI or ledger behavior under review.
  • proof: sufficient: Contributor real behavior proof is sufficient. The captured installed-CLI observations exercise the changed admission boundary: a published pre-ledger parent leaves zero rows, while a modern parent finishes its single inherited row with original metadata preserved. Real Gateway RPC checks pass at both hops; the disclosed Docker service shim does not replace the CLI or ledger behavior under review.

Evidence

What I checked:

  • Introduced patch verified: The pinned merge-base-to-head diff contains only the admission guard and corresponding legacy/modern ledger assertions; unrelated endpoint drift is excluded. (src/cli/update-cli/update-command.ts:94, 825ffb9a8f21)
  • Current main still admits legacy child runs: Inspected fetched main: updateCommand unconditionally admits a run before taking its post-core continuation path. That continuation returns plugin results without completing a newly invented history row. No merged replacement is established by the supplied related context. Release source inspection was unavailable, so no shipped-fix claim is made. (src/cli/update-cli/update-command.ts:90, 2d6191a80e9a)
  • Existing parent ownership remains intact: Modern post-core spawning forwards the parent run ID. Admission passes that ID to createUpdateRun, which returns an existing row unchanged. Resume finalization does not require opts.run, and disabled progress already accepts an absent run. (src/cli/update-cli/update-command-post-core.ts:373, 825ffb9a8f21)
  • Focused regression coverage: The extended test checks successful plugin-result output and every retained ledger row for both missing and inherited run IDs. The captured body reports the legacy case failing before the change and 380 focused tests passing afterward; tests were not executed during this read-only review. (src/cli/update-cli.test.ts:3763, 825ffb9a8f21)
  • Installed behavior proof resolves prior request: The complete captured PR body, context sourceRevision a2ab343341618ff8166d5047fade36888500a9892423b2418b07bf1894534af3, records published 2026.8.2 upgrading to the exact candidate with successful finalization and zero history rows, followed by a modern installed update retaining exactly one succeeded/finished parent row with original before/target values. Both stages include real Gateway health/version observations. The Docker service-manager shim is disclosed. Linked run https://github.com/TheCrazyLex/openclaw/actions/runs/34007924027 and artifact could not be independently retrieved because network access failed; the assessment uses the supplied copied observations, not an independently downloaded artifact. (825ffb9a8f21)
  • Documented ledger contract: The documentation describes one durable ID following the updater and restarted Gateway. The patch preserves this contract for admitted modern updates without changing schemas, retained rows, or terminal-state rules. Public docs: docs/cli/update.md. (docs/cli/update.md:168, 825ffb9a8f21)

Likely related people:

  • Peter Steinberger: 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 (1 earlier review cycle)
  • reviewed 2026-09-06T02:37:28.198Z sha 825ffb9 :: needs real behavior proof before merge. :: none

@TheCrazyLex

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

Added the requested installed-updater proof for exact head 825ffb9. Published npm 2026.8.2 handed finalization to the unchanged candidate, exited 0 with successful plugin finalization, and left zero update-history rows. A subsequent modern update exited 0 and retained exactly one succeeded/finished row whose ID matches the parent result, with original before version and target preserved. Real Gateway health and running-version checks passed at both hops. The Evidence section links the successful hosted run and full artifact, includes observed JSON and every-row checks, and states the existing Docker service-manager shim boundary.

@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 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. 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
@steipete

steipete commented Sep 7, 2026

Copy link
Copy Markdown
Contributor

Closing as superseded: the same fix is already on main.

#139660 (53b3ac08313, merged 2026-09-05) changed the admission in src/cli/update-cli/update-command.ts so the legacy 2026.9.1 updater's finalization in the new package no longer invents a requested/running history row, and it carries Co-authored-by: Alex Naidis <[email protected]> for this work. Both the legacy and the modern continuation cases from this PR's test pass on current main (verified while preparing the sibling PR #139288 today), and this branch is now conflicting with that landed change rather than adding to it. Thank you @TheCrazyLex for the precise diagnosis and the regression.

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: 🐚 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.

3 participants