Skip to content

fix(plugins): avoid blocking discovery on lazy state snapshots - #176291

Merged
vincentkoc merged 3 commits into
mainfrom
fix/plugin-discovery-async-snapshot-20261019
Oct 18, 2026
Merged

vincentkoc merged 3 commits into
mainfrom
fix/plugin-discovery-async-snapshot-20261019

Conversation

@vincentkoc

@vincentkoc vincentkoc commented Oct 18, 2026 •

Copy link
Copy Markdown
Member

What Problem This Solves

Fixes event-loop stalls when asynchronous plugin discovery first accesses a lazy shared-state snapshot during Doctor inspection.

User Impact

Discovery allows other event-loop work to progress while the existing snapshot worker prepares private database bytes. This change does not establish lower total Doctor runtime or remove the separate writable snapshot acquisition.

Why This Change Was Made

The async preparation path called the synchronous snapshot accessor, whose lazy materialization services the worker through a blocking wait loop. The state-read owner now exposes an async accessor that awaits the same preparation, retains its lifetime, rechecks admission and cancellation, and returns the same snapshot identity. Discovery preserves typed admission failures from rejected preparation promises.

Production changes add 24 net lines for the async lifetime boundary and shared error translation; synchronous consumers keep their existing path. No schema, configuration, runtime-version, or source-database mutation changes.

Follow-up: writable Doctor inspection still reacquires live database bytes. Removing its repeated full-file comparison requires a retained private database-and-WAL fork with independent writable lifetime and active-WAL isolation proof.

Evidence

  • Source trace and runtime profiling identified the synchronous lazy-snapshot accessor on the async config/plugin-discovery path.
  • Added coverage for pending preparation, asynchronous error propagation, mixed async/sync identity, one acquisition, cleanup, and rejected access after retirement.
  • git diff --check and pinned oxfmt formatting: passed.
  • Current-head CI at 1641d7c4599715f8badfc5aae1072ffed89a3cdb: runtime test lanes, production/test types, lint, guards, PostgreSQL conformance and the aggregate gate passed. The packaged build job was skipped; no separate packaged build is claimed.
  • ClawSweeper review covers that head with no actionable findings. Its CI-confirmation Rank-up move is satisfied by the successful exact-head aggregate gate.
  • Independent AutoReview: no actionable P0–P2 findings; static review only. The primary review also checked the retained-scope admission resolver omitted from the review bundle.

@vincentkoc vincentkoc self-assigned this Oct 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
ClawSweeper picked this up.

Pull request received. I will update this pull request when review starts.

ClawSweeper review in progress

ClawSweeper is reviewing this revision. This supersedes any previous blocked status.

View the workflow run.

@vincentkoc
vincentkoc marked this pull request as ready for review October 18, 2026 16:49
@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. labels Oct 18, 2026
@vincentkoc

Copy link
Copy Markdown
Member Author

@clawsweeper re-review

Please review current head 1641d7c4599715f8badfc5aae1072ffed89a3cdb. It adds the two mechanical lint corrections to the async snapshot fix.

@clawsweeper

clawsweeper Bot commented Oct 18, 2026 •

Copy link
Copy Markdown
Contributor

🦞👀
Exact review queued.

Re-review progress:

@clawsweeper clawsweeper Bot added P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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 18, 2026
@clawsweeper

clawsweeper Bot commented Oct 18, 2026

Copy link
Copy Markdown
Contributor

Codex review: needs maintainer review before merge.

What this changes

This PR makes asynchronous plugin discovery await lazy snapshot preparation instead of blocking the event loop.

Example: Doctor lint runs a selected report that first needs bundled-plugin discovery policy.

  • Before: Discovery waits synchronously for private database bytes, preventing other event-loop work from progressing.
  • After: Discovery awaits the existing preparation promise and then consumes the same snapshot identity.

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The focused implementation appears correct, but validation remains thin: added tests are present and exact-head CI is still pending.
Proof confidence 🦪 silver shellfish (2/6) This maintainer-authored PR is outside the ordinary contributor proof gate; supplied coverage uses mocked preparation and transport, with no executed shipped-entry-point result for this head.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Product

Kind: Bug fix · Worth it: Yes · Fix scope: Complete
User problem: Doctor inspection can stop other event-loop work while asynchronous discovery waits synchronously for snapshot bytes.
Reason: The maintainer-authored direction fixes a concrete blocking boundary without changing discovery policy or promising lower total Doctor runtime.

Merge readiness

✅ Ready for maintainer review

Keep this maintainer-authored PR open: it addresses a blocking lazy-snapshot read still present on main, and no concrete introduced defect was found.

Priority: P2
Reviewed head: 1641d7c4599715f8badfc5aae1072ffed89a3cdb

Before merge

None.

Findings

None.

Tests

  • Missing end-to-end proof: No shipped Doctor trace or completed red-on-base/green-on-head result is supplied for event-loop progress during lazy discovery preparation.
Agent review details

How this fits together

Doctor and asynchronous config loading prepare plugin metadata through bundled discovery, which reads machine-owned policy from a retained private shared-state snapshot.

flowchart TD
  A[Doctor or config loading] --> B[Async plugin discovery]
  B --> C[Shared-state snapshot owner]
  C --> D[Existing snapshot worker]
  D --> E[Private database bytes]
  E --> F[Prepared discovery policy]
Loading

Technical review

Best possible solution:

Use the existing snapshot owner's asynchronous preparation while retaining synchronous consumers, shared identity, admission checks, and cleanup.

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

Source traces asynchronous discovery through the synchronous accessor into the lazy snapshot owner's blocking wait loop; no target code was executed during this read-only review.

Is this the best way to solve the issue?

The patch is a focused repair using existing preparation and lifetime owners, with no competing snapshot path or unnecessary production machinery.

AGENTS.md: found and applied where relevant.

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

Provenance checked

Testing

Proof path: unit tests only.

Security

None.

Evidence

What I checked:

Likely related people:

  • Vincent Koc: Raw commit ed2de46 adds src/state/openclaw-state-db-readonly.ts:109 relative to its recorded parents. This identifies author metadata, not feature responsibility or a PR merger. (role: source-line author; confidence: high; commits: ed2de46114ea; files: src/state/openclaw-state-db-readonly.ts)

PR surface

Source +24, Tests +65. Total +89 across 4 files. Added test files: 0.

View PR surface stats
Area Files Added Removed Net
Source 2 32 8 +24
Tests 2 65 0 +65
Docs 0 0 0 0
Config 0 0 0 0
Generated 0 0 0 0
Other 0 0 0 0
Total 4 97 8 +89

Labels

Label changes:

  • add P2: The fix addresses event-loop stalls during lazy Doctor discovery without evidence of a crash, lost data, or a blocked first-use workflow.
  • add rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish 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: The fix addresses event-loop stalls during lazy Doctor discovery without evidence of a crash, lost data, or a blocked first-use workflow.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🐚 platinum hermit.
  • status: 👀 ready for maintainer look: ClawSweeper has no concrete contributor-facing blocker left for this PR.

Rank-up moves

Optional improvements that raise the rating; they are not merge blockers.

  • Confirm the exact-head CI gate passes, including the affected discovery and snapshot lifecycle tests.

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 18, 2026, 1:18 PM ET / 17:18 UTC.

@vincentkoc
vincentkoc enabled auto-merge (squash) October 18, 2026 17:29
@vincentkoc
vincentkoc merged commit 676658e into main Oct 18, 2026
154 checks passed
@vincentkoc
vincentkoc deleted the fix/plugin-discovery-async-snapshot-20261019 branch October 18, 2026 17:30
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 19, 2026
…law#176291)

* fix(plugins): avoid blocking discovery on lazy state snapshots

* test(plugins): preserve async snapshot rejection contract

* fix(plugins): satisfy snapshot lint contracts
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: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. 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