Skip to content

fix(metadata-protocol,objectql): the activation ledger upgrade prints one answer per finding and the right row count - #33492

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

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/area-A4-33340

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

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

维护者速读

  • 改了什么:18.3.0 数据库升级路径上激活台账(sys_metadata_activation)的四处运维读数:plan 的「无包行」计数改为真实总数并说明其余行为何不动;冲突句不再把包持有的行称为环境自建条目;冲突启动与升级前 plan 不再先打印一条原始 DATABASE_ERROR。
  • 为什么改:运维在升级时按这些行做决定(删哪一行、数据是否有问题);计数错、标签错、同一事实两种说法都会误导。
  • 风险与回滚:只改日志/报告文字与「先查后建」的顺序;状态码、导出形状、写入的数据均不变。回滚即 revert 本 PR。意外的驱动错误仍原样上报(作为友好错误的 detail)。
  • 先看:packages/metadata-protocol/src/migrations/activation-ledger-packageless-index.ts(建索引前先数重复行的分支);packages/metadata-protocol/src/migrations/runtime-index-preflight.ts(作用域列缺失时不再发会被拒的语句);packages/objectql/src/activation-ledger-backfill.ts(预览计数)。
  • 两分钟验证:pnpm --filter @objectstack/metadata-protocol exec vitest run src/migrations/activation-ledger-packageless-index.test.ts,预期 23 个用例全绿,其中「one answer, worded for the rows it is about」一组断言被拒语句数为 0。
  • 需要你做的:无,席位落地。

What changes

Measured end to end on a database @objectstack/cli@18.3.0 wrote (blank scaffold booted once, four package-less ledger rows planted by SQL: a flow com.example.todo ships, a position, a flow nothing ships, a webhook nothing ships; a conflict copy with the 18.3.0 (metadata_type, name) index dropped and a second package-less row for the flow), driven with this tree's CLI over examples/app-todo:

  1. Pre-upgrade os migrate plan printed four raw [sql-driver] DATABASE_ERROR … no such column: permission_set_package / connector_package lines. Source: the runtime-index preflight ran the package-less guards' duplicate listings on tables whose scope column the pending schema sync has not added yet; SqlDriver.execute logs every refused raw statement. Fix (runtime-index-preflight.ts, read-probe.ts): for a probe whose row scope is COLUMN IS NULL, the preflight first asks the catalog whether the column exists (readColumnPresence, a non-raising pragma_table_info / pg_attribute / information_schema.columns read, the same doctrine read-probe.ts already applies to table presence). Absent: the entry answers unreadable with a sentence naming the column, and the plan's own line carries it. A dialect with no catalog arm, a refused or result-less catalog read: the listing runs exactly as before, so nothing is folded that was not explained.
  2. The conflict boot printed a raw DATABASE_ERROR … UNIQUE constraint failed ahead of the friendly ERROR. Fix (activation-ledger-packageless-index.ts): the migration counts the colliding rows (its own duplicate probe, through the existing countDuplicateKeys) before it sends the build; when rows collide it reports the conflict without provoking the refusal. A count that cannot be read builds as before; any refusal the build then meets (a racing write, a server fault) reaches the operator through the driver's line and the report's detail, unchanged.
  3. The plan said 1 row(s) name no package while four rows named none. The number was the rows the next served boot binds. Fix (activation-ledger-backfill.ts, the one-shot preview): the line counts every package-less row the backfill read, says how many the next served boot binds, and gives the reason each other row stays (environment item, a name nothing holds, a type not addressed by package, a name two packages hold, an item with two rows).
  4. The conflict sentence called a package-held row "an item the environment authored". Fix: the consequence now says the rows name no package, for an item the environment authored or a package's item whose rows predate the ledger's package key, and points to the backfill's line, which names the holder. The migration has no registry to name the holder itself (metadata-protocol cannot import the objectql resolver).

Live readings, before and after (same fixtures; raw DATABASE_ERROR lines counted with grep -c):

step before (base b4624440e) after
pre-upgrade migrate plan 4 raw lines; 1 row(s) name no package 0; 4 row(s) name no package … gives 1 of them … The other 3 keep naming none: 2 for a name no package or environment item holds, 1 for a type not addressed by package
boot 1 index built, flow row bound same; 0 raw lines
plan after boot 1 replace_unique_index safe same; 0 raw lines
boot 2 rows unchanged rows byte-identical (updated_at included); 0 raw lines
conflict boot raw UNIQUE line, then ERROR "for one item the environment authored (no package)" 0 raw lines; one ERROR naming rows that name no package
delete one row, restart index built index built, flow row bound

