Skip to content

fix(update): finish 2026.9.2 updates when the Gateway publishes the deferred schema mid-update - #192140

Merged
steipete merged 2 commits into
mainfrom
codex/g31-existing-write-peer-publication
Nov 4, 2026
Merged

steipete merged 2 commits into
mainfrom
codex/g31-existing-write-peer-publication

Conversation

@steipete

@steipete steipete commented Nov 3, 2026 •

Copy link
Copy Markdown
Contributor

Related: #191357

What Problem This Solves

Fixes: updating from 2026.9.2 can end with "Update has unfinished recovery" and leave that update's recovery pending, when the restarted Gateway publishes the deferred state schema version at the same moment the updater settles its plugin cohort.

User Impact

User impact: an update that runs while a 2026.9.2 run's five-minute schema grace window ends now completes normally. Before this change, the plugin lifecycle lease failed with Existing-state schema metadata is inconsistent.. The run then reported update-recovery-pending with runtime-verification-failed, and openclaw update repair was the only way forward.

Why This Change Was Made

2026.9.2 updaters defer publishing the shared-state user_version. When the five-minute grace expires, the restarted Gateway's update-run watcher publishes the header and schema_meta in one transaction. An existing-schema writer, here the plugin lifecycle lease taken by settleUpdatePluginCohort, admits its schema facts before BEGIN. It then waits on the publisher's write lock, and inside its own transaction it reads the fresh schema_meta. It compared that value with the version admitted before BEGIN (15 against the current version) and refused. Every later step reported only the follow-on own-run UpdateRecoveryRequiredError.

#191357 added the right rule for the maintenance assertion: adopt a peer's publication only when the header and the metadata both read current inside this connection. This PR moves that rule into the admission owner (openclaw-state-db-admission.ts), next to publishStateSchemaVersionAdmission. The maintenance assertion and the existing-schema writer now share it, and the writer publishes the adopted version to its subset admission. A genuinely inconsistent database still refuses.

