Repository navigation
fix(sqlite): preserve pending cold schema preparation - #170300
Conversation
Preserve temporary schema-admission contention across the worker prepare exchange before a schema lease is acquired. Reuse the existing cold-open deadline without recording a terminal operation refusal. Keep non-initial opens, companion databases, held leases, revoked authority and transaction requests terminal. Extend the real-port regression while preserving the fresh concurrent node configuration test.
|
🦞👀 Pull request received. I will update this pull request when review starts. ClawSweeper review in progressClawSweeper is reviewing this revision. This supersedes any previous blocked status. |
|
Codex review: needs maintainer review before merge. What this changesThis PR preserves temporary schema-preparation contention across the worker admission exchange so initial database opens can retry within their existing deadline. Example: An initial open of state.sqlite encounters temporary schema contention with 100 ms available.
Review scores
ProductKind: Bug fix · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: current main still turns temporary schema-preparation contention into terminal refusal, and this focused repair preserves the existing retry owner without weakening authority checks. No actionable introduced defects were found. Priority: P2 Before mergeNone. FindingsNone. Tests
Agent review detailsHow this fits togetherSQLite workers request schema permission through a private MessagePort; the host checks the retained job and database authority, then returns a grant, terminal refusal, or retryable pending result. flowchart TD
A[Initial database open] --> B[Cold admission deadline]
B --> C[Worker preparation request]
C --> D[Host authority checks]
D --> E[Schema lease and grant]
D --> F[Pending contention]
F --> B
D --> G[Terminal refusal]
Technical reviewBest possible solution: Preserve pending schema contention through the existing exchange and let the cold-open owner enforce its deadline while retaining terminal authority refusals. Do we have a high-confidence way to reproduce the issue? Source inspection establishes the failure path: a pending schema error becomes a terminal host refusal and worker owner refusal before the existing cold-open retry handler can receive it; no tests or target code were run during this read-only review. Is this the best way to solve the issue? The repair addresses the producer and consumer of the lost pending result, reuses the existing deadline, and excludes cases where retry could replay work or borrow another database's authority. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 22443525fa0f. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
PR surfaceSource +35, Tests +56. Total +91 across 2 files. Added test files: 0. View PR surface stats
LabelsLabel changes:
Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment Reviewed October 12, 2026, 6:04 PM ET / 22:04 UTC. |
## What Problem This Solves A first database open can fail during temporary schema contention because the worker's schema-prepare exchange records the pending condition as a terminal refusal before the existing cold-open retry owner can handle it. ## User Impact Cold database opens can wait within their existing deadline for schema preparation to finish. Non-initial opens, companion databases, held schema leases, revoked authority, and ordinary transaction refusals remain terminal. No DDL, schema version, stored-row format, configuration, permission, or retention change is introduced. ## Why This Change Was Made Preserve the pending result across both sides of the existing port exchange before a schema lease or mutation body begins. The existing cold-open owner supplies the retry and deadline; this adds no owner, handshake, timeout, or write replay. The real-port regression covers retry, exhaustion, revocation, path boundaries, and held leases. No authority check is removed. Candidate `2af1dd0ac7cab0cfaecfb49c6eeb176c40b006e0` changes two files (+161/−70). Its delta matches the isolated Codex-reviewed patch and preserves main's private receipt simplification. Main `feb893ca13908081c27230530cc88c59ac7c0158` still has the exact preimages of both changed files, so there is no source overlap at that pin. The separate broker repair is excluded. ## Evidence Scoped qualification is complete. The exact-candidate update cell passed; skipped or historical jobs remain labeled according to their actual scope. | Boundary | Result and scope | | --- | --- | | Current static qualification | [Run 38315479055](https://github.com/openclaw/openclaw/actions/runs/38315479055), exact candidate: production/test types, all selected lint, source contracts, boundaries, baseline ratchets, and architecture passed. Madge reported zero cycles and Kysely guardrails passed. The run completed with 51 successful, eight failed, and 25 skipped jobs. Build-artifacts and published-driver update explicitly skipped. | | Current Knip | Job 115031514632 failed its full-tree unused-file scan on the two Control UI benchmark files described below. Production/export scans completed; production unused-file scan passed with zero entries. The inherited failure is repaired by landed openclaw#170347 (`73611b92e96a103e7ecd4260dd2583150f90a1cd`): selected-head run 38318772519 executed `deadcode:full` with all five file/export groups at zero, Madge at zero cycles, and applicable static gates passing. This does not change the failed candidate job into a pass. | | Cold-admission regression | All 13 cases, including eight schema cases, passed in [job 114956450854](https://github.com/openclaw/openclaw/actions/runs/38292637049/job/114956450854) on a prior composition with identical changed-source blobs. That job was red on four usage-cache fixture assertions. Bounded source/input review qualifies this retained pass for the admission change; no exact-candidate execution is claimed. | | Operation-admission sibling | 26/26 passed in [job 115001073266](https://github.com/openclaw/openclaw/actions/runs/38306200884/job/115001073266), on a prior composition with identical owner and test blobs; bounded source/input review qualifies this focused reuse, not exact-candidate execution. | | Node-host config sibling | `pnpm test src/node-host/config.test.ts --maxWorkers=1`: 13/13 on composition `7ac691f4a04689c9711192262ad0bc3c73b6ad92`, 175.41 s runner / 606.8 s wrapper. This included the separate broker repair and does not isolate either repair's effect. | | Required update cell | [Job 115046869851](https://github.com/openclaw/openclaw/actions/runs/38316114387/job/115046869851) passed on verified candidate `2af1dd0ac7cab0cfaecfb49c6eeb176c40b006e0`: published 2026.10.2 → candidate 2026.10.2, readiness 200, running version verified, and durable/incognito before-and-after stages all exited zero. One attempt, 658 seconds; lane and service cleanup completed. | The focused reuse compares complete owners/tests and 63 source/config/package inputs. Infra runner/setup inputs and test-loader versions match. Identified drift consists of credential cleanup, opt-in lock-diagnostic removal, lifecycle drain classification, unused Postgres/actor-maintenance paths, a TypeBox bump outside the imported standalone normalization helpers, and a PostCSS patch outside these stylesheet-free tests. The operation sibling calls unchanged settlement directly, not the changed actor dispatch path. These changes do not alter the focused admission/receipt behavior being asserted. The preceding cached-main audit at `2be43c633c855851ffd8f6f8e3cba47038d2b9fb` found 60 of the 63 retained inputs unchanged since the previous audit. The three changed inputs come from openclaw#170235: optional worker timing in broker request/reply functions, its type-only contract fields, and an early return for empty registry installs. The retained tests call admission and settlement directly, outside the changed broker functions. Schema cases do not install registry payloads; creation cases do not depend on an empty install publishing a revision or cleaning unrelated retired records, and new descriptor creation still publishes its facts. The two-file patch retains the same reviewed patch ID. Additional lockfile drift adds only Control UI dependencies, and workflow drift selects WebKit for another UI suite. This supports the same bounded reuse; it does not qualify general registry housekeeping, worker timing, or the merged runtime. The preceding source audit pinned `73611b92e96a103e7ecd4260dd2583150f90a1cd`, after openclaw#169622 and the Knip repair. All 63 retained inputs are unchanged since the preceding audit. The openclaw#169622 session/authority contract changes do not enter the two focused tests: cold cases construct the admission owner and real port directly, while the operation sibling uses native in-memory transactions and direct settlement. A supporting static-relative import census found no openclaw#169622 changes among 133 cold-test modules, 213 operation-test modules, or 25 shared-setup modules. Its only intersections in the 47-module infra-config census are two lists selecting other tests; neither focused file’s selection or isolation changes. The unchanged owners and actual call paths preserve the bounded 13/13 and 26/26 reuse; openclaw#169622 does not itself require integration or fresh execution for those assertions. This is not a complete dynamic import graph and does not qualify its session/authority integration, the broader Gateway, or an installed update. The separate exact-candidate update pass above supplies installed-update evidence at its selected SHA. The final source pin is `feb893ca13908081c27230530cc88c59ac7c0158`. Both candidate-file preimages and all 63 retained inputs are unchanged from the preceding audit, including the intermediate `01bf2a7` check. The direct admission/port and transaction/settlement boundaries preserve the same bounded focused-test reuse. The candidate imports/exports are unchanged, so this repair needs no fresh graph qualification. The passing update cell qualifies the unchanged candidate package; it is not represented as execution of this later main or a merged tree. The prior published-driver cell [job 115009067830](https://github.com/openclaw/openclaw/actions/runs/38306200884/job/115009067830) passed published 2026.10.2 → candidate 2026.10.2 with readiness 200 and running-version verification. It is historical coverage only: dependencies and update/Doctor/state-migration owners have changed since that composition. The subsequent composition omitted this patch and supplies no cold-schema update proof. The red tests are classified separately against completed scheduled-main run [38311154418](https://github.com/openclaw/openclaw/actions/runs/38311154418), head `60e5d43fa25737d62aa6ac7bdb7a11f9d936bdcb`: - Four `session-cost-usage-cache.creation-race.test.ts` cases match historical main's offline-maintenance error instead of the expected creation/schema-refresh refusal. Current main contains fixture fix `b506924d58fc9447ab35a821c2029f0c8e110cbf`, which explicitly prepares shared storage while keeping the competing agent database cold; its exact postimage is verified. No new runtime pass is claimed by this source audit. - Seventeen `board-progress.write-admission.test.ts` cases match historical main's unprepared user-profile catalog, followed by retirement and recursive instrumentation errors. Node/Bun stack formatting differs; the named cases and primary error match. Current main’s openclaw#169622 fixture prepares the role schema/catalog and restores instrumentation even when a request rejects; no new executed pass is claimed here. - The default-store rotation case in `session-accessor.test.ts` matches main's expected `session-rebound` / received `undefined` failure. Main already contains fixture fix `5e848de8695e9e8a93ac431447c11de2ffb02a6b`; the candidate contains its exact preimage. - Seven `users-preferences.test.ts` cases fail before dispatch because runtime config is unprepared. Their fixtures are already corrected on main by `95f8e973c07b5984c2760dcc3429cfae9a26ae86`. This is source-verified fixture debt; no executed scheduled-main signature was located or claimed. - Knip reports `scripts/bench-control-ui-cold-load.ts` and `ui/src/test-helpers/control-ui-cold-load-probes.ts`. The flagged files, all-exports config and scan driver remain unchanged; current main’s root Knip config now includes the missing executable entry. Commit `e35494d3fdfc92cedccd7273910de78b28571aa2` introduced the documented path-invoked benchmark without a Knip root; it imports the flagged helper. The separate Knip repair also registers the path-invoked Linux onboarding Vite fixture. Its exact-head manual run 38318772519 passed the full dead-code scan, Madge and applicable statics, and the repair is merged. The inherited static failure is resolved by that landed fix. This is a real static failure, not infrastructure. The exact-candidate real-Gateway job also timed out in `background-work.real-gateway.e2e.test.ts`, while 16 other cases passed. The candidate contains the exact two-file preimage of main fix `3dcebb24ab46297acdf43ca08acf2c715f8b277d`: its observer omits `chat.startup`, which appears successful in the timeout diagnostics. This is a known, already-fixed observer defect; the compact log does not prove it was the sole cause of the timeout. The 14 failures in `media-generate-background-retention.test.ts` are source-attributed to the older runtime-config fixture, already repaired on main by `8f447c5e83cb39fd74840eace70034c8ad1c3dd6`. The candidate writes config without preparing its runtime snapshot: admission returns null before requester lookup in eight cases, and six late-revocation cases wait for a requester-read spy that is never reached. The existing fix prepares the snapshot after all four fixture writes, without weakening assertions; openclaw#169622 now sets that fixture snapshot directly. Both production media owners remain unchanged. The session-accessor and users-preferences fixtures also gained explicit early snapshot preparation in openclaw#169622; their earlier failures remain historical evidence, not current-main failures or passes. This is historical fixture debt, not infrastructure. The hidden config exception is not printed in this job, and no pass on the repaired version is claimed. One isolated Codex review completed with no actionable P0–P2 findings; the reviewed delta is unchanged. Source formatting and diff checks passed. Direct basic oxlint reports `max-lines` at 711 > 700; the repository's native CI lint policy makes that rule advisory, and current core lint passed. The raw basic lint command is not reported as passing. This is a correctness repair, not a SQL-reduction change. It adds no SQL call or public SDK surface. No numeric statement/request or main-thread T1 reduction, standalone cold-file wall time, aggregate green CI result, or exact-head `check:changed` pass is claimed.
What Problem This Solves
A first database open can fail during temporary schema contention because the worker's schema-prepare exchange records the pending condition as a terminal refusal before the existing cold-open retry owner can handle it.
User Impact
Cold database opens can wait within their existing deadline for schema preparation to finish. Non-initial opens, companion databases, held schema leases, revoked authority, and ordinary transaction refusals remain terminal. No DDL, schema version, stored-row format, configuration, permission, or retention change is introduced.
Why This Change Was Made
Preserve the pending result across both sides of the existing port exchange before a schema lease or mutation body begins. The existing cold-open owner supplies the retry and deadline; this adds no owner, handshake, timeout, or write replay. The real-port regression covers retry, exhaustion, revocation, path boundaries, and held leases. No authority check is removed.
Candidate
2af1dd0ac7cab0cfaecfb49c6eeb176c40b006e0changes two files (+161/−70). Its delta matches the isolated Codex-reviewed patch and preserves main's private receipt simplification. Main6315f8adc18ab275a4c933c497113a65bc3f783bstill has the exact preimages of both changed files, so there is no source overlap at that pin. The separate broker repair is excluded.Evidence
Scoped qualification is complete. The exact-candidate update cell passed; skipped or historical jobs remain labeled according to their actual scope.
0d1e09b7913219091baae888feb7fcdec2b06d2c): selected-head run 38318772519 executeddeadcode:fullwith all five file/export groups at zero, Madge at zero cycles, and applicable static gates passing. This does not change the failed candidate job into a pass.pnpm test src/node-host/config.test.ts --maxWorkers=1: 13/13 on composition7ac691f4a04689c9711192262ad0bc3c73b6ad92, 175.41 s runner / 606.8 s wrapper. This included the separate broker repair and does not isolate either repair's effect.2af1dd0ac7cab0cfaecfb49c6eeb176c40b006e0: published 2026.10.2 → candidate 2026.10.2, readiness 200, running version verified, and durable/incognito before-and-after stages all exited zero. One attempt, 658 seconds; lane and service cleanup completed.The focused reuse compares complete owners/tests and 63 source/config/package inputs. Infra runner/setup inputs and test-loader versions match. Identified drift consists of credential cleanup, opt-in lock-diagnostic removal, lifecycle drain classification, unused Postgres/actor-maintenance paths, a TypeBox bump outside the imported standalone normalization helpers, and a PostCSS patch outside these stylesheet-free tests. The operation sibling calls unchanged settlement directly, not the changed actor dispatch path. These changes do not alter the focused admission/receipt behavior being asserted.
The preceding cached-main audit at
b68c44ca8f3ca9d0d4bccb7b620f867547e4cd55found 60 of the 63 retained inputs unchanged since the previous audit. The three changed inputs come from #170235: optional worker timing in broker request/reply functions, its type-only contract fields, and an early return for empty registry installs. The retained tests call admission and settlement directly, outside the changed broker functions. Schema cases do not install registry payloads; creation cases do not depend on an empty install publishing a revision or cleaning unrelated retired records, and new descriptor creation still publishes its facts. The two-file patch retains the same reviewed patch ID. Additional lockfile drift adds only Control UI dependencies, and workflow drift selects WebKit for another UI suite. This supports the same bounded reuse; it does not qualify general registry housekeeping, worker timing, or the merged runtime.The preceding source audit pinned
0d1e09b7913219091baae888feb7fcdec2b06d2c, after #169622 and the Knip repair. All 63 retained inputs are unchanged since the preceding audit. The #169622 session/authority contract changes do not enter the two focused tests: cold cases construct the admission owner and real port directly, while the operation sibling uses native in-memory transactions and direct settlement. A supporting static-relative import census found no #169622 changes among 133 cold-test modules, 213 operation-test modules, or 25 shared-setup modules. Its only intersections in the 47-module infra-config census are two lists selecting other tests; neither focused file’s selection or isolation changes. The unchanged owners and actual call paths preserve the bounded 13/13 and 26/26 reuse; #169622 does not itself require integration or fresh execution for those assertions. This is not a complete dynamic import graph and does not qualify its session/authority integration, the broader Gateway, or an installed update. The separate exact-candidate update pass above supplies installed-update evidence at its selected SHA.The final source pin is
6315f8adc18ab275a4c933c497113a65bc3f783b. Both candidate-file preimages and all 63 retained inputs are unchanged from the preceding audit, including the intermediatea00f582check. The direct admission/port and transaction/settlement boundaries preserve the same bounded focused-test reuse. The candidate imports/exports are unchanged, so this repair needs no fresh graph qualification. The passing update cell qualifies the unchanged candidate package; it is not represented as execution of this later main or a merged tree.The prior published-driver cell job 115009067830 passed published 2026.10.2 → candidate 2026.10.2 with readiness 200 and running-version verification. It is historical coverage only: dependencies and update/Doctor/state-migration owners have changed since that composition. The subsequent composition omitted this patch and supplies no cold-schema update proof.
The red tests are classified separately against completed scheduled-main run 38311154418, head
11a12460482f7790aca049243de04cb9193e87c2:session-cost-usage-cache.creation-race.test.tscases match historical main's offline-maintenance error instead of the expected creation/schema-refresh refusal. Current main contains fixture fixa919b2151d5f6487689d5dd032032a9280231e71, which explicitly prepares shared storage while keeping the competing agent database cold; its exact postimage is verified. No new runtime pass is claimed by this source audit.board-progress.write-admission.test.tscases match historical main's unprepared user-profile catalog, followed by retirement and recursive instrumentation errors. Node/Bun stack formatting differs; the named cases and primary error match. Current main’s refactor: move bundled session reads and authority into workers #169622 fixture prepares the role schema/catalog and restores instrumentation even when a request rejects; no new executed pass is claimed here.session-accessor.test.tsmatches main's expectedsession-rebound/ receivedundefinedfailure. Main already contains fixture fixbe7696c5e9bca74537156e5dc326fb71ca81aa02; the candidate contains its exact preimage.users-preferences.test.tscases fail before dispatch because runtime config is unprepared. Their fixtures are already corrected on main by7e596d5128cc1f678a8463cc9e39d6b27fd179e3. This is source-verified fixture debt; no executed scheduled-main signature was located or claimed.scripts/bench-control-ui-cold-load.tsandui/src/test-helpers/control-ui-cold-load-probes.ts. The flagged files, all-exports config and scan driver remain unchanged; current main’s root Knip config now includes the missing executable entry. Commit5559404e2da9eb32abe8bbfd74f159d605630f57introduced the documented path-invoked benchmark without a Knip root; it imports the flagged helper. The separate Knip repair also registers the path-invoked Linux onboarding Vite fixture. Its exact-head manual run 38318772519 passed the full dead-code scan, Madge and applicable statics, and the repair is merged. The inherited static failure is resolved by that landed fix. This is a real static failure, not infrastructure.The exact-candidate real-Gateway job also timed out in
background-work.real-gateway.e2e.test.ts, while 16 other cases passed. The candidate contains the exact two-file preimage of main fix9b54cd97281693edf641d320a7a6a9a44d6e2820: its observer omitschat.startup, which appears successful in the timeout diagnostics. This is a known, already-fixed observer defect; the compact log does not prove it was the sole cause of the timeout. The 14 failures inmedia-generate-background-retention.test.tsare source-attributed to the older runtime-config fixture, already repaired on main by4944a6df77080f328fed59ee22384e3ee45d522f. The candidate writes config without preparing its runtime snapshot: admission returns null before requester lookup in eight cases, and six late-revocation cases wait for a requester-read spy that is never reached. The existing fix prepares the snapshot after all four fixture writes, without weakening assertions; #169622 now sets that fixture snapshot directly. Both production media owners remain unchanged. The session-accessor and users-preferences fixtures also gained explicit early snapshot preparation in #169622; their earlier failures remain historical evidence, not current-main failures or passes. This is historical fixture debt, not infrastructure. The hidden config exception is not printed in this job, and no pass on the repaired version is claimed.One isolated Codex review completed with no actionable P0–P2 findings; the reviewed delta is unchanged. Source formatting and diff checks passed. Direct basic oxlint reports
max-linesat 711 > 700; the repository's native CI lint policy makes that rule advisory, and current core lint passed. The raw basic lint command is not reported as passing.This is a correctness repair, not a SQL-reduction change. It adds no SQL call or public SDK surface. No numeric statement/request or main-thread T1 reduction, standalone cold-file wall time, aggregate green CI result, or exact-head
check:changedpass is claimed.