Skip to content

feat(driver-sql)!: the file family's column holds the bare sys_file id, per deployment (#15989) - #17403

Merged
os-sam merged 6 commits into
mainfrom
claude/issue-15989-file-family-bare-id-column
Sep 10, 2026
Merged

os-sam merged 6 commits into
mainfrom
claude/issue-15989-file-family-bare-id-column

Conversation

@claude

@claude claude Bot commented Sep 10, 2026 •

Copy link
Copy Markdown
Contributor

Part of #15989 — deliberately Part of, not a closing keyword: the column step this card also names is not in this diff, and the half that remains is stated below so the card stays open for it.

Executes the maintainer ruling on #15041 (decision batch #49 item 1), verbatim: 「15041 应该改为实际 id 保存。选A,其他同意」. The physical column for the file family — file / image / avatar / video / audio — holds the actual sys_file id, a bare id string in a string column, not a JSON-quoted id in a JSON column. The SQL generator already emitted VARCHAR(2048) for the family and does not move; the driver is the side that moves, per deployment.

Clause-②: yes — the ruling's own word (published storage behaviour of @objectstack/driver-sql changes). Changeset is minor with a **BREAKING** banner and an ADR-0087 disposition, under the launch-window rule.

What this PR lands

1 · the family leaves JSON_COLUMN_TYPES, and the arm is a per-deployment fact. A single-value media field is a JSON column on a deployment that has not moved its columns and a varchar(2048) on one that has. isJsonField, createColumn, varcharColumnChars and the drift detector all ask the same one question (mediaColumnIsJson). multiple: true media is untouched on both arms — its value is a list of ids, it is a JSON column everywhere, and createColumn decides multiple above its type switch.

