Skip to content

fix(update): preserve config edits during plugin finalization - #189819

Merged
roboclaw-bot merged 3 commits into
mainfrom
roboclaw/plugin-finalization-config-race
Oct 31, 2026
Merged

roboclaw-bot merged 3 commits into
mainfrom
roboclaw/plugin-finalization-config-race

Conversation

@roboclaw-bot

@roboclaw-bot roboclaw-bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Collaborator

Related: #189778

What Problem This Solves

Fixes plugin finalization aborting an update with “config changed since last load” when another writer edits config during package or plugin work, including same-version repairs.

User Impact

Unrelated edits survive finalization. Already-applied changes succeed; owned-field conflicts or repeated concurrent writes produce a warning with openclaw plugins doctor / openclaw doctor --fix guidance instead of failing the core update or preventing Gateway recovery. Existing ownership, path, validation, and I/O refusals remain enforced. A plugin may remain unavailable until repaired.

This fix is not yet released. The separate Windows Gateway recovery repair is on main in #189647 (ed79334f), also not yet released. Leave #189778 open until release.

Why This Change Was Made

Finalization previously replaced config against a hash captured before awaited plugin work. It now reapplies only its changed fields to fresh config using the existing config lock, five-attempt retry, and plugin publication/index rollback owner. The planning baseline is retained before in-memory channel restoration. Authority refusals propagate unchanged; warning settlement rechecks authority after rollback.

The original report does not identify the concurrent writer. Same-version convergence can run while the Gateway is online; the regressions exercise ordinary concurrent config edits without claiming to reproduce the reporter’s exact writer or Windows update.

Evidence

  • Include/env retry invariant: every attempt reads a fresh snapshot and merges its write options. The retry loop reuses the prepared snapshot only for attempt zero. The snapshot owner returns newly captured env restoration, include hashes/targets, and plugin metadata. The writer selects the include boundary from that snapshot and restores authored env references.
  • The extended production-path persistence test switches include destinations and changes the env value during the first commit. It proves the retry preserves the root $include, root and included env references, the old include byte-for-byte, concurrent values in the new include, and install-index rollback after exhaustion. No secrets are inlined and the include is not flattened or clobbered.
  • The extended case fails with the original base finalization code (603106d1a96a: include conflict) and also fails when only the stale envSnapshotForRestore is retained (one commit attempt instead of the required successful second attempt). Both temporary controls were restored. The complete persistence suite passes: 17 tests, 31.08 s Vitest / 32.98 s wrapper. Final formatted retry cases pass: 2 tests, 39.99 s / 42.21 s including cold worker compilation.
  • Targeted CLI-update test typecheck, focused oxlint, formatting, and git diff --check pass. Earlier unchanged-source proof covers 101 focused persistence, authority, finalizer, config-fence, and degradation cases; another 19 consumer/authority cases passed after the fixture correction.
  • Fresh independent Codex autoreview, P0–P2, base 603106d1a96a through the final local candidate: scoped-clean, no findings. The committed patch matches that candidate. Existing hosted ClawSweeper review found no code defects.
  • Simplification retains the existing lock/retry/rollback owners. Production grows by 99 net lines; 177 net test/fixture lines cover distinct finalization contracts, including 50 additional lines extending the existing retry test. No test-only production seam, new schema, persisted format, public config/SDK contract, dependency, or config option is introduced. Persistence proof uses real config/include/index writes; a cheaper mocked layer cannot establish these guarantees.
  • Exact-head CI run 41252307222 is fully green on 17bfaea3d1a2674dde4341bd1e33863ed723ee46, including all three PostgreSQL conformance shards, the aggregate CI gate, and current dependency/security guards. Zero failures and zero pending checks. Prior-head CI remains historical evidence only.
  • Installed latest-stable-to-candidate Windows upgrade and real Gateway/model proof were not run. External package/service/provider operations are stubbed in local finalizer composition. This limitation remains disclosed; no installed-upgrade or live Gateway claim is made.

Work sessions

