Skip to content

refactor(plugins): read installed metadata through the shared worker - #148017

Merged
steipete merged 7 commits into
mainfrom
codex/async-installed-metadata-reads-20260914
Sep 14, 2026
Merged

steipete merged 7 commits into
mainfrom
codex/async-installed-metadata-reads-20260914

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144592

What Problem This Solves

Awaited plugin inventory and install-ledger reads still execute SQLite synchronously during installation, recovery, and registry refresh.

User Impact

These reads now perform their SQLite work in the shared worker. Returned metadata, existing validation, and synchronous helpers retain their contracts; no configuration or migration is required.

Why This Change Was Made

Stored compatibility is unchanged: the same config_machine_state row key, plugins.installedIndex, still contains the existing {revision, index} envelope with a version-1 index. The schema and write path are unchanged, and the ordinary consumer cases read fixtures encoded in that existing format.

Both read paths use the existing parser and plugin cache owner. Pending reads coalesce, newer synchronous cache publication wins, and invalidated or retired caches cannot publish an old result. Environment capture uses the existing platform-aware helper.

The worker adapter and cache preparation add 193 net production lines across nine files. No schema, retention, or version changes are included. Broader configuration preparation and task/flow restoration are separate changes.

Evidence

  • Three ordinary inventory, recovery-location, and install-lease consumer cases preserve results while nonthrowing spies record zero parent calls to DatabaseSync.prepare/exec and StatementSync.get/all/run/iterate during the measured read phases.
  • Earlier coalescing, synchronous-publication coexistence, cache retirement, and artifact-preserving inspection coverage passed. The current-main composition also passes ordinary shared metadata retirement.
  • CI exposed test-owner gaps and stale routing fixtures. The follow-ups route confirmed async metadata consumers through existing fork owners, retain former watch ownership, and drain fixture workers before deleting state. Nine ordinary metadata/chat/setup/lifecycle cases and 77 routing controls pass on the composed head; the complete selected changed-file gate and fresh P2 review pass.
  • Main 6b3e342ddb1e541f56b49b942d912cf8b376e24c was merged normally, including the shared Docker assertion repair from fix(ci): restore the ClawHub plugin sweep check #148129. The merge has no conflicts and preserves all 28 PR file blobs and package manifests. The exact previously failing Docker assertion passes. Existing main lifecycle cleanup-result changes were reviewed and retained.
  • The setup fixture lacked awaited worker drainage. Its cleanup is corrected, but the exact invalidation behind the prior CI read-admission failure was not recorded and remains unproven. Production admission checks are unchanged.
  • The original isolated production build remains prior-source evidence; no full build was replayed for the test/routing follow-ups or mechanical main refreshes. Required CI must qualify the pushed head before merge.
  • Existing mocked failure fixtures target their matching sync/async reader. Injected error/schema/path cases and Windows runtime validation were not rerun locally. No wall-clock speedup is claimed.

Move awaited installed-index and install-ledger SQL reads off the application
thread while retaining the existing synchronous helpers, parser, cache owner,
and lifecycle leases. Coalesce pending reads, preserve newer synchronous cache
publication, and capture environment lookup semantics before awaiting.

Validated ordinary metadata, recovery-location, and install-lease flows;
cache coexistence and retirement; type/lint/ownership gates; a full build;
and independent P2 review.

Refs #144592.
Strengthen the existing three ordinary parent-SQL checks with call-through
spies for prepare, exec, get, all, run, and iterate. Preserve the result
assertions, observation windows, and cleanup.
@clawsweeper

clawsweeper Bot commented Sep 14, 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 size: L maintainer Maintainer-authored PR labels Sep 14, 2026
@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. status: 👀 ready for maintainer look ClawSweeper has no concrete contributor-facing blocker left for this PR. labels Sep 14, 2026
@clawsweeper

clawsweeper Bot commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Codex review: blocked before merge. Reviewed September 14, 2026, 7:51 AM ET / 11:51 UTC (Revision 5).

ClawSweeper review

What this changes

Moves awaited installed-plugin inventory and install-record reads into the shared SQLite worker, preserves cache lifecycle checks, and updates affected test routing and cleanup.

Merge readiness

