Repository navigation
perf(storage): move bookkeeping reads to existing workers - #169631
Conversation
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review completeClawSweeper finished reviewing this revision. The review result is being finalized. |
|
Codex review: needs changes before merge. What this changesThis PR moves storage bookkeeping through existing workers and removes redundant reads while retaining synchronous SDK adapters. Example: Create a Board tab with tabId main and title Main using an ordinary request-authority callback.
Review scores
ProductKind: Performance · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep open: this owner-directed performance improvement remains useful, but the provenance lifecycle fixture regression and SDK diagnostic-documentation defect are still unfixed. Priority: P2 Before merge
Findings
Agent review detailsHow this fits togetherGateway and CLI callers submit Board, metadata, ACP, and cleanup operations to existing storage owners, which return selected facts and committed receipts. flowchart TD
A[Gateway and CLI callers] --> B[Admission and lifecycle owners]
B --> C[Shared read worker]
B --> D[Agent write worker]
C --> E[SQLite databases]
D --> E
E --> F[Facts and commit receipts]
F --> A
Technical reviewBest possible solution: Keep the worker cutover and repair the lifecycle fixtures and SDK diagnostic documentation. Do we have a high-confidence way to reproduce the issue? Current-main source establishes the foreground storage paths, and current-head CI independently confirms the introduced provenance fixture failure. Is this the best way to solve the issue? Existing workers and publication owners provide a coherent solution, with explicit reasons for removing the redundant checks. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 4fcac1184680. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource -232, Tests -168, Docs +8, Other +8. Total -384 across 60 files. Added test files: 0. View PR surface stats
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/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. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (5 earlier review cycles)
Reviewed October 12, 2026, 4:16 AM ET / 08:16 UTC (Revision 6). |
…orage # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # src/config/sessions/session-accessor.sqlite-projection.ts # src/config/sessions/session-lifecycle-projection.worker.ts
…orage # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md # src/agents/subagents/registry/subagent-registry-read-snapshot.ts # src/cron/isolated-agent/run-subagent-registry.runtime.ts # src/cron/run-continuation-cleanup.ts # src/cron/session-reaper.ts
…orage # Conflicts: # docs/reference/database-schemas/worker-access-inventory.md
Opening a database no longer refreshes Claw provenance after ef7aa6a (#169631). Explicitly initialize the existing provenance owner for both fixture generations, keeping every readiness, afterAll, resource-drain, close-invalidation and retired-generation assertion intact. The architectural PR #169714 carries the same fixture hunk and will rebase onto this narrow red-main repair. The full non-isolated runner test file passes with one worker: 2 tests in 69.66 seconds wall, including both real Gateway lifecycle fixtures. The original fixture reproduces the exact missing A:ready and B:ready failures.
…0318) Pass the captured target session identity into the existing Board mutation-kernel validation, eliminating one redundant target-session SELECT per cross-store putWidget, applyOps, and grant. Preserve source-permission checks and cover cross-physical target replacement and source revocation. The full cross-database worker cutover remains blocked on the shared final-authority contract described in #169631; Board T1 primitive counts remain unchanged. Validation: PR CI tests and static gates, Knip export scans, and independent Codex review.
…69631) Use existing database workers for Board reads and metadata bookkeeping, remove repeated subagent/provenance checks, and make plugin-state consumption atomic. Keep prepared skill resources explicit while preserving the released host construction contract. Validation: scoped owner proof, live SQL pairs, Codex review, published-driver update cell, CI types/lint/Madge/ratchets. Inherited CI failures and the retained cross-store Board authority limitation are documented in the PR.
Opening a database no longer refreshes Claw provenance after 2d26ec2 (openclaw#169631). Explicitly initialize the existing provenance owner for both fixture generations, keeping every readiness, afterAll, resource-drain, close-invalidation and retired-generation assertion intact. The architectural PR openclaw#169714 carries the same fixture hunk and will rebase onto this narrow red-main repair. The full non-isolated runner test file passes with one worker: 2 tests in 69.66 seconds wall, including both real Gateway lifecycle fixtures. The original fixture reproduces the exact missing A:ready and B:ready failures.
…nclaw#170318) Pass the captured target session identity into the existing Board mutation-kernel validation, eliminating one redundant target-session SELECT per cross-store putWidget, applyOps, and grant. Preserve source-permission checks and cover cross-physical target replacement and source revocation. The full cross-database worker cutover remains blocked on the shared final-authority contract described in openclaw#169631; Board T1 primitive counts remain unchanged. Validation: PR CI tests and static gates, Knip export scans, and independent Codex review.
What Problem This Solves
Board operations, plugin metadata inspection, and session cleanup still perform avoidable SQLite work on the Gateway thread or repeat reads already owned by a worker.
User Impact
Board operations and plugin discovery retain their behavior while moving eligible reads and writes through existing workers. Session cleanup retains live descendant protection without repeatedly scanning and hashing the registry. No schema, stored-format, retention, or configuration changes are introduced.
Released synchronous SDK adapters remain functional. The ambient-watch helper is retained with a deprecation warning directing callers to
prepareWatchedSessionsPromptAsync; proxy-capture adapters likewise warn toward their async replacements. Native incognito and cross-store Board authority paths remain explicit exceptions.Why This Change Was Made
Ordinary Board request callbacks now use the existing worker, and reads reuse an enclosing transaction instead of opening a nested savepoint. Cross-store source authority still uses its native effect boundary. Plugin metadata, including retained artifact snapshots, moves to the shared read worker; the old writer-worker command and synchronous runtime fallback are removed. Plugin-state consume uses one
DELETE … RETURNINGstatement and decodes within the transaction. The sessions CLI awaits the existing batched ACP reader, allowing the duplicate synchronous batch implementation to be deleted.Subagent cleanup consumes the worker's descendant selection and the existing in-process liveness guard. The durable digest, repeated identity captures, and their plumbing are removed. Opening another database handle no longer triggers an extra Claw provenance query; explicit config preparation and committed writes publish those facts. Skill resource callers must supply prepared library entries, removing the hidden synchronous fallback. Inventory changes classify only evidenced worker or CLI operations; remaining synchronous compatibility debt is not relabeled away.
Removed checks and accepted edges
Evidence
The measured base is
5ef9e1adcbcc11d7cec67c897f20d5a6a8b2619c; the measured candidate is1da859093f81008a4a097a26eebc62c8ea6688a9. Subsequent cleanup is SQL-equivalent. Validation follows the maintainer's relaxed testing v6: basic local formatting/lint, isolated live SQL measurement, and PR CI for the final test/static gates.Completed before the policy change: focused owner tests (including Board worker/authority behavior, committed-write metadata freshness, Claw read facts, ACP CLI batching and retained-reader admission), Madge, export-collision scan, SDK surface report, database-worker ratchet, and dialect ratchet. The initial check:changed found two incomplete test-module mocks; those now spread their real exports. The basic lint pass also removed empty callbacks left by the retired descendant check and an unused test import. These are fixture/dead-code repairs; no passing final-head CI is claimed here.
Two Codex autoreview rounds found no actionable P0/P1 issue; the subsequent skill-resource compatibility repair also received a clean focused Codex review. The published-driver × candidate update cell passed on
5fccf90be9226a1eb7a7e154fce8f2a02bb12972; subsequent commits only integrate main and resolve conflicts. Earlier-head CI passed at737a83b4b5c51a0f11520f86b1e79455aa7ce85c.Live SQL measurements
The shared harness ran in isolated state in alternating order M1, C1, M2, C2. The first pair exceeded the duration-skew threshold, so one ambiguity pair reused the exact compiled revisions. Each warmed value is a mean over ten turns; the aggregate is the median of the two run means, with their min–max range. The baseline was already below 500 statements per warmed turn before this PR; that earlier gain is not attributed to this lane.
The host was heavily loaded. Individual pairs skewed in opposite directions; the aggregate median-duration ratio is 0.814. These counts support no observed aggregate increase, not a latency or causal-savings claim. In C1, five extra background memory-core publications account for 170 additional warmed statements and 41 requests versus M1. The memory-core source is unchanged here. Maintenance timers also vary with run duration.
The changed warmed owners are stable across all four runs:
subagents.runsexecutes 10 statements/10 requests andsession.lifecycle.projectexecutes 130 statements/10 requests across ten turns. Auth-profile reads execute 30 statements, trajectory appends 80, and session-row changes 30 in every warmed sample. C1 alone places 13 first-use temporary-trigger setup statements inside the first lifecycle projection; C2 and both baselines do not. No repeated warmed increase comes from that setup.The request census reconciles exactly with the shared native statement counter in every phase/thread, with no missing contexts or duplicate sends. Each run has two boot-only unresolved worker identities (
gatewayOwnerLease.read,userProfiles.catalog); none are warmed.An initial candidate attempt timed out waiting for warmed turn 7 after six successful turns. It is excluded from the table and retained as failure evidence; the exact build passed the retry without timeout changes. M2 completed all 13 turns, child execution, cron, compaction, and clean shutdown, but
mentions.dismissreturned retryableUNAVAILABLEin the later control-plane phase, so the driver's all-RPC-success assertion failed. Its completed warmed phase is reported with that limitation. Shutdown-onlyBEGIN IMMEDIATEbusy attempts occurred in C1 (5), M2 (2), and C2 (1); no boot, first-turn, or warmed SQL errors occurred. All fixture children exited.Exact-source T1 census
Each revision's own classifier was run; this is separate from the current-classifier ratchet. Multiple tier records for the same file are summed, not overwritten.
This PR's exact changed-owner reduction is the two subagent-registry call sites. The other four lane reductions are inherited classifier changes for config health (1), cron row decoding (1), and trajectory (2). Remaining synchronous SDK/native exceptions still count as T1; this PR does not claim that the original lane reached zero.
Change size
Current integrated diff against
ccb7b5f7e5de8: 60 files, +506 / −890 lines (net −384).Landing uses the authorized SHA-pinned REST fallback: native review checkout refresh stalled over 10 minutes and was stopped before any merge submission.
The supplemental static dispatch passed both Knip production and export scans. Its later unused-file ratchet flags
scripts/check-sdk-package-extension-import-boundary.mtsandscripts/check-src-extension-import-boundary.mts; both scripts and their Knip/package/CI owners are byte-identical and already unreferenced at base70bfdc2b58e42. This inherited orphan-file result does not replace the passing export scan.Landing integration
Head
541cd8bda95b4411f1bea3c0cd170f218d91b83cintegrates mainccb7b5f7e5de8e0e6c3bd20030c902d2134e9a15without source conflicts. This includes main'sf0a14bf986e6fix for the unused cron type and two chat exports. The immediately preceding PR CI and supplemental static run at2eb658633c82cpassed types, lint, source contracts, Madge (zero cycles), T1/dialect ratchets, and SDK API diff. T1 ratchet: live 550 → 550, compatibility 2 → 2 against the integrated base; no increase or zero-T1 claim.That PR run's remaining failures are inherited:
sessions-rewind.test.ts's extra upstream-link SELECT is also in main run38216343022;server.codex-failure-recovery.test.ts's physical-owner validation error and the built CLI flip's abortedagent.waitare also in main run38220958692; the phone chat-footer overlap is outside this PR. Knip's memory-flush helper warning occurs on main in the latter run. Main's named cron/chat export fix is integrated here rather than waived. No passing current-head runtime CI is inferred from these failures.The retained Board cross-store write at
SqliteBoardStore.writerequires authority from a different physical database; the existing target worker validates only its own database. Moving that call requires a source-owner operation or complete revocation publication contract, so it remains under the explicit owner-redesign escape hatch. Ordinary bundled Board requests preserve typed preparation through Gateway dispatch and use worker admission. Opaque external callbacks retain compatibility reachability; no ordinary bundled producer was found. Native incognito is left for its designated owner.At the final exact head, CI 38223108696 passed production types, all five core test-type stripes and their aggregate, type-aware core and extension lint, source contracts, architecture checks (Madge: zero cycles), and T1/dialect ratchets. The type-suppression inventory failure is inherited: main
04cfcd8e25871added the Bun socket annotation inscripts/lib/managed-cleanup-handoff.mts; that module and the inventory test are unchanged by this PR and byte-identical to the merged main parent. The supplemental exact-source SDK API report remains valid for the unchanged SDK contract.