Reapply finalization changes to fresh config under the existing bounded mutation retry and lock. Preserve unrelated edits, roll back pending plugin publication on conflicts, and record actionable warnings while retaining ownership refusals.

Allocate 107 net regression lines for concurrent root/include edits, idempotency, owned-field conflicts, and bounded publication retry proof.

Co-authored-by: steipete <[email protected]>
@clawsweeper

clawsweeper Bot commented Oct 31, 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 docs Improvements or additions to documentation cli CLI command changes size: M labels Oct 31, 2026
@roboclaw-bot
roboclaw-bot marked this pull request as ready for review October 31, 2026 22:26
Recheck authority only when settling a config-content warning so an existing ownership refusal propagates unchanged. Keep CLI orchestration fixtures aligned with the real config transform and replacement contracts through synthetic I/O.

Allocate 20 additional fixture lines, for 127 net test lines across this fix.

Co-authored-by: steipete <[email protected]>
@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. 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 Oct 31, 2026
@clawsweeper

clawsweeper Bot commented Oct 31, 2026

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge.

What this changes

Plugin finalization reapplies its changes to fresh config with bounded retries and reports conflicting edits as repair warnings.

Example: Another writer changes gateway.port from 18789 to 19001 while plugin finalization disables fixture.

  • Before: Publication rejects the stale config hash and aborts finalization.
  • After: Finalization preserves port 19001 and saves fixture.enabled=false.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused patch with distinct persistence regressions and no definite correctness finding, held below an end-to-end pass by unproven upgrade compatibility.
Proof confidence 🦐 gold shrimp (3/6) Real behavior proof is not required for maintainer- or bot-authored pull requests.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An update or same-version repair aborts plugin finalization when another writer changes config during plugin work.
Reason: Preserving unrelated authored edits while keeping conflicts recoverable satisfies the existing update contract, and maintainer authorship establishes direction.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep this PR open: it addresses a concrete current-main finalization failure, and no definite introduced defect was found; the maintainer author explicitly requests parent review before merge.

Priority: P1
Reviewed head: 65d303bf818e2aeb9f2696fc81efed72e24cd212

Before merge

  • Add data-model compatibility proof - The review found that existing stored data may not work after upgrade. Show that existing data still loads and works with this change.

Findings

None.

Tests

  • Missing end-to-end proof: Supply an installed v2026.10.9-to-candidate update or repair showing concurrent root/include edits preserved, conflict rollback recorded, and Gateway recovery with existing settings and plugin state intact.
Agent review details

How this fits together

The update CLI runs plugin convergence, then publishes authored config and matching install records through the existing config writer and plugin lifecycle owner.

flowchart TD
  A[Update CLI] --> B[Plugin convergence]
  B --> C[Changed config fields]
  C --> D[Config lock and fresh snapshot]
  D --> E[Guarded config and index publication]
  E --> F[Success or repair warning]
Loading

Technical review

Best possible solution:

Retain selective publication through the existing mutation and rollback owners, then qualify the candidate through an installed upgrade preserving existing config and plugin state.

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

Current main captures a hash before awaited plugin work and later requires that hash for publication; an intervening write reaches the conflict check, although the linked reporter's exact writer remains unknown and no target code was executed during this review.

Is this the best way to solve the issue?

The focused approach preserves the optimistic safety check while applying only finalization-owned changes; existing merge-patch helpers do not directly supply its literal-null and already-applied-value semantics.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Config publication against the planning snapshot changes intended behavior with a stated reason (02aa587: The cited CLI cleanup retained guarded config/index publication; this is a carrying commit, not a verified original introduction.)
  • Authored config and reference preservation keeps the original intent (07636e8: Preserve authored settings, include ownership, and environment references through updates and setup.)
  • Updater authority propagation keeps the original intent (1232d3f: Candidate-runtime finalization must retain original executor and destination authority through actual writes.)
  • Package settlement and publication rollback keeps the original intent (6fd646e: Restore plugin packages when core updates roll back and retain the existing cohort publication owner.)
  • Shared orchestration fixtures keeps the original intent (6f303d4: Share CLI config and assertion fixtures; the patch keeps synthetic I/O while delegating mutation semantics to production owners.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +99, Tests +127, Docs +9, Other +2. Total +237 across 8 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 107 8 +99
Tests 3 129 2 +127
Docs 1 9 0 +9
Config 0 0 0 0
Generated 0 0 0 0
Other 1 2 0 +2
Total 8 247 10 +237

Review metrics

Metric Value Why it matters
Production versus regression growth Production +107/-8; tests and support +129/-2 Growth implements selective conflict handling and reuses existing persistence machinery; added cases cover distinct preservation, idempotency, conflict, and retry failures.

Labels

Label changes:

  • add P1: Concurrent config edits can abort a released core update or same-version repair during plugin finalization.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Label justifications:

  • P1: Concurrent config edits can abort a released core update or same-version repair during plugin finalization.
  • rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp and patch quality is 🐚 platinum hermit.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Record the installed latest-stable upgrade scenario described in the compatibility proof gap.

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.

Reviewed October 31, 2026, 6:56 PM ET / 22:56 UTC.

Extend finalization retry proof to switch include destinations and refresh an env value between attempts. Assert authored references survive, the old include stays unchanged, and concurrent values in the new include are preserved. Allocate 50 additional regression lines, for 177 net test lines across the fix.

Co-authored-by: steipete <[email protected]>
@roboclaw-bot
roboclaw-bot merged commit c633ec6 into main Oct 31, 2026
163 checks passed
@roboclaw-bot
roboclaw-bot deleted the roboclaw/plugin-finalization-config-race branch October 31, 2026 23:48
@roboclaw-bot

Copy link
Copy Markdown
Collaborator Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 1, 2026
…aw#189819)

Plugin finalization now re-reads config under the existing write lock and reapplies only its changed paths. Unrelated edits and already-applied values survive; owned-field conflicts or exhausted retries produce actionable doctor warnings while preserving updater authority refusals and plugin publication rollback.

Extend the existing retry regression to change include destinations and env values between real commit attempts. Preserve authored references, old include bytes, concurrent settings in the new include, and install-index rollback. Allocate 177 net test/fixture lines for these distinct finalization contracts, including the 50-line include/env retry extension; keep the shared scalar unchanged.

Validation: 17 persistence tests; targeted typecheck, lint, formatting; original-code and stale-env negative controls; fresh P0-P2 Codex autoreview with no findings. Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/41252307222 at 17bfaea. Installed Windows upgrade and live Gateway/model proof remain unrun.

Related: openclaw#189778. Not yet released; leave the issue open.

Co-authored-by: steipete <[email protected]>
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Plugin finalization now re-reads config under the existing write lock and reapplies only its changed paths. Unrelated edits and already-applied values survive; owned-field conflicts or exhausted retries produce actionable doctor warnings while preserving updater authority refusals and plugin publication rollback.

Extend the existing retry regression to change include destinations and env values between real commit attempts. Preserve authored references, old include bytes, concurrent settings in the new include, and install-index rollback. Allocate 177 net test/fixture lines for these distinct finalization contracts, including the 50-line include/env retry extension; keep the shared scalar unchanged.

Validation: 17 persistence tests; targeted typecheck, lint, formatting; original-code and stale-env negative controls; fresh P0-P2 Codex autoreview with no findings. Exact-head CI: https://github.com/openclaw/openclaw/actions/runs/41252307222 at 17bfaea. Installed Windows upgrade and live Gateway/model proof remain unrun.

Related: #189778. Not yet released; leave the issue open.

Co-authored-by: steipete <[email protected]>

(cherry picked from commit c633ec6)

Stable adaptation: retain the v2026.11.5 lifecycle and tentative install-index rollback owners; do not import the absent schema-backed cohort transaction feature. Preserve the stable producer assessment as unsafe/convergence-failed on deferred repair. The source merge, fresh provenance retries, configBaseline and warning advisory paths are otherwise unchanged.

Co-authored-by: RomneyDa <[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 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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant