Repository navigation
fix(driver-turso): remote ADD COLUMN on a populated table adds a storage.notNull column nullable and reports tighten_not_null - #37343
Conversation
…age.notNull column nullable Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011y7As8wf3DSPRevwNnYLcM
…UMN fix Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_011y7As8wf3DSPRevwNnYLcM
📓 Docs Drift CheckThis PR changes 1 package(s): 4 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 — 8 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 a128500eae27f1ee67dfcbe0a6795c41cc19d4ab && git checkout a128500eae27f1ee67dfcbe0a6795c41cc19d4ab
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a182fbe37765ab486f3aa5e372ffa9d6af1f6758 056bae7f5ffdb12c18d6b6943811ebc9d445cb5a && git checkout -B drift-repro a182fbe37765ab486f3aa5e372ffa9d6af1f6758 && git merge --no-ff 056bae7f5ffdb12c18d6b6943811ebc9d445cb5a
node scripts/docs-audit/affected-docs.mjs --json a182fbe37765ab486f3aa5e372ffa9d6af1f6758
|
|
repo:objectstack#7 · os-alice · session_011y7As8wf3DSPRevwNnYLcM
席位意见:ACCEPT,排队落地。 席位核对 — ACCEPT · head 056bae7 (2026-11-25T20:11Z)
|
Requested by Alice · project thread
Fixes #37281
Clause-②: no
Metadata-protocol: none
维护者速读
What changes
RemoteTransport.columnDeclarationSQL(remote-transport.ts) stays the one renderer and takes one more flag,addedToPopulatedTable. When it is set and the field declaresstorage.notNullwith no literal orNOW()default, the column is rendered withoutNOT NULL. This is the same decision the local face'screateColumnmakes (PR fix(driver-sql): a storage.notNull field added to a populated table is added nullable and reported as tighten_not_null #37279).ADD COLUMNdoors ask whether the table holds a row withSELECT 1 FROM "t" LIMIT 1, and only when a column about to be added declaresstorage.notNull(addsNotNullColumn).syncSchemasends one statement.syncSchemasBatchsends ONE extra read batch covering every such table, between the column introspection and the DDL batch. A sync that adds no such column sends nothing extra, so the steady-state round-trip count is unchanged.declaresEmittedColumnDefaultis the remote twin of driver-sql'semitsDeclaredColumnDefault, composed from the same two spec predicates (isNowDefaultToken,isRuntimeDefaultToken) in the same order. It is a twin because driver-sql does not export that predicate and the claimed file surface is driver-turso only. See Acceptance notes.storage.notNull, so the nullable column shows up astighten_not_nullon the remote face's owndetectManagedDrift. Measured: the PM's Zone 2 assumption holds.columnDeclarationSQLsection "ADD COLUMN on a table that already holds rows" is rewritten to thestorage.notNullcontract. The stance "Never drop the NOT NULL" from driver-turso remote face: create table and add column never emit NOT NULL, so storage.notNull is unenforced and every such field reads as destructive drift #23847 now applies only to the literal/NOW()default case, where the local face keeps the constraint. ThesyncSchemasBatchround-trip docblock now counts five possible calls.turso-driver.ts:REMOTE_DRIFT_REPORT_CAVEATand its docblock now also name the populated-table add as a source oftighten_not_nullthis face's own sync produces. Its "the sync creates it now" clause stopped being the whole story after this change. The only pin on it isstringContaining('NOT NULL').Tests
turso-remote-not-null.test.ts, case 4 (the KNOWN ASYMMETRY note is removed). There is adescribe.eachover two defaults that fill no row (none, and thecurrent_usertoken) and anit.eachoverlocal/syncSchemasBatch/syncSchema. Every cell asserts the same answer:plain,addedand multi-valueadded_tagsall havenotnull0, andtighten_not_nullcovers exactlyaddedandadded_tags. A create providing the columns then succeeds and reads back. A new batch cell syncs a populated table and an empty table in onesyncSchemasBatchand checks each answer: the populated table gets nullable plustighten_not_null, and the empty table gets NOT NULL with no drift.Case 5 (RECORDED ASYMMETRY, a literal
defaultValue) is unchanged and still passes: the local face accepts it as NOT NULL, and this face still refuses.Fix at head 056bae7
The typecheck program includes the test file (
tsc --noEmit --listFiles: 1 hit).Ablation (scripts/ablation-replace.mjs): the populated-table guard removed, red, then restored to the HEAD blob
This suite imports
TursoDriverfromsrc/, andremote-transport.tsis reached by a relative import with no packageexportshop, so the mutation needed no rebuild.Acceptance notes
REMOTE_DRIFT_OP_ANSWERS.tighten_not_nullisneeds-table-rebuild(migrate plan on a Turso remote primary: atighten_not_null(and every column entry the remote face cannot apply) is printed with the remedyos migrate apply --allow-destructive, which then names it as not applied and exits 1 #23925), soos migrate apply --allow-destructiveon a remote database names the entry as not applied, anddriftReportCaveatalready says the report is for reading. This is an existing declared limit of the face, and this PR does not widen it. Before this change, the object's sync failed outright.NOW()default on a populated table (case 5). This still refuses on the remote face, because the face emits no declared column DEFAULT. This PR keeps it as case 5 records it, as the card's acceptance asks ("default-carrying fields keepNOT NULL"). Closing it means deciding whether, and from which shared source, the remote face emits declared defaults. If that is owed, it is a separate card for the seat to file.declaresEmittedColumnDefaultrestates driver-sql'semitsDeclaredColumnDefault(4 lines, same spec predicates, same order). The shared form would be to export it from@objectstack/driver-sqland import it here. That is outside the claimed surface and would move driver-sql's published exports, so it is not done here. Thecurrent_usercell of case 4 and case 5 hold the two faces to one answer for the token and literal kinds.Verification
Read first:
remote-transport.tscolumnDeclarationSQL(thenotNullline and its rewritten docblock), then the two call sites insyncSchemaandsyncSchemasBatch(phase 2c), then case 4 ofturso-remote-not-null.test.ts.Two-minute check:
pnpm --filter @objectstack/driver-turso exec vitest run src/turso-remote-not-null.test.ts. Expect 15 passed, with[schema-drift] rows_t.added: metadata declares storage.notNull but the column is nullablelines printed by the remote cells.Gates (head 056bae7)
试行偏离 (maintainer-authorized trial, 2026-11-25): only a local subset ran. It is the driver-turso tests and typecheck above, plus these families. Every other derived family is cited from this PR's CI check-runs. There was no in-session wait on CI.
Local gate readings at 056bae7
pnpm check:type-check-coverageexit 0;pnpm check:type-check-debtexit 0 (surplus: none).pnpm check:doc-authoring,check:issue-citations,check:nul-bytes,check:closed-ceremony-text,check:durability-log-level,check:published-files: all exit 0.check-empty-changeset,check-changeset-no-major,check-adr-0087-registration(--base origin/main): all exit 0.check-platform-checklist --changed-from origin/main: 0 anchored files in the change set, nothing judged.dispatch-gates --ran:72 derived, 11 run, 0 NOT-MEASURED, 61 UNRUN. The 61 are left to CI under the trial.Generated by Claude Code