⛔ Blocked before merge - 1 item remains

Keep open: this remains useful work absent from current main, with no actionable introduced defect found. The earlier migration-proof blocker does not apply because the persisted format and write path are unchanged.

Priority: P2
Reviewed head: aa95206d76005143a62da58fc07d6f743d762aec

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A focused implementation with meaningful consumer and lifecycle coverage and no actionable correctness finding.
Proof confidence 🌊 off-meta tidepool Not applicable: The supplied repository state identifies this as maintainer-authored internal work, so the external-contributor proof gate does not apply. Reported SQLite consumer checks match the changed worker boundary; this review inspected their source without executing them.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The supplied repository state identifies this as maintainer-authored internal work, so the external-contributor proof gate does not apply. Reported SQLite consumer checks match the changed worker boundary; this review inspected their source without executing them.
Evidence reviewed 9 items Current main still uses synchronous SQLite: The fetched main revision’s awaited inventory reader delegates directly to its synchronous implementation; the requested worker conversion remains absent.
Latest release comparison: The v2026.9.4 source also delegates awaited inventory reads to the synchronous reader, so that release does not contain this conversion.
Existing worker and admission owner reused: The adapter captures database context before awaiting, checks admission after module loading and execution, and requests an existing-only read. The worker dispatch calls the existing read-only row implementation; it introduces no new principal or permission grant.
Findings None None.
Security None None.

How this fits together

Plugin installation, recovery, and registry refresh read installed-plugin metadata from OpenClaw’s shared SQLite database. The worker returns the stored row to the existing parser and lifecycle-owned cache before consumers use it.

flowchart TD
  A[Installation and recovery] --> B[Plugin metadata reader]
  B --> C{Cached metadata available?}
  C -->|Yes| F[Existing parser and cache]
  C -->|No| D[Shared SQLite worker]
  D --> E[Installed plugin row]
  E --> F
  F --> G[Validated inventory and install records]
Loading

Before merge

  • Add data-model compatibility proof - Confirm migration or upgrade compatibility proof before merge.
Agent review details

Security

None.

PR surface

Source +193, Tests +328. Total +521 across 28 files.

View PR surface stats
Area Files Added Removed Net
Source 9 218 25 +193
Tests 19 388 60 +328
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 28 606 85 +521

Review metrics

Metric Value Why it matters
Production versus validation growth Production +193 net lines; tests and test support +328 Production growth has a stated purpose: adapting existing readers to the worker while coalescing reads and fencing cache publication.

Stored data model

Persistent data-model change detected: serialized state: src/plugins/installed-plugin-index-record-reader.ts, unknown-data-model-change: src/plugins/installed-plugin-index-record-reader.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #144592
Summary: This PR implements the installed-plugin metadata slice of the broader asynchronous-storage effort.

Members:

Proposal only: this assessment does not dispatch repair, suppress jobs, mutate sibling items, close, or merge anything.

Technical review

Best possible solution:

Keep awaited metadata reads on the shared worker while preserving the existing parser, synchronous consumers, and explicit cache invalidation lifecycle.

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

Not applicable as a bug reproduction: this is an internal storage refactor. Current-main source confirms that the awaited readers still execute synchronous SQLite work.

Is this the best way to solve the issue?

Yes: extending the existing worker and cache owner is a focused solution, and the retained parser and write path avoid a migration or parallel storage implementation.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded runtime-storage improvement without evidence of an urgent user-facing regression.
  • rating: 🐚 platinum hermit: Overall readiness is 🐚 platinum hermit; proof is 🌊 off-meta tidepool and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR. Not applicable: The supplied repository state identifies this as maintainer-authored internal work, so the external-contributor proof gate does not apply. Reported SQLite consumer checks match the changed worker boundary; this review inspected their source without executing them.

Evidence

What I checked:

  • Current main still uses synchronous SQLite: The fetched main revision’s awaited inventory reader delegates directly to its synchronous implementation; the requested worker conversion remains absent. (src/plugins/installed-plugin-index-store.ts:155, 9a5af1b95370)
  • Latest release comparison: The v2026.9.4 source also delegates awaited inventory reads to the synchronous reader, so that release does not contain this conversion. (src/plugins/installed-plugin-index-store.ts:155, 3a9d69db306c)
  • Existing worker and admission owner reused: The adapter captures database context before awaiting, checks admission after module loading and execution, and requests an existing-only read. The worker dispatch calls the existing read-only row implementation; it introduces no new principal or permission grant. (src/plugins/plugin-metadata-state-worker.ts:12, aa95206d7600)
  • Cache publication fencing: Pending reads coalesce under the existing cache owner, accept a newer synchronous publication, reject invalidation or retirement, and release their retained cache reference after settlement. (src/plugins/plugin-cache.ts:216, aa95206d7600)
  • Prior compatibility concern reassessed: The introduced diff leaves the write owner, database schema contract, and index types unchanged. Both read paths retain the existing row key and parser; the storage policy expressly exempts read-only queries preserving existing semantics from its material-change checkpoint. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md:396, aa95206d7600)
  • Behavior coverage and execution limits: The new tests exercise inventory, recovery-location, and install-lease consumers against SQLite while observing parent-thread statement calls; additional cases cover artifact preservation, coalescing, synchronous publication, and retirement. The captured PR body reports passing consumer and routing checks, but identifies prior-source build evidence and an unexplained earlier setup admission failure. Tests and builds were not executed during this read-only review. (src/plugins/plugin-metadata-state-worker.test.ts:89, aa95206d7600)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (4 earlier review cycles)
  • reviewed 2026-09-14T06:53:51.910Z sha 2e2929d :: blocked before merge. :: none
  • reviewed 2026-09-14T07:39:42.933Z sha a7fd14c :: needs maintainer review before merge. :: none
  • reviewed 2026-09-14T08:03:50.351Z sha a7fd14c :: blocked before merge. :: none
  • reviewed 2026-09-14T09:07:31.106Z sha f3176b4 :: blocked before merge. :: none

Preserve the current session-delivery worker operation intersection while
retaining the focused metadata reader changes. Record the unchanged main
UI helper max-lines failure separately from passing metadata qualification.
@steipete
steipete marked this pull request as ready for review September 14, 2026 07:29
Use existing fork owners for SQLite consumers while preserving watch ownership. Drain fixture workers before deleting state and reset stale installer replies between cases.
@steipete steipete closed this Sep 14, 2026
@steipete steipete reopened this Sep 14, 2026
@openclaw-barnacle openclaw-barnacle Bot added the commands Command implementations label Sep 14, 2026
@steipete
steipete merged commit 6f147b0 into main Sep 14, 2026
191 of 192 checks passed
@steipete
steipete deleted the codex/async-installed-metadata-reads-20260914 branch September 14, 2026 13:37
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
…penclaw#148017)

* refactor(plugins): read installed metadata through the shared worker

Move awaited installed-index and install-ledger SQL reads off the application
thread while retaining the existing synchronous helpers, parser, cache owner,
and lifecycle leases. Coalesce pending reads, preserve newer synchronous cache
publication, and capture environment lookup semantics before awaiting.

Validated ordinary metadata, recovery-location, and install-lease flows;
cache coexistence and retirement; type/lint/ownership gates; a full build;
and independent P2 review.

Refs openclaw#144592.

* test(plugins): observe statement execution in worker metadata reads

Strengthen the existing three ordinary parent-SQL checks with call-through
spies for prepare, exec, get, all, run, and iterate. Preserve the result
assertions, observation windows, and cleanup.

* test: route metadata consumers through host-capable workers

Use existing fork owners for SQLite consumers while preserving watch ownership. Drain fixture workers before deleting state and reset stale installer replies between cases.

* test: complete installed metadata worker test ownership
steipete added a commit that referenced this pull request Oct 11, 2026
Let pending metadata reads finish with their captured facts after an explicit
cache refresh. Keep coalescing, newer synchronous publication precedence,
shutdown revocation, private snapshot identity and invalidation of completed
facts in inactive caches. Delete the tests requiring the removed cancellation
and cover the retained inactive-cache refresh contract.

Best-effort tradeoffs accepted:
- Cache invalidation during a worker read no longer cancels the read or replaces
  its original failure with an invalidation error. A cleared cache is not
  repopulated by that old read. This consistency machinery came from the worker
  preparation refactors in #148017 and #148305, not a reported incident.
- Clearing discovery state during preparation may leave that operation using
  its captured mode until another explicit refresh or restart. Retain the
  global generation stamp for completed facts in inactive operation caches.

P09 is below the campaign publication threshold: 29 net production lines
removed, with no Plugin SDK export changes. No PR is intended for this packet.
steipete added a commit that referenced this pull request Oct 11, 2026
Let pending metadata reads finish with their captured facts after an explicit
cache refresh. Keep coalescing, newer synchronous publication precedence,
shutdown revocation, private snapshot identity and invalidation of completed
facts in inactive caches. Delete the tests requiring the removed cancellation
and cover the retained inactive-cache refresh contract.

Best-effort tradeoffs accepted:
- Cache invalidation during a worker read no longer cancels the read or replaces
  its original failure with an invalidation error. A cleared cache is not
  repopulated by that old read. This consistency machinery came from the worker
  preparation refactors in #148017 and #148305, not a reported incident.
- Clearing discovery state during preparation may leave that operation using
  its captured mode until another explicit refresh or restart. Retain the
  global generation stamp for completed facts in inactive operation caches.

P09 is below the campaign publication threshold: 29 net production lines
removed, with no Plugin SDK export changes. No PR is intended for this packet.
steipete added a commit that referenced this pull request Oct 11, 2026
Let pending metadata reads finish with their captured facts after an explicit
cache refresh. Keep coalescing, newer synchronous publication precedence,
shutdown revocation, private snapshot identity and invalidation of completed
facts in inactive caches. Delete the tests requiring the removed cancellation
and cover the retained inactive-cache refresh contract.

Best-effort tradeoffs accepted:
- Cache invalidation during a worker read no longer cancels the read or replaces
  its original failure with an invalidation error. A cleared cache is not
  repopulated by that old read. This consistency machinery came from the worker
  preparation refactors in #148017 and #148305, not a reported incident.
- Clearing discovery state during preparation may leave that operation using
  its captured mode until another explicit refresh or restart. Retain the
  global generation stamp for completed facts in inactive operation caches.

P09 is below the campaign publication threshold: 29 net production lines
removed, with no Plugin SDK export changes. No PR is intended for this packet.
steipete added a commit that referenced this pull request Oct 11, 2026
* refactor(plugins): simplify in-flight metadata invalidation

Let pending metadata reads finish with their captured facts after an explicit
cache refresh. Keep coalescing, newer synchronous publication precedence,
shutdown revocation, private snapshot identity and invalidation of completed
facts in inactive caches. Delete the tests requiring the removed cancellation
and cover the retained inactive-cache refresh contract.

Best-effort tradeoffs accepted:
- Cache invalidation during a worker read no longer cancels the read or replaces
  its original failure with an invalidation error. A cleared cache is not
  repopulated by that old read. This consistency machinery came from the worker
  preparation refactors in #148017 and #148305, not a reported incident.
- Clearing discovery state during preparation may leave that operation using
  its captured mode until another explicit refresh or restart. Retain the
  global generation stamp for completed facts in inactive operation caches.

P09 is below the campaign publication threshold: 29 net production lines
removed, with no Plugin SDK export changes. No PR is intended for this packet.

* refactor(plugins): simplify reload and metadata lifetimes

Remove speculative source/metadata freshness fences, multi-Gateway arbitration,
replacement reservations and nested replacement-dependency bookkeeping.
Keep one self-reload check, actual call/consumer settlement, live effect
authority, initial source containment, copied-byte receipts and existing caches.

Best-effort tradeoffs accepted:
- Source/config changes during a captured operation take effect on a later run
  or explicit refresh, without rehashing and revalidating the entire source graph.
- One process owns one Gateway; overlapping independent Gateways are best effort.
- Nested replacement dependencies use the existing bounded drain rather than
  a second dependency graph. Ordinary 60-second drainage and --wait remain.
- Cache retirement owns one detached cleanup scope instead of handing cleanup
  admission between the requesting scope and its last borrower.

Retained incident boundaries: #151706, #152845, #153290 and #152997. Synthetic
tests that only pin removed fences are deleted with them. No intended public
SDK export, persisted schema, protocol, dependency or permission changes.

* fix(plugins): refuse reload from a live borrowed turn

Check the current live turn's exact plugin instances once before reload
effects. A turn can retain its instance between callbacks even when there is
no active plugin invocation. Keep external --wait and ordinary drainage.

The Gateway regression fails without the check by reaching config effects;
with it, the live turn is refused before effects and the same captured context
can reload after the lease closes. The six explicit-wait controls also pass.

Refs #151706.

* fix(plugins): preserve SDK shapes and finish reload cutover

* test(plugins): finish single-owner reload coverage cutover

* refactor(plugins): tidy simplified lifecycle paths

* fix(plugins): retain direct reload wait refusal

* fix(plugins): refresh install phases and finish single-gateway tests

* test(plugins): assert final-gateway shutdown contract

* test(plugins): finish retired lifecycle fixture cutover

* test(plugins): keep memory fixture behind runtime boundary

* test(plugins): drop superseded memory reload fence cases

* test(gateway): privatize unused lifecycle fixture type
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…68837)

* refactor(plugins): simplify in-flight metadata invalidation

Let pending metadata reads finish with their captured facts after an explicit
cache refresh. Keep coalescing, newer synchronous publication precedence,
shutdown revocation, private snapshot identity and invalidation of completed
facts in inactive caches. Delete the tests requiring the removed cancellation
and cover the retained inactive-cache refresh contract.

Best-effort tradeoffs accepted:
- Cache invalidation during a worker read no longer cancels the read or replaces
  its original failure with an invalidation error. A cleared cache is not
  repopulated by that old read. This consistency machinery came from the worker
  preparation refactors in openclaw#148017 and openclaw#148305, not a reported incident.
- Clearing discovery state during preparation may leave that operation using
  its captured mode until another explicit refresh or restart. Retain the
  global generation stamp for completed facts in inactive operation caches.

P09 is below the campaign publication threshold: 29 net production lines
removed, with no Plugin SDK export changes. No PR is intended for this packet.

* refactor(plugins): simplify reload and metadata lifetimes

Remove speculative source/metadata freshness fences, multi-Gateway arbitration,
replacement reservations and nested replacement-dependency bookkeeping.
Keep one self-reload check, actual call/consumer settlement, live effect
authority, initial source containment, copied-byte receipts and existing caches.

Best-effort tradeoffs accepted:
- Source/config changes during a captured operation take effect on a later run
  or explicit refresh, without rehashing and revalidating the entire source graph.
- One process owns one Gateway; overlapping independent Gateways are best effort.
- Nested replacement dependencies use the existing bounded drain rather than
  a second dependency graph. Ordinary 60-second drainage and --wait remain.
- Cache retirement owns one detached cleanup scope instead of handing cleanup
  admission between the requesting scope and its last borrower.

Retained incident boundaries: openclaw#151706, openclaw#152845, openclaw#153290 and openclaw#152997. Synthetic
tests that only pin removed fences are deleted with them. No intended public
SDK export, persisted schema, protocol, dependency or permission changes.

* fix(plugins): refuse reload from a live borrowed turn

Check the current live turn's exact plugin instances once before reload
effects. A turn can retain its instance between callbacks even when there is
no active plugin invocation. Keep external --wait and ordinary drainage.

The Gateway regression fails without the check by reaching config effects;
with it, the live turn is refused before effects and the same captured context
can reload after the lease closes. The six explicit-wait controls also pass.

Refs openclaw#151706.

* fix(plugins): preserve SDK shapes and finish reload cutover

* test(plugins): finish single-owner reload coverage cutover

* refactor(plugins): tidy simplified lifecycle paths

* fix(plugins): retain direct reload wait refusal

* fix(plugins): refresh install phases and finish single-gateway tests

* test(plugins): assert final-gateway shutdown contract

* test(plugins): finish retired lifecycle fixture cutover

* test(plugins): keep memory fixture behind runtime boundary

* test(plugins): drop superseded memory reload fence cases

* test(gateway): privatize unused lifecycle fixture type
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

commands Command implementations maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: L 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