Skip to content

fix(driver-sql): an upgraded MySQL 8 database retires the narrower key beside the functional package-less guard - #33514

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/area-A4-33201
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/area-A4-33201

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Elon · project thread
Fixes #33201
Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么:driver-sql 的扩键迁移现在能认出 MySQL 8 上平台自建的「无包守卫」(函数式键部件 + 驱动自己的哈希摘要),把它当作部分唯一索引,于是升级过的 MySQL 库会像 PostgreSQL 一样把旧的窄唯一键安全替换掉。
  • 为什么改:此前 MySQL 上旧键永远被保留,同一组织里两个包的同名权限集授权、同名连接器实例、同名激活记录都被拒,用户无法绕过。
  • 风险与回滚:识别是严格匹配(整段表达式 + 摘要必须与驱动自身的摘要构造器逐字一致 + 作用域列必须是新增的唯一可空列),运维自建的函数索引不会被误认;回滚即 revert 本 PR,旧键回到「保留」状态,不丢数据。
  • 先看:packages/drivers/driver-sql/src/schema-drift.ts(parseFunctionalRowScopedGuard 与 hasPartialUniqueGuard 新分支,风险最高);packages/drivers/driver-sql/src/sql-driver-column-creation.ts(摘要构造器抽出,须逐字节不变);packages/drivers/driver-sql/src/sql-driver-widened-declared-unique.test.ts(严格性反例)。
  • 两分钟验证:pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-widened-declared-unique.test.ts,预期纯函数段「a functional row-scoped digest (MySQL 8 package-less guard)」全绿;CI 的 Temporal Conformance (live PG + MySQL) 中三个 MySQL 单元为 replace。
  • 需要你做的:无,席位落地(含对 .changeset/31699-connection-key-package.md 的 DELIBERATE CORRECTION 确认)。

What changes

  • driver-sql (schema-drift.ts): new pure parseFunctionalRowScopedGuard(expression) reads MySQL 8's stored spelling of metadata-protocol's package-less guard, (case when (SCOPE is null) then DIGEST end), as a partial unique on the digest's columns scoped by SCOPE. hasPartialUniqueGuard accepts such an index (only key part, unique, no WHERE, no shadow carrier) when its columns are exactly the narrower key's, in key order, and its scope is the one nullable column the wider key gained. So the widening arm plans the same safe replace_unique_index it plans on PostgreSQL.
  • Strict, derived from code: the digest must equal, in MySQL's stored spelling, what the new hashShadowDigestSql(columns) builds. That builder is the one createHashShadowUniqueIndex already used (extracted, byte-identical output), and it is the digest the three migrations key ("the driver's own hash-shadow digest"). Another function, hash, width, separator, scope, an ELSE, a NULL-safe part, a scope that is a key column or not the gained column, a second key part, a non-unique index, or two nullable gained columns: not a guard, the narrower key stays kept.
  • MariaDB, SQLite, PostgreSQL paths unchanged; a shadow-carried narrower key is still kept whatever the guard.
  • Tests: the MySQL cell of sql-driver-widened-connection-key.test.ts flips from the declared limit to the replace (same assertions as the PG cell); sql-driver-widened-declared-unique.test.ts (activation ledger) and sql-driver-widened-grant-key.test.ts (grant) gain pure pins over the measured MySQL expression plus a live MySQL 8 cell each (MariaDB skips them; the MariaDB cell is untouched).
  • Docs: content/docs/deployment/cli.mdx ("Runtime-owned indexes apply builds") drops the MySQL limit; the guard docblock in metadata-protocol's connector-connection-packageless-index.ts says the driver reads the form (comment only).
  • Changeset: new driver-sql patch, FROM kept TO retired.

DELIBERATE CORRECTION

.changeset/31699-connection-key-package.md is a pending (unreleased) note whose MySQL 8 bullet this PR makes false. Corrected sentence (the rest of the note unchanged):

  • MySQL 8, upgraded databases: driver-sql reads the guard's functional key part as the partial unique it is, so the old key retires there as it does on PostgreSQL, as one safe replace_unique_index on the next sync that runs safe drift. A database created fresh on MySQL 8 has the wide key and the guard and no old key. MySQL before 8.0.13 and MariaDB before 10.3 build no form, keep the old key (or build it under the driver's generated name where it is missing) and say so at error each boot.

check-empty-changeset is red on this file by design; the dispatching seat confirms by its record.

Tests

Live MySQL 8.0.46 (local server; CI's Temporal Conformance (live PG + MySQL) uses the official mysql:8.0 image), at head d0f178767f (merge of origin/main over b3e78bb48a):

  • The three widened-key suites with OS_TEST_MYSQL_URL set: Test Files 3 passed (3), Tests 60 passed | 2 skipped (62). The two skips are the PostgreSQL cell of the connection-key suite (no PG URL locally) and the MariaDB cell of the activation-ledger suite (the server is MySQL). All three MySQL cells ran and passed: connection key (flipped from the declared limit), grant key and activation ledger (new). Each live cell also asserts the stored STATISTICS.EXPRESSION text the pure pins read.
  • pnpm --filter @objectstack/driver-sql typecheck: exit 0 (lock VERDICT command-exit 0).
  • pnpm --filter @objectstack/driver-sql test with live MySQL, at b3e78bb48a: Tests 3 failed | 5332 passed | 141 skipped. All failures are live-MySQL environment cells outside this diff: four temporal / window cells need the skewed process zone CI sets (re-run with TZ=America/New_York: green), and sql-driver-11565-row-byte-budget (an InnoDB page-limit refusal on CREATE TABLE) does not fire on the locally packaged server. None reads index introspection or the widening arm. CI's live job is the reading of record for those cells.
  • eslint (--no-inline-config) on the six changed source files: exit 0.
Ablation (one-shot, restored; readings only)

All via scripts/ablation-replace.mjs on committed b01a23c36f (tests import src, so no build leg; the tool restored each time, blob == HEAD, git diff HEAD empty):

  1. The recognition removed (functionalRowScopedGuardOf(p) replaced by null): 5 red across the three suites, the 2 pure "counts as the guard" pins and all 3 live MySQL cells (the plan is no longer the replace). This is also the premise re-measure: without the recognition, the upgraded MySQL database keeps the old key.
  2. The digest comparison deleted: 5 red (another hash width, another hash function, another separator, no hex decoding, an ELSE).
  3. The scope check deleted: 2 red (a scope that is not the gained column; two nullable gained columns).

Acceptance notes

  • Claim file-surface extension (declared here): the comment-only docblock edit in packages/metadata-protocol/src/migrations/connector-connection-packageless-index.ts and the pending changeset correction above; both are sentences this diff made false.
  • Measured: MySQL 8.0.46 stores the guard as (case when ( + backquoted scope + is null) then unhex(sha2(concat( + backquoted columns joined by ,0x1f, + ),256)) end) for all three tables; the live cells assert the stored text.
  • PostgreSQL cell: run locally against a live PostgreSQL 16 (127.0.0.1, started for this run and removed after), and it passed. CI's Temporal Conformance (live PG + MySQL) job runs the whole driver-sql suite against live PG and MySQL 8.0, but only on push to main and on schedule, not on pull_request or merge_group. On PR heads the live MySQL and PG cells are measured only by the local runs above.

Verification

Derived gate families (dispatch-gates --commands, --ran reconciled)

At b3e78bb48a: 98 derived, 95 run, 3 NOT MEASURED (check:dual-build-cjs-loads, check:lean-entry-closure, check:type-check-debt: exit 3, PREREQUISITE NOT MET, they need the whole workspace built; CI's Lint & Repo Gates runs them). Red: check-empty-changeset --base origin/main exit 1, the DELIBERATE CORRECTION above, red by design. Four doc gates first exited 3 and were re-run green after building @objectstack/lint and @objectstack/client-react. All other families exit 0. Re-derived and re-run on d0f178767f: see the os-dev-report comment on the card.

Post-merge scoped re-check (packages/spec moved upstream): @objectstack/spec check:generated reported check:test-typecheck red with "tsc failed without diagnostics" under the default heap; check:test-typecheck re-run under NODE_OPTIONS=--max-old-space-size=4096 exit 0 (this diff does not touch packages/spec).

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC

…ening arm's partial guard

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
…cs, the pending note and the guard's docblock; add the changeset

Co-authored-by: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC
@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 14, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/driver-sql, @objectstack/metadata-protocol, touching 10 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/metadata-protocol/src/migrations/connector-connection-packageless-index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • content/docs/deployment/cli.mdx (via rowScope (symbol, a field of interface FunctionalRowScopedGuard))
What this run could not see
  • 1 changed file(s) yielded no anchor (packages/metadata-protocol/src/migrations/connector-connection-packageless-index.ts) — pages documenting those are invisible to this run
  • 1 name(s) were too generic to anchor anything (single lowercase words)
  • 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 — 23 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 e40cd1e28dd79e60e7f4be0db06f071f3f962574 → packageMentionDocs.

Which tree this was computed on

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

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

⚠️ 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 e40cd1e28dd79e60e7f4be0db06f071f3f962574 → 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

Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head d0f1787 · 2026-11-14T23:54:35Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Review: PASS

review#2 (server area pilot) · area A4 · Fixes #33201 (p2) · head d0f178767ffcb2bb92ca0671c478992405dee602 · Clause-② no.

CI on this head: 38 success, 17 skipped. The only red is Check Changeset (twice), which is the check-empty-changeset refusal on .changeset/31699-connection-key-package.md, the DELIBERATE CORRECTION class. It is confirmed below.

What was checked (read-only: the diff, the card, the PR body, and the three guard builders in metadata-protocol on this head):

  • Strict recognition. parseFunctionalRowScopedGuard accepts only the whole stored expression (case when ( is null) then <digest> end). The digest must equal, in MySQL's stored spelling (blanks dropped and lower-cased outside quoted runs), what hashShadowDigestSql(columns) builds over the columns it names. Plain parts only, and the scope column must not be a key column. Anything else is not a guard, including another hash, separator, width, ELSE, NULL-safe part or IS NOT NULL, so an operator's own functional index is never read as one.
  • Narrow use. hasPartialUniqueGuard accepts the functional form only when it is the index's sole key part (unique, no WHERE, no shadow carrier, not primary), its columns are exactly the narrower key in key order, and its scope is the one nullable gained column. With two nullable gained columns no single-scope guard stands, so the old key is kept. That is the correct conservative reading: a row NULL in the untested column would escape both keys.
  • Safe failure direction. The guard builders in metadata-protocol (*-packageless-index.ts) spell their digest themselves (unhex(sha2(concat(…, 0x1f, …), 256))). If either side ever drifts, recognition fails and the differ falls back to KEEPING the old key, which is the pre-PR behaviour. Nothing is retired on a misread. The new docblock line says the two move together.
  • One builder. createHashShadowUniqueIndex now emits hashShadowDigestSql(columns, nullSafeColumns), extracted byte-identically, so the digest the sync writes and the digest the differ recognises cannot drift.
  • Pins and ablations. The connection-key MySQL cell flips from the declared limit to the replace_unique_index, and the grant-key and activation-ledger suites gain live MySQL 8 cells. The three ablations went red (5, 5 and 2). The live MySQL and PostgreSQL cells run only on push to main or on schedule. The body reports them measured locally on MySQL 8.0.46 and PostgreSQL 16 (61 passed, 1 skipped, the MariaDB cell). I accept that as the local measurement; the first scheduled run after landing is the CI confirmation.

Semver: Clause-②: no and Metadata-protocol: none are right. driver-sql at patch: an upgraded MySQL 8 database now plans the same safe, create-before-drop replace_unique_index that PostgreSQL already plans, and nothing an author writes moves.

DELIBERATE CORRECTION, confirmed sentence by sentence (the at-tier record that landing-operations.md names for a diff that also changes code):

  1. .changeset/31699-connection-key-package.md, the "MySQL 8, upgraded databases" bullet.
    • The old text says driver-sql reads the functional key part "as an expression, not as a partial guard, so the widening arm keeps the old key there … until driver-sql recognises the form", and that the grant's guard "shares this limit".
    • After this PR both statements are false: hasPartialUniqueGuard reads the form, and the grant-key suite's new MySQL cell shows the grant's old key retiring too.
    • The new text says it "reads the guard's functional key part as the partial unique it is, so the old key retires there as it does on PostgreSQL, as one safe replace_unique_index on the next sync that runs safe drift". That matches the code and the flipped connection-key cell.
    • The two unchanged sentences (fresh MySQL 8; pre-8.0.13 MySQL and pre-10.3 MariaDB) stay true and are kept verbatim.
    • Correct. Confirmed.
  2. connector-connection-packageless-index.ts docblock (comment only). The removed "⚠ driver-sql reads that key part as an expression … the widening arm keeps the old key (a declared limit; the grant guard shares it)" is false after this PR. The replacement names parseFunctionalRowScopedGuard and its exact-digest condition. Correct.
  3. content/docs/deployment/cli.mdx. "On an upgraded MySQL database both old keys stay …" becomes "driver-sql reads it as the guard it is, so an upgraded MySQL database retires both old keys the same way". Correct.

I searched for any other statement of the old limit in the pending .changeset/ notes, content/docs/ and the three guard modules on this head and found none left: the grant guard's docblock carries no MySQL limit sentence.

Nits: none.

Final round. Per landing-operations.md, this same-head PASS is the confirmation, and the PR enters the queue with Check Changeset red. The gate is not changed.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#5 · os-elon-musk · session_016WV4cw787kMeaX7oyz7DDC

ACCEPT · area A4 · head d0f1787 · 2026-11-14T23:57Z

  • review#2 PASS at this head (comment 6886215334), final round, no nits. Clause-② no.
  • DELIBERATE CORRECTION, confirmed by that same-head review record sentence by sentence: .changeset/31699-connection-key-package.md (the MySQL bullet). The record also confirms the comment-only docblock fix in metadata-protocol's connector-connection migration and the cli.mdx limit sentence. All three said the widening arm keeps the old key on MySQL, which this diff makes false.
  • Enters the queue with Check Changeset red by design (check-empty-changeset, foreign-note class DELIBERATE CORRECTION). All three conditions hold: the checker's source names this class as red-by-design with "do NOT restore it" (scripts/check-empty-changeset.mjs, FOREIGN_CORRECTION_REMEDY); pr-automation.yml runs on pull_request only, never on merge_group; and this comment records the gate and the reason. The gate is unchanged.
  • Every other check-run on this head is green or skipped: 38 success, 17 skipped, and only the two Check Changeset runs failed.
  • Live MySQL and PG cells: Temporal Conformance does not run on PR or merge-queue heads. They were measured locally against MySQL 8.0.46 and PG 16: 61 passed, 1 skipped (the MariaDB cell). The first scheduled run on main is the confirming reading.
  • check-governed-merges --pr 33514: NOT governed, 544 changed lines. Behind main by 4.
  • Landing under the maintainer's area go (pilot Dispatch by code area instead of by card: area leases, one PR per coupled set, follow-ups folded (pilot on domain:server after 18.4.0; maintainer launches) #33059): ready + auto-merge.

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

2 participants