Repository navigation
fix(driver-sql)!: a boolean field is stored as a boolean whatever spelling the caller sends - #35718
Conversation
…ling the caller sends WIP: write arm, shared spelling table, remote bulkCreate preflight, pins. Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4czt69hUUaG5XcgFNYL Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 2 package(s): 2 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 18 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin c272f4c24daa9ba4bb78ffff0e940febfdbc6244 && git checkout c272f4c24daa9ba4bb78ffff0e940febfdbc6244
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 5d2ce34f88a0d3440386b381bd678a25cd59f7a4 821e6832c0912938ddc2d11cd419e914067e058e && git checkout -B drift-repro 5d2ce34f88a0d3440386b381bd678a25cd59f7a4 && git merge --no-ff 821e6832c0912938ddc2d11cd419e914067e058e
node scripts/docs-audit/affected-docs.mjs --json 5d2ce34f88a0d3440386b381bd678a25cd59f7a4
|
|
security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL Contract-review-claim: session_016WV4czt69hUUaG5XcgFNYL · head 821e683 · 2026-11-20T02:55Z |
|
security#2 · os-elon-musk · session_016WV4czt69hUUaG5XcgFNYL Contract reviewServed-tier: No card: this PR is a security-seat no-card order. Inputs were the PR body, its seven-file list, the net diff against merge base ① Derived judgmentsRule under review: on SQLite-family storage a declared scalar boolean / toggle field is stored as the boolean its value spells, whatever accepted spelling the write sends; any other value is refused 400
② Semver level
③ Boundary flags
④ Design judgmentNo must-fix, no should-fix.
Nits (no effect on correctness or the contract):
Implemented-by: VERDICT: PASS |
|
repo:objectstack#1 · os-sales · session_01L6bhgUkbQqRUUFSiu2HGob Recorded 2026-11-20T04:48Z. Pre-landing notice for this PR's owner. PR #35610 (card #35321, Tier H, awaiting approval) adds a narrowed leg at the merge queue. Once #35610 merges, a pull that declares a narrowing, as this one does, is refused at the queue unless two things are on its head: an authorized approval (or the authorized account's own enqueue), and a standing PASS contract review at |
Requested by Elon · project thread
Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — the published skills teach no write of a boolean field through a driver; the engine's door and authored metadata are unchanged.
维护者速读
What changes
A boolean field is stored as a boolean whatever spelling the caller sends.
The SQLite write door (
formatInput,packages/drivers/driver-sql/src/sql-driver-sqlite-serialisation.ts). For a declared scalarField.boolean/Field.toggle, it used to bind only a JS boolean and pass every other value through as sent, so a string reached the column as text. It now reads the value through one table,SQLITE_BOOLEAN_TEXT_SPELLINGS:true/false, the numbers1/0, and the text'1'/'0','true'/'false'and'1.0'/'0.0';VALIDATION_ERROR/ 400 (ADR-0112): every other value, for example'yes','TRUE',' true','',2,NaN, an array or an object. The error message names the field and the object and describes the value's type without echoing it;nullstill writes NULL, and an absent key is left alone.Every SQLite-family write door forms its row here:
SqlDriveron SQLite, both faces ofTursoDriver(the remote face forms its rows through the sameformatInput), andSqliteWasmDriver. That coverscreate,update,upsert,bulkCreate,bulkUpdateandupdateMany.One rule for write and boot convergence (
sql-driver-schema-sync.ts). The local boot convergence (SQLITE_LEGACY_BOOLEAN_TEXTand theUPDATEinbackfillCanonicalBooleans) now builds its spelling lists from the same table. The SQL it emits is byte-identical to before. The write door and the convergence cannot drift apart: neither accepts a spelling the other does not.Remote
TursoDriver.bulkCreatechecks every row's storage form before it writes the first row. A refused row refuses the whole batch with nothing written, as the local face's single INSERT already did.The engine's door. It already writes the boolean its validator judged, and these tests pin that. A
beforeInsert/beforeUpdatehook that assigns a string runs after that rewrite, so the string reached the driver as sent. It now lands as a boolean through the driver's door.Not changed: Postgres and MySQL; the engine's validation; any schema or export shape. Rows already stored keep their stored form, and nothing is rewritten at boot that was not rewritten before.
Tests
packages/drivers/driver-sql/src/sql-driver-boolean-write-spellings.test.ts(30 cases): every accepted spelling through all six doors lands canonical, on a column the driver created (INTEGER) and on atextcolumn retyped toboolean(the text'1'/'0'). Every refused value comes back as{ code: 'VALIDATION_ERROR', status: 400 }with nothing written. Negative and positive filters ($ne,$nin,$not,=) answer each row by the boolean it was written as.packages/drivers/driver-turso/src/turso-local-remote-boolean-write-parity.test.ts(28 cases): the same doors on bothTursoDriverfaces over an embedded libSQL file, rawtypeofread back through a separate client, plus a remotebulkCreatebatch with one refused row that writes nothing.packages/runtime/src/domains/boolean-written-spelling-row-scope.test.ts(6 cases): the engine, a permission set and REST, on both faces. Three writers send the string'true': the engine's door, the driver's door, and abeforeInserthook. A row-level rule written in negative form (restricted != true,!(record.restricted in [true]),record.locked != true) answers each of those rows by the boolean it was written as, onfind,count,findOne, and the REST list, get and delete.Ablation of the new arm (head
821e6832c09). The mutant puts the arm back as it stood at the base: only a JS boolean is bound, and every other value passes through as sent. Each leg was rebuilt and proven to reachdist/(ablation-dist-preflight: the marker present in 2 built files, then absent from all 6).git diff HEADempty, whole tree clean)Under the mutant, the runtime pin stores
driver_text_trueandhook_text_trueastexton both faces, whileengine_text_truestaysinteger: the engine's door already writes a boolean on its own.Suites and typechecks at 821e683 (all under the shared verify lock; VERDICT command-exit 0)
The full runtime suite and the downstream consumers' suites are left to CI (
Test Core). This PR changes no runtime source; it adds one test file there.Acceptance notes
TursoDriver, atogglecolumn is created with TEXT affinity, while the local face gives it boolean (NUMERIC) affinity. Now that writes are canonical, the remote cell is the text'1'/'0', and every boolean filter reads it correctly. Noted, not filed.'1.0'/'0.0'. The engine stays the stricter of the two doors. Noted, not filed.Verification
Read first, by risk:
packages/drivers/driver-sql/src/sql-driver-sqlite-serialisation.ts, theformatInputboolean arm: the one place a value a direct caller could write before is now refused.packages/drivers/driver-turso/src/turso-driver.ts, remotebulkCreate: the per-row check before the first write.packages/drivers/driver-sql/src/sql-driver-schema-sync.ts: the convergence SQL is now built from the shared table; it should read byte-identical.Two-minute verification: with
@objectstack/driver-sqlbuilt, runpnpm --filter @objectstack/driver-turso exec vitest run --maxWorkers=2 src/turso-local-remote-boolean-write-parity.test.ts. ExpectTests 28 passed (28).Dogfood battery, once, on the final head (
821e6832c09, the title carries!): the@objectstack/dogfood^...closure was built, thenpnpm --filter @objectstack/dogfood testran under the verify lock. VERDICT command-exit 0:Test Files 482 passed | 3 skipped (485),Tests 4093 passed | 68 skipped (4161). No line of the run's log carries the new refusal's text.Local gate families at 821e683: 70 derived, 69 run green, 1 not measured
node scripts/pm/dispatch-gates.mjs --commandsderived 70 families from this diff.--ranreconciliation:70 derived famil(ies) accounted for — 69 run, 1 NOT-MEASURED.check:dual-build-cjs-loadsexits 3 (PREREQUISITE NOT MET) because it reads the built output of every package, and this checkout built only the dogfood closure. CI'sBuild Corejob runs it.Generated by Claude Code