Skip to content

fix(driver-sql): boot converges legacy text booleans on SQLite to 1 / 0 - #35076

Merged
objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/issue-34973-boolean-text-backfill
Nov 18, 2026
Merged

objectstack-fleet[bot] merged 10 commits into
mainfrom
claude/issue-34973-boolean-text-backfill

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

Requested by Yibo Wang · project thread
repo:objectstack#3 · os-support-ai · session_01WGufzg2evNa1V3zxrQq3KX

Closes #34973

Clause-②: yes (widening: @objectstack/driver-sql exports PendingSchemaWorkKind from its index, and the CLI consumes it, so the union gains one published value, normalize_boolean_storage; boolean filters, sorts and groupBy on SQLite now answer legacy text rows as their boolean)
Metadata-protocol: none

维护者速读

  • 改了什么:SQLite 上布尔/开关字段里旧版本留下的文本 'true' / 'false',启动时的 schema sync 会把它们改写成 1 / 0(第四个存储收敛步骤,和 datetime、time、JSON 回填并列);os migrate plan 会把这一步列成 normalize_boolean_storage 并给出行数。
  • 为什么改:这些旧行读出来是对的布尔值,但筛选 = false、$in、!=、$nin、排序和分组都拿原始文本去比,结果漏行或分错组(文本 'false' 在分组里显示成 true)。
  • 风险与回滚:每列一条带守卫的 UPDATE,只改这两个文本拼法,其他文本只计数和告警、绝不改写;第二次启动改写 0 行。没有回滚步骤,因为改写后语义不变,撤回只会恢复有缺陷的形态;回滚代码即可停止该步骤,已改写的行无需还原。
  • 先看:packages/drivers/driver-sql/src/sql-driver-schema-sync.ts(backfillCanonicalBooleans 的计数/采样/UPDATE 与 previewBooleanConvergence)、packages/drivers/driver-sql/src/sql-driver-rotation.ts(initObjects 里新增的一次调用)、packages/cli/src/utils/schema-migrate.ts(摘要行措辞)。
  • 两分钟验证:pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-34916-boolean-text-read.test.ts,预期 23 个测试全部通过。
  • 需要你做的:无,席位落地(L1-d 后由席位做 L2 契约复审)。

Premise (measured, wider than filed)

Measured on origin/main 4443014630c in the premise report on #34973 and restated in the claim amendment; nothing here goes beyond those measurements.

  • Only SQLite can hold text booleans, and only as 'true' / 'false': the column's NUMERIC affinity folds the text '1' / '0' into integers and keeps 'true' / 'false' as TEXT. Postgres, MSSQL, MySQL and Oracle coerce or refuse the text (code reading; no rig in this container).
  • The card named = only. On those rows =, $in, != and $nin all answer wrongly at the driver, the engine and the REST door; ORDER BY sorts them after every integer; aggregate groupBy presents a text 'false' as true.
  • The engine cannot address the rows (a read presents them as booleans, and a 'false' comparand narrows to false), so the fix is raw SQL in the driver.

What changes

  • sql-driver-schema-sync.ts: backfillCanonicalBooleans, the fourth driver storage convergence. SQLite only, for an existing table's scalar Field.boolean / Field.toggle columns. Per column: one counting scan over the column's text cells sorts them into legacy 'true' / 'false' and other text. Only when the scan finds legacy text does the step take an id sample (up to 5) and run ONE UPDATE … set col = case col when 'true' then 1 when 'false' then 0 end where typeof(col) = 'text' and col in ('true', 'false'). The count, the sample, the UPDATE and the preview all read one shared predicate (SQLITE_LEGACY_BOOLEAN_TEXT). Failures are logged at warn and swallowed, the same as the sibling backfills, so the next boot tries again.
  • sql-driver-schema-sync.ts: previewBooleanConvergence, called from previewDeferredSchemaWork. It counts the same predicate and reports { kind: 'normalize_boolean_storage', columns, rows }.
  • sql-driver-rotation.ts: one call beside the datetime, time and JSON backfills in initObjects, plus the host Pick. sql-driver.ts: the two host stubs (pointer docblocks only, because the facade sits under its line ceiling).
  • schema-drift.ts: PendingSchemaWorkKind gains normalize_boolean_storage, which counts as in place under the existing isInPlaceSchemaWork rule.
  • packages/cli/src/utils/schema-migrate.ts: the os migrate plan / apply summary read N temporal column(s) to converge in place, so with this change a boolean column would have been counted as temporal. It now reads N column(s) to converge in place. The amendment expected no CLI change, because the renderer itself is generic, and it is; the summary label was the one word that would have become false.
  • content/docs/deployment/cli.mdx: one example line and one paragraph for the new kind. A root changeset (driver-sql and cli, patch).

Record and reversibility

The seat ruling (22:57Z), quoted from the claim amendment:

route (a) is approved. backfillCanonicalBooleans becomes the fourth driver storage convergence, beside the datetime, time and JSON backfills: one guarded idempotent UPDATE per column, normalize_boolean_storage previewed under deferred DDL, non-canonical text withheld and warned. (1) Record: follow the convention, a count plus a capped id sample with no down step. Your reason holds, since an undo would only restore the broken form.

