Skip to content

improve: reduce repeated SQLite work during chat turns - #168002

Merged
steipete merged 53 commits into
mainfrom
dbasync/w10constants
Oct 10, 2026
Merged

steipete merged 53 commits into
mainfrom
dbasync/w10constants

Conversation

@steipete

@steipete steipete commented Oct 9, 2026 •

Copy link
Copy Markdown
Contributor

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 pinned 8b7184988a61 revision; the ownership correction below integrates parent a12c2b8a9e63 and pinned main db776fa6a762, then resolves the admission conflict against parent 57ffc8f51c8e. The final integration of main 4ea40f2b890e reconciles 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: published 2026.9.9 updated 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 claim is 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 main db776fa6a762 at 1df1986eb403. The ownership fixes are 9b216ca017d0 and 934fe269c6f6; both received scoped-clean Codex P0/P1 reviews. The later parent conflict is resolved at 026db9d992fe6, and duplicate tracker tests are reconciled with the parent TEMP suite at 803a68cd7e84d; 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-once a12c2b8a9e63 and the same pinned main, excluding this lane) versus candidate 934fe269c6f6. 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.

Phase Base SQL Candidate SQL Base MAIN Candidate MAIN Base requests Candidate requests Duration ratio
01.boot 2278 [2278–2278] 2202 [2202–2202] 1951 [1951–1951] 1925 [1925–1925] 61 [61–61] 60 [60–60] 0.889
01.connect 896 [896–896] 132 [132–132] 35 [35–35] 5 [5–5] 26 [26–26] 16 [16–16] 1.068
02.first-turn 2702 [2702–2702] 2898 [2898–2898] 173 [173–173] 160 [160–160] 362 [362–362] 325 [325–325] 1.140
03.warmed-per-turn 1058.1 [1058.1–1058.1] 1011.1 [1011.1–1011.1] 13.7 [13.7–13.7] 11.4 [11.4–11.4] 207.6 [207.6–207.6] 200.1 [200.1–200.1] 0.774
04.second-session 4420 [4420–4420] 3963 [3963–3963] 157 [157–157] 150 [150–150] 745 [745–745] 745 [745–745] 1.002
05.control-plane 28 [28–28] 21 [21–21] 0 [0–0] 0 [0–0] 5 [5–5] 3 [3–3] 0.767
06.cron 1169 [1169–1169] 1079 [1079–1079] 45 [45–45] 19 [19–19] 183 [183–183] 187 [187–187] 1.317
07.compaction 511 [511–511] 388 [388–388] 46 [46–46] 25 [25–25] 100 [100–100] 82 [82–82] 0.948
08.shutdown 157 [157–157] 134 [134–134] 90 [90–90] 78 [78–78] 15 [15–15] 14 [14–14] 1.766
done 0 [0–0] 0 [0–0] 0 [0–0] 0 [0–0] 0 [0–0] 0 [0–0] 1.900

Whole workload, startup through shutdown:

Metric Base Candidate Delta
All-thread SQL 22742 [22742–22742] 20928 [20928–20928] -1814
MAIN SQL 2634 [2634–2634] 2476 [2476–2476] -158
Logical worker requests 3573 [3573–3573] 3433 [3433–3433] -140
Requests including admission/control 7128 [7128–7128] 6912 [6912–6912] -216
Seconds 118.29 [118.29–118.29] 113.27 [113.27–113.27] -5.02

Entire-workload operation totals for this sanity pair:

Operation Base requests Candidate requests Base SQL Candidate SQL
database.domain.bind 108 [108–108] 95 [95–95] 642 [642–642] 549 [549–549]
database.domain.close 108 [108–108] 95 [95–95] 320 [320–320] 268 [268–268]
database.domain.execute 146 [146–146] 131 [131–131] 842 [842–842] 808 [808–808]
database.domain.publish 93 [93–93] 93 [93–93] 1583 [1583–1583] 1519 [1519–1519]
database.prepareWrite 22 [22–22] 24 [24–24] 761 [761–761] 834 [834–834]
pluginState.compareDelete 42 [42–42] 38 [38–38] 273 [273–273] 209 [209–209]
pluginState.compareUpdate 21 [21–21] 19 [19–19] 189 [189–189] 152 [152–152]
pluginState.entries 16 [16–16] 4 [4–4] 32 [32–32] 8 [8–8]
pluginState.observe 21 [21–21] 19 [19–19] 126 [126–126] 95 [95–95]
pluginState.sweep 2 [2–2] 2 [2–2] 12 [12–12] 10 [10–10]

