Skip to content

refactor(config): prepare task visibility configuration asynchronously - #148305

Merged
steipete merged 3 commits into
mainfrom
codex/async-task-config-preparation-main-20260914
Sep 14, 2026
Merged

steipete merged 3 commits into
mainfrom
codex/async-task-config-preparation-main-20260914

Conversation

@steipete

@steipete steipete commented Sep 14, 2026 •

Copy link
Copy Markdown
Contributor

Related: #144592
Builds on merged #148017.

What Problem This Solves

Cold tasks.async reads can perform SQLite work on the Gateway thread when task visibility needs configuration to resolve a bare owner.

User Impact

The existing get, list, findLatest, and resolve operations now await strict configuration preparation before applying owner visibility. Scope, lookup precedence, and response shapes remain unchanged; invalid configuration remains inaccessible.

Task and flow registry readiness retains its synchronous owner in this change. This covers cold configuration after registry readiness; asynchronous registry restoration is the next cutover. Public synchronous methods remain available.

Why This Change Was Made

Configuration loading prepares its environment, plugin metadata, health, and Claw consent prerequisites through their existing owners, then rechecks admission and newer publications before activation. Synchronous and asynchronous loaders share validation. Both Claw readers retain artifact preservation and ownership validation.

The change preserves main's synchronous metadata snapshot-sharing wrapper. Prepared async facts feed the existing derivation; no Promise enters the synchronous snapshot scope. The existing config snapshot/read-for-write paths remain synchronous metadata consumers.

This focused 43-file change includes shared validation extraction and awaited environment, runtime, metadata, and consent preparation. Production changes are +2,182/-990 lines across 31 files; tests/support are +1,503/-1 across 10 files. No second metadata or publication owner is introduced. The reviewed configuration delta is applied directly to current main containing #148017, without carrying the prior private stack ancestry.

Evidence

  • The 17 ordinary controls pass again: two registered bare-owner SDK cases, four metadata consumers, three Claw publication cases, and eight strict-loader/publication/default/shell-metadata cases. An additional inherited schema control and 75 route-planning checks pass. SDK configuration measurement begins after registry readiness and observes zero parent SQLite calls across prepare, exec, get, all, run, and iterate; direct strict-loader and metadata cases also observe six counters.
  • The complete selected 43-path check gate passes, including broad core lint, production/test types, formatting, script lint, static guards, and unused-export/import-cycle checks. Fresh P2 review on the refreshed head is scoped-clean.
  • A fresh full pnpm build passed in 618.3 seconds on tree 0b0ed30e91819da01727e110362b1aa4fd63ab17. Commit 1c6050ff27c6342c8a314aec3c9e4d3bd30a571a has that tree and normally merges main 2f04a9e2069ee62797bdb9b86ae3c2c4e62578ba into the previous 8d5efcc45ec16fc75634e9ea0292d5d8435a7263 head.
  • The conflict-free refresh includes the canonical wizard routing and Radius boundary fixes from test: route provider integration and wizard recovery tests correctly #148504. The wizard test appears exactly once; all six CI planner profiles succeed without replaying the failing scenario. Thirty-seven of 43 B file blobs remain unchanged; main’s managed-flow error causes, worker maintenance scopes, cron dispatch, documentation and routing changes are preserved. Earlier exact-head CI failed on an inherited duplicate route before its test matrix ran; that evidence remains separate from this refreshed qualification.
  • A frozen dependency install completed before proof using main’s updated dependency pins and left source and lockfiles unchanged. This refreshed build and proof are recorded separately from the original tree's evidence.

No schema, retention, configuration-option, or version changes are included. Held snapshot/WAL, native failure/path/size, liveness/PID, Windows runtime, and live-provider scenarios were not replayed for this composition; the inherited snapshot-sharing and Claw artifact-preservation owners were source-audited. This API does not provide a live configuration-publication fence through worker transaction settlement; that belongs to the existing activation/admission owner. No wall-clock speedup is claimed.

@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 docs Improvements or additions to documentation plugin: file-transfer size: XL maintainer Maintainer-authored PR labels Sep 14, 2026
@steipete
steipete marked this pull request as ready for review September 14, 2026 14:24
@steipete
steipete requested a review from a team as a code owner September 14, 2026 14:24
@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, 5:49 PM ET / 21:49 UTC (Revision 3).

ClawSweeper review

What this changes

The PR makes asynchronous task reads await configuration, environment, plugin metadata, and consent preparation while sharing validation with existing synchronous loaders.

Merge readiness

⛔ Blocked before merge - 1 item remains

This remains useful work: current main still prepares configuration synchronously during bare-owner task visibility checks. No blocking introduced defect was found, and the prior generic migration-proof warning is not supported by a changed persistent contract.

Priority: P2
Reviewed head: 1c6050ff27c6342c8a314aec3c9e4d3bd30a571a

Review scores

Measure Result What it means
Overall readiness 🐚 platinum hermit (4/6) A coherent internal cutover with meaningful boundary coverage and no blocking source finding; reported executions were not independently rerun.
Proof confidence 🌊 off-meta tidepool Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its reported registered task-runtime checks exercise cold valid/invalid configuration through real SQLite after registry readiness; inspected tests support that scope, without establishing live-provider or Windows behavior.
Patch quality 🐚 platinum hermit (4/6) No actionable review findings were identified.

Verification

Check Result Evidence
Real behavior Not applicable Not applicable: The maintainer-authored PR is exempt from ordinary contributor proof. Its reported registered task-runtime checks exercise cold valid/invalid configuration through real SQLite after registry readiness; inspected tests support that scope, without establishing live-provider or Windows behavior.
Evidence reviewed 10 items Current main still needs this cutover: Current main calls synchronous canOwnerAccessTask after worker reads; that owner resolves bare session identities through getRuntimeConfig. The supplied merged metadata prerequisite explicitly leaves configuration preparation as separate work.
Publication and visibility safeguards: Task visibility awaits the existing identity rules and rechecks database admission before returning records. Cold configuration publication checks source selectors, snapshot generation, preparer generation, candidate facts, and staged environment; superseded environment publication rolls back.
Persistent contracts remain unchanged: The new worker selector reads the existing plugins.bundledDiscovery row, and the Claw reader selects existing consent columns through the artifact-preserving reader with an ownership check. No DDL, persisted encoding, retention rule, or schema-version change is introduced.
Findings None None.
Security None None.

How this fits together

Plugins query background tasks through OpenClaw’s task runtime. It reads persisted records, resolves the requesting owner’s identity, and returns only visible task details; cold configuration preparation supplies missing identity and policy facts.

flowchart TD
  A[Plugin task query] --> B[Read persisted tasks]
  B --> C{Owner identity available?}
  C -->|Yes| E[Check owner visibility]
  C -->|No| D[Await configuration preparation]
  F[Environment and stored plugin consent facts] --> D
  D --> E
  E --> G[Return visible task details]
Loading

Before merge

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

Security

None.

PR surface

Source +1192, Tests +1502, Docs 0, Other -1. Total +2693 across 43 files.

View PR surface stats
Area Files Added Removed Net
Source 31 2182 990 +1192
Tests 10 1503 1 +1502
Docs 1 3 3 0
Config 0 0 0 0
Generated 0 0 0 0
Other 1 1 2 -1
Total 43 3689 996 +2693

Review metrics

Metric Value Why it matters
Production versus test growth Production +1,192 net lines; tests/support +1,502 net lines The PR justifies production growth through awaited preparation and shared validation, with substantial boundary and publication coverage.

Stored data model

Persistent data-model change detected: database schema: src/claws/provenance-runtime-read.kernel.ts, database schema: src/claws/provenance-runtime-read.ts. Confirm migration or upgrade compatibility proof before merge.

Root-cause cluster

Relationship: partial_overlap
Canonical: #144592
Summary: This PR handles configuration preparation within the broader asynchronous-storage effort; registry restoration remains separate.

Members:

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

Technical review

Best possible solution:

Keep configuration preparation behind the existing publication and metadata owners, preserving task visibility and synchronous compatibility while moving cold SQLite reads off the Gateway thread.

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

Yes, from source: a bare-owner task without a persisted requester agent reaches the synchronous configuration loader on current main. The registered SQLite test provides a focused measurement path; this review did not execute it.

Is this the best way to solve the issue?

Yes. Shared sync/async orchestration retains one validation policy and existing storage owners, while the added preparation path addresses the identified cold-read boundary.

AGENTS.md: found and applied where relevant.

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

Labels

Label justifications:

  • P2: This is a bounded runtime responsiveness improvement for cold task visibility checks, with no demonstrated urgent user-facing outage.
  • 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 maintainer-authored PR is exempt from ordinary contributor proof. Its reported registered task-runtime checks exercise cold valid/invalid configuration through real SQLite after registry readiness; inspected tests support that scope, without establishing live-provider or Windows behavior.

Evidence

What I checked:

  • Current main still needs this cutover: Current main calls synchronous canOwnerAccessTask after worker reads; that owner resolves bare session identities through getRuntimeConfig. The supplied merged metadata prerequisite explicitly leaves configuration preparation as separate work. (src/plugins/runtime/runtime-tasks-async.ts:75, 52f2f2fd87bb)
  • Publication and visibility safeguards: Task visibility awaits the existing identity rules and rechecks database admission before returning records. Cold configuration publication checks source selectors, snapshot generation, preparer generation, candidate facts, and staged environment; superseded environment publication rolls back. (src/config/runtime-snapshot.ts:519, 1c6050ff27c6)
  • Persistent contracts remain unchanged: The new worker selector reads the existing plugins.bundledDiscovery row, and the Claw reader selects existing consent columns through the artifact-preserving reader with an ownership check. No DDL, persisted encoding, retention rule, or schema-version change is introduced. (src/state/openclaw-state.worker.ts:145, 1c6050ff27c6)
  • Prior review warning reassessed: The prior completed review had no findings and requested generic migration or upgrade compatibility proof. The storage policy exempts semantics-preserving reads from its material-change checkpoint; inspected tests cover fresh defaults, existing metadata, environment ownership, and superseded recovery observations. No schema migration requirement was established. Public docs: docs/reference/database-schemas/storage-changes.md. (docs/reference/database-schemas/storage-changes.md:412, 1c6050ff27c6)
  • Registered task boundary coverage: The added valid/invalid bare-owner cases invoke createPluginRuntime().tasks.async across get, list, findLatest, and resolve against SQLite fixtures. They assert returned visibility, snapshot publication, and zero parent-thread SQLite calls after registry readiness. These tests were inspected, not executed during this review. (src/infra/sqlite-worker-task-runtime.test.ts:105, 1c6050ff27c6)
  • Captured validation evidence: The supplied complete PR body reports 17 ordinary controls, an inherited schema control, 75 routing checks, the selected check gate, and a full build on tree 0b0ed30e91819da01727e110362b1aa4fd63ab17. Local tree identity matches. The body expressly excludes Windows, live-provider, and several native fault scenarios; those were not treated as exercised. (1c6050ff27c6)

Likely related people:

  • steipete: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • Ayaan Zaidi: Suggested for follow-up; no historical authorship or introduction is verified. (role: unverified routing candidate; confidence: low)
  • SunnyShu: 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 (2 earlier review cycles)
  • reviewed 2026-09-14T15:32:21.467Z sha 0ca85d6 :: blocked before merge. :: none
  • reviewed 2026-09-14T17:29:16.495Z sha 8d5efcc :: blocked before merge. :: none

@steipete
steipete merged commit 6718352 into main Sep 14, 2026
193 checks passed
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via squash.

@steipete
steipete deleted the codex/async-task-config-preparation-main-20260914 branch September 14, 2026 23:05
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Sep 15, 2026
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

docs Improvements or additions to documentation maintainer Maintainer-authored PR P2 Normal backlog priority with limited blast radius. plugin: file-transfer rating: 🐚 platinum hermit Good normal PR readiness with ordinary maintainer review expected. size: XL 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