Skip to content

fix(update): preserve serving state during candidate plugin maintenance - #208776

Merged
obviyus merged 3 commits into
mainfrom
fix/candidate-plugin-no-migrate
Nov 30, 2026
Merged

obviyus merged 3 commits into
mainfrom
fix/candidate-plugin-no-migrate

Conversation

@obviyus

@obviyus obviyus commented Nov 30, 2026 •

Copy link
Copy Markdown
Collaborator

What Problem This Solves

Older updaters can ask a candidate to maintain plugins while the old Gateway still serves. Acquiring the plugin lifecycle lease can then migrate live shared state ahead of activation, leaving that Gateway unable to read it. This broke both 2026.12.1-beta first-hop upgrade jobs in Package Acceptance 46335650023.

User Impact

Candidate plugin maintenance now returns the existing warning result when serving state needs a newer schema and no update trial is active. It preserves the database, sidecars, configuration, and plugin index; the activated build converges plugins after readiness. Missing/current state and active trials retain normal behavior. Unreadable state fails explicitly.

Why This Change Was Made

One artifact-preserving schema read at the maintenance entry prevents all configuration preparation, plugin-index reads, and lease acquisition on the deferred path. It uses existing schema, trial, and warning owners without changing global database/lease defaults, launcher formats, protocols, or dependencies.

The author simplification pass retained one runtime decision owner and no new update machinery. Net change: +28 runtime lines, +62 Docker harness lines, +281 test lines. Regression coverage stays in the existing host-broker-routed maintenance test file; the readiness test file was already at its line cap. The harness additionally activates a matching prepared trial before demanding terminal success, using the existing Gateway readiness path and twelve-minute settlement budget; terminal assertions are unchanged.