Tests

  • packages/objectql/src/activation-ledger-backfill.test.ts: a one-shot boot over a ledger with five package-less rows (one bound, four kept for four reasons) and one bound row: the line says 5 row(s) name no package, gives 1 of them, The other 4, and each reason once.
  • packages/metadata-protocol/src/migrations/activation-ledger-packageless-index.test.ts, new describe over real SQLite through a seam shaped like SqlDriver.execute (a SELECT answers rows, a refused statement throws; the driver prints one raw line per refusal, so the refused-statement count is the raw-line count): the conflict sends zero refused statements and logs one ERROR; the sentence names rows that name no package and never "one item the environment authored (no package)"; a count that cannot be read builds and reports the UNIQUE refusal with its text; an unexpected build failure (disk I/O error) is reported failed with the driver's text.
  • packages/metadata-protocol/src/migrations/runtime-index-preflight.test.ts, new describe: a grant table without permission_set_package answers unreadable naming the column, with zero refused statements on that table; CONTROL with the column added: clear; CONTROL with no client (no catalog arm): the listing runs and the dialect's refusal is the answer, as before.
  • packages/metadata-protocol/src/migrations/read-probe.test.ts: readColumnPresence on real SQLite (present, absent, absent table), and unknown (never absent) for no catalog arm, a refused read, no result set.
  • packages/cli/src/utils/schema-sync-indexes.operator-text-21418.test.ts: fixture triage only. Its double answered every read with no rows, which the new catalog column read takes as "column absent"; the double means "column present, the guard's presence read refused", so it now answers the column read with a row. Assertions unchanged.

Ablations (each through scripts/ablation-replace.mjs on a committed tree, restore verified by the tool: blob equals HEAD and git diff HEAD empty):

mutation file result
preview count back to report.bound.length activation-ledger-backfill.ts red: the count pin (expected … 1… to contain '5 row(s) name no package'), 1 failed / 16 passed
pre-build count condition made unreachable (the keys test inverted to "below zero") activation-ledger-packageless-index.ts red: the refused-statement pin (expected [ Array(1) ] to deeply equal []), 1 failed / 22 passed
old consequence wording restored activation-ledger-packageless-index.ts red: the wording pin, 1 failed / 22 passed
column-presence verdict never absent runtime-index-preflight.ts red: expected 'no such column: permission_set_package' to contain 'has no permission_set_package column …', 1 failed / 12 passed

Acceptance notes

  • Same class, not changed here (not measured on this path): the overlay index probe's own member-column check (BEFORE_MEMBER_COLUMN in runtime-index-preflight.ts) still asks with a raising statement, so a store that predates that column would print one raw line on os migrate duplicates / plan; the other probes' table-presence statements (WHERE 1 = 0) also print one per absent optional table. The new readColumnPresence is the helper either would move to.
  • On MySQL the package-less build still learns "index already there" from ER_DUP_KEYNAME, which the driver logs as a raw line on every boot after the first; the grant guard reads the catalog first instead. Read from source, not measured.
  • Every boot of the fixture also logs the documented [security] upgrade impact ERROR lines for the planted unshipped rows: expected, as the checklist item says.

Verification

Head 7685d7612 (merged origin/main at 9499dcc53).

Package suites and typecheck
  • pnpm --filter @objectstack/metadata-protocol test: Test Files 340 passed, 9 skipped (349); Tests 22874 passed, 43 skipped.
  • pnpm --filter @objectstack/objectql test: Test Files 595 passed (595); Tests 12998 passed.
  • pnpm --filter @objectstack/metadata-protocol --filter @objectstack/objectql typecheck: lock VERDICT command-exit 0.
  • CLI files that read the preflight (schema-sync-indexes.operator-text-21418, duplicates.contract, duplicates.null-seam, duplicates.pre-repair, duplicates.created-at-canonical, duplicates.integration, schema-migrate.grant-guard.integration, schema-sync-indexes.integration): 8 files, 47 tests passed; runtime dispatcher-unique-violation-wire-code: 7 passed.
  • pnpm --filter @objectstack/cli exec vitest run --project unit: 418 of 419 files passed; the one red (test/setup-diagnostics-audience.pin.test.ts) was a stale platform-objects dist after merging main; rebuilt, it passes 3/3. CLI integration tier left to CI.
