Skip to content

fix(update): repair refuses forever when plugin files, config or snapshots changed after the update - #193645

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

fuller-stack-dev merged 17 commits into
openclaw:mainfrom
fuller-stack-dev:fix/update-cohort-besteffort-artifacts-config

Conversation

@fuller-stack-dev

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

Copy link
Copy Markdown
Member

Related: #193632, #193132

#193632 has landed (351af32a) and is merged into this branch, so the diff now contains only this PR's changes.

What Problem This Solves

Fixes: openclaw update repair still fails on every attempt when a plugin's package files, a config file the update wrote, or a plugin's source snapshot changed after the update.

User Impact

User impact: repair finishes the plugin rollback in these cases too. It keeps the newer files or snapshot, restores everything that still matches, and lists what it kept in the same update warning that repair, openclaw doctor and the update report show.

Why This Change Was Made

#193632 made rollback keep a later plugin migration obligation or install record instead of refusing. Three related checks still refused, and like the earlier ones they wrote nothing before refusing:

  • Package files. During settlement, artifactUnchanged replaces the throwing assertArtifact. A payload that a later writer replaced, or an originally absent one that now exists, keeps that plugin's current index entry. So does a missing retained or published artifact entry. Retention markers for those payloads are left alone. The begin-time check still throws, because that path is not a rollback.
  • Config files. restorePluginCohortConfigPublication now returns false when a later writer changed what the publication wrote. Before, its own conflict check threw "Configuration changed after update publication". Settlement keeps that file and moves on.
  • Source snapshots. If a later writer changed a plugin's source snapshot, settlement keeps that plugin's whole index entry, record and snapshot together, so they can't disagree. listLaterPluginSourceSnapshotChanges uses the same comparison as the restore.

These still refuse on purpose:

  • config path identity guards, because they protect the write target itself
  • SecretRef preflight and config validation failures
  • corrupt publication chains, which are journal corruption rather than a later writer

Evidence

Red on #193632's head 53d4e682e068, with real install-index files and SQLite:

  • src/plugins/update-cohort-recovery.test.ts: three cases fail.
    • The snapshot successor fails with "Plugin fixture source snapshot changed after the update".
    • Later package files and a later payload at the originally absent path fail with "Plugin cohort artifact changed".
  • src/infra/update-plugin-cohort-recovery.test.ts: the config tests fail on the new restored/kept return value. In the same test, a later edit to the publication's own leaf used to throw "Configuration changed after update publication".

Green on this head:

  • Both files pass (17 and 16 tests).
  • In each kept case, the later value stays, the cohort is deleted, and the update run's warning names the kept item.
  • Negative controls:
    • in the package-files case, a second plugin's matching record is restored
    • the config test restores a matching file to its original bytes before the later edit
    • the other snapshot modes restore the original snapshot
  • Rewritten instead of deleted:
    • the old record/artifact/chain conflict test is now the chain-only refusal plus a keep case, and the artifact case moved into that keep case
    • the snapshot successor and later-payload cases now assert the kept outcome
  • The config path-identity cases still assert refusal.

node scripts/test-projects.mts across those two files, 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 and plugins-platform test shards shows only the existing packages/ai error. The test-line allocation matches the 325 lines this PR adds against current main.

After merging #193632's current head, which includes #193132, one repair settlement test needed a new route. It used to reach a half-finished rollback through a config conflict, and a later config edit no longer stops rollback. The test now interrupts the config restore once, after the migration rows were restored, and checks that the verified candidate still finishes the rollback. Disabling the "already restored" check makes it fail. A separate case checks that rollback keeps a later config edit and names the file in the warning. src/cli/update-cli/update-plugin-cohort-settlement.test.ts passes 12/12, and the related suites pass with 139 tests.

Review follow-up:

  • Snapshots by installation owner. listLaterPluginSourceSnapshotChanges now returns the later snapshot changes themselves, and they are matched to install-record keys by recorded installation owner. A later demo snapshot under the package-owner installation used to let that record roll back to its original. Now the record is kept along with the snapshot. The test covers a later record and a later snapshot in the demo / package-owner shape, with intact payloads so only the later state can stop the restore. It was red before the fix and is green after (19/19).
  • Kept config survives a resumed repair. A kept config file is now written to the run's warning:plugin-cohort:later-changes-kept step before settlement counts it. Every later write merges with the items already recorded instead of replacing them. If the run's history was pruned, settlement still completes. New test: a config edit is kept, then settlement is interrupted after counting the file. Before the fix the next repair reported no warning; now it reports the config file. The helpers moved to src/plugins/update-cohort-kept-changes.ts, which keeps the cohort owner under the line limit.
  • Invalid config still refuses. Autoreview caught that the invalid-config check had been routed through the "later edit" path. A config file that no longer validates now refuses with "Configuration is invalid after update publication", and repair stays pending. Test: red before, green after.
  • Docs. The npm plugin rollback section also covers package files, source snapshots and config files. It says recovery still stops for a replaced config path, config that fails validation or secret resolution, and a corrupt recovery journal.
  • Stored data. The released-row compatibility test from fix(update): repair refuses forever when a plugin changed after the update #193632 also passes on this branch. This PR adds no stored field. A kept config file is recorded only in the existing update-run warning step.
  • Checks. Related suites pass with 153 tests. The settlement file is now 15/15 and the config recovery file 16/16. Format, docs MDX, lint on touched files, import cycles and tsrs (apart from the existing packages/ai error) are clean. Autoreview at P2 is clean after the invalid-config fix.

