Repository navigation
feat: generate PostgreSQL DDL from canonical SQLite schemas - #168219
Conversation
|
🦞👀 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. |
|
Codex review: needs maintainer review before merge. What this changesThis PR generates PostgreSQL DDL and explicit portability reports from the canonical SQLite schemas. Example: A developer runs pnpm db:postgres:gen --out /tmp/openclaw-postgres.
Review scores
ProductKind: Feature · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep this PR open: it delivers useful, maintainer-directed PostgreSQL readiness tooling, and review found no definite introduced correctness or security defect. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherOffline developer tooling loads the canonical SQL files into in-memory SQLite, translates catalog facts into PostgreSQL artifacts, and optionally compares an applied PostgreSQL catalog. flowchart LR
A[Canonical SQLite schemas] --> B[In-memory SQLite catalog]
B --> C[Portable expression translator]
C --> D[PostgreSQL DDL]
C --> E[Portability reports]
D --> F[Disposable PostgreSQL database]
F --> G[Catalog verification]
B --> G
Technical reviewBest possible solution: Land the bounded readiness generator through the native CI admission workflow while keeping runtime PostgreSQL support and data migration separate. Do we have a high-confidence way to reproduce the issue? This PR adds developer tooling rather than fixing a reported runtime defect; source inspection establishes its generation and verification paths. Is this the best way to solve the issue? SQLite catalog introspection, an explicit portable subset, and visible omissions fit the approved preparation scope without introducing a second runtime storage owner. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 3e44be0fb8a6. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +399, Docs +9, Config +1, Other +900. Total +1309 across 5 files. Added test files: 1. 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 HistoryReview history (4 earlier review cycles)
Reviewed October 10, 2026, 2:48 PM ET / 18:48 UTC (Revision 5). |
Add deterministic readiness DDL, an explicit portability inventory, and PostgreSQL catalog verification. SQLite remains the only runtime store; canonical schemas and runtime code stay unchanged.
0a5afe6 to
7bed777
Compare
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…#168219) * feat: generate PostgreSQL DDL from canonical SQLite schemas Add deterministic readiness DDL, an explicit portability inventory, and PostgreSQL catalog verification. SQLite remains the only runtime store; canonical schemas and runtime code stay unchanged. * refactor: split PostgreSQL schema catalog by object kind
What Problem This Solves
We need a reproducible account of which canonical SQLite schema objects PostgreSQL can represent before building a real PostgreSQL conformance lane. This is maintainer-requested PostgreSQL-readiness preparation.
User Impact
There is no runtime behavior change. SQLite remains the only supported runtime store, and the canonical SQLite files remain authoritative and unchanged. The generated DDL is a partial projection with explicit omissions, not a production migration; per-agent PostgreSQL topology remains undecided.
Why This Change Was Made
pnpm db:postgres:gen --out <dir>reads SQLite's own catalog and pragmas, translates an explicit portable expression subset, and writes deterministic DDL plus JSON/Markdown portability reports. Every canonical table, column, index, FK, CHECK, trigger, and virtual table is accounted for. Unsupported expressions and dependent objects are reported rather than silently discarded.--verify-psqlcompares the applied PostgreSQL catalog with the mapped SQLite facts.The projection emits 174 ordinary tables, 1,712 ordinary columns, all 57 FKs, and 320 of 354 CHECKs. Six ordinary indexes, 34 CHECKs, 14 triggers, and two FTS5 virtual tables are reported as untranslatable; SQLite internal storage is inventoried separately. Identity allocation differences and excluded runtime/plugin/startup DDL are documented in the report. There are no runtime dependencies or runtime-code changes.
Evidence
Readability refactor:
catalog()is now a 9-line coordinator with named helpers per object kind sharing one context. The entrypoint and catalog module total 900 lines, unchanged; the expression translator and test expectations are unchanged.Output identity: generated before/after artifacts with the default prefix and with
--schema-prefix pgtest; bothdiff -rcomparisons returned exit 0 with no output, covering all four generated SQL/JSON/Markdown files per prefix. The accepted PostgreSQL 17.11 apply/catalog proof carries over and was not rerun.Refactor validation: all 13 unchanged tests passed locally (186 ms execution / 4.15 s wall); focused lint/format and autoreview through P2 passed.
pnpm check:changed --base f91baf27ccc296c90a8268a7bee234e4ffdfd3b3 -- scripts/generate-postgres-schema.mts scripts/lib/postgres-schema-catalog.mtspassed on Testbox in 293.427 s. Its initial missing-baseline-object failure was resolved by fetching that exact published commit without changing the tested checkout.PostgreSQL 17.11 on isolated Testbox: applied both generated files with
psql -v ON_ERROR_STOP=1; verified all 129 state and 45 agent tables with zero unexplained differences in columns, types, nullability, identity, PKs, UNIQUE constraints, FKs/actions/deferrability, index counts, and CHECK counts.Live generated-DDL probes passed for standalone-unique-index FK targets, nested unary operators,
IS JSON, and exact GLOB translation.pnpm test test/scripts/generate-postgres-schema.test.ts --maxWorkers=1: 13 passed. Local: 165 ms test execution / 2.46 s wall. Testbox: 133 ms test execution / 1.67 s wall. Canonical schemas are loaded only by the inventory/determinism test; regression cases use tiny distinct schemas. Hosted PR-CI test time is not yet available.pnpm check:changed --base 03fab71bbad05c6d73c48c2dff83db07f18263ad -- scripts/generate-postgres-schema.mts test/scripts/generate-postgres-schema.test.ts package.json docs/reference/database-schemas/storage-changes.md: passed on Testbox. The final remote tests/check/cleanup bundle took 381.293 s.Codex autoreview: scoped-clean through P2.
git diff --checkpassed. A supplemental proof-script schema-name typo and three test-inventory parameter type errors were corrected before the final successful proof.DDL/catalog proof does not establish runtime SQL, data-migration, transaction/concurrency, FTS-tokenizer, or vector-search conformance.
Landing validation
The coordinator-approved rebase produced head
7bed777cbbafdde4d0ef3cc9622923ff1c7736e0. Range-diff against the reviewed0a5afe62677dstack marks both commits=; there was no conflict or patch change.git diff --checkpassed. The independent Codex review and original PostgreSQL apply/catalog proof carry over for those identical patches.PR CI run 38072214963, attempt 2, remains failed because of three independently qualified baseline failures:
check-lint:managed-cleanup-handoff.mts:224consistent-return error, also present in main CI run 38072014174. Main subsequently fixed the cleanup owner in493a499b86e3.checks-node-changed-extensions-bundle-28: three Agents API steering/retry assertions. An isolated checkout of main0f08bb02f0b7reproduced exactly the same three failures, with the other nine cases passing, on Testbox.checks-node-changed-extensions-bundle-22-1: the memory-core shard stopped after five minutes without output. The same ten-file, two-worker main baseline independently stalled and repeatedly timed out inmanager.borrowed-connection.test.tshooks on Testbox. The lease was stopped after recording those failures; remaining baseline coverage is unrun.The tested merge
54ce781fdd0cdiffers from its main parent only in this PR's five files. The relevant runtime, extension, test configuration, lockfile, and runner inputs are unchanged; these failing shards do not execute the new generator. These failures are submitted for native inherited-failure admission; CI remains failed.The initial Android 16 KB job failed while resolving Kotlin 2.4.0. The exact Maven Central artifact later returned HTTP 200; one targeted job rerun passed. No code was changed or repushed for that infrastructure recovery.
security-fastpassed independently, and no jobs were cancelled in attempt 2.