Skip to content

fix(plugins): defer startup registration until data migrations finish - #178165

Merged
RomneyDa merged 3 commits into
mainfrom
fix/plugin-migration-startup-admission-20261018
Oct 20, 2026
Merged

RomneyDa merged 3 commits into
mainfrom
fix/plugin-migration-startup-admission-20261018

Conversation

@RomneyDa

@RomneyDa RomneyDa commented Oct 20, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes: restarting before Doctor finishes a plugin data migration evaluates the replacement against unmigrated data, leaving the plugin broken even though the Gateway can become ready.

User Impact

Plugins awaiting a recorded data migration stay unavailable with an actionable Doctor diagnostic, without evaluating replacement code. Reload refuses the replacement before stopping the working predecessor. Stop the Gateway, run openclaw doctor --fix against the same state and config, then start it again.

Why This Change Was Made

Cold runtime admission consumes the existing migration obligation. Admitted instances remain reusable; refused registries are not cached, so Doctor completion allows a retry in the same inventory. Doctor remains the migration and backup owner.

The PostgreSQL CI follow-up moves ordinary prepared-catalog loading onto the existing asynchronous plugin loader, preserving cached registries, primary-registry callbacks, and donor adoption. It does not use inspection-only resource ownership or weaken the worker-only database guard. Explicit synchronous callers retain their existing adapter.

No schema, persisted format, runtime config option, or plugin SDK option changes. Main only; no separate 10.3 backport.

Evidence

  • The production-owner migration regression passes: no replacement evaluation while pending; real Gateway reload preflight refuses; predecessor RPC remains callable; Doctor preserves record IDs, ages, and operator settings; same-inventory retry and fresh startup succeed.
  • Reproduced the CI failure on 449e694e6252 using the existing PostgreSQL model-catalog conformance test and the CI-pinned PostgreSQL 17 image. The stack reached the synchronous migration-readiness read from prepared-catalog construction. The corrected route passes both SQLite and PostgreSQL cases (2 tests; 46.33 seconds wall time including schema verification and worker preparation).
  • Focused prepared-runtime, static-catalog, registry-ownership, and original migration/reload coverage passes: 4 files, 41 tests, 70.09 seconds wall time. Existing tests supply the regression; no duplicate test cases or timers were added.
  • The first repaired-head CI run exposed a Worker Goal fixture that still intercepted only the synchronous registry adapter. Its five failure modes reproduced locally. Adding/restoring the corresponding async spy leaves every placement, requester/claim revocation, continuation, cleanup, and persistence assertion intact; the complete Goal suite passes (31 tests, 66.95 seconds wall time). This follow-up changes no production code.
  • pnpm build completed successfully in 5m 8.2s, including the CLI bootstrap import guard.
  • Core typecheck, targeted production lint, changed-file formatting, and git diff --check passed.
  • Built-artifact CLI smoke passed in 55.83 seconds using fully isolated state and the existing test-instance process/cleanup owner: plugins inspect --runtime --json refused evaluation while preserving exact data/config bytes; offline doctor --fix --yes completed the migration; a fresh built CLI process loaded the retained IDs, ages, and operator settings.
  • Independent Codex AutoReview through P2 is scoped-clean for both the production repair and the four-line Worker Goal fixture follow-up; the original admission patch also received an independent review. ClawSweeper's original-head review reported no code findings.
  • Hosted CI for final repair commit 8b8577faea6e is pending; old-head CI is not evidence for the final head.

Validation limits

  • The full mock-export ratchet reports test/scripts/ci-node-test-plan.test.ts:3297 (../../scripts/lib/ci-test-timings.mts). The same failure reproduces against the unchanged index. The three repaired mock factories have explicit isolation reasons, and only their three obsolete grandfathered entries were removed.
  • The build's UI budget report warns that chat/new boot gzip sizes exceed their limits; successful build completion is not a passing UI-budget check. No UI files are changed.
  • An earlier optional changed-file check reported inherited max-lines suppressions in three untouched UI files (chat-message.test.tsx, config-page-state.ts, sessions-page-state.ts).
  • The CLI smoke uses a synthetic installed plugin, not a separate Gateway fresh-install or stable-upgrade run.

The simplify/test-audit pass retains the existing admission, diagnostic, registry, and migration owners. The CI repair adds 27 production lines and removes 2, adds 12 fixture-adapter lines, and removes 3 mock-baseline entries; it adds no persistent state or new cache.

@clawsweeper

clawsweeper Bot commented Oct 20, 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 commands Command implementations size: M labels Oct 20, 2026
@RomneyDa
RomneyDa marked this pull request as ready for review October 20, 2026 06:39
@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. P2 Normal backlog priority with limited blast radius. rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. 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. clawsweeper:intake:needs-environment Preliminary submission classification; full source review pending. clawsweeper:intake:needs-repro Preliminary submission classification; full source review pending. labels Oct 20, 2026
@clawsweeper

clawsweeper Bot commented Oct 20, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR prevents plugin replacement code from running while its recorded data migration remains unfinished.

Example: The pending-data-fixture plugin version 2.1.0 requires Doctor to migrate retained records.

  • Before: Startup evaluates replacement code against unmigrated data and registration fails.
  • After: Startup reports the plugin unavailable without evaluating it; after Doctor completes, loading succeeds with record IDs, ages, and settings preserved.

