Repository navigation
perf(config): stop blocking plugin-update config writes on repeated migration checks - #170695
Merged
Merged
Conversation
A config write inside a deferred plugin migration completion scope (plugin update or install finishing a pending migration) read the pending-migration ledger twice before publication: once in replaceConfigFile and again in the file write. Outside the Gateway each read was a synchronous SQLite snapshot child on the main thread. Before publication those reads could only return the scope's admitted generation minus the resolved plugins, or throw. The publication write transaction (withDeferredPluginMigrationsCurrent) already re-reads the rows and asserts that exact generation for root and include-owned writes, so the pre-publication path now returns the admitted facts directly. After publication in the same scope the fresh read stays, moved to the async state-worker read. Scope filtering is unchanged, and no write option or plugin SDK surface is added. Related: #160682, #170230.
Contributor
|
🦞👀 Pull request received. I will update this pull request when review starts. |
steipete
marked this pull request as ready for review
October 13, 2026 05:48
Contributor
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
Contributor
Author
|
Merged via squash.
|
github-actions Bot
pushed a commit
to Desicool/openclaw
that referenced
this pull request
Oct 14, 2026
…claw#170695) A config write inside a deferred plugin migration completion scope (plugin update or install finishing a pending migration) read the pending-migration ledger twice before publication: once in replaceConfigFile and again in the file write. Outside the Gateway each read was a synchronous SQLite snapshot child on the main thread. Before publication those reads could only return the scope's admitted generation minus the resolved plugins, or throw. The publication write transaction (withDeferredPluginMigrationsCurrent) already re-reads the rows and asserts that exact generation for root and include-owned writes, so the pre-publication path now returns the admitted facts directly. After publication in the same scope the fresh read stays, moved to the async state-worker read. Scope filtering is unchanged, and no write option or plugin SDK surface is added. Related: openclaw#160682, openclaw#170230.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What Problem This Solves
A plugin update that completes a deferred plugin migration wrote config while reading the migration ledger twice before publication, once in
replaceConfigFileand once in the underlying file write. Outside the Gateway, each read was a synchronous SQLite snapshot child that blocked the CLI main thread (about 0.5 s on a built CLI and 1-3 s under heavy load). Both reads only repeated a generation check that publication already performs.User Impact
No user-visible behavior change.
openclaw plugins updateand plugin installs that finish a pending plugin migration no longer spend two blocking SQLite snapshot reads per config write. Retained plugin inputs stay protected, and a migration obligation that changes before publication still refuses the write with the same conflict error.Why This Change Was Made
Inside an unpublished
withDeferredPluginConfigCompletionscope, the pre-publication read could only return the scope's admitted generation minus the resolved plugins, or throw.withDeferredPluginMigrationsCurrentalready re-reads the pending rows inside the publication write transaction and asserts that exact generation before publishing, for both root and include-owned writes.readConfigWritePendingMigrationsnow returns the admitted facts directly and leaves the generation check to that point of effect. Scope filtering (resolved owners released, unresolved owners retained) is unchanged.After publication in the same scope, the function still reads fresh rows, now through the async state-worker read (
readDeferredPluginMigrationsAsync) instead of the synchronous main-thread read.readConfigWritePendingMigrationsandreadConfigWriteMigrationFactsbecame async; both callers were already async.Ordinary config writes are unaffected: since #170230 they do not read migration state at all. No write option was added, so plugin code reaching
replaceConfigFile/mutateConfigFilethrough the SDK gains no new way to influence migration protection.Accepted edge case: a migration obligation that changes between write preparation and publication is now reported at publication rather than at the start of the write. Nothing is published either way; the write only does its validation work before refusing.
Related: #160682, #170230.
Evidence
src/config/io.deferred-plugin-migrations.test.ts: drives a completion-scopedreplaceConfigFilethrough the real config IO and state database, counting pending-ledger queries executed outside a write transaction. Onorigin/mainit fails with 2 such reads (the publication transaction itself reads 3 more times, unchanged); with this change it records 0. The same test proves a migration obligation recorded inbeforeCommitstill rejects withDeferredPluginMigrationConflictErrorand leaves the file unchanged, and that a successful completion keeps the unresolved owner'ssession.store, releases the resolved owner's plugin config, and records only the unresolved obligations as pending.pnpm test src/config/io.deferred-plugin-migrations.test.ts --maxWorkers=1: 9/9 pass at the PR head. The new test takes 2.9 s; the whole file took 207 s wall (179 s Vitest duration, 74% cold transform) on a host at load ~52 on 32 cores, where its pre-existing tests take 6-11 s each. CI seconds: see the PR CI run.node scripts/check-changed.mjs --staged: every lane green for the changed files, including format, line-cap (io.write.ts stays at its 700-line cap), mock-export, SQLite worker (T1 455 -> 455, no growth),typecheck core, oxlint on the changed files, and import cycles. Two lanes failed only on files this PR does not touch, both inherited from the base commit 33a438a and already fixed on main (the PR merge ref includes both): TS2724 insrc/commands/config-preflight-snapshot.test.ts(fixed by test(config): migrate preflight snapshot reader ownership #170619) and the Knip unused exportrenderBoardWidgetError(fixed by fix(ui): remove obsolete board error adapter #170609).withDeferredPluginMigrationsCurrent, both publishers, and the completion-scope caller supplied as evidence.openclaw doctor --fixthat showed two pending-migration snapshot children per config write predates perf(config): keep deferred plugin migrations out of normal runs #170230. Since perf(config): keep deferred plugin migrations out of normal runs #170230, ordinary and Doctor legacy-key writes perform no ledger read at all (covered by the existing "normal reads and writes never inspect deferred migration records" test), so this PR targets the remaining completion-scope path.openclaw plugins update; the read count is proven at the config write owner against the real state database.