Skip to content

fix(update): repair refuses forever when a plugin changed after the update - #193632

Merged
fuller-stack-dev merged 6 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-cohort-besteffort-rollback
Nov 5, 2026
Merged

fuller-stack-dev merged 6 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-cohort-besteffort-rollback

Conversation

@fuller-stack-dev

@fuller-stack-dev fuller-stack-dev commented Nov 5, 2026 •

Copy link
Copy Markdown
Member

Related: #193132

What Problem This Solves

Fixes: openclaw update repair fails on every attempt when a plugin's data/settings obligation or install record changed after an update published it.

User Impact

User impact: repair now finishes the plugin rollback instead of refusing forever. It keeps the newer change, restores everything else, and reports what it kept as a warning. The warning shows in repair output, in openclaw doctor under update history, and in the update report.

Why This Change Was Made

When rollback found a plugin migration obligation or install record that matched neither the update's original value nor what the update wrote, it threw. That throw happened before anything was written, so the newer value survived either way. The only effect was that the cohort could never settle. Repair, Doctor and triage then kept pointing at each other, and the cohort pinned capture and rollback artifacts indefinitely.

Rollback now keeps that newer value, skips it, restores every item that still matches, and completes. restorePluginCohortMigrationRowsInDatabase returns the plugins it kept. settleUpdatePluginCohort collects those along with any install records it kept, and writes one warning:plugin-cohort:later-changes-kept step on the update run. Doctor and the run report already show completed warning steps. A kept install record also keeps its source snapshot, so the record and snapshot can't disagree.

One related refusal goes the same way. If the obligation table itself is gone, because the database was restored from a backup older than it, rollback no longer refuses. It now leaves that state alone instead of initializing the candidate schema, and reports the original obligations as kept.

The settlement result shape is unchanged, so the worker callers' strict result parsing still holds. Commit does not restore anything and is unaffected. The live updater rollback still rechecks the database before it restores the previous package. Repair's ordering doesn't need to change: once rollback can't refuse, repair no longer gets stuck settling the cohort before package recovery runs.

Three refusals are left for a follow-up: published artifacts that changed, config files edited after publication, and a source snapshot that changed while its install record did not. Corrupt publication chains still refuse, because that is a journal integrity failure rather than a later writer.

Evidence

Red on base 480d50305383, using real SQLite and the real install index:

  • src/infra/update-plugin-cohort-recovery.test.ts: the later-Doctor-decision case, in both baseline variants, fails with "Plugin migration obligation changed after update publication". The older-backup case fails with "Plugin migration recovery is missing its original obligations". The two other older-database cases fail only on the new return value.
  • src/plugins/update-cohort-recovery.test.ts: the new later-install-record case fails with "Plugin fixture changed after the update; cohort recovery preserved it."

Green on head:

  • Both files pass (16 and 17 tests).
  • The later obligation and the later install record are kept.
  • In the same rollback, a matching install record for a second plugin is restored, which is the negative control. The earlier steps of the migration test also restore matching rows.
  • The cohort is deleted, and the update run's warning projection contains the recorded warning.
  • The existing record-conflict test is rewritten to this outcome rather than deleted. Its artifact and chain cases still refuse.

node scripts/test-projects.mts across the two files above, plus src/plugins/update-cohort.test.ts, src/cli/update-cli/update-repair-command.test.ts, src/cli/update-cli/update-repair-handoff.test.ts, src/cli/update-cli/update-command-plugin-cohort-handoff.test.ts, src/infra/update-plugin-cohort-commit.process.test.ts and src/cli/update-cli/update-command-database-rollback.test.ts: 127 passed.

Format check passes, lint:core has no findings in the touched files, and the import cycle check is clean. Locally, tsrs on core and the infra, plugins-platform and cli-update test shards shows only the existing packages/ai error that base also has. The test-line allocation matches the 260 lines this branch adds against current main.

After #193132 merged, I merged main into this branch. Repair's forward settlement and best-effort rollback now share settleUpdatePluginCohort, and rollback uses the action that settlement resolved. The repair settlement tests in src/cli/update-cli/update-plugin-cohort-settlement.test.ts that used to expect a refusal ("keeps rollback selected") now check that rollback completes, the later decision is kept, and the kept-change warning is recorded. The forward cases check that no warning is recorded, so the two paths stay distinguishable. All 11 cases pass. The related suites, including the cohort and repair tests above, pass with 138 tests.