Gate families

node scripts/pm/dispatch-gates.mjs --commands derived 66 families; 63 exited 0. NOT MEASURED locally, left to CI: check:dual-build-cjs-loads and check:i18n-coverage (PREREQUISITE NOT MET: they need a full build of packages this diff does not touch), check:type-check-debt (lock queue budget spent behind another seat's run, exit 3).

🤖 Generated with Claude Code

https://claude.ai/code/session_016WV4cw787kMeaX7oyz7DDC

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

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

10 anchor(s) derived from 2 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 — 27 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 b392ff7bdf4c470d422bc8723aa46dc3e301b87a → packageMentionDocs.

Which tree this was computed on

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

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

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Contract-review-claim: session_016WV4cxDxAYxdtDhtR1kQQe · head 7685d76 · 2026-11-14T22:36:21Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

Review: PASS

review#2 (server area pilot) · area A4 · Fixes #33340 · head 7685d7612297e78702e0405026a4c3d6e3dc7e74 · Clause-② no, not governed. CI on this head was still running at review time (15 success, 16 skipped, 17 in progress, none failing); the merge waits for it as usual.

The two fallback paths asked about

  • Count unreadable, so the build runs as before. countDuplicateKeys (partial-index-probe.ts) answers undefined on a thrown read, a non-result-set answer, or a non-finite count. The new pre-build branch acts only on blocking !== undefined && blocking.keys > 0. Every other case, including { keys: 0 }, falls through to the unchanged try build. Its catch still classifies the refusal, recounts on conflict, and reports the driver's operator-facing text through reportDegradation. A row written between the count and the build therefore reaches the operator exactly as before this PR.
  • An unexpected build error still reaches the operator. Nothing in the catch arm changed except the shared consequence sentence: isDuplicateKeyName → created, otherwise classifyIndexFailure plus operatorFacingErrorText. The new case in activation-ledger-packageless-index.test.ts pins both sides: no build statement is sent when the count reads duplicates, and the build is sent when the count is unreadable.

The other two lines

  • Preflight column read. readColumnPresence answers absent only when the catalog itself answered with zero rows. unknown covers no dialect arm, a refused read and a non-result-set answer, and leaves the listing running as before, so the read can only spare a refusal. It runs after the table-presence check and after the seam liveness probe, so absent is really about the column. nullScopeColumn reads the column off the owning migration's own <column> IS NULL scope constant, so it cannot name a column the migration does not. The answer is unreadable, the same status the listing's own catch gave before, so only the sentence changes and nothing an exit code or --json reader keys on moves.
  • Preview count. packageLessRowCount sums bound + ambiguous + unchanged + failed plus the package-less rows of duplicated. It filters packageId === undefined, because a duplicated entry can also list the row that already names the holder. Against ActivationLedgerBackfillReport (core/src/utils/metadata-activation-store.ts) these buckets are disjoint, so no row is counted twice.

Semver: Clause-②: no and Metadata-protocol: none are right. readColumnPresence, buildColumnPresenceSql and packageLessRowCount are module exports, not root exports: neither @objectstack/metadata-protocol's index.ts nor @objectstack/objectql's index.ts re-exports them (the #30691/#30754 precedent). No status, code or stored row changes. Patch bumps are the right level.

Nits (none blocking):

  • N1: a raw seam that answers [] to every statement now reads every scope column as absent, so its listings answer unreadable where they used to run. That is why the CLI fixture needed its pragma_table_info row. No shipped driver behaves that way after the seam liveness probe, but a later test double that returns [] for everything will meet the same surprise. A line in readColumnPresence's jsdoc saying "an empty result set is read as absent" would help the next author of such a fixture.
  • N2: the preview line still prints only when bound.length > 0. On a database where every package-less row is the environment's own, or unheld, the plan says nothing about them. That matches the card's scope (the wrong count), so it is noted only for the loose-ends card.

Nits only, so this is the final round.


Generated by Claude Code

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

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

ACCEPT · area A4 · head 7685d76 · 2026-11-14T22:54Z

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 14, 2026 22:55
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 14, 2026
Merged via the queue into main with commit b8f6237 Nov 15, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/area-A4-33340 branch November 15, 2026 01:08
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.

activation ledger package-key upgrade: raw DATABASE_ERRORs and wrong counts on the upgrade path

2 participants