Repository navigation
refactor(state): inline canonical database schemas at build - #117433
Conversation
|
Codex review: needs maintainer review before merge. Reviewed August 1, 2026, 11:30 AM ET / 15:30 UTC. ClawSweeper reviewWhat this changesThe PR removes committed generated SQLite schema-string modules, makes source runs read the canonical SQL files, and inlines those same bytes into the unified packaged runtime build. Merge readinessThis refactor appears technically sound: it replaces duplicated generated schema strings with canonical SQL loaders for source runs and build-time inlining for packaged runtime. It should remain open for explicit maintainer review because the protected Priority: P3 Review scores
Verification
How this fits togetherOpenClaw’s state layer initializes shared and per-agent SQLite databases from schema SQL. The change moves the source of truth to the canonical flowchart LR
A[Canonical SQLite schema files] --> B[Source schema loaders]
B --> C[Shared and agent database setup]
A --> D[Unified build-time inlining]
D --> E[Packaged runtime bundle]
C --> F[SQLite databases]
E --> F
Decision needed
Why: The patch and tests establish the invariant for today’s runtime graph, but only an owner can decide whether that packaging boundary is the durable contract for future database entrypoints. Before merge
Agent review detailsSecurityNone. PR surfaceSource +14, Tests +62, Docs 0, Generated -2835, Other +15. Total -2744 across 26 files. View PR surface stats
Review metricsNone. Stored data modelPersistent data-model change detected: Merge-risk optionsMaintainer options:
Technical reviewBest possible solution: Keep the canonical SQL files as the sole schema representation, retain the unified-build inlining and cache coverage, and make any future packaged database entrypoint join that graph or explicitly receive the same schema-inlining treatment. Do we have a high-confidence way to reproduce the issue? Not applicable: this PR refactors build and state-schema representation rather than repairing a reported user-facing defect; its relevant behavior is covered by source/build and packaged-artifact proof. Is this the best way to solve the issue? Yes, with maintainer confirmation of the package-graph invariant: replacing duplicated generated runtime strings with canonical SQL plus build-time inlining is the narrower maintainable solution and preserves asset-free packaged startup. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning high; reviewed against 7bcbe743bd42. LabelsLabel justifications:
EvidenceWhat I checked:
Likely related people:
Rating scale
Overall follows the weaker of proof and patch quality. Workflow
HistoryReview history (5 earlier review cycles)
|
28d7b30 to
73f4151
Compare
73f4151 to
b2ec661
Compare
|
Merged via squash.
|
What Problem This Solves
The committed runtime schema modules duplicate 2,835 lines from the canonical SQLite
.sqlfiles. That creates a large generated diff surface and a second representation that must stay byte-aligned with the actual schema owner.Why This Change Was Made
Keep the committed
.sqlfiles as the sole canonical schema source. Direct source runs read those files through Node's native builtin handle, so unrelated filesystem mocks cannot replace the input. The production tsdown graph replaces the two tiny loader modules with byte-exact inlined constants. Packaged runtime behavior remains asset-free and performs no schema-file reads. The build cache now tracks.sqlinputs, and Kysely generation remains responsible only for generated database types.No SQLite schema, schema version, migration, config, protocol, or public API changes.
User Impact
No user-visible behavior changes. Maintainers remove 2,744 net lines and one entire class of committed generated duplication while preserving source, packaged, recovery, and install behavior.
Evidence
b2ec661afe4e1809e4f2e8de3d82f8dcd4baa52c.518c964c720149ce02cca97daf2cab533cf5abe2cd87b549de77daa1d38ebd83(shared state) andea87be535142e2f8203d0c670fcb70c0ea2a7c235f6443235b20404d5aaa8984(agent).pnpm db:kysely:checkpassed.build-artifactscompleted successfully, including built-artifact checks: https://github.com/openclaw/openclaw/actions/runs/30705058258/job/91382688815openclaw/ci-gatecompleted successfully: https://github.com/openclaw/openclaw/actions/runs/30705058258/job/91383261024checks-node-compact-small-9: https://github.com/openclaw/openclaw/actions/runs/30705058258/job/91382689118checks-node-compact-small-13: https://github.com/openclaw/openclaw/actions/runs/30705058258/job/91382689110checks-node-compact-small-15: https://github.com/openclaw/openclaw/actions/runs/30705058258/job/91382689124process.getBuiltinModuleis available since Node 22.3.0.pnpm buildpassed; actual built chunks contain byte-exact schema literals, contain no.sqlassets, and open both shared and per-agent databases withPRAGMA integrity_check = ok.c5fc6002401fdd619b892f0ebbfba48026b631b3ce54d7aef88d66fb1da287d1.node:sqlitecapability rejection.