Review follow-up:

  • Installation owner keys. Install records are keyed by installation owner, and source snapshots by plugin ID. Keeping a later package-owner record used to leave the demo plugin's snapshot restoration queued. The installed-index owner then rejected it ("Plugin demo source snapshot changed after the update"). A kept installation now drops every snapshot restoration whose recorded install owner is that key. It falls back to the plugin ID only when no owner is recorded. New test in src/plugins/update-cohort-recovery.test.ts, using the demo / package-owner shape: red with that error before the fix, green after (18/18).
  • Stored data compatibility. The new last case in src/cli/update-cli/update-plugin-cohort-settlement.test.ts writes the update recovery and plugin cohort rows into real SQLite exactly as shipped updaters and the refused repair stored them on the affected install: disposition rollback, revision 2, settledPublications: 0, and one plugin-migrations publication for discord and whatsapp. Only paths and the run identity differ. It then repairs with this branch's code. The rows load without migration, rollback completes, both later obligations stay as they are, recovery admission clears, and the warning names both plugins. Run against current main's source, the same stored rows load and then refuse with "Plugin migration obligation changed after update publication: discord". This PR adds no stored field, so released rows keep the same shape.
  • Docs. docs/install/updating.md now describes the new outcome in the npm plugin rollback section. Later install-record and obligation changes are kept, rollback completes, and an update warning names them. Settings and artifacts still leave recovery unfinished in this PR; fix(update): repair refuses forever when plugin files, config or snapshots changed after the update #193645 covers those.
  • Checks. Related suites pass with 150 tests across 10 files, including the installed-index snapshot tests. Format, the docs MDX check and tsrs (apart from the existing packages/ai error) are clean. Autoreview at P2 is clean.

…lback

A plugin cohort rollback refused outright when a later writer had changed a
plugin migration obligation or install record after the update published it.
The refusal wrote nothing, so the later value survived either way, but the
cohort could never settle and `update repair` failed on every attempt.

Rollback now keeps those later values, restores everything that still matches
the update's publication, completes, and records what it kept as a warning on
the update run, which repair prints and Doctor and status reports show.
@clawsweeper

clawsweeper Bot commented Nov 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 cli CLI command changes size: S labels Nov 5, 2026
@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. P1 High-priority user-facing bug, regression, or broken workflow. 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 clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

Plugin rollback preserves later migration decisions and install records, restores matching entries, and records a warning.

Example: Doctor completes discord's migration obligation after an update reopened it, and the update subsequently needs rollback.

  • Before: Every repair attempt refuses with “Plugin migration obligation changed after update publication,” leaving recovery pending.
  • After: Repair preserves discord's completed obligation, restores matching entries, clears the cohort, and records what it kept.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Focused and source-consistent, with both prior findings resolved; supplied validation reaches real storage owners but remains harness-based.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence covers cohort settlement, preserved later decisions, matching-record restoration, snapshot ownership, and warning projection through real storage owners.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Update repair repeatedly refuses after a later plugin decision or installation change, preventing recovery from completing.
Reason: This maintainer-authored change explicitly accepts preserving later values with warnings instead of leaving recovery permanently blocked.

Merge readiness

✅ Ready for maintainer review

This maintainer-authored PR fixes a recovery failure that remains on current main. Both prior findings are resolved, and no additional actionable defect was found.

Priority: P1
Reviewed head: c46bed0fce189365a59306ed7b859047b7468623

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied evidence exercises real SQLite and installed-index owners in process, without a shipped-CLI repair or full latest-stable upgrade run.
Agent review details

How this fits together

The update recovery owner consumes recorded plugin publications under installation custody and restores migration rows, install records, and source snapshots before releasing recovery admission.

flowchart TD
  A[Update repair] --> B[Installation custody]
  B --> C[Plugin cohort settlement]
  C --> D[Migration obligation owner]
  C --> E[Installed plugin index]
  D --> F[Preserve later changes]
  E --> F
  F --> G[Clear cohort and record warning]
Loading

Technical review

Best possible solution:

Complete this focused preservation fix through the existing cohort owner, leaving other conflict types to the explicitly stacked follow-up.

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

Current-main conflict checks establish the failing path, and supplied real-SQLite regressions report the intended base failure and corrected outcome; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch makes the smallest coherent change in existing restoration owners: preserve later values, restore matching entries, retain associated snapshots, and report the result without adding another recovery mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Migration and install-record conflict refusal changes intended behavior with a stated reason (6fd646e: Restore a compatible plugin cohort during core rollback while refusing to overwrite independent later changes.)
  • Install-record and source-snapshot binding keeps the original intent (8e6129a: Source snapshots are bound to installation records and must remain consistent through rollback.)
  • Forward versus rollback settlement selection keeps the original intent (c718583: A verified candidate may settle forward only when original-core recovery is unavailable and rollback has restored nothing.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Jason (Json): Raw commit c718583 adds src/plugins/update-cohort-recovery.ts:362 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: c7185836beb3; files: src/plugins/update-cohort-recovery.ts)
  • Peter Steinberger: Raw commit 8e6129a adds src/plugins/update-cohort-recovery.ts:400 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 8e6129a813f8; files: src/plugins/update-cohort-recovery.ts)
  • RoboClaw: Raw commit 6fd646e adds src/plugins/update-cohort-recovery.ts:355 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 6fd646e86cd7; files: src/plugins/update-cohort-recovery.ts)

PR surface

Source +47, Tests +260, Docs +3, Other +7. Total +317 across 10 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 5 73 26 +47
Tests 3 299 39 +260
Docs 1 6 3 +3
Config 0 0 0 0
Generated 0 0 0 0
Other 1 7 0 +7
Total 10 385 68 +317

Preflight source

Source unknown. Source comparison at the observed PR snapshot only. Completion is self-reported; body, policy, tests, execution, and report bytes are not verified.

Labels

Label changes:

  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.
  • remove status: ⏳ waiting on author: Current PR status label is status: 👀 ready for maintainer look.

Label justifications:

  • P1: A legitimate later plugin change can permanently block update repair and subsequent updates.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rating scale

6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior.

Workflow

ClawSweeper edits this one comment on every review. Comment @clawsweeper re-review for a fresh review only. Repair and merge execution lanes are retired.

History

Review history (2 earlier review cycles)
  • reviewed 2026-11-05T17:48:23.610Z sha 53d4e68 :: blocked before merge. :: [P2] Exclude preserved snapshots by installation owner | [P3] Update the documented rollback conflict outcome
  • reviewed 2026-11-05T18:54:37.689Z sha 17eaf11 :: blocked before merge. :: [P2] Exclude preserved snapshots by installation owner | [P3] Update the documented rollback conflict outcome

Reviewed November 5, 2026, 3:30 PM ET / 20:30 UTC (Revision 3).

Rollback settlement now completes when repair keeps a rollback selected, so the
merged settlement cases assert the kept decision and its warning.
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
Install records are keyed by installation owner while source snapshots are
keyed by plugin ID, so keeping a later `package-owner` record left `demo`'s
snapshot restoration queued and the index owner rejected it. Kept
installations now drop every snapshot they own.

Also prove that cohort rows stored by released updaters settle unchanged, and
describe the kept-change outcome in the npm plugin rollback docs.
@openclaw-barnacle openclaw-barnacle Bot added the docs Improvements or additions to documentation label Nov 5, 2026
fuller-stack-dev added a commit to fuller-stack-dev/openclaw that referenced this pull request Nov 5, 2026
…n kept config

Merges openclaw#193632's review fixes, then applies the same installation-owner mapping
to later source snapshots: a later `demo` snapshot now keeps its `package-owner`
record instead of letting it roll back. Kept config files are written to the run
warning before settlement counts them, and later writes merge into that warning,
so a resumed repair still reports them. The kept-change warning helpers move to
their own module, and the rollback docs cover package files, snapshots and config.
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

@clawsweeper

clawsweeper Bot commented Nov 5, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action. clawsweeper:intake:bug Preliminary submission classification; full source review pending. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Nov 5, 2026
@fuller-stack-dev
fuller-stack-dev merged commit 351af32 into openclaw:main Nov 5, 2026
166 of 167 checks passed
@fuller-stack-dev

Copy link
Copy Markdown
Member Author

Merged via squash.

@fuller-stack-dev
fuller-stack-dev deleted the fix/update-cohort-besteffort-rollback branch November 5, 2026 20:56
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…pdate (openclaw#193632)

* fix(update): keep later plugin changes instead of refusing cohort rollback

A plugin cohort rollback refused outright when a later writer had changed a
plugin migration obligation or install record after the update published it.
The refusal wrote nothing, so the later value survived either way, but the
cohort could never settle and `update repair` failed on every attempt.

Rollback now keeps those later values, restores everything that still matches
the update's publication, completes, and records what it kept as a warning on
the update run, which repair prints and Doctor and status reports show.

* fix(update): keep an installation's snapshots with its later record

Install records are keyed by installation owner while source snapshots are
keyed by plugin ID, so keeping a later `package-owner` record left `demo`'s
snapshot restoration queued and the index owner rejected it. Kept
installations now drop every snapshot they own.

Also prove that cohort rows stored by released updaters settle unchanged, and
describe the kept-change outcome in the npm plugin rollback docs.

* test(update): match best-effort rollback test-line allocation to added lines
wangmiao0668000666 pushed a commit to wangmiao0668000666/openclaw that referenced this pull request Nov 6, 2026
…pdate (openclaw#193632)

* fix(update): keep later plugin changes instead of refusing cohort rollback

A plugin cohort rollback refused outright when a later writer had changed a
plugin migration obligation or install record after the update published it.
The refusal wrote nothing, so the later value survived either way, but the
cohort could never settle and `update repair` failed on every attempt.

Rollback now keeps those later values, restores everything that still matches
the update's publication, completes, and records what it kept as a warning on
the update run, which repair prints and Doctor and status reports show.

* fix(update): keep an installation's snapshots with its later record

Install records are keyed by installation owner while source snapshots are
keyed by plugin ID, so keeping a later `package-owner` record left `demo`'s
snapshot restoration queued and the index owner rejected it. Kept
installations now drop every snapshot they own.

Also prove that cohort rows stored by released updaters settle unchanged, and
describe the kept-change outcome in the npm plugin rollback docs.

* test(update): match best-effort rollback test-line allocation to added lines
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

cli CLI command changes docs Improvements or additions to documentation P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. size: M 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