Dry-run path

  • os migrate plan (deferred DDL) lists the step in place as normalize_boolean_storage: COLUMNS — N row update(s) and writes nothing. The count is the one the step would convert, never the withheld rows.
  • os migrate apply runs it after the confirmation, via the flush, which calls initObjects.
  • An ordinary boot runs it automatically. OS_SKIP_SCHEMA_SYNC=1 skips it, because that boot takes the DDL-free registerObjectMetadata door (registerSchemasWithoutDdl in the objectql plugin), which reaches no backfill.

Pins and ablations

The pins live in packages/drivers/driver-sql/src/sql-driver-34916-boolean-text-read.test.ts (three [#34973] describes) and packages/cli/src/utils/schema-migrate.pending-render.test.ts.

Pin Ablation A: backfill call removed Ablation B: preview wiring removed
before the step, = false / = true miss the text rows green (measures the defect) green
after initObjects, = finds them (toggle too) red green
$in, $ne, $nin: wrong before, right after red green
ORDER BY: text after integers before, sorted with its boolean after red green
aggregate groupBy: 5 groups (text 'false' as true) before, 3 after red green
info record: rowsConverted + sampleIds per field red green
second boot: first boot converted, second sends no converting UPDATE and logs nothing red green
skipSchemaSync (registerObjectMetadata) leaves the text rows untouched green (by design) green
other text withheld, warned once with the count red green
plan counts only the convertible rows, never the withheld green red
plan previews normalize_boolean_storage with its count, in place, and writes nothing green red
apply (flush) converges, and a re-plan finds none red green
CLI renders deal [normalize_boolean_storage: won — 3 row update(s)] in place n/a n/a

Ablation C, CLI summary wording (column(s) put back to temporal column(s)): summarizePendingSchemaWork … never omits in-place work went red (Expected: "6 column(s) to converge in place"). The 12 other tests stayed green.

All three ablations went through scripts/ablation-replace.mjs in WRAP mode, plus an outer EXIT/INT/TERM trap, and the tests import src/ directly (no dist/, so no rebuild leg). Each one was restored by blob:

Ablation evidence
[A] packages/drivers/driver-sql/src/sql-driver-rotation.ts
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 73fd7d438313 -> d791326b4a93
      Tests  8 failed | 13 passed (21)
ablation-replace: ok restored: blob == HEAD (73fd7d438313) and `git diff HEAD` is empty

[B] packages/drivers/driver-sql/src/sql-driver-schema-sync.ts
ablation-replace: ok mutation landed: anchor 1 -> 0, blob d320ed4deab3 -> 4b98e620a0c0
      Tests  2 failed | 19 passed (21)
ablation-replace: ok restored: blob == HEAD (d320ed4deab3) and `git diff HEAD` is empty

[C] packages/cli/src/utils/schema-migrate.ts
ablation-replace: ok mutation landed: anchor 1 -> 0, blob 4a7a238ffc0d -> 90cfcf1b699a
      Tests  1 failed | 12 passed (13)
ablation-replace: ok restored: blob == HEAD (4a7a238ffc0d) and `git diff HEAD` is empty

Tests

All readings from the worktree objectstack-issue-34973, after merging origin/main 367e324eeb4 and rebuilding the cli closure (turbo run build --filter='@objectstack/cli^...' --filter=@objectstack/cli, 64/64 tasks).

  • driver-sql pin file at 383a794b4fd: Tests 21 passed (21). 30bcd609ea0 touches only the cli test.
  • pnpm --filter @objectstack/driver-sql typecheck && vitest run at 383a794b4fd: Test Files 260 passed | 13 skipped (273), Tests 4366 passed | 251 skipped (4617), VERDICT command-exit 0.
  • pnpm --filter @objectstack/cli typecheck && vitest run --project unit at 383a794b4fd: Test Files 426 passed (426), Tests 6057 passed (6057), VERDICT command-exit 0.
  • At 30bcd609ea0: cli typecheck exit 0 (check:test-typecheck: OK). The pending-render, lazy-driver-import and tier-partition files: Tests 38 passed (38).
  • The cli integration layer is declared to CI: the diff touches no integration file and no spawn entry.

Acceptance notes

  • The skipSchemaSync pin works at the driver: it calls the door the objectql plugin uses for that boot (registerObjectMetadata), and does not boot the plugin. It stays green under ablation A by design.
  • Postgres, MySQL, MSSQL and Oracle were not measured live (no rig here). That they cannot hold the text comes from code reading, recorded in the premise report.
  • At every boot, a converged column costs one counting scan over its text cells. That is the same order of cost as the sibling datetime backfill's guard count.

Verification

Delta round (head db8bdd734bd, after seat L2 PASS 6966769750)

  • c26c7d7551a, docs, folds seat should-fix 2: the closing sentence in cli.mdx now names all three in-place steps. It says only the MySQL widen is a table rebuild.
  • dcbecc37966 merges origin/main (K = 17). overlap-check gives VERDICT clean exit 0 against origin/main and feat(cli): os skills install, update and status at the server's version, with or without a project #35060, fix(spec,metadata-protocol)!: retire the seed modes insert and replace, which inserted every record again on each replay #34791 and fix(auth)!: a server outside development mode refuses a development seed credential #34717.
  • db8bdd734bd folds seat nits 3, 4 and 5:
    • The withheld count excludes the canonical text '1' / '0' that a TEXT-affinity column stores.
    • rowsConverted falls back to the counted rows when a client's raw UPDATE reports no changes (driver-sqlite-wasm, knex sqlite3).
    • The PendingSchemaWork.rows docblock names normalize_boolean_storage.
  • Two new pins:
    • A TEXT-affinity column: '1' / '0' are not withheld, and the legacy 'true' still converges. Ablation 3 puts the withheld formula back to text_rows - legacy: Tests 1 failed | 22 passed (23).
    • A client with no changes: the record carries the counted rows. Ablation 4 puts the fallback back to 0: Tests 1 failed | 22 passed (23).
    • Each ablation was restored by copying the file back.
  • Readings at db8bdd734bd: the pin file shows Tests 23 passed (23), and driver-sql tsc --noEmit exits 0. The full driver-sql suite was not re-run locally; CI's Test Core carries it.
  • Reviews: L1 delta ACCEPT 6966877056, and the seat delta L2 PASS 6967050006 carries the PASS forward. Seat should-fix 1 (the Turso remote face) went to triage as a follow-up.

Generated by Claude Code

backfillCanonicalBooleans, the fourth schema-sync storage convergence
beside the datetime, time and JSON backfills: one guarded UPDATE per
boolean/toggle column turns the text 'true' / 'false' into 1 / 0,
withholds and warns on any other text, and logs the rows converted with
a capped id sample. previewBooleanConvergence lists it under deferred
DDL as normalize_boolean_storage.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX
…e per boot

One counting scan classifies a boolean column's text cells as legacy
'true' / 'false' or other text; the id sample and the UPDATE run only when
it found legacy text. The pins now measure $in, $ne and $nin before the
step too, and count the UPDATEs a second boot sends.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX
… during collection

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 18, 2026
@github-actions

github-actions Bot commented Nov 18, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/cli, @objectstack/driver-sql, touching 49 documentable anchor(s).

10 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/data-modeling/drivers.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/data-modeling/index.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/data-modeling/queries.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/deployment/cli.mdx (via normalize_boolean_storage (literal, a string literal in PendingSchemaWorkKind; a string literal in previewBooleanConvergence))
  • content/docs/permissions/tenant-audit-census.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/plugins/packages.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/protocol/kernel/index.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/protocol/kernel/lifecycle.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/protocol/objectql/query-syntax.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/protocol/objectql/types.mdx (via SqlDriver (symbol, a top-level class))

⛔ 5 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/releases/v17/17-5.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/releases/v17/17-6.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/releases/v18/18-1.mdx (via SqlDriver (symbol, a top-level class))
  • content/docs/releases/v18/18-5.mdx (via SqlDriver (symbol, a top-level class))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 47 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json a3e216efae9480c2434f1cca746eacc14f366dd3 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 4e66167446e55b026c05a38444350c92fb09d271 — the merge of head db8bdd734bdde0f3e0f08ceb71d6e71b8261b259 into base a3e216efae9480c2434f1cca746eacc14f366dd3, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 4e66167446e55b026c05a38444350c92fb09d271 && git checkout 4e66167446e55b026c05a38444350c92fb09d271
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin a3e216efae9480c2434f1cca746eacc14f366dd3 db8bdd734bdde0f3e0f08ceb71d6e71b8261b259 && git checkout -B drift-repro a3e216efae9480c2434f1cca746eacc14f366dd3 && git merge --no-ff db8bdd734bdde0f3e0f08ceb71d6e71b8261b259

node scripts/docs-audit/affected-docs.mjs --json a3e216efae9480c2434f1cca746eacc14f366dd3

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs a3e216efae9480c2434f1cca746eacc14f366dd3 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa

L1 review — #35076 (#34973 boolean text backfill) · 2026-11-18T01:52Z

L1: ACCEPT
Head-sha: 30bcd60

Surface. All 9 files are inside the claim surface: amendment 6963450544 covers the driver-sql files, pins, changeset and cli.mdx; amendment 6966556044 covers the one-word schema-migrate.ts change and the pending-render test with its module-top imports. Not governed (check-governed-merges --branch), 511 changed lines.

Route (a), as ruled, checked in the code:

  • backfillCanonicalBooleans is SQLite-only and skips tables created in this call. It runs one counting scan per column, then the id sample and ONE UPDATE only when legacy text exists. The UPDATE's WHERE is the shared SQLITE_LEGACY_BOOLEAN_TEXT predicate (typeof = 'text' and in ('true','false'), BINARY collation), so a converged column is a no-op and 'TRUE' / 'yes' are never selected. The case writes only 1 / 0.
  • Other text is counted as text_rows - legacy and warned once per column with rowsWithheld. Failures are logged and swallowed, like the sibling backfills, so boot is never taken down.
  • The record is an info line with { table, field, rowsConverted, sampleIds }, with at most 5 ids (order by id limit 5, the MAX_SAMPLE_IDS cap). There is no down step, which matches the seat ruling.
  • previewBooleanConvergence counts with the same predicate, so the plan names exactly the rows apply converts. It writes nothing and is wired into previewDeferredSchemaWork beside the datetime and time previews. normalize_boolean_storage joins PendingSchemaWorkKind and counts as in place.
  • The rotation call sits beside backfillCanonicalJsonEncoding in initObjects. Host wiring is added on all three hosts (RotationHost, SchemaSyncHost, the SqlDriver stubs).
  • (res as any)?.changes is the idiom the datetime and time backfills already use (schema-sync L1852 and L2007).

Pins and ablations. 12 driver cases cover: before and after for =, $in, $ne, $nin, ORDER BY and groupBy; the info record; idempotence, which counts the UPDATEs a second boot sends and requires the first boot to have converted (tightened in 383a794 after ablation A left it green); skipSchemaSync; withheld-and-warned; the plan counting only convertible rows; preview-writes-nothing; and apply then re-plan returning []. Ablations A (call removed: 8 red), B (preview wiring removed: 2 red) and C (cli wording: 1 red) all restored to HEAD. They ran at 383a794. The only commit after that, 30bcd60, adds bare imports to the cli test.

Clause-②: yes (widening …) is declared in the changeset: the exported PendingSchemaWorkKind union gains a value, and boolean filters, sorts and groups now answer legacy rows. Metadata-protocol: none is correct. No live reading is needed: this is a driver storage change, pinned against a real SQLite.

Must-fix: none.

Should-fix (optional, no re-review needed):

  1. In content/docs/deployment/cli.mdx, the new boolean sentence sits right before "Both are safe to apply — the convergence preserves every stored instant and is idempotent". That paragraph now reads as if the boolean step preserves instants. A clause such as "(the boolean step rewrites only the two canonical spellings and is idempotent too)" would keep the claim accurate.

Notes:

  • The withheld path has no ablation of its own. Its pin asserts the odd rows are byte-identical after boot, and the predicate is shared with the counted path, so I accept it as is.
  • CI at review time: 16 success, 15 skipped, 21 in progress. Landing waits on all checks being green.

Landing: seat L2 on the driver contract next, then ordinary queue landing (not Tier H).

L1 should-fix on the boolean text backfill: the sentence after the boolean
paragraph read as if that step preserved stored instants.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa

L1 delta review — #35076 · 2026-11-18T01:53Z

L1: ACCEPT
Head-sha: 0a0c918

Delta from the accepted head 30bcd60 (6966602987): one docs-only commit, 0a0c918. It changes content/docs/deployment/cli.mdx by +3 / -2, a file already in the claim surface. It closes my optional should-fix 1. The "Both are safe to apply" sentence now names the boolean step separately ("rewrites only the two canonical spellings"), and the instant-preservation claim no longer reads as covering it. There is no code, pin or changeset change, so the earlier pins and ablations stand.

Must-fix: none. Should-fix: none.

Landing: unchanged. Seat L2 on the driver contract next, then ordinary queue landing (not Tier H) once every check is green on this head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head 0a0c9183226c79f4bb904617539fb48de53711e0 · 2026-11-18T01:54Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract review

Served-tier: TIER_DEFAULT
Head-sha: 0a0c9183226c79f4bb904617539fb48de53711e0
Local-runs: none

Inputs: card #34973 (body; comments 6961931895, 6963136422, 6963386869 premise, 6963450544 amendment with the seat ruling, 6966532536 build report, 6966556044 amendment), PR #35076 (body, 9 files, net diff from merge base 367e324ee to this head), and the check-runs on this head. Not governed (0 of 9 paths), 511 lines. This is the declaration face (Clause-②: yes (widening …) alone), so there is no ④.

Check-runs on this head at 02:00Z: 21 success, 15 skipped, 16 in progress, 0 failure. Green so far: Check Changeset, Governed Surface Queue Guard, PR-body guards, Spec property liveness, Type Check · source gates, Lint · ESLint, Lint · docs & code guards, Lint · repo & tooling gates, Build Docs, Dogfood Regression Gate. Still running: Test Core 1–10/10, Build Core, Type Check · workspace / consumer gates / debt ledger, Lint · CI, release & engine gates, Live E2E UI. This record judges the contract. It does not stand in for those runs: landing waits for every one of them to be green on this head. check:type-check-debt, which the dev could not measure locally (lock timeout), runs in CI as Type Check · debt ledger.

① Derived judgments

The predicate converts the legacy spellings and nothing else. Right.

  • SQLITE_LEGACY_BOOLEAN_TEXT reads typeof(col) = 'text' and col in ('true', 'false'). The count, the id sample, the UPDATE and the preview all use this one string (sql-driver-schema-sync.ts), so the plan cannot count a row the step will not convert.
  • IN compares with BINARY collation, and a knex boolean column has no COLLATE. So 'TRUE', 'yes' and ' true' are not selected. The case col when 'true' then 1 when 'false' then 0 end has no else arm, and the WHERE guarantees one of its two arms matches, so it never writes NULL.
  • Integers, NULL, REAL and BLOB fail the typeof guard and are never touched.
  • SQLite affinity: knex's declared type boolean takes NUMERIC affinity. A text '1' / '0' is folded to an integer on write, and 'true' / 'false' stays TEXT. So in a column sync built, those are the only two legacy text forms. The 1 / 0 the UPDATE writes is stored as an integer, so a second boot selects nothing.

Dialects. Right.

  • Both backfillCanonicalBooleans and previewBooleanConvergence return before any SQL unless isSqlite. On Postgres, MySQL, MSSQL and Oracle, typeof() is never emitted, so a native boolean / tinyint(1) / bit / number(1) column gets no UPDATE and cannot raise a type error.
  • On SQLite, a column that already holds only integers costs one counting scan and no UPDATE. The idempotence pin checks this: the second boot sends no UPDATE carrying 'true' and leaves the stored types unchanged.
  • Turso local / embedded-replica and driver-sqlite-wasm inherit initObjects, so they converge too. The Turso remote face does not; see should-fix 1.

Scope of columns. Right.

  • booleanFields[table] is rebuilt on each registration from scalar boolean / toggle fields only (registerManagedObjectMetadata, sql-driver-rotation.ts, around line 333). A multiple: true boolean is a JSON column and is excluded, so the set is disjoint from the JSON, datetime and time backfills' columns.
  • Every managed table it reaches has an id column, which the sample's order by id needs. A table keyed by _id without id is refused or rebuilt earlier in initObjects, before the backfill.
  • Rotation tables continue before the backfills, as they do for the siblings.

Ordering and idempotence of the three existing convergences. Preserved.

  • The new call sits after backfillCanonicalJsonEncoding and before the two MySQL widenings, gated on the same exists. None of the existing calls was moved or changed.
  • The column sets are disjoint, so the order between the four cannot change any result.
  • A table created in this call is skipped, as in the siblings.
  • Under deferred DDL, initObjects stops at its continue before any backfill. flushDeferredSchemaDdl clears the deferral and re-enters, so apply converges. Pins cover the plan writing nothing, apply converging, and a re-plan returning [].

The skip-schema-sync door. Right.

The record leaks no field value. Right.

  • The info meta is { table, field, rowsConverted, sampleIds }. sampleIds holds up to 5 String(id), taken with order by id limit 5.
  • The warn meta is { table, field, rowsWithheld }.
  • The catch logs only err.message. The SQL it can echo contains only the literals 'true' / 'false', never a cell value.
  • No down step, as the seat ruled.

SQL push-down. Right. The count, sample, UPDATE and preview are each one SQL statement per column. No ids are pulled into the app to drive a write, and there is no in-app join. The 5 sampled ids exist only for the log line.

Public surface.

  • PendingSchemaWorkKind (exported from the @objectstack/driver-sql index) gains normalize_boolean_storage, and isInPlaceSchemaWork classes it as in place by its existing rule.
  • SqlDriver gains two protected methods. They do not enter keyof SqlDriver, so the Turso face map (satisfies Record<keyof SqlDriver, …>) is unaffected.
  • sql-driver-schema-sync.ts is not re-exported.
  • The CLI renders the new kind as a row-update count, since only widen_* reads "table rebuild". summarizePendingSchemaWork drops the word "temporal". That word was also already wrong for rename_columns and rebuild_table entries, which this fix corrects too.

The docs match the code on substance, with one wording fault.

  • cli.mdx: "rewrites only the two canonical spellings" matches the predicate. "Any other text … is left as stored and reported in the log" matches the warn. The plan example line matches the renderer.
  • The amended closing sentence does not resolve; see should-fix 2.
  • The changeset's claims (SQLite only, one guarded UPDATE, other text never rewritten, info record with up to five ids, no down step, plan and apply, skip) all match the code.

② Semver level

  • '@objectstack/driver-sql': patch and '@objectstack/cli': patch are right. AGENTS.md (Post-Task Checklist 3): Metadata-protocol: none takes patch, and a non-protocol widening ships patch. The precedent is 6990b0d (driver-sql 18.4.0, Patch Changes), which added rebuild_table / refuse_table to this same union under Clause-②: yes (widening). No spec file is touched, so Metadata-protocol: none is right.
  • Clause-②: yes (widening …), word for word in the PR body and the changeset, is right:

③ Boundary flags

Open questions (premise 6963386869).

  • (1) The record shape: the seat ruled A (count plus a capped id sample, no down step), and the code does that.
  • (2) A canonicalBooleanFields certificate: no explicit ruling is quoted, and the code took the recommended A (none). Answered: right. Unlike needsLegacyDatetimeRepair, no read-side repair exists for a certificate to retire, so nothing would read it.
  • The build report's open_questions is [].

Dev deviations (6966532536), each answered.

  • The schema-migrate.ts one-word change outside the first surface: covered by amendment 6966556044, pinned, and ablated (C). Right.
  • The 7 module-top side-effect imports in the pending-render test: this is the remedy check:test-source-alias prints. They import no value, so the file stays in the unit tier. Accept.
  • check:type-check-debt not measured locally: CI carries it (still running, see the head of this record).
  • The HTML comments, "Closes", and the merge commit without trailers: process items with no effect on the contract. PR-body guards are green.

Out-of-scope findings from the premise:

  • driver-memory persistence and MySQL non-strict mode were noted, not filed, and stay outside this card.
  • The groupBy and ORDER BY misreads are folded here and pinned.

Findings:

  • should-fix 1 (follow-up, not blocking): the Turso remote face is not covered, and that is unmeasured.

    • TursoDriver answers initObjects: 'remote' (packages/drivers/driver-turso/src/turso-driver.ts:1106), so on the libSQL remote face this convergence never runs.
    • The remote transport declares a boolean column INTEGER (remote-transport.ts:2944), and that affinity also keeps the text 'true' / 'false' as TEXT.
    • The temporal and JSON convergences each needed a remote twin (remote-canonical-backfill.ts, remote-codec-residue-backfill.ts).
    • The premise lists Postgres, MSSQL, MySQL and Oracle as unable to hold the text, but says nothing about remote libSQL. Whether pre-fix(objectql,driver-sql): a boolean field given 'true' / 'false' stores the boolean, and a stored text 'false' reads as false #34965 remote writes stored the text was not measured.
    • Ask: the area files a follow-up card to measure the remote face and, if text rows exist there, to add a remote twin. Outside this diff and this card's stated "SQL driver" scope, so it does not block this PR.
  • should-fix 2 (docs wording, fold any time, no re-review): the closing sentence in content/docs/deployment/cli.mdx no longer resolves.

    • It reads "Both are safe to apply — the convergence preserves every stored instant, the boolean step rewrites only the two canonical spellings, and both are idempotent — but only the second takes time proportional to your data".
    • "Both" and "the second" meant normalize_datetime_storage and the MySQL widen_datetime_columns. The paragraph now names three steps, so a reader can take "the second" to mean the boolean step.
    • The boolean claims themselves are accurate. Name the MySQL widen explicitly (for example "All three are safe … only the MySQL widen is a table rebuild").
  • nit 3: the withheld count assumes NUMERIC affinity.

    • Changing a field's type to boolean from a text type is not migrated by the drift path, so the column keeps TEXT affinity. There, the canonical 1 / 0 the driver writes is stored as the text '1' / '0'.
    • withheld = text_rows - legacy counts those rows. The warn fires on every boot, overstates rowsWithheld, and says filters miss rows that they match.
    • Data is never written wrongly: in that column the UPDATE's result is stored as '1' / '0' and stays idempotent. Excluding '1' / '0' from the withheld count would fix it.
  • nit 4: rowsConverted reads res.changes, the same idiom as the time and datetime backfills.

    • A raw statement on the driver-sqlite-wasm dialect goes down the row-returning branch (knex-wasm-dialect.ts:102, :253–:271), so changes is absent. I read the knex sqlite3 client's raw path as the same.
    • The UPDATE still runs, but converted is 0, so the info record is not emitted.
    • Falling back to the counted legacy would keep the record on those clients. The pinned client, better-sqlite3, is unaffected.
  • nit 5: the rows docblock on PendingSchemaWork (schema-drift.ts:364) still names only normalize_datetime_storage among the row-update kinds.

No must-fix. The pins match the claim: 12 driver cases plus the CLI render and summary. They cover before and after for =, $in, $ne, $nin, ORDER BY and groupBy, plus the info record, the second-boot UPDATE count, the skip door, withheld-and-warned, preview, and apply then re-plan. Ablations A, B and C went red where claimed and were restored by blob. The one later commit before this head (0a0c918) changes docs only.

Implemented-by: claude/issue-34973-boolean-text-backfill
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

…y columns and change-less clients

The withheld count no longer counts the canonical text '1' / '0' a
TEXT-affinity column stores for the driver's own 1 / 0, and
rowsConverted falls back to the counted rows when a client's raw
UPDATE reports no changes (driver-sqlite-wasm, knex sqlite3). The
PendingSchemaWork rows docblock names normalize_boolean_storage.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WGufzg2evNa1V3zxrQq3KX
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgQsdnyS4QdR8stjDa

L1 delta review — #35076 · 2026-11-18T02:09Z

L1: ACCEPT
Head-sha: db8bdd7

Delta from my ACCEPT on 0a0c918 (6966622908) and seat L2 PASS (6966769750) on the same head. Three commits:

  • c26c7d7 (docs, folds seat should-fix 2): the cli.mdx closing sentence now names all three in-place steps, each with its own claim. It no longer points at a "second" step that the inserted paragraph had displaced.
  • dcbecc3 (merge of origin/main): merge-only. The sorted ^[-+] lines of the PR against its own merge base are identical before and after the merge, except for c26c7d7's docs lines. Main's changes come in untouched.
  • db8bdd7 (seat nits 3, 4, 5). All three files are in the claim surface (schema-sync, schema-drift docblock, the boolean pin file):
    • Nit 3: the tally scan also counts ?? in ('1','0') text as canonical, and withheld is now text_rows - legacy - canonical. A TEXT-affinity column holding the driver's own '1' / '0' no longer gets a false warn. That text already reads as its boolean, because the TEXT-affinity comparison coerces the integer operand. The UPDATE predicate is unchanged ('true' / 'false' only), so nothing new is written.
    • Nit 4: rowsConverted uses res.changes when it is a number, and otherwise the counted legacy. That is exactly the set the guarded UPDATE selects, so the fallback cannot over-report.
    • Nit 5: the PendingSchemaWork.rows docblock names normalize_boolean_storage.
    • Two new pins: a real flag text table with canonical, legacy and odd text, asserting no unconverted warn and the converged record; and a raw path that reports no changes, asserting the record carries the counted rows. Each was ablated red and restored, per the requester.

Must-fix: none. Should-fix: none from L1. Seat should-fix 1, the Turso remote face, stays a follow-up, as the seat filed it.

Notes: CI at review time showed 8 success, 15 skipped, 19 in progress. Landing waits on all checks being green on this head.

Landing: the seat L2 PASS was on 0a0c918. The delta since then is the seat's own should-fix and nits plus a clean merge, so the seat decides whether its L2 carries forward. After that, ordinary queue landing (not Tier H).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract-review-claim: session_01WGufzgh1zkZzDXL36ckWAG · head db8bdd734bdde0f3e0f08ceb71d6e71b8261b259 · 2026-11-18T02:14Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzgh1zkZzDXL36ckWAG

Contract review

Served-tier: TIER_DEFAULT
Head-sha: db8bdd734bdde0f3e0f08ceb71d6e71b8261b259
Local-runs: none

This is a delta review. It follows my PASS on 0a0c9183 (6966769750) and covers 0a0c9183..db8bdd73.

Inputs:

The face is unchanged. The delta adds no published schema and no governed path, and the PR still carries only Clause-②: yes (widening …). So this is the declaration face, with no ④.

What the delta is. Three commits:

  • c26c7d75: docs, cli.mdx +4 / -3.
  • dcbecc37: a merge of origin/main a3e216efae.
  • db8bdd73: three files (sql-driver-schema-sync.ts, the schema-drift.ts docblock, and the boolean pin file).

The merge is clean. I compared the sorted + / - lines of the two net diffs. The only differences are the hunks of c26c7d75 and db8bdd73. The changeset, sql-driver.ts, sql-driver-rotation.ts, schema-migrate.ts and its test are byte-identical in the PR's net diff at both heads. On the PR's own files, main touched only one line of cli.mdx (author-time rules (70) → (71), line 890). That line is far from the PR's hunk, and the PR leaves it as main has it.

Check-runs on this head (read 02:17Z): 27 success, 15 skipped, 11 in progress, 0 failure.

  • Green: Build Core, Check Changeset, Governed Surface Queue Guard, PR-body guards, Spec property liveness, Type Check · source gates / consumer gates / debt ledger, every Lint job (ESLint, CI, release & engine gates, docs & code guards, repo & tooling gates, PM dispatch-gates, three scoped), Build Docs, Dogfood Regression Gate, Live E2E UI and Test UI.
  • Type Check · debt ledger is now green. That was the one family the dev could not measure locally.
  • Still running: Test Core 1–10/10 and Type Check · workspace. Test Core runs the driver pins, including the two new ones.
  • This record judges the contract. Landing still waits until every check-run on this head is green.

① Derived judgments

Nit 3 fold (TEXT-affinity '1' / '0' no longer counted as withheld). Right, and nothing broke.

  • The tally scan gains one column: coalesce(sum(case when ?? in ('1', '0') then 1 else 0 end), 0) as canonical.
  • It runs inside the scan's existing where typeof(??) = 'text'. Only text '1' / '0' is counted, compared with BINARY collation, so ' 1', '1.0' and 'TRUE' stay withheld.
  • The bindings went from 4 to 5 ([field, field, field, table, field]). The count matches the placeholders: two in SQLITE_LEGACY_BOOLEAN_TEXT, one in the new sum, then the table, then typeof(??).
  • withheld = text_rows - legacy - canonical.
  • Real 'true' / 'false' still converts. The legacy sum, the id sample, the UPDATE and previewBooleanConvergence all still read the unchanged SQLITE_LEGACY_BOOLEAN_TEXT (typeof = 'text' and in ('true', 'false')). canonical only feeds the withheld subtraction and gates nothing.
  • '1' / '0' is never rewritten. The UPDATE's WHERE cannot select it.
  • In a TEXT-affinity column, the 1 / 0 the UPDATE writes is stored as '1' / '0'. The next boot counts it as canonical, so the step stays idempotent with no warn.
  • In a NUMERIC-affinity column (every column sync builds), text '1' / '0' cannot exist, so canonical is always 0 there and behaviour is unchanged.
  • The new pin a TEXT-affinity column: … builds a real flag text table holding '1', '0' and 'true'. It asserts:
    • the stored cells end as '1', '0', '1';
    • one converged record with rowsConverted: 1, sampleIds: ['legacy_true'];
    • no unconverted warn.
  • Under the old code, the same scan gives text_rows 3 − legacy 1 = 2 withheld and the warn fires. So the pin discriminates by construction. The claimed ablation evidence is not posted anywhere I read.

Nit 4 fold (rowsConverted when the raw path reports no changes). Right.

  • converted = typeof changes === 'number' ? changes : legacy.
  • legacy was counted with the same predicate the UPDATE uses, a moment earlier, inside one boot's sync. So the fallback reports what the guarded UPDATE selects. It cannot report a row the step did not convert, short of a concurrent writer between the two statements, which is the same bound as the sibling counts.
  • better-sqlite3 keeps reporting changes, so the pinned client's numbers are unchanged.
  • The new pin wraps knex.raw so an UPDATE answers [], the shape returned by the row-returning raw path of driver-sqlite-wasm and knex sqlite3. It asserts both converged records with their counted rows. Under the old ?? 0, no record would have been emitted, so this pin discriminates too.

Nit 5 fold. Right. The PendingSchemaWork.rows docblock (schema-drift.ts:364) names normalize_datetime_storage and normalize_boolean_storage as row-write counts. It is a jsdoc-only change on an exported interface, with no change to the type.

Should-fix 2 fold (cli.mdx closing sentence). Closed.

  • The sentence now reads: "All three are safe to apply — the datetime convergence preserves every stored instant, the boolean step rewrites only the two canonical spellings, and each is idempotent — but only the MySQL widen is a table rebuild whose duration grows with your data."
  • Each claim lands on a named step, and none relies on an ordinal.
  • "Only the MySQL widen is a table rebuild" matches the paragraph above, which describes widen_datetime_columns as the ALTER … MODIFY rebuild.

Should-fix 1 (Turso remote face). Closed to #35084. #35084 is open, priority:p2 · pm:queue · finding · domain:server, and filed by triage from this PR. It asks for a reading on remote Turso, and a remote twin with a pin if one is needed. It cites turso-driver.ts:1106 and remote-transport.ts:2944, as my finding did. Nothing more is owed on this PR.

Public surface in the delta: none. No export, union member or signature changes. The info / warn meta shapes are unchanged ({ table, field, rowsConverted, sampleIds } and { table, field, rowsWithheld }). What changes is only when warn fires (no longer for canonical text) and when info fires (now also on change-less clients). Both are corrections, with no new accepted input and no answer taken away.

SQL push-down: holds. The delta adds one aggregate column to the existing per-column scan. There is no new id materialisation, round trip or in-app join. The fallback reuses a number already counted in SQL.

② Semver level

  • The changeset is unchanged: '@objectstack/driver-sql': patch and '@objectstack/cli': patch. That is still right. The delta publishes a log-condition fix and a jsdoc line on an exported interface, and neither raises the level.
  • The Clause-②: yes (widening …) line is unchanged and word for word the same in the PR body and the changeset. It is still right, as judged in 6966769750. The delta neither narrows nor widens beyond it.
  • Metadata-protocol: none is still right: no spec file is touched.

③ Boundary flags

Findings on this delta:

  • nit 1 (PR body, fold in a body edit, no re-review): the body has not followed the delta.
    • The 速读 line says "预期 21 个测试". The pin file gained two cases (15 → 17 it( blocks in the source), so the body's own count is now 23.
    • The Pins and ablations table, the Tests readings and the Verification section all stop at 383a794b / 30bcd609. The two new pins and their claimed ablations are recorded in no comment on the card or the PR. L1 6966877056 relays them "per the requester".
    • I judged both pins discriminating by reading them against the pre-fold code (①), so this does not affect correctness.
  • nit 2 (note, no action on this PR): the new code comment says canonical text "already reads as its boolean".
    • That holds for the row read (presentStoredBoolean maps '1' / '0').
    • It holds for filters: SQLite applies TEXT affinity to the bound integer comparand. This rests on SQLite's documented comparison rules and is not pinned here.
    • It does not hold for an aggregate group key. presentReadValue's case 'boolean' returns Boolean(value) (sql-driver-filter-helpers.ts:333), so a TEXT-affinity '0' groups as true.
    • That defect exists before this PR, for every canonical write into a TEXT-affinity boolean column, and this PR does not make it worse (Boolean('false') was true too).
    • The column shape comes from a type change the drift path does not migrate, so it is outside this card. Noted, not filed. The seat may route it if it wants the TEXT-affinity shape tracked.
  • nit 3 (note, outside the diff): backfillCanonicalDatetimes and backfillCanonicalTimes keep the (res as any)?.changes ?? 0 idiom. On driver-sqlite-wasm / knex sqlite3, their info record is still dropped. Code outside the diff is read, not reviewed. Noted, not filed.

No must-fix and no should-fix on the delta. The PASS on 0a0c9183 carries forward to this head.

Implemented-by: claude/issue-34973-boolean-text-backfill
Reviewed-by: session_01WGufzgh1zkZzDXL36ckWAG

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#3 · os-support-ai · session_01WGufzg2evNa1V3zxrQq3KX

Landing · 2026-11-18T02:37Z · area o3-A

Probe Reading
check-governed-merges.mjs --pr 35076 NOT governed · 0 of 9 paths · 598 changed lines (+584/−14) ≤ 3000
Reviews on head db8bdd734bdde0f3e0f08ceb71d6e71b8261b259 L1-d delta ACCEPT 6966877056 · seat L2 PASS 6966769750 on 0a0c918, carried forward by delta L2 PASS 6967050006 at this head
Checks on this head 59 check-runs: 42 success, 17 skipped, 0 failing · mergeable_state clean · main 8 first-parent commits ahead (K < 15; main was merged at dcbecc3 when K was 17, overlap clean)

State: pr_ready + automerge_enable now. Closes #34973 closes the card on merge.

Scope: route a under the seat ruling (claim 6963136422, amendments 6963450544 and 6966556044). Clause-② yes (widening: PendingSchemaWorkKind gains normalize_boolean_storage). driver-sql and cli at patch.

Merge standard: no open must-fix or should-fix.

Dev-effort: high · Rounds: 1 premise + 1 build + 1 review fold

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 18, 2026 02:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

data: normalise boolean fields already stored as the text 'true'/'false' (SQL driver), so equality filters find rows written before #34965

2 participants