Repository navigation
feat(database): share experimental database engine adapters - #169933
Conversation
Keep SQLite as the default and move PostgreSQL admission, setup policy, and worker settlement behind the database engine owner. Preserve redacted connection failure diagnostics and allow a 60-second connect budget below the 120-second bridge deadline.
|
🦞👀 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. |
Regenerate the configuration checksum to resolve the draft PR conflict. Preserve the reviewed adapter changes and the upstream explicit worker-message transfer list; verify the connection contract, configuration docs, and import cycles after integration.
|
Codex review: needs changes before merge. What this changesThis PR shares experimental database adapters across stores and adds engine diagnostics while preserving SQLite as the default. Example: Run Doctor with database.engine set to postgres.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 1 item remains Keep this PR open: the maintainer-directed extraction is useful, but the earlier wrapper inventory finding remains partially unresolved and blocks merge. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherHost configuration resolves database credentials, shared infrastructure admits physical stores and manages worker operations, and store kernels return results through the existing broker. flowchart TD
Config[Database configuration] --> Secrets[Host secret resolution]
Secrets --> Broker[Worker broker]
Broker --> Engine[Shared engine owner]
Engine --> SQLite[SQLite store or anchor]
Engine --> Postgres[PostgreSQL bridge]
SQLite --> Kernel[Workboard kernel]
Postgres --> Kernel
Technical reviewBest possible solution: Complete the shared engine cutover while preserving existing SQLite behavior and PostgreSQL identity, admission, and settlement contracts. Do we have a high-confidence way to reproduce the issue? Source inspection and exact-head CI establish the missing wrapper dependencies; no local target code was executed. Is this the best way to solve the issue? Moving the pilot into a shared host/worker owner is a coherent solution, but its runtime dependencies must accompany the extracted wrapper. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 64400ffa0503. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +648, Tests +515, Docs +176, Config +8, Generated 0, Other +10. Total +1357 across 59 files. Added test files: 5. View PR surface stats
Review metrics
LabelsLabel changes: No label changes. Label justifications:
Rating scale6/6 🦀 challenger crab · 5/6 🦞 diamond lobster · 4/6 🐚 platinum hermit · 3/6 🦐 gold shrimp · 2/6 🦪 silver shellfish · 1/6 🧂 unranked krab. Overall follows the weaker of proof and patch quality; ✨ marks media proof (a screenshot, video, or linked artifact) that directly shows the changed behavior. WorkflowClawSweeper edits this one comment on every review. Comment HistoryReview history (2 earlier review cycles)Reviewed October 12, 2026, 11:10 AM ET / 15:10 UTC (Revision 3). |
|
postgres-sync/connection.ts imports database-engine/observation and policy since #169933; the eager-import-closure wrapper inventory test failed on main without them.
…170059) Preserve shared-state PostgreSQL CHECKs, indexes, and foreign keys; declare feature fragments through the existing schema owner; and validate catalog equivalence in CI. SQLite first-use statements and schema version remain unchanged. PostgreSQL conformance passed. Inherited and unrelated Node test failures are retained under the documented maintainer exception. Refs #169254, #169933, #169952.
…#169933) Share database-engine contracts, physical-store admission and bootstrap, transaction capabilities, and observation. Workboard consumes the shared adapters while SQLite remains the default and PostgreSQL remains experimental. Includes one bounded CI-contract repair. Remaining wrapper-inventory and unmatched test failures are recorded in the PR; no passing CI result is claimed. Landed under the maintainer-authorized campaign exception with the reviewed head pinned.
postgres-sync/connection.ts imports database-engine/observation and policy since openclaw#169933; the eager-import-closure wrapper inventory test failed on main without them.
…penclaw#170059) Preserve shared-state PostgreSQL CHECKs, indexes, and foreign keys; declare feature fragments through the existing schema owner; and validate catalog equivalence in CI. SQLite first-use statements and schema version remain unchanged. PostgreSQL conformance passed. Inherited and unrelated Node test failures are retained under the documented maintainer exception. Refs openclaw#169254, openclaw#169933, openclaw#169952.
Coordinator review and async-DB file coordination are complete.
Related: #169214, #169254, #169414
What Problem This Solves
PostgreSQL selection, anchor admission, and write settlement were workboard-specific, preventing other stores from adopting one engine contract.
User Impact
SQLite remains the default: existing installations keep their stored data, SQLite schema owner, and statement counts. Opting into experimental
database.engine: "postgres"selects PostgreSQL for workboard; unported store families remain on SQLite and Doctor reports the selections with one experimental/mixed-engine warning.There is no silent SQLite fallback. Existing SQLite workboard data cannot switch engines until a port tool exists. PostgreSQL currently supports fresh bootstrap and matching schemas, not forward migrations.
Why This Change Was Made
src/infra/database-engine/owns adapters, physical-store admission, bootstrap/version/identity checks, transaction capabilities, host secret preparation, worker settlement, and observation. Workboard registers its generated PostgreSQL DDL and consumes the generic open/operation paths; its private PostgreSQL opener and database-config module are removed.The existing config fields use experimental labels/help, a SecretRef-capable connection, and the default
openclawschema prefix. Secrets resolve on the host through the secrets owner and travel through the existing worker input transport. Secret configure/audit/preparation includes the connection only when PostgreSQL is selected.PostgreSQL connections reject main-thread opens except explicit admission/migration. Setup installs adapter-owned connect/lock/statement timeouts once. The connect budget is 60 seconds, leaving 60 seconds below the sync bridge's 120-second request deadline. Every confirmed PostgreSQL commit (including raw and read-only COMMIT) and uncertain commit outcome advances the anchor token; rollback retains it. Shared SQLite transaction/Kysely code dispatches through the leaf connection contract. The compile-only query compiler moves to a shared SQL leaf, keeping PostgreSQL implementation modules out of SQLite-only static closures.
The database engines guide documents configuration, supported stores, isolation/durability, matched PostgreSQL/anchor backups, limitations, and diagnostics. Statement events describe connection execution calls, with compound SQL retained as one normalized event; subscriptions are isolate-local and never include bindings.
Update behavior: omitted config continues to select SQLite. Existing PostgreSQL pilot anchors retain their UUID/schema and require matching metadata; this extraction adds no PostgreSQL migration or data conversion.
Evidence
The r2 repair preserves the original connection-setup error through the sync bridge and rethrows it with
cause, a redacted code/reason, and the existing next-step hint. Unit regressions cover authentication failure, exhausted connections, and connection timeout without exposing the DSN or password.R2 targeted proof at
d9dfb6fc12699(same source throughout those runs):src/infra/database-engine/*.test.tsplussrc/infra/postgres-sync/connection.test.tscommand.test.tscommand.test.tslifecycle-sync.cleanup-recovery.test.tsThe first r2 PostgreSQL cleanup run passed the originally failing initial-sweep case. It instead missed the existing wait window for a retained-worktree callback and observed the blocked-worktree callback before the subsequent metadata write. The cleanup owner awaits removal and then awaits the store update; no test timeout or lifecycle implementation was changed. The single unchanged PostgreSQL replay passed all four cases as host load fell from roughly 155 at the first file start to 72 at replay completion. This supports the load-related timing diagnosis; it is not a new lifecycle-code repair. No connection-open failure occurred in the r2 command proof, so the old swallowed error's original cause cannot be recovered.
SQLite's initial
pnpm testcommand attempt reached the harness's 900-second no-output watchdog without assertions (1234.33 seconds total); a direct-wrapper attempt exposed its shorter 120-second default (263.10 seconds). The final direct-wrapper runs explicitly use the same 900-second harness budget aspnpm test, with all test timeouts unchanged. The above passing results came from that supported wrapper; both preparation failures remain reported here.R2 changed-file oxfmt/oxlint, whitespace checks, and madge pass (0 cycles; 178.22 seconds). The isolated r2 delta review is scoped-clean through P2. Earlier broad conformance and other unchanged-scope proof below remain valid evidence; no fresh full-suite run is claimed.
After GitHub reported a merge conflict, this branch integrated
mainate98a15b7d695. The only manual conflict was the generated configuration checksum, regenerated and checked through its owner. The runtime overlap is upstream's explicit empty transfer list inPostgresSyncConnection; the focused connection file passes again (11 tests, 318.68 seconds), with changed-file formatting/lint/whitespace, config-doc checks, and the post-merge cycle check passing. No additional adapter logic or test timeout changed.Original full run: the PostgreSQL conformance run had three failures. Two
command.test.tscases failed to open a connection after approximately 17.8 seconds;lifecycle-sync.cleanup-recovery.test.tsmissed the initial cleanup callback inside its existingvi.waitFor. At that point the connection timeout was 15 seconds; the test files were unchanged. PostgreSQL remained available and subsequent cases passed. This is not a green conformance result; a bounded diagnostic reproduction of both files was stopped after 608.21 s of preparation without completing an assertion (692.60 s CLI wall including cancellation cleanup). It adds no passing proof and does not establish the cause of the original failures.pnpm test extensions/workboard src/infra/database-engine/config.test.ts --maxWorkers=1; PostgreSQL uses a throwaway Homebrew PostgreSQL 17 cluster over a Unix socket and a conformance preload that supplies config through worker environment data.workboard.boards.registerexecutes 4 statements before and 4 after. Direct negative/positive proof also confirms grouped SQLite writes roll back after a later failure; the existing grouped-write/claim regressions cover both engines.postgres-syncmodules. Runtime-only counts: SQLite transactions 130 modules, Kysely 11, host workboard facade 855. Including type imports: 352 / 11 / 4,969, also clean. Madge reports 0 cycles.git diff --check,pnpm config:docs:check, andpnpm plugin-sdk:check-exportspass. The three original Codex reviews and the additional r2 delta-only review are scoped-clean through P2.Earlier focused test results and cost
All commands use
pnpm test <file> --maxWorkers=1. Wall time includes worker/module preparation on the loaded local host; PR CI seconds are pending.src/infra/database-engine/registry.test.tssrc/config/zod-schema.database.test.tssrc/infra/database-engine/open.test.tssrc/infra/database-engine/observation.test.tssrc/infra/postgres-sync/connection.test.tssrc/commands/doctor-database-engine.test.tssrc/secrets/target-registry.test.tssqlite-store-batch-read,sqlite-store.lifecycle, andsqlite-store-policytest filesThe four host config/SecretRef tests are included in the conformance totals. The two extended grouped-rollback cases took about 80 ms each on warm SQLite and 4.7–7.0 s on PostgreSQL, including their existing fixture and claim checks. No timers, sleeps, worker pins, or serial test configuration were added.
Earlier changed-file formatting/lint/whitespace: 138.41 s. Config documentation: 54.98 s. SDK export check: 5.11 s. Madge: 1005.31 s. Type-inclusive import closure: 52.03 s.
A supplemental
runtime-inactive-core-surfaces.test.tsattempt was stopped after 490.47 s without assertions while module/filesystem work held source preparation. Its new prepared-secret-owner cases remain a local proof gap for CI. The broader type-aware lint wrapper timed out during declaration preparation; direct changed-file oxlint passed. Broad builds, types, and suites remain PR CI's responsibility. Early test preparations invalidated by source edits were discarded; final proof uses frozen sources.Production diff: +646 net lines. No Testbox/Crabbox leases were used. All task-owned throwaway Homebrew PostgreSQL 17 clusters were stopped, verified stopped, and their data directories removed. Server logs are retained outside the repository.
Async-owned touch points:
src/infra/kysely-sync.ts: import-only relocation of the compile-only SQL compiler; native function bodies unchanged.extensions/workboard/src/sqlite-store-kernel.ts: adapter-owned snapshot selection; the original native write-transaction API is preserved.extensions/workboard/src/sqlite-store.worker.ts: generic engine input and adapter-owned outer write envelope.src/infra/postgres-sync/bridge.worker.ts: install adapter-owned connect/lock/statement timeouts once and preserve connection-setup socket codes.No
src/state/**orsrc/infra/sqlite-*production edits. Coordinator and async-DB file coordination are complete.Landing CI follow-up
CI run 38261570475 tested
65d68564e14a82685b5adfe11f28602b04b2d066. It failed; no green run is claimed.The single CI repair commit aligns the moved SQL compiler with the native wrapper inventory, preserves mock exports, removes a test-only core import, binds the workboard transaction callback, records engine schema/bootstrap raw-SQL ownership in the guard, and updates the approved shared-adapter SDK surface budgets. No CHANGELOG edit.
check-additional-boundaries,check-guards-architecture,checks-fast-baseline-ratchets,check-lint-extensions-3,checks-node-compact-small-3,checks-node-compact-small-5,checks-node-compact-small-6,checks-node-changed-compact-large-10checks-node-changed-4: the same SDK entrypoint-guide declaration case fails on main run 38258960208 and run 38253366956.checks-node-changed-compact-small-14-2: HTTP 504 during runner setup, before test execution.checks-node-changed-19,checks-node-changed-20,checks-node-changed-21,checks-node-changed-extensions-bundle-13,checks-node-changed-extensions-bundle-22-2,checks-node-changed-extensions-bundle-33,checks-node-changed-extensions-bundle-8. The sampled scheduled-main runs do not contain matching cases; these have not been labeled inherited or passing.Fix validation: independent Codex review scoped-clean through P2; adapter diagnostics 3 passed (302.72 s Vitest), Doctor 2 passed (15.19 s Vitest), PostgreSQL conformance file 11 skipped without a live PostgreSQL lane (78.45 s Vitest). Formatting and whitespace checks passed. Local type-aware lint did not reach lint assertions: its declaration-preparation child hit the 300-second managed-command timeout. Required CI remains the broad proof.
Final CI classification after the single fix push
Head
177d21a9a078fc32c0dbc4428d5b20ebd691cc6bwas tested by CI run 38266187191. The boundary, architecture, baseline-ratchet, extension lint, and security-fast checks passed. Eight non-aggregate jobs still failed; no second fix push was made.scripts/pr-lib/wrapper-components.txtstill lackssrc/infra/database-engine/observation.tsandsrc/infra/database-engine/policy.ts. The two static closure cases pass on main job 114844765748. This remains disclosed under the one-fix-push limit; it is not product-behavior proof.checks-node-changed-19,checks-node-changed-20,checks-node-changed-21,checks-node-changed-extensions-bundle-8,checks-node-changed-extensions-bundle-11,checks-node-changed-extensions-bundle-24,checks-node-changed-extensions-bundle-33. These have not been relabeled inherited or passing.Native exact-head review validation and
prepare-runcompleted. Nativemerge-run --auto-mergerefused the failed aggregate gate before submitting a merge request; no merge outcome receipt was created. The operator's explicit relaxed landing rules allow only one small-failure fix push, stop only for a proven product regression, and authorize head-pinned REST squash after a native-merge stall exceeding ten minutes. No product-behavior regression has been proven by the available comparisons.Landed by the operator-authorized, head-pinned REST squash fallback at 2026-10-12 15:22:55 UTC, commit
9dc64662f16ef6af61aed51c6ba16445b8d607d8, after the native merge remained blocked for more than ten minutes. The commit is onorigin/main; all 59 merge-commit file paths match the PR file list. The CI exceptions above remain recorded, not relabeled green.