Warmed 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.prepareWrite increases 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 failed BEGIN diagnostics 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 803a68cd7e84d passes 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.

Final focused command (pnpm test … --maxWorkers=1) Tests Wrapper wall seconds
src/infra/sqlite-schema-facts.temp.test.ts 17 6.16
src/infra/sqlite-schema-facts.test.ts + src/infra/sqlite-database-admission.worker.test.ts 60 70.87
src/cli/database-ownership.process.test.ts 3 43.51
src/cli/local-state-owner.test.ts 1 19.20
src/config/sessions/session-accessor.sqlite-entry-revision.test.ts 6 2.86

pnpm install --frozen-lockfile passes. Madge reports zero cycles (20.58 s). File-scoped check:changed stops at two file-size ratchet findings: sqlite-database-admission.ts has 701 counted lines and sqlite-schema-facts.ts has 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-birthtime type 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 head 803a68cd7e84d; no fresh final-merge full production scan is claimed.

The attempted comparison scan at main cdeb1e37adc6e also exited 1, but it is not claimed as an exact reproduction: the newer checkout lacked the linked @openclaw/libterminal dependency, and reported different unused dependency/export entries (@modelcontextprotocol/core, isPollVoteEchoText, and PUBLIC_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 (main 4ea40f2b890e); its fresh Codex P0/P1 review is scoped-clean. It preserves all resolved lane production files byte-for-byte from tested head 803a68cd7e84d. In files shared with the lane, main adds unrelated MCP/models fixture dispatch and the verify-preservation CLI 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 on 803a68cd7e84d, 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 0856728ac4569 before 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. Only claimOpenClawStateOwnership gains 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:

Proof Result Wall seconds
Same pre-park lifecycle selection 7/7 pass, including all six original failures 181.66 wrapper
State ownership + general owner suites 55/55 pass 84.06 Vitest
Final CLI/direct claim process file 4/4 pass 50.23 wrapper
Production typecheck pass 28.76
Canonically selected affected test graphs all 27 pass 691.80
Final CLI type graph after assertion corrections pass 3.81

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-maintenance role rather than the CLI's agent-embedded role. 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 --check pass. 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 at d2b39426fc5f shares 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.

Metric Base Candidate Delta
All-thread statements 25291 [22763–25430] 22433 [21542–22449] -2858
MAIN statements 2714 [2522–2877] 2539 [2494–2774] -175
Logical worker requests 3691 [3406–3703] 3457 [3415–3541] -234
Logical + admission/control requests 7459 [6746–7630] 7032 [6831–7068] -427
Wall seconds 139.241 [62.429–147.698] 134.67 [117.103–170.949] -4.571

Whole-workload operation totals (median [min–max]):

Operation Base requests Candidate requests Base SQL Candidate SQL
database.domain.bind 112 [88–122] 99 [95–105] 668 [501–743] 580 [550–618]
database.domain.close 112 [88–122] 99 [95–105] 332 [240–376] 284 [268–304]
database.domain.execute 156 [120–170] 133 [129–143] 907 [759–941] 791 [789–853]
database.domain.publish 93 [93–93] 93 [93–93] 1634 [1633–1635] 1573 [1572–1576]
database.prepareWrite 42 [13–47] 17 [14–33] 1459 [447–1632] 587 [484–1148]
pluginState.compareDelete 46 [34–50] 38 [38–42] 299 [221–325] 209 [209–231]
pluginState.compareUpdate 23 [17–25] 19 [19–21] 207 [153–225] 152 [152–168]
pluginState.entries 22 [10–25] 5 [4–5] 44 [20–50] 10 [8–10]
pluginState.observe 23 [17–25] 19 [19–21] 138 [102–150] 95 [95–105]
pluginState.sweep 2 [1–2] 2 [2–2] 12 [6–12] 10 [10–10]

database.domain.execute includes 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:

Namespace Base requests Candidate requests
core:context-engine-quarantine-health/runtime-quarantines 3 [2–4] 3 [2–3]
device-pair/notify-seen-requests 9 [4–11] 1 [1–1]
device-pair/notify-subscribers 9 [4–11] 1 [1–1]

Exact 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.

Pair Total SQL delta Constant SELECTs Tracker setup Mentions snapshot Idle notifier SQL Other SQL
1 -1221 -1467 -16 +0 -12 +274
2 -2981 -1569 -46 +0 -40 -1326
3 -2858 -1574 -28 +0 -32 -1224
Final series phase and memory-command detail
Phase Base SQL Candidate SQL Base MAIN Candidate MAIN Base requests Candidate requests Duration ratio
01.boot 3278 [3276–3306] 3206 [3186–3208] 2014 [1997–2016] 1986 [1986–1986] 69 [67–70] 68 [68–68] 1.319
01.connect 293 [247–881] 253 [218–278] 33 [31–95] 44 [20–45] 44 [38–96] 38 [35–40] 1.903
02.first-turn 2207 [1481–2230] 2306 [2229–2503] 108 [25–113] 96 [94–127] 304 [243–316] 342 [336–345] 1.690
03.warmed-per-turn 1264.4 [1076.3–1303.1] 1026.1 [1009.4–1059.8] 20.8 [9–21.5] 12.2 [11.4–13.1] 216.3 [198.3–221.4] 199.9 [196.4–200.2] 0.977
04.second-session 4410 [4307–4447] 4055 [4019–4274] 132 [130–134] 137 [129–143] 724 [699–734] 728 [692–749] 0.878
05.control-plane 135 [32–255] 21 [20–21] 0 [0–22] 0 [0–0] 28 [5–44] 3 [3–3] 0.877
06.cron 1478 [1179–1782] 1318 [1118–1630] 63 [30–288] 41 [19–276] 221 [171–253] 213 [179–245] 1.423
07.compaction 413 [408–534] 402 [392–414] 26 [25–46] 25 [24–25] 83 [83–102] 82 [81–84] 1.219
08.shutdown 154 [151–162] 137 [126–137] 87 [87–98] 81 [75–81] 15 [15–16] 15 [15–16] 0.661
done 0 [0–0] 0 [0–0] 0 [0–0] 0 [0–0] 0 [0–0] 0 [0–0] 1.700
Operation Base requests Candidate requests Base SQL Candidate SQL
database.domain.execute/cache.prune 12 [8–14] 11 [9–11] 12 [8–14] 11 [9–11]
database.domain.execute/cache.read 11 [8–12] 9 [9–10] 11 [8–12] 9 [9–10]
database.domain.execute/cache.stage.start 11 [8–12] 9 [9–10] 0 [0–0] 0 [0–0]
database.domain.execute/cache.write 11 [8–12] 9 [9–10] 145 [106–156] 119 [118–132]
database.domain.execute/database.publish 1 [1–1] 1 [1–1] 57 [57–57] 61 [61–61]
database.domain.execute/match 14 [14–15] 14 [14–15] 84 [84–90] 84 [84–90]
database.domain.execute/participant 13 [13–13] 13 [13–13] 112 [112–112] 112 [112–112]
database.domain.execute/schema.admit 1 [1–1] 1 [1–1] 131 [131–131] 131 [131–131]
database.domain.execute/session.current 11 [8–12] 9 [9–10] 11 [8–12] 9 [9–10]
database.domain.execute/source.hash 12 [9–14] 10 [10–11] 12 [9–14] 10 [10–11]
database.domain.execute/source.refresh 1 [1–2] 2 [2–2] 6 [6–12] 12 [12–12]
database.domain.execute/source.replace 11 [8–12] 8 [8–9] 273 [195–289] 196 [196–230]
database.domain.execute/source.state 12 [8–14] 11 [9–11] 12 [8–14] 11 [9–11]
database.domain.execute/stage.append 22 [16–24] 17 [17–19] 29 [22–30] 23 [22–27]
database.domain.execute/stage.start 11 [8–12] 8 [8–9] 0 [0–0] 0 [0–0]
database.domain.execute/sweep 1 [1–1] 1 [1–1] 5 [5–5] 5 [5–5]
database.domain.publish/claim 14 [14–14] 14 [14–14] 70 [70–70] 70 [70–70]
database.domain.publish/count 13 [13–13] 13 [13–13] 65 [65–65] 65 [65–65]
database.domain.publish/prepare 13 [13–13] 13 [13–13] 90 [90–90] 78 [78–78]
database.domain.publish/read 2 [2–2] 2 [2–2] 4 [4–4] 4 [4–4]
database.domain.publish/session.metadata.append 49 [49–49] 49 [49–49] 1394 [1393–1395] 1346 [1345–1348]
database.domain.publish/session.metadata.initialize 2 [2–2] 2 [2–2] 11 [11–11] 10 [10–11]

The 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.refresh replaces 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 locked in 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,C pairs compare 8b7184988a61 with the constants implementation at f4ba3e922ae1. 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.

Operation Base requests Candidate requests Base statements Candidate statements
database.domain.bind 104 [83–109] 102 [86–109] 616 [465–650] 599 [485–650]
database.domain.close 104 [83–109] 102 [86–109] 304 [220–324] 296 [232–324]
database.domain.execute 144 [111–153] 140 [116–151] 843 [712–899] 838 [747–878]
database.domain.publish 93 [93–93] 93 [93–93] 1634 [1633–1636] 1572 [1571–1576]
database.prepareWrite 29 [15–30] 26 [9–32] 1004 [518–1040] 900 [309–1109]
pluginState.compareDelete 42 [30–46] 42 [34–46] 273 [195–299] 231 [187–253]
pluginState.compareUpdate 21 [15–23] 21 [17–23] 189 [135–207] 168 [136–184]
pluginState.entries 14 [11–18] 17 [10–20] 28 [22–36] 34 [20–40]
pluginState.observe 21 [15–23] 21 [17–23] 126 [90–138] 105 [85–115]
pluginState.sweep 2 [1–2] 2 [1–2] 12 [6–12] 10 [5–10]

database.domain.execute has 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 one source.replace with one cheaper source.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.entries increase 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 in 7dba5c720cc0, with the fresh pair reported above.

Per-phase measurements from the original three pairs:

Phase Base all-thread Candidate all-thread Base MAIN Candidate MAIN Base requests Candidate requests Duration ratio
01.boot 3289.0 [3274.0–3292.0] 3204.0 [3202.0–3219.0] 2016.0 [2014.0–2016.0] 1986.0 [1986.0–1986.0] 69.0 [67.0–69.0] 68.0 [68.0–71.0] 1.25
01.connect 380.0 [312.0–924.0] 241.0 [232.0–271.0] 81.0 [55.0–102.0] 44.0 [30.0–45.0] 43.0 [37.0–90.0] 38.0 [35.0–38.0] 0.85
02.first-turn 2097.0 [1531.0–2223.0] 2431.0 [2416.0–2435.0] 53.0 [37.0–82.0] 99.0 [95.0–114.0] 300.0 [250.0–313.0] 349.0 [345.0–365.0] 1.45
03.warmed-per-turn 1164.3 [1118.2–1208.9] 1061.3 [967.1–1114.3] 14.1 [11.2–15.9] 11.4 [6.6–16.2] 207.8 [203.3–212.0] 200.4 [191.0–208.1] 0.92
04.second-session 4114.0 [3891.0–4477.0] 3986.0 [3578.0–4032.0] 141.0 [102.0–197.0] 129.0 [97.0–148.0] 705.0 [658.0–713.0] 719.0 [643.0–731.0] 0.88
05.control-plane 245.0 [28.0–271.0] 52.0 [22.0–165.0] 8.0 [0.0–10.0] 2.0 [0.0–14.0] 43.0 [5.0–48.0] 9.0 [3.0–29.0] 0.77
06.cron 1280.0 [1186.0–1354.0] 1101.0 [1083.0–1177.0] 30.0 [17.0–55.0] 19.0 [19.0–42.0] 191.0 [173.0–203.0] 179.0 [170.0–185.0] 1.20
07.compaction 431.0 [423.0–468.0] 412.0 [395.0–415.0] 33.0 [25.0–49.0] 25.0 [24.0–25.0] 87.0 [84.0–92.0] 84.0 [81.0–84.0] 1.18
08.shutdown 154.0 [148.0–154.0] 137.0 [131.0–137.0] 87.0 [84.0–90.0] 81.0 [78.0–81.0] 15.0 [15.0–15.0] 15.0 [15.0–15.0] 0.31
done 0.0 [0.0–0.0] 0.0 [0.0–0.0] 0.0 [0.0–0.0] 0.0 [0.0–0.0] 0.0 [0.0–0.0] 0.0 [0.0–0.0] 0.90

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 IMMEDIATE statements, 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.

Test file Local test seconds
src/infra/sqlite-schema-facts.test.ts 0.88
src/config/sessions/session-accessor.sqlite-transcript-store.test.ts 17.31
src/state/openclaw-state-ownership.test.ts 216.97
src/gateway/mention-inbox.test.ts 323.31
src/config/sessions/startup-migration.registry-recovery.test.ts 114.63
src/agents/auth-profiles.sqlite-store.test.ts 45.21
src/config/sessions/session-accessor.sqlite-schema-probes.test.ts 14.91
src/agents/auth-profiles.sqlite-read-pool.test.ts 22.89
src/config/sessions/session-canonical-key.test.ts 17.27
src/config/sessions/session-canonical-reader-continuation.test.ts 11.73
src/config/sessions/session-canonical-key-policy.test.ts 0.31
src/tts/tts-preferences.worker.test.ts 6.61
src/gateway/mention-inbox.worker.test.ts 0.09
src/config/sessions/session-accessor.sqlite-entry-revision.test.ts (final run) 0.19
src/infra/sqlite-database-admission.worker.test.ts (extended cases, full file) 5.59

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-birthtime errors in session-transcript.worker.schema-freshness.test.ts; the focused type command reproduces the same errors on the pinned base.
  • Native focused core lint passes for every changed core file. Supplemental full core lint reported 15 pre-existing file-size violations in unchanged files (identical base blobs/config); the four lane lint findings were fixed and the changed scope rechecked. Script lint and all remaining planned structural checks pass.
  • Madge/import-cycle checks pass. Knip full-tree/all-exports and script scans report zero unused entries. The production scan retains the base's test-used settleFailedSqliteWorkerJobs export warning; its baseline failure was reproduced. The assertion baseline total remains 6,847 and T1 call count does not rise.
  • Source-mapped qaRuntime build 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 d58e0290 reports 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). The views field extends host-produced catalog facts; the admission key's optional host-writer marker and optional transferred completeness revision stay internal. sqlite-worker-runtime is 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 f4ba3e922ae1 passes 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 use setCanonicalSqliteSessionMainKey; its final commit publishes the replacement and revokes affected continuations.
  • gateway.supervision: claimOwnershipRow is 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.
  • Mentions head/source keys: writeMentionStoreChanges is 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.
  • Session generations: exact session-node/participant triggers cover connection-local mutation; raw/native rollback invalidates abandoned tokens. Auth catalog changes remain with schema migration/repair admission.

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_version component 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-wide session_nodes/session_participants mutation 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 7dba5c720cc0 produces three expected missed-notification failures; the fixed notifier/CAS suite passes 28/28 in 56.94 s. The final source-mapped build at d2b39426fc5f passes 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.