Review scores

Measure Result What it means
Overall readiness 🦐 gold shrimp (3/6) A useful, focused patch with meaningful owner-boundary coverage; shipped-entry-point validation remains unreported.
Proof confidence 🦐 gold shrimp (3/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied behavioral evidence is an in-process loader, reload-preflight, and Doctor regression rather than a shipped CLI/Gateway run.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: A restart can evaluate replacement plugin code before its required data migration finishes, leaving the plugin broken while the Gateway reports ready.
Reason: The maintainer-authored direction protects retained data through an existing repair contract without adding configuration, SDK options, or persisted state.

Merge readiness

✅ Ready for maintainer review

Keep this PR open: it addresses a current migration-admission gap, preserves existing recovery behavior, and has no actionable code findings.

Priority: P2
Reviewed head: 449e694e6252976c66311b26daabc9b394779f88

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: The announced isolated CLI/Gateway smoke, fresh-install check, and upgrade from v2026.10.5 with retained plugin data and settings are not supplied.
Agent review details

How this fits together

The plugin loader consumes selected manifests, configuration, and migration obligations to produce executable registries or actionable unavailability diagnostics; Doctor continues to own migration and backup.

flowchart TD
  A[Startup or reload] --> B[Plugin loader]
  C[Migration ledger] --> B
  B --> D[Unavailable diagnostic]
  B --> E[Plugin registry]
  F[Doctor repair] --> C
Loading

Technical review

Best possible solution:

Keep migration admission in the existing loader and repair in Doctor, preserving predecessor recovery and retry after completion.

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

Current-main source permits replacement evaluation despite a recorded state-migration obligation; the supplied regression models that path, but no target code was executed during this review.

Is this the best way to solve the issue?

The patch is a focused repair using the existing ledger, diagnostics, loader, and Doctor owners; the simplify and test-value passes found no unnecessary production machinery or duplicate regression group.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: in-process harness.

Security

None.

Evidence

What I checked:

PR surface

Source +110, Tests +233, Docs +6. Total +349 across 7 files. Added test files: 1.

View PR surface stats
Area Files Added Removed Net
Source 5 121 11 +110
Tests 1 233 0 +233
Docs 1 6 0 +6
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 7 360 11 +349

Labels

Label changes:

  • add P2: A focused startup and reload correctness repair for plugins with unfinished recorded state migrations.
  • add rating: 🦐 gold shrimp: Overall readiness is 🦐 gold shrimp; proof is 🦐 gold shrimp 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 focused startup and reload correctness repair for plugins with unfinished recorded state migrations.
  • 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.

Reviewed October 20, 2026, 2:56 AM ET / 06:56 UTC.

@openclaw-barnacle openclaw-barnacle Bot added the agents Agent runtime and tooling label Oct 20, 2026
@openclaw-barnacle openclaw-barnacle Bot added the gateway Gateway runtime label Oct 20, 2026
@RomneyDa
RomneyDa enabled auto-merge (squash) October 20, 2026 08:14
@RomneyDa
RomneyDa merged commit 36b28bb into main Oct 20, 2026
164 checks passed
@RomneyDa
RomneyDa deleted the fix/plugin-migration-startup-admission-20261018 branch October 20, 2026 08:30
@RomneyDa

Copy link
Copy Markdown
Member Author

Merged via squash auto-merge.

steipete added a commit that referenced this pull request Oct 20, 2026
Read ordinary deferred-plugin readiness through the live state read worker and retain results under the migration owner's process receipt and database engine. Invalidate on committed ledger changes while preserving the pending-data registration gate and explicit snapshot scopes.

Three alternating baseline/candidate pairs reduce the readiness family from 226 SQL statements / 42 requests / 5 MAIN statements to 41 / 10 / 0. Warm causal work stays 46 / 11 / 0. Retain one cold read per Gateway/catalog isolate; unrelated state writes no longer discard settlement.

Preserve and extend the retained-data migration regression from #178165. 162 focused tests, PostgreSQL conformance, static CI, two isolated reviews and the published-driver update check pass. Record the source-key namespace guarantee for session-import recovery.

Co-authored-by: Dallin Romney <[email protected]>
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
…openclaw#178165)

* fix(plugins): defer startup registration until data migrations finish

* fix(agents): await plugin admission in prepared catalogs

* test(gateway): keep worker Goal fixture on async registry path
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 21, 2026
Read ordinary deferred-plugin readiness through the live state read worker and retain results under the migration owner's process receipt and database engine. Invalidate on committed ledger changes while preserving the pending-data registration gate and explicit snapshot scopes.

Three alternating baseline/candidate pairs reduce the readiness family from 226 SQL statements / 42 requests / 5 MAIN statements to 41 / 10 / 0. Warm causal work stays 46 / 11 / 0. Retain one cold read per Gateway/catalog isolate; unrelated state writes no longer discard settlement.

Preserve and extend the retained-data migration regression from openclaw#178165. 162 focused tests, PostgreSQL conformance, static CI, two isolated reviews and the published-driver update check pass. Record the source-key namespace guarantee for session-import recovery.

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

Labels

agents Agent runtime and tooling commands Command implementations docs Improvements or additions to documentation gateway Gateway runtime P2 Normal backlog priority with limited blast radius. 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