2 · the distinguishing mechanism, and why absence is the JSON arm. The addendum forbids keying on the adr-0104-file-references flag alone: every creation-attested store since 17.0 and every earlier os migrate files-to-references --apply run holds that flag and JSON-quoted ids. The evidence is sys_migration.columns_moved_at (landed on #16185), reaching the driver as the new published option SqlDriverConfig.fileColumnsMoved — a boolean or an async resolver, resolved once at initObjects and memoized. Every way of not knowing answers "not moved": omitted, throws, rejects, never runs, or a host that never calls initObjects. Every flag row that exists in the world today lacks the field, so every existing deployment reads "not moved" with no extra logic, which is the direction the addendum requires.

3 · the window reads BOTH encodings, on every dialect. MEASURED on live PostgreSQL 16.13 before this change: a JSON-quoted id in a generator-shaped varchar column read back with its quotes — the corruption #15771 named, alive on any deployment built by os generate migration --format sql and served on a server dialect. formatOutput now decodes a JSON-encoded media cell on all three dialects and on both arms. It is a repair, not a second encoding flip: the write side is unchanged on the JSON arm, and the decode engages only on a leading ", { or [ — none of which can begin a sys_file id, a resolver URL or a data: URI. SQLite never had this defect; its read arm already parsed the cell and kept the raw string on failure, which is why the gap was a server-dialect one.

4 · the drift detector moves with the writer. JSON_COLUMN_FIELD_TYPES no longer names the family, because the family is not a constant on either side of the module cycle any more; diffManagedTable takes a fileColumnsMoved input instead, and omitting it reproduces the previous verdicts exactly — the same intentionally additive posture the varcharColumnChars mirror already takes. Without this the ruled end-state column would be reported as type_mismatch / severity: 'error' with a remedy that converts it back to json, i.e. every migrated deployment told by its own tooling to undo the ruling.

5 · the generator pin is retired to coverage, in the same commit. generate-field-type-vocabulary.pin.test.ts's block labelled 「recorded divergence, NOT coverage」 asserted that the driver DID seed the JSON set from FILE_REFERENCE_TYPES. That is the ruling's own step 3, and it is not optional cleanup: the first edit of deliverable 1 reddens it by design. It now pins the retirement direction — the driver must NOT seed from the family again — with an anti-vacuity control on the neighbouring classes.

The two decisions this card delegates, decided

schema-drift — folded in, and it was not a free choice. #15771 is closed (PR #16073) and its widening already spreads FILE_REFERENCE_TYPES into JSON_COLUMN_FIELD_TYPES, so the ruling's 「fold #15771 in or leave it adjacent」 is moot as written. What replaced it is an obligation: schema-drift.json-column-parity.test.ts holds the differ's JSON-class predicate equal to the writer's, so the moment the writer's answer becomes per-deployment the pin reds by name on those five types. Leaving schema-drift adjacent was therefore not available — the choice was between threading the arm and weakening a good pin. The arm is threaded, and the pin now asserts the agreement on both arms rather than at one point. This answers the question #16184 carries; that card is left open for its own seat to verify and dispose of rather than closed from here.

born-fresh stores — option B, explicitly, and here is the cost. A datastore born after this lands is attested at kernel:ready, after schema sync has already created its media columns, and at sync time no flag exists. The seam between column creation and attestation cannot be closed in this change, and recording a column step that did not happen is the one thing the mechanism must never do. So a born-fresh store starts on the JSON arm and needs one os migrate files-to-references --apply like everyone else. The cost, named rather than left to be discovered: the bare arm has no standing canary — every dogfood boot exercises the legacy arm only, and the bare arm's coverage is the dialect matrix in this PR.

⛔ What this PR does NOT land

The column step itself. os migrate files-to-references --apply does not yet retype or rewrite media columns, and nothing here moves any deployment's storage. That is deliberate, and it is the PM's own sequencing on this card (comment 5556979386: 「the PG/MySQL decode arm → the registry-freeze rework of arm 1 → step 3 with its measured abort」 — this PR is the first two). Two reasons it is not folded in:

  • MEASURED on SQLite: after the columns are converted, a driver still on the JSON arm reads the migrated column correctly but its next write re-quotes. So the column move and the arm flip must be one act, and the arm flip needs a boot-time wiring point (kernel → SqlDriverConfig.fileColumnsMoved) that does not exist yet. Landing the migration without it is exactly the half-migrated storage format the card rules out.
  • The MySQL statement order is the thing the addendum itself leaves unsettled, and MySQL is not reachable from this container (no mysqld/mariadb binary, no docker daemon — dial unix /var/run/docker.sock: no such file or directory). Landing an unrehearsed DDL sequence inside a data migration is the data-loss shape the previous round refused, and the PG half of that same sketch was already measured wrong: ALTER ... USING (col #>> '{}') does not abort on a non-string cell.

Evidence

Dialect coverage, stated rather than implied.

cell how
SQLite measured, every case
PostgreSQL 16.13 measured live — a local cluster started for this run, OS_TEST_POSTGRES_URL wired, database dropped and the server stopped afterwards
MySQL 8.x NOT MEASURED here — no server and no docker daemon in this container. The pins are authored and iterate DIALECT_CELLS, so CI's Temporal Conformance (live PG + MySQL) job carries that cell; a missing URL there is a named skip, never a silent pass

Red before green, in the real direction. Three pins reddened by design before they were updated, each with the real output captured: the JSON-column parity pin (expected [ 'address', 'audio', 'avatar', …(12) ] to deeply equal [ 'address', 'checkboxes', …(8) ]), the CLI vocabulary pin (expected '// Copyright …' to contain '...STRUCTURED_JSON_TYPES, ...FILE_REF…'), and the base-type-mismatch sweep.

Ablations — two, each proved on disk and each restored by bytes. Every leg ran under a trap … EXIT INT TERM with an absolute path, restored with git checkout HEAD -- naming the file, and was verified by git diff HEAD empty plus git hash-object equal to the HEAD blob, with a fixed-string control grep that fires.

  • A · delete the media read repair. Predicted: §3 and §4 red, everything else green. Observed exactly that — 3 failed / 11 passed / 1 skipped. Note §4 reds only on the live-PG cell, which is the recorded fact that the dual-read gap is a server-dialect one.
  • B · the driver ignores the arm (mediaColumnIsJson() always answers "json" — the shape the driver has today, and the one a careless refactor restores). Predicted: the moved-arm cases red on both pin files. Observed 11 failed / 10 passed across both files, including all three arm-aware parity cases.
  • ⚠️ Disclosed rather than quietly re-run: ablation A's own before/after marker grep was written with unescaped brackets (this.mediaFields[object] — a bracket expression to grep), so that reading is void in both directions. The mutation's presence on disk rests on the blob-hash comparison and on the injected marker's grep, which fired (1). Ablation B used grep -F throughout and read 1 → 0 on the original line and 0 → 1 on the plant.

Reverse verification that the consumer reads the rebuilt declaration — because an additive optional field is exactly the shape a cached .d.ts answers the same way twice. In @objectstack/cli's own diffManagedTable call: planting fileColumnsMoved: false typechecks (exit 0, 0 errors); planting the one-character typo fileColumnsMovedX goes red with TS2561 … Did you mean to write 'fileColumnsMoved'?. Both legs restored, git diff HEAD empty, blob equal.

Gates. All 65 families dispatch-gates.mjs --repo objectstack-ai/objectstack derives for this diff were run with their exit codes captured by redirect-then-$?, and reconciled with --ran: 65 accounted for — 65 run, 0 NOT-MEASURED (a DERIVED zero). Three needed their prerequisite met first and were re-run after it (check:dual-build-cjs-loads and check:i18n-coverage after a full pnpm build; check:type-check-debt after raising the heap past an OOM), and check:query-options-erasure caught a real erased options bag in the new pin, which is now typed. pnpm lint — the whole-repo scan, node --stack-size=4000 eslint . --no-inline-config — ran green over 6491 files (0 errors, 0 warnings, count read from --format json) at d76b8ef8c3.

Suites. @objectstack/driver-sql pnpm test: 168 passed / 11 skipped files, 2491 passed / 154 skipped tests. @objectstack/cli --project unit: 192 files, 2667 tests green (two of them needed pnpm --filter @objectstack/cli build first — a PREREQUISITE NOT MET, re-run green after it). typecheck green on both packages. The media pins against live PG: 3 files, 54 passed / 3 skipped.

Docs — measured, and the page needs nothing

content/docs/protocol/objectql/types.mdx:1148 states the file family's stored value unconditionally:

Stored value: an opaque sys_file id string. The expanded read form is the media metadata object, whose only required member is url

Decision: no edit, because that sentence is about the VALUE CONTRACT and this PR does not move it — it makes it MORE true, uniformly. The reasoning, with the two structural facts measured rather than assumed:

  1. The sentence's own subject is the value, in the spec's own vocabulary. 「Stored value」 / 「expanded read form」 is the valueSchemaFor(def, form) pair in packages/spec/src/data/field-value.zod.ts — FileReferenceIdValueSchema for the stored form, the union with FileValueSchema for the expanded one. That contract has been id-only since 17.0, and packages/spec is untouched by this diff.
  2. This page states a physical column through two mechanisms, and the family appears in NEITHER. Measured with a firing control: parsing the page into its twelve ### type sections, location (line 1130) and address (line 1090) carry a **Database mapping:** block and file / image carry none; and the Type Conversion Matrix has no row naming file / image / avatar / video / audio, while the control row json / location / address is present. So the page makes no claim this PR could falsify.
  3. What this PR does to that sentence is repair it. Before this change the sentence was FALSE on one real population — a generator-shaped varchar media column on Postgres or MySQL handed the value back as "file_01HXYZ", quotes included. After it, every dialect and both arms hand back the id. The per-deployment thing is the physical column, which this page does not state for this family.

Adding a flag-window sentence here would introduce a physical-column claim the section does not currently make, in a section whose sibling mechanism for exactly that claim (**Database mapping:**) the family deliberately does not have — and it would need a second edit when the window closes. The legacy direction is already carried, conditionally and correctly, by the callout directly below the sentence.

Spot-check of the two pages that could not appear in an emitter-only diff (they name the family by its type names, sharing no identifier with SqlDriver): content/docs/kernel/contracts/storage-service.mdx is clean — zero hits for column / VARCHAR / stored value, against a control that fires 72 times on types.mdx. content/docs/permissions/attachments-access.mdx is not clean, and the direction is the opposite of the page above: line 19-21 says Field.file / Field.image 「store a file URL in the record's own column」, which ADR-0104 D3 retired — isFileIdToken's own docblock says a URL 「can never match」. Filed as #17406 rather than folded in: touching content/docs pulls the Build Docs job into this PR's check set, a verification surface this diff otherwise does not have.

Acceptance notes

Out-of-scope findings, noted and not filed — each with who would meet it:

Those three were not filed: each lands inside #15989's own remaining deliverable or inside #16184, and filing them separately would duplicate an open card's scope. One finding WAS filed — #17406, the attachments-access.mdx stored-form error above — because it is an error rather than an omission, it is load-bearing on a page whose whole subject is access, and a targeted dedup scan over the 76 open documentation issues found no existing card for it (control term docs: 51 hits, so the zero is a reading).

Authored by Claude Code, session session_01XTBcV7zZHmokdyQgXjbyEU (https://claude.ai/code/session_01XTBcV7zZHmokdyQgXjbyEU) — carried in prose because this PR body's UPDATE channel appends its own footer block and would otherwise leave two.


Generated by Claude Code

… JSON-column parity pin arm-aware

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTBcV7zZHmokdyQgXjbyEU
…asting null away

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTBcV7zZHmokdyQgXjbyEU
…le id, per deployment

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01XTBcV7zZHmokdyQgXjbyEU
@claude claude Bot added the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Sep 10, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/driver-sql, touching 22 documentable anchor(s).

8 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/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))

⛔ 1 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/ 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
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 60 of 215 client-bound route-ledger rows — the other 155 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 155: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 100 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.

Coarse fallback — 10 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 776d64cd3da79e30c8fc87783020e3e52c3a7c28 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 9b2f633d4986cb7d7b0c5282a4690990d695d7c8 — the merge of head d76b8ef8c3d79056b9d67dcf08a9371e858424be into base 776d64cd3da79e30c8fc87783020e3e52c3a7c28, 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 9b2f633d4986cb7d7b0c5282a4690990d695d7c8 && git checkout 9b2f633d4986cb7d7b0c5282a4690990d695d7c8
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 776d64cd3da79e30c8fc87783020e3e52c3a7c28 d76b8ef8c3d79056b9d67dcf08a9371e858424be && git checkout -B drift-repro 776d64cd3da79e30c8fc87783020e3e52c3a7c28 && git merge --no-ff d76b8ef8c3d79056b9d67dcf08a9371e858424be

node scripts/docs-audit/affected-docs.mjs --json 776d64cd3da79e30c8fc87783020e3e52c3a7c28

⚠️ 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 776d64cd3da79e30c8fc87783020e3e52c3a7c28 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@github-actions github-actions Bot added 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 Sep 10, 2026
@claude claude Bot removed the needs:contract-review Marker only — PR awaits its at-tier Contract review PASS; no check reads it, the record decides label Sep 10, 2026
Merged via the queue into main with commit 77c801e Sep 10, 2026
54 checks passed
akarma-synetal pushed a commit to akarma-synetal/framework that referenced this pull request Sep 17, 2026
…and its kernel→driver supply (objectstack-ai#15989) (objectstack-ai#17859)

Fixes objectstack-ai#15989

Clause-②: yes

Step 2 of the maintainer ruling on objectstack-ai#15041, completed. PR objectstack-ai#17403 landed
the encoding half; this lands the two things it named as still owed —
**the kernel→driver supply seam** and **the column step** — under the
director ruling `5643444495` (decision batch objectstack-ai#120 item 1).

## ⛔ The ruling supersedes the card body in two places, and both are
honoured

**1 · Keying.** The card body's "Shape of the change" item 1 says the
wiring is keyed on the `adr-0104-file-references` flag. That is
**overturned**. The arm is keyed on `sys_migration.columns_moved_at`,
and it additionally requires the flag to be verified — never the flag
alone. The reason is measured, not formal: every creation-attested store
since 17.0 holds that flag **and** JSON-quoted ids in a JSON column, so
flag-keying would read every existing deployment as migrated and then
write bare ids into a JSON column.
`adr0104-file-columns-moved-supply.test.ts` pins exactly that row —
verified, unstamped — as "not moved".

**2 · The migration SQL.** The addendum's `USING (col #>> '{}')` is
**not used bare**. It is preceded by the pre-check the dev seat
measured, which aborts on a non-JSON-string cell. See the ablation
below: the superseded form was executed on live PostgreSQL 16.13 in this
PR's own suite, and it does not abort.

⭐ Worth carrying forward, in the card's own words: *"an Execution
paragraph is authoritative about intent, not immune to being wrong about
SQL."*

## The ablation — the single most important measurement here

Both clauses, executed on one fixture (one converted cell, one inline
blob the backfill has not reached), in
`sql-driver-15989-file-column-move.test.ts` §1, on every dialect this
step serves.

| clause | what happened |
|:--|:--|
| **superseded** — `ALTER … TYPE varchar(2048) USING (col #>> '{}')`,
alone | **ACCEPTED**, exit 0, no warning. The column is no longer
`json`, so the unconverted object is now a plain string in a column
whose declared contents are bare ids. |
| **this PR** — the same DDL behind `json_typeof(col) IS DISTINCT FROM
'string'` | pre-check answers **1** ⇒ the step runs **no statement**.
Cells byte-identical, column still `json`. |
| **CONTROL** — the same pre-check on a fixture with no unconverted row
| answers **0** ⇒ the move proceeds, producing bare ids, `NULL`
preserved. So the `1` above is a reading, not a pre-check that always
blocks. |

⚠️ **What is lost differs by dialect, and the PR states the two
separately rather than averaging them.** On PostgreSQL the `json` type
stores its input text verbatim and `#>> '{}'` hands that same text back,
so the **bytes survive and the TYPE is destroyed** — which is exactly
why the defect is invisible to a byte diff. On SQLite there is no type
to lose, so the loss is in the **bytes**: `json_extract` re-serialises
the blob and its formatting is gone. Either way the superseded form
wrote to a row it was required to refuse.

Reproduced outside the suite first, against a cluster started for the
purpose (PostgreSQL 16.13, port 54331, torn down afterwards); the
readings are in the report.

## The seam — "every way of not knowing answers not moved"

⚠️ **Why the wiring is owed: ruling item 2, not a zero-hit reading.**
`fileColumnsMoved` had no supplier outside `driver-sql` on the dispatch
base — re-measured here with a same-subject control, asking the
identical question of each of `SqlDriverConfig`'s own added keys over
the same corpus and package boundary: `schemaMode` 72 files ·
`autoMigrate` 14 · `sqliteAbsentFile` 6 (the firing control, and it
includes a real host wiring site,
`service-datasource/src/default-datasource-driver-factory.ts`) ·
`sqliteJournalMode` **0** · `fileColumnsMoved` **0**. ⛔ So the zero
proves only that there was no supplier — `sqliteJournalMode` reads zero
too and is a perfectly ordinary optional key no host sets. What makes
this one owed is the director ruling's item 2, which places the
kernel→driver wiring inside this dispatch rather than after it.

`ObjectQL.registerDriver` hands every driver that has the seam a closure
over the new `ObjectQL.haveFileColumnsMoved()`. Pinned on both sides —
thirteen engine-side cases and twelve driver-side ones:

- option omitted · resolver throws · resolver rejects · resolver answers
a non-`true` value · resolver never runs (the host never calls
`initObjects`) · driver has no seam at all;
- no `sys_migration` object · no row · unreadable table · null stamp ·
empty-string stamp · stamp on an unverified row · stamp on a row with
blocking findings;
- ⭐ and the **control** in both files: a verified row **with** a stamp
answers `true`, so every `false` above is a reading rather than a
welded-shut arm.

⛔ **A host that names `fileColumnsMoved` in its own config wins, in
either polarity.** The engine only fills an empty slot. Overruling a
declared `false` is the bare-ids-into-a-JSON-column failure this whole
mechanism exists to prevent; overruling a declared `true` writes JSON
into columns already retyped. The host is the more specific authority
about its own storage, so the engine never contradicts it.

A resolver arriving **after** the first `initObjects` is also refused:
`registerObjectMetadata` has already frozen `isJsonField`'s answer for
every media column, so a late resolver would be a promise the driver
cannot keep.

## The column step

`os migrate files-to-references --apply` gains it, and it moves nothing
until three gates pass: the migration's own gate (zero blocking rows),
**every** pre-check across **every** planned column, and no refusals.
Two-phase on purpose — a step that moved three columns and aborted on
the fourth leaves a datastore in a state no flag can describe.

The shape is read off the column's **physical type**, never off the
dialect: a `json` column is retyped; a column already `varchar` — the
population `os generate migration --format sql` creates and a JSON-arm
driver fills with quoted ids (objectstack-ai#15771) — has its values unquoted in
place. Classifying by dialect would have left that population full of
quoted ids behind a `columns_moved_at` stamp claiming it was converted.

⛔ **MySQL is out of scope and refused by name**, per ruling item 3 —
objectstack-ai#17788 owns it, on a real instance, because the addendum leaves its
statement ORDER unsettled. `mediaColumnMoveDialect('mysql')` answers
`null` and the step reports a named refusal. §5 pins that refusal so
nobody "completes the matrix" by transcribing a form nobody has run —
which is the move that produced the Postgres clause this card had to
overturn.

## Per-dialect pin results

`sql-driver-15989-file-column-move.test.ts`, both arms, both encodings,
across the window:

- **SQLite** — 7 passed, 1 skipped (the unprovisioned PG cell, named).
- **live PostgreSQL 16.13** — 13 passed, 0 skipped, with
`OS_TEST_POSTGRES_URL` provisioned.
- ⛔ **MySQL — NOT MEASURED, and not a cell.** No `mysqld`/`mariadb`
binary and no docker daemon in this container; more to the point the
step has no MySQL statements to measure. This is a named absence, never
a pass and never a fail.

§3 is the reverse verification the card asks for: after the move, a
driver on the **moved** arm writes a bare id and reads it back
unchanged, and reads the row the move itself converted; §3b holds the
other half of the window, where an **unmoved** deployment still stores
and reads its JSON-quoted id.

⚠️ One fixture correction worth naming: the SQLite cell is `:memory:`,
so two driver instances are two **separate** databases — a §3 written
against it would have been green while measuring nothing (the second
driver creates its own table, its own writes read back perfectly, and
the migrated rows are simply absent). The suite uses a file-backed
SQLite database so the two arms share bytes, as the live cells already
do.

## Changeset

`.changeset/15989-file-family-column-step.md` — `minor` on the five
packages that publish a change, with the launch-window `**BREAKING**`
banner, and the ADR-0087 disposition **not-required
(no-migration-prescription)** derived from this diff: nothing authorable
moves. `DataMigrationFlagSchema` and its `columns_moved_at` member
landed under objectstack-ai#16185 and are read here, not edited; the one
`packages/spec` edit is a new exported predicate function over that
existing type. So `os migrate meta` has nothing to visit,
`spec-changes.json` nothing to project, the upgrade guide no row to
gain. The other four categories are closed on facts in the changeset
itself.

## Verification

Every exit code captured by redirect-then-`$?`, never across a pipe.

**Suites — each package's own `test` target, unnarrowed. ⛔ No
`--project` filter anywhere** (a `--project` filter silently drops a
named file outside that project and reports it as passing — objectstack-ai#17853).

| package | tiers | files | tests |
|:--|:--|--:|--:|
| `@objectstack/driver-sql` | single | 182 passed, 3 skipped (185) |
3213 passed, 81 skipped (3294) |
| `@objectstack/cli` | **unit + integration, both** | 246 passed (246) |
3247 passed (3247) |
| `@objectstack/objectql` | single | 298 passed (298) | 4990 passed
(4990) |
| `@objectstack/spec` | single | 472 passed (472) | 13434 passed (13434)
|
| `@objectstack/platform-objects` | single | 40 passed (40) | 571 passed
(571) |

`driver-sql` ran against **live PostgreSQL 16.13** with the server at
`Asia/Shanghai` and the process at `America/New_York`, matching how
`ci.yml` provisions the live matrix — the live suites assert a three-way
zone skew and are vacuous on a UTC server, which is a guard, not an
obstacle.

⛔ **MySQL: NOT MEASURED.** No `mysqld`/`mariadb` binary and no docker
daemon in this container — and the column step has no MySQL statements
to measure in the first place (objectstack-ai#17788). A named absence: never a pass,
never a fail.

**Gates.** `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` derived **103** families for this diff; all
103 were run and reconciled with `--ran`, each carrying its real exit
code, so the NOT-MEASURED zero is derived rather than claimed. ⛔ Four
hit `exit 3` (PREREQUISITE NOT MET — never a pass) and went green after
a full `pnpm build`: `check:dual-build-cjs-loads`, `check:i18n`,
`check:i18n-coverage`, `check:i18n-walk-parity`.

**Four gates went genuinely RED on my own first draft, and are recorded
rather than smoothed over:**

- `check:doc-authoring` — a tracker id in two runtime strings an
operator reads. Fixed by removing the id from the driver's refusal text
and by writing the engine's log literal once instead of duplicating it.
- `check:engine-double-contract` / `check:objectql-double-limit` /
`check:where-matcher` — all three on my new fakes. They now route
`update()` through `assertEngineUpdateDispatch`, apply the caller's
`limit` by presence after the filter, and REFUSE a combinator they do
not implement instead of reading it as a field name. The last one
matters here more than usual: a matcher that answers "no rows" for a
filter it does not understand is indistinguishable from an empty ledger,
which is exactly the false "not moved" every case in those files is
trying to tell apart from a real reading.

**Cross-package reverse verification** (an additive optional member on a
type crossing a package boundary is exactly the shape a cached `.d.ts`
answers the same way twice, so both legs were run): planting
`MediaColumnMoveScan['plansZZ']` in `@objectstack/cli` goes RED with
`TS2339: Property 'plansZZ' does not exist on type
'MediaColumnMoveScan'` (leg 2 exit 1), while the real member typechecks
(leg 1 exit 0) — so `tsc` is reading `driver-sql`'s rebuilt declaration,
not a cached one. Restored under a `trap … EXIT INT TERM` with
repo-absolute paths via `git checkout HEAD -- path`, and the restore
proven by state rather than by an exit code: `git hash-object` back to
`88f1ad9944` byte-identical to the HEAD blob, `git diff HEAD` empty.

All gate figures above are read at the final commit `303d7946e4`; the
reconciliation and the suites were re-run on the head that produced them
rather than on the tree that first did. The last commit is a one-line
correction inside the ADR-0087 marker — the seat's review measured my
rationale's counts as understated, I re-measured them independently off
the three-dot diff and got the same answer, and the marker now NAMES
what it counts so a reader can recount it: **13** new declarations
reaching a package entry (11 on `@objectstack/driver-sql`'s entry — 6
values and 5 types — plus `recordFileColumnMove` on
`@objectstack/platform-objects/system` and `hasMovedFileColumns` on
`@objectstack/spec`) and **3** new public methods on exported classes
(`SqlDriver.planMediaColumnMove`,
`SqlDriver.setFileColumnsMovedResolver`, `ObjectQL.haveFileColumnsMoved`
— none private or protected, on classes exported at `sql-driver.ts:4514`
and `engine.ts:2768`). The level, the BREAKING banner and the
disposition itself are unchanged; the clause those counts support is
simply more true at 13/3 than at the 5/2 I first wrote.

Control-byte self-scan over all changed files: zero hits, with a control
that fires on an in-class byte (0x0B). `pnpm check:nul-bytes` exit 0.

## Acceptance notes

- **filed as objectstack-ai#17869:** a non-`Command` module under
`packages/cli/src/commands/` makes EVERY `os` invocation warn
`findCommand … not found` on stderr, because the oclif command table is
a `**/*.js` glob — and it corrupts machine-readable output for any
consumer that reads stdout and stderr together (`os validate --json`
then fails `JSON.parse`). Found because my own first draft put the
column-step helper there; that instance is fixed in this PR by moving it
to `src/utils/`, where every other CLI helper already lives. The missing
GUARD is the card: `check:cli-command-ids` walks the same population but
asks the opposite question, and the trap was caught by exactly one of
3247 CLI cases. Dedup ran before filing, with a firing control.
- `noted, not filed:` the docblock on `SqlDriverConfig.fileColumnsMoved`
pointed at `SqlDriver.setFileColumnsMoved`, a method that did not exist
— a dangling link left when the option landed without its supply.
Repaired in place by this PR, since the method the link wanted is the
one this PR adds. Successor: none needed, it is fixed here.
- `noted, not filed:` `readDataMigrationFlag` dropped `columns_moved_at`
on the way out, so a moved deployment was indistinguishable from an
unmoved one to every caller reading the ledger through it. Fixed here
because the column step is the first caller that has to tell them apart.
Successor: none needed.
- `noted, not filed:` the TS and SQL halves of the generator still
disagree on this family's width — `generateMigrationSql` emits
`VARCHAR(2048)` while `generateMigrationTs` emits knex's `varchar(255)`.
Carried from the objectstack-ai#17403 round, which named the column-step seat as its
successor. This PR retypes to 2048, the SQL half's width and the one the
ruling calls the end-state, so the disagreement is now between the
generator's two halves alone. Successor: a
`packages/cli/src/commands/generate.ts` card; the file is untouched
here.
- `noted, not filed:` `os migrate plan` prose for a media column still
describes the JSON end-state, generated from the drift entry's message.
Correct for an unmoved deployment and wrong once one can be moved —
which this PR makes possible for the first time. Successor: the
drift-message half of objectstack-ai#16184, which rewrites that arm.

Authored by the `domain:engine` execution seat, session
`https://claude.ai/code/session_01RuoNSXUbBoWHkNS4AknTrM`. (Carried in
prose: on this repository the PR-body UPDATE channel does not recognise
the session-URL footer block and appends a second, bare one — measured
on the create/update pair for this very PR, so the platform's own
appended footer below is left as the single one.)


---
_Generated by [Claude Code](https://claude.ai/code)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
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.

1 participant