…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.
@clawsweeper

clawsweeper Bot commented Oct 9, 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 gateway Gateway runtime agents Agent runtime and tooling extensions: device-pair labels Oct 9, 2026
@clawsweeper clawsweeper Bot removed the rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. label Oct 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Fixed in c9543f26c4feba159228a18ee679ddde91c3b1ba.

The remaining failures were test-contract issues:

  • Cron: fix(cron): keep unroutable reports out of execution errors #168380 keeps successful agent execution ok when delivery is refused. The regression now checks deliveryError, deliveryState.status === "not-delivered", delivered === false, and no Telegram send or main-session event.
  • Startup ownership: the fixture wrote gateway.supervision with raw SQL, bypassing the owner publication required by SINGLE OWNER. It now invokes the real claim operation. The cached-handle hook also runs before its native observer, so it models a committed owner event instead of a reentrant native callback. Both cases verify refusal and no lease/checkpoint writes.

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.

Proof Before After
Cron shard: 33 files / 315 tests 1 failure 315 passed
Infrastructure shard: 14 files / 227 tests 2 failures 227 passed
Ownership, pairing, CLI claim, physical-identity suites — 100 passed

Scoped infrastructure/cron typechecks, changed-file lint, formatting, ratchets (no T1 growth), and fresh Codex P0/P1 review passed. check-changed stops on four inherited unused exports, reproduced on main d7f014ae5dea9: the default export in tools/solid-lint/index.mjs, POST_ACTIVATION_INSPECTIONS_STEP, resolveSessionConversationStub, and resolveSessionTargetStub. All three affected files are untouched by this PR.

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.