Evidence

  • Regression test. src/state/openclaw-state-db-peer-publication.test.ts, "admits a peer process publication for existing-schema writes". A real child process holds BEGIN IMMEDIATE while it publishes the header and schema_meta. Meanwhile the parent runs an existing-schema write with the lease schema subset. Red on base with the exact production message, Existing-state schema metadata is inconsistent.; green with the fix. The peer-publication, existing-write and lease-maintenance suites all pass, 34 tests.
  • Masked first error, recovered from an instrumented main build of the local update-first-hop-compat-2026.9.2 Docker lane: OpenClawStateLeaseError: failed to acquire plugin lifecycle lease core:plugin-lifecycle/global: store unavailable (storage-error). It was raised from settleUpdatePluginCohort → commitVerifiedUpdatePluginCohort → reportResult, with cause Existing-state schema metadata is inconsistent.. Unwind admission then raised the own-run has unfinished recovery refusal, which is what CI shows. CI hit the same signature on main d615435 in run 41656977990, which failed 1 of 3.
  • Local update-first-hop-compat-2026.9.2 Docker lane, red/green on one Crabbox AWS box (c7a.48xlarge), 3 concurrent runs per batch, packages built from the same base 01838fc.
    • Base (main 01838fc): 3 of 3 failed with has unfinished recovery.
    • This head (459ad51): 3 of 3 passed. All three hops succeeded and assertions passed, with positive-second ~395 s and positive-unsupported-admission ~390 s.
    • Earlier batches on main d615435 failed 3 of 3, 2 of 3 and 3 of 3.
  • Static checks. Type-aware oxlint core shard and tsgo:core pass.
  • Review. $autoreview is scoped-clean. An independent codex exec review returned NO FINDINGS.
  • Landing. The 3-of-3 lane runs used production-identical 459ad51; merged head 9df8ea4 changes only the regression test. Exact-head CI 41869260521 was red on inherited main failures only (browser-panel TS2322 from improve(ui): clarify browser and link reader feedback #192281, creator-review e2e after improve(ui): clarify templates and Apps directory copy #192284, test-line ceiling debt), so this landed through the attributed pre-existing-failure route.

@clawsweeper

clawsweeper Bot commented Nov 3, 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.

@clawsweeper clawsweeper Bot added clawsweeper:intake:bug Preliminary submission classification; full source review pending. P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. and removed clawsweeper:intake:bug Preliminary submission classification; full source review pending. labels Nov 3, 2026
@clawsweeper

clawsweeper Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR lets existing-schema writers adopt a peer's completed schema publication through the shared admission owner.

Example: An updater retains schema version 15 while the Gateway publishes version 39 before plugin-cohort settlement.

  • Before: Lease acquisition rejects consistent metadata as inconsistent, leaving update recovery pending.
  • After: The writer verifies that both physical markers equal 39, refreshes admission, and continues.

Review scores

Measure Result What it means
Overall readiness 🧂 unranked krab (1/6) The production repair is focused and source-consistent; the supplied validation stops at regression tests rather than a successful fixed updater flow.
Proof confidence 🧂 unranked krab (1/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 can leave its own recovery pending when the Gateway publishes deferred schema metadata during plugin-cohort settlement.
Reason: The maintainer-authored direction restores documented legacy-upgrade behavior without changing configuration, defaults, publication timing, or public APIs.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it repairs a concrete update failure still present on current main, and source review found no introduced correctness defect.

Priority: P2
Reviewed head: 459ad51a3e656e2f3bf0f98b6a337bfbe338a490

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: A completed fix-head updater run must cover deferred publication during plugin-cohort settlement, with existing settings and data preserved.
Agent review details

How this fits together

The shared-state admission layer receives SQLite connections and schema metadata, validates storage compatibility, and supplies admitted facts to maintenance operations and transactional writers.

flowchart TD
  A[Gateway publication watcher] --> B[SQLite header and metadata]
  C[Updater plugin settlement] --> D[Existing schema writer]
  D --> E[Shared admission owner]
  B --> E
  E --> F[Transactional lease operation]
Loading

Technical review

Best possible solution:

Keep peer-publication adoption in the existing admission owner and retain the transaction-local ownership, integrity, and schema checks.

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

Source confirms that admission occurs before BEGIN and metadata validation afterward, allowing a peer publication between them; the PR reports an exact base-red regression, but this read-only review executed no reproduction.

Is this the best way to solve the issue?

The patch is a focused repair of the existing invariant: accept completed publication only when the header and metadata both equal the supported current version, while preserving other refusals.

AGENTS.md: found and applied where relevant.

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

Provenance checked

  • Deferred schema publication keeps the original intent (02fb5fc: Allow released 2026.9.2 updaters to finish ledger writes while migrated content is available and publication remains deferred.)
  • Shared admission reuse keeps the original intent (bb7d32e: Reuse admitted physical-database facts across workers and reopens while migration and repair owners publish committed facts.)
  • Existing-schema writer validation keeps the original intent (335d435: Retain progress connections and reuse structural admission while preserving current identity, authority, ownership metadata, and version checks.)
  • Maintenance peer adoption keeps the original intent (669193e: Refresh stale admitted versions when the physical header and metadata independently confirm completed current-version publication.)

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

Likely related people:

  • Peter Steinberger: Raw commit 335d435 adds src/state/openclaw-state-db-existing-write.ts:67 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: 335d435bded0; files: src/state/openclaw-state-db-existing-write.ts)

PR surface

Source +28, Tests +49. Total +77 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 3 52 24 +28
Tests 1 49 0 +49
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 101 24 +77

Labels

Label changes:

  • add P2: A specific legacy-upgrade timing window leaves recovery pending, with a focused repair and limited affected population.
  • add rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab and patch quality is 🐚 platinum hermit.
  • add status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Label justifications:

  • P2: A specific legacy-upgrade timing window leaves recovery pending, with a focused repair and limited affected population.
  • rating: 🧂 unranked krab: Overall readiness is 🧂 unranked krab; proof is 🧂 unranked krab 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.

Reviewed November 3, 2026, 12:59 PM ET / 17:59 UTC.

@steipete
steipete marked this pull request as ready for review November 4, 2026 15:35
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 4, 2026 •

Copy link
Copy Markdown
Contributor

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-04T16:38:58.997670Z 9df8ea4 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@steipete
steipete merged commit 85905ea into main Nov 4, 2026
102 of 113 checks passed
@steipete
steipete deleted the codex/g31-existing-write-peer-publication branch November 4, 2026 17:11
@steipete

steipete commented Nov 4, 2026

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Nov 5, 2026
…eferred schema mid-update (openclaw#192140)

* fix(update): keep plugin leases working when the Gateway publishes a deferred schema

* test(state): prove the peer publication race through the real lease write
RomneyDa added a commit that referenced this pull request Nov 17, 2026
Share the current-header and metadata publication check between retained
maintenance connections and existing-schema lease writes. Keep mismatched
markers refused and preserve the existing ownership checks.

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

P2 Normal backlog priority with limited blast radius. rating: 🧂 unranked krab Not merge-ready due to missing proof or serious correctness/safety concerns. 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.

1 participant