Repository navigation
build: add shrink-only SQLite dialect ratchet - #168382
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 adds a Git-based check that rejects growth in three groups of SQLite-specific SQL constructs. Example: A developer adds SELECT value FROM json_each(?) while retaining one INSERT OR IGNORE statement.
Review scores
ProductKind: Maintenance · Worth it: Yes · Fix scope: Complete Merge readiness✅ Ready for maintainer review Keep open: this maintainer-authored PR provides useful portability enforcement absent from current main, with no actionable correctness or security findings. Priority: P3 Before mergeNone. FindingsNone. Agent review detailsHow this fits togetherLocal checks and CI supply a Git base; the scanner compares production source snapshots and returns construct counts, growth diagnostics, and an exit status. flowchart TD
A[Local checks and CI] --> B[Dialect ratchet]
B --> C[Git source snapshots]
C --> D[Shared TypeScript parser]
D --> E[Lexical construct inventory]
E --> F[Independent group comparisons]
F --> G[Diagnostics and exit status]
Technical reviewBest possible solution: Retain the focused lexical guard, shared snapshot machinery, and documented limits, using the native inherited-failure workflow for landing. Do we have a high-confidence way to reproduce the issue? This is new developer tooling; supplied CLI results and real-Git integration coverage exercise its intended contract, and no target code was executed during this review. Is this the best way to solve the issue? Shared Git-base selection, identical lexical rules at both revisions, and independent group totals provide proportionate enforcement while allowing moves and shrinkage. AGENTS.md: found and applied where relevant. Codex review notes: model internal, reasoning medium; reviewed against 89a1e7e52451. Provenance checked
TestingProof path: shipped entry point. SecurityNone. EvidenceWhat I checked:
Likely related people:
PR surfaceTests +190, Docs +4, Config +3, Other +396. Total +593 across 9 files. Added test files: 1. 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 (4 earlier review cycles)
Reviewed October 10, 2026, 3:33 PM ET / 19:33 UTC (Revision 5). |
b453af2 to
72da62e
Compare
|
Merged via explicitly authorized admin squash with attributed pre-existing CI failures.
|
* build: add shrink-only SQLite dialect ratchet * fix: restrict dialect ratchet to SQL-looking text * fix: preserve SQL quote state across template spans
What Problem This Solves
Keep SQLite-specific SQL debt from growing while preparing OpenClaw for a possible PostgreSQL backend, without treating error messages, HTTP headers, or CLI help as SQL. The corrected executed-SQL census measured approximately 1,008 warmed statements per turn: 59.4% portable, 6.8% mechanical, 7.2% design, and 26.7% engine maintenance, including 221.6 freshness probes per turn.
User Impact
No runtime, schema, configuration, driver, or dependency change. Developers get a shrink-only check that compares each construct group's total with the Git base and reports growth locations. Ordinary prose such as "does not match", "a -> b", "Pragma", "failed to attach", and "use glob patterns" does not count. This is PostgreSQL-readiness preparation only.
Why This Change Was Made
The guard applies identical lexical rules at base and head, scanning only differing production
.ts,.mts, and.sqlfiles undersrc/,extensions/, andpackages/, with the database-worker inventory's test and fixture exclusions. Unchanged files cancel out; moves and reductions are allowed. Untracked files are included,--stagedreads the index, and--full-treereports whole-tree totals. The central string-set helpers retain their owner annotation within mechanical debt.Examined text is restricted to:
.sqlfiles minus comments.sql, case-insensitively: for examplesql,kyselySql, anddb.sql.(with an uppercase keyword fromSELECT,INSERT,UPDATE,DELETE,REPLACE,WITH,CREATE,DROP,ALTER,PRAGMA,BEGIN,COMMIT,ROLLBACK,SAVEPOINT,RELEASE,VACUUM,ATTACH,DETACH,ANALYZE,REINDEX, orEXPLAIN; all static template parts are then examined.orReplace,orIgnore,orAbort,orFail,orRollback) as code tokens.Within that text, the existing case-insensitive word-boundary construct regexes are unchanged: SQL double-quoted text never matches, functions require
(, anddata_version/schema_version/user_versionrequirePRAGMA <name>orpragma_<name>(. Substitutions are never examined. Nonmatching prose, fragments, lowercase untagged statements, and assembled SQL are intentionally ignored or under-counted. A keyword-only SQL classifier token such as"SAVEPOINT"still satisfies this lexical gate. There is no type checking, symbol/import resolution, or SQL token-role analysis.The implementation is 376 lines across three new production scripts (94 + 192 + 90), with a 174-line test file. The shared TypeScript parser is unchanged. The guard is wired into full/changed checks and CI.
Evidence
pnpm test test/scripts/check-database-dialect-ratchet.test.ts --maxWorkers=1: 2 tests passed, 1.116 s execution, 2.18 s Vitest duration, 7.07 s command wall time. Coverage includes the specified prose exclusions, SQL tags and statement prefixes, static template tails, skipped substitutions, deterministic output, real Git base/head selection, growth/shrinkage, moves, deletion, untracked files, and staged content.pnpm check:database-dialect-ratchet --base 03fab71bbad0: passed in 2.66 s wall time, with zero differing production files. This is above the approximate 2 s target on the loaded local host; user CPU time was 0.57 s.--full-tree: passed in 53.02 s wall time. Both base and head report 95 mechanical, 366 design, 391 engine-maintenance, with 2 owner occurrences included in mechanical.pnpm check:changed --base 03fab71bbad05c6d73c48c2dff83db07f18263ad: passed on the first Testbox attempt in 468.39 s command wall time, including typechecks, export scans, formatting, and scripts/test lint with zero warnings or errors.SAVEPOINTclassifier token is noted above. These are lexical source occurrences, separate from the weighted execution census.git diff --check: passed. Hosted PR CI execution time for the test is not yet available; local cost is recorded above.Per-construct full-tree counts before and after the SQL-looking-text gate
The production source tree is identical for both tallies; the reduction comes from restricting examined text. Total source occurrences: 2,502 → 852.
Landing validation
Rebased after generator PR #168219 onto main
21f5711b9c66, producing72da62e442daa2c637e99d84395957fa1970a33f. The only conflict was the shared insertion point instorage-changes.md: both paragraphs remain verbatim, generator first and ratchet second. Range-diff reports documentation and adjacent package context shifts; removing the exact original additions from every rebased file yields the new base byte-for-byte. All four new script/test blobs match the reviewed head, so the coordinator's independent Codex review carries over.git diff --check, the one-file MDX check, and one-file formatting passed.pnpm test test/scripts/check-database-dialect-ratchet.test.ts --maxWorkers=1passed all 3 tests: 3.551 s test execution / 12.31 s command wall.PR CI run 38078511415, attempt 1, remains failed on three independently qualified baseline failures:
checks-ui (3/3): the sidebar main-chat metadata test cannot find.session-owner-chip; the same case and assertion fail in main run 38076523822.QA Smoke CI (profile 4/4):subagent-completion-direct-fallbackfails its private runtime-context/user-turn projection check; the same scenario fails in that main run.checks-node-changed-extensions-bundle-22-1: the unchanged memory-core shard reaches its five-minute no-output limit. Independent main-baseline Testbox proof reproduces repeated hook timeouts in the same provider-none maintenance tests. The lease was stopped after those failures; remaining baseline coverage is unrun. Intervening embedding-cap changes do not execute in the affected provider-none cases.Runtime, UI, QA and extension inputs are unchanged between the tested main parent and PR merge. These failures are submitted for the native inherited-failure exception; CI is not represented as green. Independent
security-fastpassed and no jobs were cancelled. No ratchet CI rerun was requested.