@clawsweeper clawsweeper Bot removed the merge-risk: 🚨 automation 🚨 May affect CI, automerge, proof capture, label sync, or maintainer automation. label Oct 10, 2026
@steipete

Copy link
Copy Markdown
Contributor Author

Integrated main 7635272538044 (including noprobe #167965 / 1d76f57d4be51) in edcc42a6f8600. Final fixture repair: f0dd897dfb272.

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:

Proof Result Vitest wall time
Exact CI cron shard, selected files and order, Linux Node 24.19.0 33 files / 315 tests passed 117.55s
Exact CI infrastructure shard, selected files and order, Linux Node 24.19.0 14 files / 227 tests passed 40.11s
Six lifecycle cases plus preparing sibling 7 passed 234.19s
Final schema-facts fixture rerun, one worker 49 passed 2.40s (3.44s runner)
Session entry revision 7 passed 6.16s

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: sqlite-database-admission.ts 757 lines and sqlite-schema-facts.ts 708, against 700. These are recorded under the campaign's explicit LOC-is-not-a-gate decision; no lint suppression or extra production refactor was added. The typecheck wrapper's unrelated UI root-budget check reports 722 roots against 720; its inputs are unchanged from integrated main, and the four scoped compiler commands passed directly.

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.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. and removed rating: 🦐 gold shrimp Decent PR readiness signal, but merge confidence is limited. labels Oct 10, 2026
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.
@steipete
steipete merged commit 7517981 into main Oct 10, 2026
207 of 214 checks passed
@steipete
steipete deleted the dbasync/w10constants branch October 10, 2026 16:33
@steipete

Copy link
Copy Markdown
Contributor Author

Merged via explicitly authorized admin squash with attributed pre-existing CI failures.

steipete added a commit that referenced this pull request Oct 10, 2026
7517981 (#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.
steipete added a commit that referenced this pull request Oct 10, 2026
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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
* 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.
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 11, 2026
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.
steipete added a commit that referenced this pull request Oct 11, 2026
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.
steipete added a commit that referenced this pull request Oct 11, 2026
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.
steipete added a commit that referenced this pull request Oct 11, 2026
…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
github-actions Bot pushed a commit to Desicool/openclaw that referenced this pull request Oct 12, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

agents Agent runtime and tooling cli CLI command changes docs Improvements or additions to documentation extensions: device-pair gateway Gateway runtime merge-risk: 🚨 security-boundary 🚨 May affect sandboxing, authorization, credentials, or sensitive data. P2 Normal backlog priority with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. security-sensitive-changed size: XL status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant