Repository navigation
refactor(database): prepare shared-state engine admission (PR2a) - #170266
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 changes before merge. What this changesThis PR adds owner-supplied SQLite classification, PostgreSQL catalog facts, runtime DDL, and scoped main-thread admission. Example: PostgreSQL is selected for a workboard.sqlite file containing a legacy schema_meta table.
Review scores
ProductKind: Refactor · Worth it: Yes · Fix scope: Complete Merge readiness⛔ Needs changes before merge - 2 items remain Keep this PR open: the approved engine preparation is useful, but the previously reported P2 catalog-validation defect still blocks merge. Priority: P2 Before merge
Findings
Tests
Agent review detailsHow this fits togetherThe database-engine layer accepts a native anchor, schema contract, and prepared engine input, then returns the selected connection and publishes reusable physical-store facts. flowchart TD
A[Workboard schema owner] --> B[Engine store admission]
B --> C[SQLite anchor]
B --> D[PostgreSQL connection]
D --> E[Server catalog capture]
E --> F[Shared admission facts]
F --> B
Technical reviewBest possible solution: Validate the expected contract against retained catalog facts without querying PostgreSQL again, preserving the approved prerequisite scope. Do we have a high-confidence way to reproduce the issue? Current main shows the prefix-only SQLite classification and unconditional admission exemption; the PR's retained-facts validation bypass is also directly traceable in source, without running target code. Is this the best way to solve the issue? The shared-owner placement and lexical scope fit the approved design, but cached and freshly captured catalogs must enforce the same expected contract. Full review comments:
Overall correctness: patch is incorrect AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against e4f463159d0a. Provenance checked
TestingProof path: in-process harness. SecurityNone. EvidenceAcceptance criteria:
What I checked:
Likely related people:
PR surfaceSource +98, Tests +755, Docs +46, Config 0, Other -56. Total +843 across 77 files. Added test files: 8. View PR surface stats
Review metrics
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 12, 2026, 7:52 PM ET / 23:52 UTC (Revision 5). |
2d92df3 to
0fbf8b9
Compare
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
…nclaw#170266) * refactor(database): prepare physical engine admission * fix(database): align worker conformance and CI classification * refactor(db): keep one PostgreSQL DDL form per state object * style(database): format rebased SDK budget comments
* fix(database): preserve agent PostgreSQL schema contracts Generate owner-scoped agent runtime DDL with faithful relational indexes and checks, ten canonical non-search triggers, and explicit pending search capabilities. Verify the agent catalog and paired SQLite/PostgreSQL behavior in conformance. Keep runtime enablement and schema versions unchanged. Related: #169254, #170059, #170266 * fix(ci): exclude generated PostgreSQL from SQLite ratchet The generated PostgreSQL schema uses JSON function and operator names shared with SQLite. Keep the canonical PostgreSQL artifacts outside the SQLite debt inventory while retaining checks on SQLite source.
…71350) * fix(database): preserve agent PostgreSQL schema contracts Generate owner-scoped agent runtime DDL with faithful relational indexes and checks, ten canonical non-search triggers, and explicit pending search capabilities. Verify the agent catalog and paired SQLite/PostgreSQL behavior in conformance. Keep runtime enablement and schema versions unchanged. Related: openclaw#169254, openclaw#170059, openclaw#170266 * fix(ci): exclude generated PostgreSQL from SQLite ratchet The generated PostgreSQL schema uses JSON function and operator names shared with SQLite. Keep the canonical PostgreSQL artifacts outside the SQLite debt inventory while retaining checks on SQLite source.
Problem and scope
openEngineStoreinferred existing SQLite data from table-name prefixes, which could miss partial or legacy stores. The PostgreSQL adapter also granted every main-thread open an admission exemption that outlived boot.This PR is PR2a: engine prerequisites only. It adds owner-supplied data classification, separately published PostgreSQL catalog facts, a single runtime DDL artifact per state object, and a synchronous admission scope with request-time enforcement. Workboard adopts the contract; its PostgreSQL workload fixtures now run in real workers with host-retained admission. Shared state remains SQLite in production; its physical-open cutover, lazy ensure wiring, state conformance, and type frontier are PR2b.
Builds on #170059, #170017, and #170037. No schema version, durability, configuration, or stored-data migration changes.
Evidence
Raw native SQLite execution captures are byte-identical to the base, without SQL normalization: workboard 35,592 bytes (98 cold-open statements, one write, eight warm-reuse statements, one read); shared state 196,425 bytes (86 cold-open statements, three write-transaction statements, 31 restart statements, one read). The state owner source is unchanged.
Local PostgreSQL 17 proof used a throwaway cluster on port 55440, stopped and removed afterward. Catalog verification matched 134 tables, 1,386 columns, 293 CHECKs, 297 indexes, and 32 foreign keys; the two declared pending ACP indexes remain explicit. Physical-facts tests passed (3 tests; 40.68s Vitest, 555.18s including compilation). The final workboard fixture uses the existing engine worker broker. Its local PostgreSQL conformance passed (15 tests, seven native-only skips; 579.26s Vitest, 706.78s runner including 324.86s worker preparation).
Engine-open tests passed (4); generator tests passed (15; 76.68s); guard/adapters/connection proof passed, including live refusal of post-admission main-thread SQL and successful worker reads/writes. After the final test-helper typing correction, the focused guard rerun passed (2 tests; 7.53s Vitest, 15.50s runner). Runtime build, formatting, Madge (zero cycles), wrapper inventory, and diff checks passed. Two independent Codex review rounds found no actionable P0–P2 defects. Initial source-freshness and SDK-preparation failures were tooling failures; successful frozen-source reruns are the evidence above.
Core typecheck and extension lint passed. The first draft CI PostgreSQL conformance job passed. CI exposed a SQLite dialect-classification bug (PostgreSQL-only JSONB constructors/aggregates were counted as SQLite debt), an extension-test helper bridge, and excessive SDK exports. The classifier now distinguishes the actual dialect functions with a regression; the workboard fixture uses the existing engine worker broker; physical catalog helpers remain engine-internal. The sole new public SDK name is the lexical admission scope; the existing worker-outcome predicate is also available on its narrow private-local worker subpath. The exact SDK budget increase is one export/one callable; no shipped API was removed. The PostgreSQL generator is registered as its actual executable root for dependency analysis. The two maintenance capability exports intentionally await PR2b routing; the production-only Knip exception names that module, while the full-tree test-aware export audit remains enabled.
The final fixture passed the extension typecheck and focused extension-boundary test (one assertion, 470.41s runner including shared build preparation); the direct extension-test-import checker also passed. The dialect regression suite passed (six tests, 72.07s runner), and the dialect ratchet reports no growth. Final targeted core, root-test, script, and revised-fixture lint passed; formatting and diff checks passed. SDK declaration preparation exceeded the default five-minute local budget, then passed with the repository-supported 15-minute budget (12,847 declarations); downstream checks reused the completed outputs. The exact SDK surface check passed at 3,713 public exports/2,168 callables with no shipped removals. The production dependency scan now reports only the inherited outbound re-export below. Prior-head CI: run 38317012886 at
5c593e113b249758f148bd53a9697f30396a0080. PostgreSQL conformance passed (409 tests; 262.43s across three Vitest shards), as did the baseline ratchets, additional boundaries, changed-boundary suite, and test-type job. The dependency job reports only the unchanged outbound re-export described below; its log was checked against the base. Other broad CI jobs may still be completing; this draft is not merged. The inherited unusedhasActiveDeliveryOwnerre-export insrc/infra/outbound/delivery-queue-storage.tsexists unchanged at the base and is outside this PR.Coordinator correction: removed the superseded wrapped state/fragment DDL and the duplicate
.runtimefilenames. The manifest now names one unqualified runtime file per state object; catalog equivalence executes those same files. All retained state SQL is byte-identical to its prior runtime counterpart, andagent.postgres.sqlremains byte-identical and wrapped. Tracked generated output falls from 87 files / 7,008 lines to 45 files / 4,090 lines. Manual application in a chosen schema is documented. The existing CI path filter already includes every retained generated file. Correction validation passed:pnpm db:postgres:check(15 generator tests, 58.12s Vitest / 139.57s runner, plus canonical/workboard freshness), wrapper inventory (4 assertions, 64.21s Vitest / 75.27s runner), targeted script/test type-aware lint, formatting, andgit diff --check. Shared SDK declaration preparation completed successfully (12,847 files). CI for correction head2d92df3d9f8555ca039477504006f14b4a2464e4: run 38320942163. PostgreSQL conformance was skipped because preflight refused the stale synthetic PR merge head (5c593e113b249758f148bd53a9697f30396a0080instead of the pushed correction). GitHub reports the PR conflicts with current main. This run did not execute the PostgreSQL tests; the prior-head pass above is not new-head evidence.Handwritten production growth: 296 net lines, below the 550-line budget; generated SQL and test fixtures are separate. No protected async-owned file changed.
Landing validation
Rebased head:
0fbf8b960806a72dedf53b8e2ca92e52922ef93f. The only conflict was SDK budget arithmetic; main's additions and this PR's one export/callable are preserved. PostgreSQL regeneration produced unchanged outputs,pnpm db:postgres:checkpassed all 15 generator tests, and current-head PostgreSQL conformance passed in CI run 38322851750.Maintainer-authorized native CI exception under the causal-path rule:
checks-node-changed-extensions-bundle-19-2checks-node-changed-extensions-config-119checks-node-changed-extensions-bundle-28checks-node-changed-2CI's automatic classifier reports
unknownfor the three failed jobs because scheduled main uses different job names. Independent causal inspection and matching tree/blob identities establish that the observed failing paths are disjoint from this PR. The tested merge is5e8938315beeb2180a4d515a015dd4243bc4b80e, with main parent0a3231562bb3ddcb44d4ca73a65f9b62dbf46116and the exact PR head.security-fastpassed independently.Approved design of record — sections 1–4 (PR2a implements the engine prerequisites; state integration is PR2b)