Evidence

  • On base 531c797, both DELETE/WAL older-schema regressions failed at the intended warning contract (returned ok).
  • Focused vitest-source proof on studio: all 8 maintenance tests passed, including older-state artifact preservation/no configuration-index-lease work, missing/current state, unreadable state, active trial, interruption cleanup, and post-ready convergence (81.57 seconds; 167.41 seconds with worker preparation/wrapper). The unchanged readiness suite also passed in the earlier combined 37-test run. A subsequent test-only repair replaces nondeterministic recursive directory enumeration with the bounded sorted walker and path-keyed SHA-256 snapshots, retaining every file; both repaired artifact cases passed (0.95 seconds of tests; 74.46 seconds including preparation).
  • mbp-m5 was attempted first and timed out. OPENCLAW_* variables were stripped from direct test/check commands.
  • Final targeted formatting and the repaired lint rules passed with zero warnings/errors. The initial broad targeted lint timed out after 90 seconds on the overloaded host; compiler/build and full lint proof remain CI-owned. No local full build claimed.
  • Runtime-head PR CI passed for 5f89e78. Final-head CI is still running for 892941f, with the unrelated UI mock-export ratchet failure tracked by #208843. Harness unit proof passed 42 tests (6.06 seconds), with 32 affected caller tests also passing (18.63 seconds), targeted lint/format and bash -n green.
  • Package Acceptance tested the unchanged production parent 8e08095. Candidate resolution/full package builds and integrity passed in both runs. Both npm 12 install.sh jobs failed at the known installed-package budget (main: installed package tree over the 47,500-entry budget (47,745), 2,255 entries from the shipped-updater cap #208295): 47,562 entries versus 47,500.
  • The two beta cells on the final head now end in a visible, safe refusal and launcher rollback, not the original schema migration failure. The candidate still identifies as 2026.11.12, older than the beta baseline that last wrote the config. Both selected update runs finish failed; the candidate is not declared ready. The launcher switches back and the baseline becomes ready. The remaining beta-cell red is this candidate/baseline version skew.

The beta.1 Gateway log contains the following two lines (beta.2 has the same refusal naming 2026.12.1-beta.2):

Refusing to run gateway state preparation because this OpenClaw binary (2026.11.12) is older than the config last written by OpenClaw 2026.12.1-beta.1.
openclaw: new build failed to start; switched back to /tmp/openclaw-upgrade-survivor-runtime/npm-prefix/lib/node_modules/openclaw

The stable baseline and update-restart-auth results remain green:

Lane / published baseline Result
published-upgrade-survivor / 2026.12.1-beta.1 Safe refusal + rollback; lane failed on version skew
published-upgrade-survivor / 2026.12.1-beta.2 Safe refusal + rollback; lane failed on version skew
published-upgrade-survivor / 2026.11.5 Passed
published-upgrade-survivor / 2026.11.10 Passed
published-upgrade-survivor / 2026.11.11 Passed
published-upgrade-survivor / 2026.11.12 Passed
update-restart-auth / openclaw@latest Passed

- Preserve older serving state before configuration, index reads, or lifecycle leases.
- Leave ordinary startup migration and post-ready plugin convergence unchanged.
@clawsweeper

clawsweeper Bot commented Nov 30, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Pull request received.

ClawSweeper review complete

ClawSweeper finished reviewing this revision.

View the workflow run.

@clawsweeper clawsweeper Bot added P1 High-priority user-facing bug, regression, or broken workflow. impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. labels Nov 30, 2026
@obviyus
obviyus marked this pull request as ready for review November 30, 2026 03:56
@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. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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. labels Nov 30, 2026
@clawsweeper

clawsweeper Bot commented Nov 30, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs changes before merge.

What this changes

This PR defers candidate plugin maintenance when shared state needs migration and no update trial is active.

Example: An older updater invokes candidate plugin maintenance before stopping the serving Gateway.

  • Before: Plugin maintenance can reach a lifecycle lease that opens and migrates the serving database.
  • After: The candidate reads the schema without changing its artifacts and returns a warning, leaving plugin convergence to the activated Gateway.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The production fix is focused and worthwhile, but introduced lint and preservation-test failures block a clean verdict; no persisted format or migration definition changes.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is exempt from the contributor proof gate; supplied evidence exercises maintainPlugins with real SQLite, while the scheduled convergence case mocks subprocess execution and published upgrade acceptance remains incomplete.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: An upgrade candidate can migrate shared state while the old Gateway still serves, making that Gateway unable to read it.
Reason: The change restores the documented handoff invariant, addresses a reported acceptance failure and has maintainer-authored direction.

Merge readiness

⛔ Needs changes before merge - 2 items remain

Keep this PR open: it addresses a concrete update-contract violation still present on main, but the introduced preservation test and directory traversal need repair.

Reviewed head: 8e08095df37ee9ddaa747074b734481e36d12971

Before merge

  • Use the supported directory walker in the snapshot helper (P2) - The added fs.readdir call sets recursive:true, which the enabled openclaw-boundaries/no-recursive-readdir rule rejects even in tests. This is a concrete introduced violation in the failing boundary-lint bundle. Use listDirectoryTreeStrict from src/infra/directory-walk.ts and resolve its relative entries when reading snapshot bytes.
  • Resolve the new preservation test's credential-store mutation (P2) - On the reviewed head, checks-node-changed-5 reaches this assertion and fails because client/credentials.sqlite was created after the baseline snapshot. The new regression therefore does not pass in its actual CI execution environment. Trace that writer and establish the fixture's completed initialization before the baseline, or repair an unintended maintenance-side write; retain the database, sidecar, configuration and index preservation checks rather than excluding the unexpected change without explanation.

Findings

  • [P2] Use the supported directory walker in the snapshot helper — src/update/plugins.test.ts:49
  • [P2] Resolve the new preservation test's credential-store mutation — src/update/plugins.test.ts:86
Agent review details

How this fits together

The candidate's update plugins command receives maintenance options, prepares configuration and installed-plugin records, and invokes the existing plugin maintenance owner.

flowchart TD
  A[Older updater] --> B[Candidate plugin command]
  B --> C[Read existing schema]
  C --> D[Return deferred warning]
  C --> E[Existing plugin maintenance]
  F[Activated Gateway readiness] --> E
Loading

Technical review

Best possible solution:

Retain the early schema guard in maintainPlugins and repair the preservation fixture and directory traversal without weakening artifact checks.

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

Current main reaches configuration and lifecycle operations without checking the serving schema first; the linked acceptance failures and reported base regressions support that path, but this read-only review did not execute it.

Is this the best way to solve the issue?

The early guard uses existing schema, trial and warning owners at the correct maintenance boundary, with no parallel migration mechanism or new configuration.

Full review comments:

  • [P2] Use the supported directory walker in the snapshot helper — src/update/plugins.test.ts:49
    The added fs.readdir call sets recursive:true, which the enabled openclaw-boundaries/no-recursive-readdir rule rejects even in tests. This is a concrete introduced violation in the failing boundary-lint bundle. Use listDirectoryTreeStrict from src/infra/directory-walk.ts and resolve its relative entries when reading snapshot bytes.
    Confidence: 0.99
  • [P2] Resolve the new preservation test's credential-store mutation — src/update/plugins.test.ts:86
    On the reviewed head, checks-node-changed-5 reaches this assertion and fails because client/credentials.sqlite was created after the baseline snapshot. The new regression therefore does not pass in its actual CI execution environment. Trace that writer and establish the fixture's completed initialization before the baseline, or repair an unintended maintenance-side write; retain the database, sidecar, configuration and index preservation checks rather than excluding the unexpected change without explanation.
    Confidence: 0.98

Overall correctness: patch is incorrect
Overall confidence: 0.95

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

Acceptance criteria:

  • pnpm test src/update/plugins.test.ts --maxWorkers=1
  • pnpm exec oxlint src/update/plugins.ts src/update/plugins.test.ts
  • pnpm lint:no-chained-type-assertions
  • git diff --check

What I checked:

PR surface

Source +28, Tests +210. Total +238 across 2 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 1 29 1 +28
Tests 1 211 1 +210
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 2 240 2 +238

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 growth production +28 net lines; tests +210 net lines A small entry-point guard adds coverage for DELETE/WAL preservation, missing/current state, active trials, unreadable state and post-migration maintenance.

Labels

Label changes:

  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • add status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

Label justifications:

  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦐 gold shrimp and patch quality is 🦪 silver shellfish.
  • status: ⏳ waiting on author: ClawSweeper has contributor-facing work open and is waiting for author action.

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 readiness starts with the lower of the proof and patch scores. It is capped at 3/6 if the fix is partial, the change offers little benefit, a product decision is still open, or the PR reverses an earlier decision without saying why. ✨ 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 November 29, 2026, 11:16 PM ET / November 30, 2026, 04:16 UTC.

- Use the bounded sorted directory walker and path-keyed SHA-256 snapshots.
- Keep the warning assertion at the serialized updater JSON boundary.
- Keep terminal success assertions unchanged and wait for the selected run after readiness.
- Preserve the original prepared receipt and retain offline migration checks.
- Cover immediate success, prepared success, failed activation, and settlement timeout.
@obviyus

obviyus commented Nov 30, 2026

Copy link
Copy Markdown
Collaborator Author

Maintainer override: the only red CI job is the mock-isolation ratchet (checks-fast-baseline-ratchets#141641835082) on ui/src/pages/channels/channel-settings-presentation.transport.node.test.tsx:25, which this PR does not touch; it is a main defect filed as #208843. CI on the same runtime code (run 46352454632) is fully green; the local review of this head is clean.

@obviyus
obviyus merged commit 4d00e12 into main Nov 30, 2026
154 of 161 checks passed
@obviyus
obviyus deleted the fix/candidate-plugin-no-migrate branch November 30, 2026 05:49
vincentkoc added a commit that referenced this pull request Nov 30, 2026
* commit 'c5c1dc278a6f789d739d70afe192c4d1e37058f5':
  fix(ci): include provider rejection text in PR tooling (#208891)
  feat: let plugins bring their own sidebar icon (#208885)
  docs: clarify node pairing and credentials on PostgreSQL gateways (#208850)
  fix(ui): show a confirmed subagent stop once in chat (#208533)
  fix(ui): keep collapsed work close to the reply in long chats (#207843)
  fix(update): finish failed recovery startup records (#208794)
  chore(ci): inventory media worker lifecycles (#208888)
  fix: use the same clock icon for Automations (#208539)
  improve(ci): reduce compiler round trips in database checks (#208878)
  fix(ci): preserve complete adaptive test observations (#208874)
  test(gateway): isolate usage context database fixtures (#208304)
  fix: avoid false worker cleanup failures (#208861)
  fix: let Git upgrade acceptance fetch its missing baseline (#208746)
  fix: isolate scheduled Processes reads in the Control UI config-change test (#208205)
  fix: make plugin hash worker tests independent of runner memory (#208860)
  fix(update): preserve serving state during candidate plugin maintenance (#208776)
  test(ui): preserve exact session keys in older chat links (#208873)
  docs(cli): say what bounds a yielded agent turn's subagent wait without --timeout (#208858)
vincentkoc added a commit that referenced this pull request Nov 30, 2026
* fix: restore managed worktrees from bare primary repositories

Managed worktrees created from a linked checkout record its primary repository. Resolve that registration during inspection, removal, and snapshot restore while keeping new checkout creation strict.

* Merge verified upstream CI repairs into managed worktree recovery

* commit 'c5c1dc278a6f789d739d70afe192c4d1e37058f5': (64 commits)
  fix(ci): include provider rejection text in PR tooling (#208891)
  feat: let plugins bring their own sidebar icon (#208885)
  docs: clarify node pairing and credentials on PostgreSQL gateways (#208850)
  fix(ui): show a confirmed subagent stop once in chat (#208533)
  fix(ui): keep collapsed work close to the reply in long chats (#207843)
  fix(update): finish failed recovery startup records (#208794)
  chore(ci): inventory media worker lifecycles (#208888)
  fix: use the same clock icon for Automations (#208539)
  improve(ci): reduce compiler round trips in database checks (#208878)
  fix(ci): preserve complete adaptive test observations (#208874)
  test(gateway): isolate usage context database fixtures (#208304)
  fix: avoid false worker cleanup failures (#208861)
  fix: let Git upgrade acceptance fetch its missing baseline (#208746)
  fix: isolate scheduled Processes reads in the Control UI config-change test (#208205)
  fix: make plugin hash worker tests independent of runner memory (#208860)
  fix(update): preserve serving state during candidate plugin maintenance (#208776)
  test(ui): preserve exact session keys in older chat links (#208873)
  docs(cli): say what bounds a yielded agent turn's subagent wait without --timeout (#208858)
  test(ui): keep real exports in the channel settings distribution mock (#208855)
  test(normalization): preserve inline code in quoted previews (#208857)
  ...

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

Labels

impact:session-state Session, memory, transcript, context, or agent state can drift or corrupt. P1 High-priority user-facing bug, regression, or broken workflow. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. scripts Repository scripts size: M status: ⏳ waiting on author ClawSweeper has contributor-facing work open and is waiting for author action.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant