Repository navigation
improve: reduce repeated SQLite work during chat turns - #168002
Conversation
…odules Merge current main while preserving shared physical admission, cancellation, reader validation birthtime, and live deletion authority. Split worker usage, pool construction, failure settlement, and schema owner types to keep the existing line caps.
Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions.
Reuse admitted policy, supervision, TTS and mention facts; replace the connection-local generation table with JavaScript tracking. Initial P2 review is clean. Focused proof and host-custody test routing are in progress.
Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity.
Merge current main and preserve its optional settlement-only receipt delivery through the extracted owner. Keep the worker refusal error with the leaf contract to stay within the existing admission line cap. End the marker-free read-only fixture transaction normally; dedicated rollback and explicit revocation coverage remains unchanged.
Share startup policy facts, coalesce cold TTS reads, and fence failed policy publication. Exercise the physical admission owner in host tests, preserve artifact and recovery contracts, and correct prerequisite test metadata.
Retain the inactive notifier fact until its own writer attempts or service restart invalidate it. Fence empty reads against concurrent writes, including committed writes whose replies are lost, while preserving active delivery authority and receipts.
Resolve canonical validation fixture conflicts while preserving first-physical-admission behavior. Route the Windows Memory corpus suite through its existing host-owned project. Post-integration production and test type graphs and Madge pass; focused conflict and ownership tests pass.
Agent-specific inbound registries can register a distinct command API while the Gateway notifier remains active. Share write revisions across those APIs so a committed arm, including a lost reply, invalidates every older empty observation.
|
🦞👀 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. |
|
Fixed in The remaining failures were test-contract issues:
Ownership already uses the shared physical-database identity admission. No cache flush, per-request ownership read, or production change was added. Replayed the exact selected CI shard plans with Node 24.19.0 on Linux. Testbox timed out after 15 minutes queued; the authorized AWS Crabbox fallback used one lease for before/after proof.
Scoped infrastructure/cron typechecks, changed-file lint, formatting, ratchets (no T1 growth), and fresh Codex P0/P1 review passed. Remote wall times: cron shard 153.70s; infrastructure shard 64.58s; focused suite wrapper 62.57s. Test-only delta: +26/-39 lines; production +0/-0. Prior SQL savings remain unchanged. The published-driver update cell remains pending for the lander. |
|
Integrated main The shared generation layout now assigns write receipts to slot 5 and host-publication completeness to slot 6. Both the allocator and inherited-record validator use the seven-slot layout; readers and writers use the same named indices. A regression asserts that all indices are unique and fit the buffer. The remaining resolutions preserve noprobe's receipt-driven freshness and this PR's cached ownership/main-key facts. The JS generation tracker retains rollback invalidation through the extracted scope helper. Existing canonical-writer publication/race tests retain coverage of main-key changes; raw-worker edits to process-owned constants are outside that contract. No freshness probes or general lifecycle access restrictions were restored. Verification:
The CI shards ran through the real shard runner on Testbox, including cron refusal and both startup-migration ownership cases. The combined shard command passed in 162 seconds. Its lease is stopped and the remote slot released. The initial focused batch had 196 passes and one obsolete TEMP-generation fixture failure. The fixtures now use the existing transcript-index tracking shape; its installer resets the status, so the custom trigger is restricted to the explicit write under test. The subsequent batch passed all 53 native-schema tests and all 18 canonical-policy tests; the remaining schema-facts case then passed with the complete 49-test file above. Ownership/live and offline claim, pairing, physical identity, worker admission, canonical keys, session probes, auth-profile stores and TEMP-facts coverage passed. Production code has not changed since the Testbox run; the final repair is test-only (+17/-17 lines). Scoped infra, config-cli, state-logging and services-cron typechecks passed. Formatting and final test-file lint passed. The broader lint run has only two remaining file-length diagnostics: Fresh Codex P0/P1 reviews of the conflict resolution and final fixture repair: clean. Prior P2 review convergence is retained. Local focused/static checks used the campaign proof slot after the remote wait exceeded 30 minutes with host load below 48. No additional SQL measurement was run for this conflict resolution; the existing paired savings proof is retained. The published-driver update cell remains pending for the lander. I have not merged this PR. |
Keep auth staging assertions on the canonical-schema diagnostic emitted by the helper. Focused proof: 4 tests pass; fix-only review found no P0/P1 issues.
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
Clone typed history parameters once while retaining entry and environment pruning. Let the native list reader validate the selected file instead of repeating host stat probes around dispatch. A replacement immediately after the native read is best effort; consumer authority and multi-store checks remain. Provenance: request capture from #147914; redundant host probes from #165470. Net production reduction: 94 lines. Focused proof: 123 tests passed; core typecheck and independent review passed. Existing lint-suppression allowlist failure in untouched #168002 test-support files is not changed.
* perf(sqlite): checkpoint shared admission across workers (WIP) * test(sqlite): align worker fixtures with shared admission * perf(sqlite): avoid repeated quarantine reads in retained scopes * test(sqlite): align first-admission coverage and deletion fixtures Route retained existing-state writer coverage through the host-owned worker project, preserve first-admission incompatibility refusal, and match the final deletion-authority contract. Keep the gateway test under its inherited line count by moving existing pure fixture helpers. Regenerate assertion allowances without adding production assertions. * perf(sqlite): retain process-owned database constants Reuse admitted policy, supervision, TTS and mention facts; replace the connection-local generation table with JavaScript tracking. Initial P2 review is clean. Focused proof and host-custody test routing are in progress. * build(sqlite): include shared admission in compiled wrappers Include the thirteen transitive admission modules required by the native wrapper import-closure proof. Carry the existing birthtime through the worker validation fixture to preserve its physical-file identity. * test(sqlite): use the canonical settlement owner in publication proof * perf(sqlite): finish constant publication and startup reuse Share startup policy facts, coalesce cold TTS reads, and fence failed policy publication. Exercise the physical admission owner in host tests, preserve artifact and recovery contracts, and correct prerequisite test metadata. * test(sqlite): exercise worker failure through its owner * perf(sqlite): retain host publication completeness across worker relays * test(sqlite): type admission fixture results against their operation contract * fix(sqlite): preserve cleanup and explicit maintenance validation * fix(sqlite): retain revocation and scoped worker admission * fix(sessions): preserve committed main key across unrelated schema changes * style(sqlite): clarify method interception and remove redundant copying * fix(sqlite): preserve migration and read-cache owners * perf(device-pair): skip repeated empty notification scans Retain the inactive notifier fact until its own writer attempts or service restart invalidate it. Fence empty reads against concurrent writes, including committed writes whose replies are lost, while preserving active delivery authority and receipts. * fix(sqlite): preserve maintenance and bootstrap admission * fix(sqlite): keep temporary trigger admission connection-local * fix(device-pair): invalidate idle state across agent registries Agent-specific inbound registries can register a distinct command API while the Gateway notifier remains active. Share write revisions across those APIs so a committed arm, including a lost reply, invalidates every older empty observation. * fix(sqlite): preserve unavailable discovery target isolation * fix(database): require offline custody for ownership claims * fix(database): preserve read-only inspection behind live owners * fix(sqlite): preserve rollback and cleanup admission boundaries * fix(sqlite): preserve admission custody and explicit update inspection * refactor(database): simplify admission control flow * test(sqlite): restore tracker fixture import after integration * fix(sqlite): preserve admission custody across cleanup and creation * fix(pr): retain receipt dependency in wrapper inventory * fix(sqlite): preserve first-creation admission authority * test: reconcile tracker coverage with parent temp admission * fix(database): scope live-owner exclusion to ownership claims * test: use canonical writers for ownership and cron fixtures * test: align ownership and cron refusal fixtures * test: align SQLite fixtures with admission ownership * test(sqlite): align merged fixtures with receipt tracking * test(sqlite): restore auth staging error expectations Keep auth staging assertions on the canonical-schema diagnostic emitted by the helper. Focused proof: 4 tests pass; fix-only review found no P0/P1 issues.
c038ede (openclaw#168002) added test-support probes that retain raw prototype methods for restoration and invoke them through Reflect.apply with the live receiver; record the three suppressions on the explicit allowlist.
Clone typed history parameters once while retaining entry and environment pruning. Let the native list reader validate the selected file instead of repeating host stat probes around dispatch. A replacement immediately after the native read is best effort; consumer authority and multi-store checks remain. Provenance: request capture from #147914; redundant host probes from #165470. Net production reduction: 94 lines. Focused proof: 123 tests passed; core typecheck and independent review passed. Existing lint-suppression allowlist failure in untouched #168002 test-support files is not changed.
Clone typed history parameters once while retaining entry and environment pruning. Let the native list reader validate the selected file instead of repeating host stat probes around dispatch. A replacement immediately after the native read is best effort; consumer authority and multi-store checks remain. Provenance: request capture from #147914; redundant host probes from #165470. Net production reduction: 94 lines. Focused proof: 123 tests passed; core typecheck and independent review passed. Existing lint-suppression allowlist failure in untouched #168002 test-support files is not changed.
…ling (#168991) * refactor(sessions): simplify history request capture and list reads Clone typed history parameters once while retaining entry and environment pruning. Let the native list reader validate the selected file instead of repeating host stat probes around dispatch. A replacement immediately after the native read is best effort; consumer authority and multi-store checks remain. Provenance: request capture from #147914; redundant host probes from #165470. Net production reduction: 94 lines. Focused proof: 123 tests passed; core typecheck and independent review passed. Existing lint-suppression allowlist failure in untouched #168002 test-support files is not changed. * refactor(sessions): simplify read and reconcile lifecycles Remove speculative registry retargeting, reader custody and generation protocols, reconcile priority reservations and successor handoffs. Keep one current-authority check at effects, atomic projection finalization, bounded resources and ordinary write-capable shutdown settlement. Retain simple session-boundary fairness for the production incident recorded in #165107 and bounded backoff for the human report #115908. Unsupported mid-call topology changes and failed derived projection preparation are best effort until the next request or restart. No schema, stored-data, retention, permission or public API change. Validation: 36 focused history/bootstrap tests pass; corrected Testbox shutdown and registry controls pass; both import-cycle checks report zero cycles; core typecheck and targeted lint pass. Review findings addressed, including empty archive-path semantics and immediate async-consumer rejection handling. Publication remains blocked before PR/merge: still-open heartbeat PR #167796 protects session-logical-entry-read.worker.test.ts, whose obsolete pending-registration assertions require a scope exception. Full sessions proof is incomplete. Unchanged baseline suppression and UI test-root budget failures are recorded in the lane ledger. * test(sessions): retire obsolete registry interleavings * test(sessions): retire obsolete history lifecycle guards * test(sessions): retire obsolete read lifetime assertions * test(sessions): keep reclamation checks at the write boundary * test(sessions): retire obsolete incognito reconcile handoffs * test(sessions): retire remaining registry and handoff fixtures * refactor(sessions): remove unused registry settlement waiters * fix(sessions): bound reconcile admission and close readiness safely * style(sessions): format merged target cache imports * test(sessions): decouple cross-agent recovery ordering * fix(sessions): keep registry settlement independent of callers * fix(sessions): reauthorize incognito context publication * fix(sessions): preserve absent incognito context reads
…ling (openclaw#168991) * refactor(sessions): simplify history request capture and list reads Clone typed history parameters once while retaining entry and environment pruning. Let the native list reader validate the selected file instead of repeating host stat probes around dispatch. A replacement immediately after the native read is best effort; consumer authority and multi-store checks remain. Provenance: request capture from openclaw#147914; redundant host probes from openclaw#165470. Net production reduction: 94 lines. Focused proof: 123 tests passed; core typecheck and independent review passed. Existing lint-suppression allowlist failure in untouched openclaw#168002 test-support files is not changed. * refactor(sessions): simplify read and reconcile lifecycles Remove speculative registry retargeting, reader custody and generation protocols, reconcile priority reservations and successor handoffs. Keep one current-authority check at effects, atomic projection finalization, bounded resources and ordinary write-capable shutdown settlement. Retain simple session-boundary fairness for the production incident recorded in openclaw#165107 and bounded backoff for the human report openclaw#115908. Unsupported mid-call topology changes and failed derived projection preparation are best effort until the next request or restart. No schema, stored-data, retention, permission or public API change. Validation: 36 focused history/bootstrap tests pass; corrected Testbox shutdown and registry controls pass; both import-cycle checks report zero cycles; core typecheck and targeted lint pass. Review findings addressed, including empty archive-path semantics and immediate async-consumer rejection handling. Publication remains blocked before PR/merge: still-open heartbeat PR openclaw#167796 protects session-logical-entry-read.worker.test.ts, whose obsolete pending-registration assertions require a scope exception. Full sessions proof is incomplete. Unchanged baseline suppression and UI test-root budget failures are recorded in the lane ledger. * test(sessions): retire obsolete registry interleavings * test(sessions): retire obsolete history lifecycle guards * test(sessions): retire obsolete read lifetime assertions * test(sessions): keep reclamation checks at the write boundary * test(sessions): retire obsolete incognito reconcile handoffs * test(sessions): retire remaining registry and handoff fixtures * refactor(sessions): remove unused registry settlement waiters * fix(sessions): bound reconcile admission and close readiness safely * style(sessions): format merged target cache imports * test(sessions): decouple cross-agent recovery ordering * fix(sessions): keep registry settlement independent of callers * fix(sessions): reauthorize incognito context publication * fix(sessions): preserve absent incognito context reads
What Problem This Solves
Chat turns repeatedly read SQLite facts that only the owning Gateway process can change, and an unarmed device-pair notifier repeatedly scans two empty stores.
Prerequisite #167739 has merged; this PR now targets
main. The earlier measurement base is its pinned8b7184988a61revision; the ownership correction below integrates parenta12c2b8a9e63and pinned maindb776fa6a762, then resolves the admission conflict against parent57ffc8f51c8e. The final integration of main4ea40f2b890ereconciles the prerequisite’s squash ancestry. This lane does not claim the prerequisite’s check-once savings. The admission conflict resolution retains both generation-identity cursor fencing and the host-owned constant receipts; it adds no SQL.User Impact
Fewer SQLite statements and worker requests during chat and idle notification scans. Configuration, persisted schema, durability, retention, permissions, and active notification delivery behavior are unchanged.
Runtime writes follow one Gateway owner. Established updater handoff, restart-sentinel, and update-finalization writers retain their existing lifecycle fences. Ownership claims require exclusive offline custody; remaining routing follow-ups are listed below.
The final-head published-driver × candidate update cell passed on AWS at
a83d81d8be926: published2026.9.9updated successfully, readiness returned 200, the running version matched, and durable/incognito state survived.Why This Change Was Made
Canonical main-key policy, supervision ownership, and the TTS preference path use the existing physical-database admission owner. Writers publish committed replacements; present main-key values survive unrelated DDL, while missing rows remain visible to schema seeding. Late initial reads cannot overwrite a committed policy. Host completeness is carried through nested workers without repeated missing-key exchanges.
The Mentions Inbox skips unchanged snapshots and reads changed head/source state atomically. Existing TEMP triggers advance connection-local JavaScript generations instead of selecting a counter. Auth readers consume admitted table/view/absence facts. The device-pair notifier retains only the fact that both stores are empty: its own write attempts and service startup invalidate that fact, and a module-owned revision/in-flight-write count fences older reads across the distinct APIs used by Gateway and agent registries. Active delivery still observes current subscriptions and commits the same CAS and delivery receipts.
Against integrated main
4ea40f2b890e, net growth is 469 production lines (679 added, 210 removed), 708 test/support lines (1,060 added, 352 removed), and 32 documentation lines (34 added, 2 removed). The growth carries publication/rollback ordering, claim-only custody, and real worker/process-boundary regression proof; no new manager or persistent store is introduced.ClawSweeper P1 resolution: enforce offline supervisor adoption
The accepted ownership finding is fixed in this PR.
openclaw database ownership claimis a one-time external-supervisor setup command, so it must run after the supervisor stops the Gateway and all embedded agents. It does not need a live Gateway to accept setup, and no new Gateway RPC is added.The CLI now uses
runWithLocalStateOwner: verified live Gateway/embedded custody refuses before mutation with external-supervisor stop guidance; otherwise exclusive offline custody covers config admission, the claim transaction, accepted work, and native cleanup. The low-level claim operation also takes the existing exclusive physical lease through admission, commit, repair, and checkpoint. General database admission is restored exactly to integrated main for other operations, including existing cross-process lifecycle writers; the temporary read-only admission exceptions are removed. Cached ownership publications, synchronous transactions, and live authority checks are unchanged; no per-request ownership or schema SELECT is restored.The docs now state that the CLI enforces the offline procedure. Real child-process regressions cover live refusal with the database unchanged and the Gateway's next write still valid, offline custody during the actual ownership INSERT, next-start ownership enforcement, and same-manager idempotency. Direct-operation regressions separately prove that bypassing the CLI cannot claim behind a live Gateway/embedded owner or commit without offline custody. Negative controls exercise both the lifecycle regression and missing claim-only custody.
The parent integration is
9456eba0ffd8(six resolved files, scoped P0/P1 review clean), followed by one conflict-free integration of pinned maindb776fa6a762at1df1986eb403. The ownership fixes are9b216ca017d0and934fe269c6f6; both received scoped-clean Codex P0/P1 reviews. The later parent conflict is resolved at026db9d992fe6, and duplicate tracker tests are reconciled with the parent TEMP suite at803a68cd7e84d; both follow-ups also received scoped-clean P0/P1 reviews. The latter removes stale counter-table fixtures and the duplicate tests that still expected unrelated TEMP DDL to revoke MAIN admission; the parent suite retains the stronger current-contract coverage. The existing three-P2-round convergence limit remains in force.One alternating sanity pair uses baseline
75a8890d755a(clean merge of check-oncea12c2b8a9e63and the same pinned main, excluding this lane) versus candidate934fe269c6f6. Both have verified source-mapped builds. Subsequent return/dispatch simplifications, admission-cursor integration, and tracker-test reconciliation are SQL-neutral and covered by the final focused checks. This is the coordinator-requested warmed-savings check, distinct from the earlier three-pair proof. A singleton has identical median and min–max; warmed rows are per turn, other rows are phase totals. Requests are logical worker requests.Whole workload, startup through shutdown:
Entire-workload operation totals for this sanity pair:
database.domain.binddatabase.domain.closedatabase.domain.executedatabase.domain.publishdatabase.prepareWritepluginState.compareDeletepluginState.compareUpdatepluginState.entriespluginState.observepluginState.sweepWarmed attribution conserves exactly: −77.9 constant reads + 2.6 TEMP setup + 28.3 other SQL = −47.0 statements/turn. Removed reads are main key 34.9, ownership 21.8, connection generation 14.0, auth catalog 3.2, Mentions head 3.0, and TTS path 1.0. The setup offset is two newly initialized connection-local trigger sets (one catalog query, six drops and six creates each). Other SQL is +45.5 from
database.prepareWrite, +8.9 session/shared row facts, and −26.1 across the remaining recorded owners. Memory producer trees are byte-identical between these heads. Logical requests fall 7.5/turn: four Mentions/TTS requests plus 3.5 from other owners. Fact messages rise 2.4 and other control messages 1.2, giving 3.9 fewer total request messages/turn. Moving statements between threads is not counted as a saving.The warmed duration ratio is 0.774 and whole-workload ratio 0.958. This singleton has +196 first-turn SQL and a 1.766 shutdown duration ratio; it does not replace the earlier three-pair whole-workload gate.
database.prepareWriteincreases from 22 to 24 calls (+73 SQL) over the entire workload, so this singleton does not establish a reduction for every operation family. Two unresolved bootstrap destination IDs occur on each side; all requests are counted and SQL conservation is exact. Best-effort failedBEGINdiagnostics remain recorded: one shutdown lease release on each side and one additional first-turn plugin-maintenance lease release on candidate.Historical negative controls failed on the integrated pre-fix baseline for live claims and absent offline custody. The original broad-admission negative control is superseded by the claim-only regressions below; general access intentionally retains main behavior. The source-mapped candidate build passed in 151.4 s. Compact per-run, request/SQL-owner, attribution, and SHA-256 evidence is retained; raw runs and the disposable baseline are removed after aggregation.
Final local focused proof on
803a68cd7e84dpasses 87/87 tests, through the campaign proof slot. The seven formerly missing-import cases are now covered at the parent’s consolidated tracker owner: 17 TEMP/tracker cases pass, alongside 60 schema/worker-admission cases, all three real claim-process regressions, the local-owner unit case, and six entry-revision cases. The earlier completed 238 passes, including the 58-case owner-routing matrix, are reused. No production behavior changed in the final test consolidation.pnpm test … --maxWorkers=1)src/infra/sqlite-schema-facts.temp.test.tssrc/infra/sqlite-schema-facts.test.ts+src/infra/sqlite-database-admission.worker.test.tssrc/cli/database-ownership.process.test.tssrc/cli/local-state-owner.test.tssrc/config/sessions/session-accessor.sqlite-entry-revision.test.tspnpm install --frozen-lockfilepasses. Madge reports zero cycles (20.58 s). File-scopedcheck:changedstops at two file-size ratchet findings:sqlite-database-admission.tshas 701 counted lines andsqlite-schema-facts.tshas 713, against a 700-line cap. These are recorded as non-blocking under the explicit campaign instruction that LOC has no hard cap. The remaining canonical check plan is run separately, preserving the type, lint, formatting, authority, and SQL-worker gates.The remaining canonical plan completed all 32 checks: 31 pass; scoped lint reports only the same 701-line admission file. Production types pass in 33.57 s, all 27 affected test type graphs pass in 522.67 s, and the core graph boundary passes in 65.35 s. Formatting, plugin boundaries, schema/storage, authority-related guards, and runtime import cycles pass. The SQLite worker ratchet reports no T1 call-count growth against
57ffc8f51c8e. The assertion baseline is 6,775 on this integrated parent. The earlier missing-birthtimetype failures are absent from this final run.Knip production/script/full-tree unused-export scans and the standalone all-exports scan pass with zero entries. The full production scan reports one inherited unused-file warning:
src/infra/sqlite-source-fence-admission.ts. This file is unchanged by the lane and byte-identical on main, where only its test imports it. Main already fixes exactly this warning in #168241 (d719f09ad46f2) by explicitly exempting the dormant module until its first production caller. The final main integration includes that config-only fix. The scan result above is retained as evidence from tested head803a68cd7e84d; no fresh final-merge full production scan is claimed.The attempted comparison scan at main
cdeb1e37adc6ealso exited 1, but it is not claimed as an exact reproduction: the newer checkout lacked the linked@openclaw/libterminaldependency, and reported different unused dependency/export entries (@modelcontextprotocol/core,isPollVoteEchoText, andPUBLIC_SESSION_ENTRY_SCRIPT). The exact upstream fix and unchanged source establish the candidate warning's inherited origin; the comparison's dependency limitation is retained as a proof gap. Its disposable worktree was removed. The only lane-owned static exceptions are the explicitly non-gating file-size findings described above; no type, runtime, authority, or T1 failure remains.Remote verification previously exhausted three hours without executing a payload: Testbox timed out queued and was stopped; AWS refused the shared fleet cap; the Hetzner attempt remained queued and was canceled before allocation. The coordinator authorized the final local run. No task-owned remote lease remains. Hosted CI timings are pending.
The final main integration is
0856728ac4569(main4ea40f2b890e); its fresh Codex P0/P1 review is scoped-clean. It preserves all resolved lane production files byte-for-byte from tested head803a68cd7e84d. In files shared with the lane, main adds unrelated MCP/models fixture dispatch and theverify-preservationCLI command; the worker-test registry retains both sets of registrations. The two unrelated test conflicts take main exactly. Registry syntax and staged whitespace checks pass. The completed focused/static proof above is reused for the preserved lane code; it was run on803a68cd7e84d, not the final merge commit.The final-head published-driver × candidate update cell passed on AWS. No schema or durability/retention contract changes accompany this correction.
Lifecycle narrowing after CI regression
The general foreign-owner guard caused six lifecycle failures in the exact-head CI job. All six were reproduced locally on
0856728ac4569before editing: pre-park staging (SIGINT, uncertain SIGTERM, failed Gateway close, and hosted stop), completion, and pre-transfer. Handoff, restart-sentinel, and update-finalization writes were rejected before their existing lifecycle fences could do their work. The seventh preparing-phase case passed. The focused reproduction took 90.83 seconds, excluding the 34-minute shared-slot wait.The correction restores all nine general admission/reader files byte-for-byte to integrated main
4ea40f2b890e. OnlyclaimOpenClawStateOwnershipgains an exclusive physical lease through admission, transaction, repair, and checkpoint; the CLI retains its offline owner scope and external-supervisor stop guidance. Synchronous transactions and cached ownership publication remain unchanged. No SQL query or worker request is added to the warmed path, and no new measurement claim is made.With only the general reversion applied, the direct-operation regressions failed as intended: both live-owner roles accepted the claim, and the offline direct claim wrote without custody (three failures; CLI offline case passed, 92.15 seconds). The final regressions retain the existing CLI behavior and add the direct-operation boundary.
The correction is committed as
7c850b2cc9e40. Final proof ran locally through the campaign proof slot:The first combined focused invocation took 187.12 seconds and exposed three test-assertion failures: the direct fixture returns a structured JSON error, and its exclusive lease has the
sqlite-maintenancerole rather than the CLI'sagent-embeddedrole. Those assertions were corrected to the existing contracts; the final four-case rerun above passes completely, including unchanged live database bytes, the Gateway's subsequent write, exclusive offline custody, next-owner enforcement, and same-manager idempotency. The 55 state/owner results remain valid because production did not change after that run. The negative controls failed at the intended missing-refusal/missing-custody assertions before the lease was added.Frozen install, final formatting, and
git diff --checkpass. The final Codex P0/P1 review is scoped-clean. No fourth P2 round was added. New-head hosted CI seconds are pending; no CI rerun or green-CI claim is made here. The final-head published-driver update cell passed on AWS; see the landing validation below. No task-owned remote lease remains.Earlier three-pair evidence
The first-turn question is evaluated across the entire fixed workload, startup through shutdown, using three alternating pairs with all threads and helper processes counted. Every requested operation family has equal or lower median request and statement totals. Whole-workload duration ratio is 0.967; warmed-turn duration ratio is 0.977. The first slow candidate was retained, and two further alternating pairs resolved its timing skew—no run was discarded.
Measurement heads are
8b7184988a61→7dba5c720cc0. The final correctness correction atd2b39426fc5fshares a JavaScript invalidation revision across agent API objects. It adds no SQL, changes no public signature, and preserves the measured workload’s executed SQL paths (the workload does not arm notifications). The six-run proof is reused for that bounded correction; three negative-control missed-notification cases and 28 passing focused tests cover the changed cross-API behavior on the final source.Whole-workload operation totals (median [min–max]):
database.domain.binddatabase.domain.closedatabase.domain.executedatabase.domain.publishdatabase.prepareWritepluginState.compareDeletepluginState.compareUpdatepluginState.entriespluginState.observepluginState.sweepdatabase.domain.executeincludes different command/payload shapes. A vectorless shadow publication costs 57 statements; a populated, complete vector shadow costs 61. Each run publishes once. The extra four are the existing sqlite-vec check, vector-table creation, copying vectors, and the completeness marker. The candidate indexes the first session in the shadow, while the base builds vectors later in the canonical DB. Those memory producers are unchanged. The higher mixed SQL/request average is not new overhead for identical inputs; all named operation totals above decline or remain equal.The notifier fix reduces both empty-store reads to one request per service load. Context-engine health counts stay equal or lower:
core:context-engine-quarantine-health/runtime-quarantinesdevice-pair/notify-seen-requestsdevice-pair/notify-subscribersExact per-run statement accounting is below. “Constant SELECTs” covers main key, supervision ownership, TTS path, Mentions head, session generation, and auth catalog reads. Idle notifier counts come from the recorded plugin ID/namespace, at two statements per request. Other SQL is retained in the total and attributed to its existing operation/source in the trace ledger; it is not claimed as a direct constant-cache saving. Per-run rows conserve exactly; independent side medians are not additive.
Final series phase and memory-command detail
database.domain.execute/cache.prunedatabase.domain.execute/cache.readdatabase.domain.execute/cache.stage.startdatabase.domain.execute/cache.writedatabase.domain.execute/database.publishdatabase.domain.execute/matchdatabase.domain.execute/participantdatabase.domain.execute/schema.admitdatabase.domain.execute/session.currentdatabase.domain.execute/source.hashdatabase.domain.execute/source.refreshdatabase.domain.execute/source.replacedatabase.domain.execute/source.statedatabase.domain.execute/stage.appenddatabase.domain.execute/stage.startdatabase.domain.execute/sweepdatabase.domain.publish/claimdatabase.domain.publish/countdatabase.domain.publish/preparedatabase.domain.publish/readdatabase.domain.publish/session.metadata.appenddatabase.domain.publish/session.metadata.initializeThe first-turn median remains 2,207 → 2,306 statements while the entire workload falls 25,291 → 22,433. No first-turn SQL was excluded. The whole-workload operation accounting establishes earlier startup work rather than an added constant-read loop. Unchanged-content
source.refreshreplaces heavier source replacement work; row-dependent staging/cache operations retain their original producers.Failed native executions remain separate from successful-SQL counts: baseline [1,2,0], candidate [0,0,1], all
BEGIN IMMEDIATE: database is lockedin existing plugin/agent lease cleanup. There are no failed prepares. Two boot request-origin mappings remain unresolved on each run, with their requests and SQL included. All native/census statement totals conserve per phase and thread.Original three alternating pairs: constants implementation
The three
M,C,M,C,M,Cpairs compare8b7184988a61with the constants implementation atf4ba3e922ae1. Every run used Node 24.21.0 / SQLite 3.53.4, the same fixed synthetic workload, and successful native executions across MAIN, workers, and helper processes. No SQL was subtracted or moved between phases. All phase duration ratios are ≤1.45.Whole-workload SQL totals were [24,203, 24,044, 22,613] → [22,657, 22,250, 20,994]: medians 24,044 → 22,250 (−1,794). Logical worker requests were [3,592, 3,547, 3,377] → [3,520, 3,480, 3,334]: medians 3,547 → 3,480 (−67). Logical plus admission/control requests had medians 7,149 → 7,028 (−121). These include counted worker callbacks and database-fact exchanges; reply and transfer frames are tracked separately.
The per-operation table below totals startup through shutdown, then takes each side’s median [min–max]. It is not a sum of phase medians.
database.domain.binddatabase.domain.closedatabase.domain.executedatabase.domain.publishdatabase.prepareWritepluginState.compareDeletepluginState.compareUpdatepluginState.entriespluginState.observepluginState.sweepdatabase.domain.executehas median SQL/request 5.876 → 5.986 while total requests fall 144 → 140 and total SQL falls 843 → 838. It mixes operations with different inputs. Each run publishes one memory shadow: 57 SQL statements for a vectorless shadow, or 61 when it already contains vectors. The four additional statements load/check sqlite-vec, create the vector table, copy shadow vectors, and mark them complete. In the candidate, the shadow had already indexed the first session; the base built vectors later in the canonical database. Those producers are byte-identical between the compared heads. Atomic publication was preserved. The first two pairs also replace onesource.replacewith one cheapersource.refresh; the third keeps the same counts. Command/payload mix explains the average per-call difference; identical operation inputs do not gain new work.The
pluginState.entriesincrease exposed unnecessary idle notifier reads. Recorded stacks identify the ten-second pairing scan; the labeled follow-up distinguishes both notifier namespaces from context-engine health. That producer is fixed in7dba5c720cc0, with the fresh pair reported above.Per-phase measurements from the original three pairs:
The warmed total falls 1,164.3 → 1,061.3 (−103) statements, 207.8 → 200.4 (−7.4) logical requests, and 418.2 → 406.6 (−11.6) logical plus admission/control requests per turn. Directly removed SELECT classes are main key 34.1, supervision ownership 21.8, connection generation 15.0, auth catalog 3.2, Mentions head 3.0, and TTS path 1.0 per turn (side medians). Their per-run sum falls by a median 78.1 [77.2–80.4]; generation-tracker setup is separately reduced. Three unchanged Mentions snapshots and one TTS lookup remove exactly four logical requests per warmed turn. Remaining deltas are recorded as changes in other work, not claimed as direct lane savings. Independent medians are not additive.
Successful-SQL counts exclude failed executions. The original pairs recorded baseline [1,0,1] and candidate [0,0,1] failed
BEGIN IMMEDIATEstatements, with zero failed prepares. They occur in existing agent/plugin lease cleanup; shutdown-only counts are baseline [1,0,0], candidate [0,0,0]. Two boot request-to-SQL mappings remain unresolved on each side (workerEnvironments.snapshot,userProfiles.catalog); requests and SQL are included in totals. Native/census conservation is exact per phase/thread/SQL.Correctness, checks, and test cost
Focused owner coverage includes canonical policy/config changes and cold-read races, rollback and publication failure, ownership takeover and lease loss, Mentions FIFO/unknown outcomes/atomic snapshots, TTS write/delete/import and cold-read coalescing, auth table/view absence, and generation changes through writes/triggers/rollback. Negative controls on the base fail for each removed statement class: extra main-key, ownership, generation, auth-catalog and Mentions reads, and the repeated TTS worker request.
The broad focused run had 293 passing tests and 12 failures in 1,331.0 s wall time. Six lane fixture failures were corrected and their affected cases passed; six failures reproduced on the pinned prerequisite and remain inherited: stale-lease alias admission, owner drift with retained workers on/off, retained metadata-version/missing drift, and dangling Workshop-index repair before the injected ownership claim. They are recorded as failures, not passing tests.
The final policy/transport run passed 83/83 tests. The extended stale-snapshot/nested-relay cases and the later mechanical extraction passed 24/24 tests in the existing carrier and session fixtures (15.47 s Vitest, 43.93 s wrapper). Generation passed 6/6 (4.14 s wall); the eight repaired owner cases passed (116.37 s wall including shared worker preparation). Commands use
pnpm test <files> --maxWorkers=1; no new worker pin, serial config, sleep, or process boot was added for the relay cases.Per-file test execution time from the broad focused run is below (imports/shared compiler preparation are included only in the group wall time above). These are local observations, including the failed cases; hosted CI seconds are pending at PR creation. Existing slow native lifecycle suites remain because they exercise real file replacement, ownership, worker cleanup, and migration boundaries. The repaired-case rerun took 4.60 s for ownership, 5.29 s for startup migration, 6.62 s for Inbox scheduling, 0.03 s for the Inbox snapshot case, and 4.79 s for TTS.
src/infra/sqlite-schema-facts.test.tssrc/config/sessions/session-accessor.sqlite-transcript-store.test.tssrc/state/openclaw-state-ownership.test.tssrc/gateway/mention-inbox.test.tssrc/config/sessions/startup-migration.registry-recovery.test.tssrc/agents/auth-profiles.sqlite-store.test.tssrc/config/sessions/session-accessor.sqlite-schema-probes.test.tssrc/agents/auth-profiles.sqlite-read-pool.test.tssrc/config/sessions/session-canonical-key.test.tssrc/config/sessions/session-canonical-reader-continuation.test.tssrc/config/sessions/session-canonical-key-policy.test.tssrc/tts/tts-preferences.worker.test.tssrc/gateway/mention-inbox.worker.test.tssrc/config/sessions/session-accessor.sqlite-entry-revision.test.ts(final run)src/infra/sqlite-database-admission.worker.test.ts(extended cases, full file)Three P2 Codex autoreview rounds completed. The first two were scoped-clean. The third identified only the old index's missing host-completeness marker and explicitly verified the working-tree protocol; committing that complete change resolved the finding. Subsequent deterministic worker testing found a P1 stale-policy race across unrelated DDL: both the delayed read and its next zero-SQL read returned the old key. The bounded data-fact correction fixes that reproduced wrong result; all 68 focused policy, schema, startup and continuation-authority tests pass (169.94 s Vitest, 368.96 s wrapper including shared worker compilation). The new missing-row seed case and extended unrelated-DDL case each took 29 ms; the real worker race took 4.76 s. This P1 correction followed the convergence rule; no fourth P2 review round was run.
pnpm check:changed --base 8b7184988a61: production types, changed-file formatting, admission/SQL worker T1 ratchet, assertion/mock/timeout ratchets and the other pre-type guards pass. The core test graph stops only on five pre-existing missing-birthtimeerrors insession-transcript.worker.schema-freshness.test.ts; the focused type command reproduces the same errors on the pinned base.settleFailedSqliteWorkerJobsexport warning; its baseline failure was reproduced. The assertion baseline total remains 6,847 and T1 call count does not rise.qaRuntimebuild passes. No stored schema/version change is required. The final-head published-driver update cell passed on AWS; see the landing validation below. Hosted CI seconds will be available after PR creation.SDK diff
d58e0290reports 153 reachable-declaration changes, zero public entrypoint additions/removals, and zero public signature changes. The TEMP generation descriptor is an internal contract introduced after the inspected released tags (v2026.9.9,v2026.10.1-beta.2). Theviewsfield extends host-produced catalog facts; the admission key's optional host-writer marker and optional transferred completeness revision stay internal.sqlite-worker-runtimeis private-local-only. Later changes affect private cache descriptors, an existing function body, tests and documentation; the explicit public signatures and exported SDK types are unchanged, so this API proof remains applicable.The final notifier and CAS suites pass 28/28 in 56.94 s (
pnpm test extensions/device-pair/notify.test.ts extensions/device-pair/notify-cas.test.ts --maxWorkers=1). The original code fails both idle-budget regressions on actual extra store reads; the intermediate API-local cache fails three missed-notification cases when another agent API arms the same store. The final shared revision covers both cases, lost commit replies, restart recovery, and existing delivery authority/receipts. The final source and its supporting registry/module-identity context received a scoped-clean P0/P1 Codex review.Follow-up
pnpm check:changed --base f4ba3e922ae1passes both extension type graphs, formatting, plugin boundaries, and structural/SQL-worker ratchets. It stops only on the same untouched production export warning,settleFailedSqliteWorkerJobs; Knip’s full-tree and script scans report zero unused entries. The remaining planned commands were run separately and pass: type-aware lint of both changed extension files, database-first storage, media helpers, runtime sidecar loaders, and import-cycle checks (zero runtime value cycles). No T1 growth or SDK/public signature change is introduced by the private notifier follow-up. The earlier SDK diff and unchanged core-owner proof are reused. Hosted CI timing remains pending.Writer coverage and remaining boundaries
session_key_contract.main_key: startup/config maintenance and Doctor canonical-key repair usesetCanonicalSqliteSessionMainKey; its final commit publishes the replacement and revokes affected continuations.gateway.supervision:claimOwnershipRowis the sole SQL producer, including malformed-ownership repair. The ownership claim publishes after commit; lease loss stays a live owner event/check.tts.prefsPath: the legacy machine-state migration is the production key producer. Generic upsert, update/delete, delete, and import operations publish this named key. Other machine-state keys retain their existing owners.writeMentionStoreChangesis the sole SQL producer, reached through the worker mutation and the released synchronous SDK adapter in the same process. The adapter remains for its released contract.The ownership-claim follow-up is resolved by the offline claim enforcement described above. Remaining single-owner follow-ups: route or fence Doctor's canonical-key repair and legacy config/TTS migrations through the Gateway or require it to be stopped. No out-of-process Mentions writer was found.
The existing session cache
data_versioncomponent remains because it also detects our own sibling-connection writes. Current entry publication updates host handles but does not cover every retained worker-isolate cache. Removing that component safely requires complete process-widesession_nodes/session_participantsmutation receipts for all those consumers; this lane removes the separate connection-local generation SELECT and adds no freshness probe.The device-pair notifier is the sole production writer of its subscriber and seen-request namespaces. Agent-specific inbound registries can use distinct API objects while the Gateway notifier remains active. The bundled module shares write invalidation across those APIs; each API retains only its observed empty revision, and service startup advances the shared revision. No generic plugin-state cache or foreign-process polling was added.
The final cross-registry correction has its own P0/P1 Codex review, scoped-clean. Negative control at
7dba5c720cc0produces three expected missed-notification failures; the fixed notifier/CAS suite passes 28/28 in 56.94 s. The final source-mapped build atd2b39426fc5fpasses in 55.4 s. The final affected check plan passes with the unchanged export scan and SDK/Kysely artifact preparation reused (OPENCLAW_CHECK_CHANGED_SKIP_DEADCODE=1 OPENCLAW_OXLINT_SKIP_PREPARE=1 pnpm check:changed --base 7dba5c720cc0); current-source extension types, type-aware lint, formatting, ratchets, boundaries, and import-cycle guards still run. The earlier full Knip result—including the inherited production warning—and public SDK proof remain recorded above. No further P2 review round was added.Landing validation
The lander restored two stale auth-staging error expectations at
a83d81d8be926; all four focused cases passed, and a fix-only P0/P1 review was clean. The final-head package build, tarball integrity check, and published-driver update cell passed on AWS (965.1 seconds for the full remote command; 394.5 seconds for the update). The coordinator’s 542-test Testbox and lifecycle proof is reused for unchanged product code.CI run 38063661702 remains red only for two independently qualified inherited failures: the unchanged worker-placement evidence case fails identically in main run 38059964113, and the unchanged sandbox ownership snapshot case independently reproduces on clean main because Bun creates cache files under its synthetic HOME. Landing uses the explicitly approved native inherited-failure admin route; this does not claim green CI.