Skip to content

fix(driver-sql): the orphan arm keeps a hash-shadow carrier whose key it could not read, never an orphan drop - #32430

Merged
objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-y58py2
Nov 11, 2026
Merged

objectstack-fleet[bot] merged 1 commit into
mainfrom
claude/project-thread-y58py2

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread
Fixes #32399

domain:server#2 · os-bill · session_01Utp6CaP1iy4RSEQbW6177G

Clause-②: no

Metadata-protocol: none
Skills-docs: none. git grep -i -E 'hash.?shadow|__hash|shadow carrier|orphan(ed)? index|drop_index' -- skills content/docs (releases excluded) has 1 hit, content/docs/deployment/cli.mdx line 1182, the drop_index row of the index-drift table ("An index carrying ObjectStack's generated naming that metadata no longer declares"). It says what the op means, not that every such index gets it (runtime-managed partial and expression indexes were already excluded without a sentence there), so this change makes it no less true.

维护者速读

  1. 改了什么:driver-sql 的 schema 差异比对里,"孤儿索引"这条规则遇到 MySQL/MariaDB 上读不出所哈希键的影子列唯一索引时,不再提议删除(destructive),改为保留、什么都不提议;读得出键的孤儿影子索引照旧提议删除。
  2. 为什么改:读不出键就不知道删掉的是哪条唯一约束;os migrate apply --allow-destructive 会把它删掉,数据从此静默失去这条约束。加宽分支和重定义分支早已这样处理,只差孤儿分支。
  3. 风险与回滚:只会把一条"提议删除"变成"保留",不新增任何操作;代价是这种读不出键、声明又确实已删掉的影子索引不再出现在计划里(与另两条分支相同的取舍:少一条发现,绝不丢一条约束)。回滚即还原本 PR。
  4. 先看:packages/drivers/driver-sql/src/schema-drift.ts 里 diffManagedIndexes 第 3 段(孤儿分支)新加的一行守卫与注释。
  5. 两分钟验证:pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-13015-shadow-carried-index-drift.test.ts,预期 11 个过、2 个实库单元无 MySQL 时具名跳过(设 OS_TEST_MYSQL_URL 则 16 个全跑);读不出键的影子索引不出现在结果里,读得出键的那个仍是 drop_index。
  6. 需要你做的:无,席位落地。

What changes

packages/drivers/driver-sql/src/schema-drift.ts, section 3 of diffManagedIndexes (the orphan arm): one guard, if (isHashShadowCarrier(p) && !p.shadowKey) continue;, placed after the runtime-managed skip and before the orphan entry is built. It is the redefinition arm's guard, byte for byte, with the same load-bearing !p.shadowKey half: a carrier whose key was resolved is not exempted and is still offered as the orphan drop, described by the key it enforced. The widening arm (PR #32356) is untouched.

This is the answer the other two arms already give an unresolved carrier, and the one SqlDriver.resolveHashShadowKeys' docblock promises ("diffManagedIndexes then reports NOTHING for it ... The degraded outcome is a missing finding, never a dropped constraint"). Before this change the orphan arm broke that promise.

Why

isHashShadowCarrier recognises a carrier by name alone, so it holds even when the generation expression cannot be read, and its jsdoc rules that a carrier "is never a thing this differ may propose destroying on a guess". PR #32356 applied that to the widening arm; the redefinition arm already had it. The orphan arm had no such exemption, so an unresolved carrier under any other generated name (a retired declaration, or a tenant-arm legacy name, which claims no carrier) was offered as drop_index, destructive. An operator running os migrate apply --allow-destructive would drop a unique constraint whose key nobody had read.

Tests

All in packages/drivers/driver-sql/src/sql-driver-13015-shadow-carried-index-drift.test.ts, the shared harness for shadow-carried index drift, as one new top-level describe plus one live cell (no new file):

  • An unresolved carrier no declaration names: no entry of any kind. In the same call, two colocated CONTROLs: a RESOLVED orphan carrier is still unmapped_index / drop_index / destructive, described as UNIQUE (organization_id, gone), and the ordinary drifted unique is still recreate_index.
  • Outside the widening arm: an unresolved carrier under a tenant-arm legacy name (no widenedBy) is kept; the whole diff is empty.
  • CONTROL: the same carrier with its key read is still the orphan drop_index.
  • The widening arm's unresolved-carrier answer from PR fix(driver-sql): the widening arm keeps, or safely retires, an 18.0 NULL-safe narrower key, and keeps a shadow-carried one or one whose gained column is not yet physical, never an orphan drop #32356 is unchanged (kept, nothing offered).
  • Live MySQL cell: two retired shadow-carried UNIQUEs built by initObjects; one shadow is rebuilt with a generation expression that names no column (UNHEX(SHA2('unreadable', 256))), which resolveHashShadowKeys resolves to nothing. A fresh driver with neither declared: the resolved one is offered as drop_index, the unreadable one is not; after applyMigrationEntries(drift, { allowDestructive: true }) the catalog still holds the unreadable index and no longer holds the resolved one.

Acceptance notes

Verification

Measured on origin/main 7d82b2dab + this branch (head 1ead60236), with a live MySQL 8.0.46 (mysql:8.0, the image CI's live job uses) in this container.

Red first, on unfixed main (live MySQL 8.0.46)

The card's first step: an unreadable carrier does reach the orphan arm on a live server. On 7d82b2dab with only the new tests added, OS_TEST_MYSQL_URL=… vitest run src/sql-driver-13015-shadow-carried-index-drift.test.ts: Tests 3 failed | 13 passed (16), live mysql RAN. The live cell's subject assertion received:

"kind": "unmapped_index", "category": "destructive",
"actual": "UNIQUE (uniq_os32399_orphan_unreadable__hash)",
"op": { "type": "drop_index", "indexName": "uniq_os32399_orphan_unreadable", ... }

The two pure-function subject pins failed the same way; every CONTROL and every pre-existing test passed. (A MariaDB 11.8 run was tried first: MariaDB keys a long TEXT unique natively and takes no shadow route, so the shadow cells, the pre-existing #13015 ones included, do not apply there.)

Green
Ablation (once)

node scripts/ablation-replace.mjs on the committed head replaced the new guard line with a marker comment (anchor 1 → 0, blob 08055dc8f89c → c063c9a460c2), live MySQL: Tests 3 failed | 13 passed (16), the three subject pins (pure unresolved orphan, tenant-arm legacy name, live cell); every CONTROL and the widening-arm pin stayed green. Restored by the tool: blob back to 08055dc8f89c, git diff HEAD empty.

Gates

On 1ead60236 (the final tree; git merge origin/main before opening: already up to date at 7d82b2dab):

  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack derived 66 commands over the 3 changed paths (200 changed lines, under the 3000 threshold). Each was run with its exit code recorded before any pipe.
  • First pass: 62 exited 0, 4 exited 3 (PREREQUISITE NOT MET, not findings): check-plugin-teardown-shape --self-test (its fixture commit was outside this shallow clone; the commit was fetched), and check:dual-build-cjs-loads, check:lean-entry-closure, check:type-check-debt (they read built output of packages outside driver-sql's closure; pnpm turbo run build --concurrency=2, 120 of 120 tasks, VERDICT command-exit 0). All four re-run: exit 0.
  • node scripts/pm/dispatch-gates.mjs --ran: 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN, exit 0.
  • pnpm lint (repo-wide eslint . --no-inline-config): exit 0. eslint over the two touched source files: exit 0.

NOT MEASURED here: MariaDB with a shadow carrier (MariaDB takes no shadow route for this shape, see above); the full dogfood battery (no ! title and no (narrowing) arm).

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (No spec change.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes. (Repo-wide pnpm lint: exit 0.)
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (Not touched.)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English. (## 维护者速读 is the maintainer's Chinese summary the dispatch rules ask for.)
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CamgV1EYRYcyP8yQ5h


Generated by Claude Code

… it could not read, never a drop

Claude-Session: https://claude.ai/code/session_01Utp6CamgV1EYRYcyP8yQ5h
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m 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 11, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

1 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

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 — 14 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 7d82b2dab87c124d089c29933c2c83feb06431b5 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 7d82b2dab87c124d089c29933c2c83feb06431b5

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-bill · session_01Utp6CaP1iy4RSEQbW6177G

维护者速读

  1. 改了什么:driver-sql 的迁移计划里,"孤儿索引"分支遇到读不出所哈希键的影子列唯一索引(MySQL/MariaDB 长文本唯一键)时,不再提议删除,改为保留;读得出键的孤儿影子索引照旧提议删除。
  2. 为什么改:读不出键就不知道删的是哪条唯一约束,os migrate apply --allow-destructive 会把它删掉,数据静默失去约束。加宽分支(fix(driver-sql): the widening arm keeps, or safely retires, an 18.0 NULL-safe narrower key, and keeps a shadow-carried one or one whose gained column is not yet physical, never an orphan drop #32356)和重定义分支早已这样处理,只差孤儿分支。
  3. 风险与回滚:只把一条"提议删除"变成"保留",不新增任何操作;代价是这种索引不再出现在计划里(少一条发现,不丢约束)。回滚即还原本 PR。
  4. 先看:packages/drivers/driver-sql/src/schema-drift.ts 中 diffManagedIndexes 第 3 段新加的一行守卫。
  5. 两分钟验证:pnpm --filter @objectstack/driver-sql exec vitest run src/sql-driver-13015-shadow-carried-index-drift.test.ts,预期全过(无 MySQL 时两个实库单元具名跳过)。
  6. 需要你做的:无,席位落地(非 BREAKING、非受管面、200 行)。

席位意见:ACCEPT。一行守卫与重定义分支逐字相同,!p.shadowKey 半边保住读得出键的孤儿仍被删除;实库 MySQL 8.0 前后对照与消融都在报告里。

席位核对 — ACCEPT · domain:server#2 · head 1ead602361f139801ba3abc194c7a010215129fc · 2026-11-11T20:07Z

  • 形态: 3 files (+200/−0) via get_files: schema-drift.ts +10 (orphan arm only), one test file +180, one changeset (@objectstack/driver-sql patch). Inside the claimed surface (6795926447). Not governed (check-governed-merges --pr 32430: no governed path, 200 ≤ 3000). No merge=os-regen path. Author objectstack-fleet[bot] (relay); report mcp_calls read-only.
  • 前提实测: the guard sits after isRuntimeManagedIndex and before the orphan entry is built in section 3; it is byte-identical to the redefinition arm's guard on origin/main. Report 6806072514 records the live MySQL 8.0.46 before/after (unreadable carrier offered and dropped by apply --allow-destructive before; kept after) and the ablation (3 red, controls green).
  • 门禁 check-runs: head 1ead6023: 35 success, 16 skipped, 0 failure/pending; mergeable_state: clean.
  • 接受的偏差: open question answered A: "kept and reported" is read as the widening arm's answer after fix(driver-sql): the widening arm keeps, or safely retires, an 18.0 NULL-safe narrower key, and keeps a shadow-carried one or one whose gained column is not yet physical, never an orphan drop #32356 (kept, nothing offered); no arm reports an unresolved carrier today, and a report-only drift kind would be new surface with no pull. Clause-②: no accepted: planner output withdraws one opt-in destructive step the isHashShadowCarrier contract already forbids; no accept set or public surface moves, so no contract-review-tier review is owed.
  • 范围外去向: report-only drift kind for unresolved carriers → dropped — no consumer asks for it. Overlap with open PR feat(plugin-security, runtime, core)!: the permission-set grant, clone and activation doors take a package, and a grant is unique per package #32306 (section 1, widening arm): disjoint hunks, second to merge takes origin/main. Skills-docs: none (grep in PR body, 1 hit stays true).
  • 落地条款: Fixes #32399; not BREAKING; seat lands: pr_ready + automerge_enable after this record.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 11, 2026 20:09
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 11, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 11, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-bill · session_01Utp6CaP1iy4RSEQbW6177G

Re-queue receipt · 2026-11-11T21:02Z

Dequeued CI_FAILURE at 2026-11-11T21:01Z. Signature, read from the queue's merge_group runs on gh-readonly-queue/main/pr-32430-14754c70…: every finished job is success (Governed Surface Guard, Spec Liveness Check, PR-Body Guards, all 14 Lint & Type Check legs); the one red run, Lint & Type Check 43093974725, failed only because its TypeScript Type Check job 130782071656 never left queued (started_at 20:21Z, no runner, no log), and CI 43093974637 is also still queued. No step of this PR's code failed. Same head 1ead6023 (all 51 PR checks green). Re-queued once; a second kick stops re-queueing and goes back to diagnosis.

@github-actions

Copy link
Copy Markdown
Contributor

⛔ merge queue 构建失败 — 先分诊,再决定要不要重排

队列构建 43093974637 红了。队列跑的是全量套件(PR 侧 CI 只跑 affected 子集),
所以失败的测试可能在本 PR 没碰过的包里 —— 那不是重排能修的。每次盲目重排都会让排在后面的所有 PR 重建一轮。

分类:failure —— 按下面的日志分诊。

失败的 job(日志抽取,best effort):

  • Build Core — 失败步骤: Upload build artifacts(日志不可读,点进 job 看)
  • Dogfood Regression Gate (3/3) — 失败步骤: Publish this shard's attestation(日志不可读,点进 job 看)

↳ 失败原因 是判读的关键:超时(Test timed out in … / Hook timed out in …)多半是负载/时序,不是本 PR 的回归;
断言(AssertionError: …)才指向真实的行为改变。两者的 FAIL 行长得一模一样,只有这一行能区分。

⚠️ 断言这一侧有一类例外,判据是断言在测什么,不是它是不是 AssertionError。 断言的对象是产品行为(一个值、一个形状、一次拒收)⇒ 照上面读:真实的行为改变,去查,⛔ 不要重排掉;
断言的对象是这次实验自身的有效性前提(跑完的耗时、负载下的先后、任何只在时间预算内才成立的条件)⇒ 它跟超时是同一类,同样对负载敏感,重排一次是合法的判别手段。
识别是机械的:断言的消息或它比较的值本身点名了一段时长、一个时间戳、一个耗时计数。实测过的一对 —— AssertionError: SecurityPlugin.init() ran: expected false to be true 测的是产品行为(真回归);
AssertionError: this run took over a second, so second-precision stamps could have differed too: expected 1006 to be less than 1000 测的是实验前提:它守护的那条不变式当时是绿的,同一个 head 原样重排一次即成功。
穿着 AssertionError 外衣的时间测量,仍然是时间测量。(⛔ 这只改「怎么读一次红」,不改「哪些测试可以重排」——后者由别处管。)

跨 PR 相同签名(24h,按失败测试文件聚合):

  • ⚠️ 本次没有可用的聚合签名(日志里没有能解析出测试文件名的 FAIL 行)—— 这不是「没有同签名的其他 PR」,是这一轮没测到。跨 PR 聚合本次不可用,请手工比对其他 PR 的同类评论。
  • ⚠️ 24h 评论账本没读完(超过 5 页仍未读到窗口尽头),所以上面的「不同 PR 数」是下界,不是全量。

历史信号:

  • 本 PR 过去 24h 无队列失败记录(首次)。
  • 过去 24h 队列共有 5 个失败构建(不含本次)。

分诊清单:

  1. 失败测试在本 PR 改动的包里 → 真回归,修 PR。
  2. 失败测试与本 PR 无关 → 看上面的「跨 PR 相同签名」;已有汇总 issue ⇒ flaky/环境问题实锤,去那张 issue 上谈,修好前重排只会再烧一轮全队列。
  3. 两者都不是 → 可能与同组 PR 语义冲突;等前面的 PR 落地或失败出队后再重排一次即可,不要连续重排。

Generated by Claude Code · merge-queue-triage workflow (#4859)

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-bill · session_01Utp6CaP1iy4RSEQbW6177G

Addendum to the re-queue receipt 6806980816 · 2026-11-11T21:05Z: CI 43093974637 has since finished red too, and its two failed jobs both failed at artifact steps, not tests: Build Core at Upload build artifacts, Dogfood Regression Gate (3/3) at Publish this shard's attestation (no test FAIL line; the triage bot found no file signature). With the job that never got a runner, all three are runner/artifact-storage failures; none touches driver-sql. The one re-queue stands; a second kick goes back to diagnosis.

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/m 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.

driver-sql: the orphan arm can offer a destructive drop_index for a hash-shadow carrier whose key it could not read, outside the widening arm

1 participant