Repository navigation
fix(sqlite): avoid repeated validation after session tracker setup - #166698
Conversation
Keep first-use session generation tracking from revoking shared schema admission. Install typed TEMP counter and trigger definitions through the existing schema observer, verify any existing matching names, and retain ordinary revocation for drift, reentrant DDL, and partial batches. No persistent schema, stored bytes, or update behavior changes.
Bind the preserved native method to the fixture database before injecting reentrant DDL, keeping the callback receiver explicit.
|
🦞👀 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. |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Codex review: blocked before merge. Reviewed October 7, 2026, 3:24 PM ET / 19:24 UTC (Revision 4). ClawSweeper reviewWhat this changesThe PR preserves SQLite validation when installing the session cache’s temporary change counter and triggers, with regression coverage, documentation, and wrapper packaging updates. Warning SQLite table change This PR modifies persisted SQLite tables in Merge readiness⛔ Blocked before merge - 1 item remains This PR remains useful: current main still revokes schema admission during first-use tracker setup. No introduced correctness or security defect was found, and the runtime evidence supports the focused repair without an additional review blocker. Priority: P2 Review scores
Verification
How this fits togetherSession caches use SQLite change counters to detect stale session data. The database schema owner installs those counters and controls whether validated database facts can be reused or must be checked again. flowchart TD
A[Session reads and maintenance] --> B[Session change tracker]
B --> C[SQLite schema owner]
C --> D{Declared TEMP shapes match?}
D -->|Yes| E[Preserve validation receipt]
D -->|No or installation fails| F[Revoke validation receipt]
E --> G[Reuse admitted database facts]
F --> H[Readmit database schema]
Before merge
Agent review detailsSecurityNone. PR surfaceSource +100, Tests +87, Docs +4, Other +1. Total +192 across 7 files. View PR surface stats
Review metrics
Stored data modelPersistent data-model change detected: Technical reviewBest possible solution: Keep lazy tracker installation under the existing schema owner, preserving admission only for verified TEMP shapes while retaining invalidation for real schema changes and failures. Do we have a high-confidence way to reproduce the issue? Yes, source establishes the path: first-use session tracking executes TEMP DDL through the ordinary schema observer and revokes admission on current main. The submitted baseline regression and native traces corroborate it; this review did not execute the path. Is this the best way to solve the issue? Yes, the patch gives the existing schema owner a narrow typed installation path instead of suppressing DDL observation broadly or introducing another validation owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against cbfbdc8ddb95. LabelsLabel changes: No label changes. Label justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
History |
|
@clawsweeper re-review |
|
🦞👀 Re-review progress:
|
|
Merged via squash.
|
Merge main at e1dbb59 after #166698 landed. Keep the selected session execution and foreground fact implementation, and its freshness-fixture correction, unchanged while incorporating the canonical TEMP generation admission fix. The integration required no conflict resolution or additional product changes. Fresh P2 review is clean; affected checks and alternating statement measurements remain required before landing.
* fix(sqlite): preserve admission during transcript tracker setup Extend the checked TEMP tracking owner introduced in #166698 to the fixed transcript-index status table, pending queue, index and enqueue triggers. Installing these connection-local objects must not revoke the agent database's main-schema admission receipt. Ordinary DDL, unexpected object shapes, reentrant mutations and partial installation failures still revoke it. Move the existing SQL into the typed builder and migrate both tracking callers to its shared operation. Preserve local read revisions, rollback staging and INSERT OR REPLACE behavior. No persisted schema, stored bytes, migration, public SDK contract, retry or timeout changes. The existing status-owner regression fails on the parent at first tracker installation. All six owner cases pass after the repair (1.78s invocation), including drift, rollback, foreign writes and bounded cleanup. P2 review is clean. The broader restart investigation and Linux gates remain recorded in the task evidence; this commit alone is not a claim that the QA race is fixed. * fix(state): retain valid admission across concurrent opens A startup reader can publish canonical proof before native admission starts. A concurrent fully checked host open then registered the same database by revoking that proof, rejecting the pending native receipt and failing the post-restart turn before a provider request could begin. Publish the checked opener's registration through the validation owner and promote live proof without retiring its pending handoff. Keep physical-file replacement and explicit lifecycle revocation strict. Reject stale required schema receipts before they can replace newer facts, and retain the shared schema revocation cell for matching live schemas. Accepted schema changes and schema-optional revocation reports retire the displaced borrowers. Regressions cover canonical and empty promotion, physical replacement, revocation, delayed publication, and borrowed-schema retirement. All 36 receipt-owner cases pass (30.60s Vitest, 34.03s wrapper); the corresponding negative controls failed before their repairs. P2 review is clean. Linux pressure, owner-suite, and static gates are tracked separately before landing. No stored data, schema version, public SDK, retry, or timeout changes.
…penclaw#166698) * fix(sqlite): retain admission during generation tracker setup Keep first-use session generation tracking from revoking shared schema admission. Install typed TEMP counter and trigger definitions through the existing schema observer, verify any existing matching names, and retain ordinary revocation for drift, reentrant DDL, and partial batches. No persistent schema, stored bytes, or update behavior changes. * test(sqlite): bind native exec in DDL observation proof Bind the preserved native method to the fixture database before injecting reentrant DDL, keeping the callback receiver explicit. * fix(tooling): include TEMP generation schema in PR wrappers
) * fix(sqlite): preserve admission during transcript tracker setup Extend the checked TEMP tracking owner introduced in openclaw#166698 to the fixed transcript-index status table, pending queue, index and enqueue triggers. Installing these connection-local objects must not revoke the agent database's main-schema admission receipt. Ordinary DDL, unexpected object shapes, reentrant mutations and partial installation failures still revoke it. Move the existing SQL into the typed builder and migrate both tracking callers to its shared operation. Preserve local read revisions, rollback staging and INSERT OR REPLACE behavior. No persisted schema, stored bytes, migration, public SDK contract, retry or timeout changes. The existing status-owner regression fails on the parent at first tracker installation. All six owner cases pass after the repair (1.78s invocation), including drift, rollback, foreign writes and bounded cleanup. P2 review is clean. The broader restart investigation and Linux gates remain recorded in the task evidence; this commit alone is not a claim that the QA race is fixed. * fix(state): retain valid admission across concurrent opens A startup reader can publish canonical proof before native admission starts. A concurrent fully checked host open then registered the same database by revoking that proof, rejecting the pending native receipt and failing the post-restart turn before a provider request could begin. Publish the checked opener's registration through the validation owner and promote live proof without retiring its pending handoff. Keep physical-file replacement and explicit lifecycle revocation strict. Reject stale required schema receipts before they can replace newer facts, and retain the shared schema revocation cell for matching live schemas. Accepted schema changes and schema-optional revocation reports retire the displaced borrowers. Regressions cover canonical and empty promotion, physical replacement, revocation, delayed publication, and borrowed-schema retirement. All 36 receipt-owner cases pass (30.60s Vitest, 34.03s wrapper); the corresponding negative controls failed before their repairs. P2 review is clean. Linux pressure, owner-suite, and static gates are tracked separately before landing. No stored data, schema version, public SDK, retry, or timeout changes.
What Problem This Solves
Fixes redundant schema validation after the session generation tracker initializes on an already-admitted SQLite connection.
User Impact
Cold session operations and maintenance avoid unnecessary schema work. After integration, first-turn ALL-thread statements drop by 174, warmed turns by 1.0, and focused maintenance by 173. Durable schemas, stored data, retention, permissions, and update behavior are unchanged; no migration or operator action is required.
Approved correctness exception: compaction increases by 38 statements because the candidate performs required readmission after real memory DDL. Baseline main currently skips that validation because of a preexisting host/worker schema-receipt handoff gap. The coordinator explicitly approved preserving these checks over meeting the statement estimate. The raw increase remains visible below; it is not labeled a passing numeric gate or subtracted from the measurements.
Why This Change Was Made
The tracker's connection-local TEMP DDL was revoking the schema receipt, forcing later operations to rebuild expected schema and repeat admission. The tracker now declares its counter and typed INSERT/UPDATE/DELETE triggers to the existing schema owner. That owner generates the fixed definitions and checks existing TEMP objects by name, type, target table, and normalized SQL before preserving the receipt.
Initialization stays lazy, avoiding tracker creation on connections that never need it. Unexpected TEMP/main DDL, wrong-shaped same-named objects, reentrant DDL, and partial installation failures still revoke admission. Execution and revocation remain with the existing schema observer.
Follow-up: repair schema receipt publication/adoption across host and worker replacements. Republishing a host receipt must not leave a retained worker invalidating an older validity cell. That owner-level repair needs a regression proving shared revocation across republishing.
Evidence
The real agent-database regression fails on baseline with 28 catalog inspections after first-use tracking and passes on the candidate with zero, while the original receipt remains valid. Negative cases cover ordinary TEMP/main DDL, tracker tampering, mismatched existing tables/triggers, reentrant DDL, and partial installation failure. Existing tests also cover matching reinstall, raw DML generation increments, rollback, foreign commits, and admission lifetime.
Pre-integration statement measurements and approved attribution
Counts are successful native SQL executions. MAIN is the main-thread count; ALL includes every worker and background thread. Nothing is subtracted. Values are side medians across alternating baseline/candidate pairs; warmed values are ten-turn means. All gated duration ratios are below 1.5.
Three fixed pairs ran on one dedicated AWS Linux host with Node 24.21.0, separate frozen source-mapped builds, and 99.69–100% CPU idleness before each run. All six functional workloads completed, and classification conserved every successful statement.
The first-turn and warmed gates pass strictly; no noise-floor qualification is used. Second-session +1 comes from unchanged session/participant timer reads and RPC timing. Cron +4 comes from existing audit retry/timeout controls and state-cache admission reads.
The real focused maintenance workload, including managed backdate/recheck assertions, ran in three local alternating pairs. Every statement count was identical across all three runs per side:
Maintenance drops 173 statements (16.89%), with no phase increase. On this baseline, redundant readmission occurs in foreign cadence; managed backdate and recheck remain unchanged. The new one-time TEMP shape inspection is counted, and no TEMP shape inspections occur in warmed turn windows.
Why compaction adds 38
Tracker DDL/DML spelling and qualification changes have zero net statement count. The retained primary writer shows the same sequence in every pair. Pair 1's native trace is:
All three baseline runs also execute 133 expected-agent-schema statements on the Gateway thread during the first turn under
loadTranscriptHeaderSync → openOpenClawAgentDatabaseSteps → agentDatabaseIntegrityBeforeMutationSteps → buildSqliteSchemaContract; all three candidates execute zero in that path. Baseline pair 1 records this atsql-11484-0.jsonl, site 1666.Source explains the handoff gap: the baseline TEMP revocation provokes a host reopen that takes
!reusedSchemapublication.publishOpenClawAgentDatabaseSchemaallocates a new SharedArrayBuffer and replaces the host object's schema slot. The worker retains its structured-cloned object and older cell; its later DDL listener can revoke that cell while the host's replacement remains valid.requiresReadmissionthen skips baseline validation. The candidate avoids the erroneous initial republish, keeping the live cell shared until real DDL revokes it and correctly requests readmission.The SQL branches and ordering are directly observed; SharedArrayBuffer identities/property assignments were not instrumented, so the precise stale-cell mechanism is source-traced inference. The coordinator accepted this attribution and approved the correctness cost. Compaction+shutdown still exceeds the original estimate: baseline sums
[1698, 1702, 1702], candidate[1740, 1740, 1740], medians 1,702 → 1,740 (+2.23%). No alternate window is used to hide the increase, and no real-DDL checks are suppressed.Earlier loaded-host cohort and native lock diagnostics
The initial three local ordinary pairs had invalid second-session/shutdown duration ratios, so two more pairs were added and all five retained. Final ratios were valid, but shutdown remained variable. These results motivated the separate dedicated-host cohort; they were not pooled with AWS or relabeled as a passing numeric gate.
Control+cron sums: baseline
[1616, 1668, 1626, 1655, 1680], candidate[1580, 1863, 1880, 1663, 1651], median +0.48%, attributed to unchanged WAL maintenance, plugin-state/device inventory, and state-cache owners. Compaction+shutdown sums: baseline[1700, 1707, 2533, 1783, 1745], candidate[2399, 1740, 2427, 1752, 2391], median +37.02%, which remains a failed local count result. High-shutdown runs open a cold writer during late memory publication on both sides; its expected-schema batch costs 606 statements on baseline versus 473 on the candidate. The traces support preexisting drain ordering but do not prove why high-mode frequency differed on the loaded host.All functional workloads completed. Native
BEGIN IMMEDIATE: database is lockedrefusals remain separately recorded under the successful-statement counting contract:All other ordinary runs and all focused maintenance runs had zero native failures. There were no AWS shutdown failures. Earlier Testbox sync and AWS preflight attempts ran no measurement samples. All owned remote leases were stopped and verified released.
Tests, review, compatibility, and update proof
All 180 focused tests passed across schema facts, worker admission, session revalidation, maintenance worker, and validation-cache suites. Standalone changed-test file costs with
pnpm test <file> --maxWorkers=1: schema facts 23.479 s (39 tests), worker admission 203.828 s (23 tests). The new admission regression itself took about 1.7 s. The five-file run took 1,635.86 s on the loaded host. After the final test-only binding correction, all 39 schema-facts tests passed again in 13.13 s command wall time. PR CI runtime is not yet measured.pnpm check:changed --base 7a8e5a19b68b5f3b3f824ba4f17ac6763d1a8063passed end to end at the final head. Madge reports zero cycles; the SQLite worker ratchet reports no T1 growth. P2 Codex reviews are clean for the production change and final test-only correction.SDK comparison: no public entrypoints added/removed and all direct public export declarations/kinds unchanged. There are 131 reachable closure-hash changes from two internal declaration deltas: the schema-facts installer/import and new TEMP schema helper. No public barrel or exports map changed.
The published
2026.9.8driver updated successfully to candidatea16efa57f4e63bbb12786a8f5691092522953e92: all 19 command phases exited 0, readiness returned 200, durable history survived, and incognito history cleared on managed restart. The delegated Testbox command settled successfully; the hosting Actions run ended CANCELLED during lease cleanup and is not claimed as green CI. Production source was unchanged through approved heada87e846cebcd751587b52d77deb3d4401afd5fd5; these receipts predate the main integration. Candidate tarball SHA-256:f31d6b4d6b5ea6d998dd35da15a571c1ae59ddb18d397d51c8d581a362509cad.Runtime, package, and SDK evidence is pinned to
a16efa57f4e63bbb12786a8f5691092522953e92, against baseline7a8e5a19b68b5f3b3f824ba4f17ac6763d1a8063. Final heada87e846cebcd751587b52d77deb3d4401afd5fd5changes only a test's nativeexecbinding; production bytes are identical. Dedicated-cohort archive SHA-256:b87d2937348a88955cd64b5bd2c53ed9d56638d635d3c7684dd09acbd361a079.Landing integration and review
Integrated main
94fc0814ef649e2fd630aebe9836e36dec65009ewithout conflicts in merge commitb6d5c68f3855b048ff0fd81aa2adc04525aa1851. Fix0cfce3df4ed0dc9deb3b2ad85b1c6ea964084f53adds the new TEMP helper to the compiled PR-wrapper dependency inventory. The original CI failures in compact-small-1 and changed-7 were PR-caused: extracted wrappers omitted that module; the provisioning fixture then failed before recording its private-store initialization. No assertions were weakened. The focused inventory test passes, and P2 review of the integrated change is clean. Current-head CI run 37670946776 passed. Production and all selected test typecheck lanes, Madge (zero cycles), formatting, targeted lint, wrapper/import closure, and all 23 worker-admission tests passed. The released SDK diff completed againstv2026.9.8; its cross-release API changes are inherited from main, and this PR adds no public signature or export removal. Post-integration alternating-pair statement measurements passed the turn and maintenance gates; detailed values and the approved compaction exception follow below.ClawSweeper completed its latest review of
0cfce3df4ed0dc9deb3b2ad85b1c6ea964084f53on October 7 at 19:24 UTC and found no actionable code/security defect. Its automated persisted-table checklist warning remains, while the technical review confirms the TEMP-only boundary and no durable migration contract; the maintainer assessment rejects that warning as inapplicable. Its automatic persisted-table warning is inapplicable: the generated counter and triggers are connection-local TEMP objects; durable schemas and migrations do not change. Existing published-driver command receipts provide pre-integration update proof as qualified above. Latest stable and beta SDK source inspection found no changed public signature, async/callback contract, or removed export. No new environment-variable names or worker/host-grant cutover are introduced.Inherited local test limitation: the macOS-only
pr-worktree-provision.test.tscold/warm/sparse transition case exceeded its unchanged 120-second Vitest budget (193.061 s observed) in the combined run. The infra project had 77 passing tests and one skipped case; the original missing-module provisioning failures are fixed. Linux CI skips the macOS-specific case. The test creates six real worktrees using synchronous wrapper commands; neighboring single-worktree cases took 25–81 s. The test, fixture helpers, and worktree/provisioning implementation match baseline main, but the changed shared SQLite owner is reachable, so source equality alone does not establish attribution. Five focused--maxWorkers=1runs on baseline and five on candidate all reproduced the same 120-second timeout, with no other failure. Command wall seconds were main[222.51, 234.24, 318.9, 473.27, 240.62]and candidate[231.03, 280.28, 373.69, 231.6, 319.67]. The precise slow inner operation is uninstrumented; this establishes an inherited local fixture deadline failure, not a repaired fixture or a passing replay. Current-head CI is green, so no admin CI exception is needed.Post-integration statement proof
Pinned baseline
94fc0814ef649e2fd630aebe9836e36dec65009eversus integrated candidate0cfce3df4ed0dc9deb3b2ad85b1c6ea964084f53. Three alternating pairs ran on one dedicated AWSc7a.2xlargehost with Node 24.21.0, separate frozen source-mappedqaRuntimebuilds, and unchanged ordinary/maintenance workload bytes. Before-run CPU idleness was 99.875–100%. All twelve workload cells passed; classification reproduced every successful phase/thread/SQL count exactly. All gated candidate/main median duration ratios are below 1.5.Raw successful ALL-thread statements decide the gate; nothing is subtracted. Warmed values are ten-turn means. First turn falls by 174, warmed mean by 1.0, and maintenance by 173. The existing +38 compaction correctness exception remains explicit and approved; the numeric classifier continues to label that phase above its normal ceiling.
Ordinary
Maintenance
Maintenance totals are identical within each side: main
[1022, 1022, 1022], candidate[849, 849, 849], a 173-statement (16.93%) reduction. No maintenance phase increases.Growth attribution. Boot +1 is one additional execution of the existing
deliveryQueue.outboundpending-delivery scan (src/state/openclaw-state-read.worker.ts:259,src/infra/outbound/delivery-queue-storage.kernel.ts:88). Four shared-state schema-admission statements change their requesting path frommentions.mutatetoaudit.writer.prune, with net zero statements. Shutdown +14 (+1.59%) is one existingsession-row-factsbatch (+11 statements, including two watermark reads) and its ACP/shared-state metadata read (+3). The owning dispatch/read implementations are byte-identical between baseline and candidate; this PR adds no request in these owners. These unchanged-owner variations pass the non-turn tolerance. Twelve of the thirteen positive shutdown SQL+full-stack groups also occur in baseline traces. The remaining +1 participant query uses the same unchangedreadParticipantRowsSQL/owner, observed on baseline through the membership-read path rather than this exact row-facts stack. This passes the individual +1.59% unchanged-owner tolerance; it does not use the stricter adjacent-window rule requiring every full-stack group to recur. The native observer loses the original sender across the asynchronous worker boundary, so this establishes the read owners rather than claiming direct timer provenance for every statement.Compaction remains 820 → 858: required real-DDL readmission (40 statements) replaces three direct schema-fact probes, and exact TEMP shape inspection adds one. Keep the coordinator-approved correctness cost and the existing host/worker receipt publication/adoption follow-up; do not suppress the readmission. Combined compaction+shutdown sums are main
[1696, 1702, 1702], candidate[1754, 1740, 1754], medians 1702 → 1754 (+3.06%). No combined window hides the exception.Native diagnostics. Ordinary main/candidate native failures are both
[0, 0, 0]; maintenance main/candidate are both[0, 0, 0]. All twelve calibration traces (main thread and worker on each ordinary run) independently show 8 native calls, 2 prepares, 7 successful statements, zero failures. All harness children settled; maintenance instrumentation restored the exact tracked source after every run.ALL-thread samples in alternating-pair order
[3385, 3381, 3381][3381, 3382, 3382][365, 324, 327][329, 323, 326][4657, 4731, 4728][4554, 4558, 4541][1590.1, 1589.8, 1588.8][1587.8, 1588.8, 1590.9][5319, 5320, 5318][5316, 5311, 5430][53, 55, 57][51, 55, 55][1517, 1470, 1487][1468, 1472, 1489][812, 820, 820][858, 858, 858][884, 882, 882][896, 882, 896][221, 221, 221][50, 50, 50][33, 33, 33][33, 33, 33][87, 87, 87][87, 87, 87][681, 681, 681][679, 679, 679]The dedicated AWS lease was released immediately after archive verification; its final state was verified as released. The 145,843,959-byte archive matches its remote SHA-256:
de49e1355524d4f4dcf74bd66931203dc81c690110079db854bb02d38d061846.