Second review follow-up:

  • Malformed included config. An included file edited into malformed JSON5 produces an invalid snapshot with no include provenance. The ownership check used to treat that as a later edit, and settlement kept it. Validity is now checked before ownership is classified, and the restore refuses with "Configuration is invalid after update publication". New test in src/infra/update-plugin-cohort-recovery.test.ts with a real gateway.json5 include: red ("resolved false") before the fix, green after.
  • Kept install records, snapshots and package files on a resumed repair. Autoreview suggested recording these before settlement advances, the same way config is handled. They don't need that. Settlement recomputes these items from the current index on every attempt, independent of settledPublications. A probe interrupted settlement after all three publications were counted, and the resumed repair still reported the kept install record or package files. Config is different because a counted config file is never revisited.
  • Checks. Related suites pass with 155 tests. Lint on the touched files, import cycles, format, docs MDX and tsrs (apart from the existing packages/ai error) are clean.

Third review follow-up:

  • Several plugins under one installation. A package can expose more than one plugin, such as pack/a and pack/b, under one install owner. When a later writer refreshed only pack/a's snapshot, settlement kept the installation's record but left pack/b queued for its old snapshot. The installed-index owner then rejected that with "Plugin pack/b source snapshot restoration no longer matches its install record". A kept installation now drops every snapshot restoration it owns. New test with a real two-entry npm package: red with that error before the fix, green after. The installation-owner tests moved to src/plugins/update-cohort-recovery.owner.test.ts, with shared fixtures in update-cohort-recovery.test-support.ts, to keep the main test file under its line cap.
  • update-cli.already-current CI failure. "ends unfinished retention at --timeout with the installed package untouched" fails the same way on current main (071ea8338d93), 3 of 3 local runs, as on this branch, 3 of 3. It isn't caused by this PR.
  • Test-line ratchet. CI reported "over by: 89" against an older ratchet base. Against current main, the allocation equals this PR's net added lines and the ratchet passes with main's own slack.
  • Checks. Related suites pass with 156 tests. Lint on the touched files, the line-cap ratchet, import cycles 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.
…cohort rollback

Plugin cohort rollback still refused outright when a later writer had changed
a published package payload, a config file the update wrote, or a plugin's
source snapshot. Like the earlier obligation and install record cases, the
refusal wrote nothing and left repair unable to settle.

Rollback now keeps those later changes, restores everything that still
matches, completes, and records them in the same update warning. Config path
identity guards and corrupt publication chains still refuse.
@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: M 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

This PR lets update rollback preserve later plugin files, configuration edits, and source snapshots while restoring matching state and recording warnings.

Example: An update changes gateway.port from 18789 to 1, then an independent writer changes it to 18791.

  • Before: Update repair repeatedly refuses with “Configuration changed after update publication”.
  • After: Repair preserves port 18791, completes settlement, and records a warning naming the config file.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) Useful, focused recovery repair with no remaining actionable finding; supplied behavioral validation is at the production-owner harness boundary.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied evidence exercises config, index, artifact, and resumed-settlement owners in process, without claiming a shipped CLI reproduction.
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 keeps refusing after independent plugin or config changes, leaving recovery pending indefinitely.
Reason: The maintainer-authored direction extends the existing preserve-later-changes contract without adding settings or relaxing write-target authority.

Merge readiness

✅ Ready for maintainer review

Keep open: this maintainer-authored PR addresses recovery refusals still present on main, and the previously reported findings are resolved.

Priority: P1
Reviewed head: 9e0aa43578e27a6cb1195524a3d5d620cf480006

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The supplied changed-path validation exercises production recovery owners with real files and SQLite, rather than the shipped update-repair CLI.
Agent review details

How this fits together

Update repair passes the recorded plugin cohort and current recovery authority to settlement, which restores matching config and installed-index state and reports preserved changes through update history.

flowchart TD
  A[Update repair] --> B[Cohort settlement]
  C[Recovery journal] --> B
  B --> D[Config owner]
  B --> E[Installed index owner]
  B --> F[Artifact retention owner]
  B --> G[Update history warnings]
Loading

Technical review

Best possible solution:

Use the existing recovery owners to preserve later changes with durable warnings while retaining path-identity, validation, and journal-integrity refusals.

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

Current-main source deterministically refuses later artifact, config, and snapshot changes; the PR supplies failing-before and passing-after owner-test results, which were inspected but not rerun during this read-only review.

Is this the best way to solve the issue?

The patch extends the established best-effort settlement policy through existing config, index, and retention owners, with focused regressions for distinct failure boundaries and no unnecessary parallel recovery mechanism.

AGENTS.md: found and applied where relevant.

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

Provenance checked

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/installed-plugin-index-source-snapshots.ts:133 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/installed-plugin-index-source-snapshots.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 +124, Tests +325, Docs +1, Other +9. Total +459 across 11 files. Added test files: 2.

View PR surface stats
Area Files Added Removed Net
Source 4 165 41 +124
Tests 5 560 235 +325
Docs 1 6 5 +1
Config 0 0 0 0
Generated 0 0 0 0
Other 1 9 0 +9
Total 11 740 281 +459

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.

Review metrics

Metric Value Why it matters
Production versus test changes Production +165/-41 lines; tests and fixtures +560/-235 lines. Production growth handles distinct preservation boundaries and restart-safe warnings; test growth covers installation ownership, invalid includes, later payloads, and interrupted settlement, including relocated coverage.

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: Repeated repair refusal leaves an interrupted update unresolved and can block 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 (4 earlier review cycles)
  • reviewed 2026-11-05T18:14:55.326Z sha 6a1973c :: blocked before merge. :: [P2] Preserve the installation owner of a later source snapshot | [P2] Retain kept-config warnings before advancing settlement | [P3] Update the documented rollback conflict outcome
  • reviewed 2026-11-05T19:12:15.160Z sha 11ced7f :: blocked before merge. :: [P2] Preserve the installation owner of a later source snapshot | [P2] Retain kept-config warnings before advancing settlement | [P3] Update the documented rollback conflict outcome
  • reviewed 2026-11-05T20:30:22.940Z sha 99b6d1c :: needs changes before merge. :: [P2] Reject invalid includes before treating missing ownership as a later edit
  • reviewed 2026-11-05T21:24:08.797Z sha e5c560e :: needs changes before merge. :: [P2] Preserve sibling snapshots when keeping their installation record

Reviewed November 5, 2026, 5:46 PM ET / 22:46 UTC (Revision 5).

Rollback settlement now completes when repair keeps a rollback selected, so the
merged settlement cases assert the kept decision and its warning.
…ack' into fix/update-cohort-besteffort-artifacts-config
…onflict

A later config edit no longer stops rollback, so the settlement test that
reached a partial rollback through a config conflict now interrupts the config
restore directly, and a separate case covers keeping the edit.
@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. merge-risk: 🚨 compatibility 🚨 May break existing users, config, migrations, defaults, or upgrade paths. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 5, 2026
@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
… later snapshot

When a later writer refreshed one plugin's snapshot, settlement kept that
installation's record but left its other plugins' snapshot restorations queued.
The index owner then rejected them because they no longer matched the kept
record. A kept installation now drops all of its plugins' restorations.

The installation-owner tests move to a sibling file with shared fixture helpers,
keeping the cohort recovery test file under its line cap.
@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 58155d2 into openclaw:main Nov 5, 2026
156 of 157 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-artifacts-config branch November 5, 2026 23:17
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 6, 2026
…shots changed after the update (openclaw#193645)

* 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 later plugin payloads, config and snapshots during cohort rollback

Plugin cohort rollback still refused outright when a later writer had changed
a published package payload, a config file the update wrote, or a plugin's
source snapshot. Like the earlier obligation and install record cases, the
refusal wrote nothing and left repair unable to settle.

Rollback now keeps those later changes, restores everything that still
matches, completes, and records them in the same update warning. Config path
identity guards and corrupt publication chains still refuse.

* test(update): exercise partial rollback by interruption, not config conflict

A later config edit no longer stops rollback, so the settlement test that
reached a partial rollback through a config conflict now interrupts the config
restore directly, and a separate case covers keeping the edit.

* 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

* fix(update): keep cohort rollback pending for invalid config

A config file that no longer validates is not a later edit to keep. Its
restore now refuses with its own error, so repair stays pending as the docs
describe, while ordinary later edits are still kept.

* fix(update): refuse a malformed included config before treating it as a later edit

An included file edited into malformed JSON5 has no include provenance, so the
ownership check classified it as a later edit and settlement kept it. Check
validity first and refuse with the same invalid-config error, so repair stays
pending.

* test(update): match best-effort artifact and config test-line allocation to added lines

* fix(update): keep every plugin snapshot of an installation kept for a later snapshot

When a later writer refreshed one plugin's snapshot, settlement kept that
installation's record but left its other plugins' snapshot restorations queued.
The index owner then rejected them because they no longer matched the kept
record. A kept installation now drops all of its plugins' restorations.

The installation-owner tests move to a sibling file with shared fixture helpers,
keeping the cohort recovery test file under its line cap.

* test(update): match best-effort artifact and config 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: XL 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