Skip to content

fix(driver-sql): on MySQL, os migrate converts a keyed TEXT column to its declared varchar(n) - #39784

Draft
objectstack-fleet[bot] wants to merge 7 commits into
mainfrom
claude/issue-35862-wip
Draft

objectstack-fleet[bot] wants to merge 7 commits into
mainfrom
claude/issue-35862-wip

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread
Part of #35862
Clause-②: no
Metadata-protocol: none

维护者速读

  • 用户能看到什么变化:使用 MySQL 的部署,运行迁移检查时会多出一条提示,说明某个文本列需要转成定长文本才能建索引;数据都放得下时,迁移会直接完成转换,索引随后自动建好。
  • 为什么做:这是收件箱索引那张卡的前一半,替 MySQL 用户解决“文本列建不了索引、只能手写改表语句”的问题;收件箱的索引本身放在下一个 PR。
  • 出错会怎样:最坏是某列转换被拒绝并留在原样,应用照常启动、照常服务;有超长数据时迁移会列出行号并拒绝,不会截断数据;撤回本改动即可复原。
  • 要你做什么:无。

What changes

Half A of the card, as ruling A1′ (card comment 7239720208) lays it out. The inbox object change is the next PR.

  • Differ (schema-drift.ts): a MySQL-only branch in diffManagedTable. When the emitter would build a field as varchar(n) but the physical column is in the TEXT family, it reports the exported narrow_varchar op with no from, at category needs_confirm. The category is never destructive, because the artifact-pinned boot refuses on destructive alone. No DriftOp variant is added.
  • Plan-side probe and apply arm (new sibling module mysql-text-to-varchar.ts). sql-driver-schema-sync.ts is over 1,000 lines, so it only gains the two calls.
    • detectManagedDrift counts the rows whose value is longer than n. If there are none, the entry becomes a warning. Otherwise it gets an applyLimit naming the count and up to five row ids, and os migrate apply refuses that entry.
    • applyDriftOpInPlace sends a TEXT-source narrow_varchar to the apply arm. It pins one connection and sets the bounded lock_wait_timeout and STRICT_ALL_TABLES. It then probes the rows again and refuses (skipped, rows named at warn) if any value is longer than n. Otherwise it runs MODIFY to varchar(n), restating NOT NULL, DEFAULT (expression defaults included), character set, collation and comment from the catalog. The session's prior settings are restored.
  • Remedy text (sql-driver-column-creation.ts, explainUnkeyableTextColumn): now points at os migrate plan / apply instead of a hand-written ALTER.
  • Changeset: @objectstack/driver-sql patch.

Tests

Run on head 16cc1125. Test file: sql-driver-35862-text-to-varchar.test.ts.

  • Pure differ:
    • a keyed TEXT column reports narrow_varchar at needs_confirm, with every member of the TEXT family;
    • CONTROL: an unkeyed text field, Postgres, SQLite and a varchar of the declared width report nothing.
  • Live cells (SQLite locally; Postgres and MySQL in Temporal Conformance (live PG + MySQL), which runs the whole driver-sql suite with OS_EXPECT_LIVE_DIALECT_MATRIX=1):
    • clean data: planned at warning, applied, NOT NULL and DEFAULT kept, rows intact, the index built, and a second plan reports nothing;
    • dirty data: planned with the row named, refused by the apply's re-probe, and the column stays TEXT;
    • the artifact-pinned boot policy, for clean and dirty data: no destructive entry, so the gate answers ok, and applyMigrationEntries with allowDestructive: false converts the clean column and skips the dirty one;
    • the Postgres and SQLite cells are the no-finding CONTROL.
Local readings
  • pnpm --filter @objectstack/driver-sql typecheck and vitest run src/sql-driver-35862-text-to-varchar.test.ts src/sql-driver-column-creation src/schema-drift: exit 0, Test Files 8 passed (8), Tests 87 passed | 5 skipped (92). The 2 skips in this file are the live pg and mysql cells: there is no server in this container.
  • Ablation: the differ branch was disabled on disk (false && before isTextFamilyColumn). Result: Tests 2 failed | 6 passed | 2 skipped. The two failures are the differ pins. The file was then restored from HEAD.
  • dispatch-gates --ran: 74 derived families. 70 ran with an exit code and 4 are NOT MEASURED: check:dual-build-cjs-loads and check:lean-entry-closure (prerequisite not met: the whole-repo dist was not built), and check:query-options-erasure and check:type-check-debt (stopped at a 240 s local cap on a shared box). node scripts/ci/snapshot-next.mjs --self-test exited 1 in its live stable-lane case. This diff does not touch scripts/ci/. CI reads all five.
  • Not run locally: the live MySQL and Postgres cells. CI's Temporal Conformance (live PG + MySQL) job is their reading.

Acceptance notes

  • In the dirty case the probe scans the table on every artifact-pinned boot and every plan until the rows are fixed. It is one COUNT(*) with a CHAR_LENGTH filter, plus the apply's re-probe. A clean column converts on its first pass, so the scan does not recur for it.
  • The live MySQL pins are measured only in CI. This container has no MySQL server.
  • scripts/pm/dev-worktree.sh refuses a resume when the branch name changes (claude/project-thread-01z3wq to claude/issue-35862-wip), so the worktree was built by hand from b612214. origin/main 56bed06 then merged cleanly.

Verification

Read first, by risk:

  1. mysql-text-to-varchar.ts convertMysqlTextColumnToVarchar: how the column definition is restated (the DEFAULT expression unescaping, and the NULL / NOT NULL choice).
  2. schema-drift.ts: the new MySQL branch in diffManagedTable, especially the category.
  3. sql-driver-schema-sync.ts: the narrow_varchar routing in applyDriftOpInPlace.

Two-minute check: OS_TEST_MYSQL_URL=mysql://root:root@127.0.0.1:3306/conformance pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-35862-text-to-varchar.test.ts. Expected: 10 tests, and the MySQL cell's three live tests pass.

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj

@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 Dec 5, 2026
@github-actions

github-actions Bot commented Dec 5, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

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

  • content/docs/deployment/cli.mdx (via needs_confirm (literal, a string literal in diffManagedTable))

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

  • content/docs/releases/v17/17-0.mdx (via needs_confirm (literal, a string literal in diffManagedTable))

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 71 of 255 client-bound route-ledger rows — the other 184 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 184: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 60 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 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 — 15 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 0635432d09c4d6d95eacd6c39aa0caee845f01e2 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 164abd31717b0dc973dd9ff1620d607d91051241 — the merge of head 54e77c076fd7ae66b9ce18ea60d41aafee8a4c33 into base 0635432d09c4d6d95eacd6c39aa0caee845f01e2, 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 164abd31717b0dc973dd9ff1620d607d91051241 && git checkout 164abd31717b0dc973dd9ff1620d607d91051241
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 0635432d09c4d6d95eacd6c39aa0caee845f01e2 54e77c076fd7ae66b9ce18ea60d41aafee8a4c33 && git checkout -B drift-repro 0635432d09c4d6d95eacd6c39aa0caee845f01e2 && git merge --no-ff 54e77c076fd7ae66b9ce18ea60d41aafee8a4c33

node scripts/docs-audit/affected-docs.mjs --json 0635432d09c4d6d95eacd6c39aa0caee845f01e2

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

…h no manual MODIFY in it

Claude-Session: https://claude.ai/code/session_016WV4cwiNRyb9B38wT2fjYj
Co-authored-by: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

2 participants