Repository navigation
fix(metadata)!: MetadataManager.loadMany takes a by-package name's bodies and packages off the loader's keyed entries; loadManyKeyed entries carry their package - #33299
Conversation
…oader's keyed entries Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw
…s values Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw
Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw
📓 Docs Drift CheckThis PR changes 1 package(s): 5 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 2 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 16 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # while this PR is open — GitHub drops the merge commit once it closes
git fetch origin 773feb5016c00c417386d02a3a2c912b87465cd2 && git checkout 773feb5016c00c417386d02a3a2c912b87465cd2
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 9f736f2e2469d159422fb2ce1456bd932278ffff fad580c029a6fa7cdc88b22ad12f883a60ba29bd && git checkout -B drift-repro 9f736f2e2469d159422fb2ce1456bd932278ffff && git merge --no-ff fad580c029a6fa7cdc88b22ad12f883a60ba29bd
node scripts/docs-audit/affected-docs.mjs --json 9f736f2e2469d159422fb2ce1456bd932278ffff
|
|
domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw |
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentStamping by content equality was a guess that failed silently in two measured shapes (F2, F3). Reading each keyed entry's own body and package removes the guess, and the one moved user-visible answer is the refusal the epic's red line asks for. Holds against the cited code and the card. Implemented-by: VERDICT: PASS N1 optional. |
|
domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw
|
…object, name) on the stored side, so a package-less save never lands in another object's holder (objectstack-ai#33318) <!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDZYUbJbnXUTqZoZ56k4czR)_ Part of objectstack-ai#32681 Clause-②: yes (narrowing) Metadata-protocol: none ## 维护者速读 - 改了什么:`DatabaseLoader` 存一条不属于任何包、绑在某对象上的 `action` 行时,按 `(对象, 名字)` 数持有者(和内存注册表一致),不再按名字数所有包;它按槽读行时,把"名字被两个包持有、只有一个包绑了同一对象"的包外行当作那个包的定制,排在该包自己的行前面交出。 - 为什么改:席位裁决 A(2026-11-14T16:12Z):包外行按 `(对象, 名字)` 归属。之前 ALPHA 绑 `account`、BETA 绑 `contact` 时,包外的 `account` 存档写成包外行(而注册表把它当 ALPHA 的定制);只有 BETA 绑 `contact` 时,包外的 `account` 存档被写成 BETA 的 `account` 绑定(BETA 从没声明过);启动预载前后点名 ALPHA 的读答案不同。 - 风险与回滚:只影响接了 `DatabaseLoader` 的宿主(工作区内 0 处);库里已有的行不改不迁移,只改新写入落在哪一行、以及冷读怎么归属;回滚 = revert 本 PR。 - 先看:`packages/metadata/src/loaders/database-loader.ts` 的 `slottedSaveTarget`(风险 hunk:按 `storeRowSlotKey` 分槽、按包桶命名未命名行)与 `loadManySlots`;`packages/metadata/src/package-slotted-store.ts` 的 `storeRowWriteKey` 与 `pluralEntryCustomizedHolders`。 - 两分钟验证:`pnpm --filter @objectstack/metadata exec vitest run src/loaders/database-loader.test.ts -t 32681`,预期新增用例全绿。 - 需要你做的:无,席位落地。镜像形状(ALPHA 绑 `account`、包外行绑 `contact`)的启动预载修复依赖 objectstack-ai#33299 先合入,见 Acceptance notes。 ## What changes Seat ruling A on objectstack-ai#32681: a package-less action row bound to an object is keyed per `(object, name)` everywhere, as ADR-0150 D4 keys an action by `(package, objectName, name)`. - **Save** (`DatabaseLoader.save` through `slottedSaveTarget`): rows are keyed as the in-memory store keys items (`storeRowSlotKey`), and `storeRowWriteKey` counts the holders of the written body's identity (`slotIdentityOf`: an object-bound action's object and name), as `storeWriteKey` already does in memory. A package binding the name to another object is a different key, never a holder of this one. The unique-key bucket a pending object-naming acts on is still the package's (every row of the package the write's slots belong to). - **Slot read** (`DatabaseLoader.loadManySlots`, and `loadSlots`, which filters it): a package-less action row bound to an object that exactly one package binds the name to, under a name two or more packages hold, is handed on held for that package, just before that package's own row of the object (`pluralEntryCustomizedHolders`). That is where the boot priming pass files it: the unscoped plural read keeps it apart from both holders, and the pass registers it after them, so the store's `(object, name)` write rule puts it in that package's slot. Readers that keep a slot's first item (`slotStoreOf`, `list`) now answer it without the pass too. The row is not rebound: no write, its `package_id` stays empty. Every moved answer, FROM to TO (host wiring a `DatabaseLoader`; ALPHA and BETA are two packages, `approve` the action name): | Shape | Answer | FROM | TO | |:--|:--|:--|:--| | ALPHA `approve` on `account`, BETA's on `contact`; a package-less save of `approve` on `account` | the row written | a new package-less row bound to `account` | ALPHA's `account` row (its customization, D4) | | BETA's `approve` on `contact` alone; a package-less save of `approve` on `account` | the row written | a new row with `package_id` BETA bound to `account` (a binding BETA never declared) | a new package-less row bound to `account` | | ALPHA's `approve` on `account` alone; a package-less save of an object-less `approve` | the row written | a new row with `package_id` ALPHA, object-less | a new package-less object-less row | | BETA's `approve` on `contact` and a package-less row on `account`; ALPHA's first save of `approve` on `account` | the row written | a new ALPHA row beside the package-less one | the package-less row, updated and bound to ALPHA (a package's first item takes over the bare slot, as in memory) | | ALPHA's row on `account`, BETA's on `contact`, a stored package-less row on `account` (any version order) | read naming ALPHA without the boot pass (`MetadataManager.get`) | ALPHA's own row | the package-less row, as after the pass | | same | `list('action')` without the pass | ALPHA's row and the package-less row | the package-less row (ALPHA's slot), as after the pass | | same | bare read, read naming BETA, every read after the pass | `409` naming ALPHA and BETA; BETA's row; as listed | unchanged | | a package-less row on `o1`, then a package's save on `o2` | the row written | the package's save takes the `o1` row over | the package's own new row; the `o1` row keeps its column (moved objectstack-ai#32540 pin) | | ALPHA on `account`, BETA on `contact`, package-less save (A-B-save / B-save-A) | `/actions/account/approve` declaration | ALPHA's own body while ALPHA's slot holds the customization / refused `ambiguous-in-environment` (and `contact`: no declaration) | the item ALPHA's slot holds, ALPHA's handler run, in both orders | The second row is the narrowing: an address naming BETA no longer reaches an `account` binding a package-less save wrote into BETA's bucket. Not changed: types other than `action` (their identity is the name, and the slot read's new rule never fires for them); a name one package holds; stored rows (no migration: a stored package-less row is read as its holder's customization, never rebound; rows earlier saves wrote are listed by the ADR-0150 D10 report as before). ## Tests - `packages/metadata/src/loaders/database-loader.test.ts` describe `[objectstack-ai#32681]` (11 cases); the moved objectstack-ai#32540 pin in `metadata-manager-match-endpoint.test.ts`; `packages/runtime/src/action-package-addressing.test.ts` describe `[objectstack-ai#32681]` (3 cases: real ObjectQL registry, protocol over a MetadataManager from the real MetadataPlugin boot pass, DatabaseLoader over a writable `sys_metadata` double routed through the engine dispatch asserts). - BEFORE (observed with the fix reverted): A-B-save judged ALPHA's own body while ALPHA's slot read the customization; B-save-A refused the `account` route `ambiguous-in-environment` and found no `contact` declaration; the single-holder save stored a `[BETA, account]` row. ## Acceptance notes - The mirror shape (ALPHA's `approve` on `account`, a package-less row on `contact`) is not in this PR. `DatabaseLoader`'s unscoped plural read folds the package-less `contact` row into ALPHA by name, so after the boot pass a read naming ALPHA answers the `contact` row where the read without the pass answers ALPHA's `account` row. Counting per `(object, name)` there hands both rows on, but `main`'s `MetadataManager.loadMany` then pairs bodies by content and stamps neither, the pass files ALPHA's body in the bare slot, and a read naming BETA would answer ALPHA's item. That half needs objectstack-ai#33299's keyed-entry stamping first; it is not stacked here (AGENTS.md: a stacked series is not a supported form). - Single-holder cell after boot (same fold as the mirror shape, follows objectstack-ai#32680): with BETA's `approve` on `contact` alone and a package-less row on `account`, a read naming BETA after the boot pass still answers the `account` row and `/actions/contact/approve` finds no declaration — as on `main`. Carried by the follow-up on this card. - The ADR-0150 D10/R15 report's `packageLessRowOwners` (area E1) still counts holders per name, so a package-less row this PR reads as ALPHA's customization is still listed as ambiguous there. Noted for E1. - No change in `packages/metadata-protocol/src/**` or `packages/metadata/src/metadata-manager.ts`; in `database-loader.ts` only `slottedSaveTarget`, `loadManySlots`, the imports and one doc paragraph move (open PR objectstack-ai#33193 edits the history functions). ## Verification <details><summary>Local runs</summary> At c7e35e3: `@objectstack/metadata` test 77/77 files, 2325 tests; `@objectstack/objectql` 595/595 files, 12942 tests; `@objectstack/runtime` 599/599 files, 10678 passed, 19 skipped; metadata + runtime typecheck exit 0; dogfood battery 464 passed / 3 skipped files, 3927 passed / 42 skipped tests, no failures. Derived gates: 70 families, 69 exit 0, 1 NOT MEASURED (`check:dual-build-cjs-loads`, no dist in the worktree; CI Build Core covers it). Ablation (stored-side files reverted to the merge base, landing proven by grep): metadata `[objectstack-ai#32681]` 10 failed / 1 CONTROL green, the moved o1 pin red; runtime (metadata dist rebuilt, preflight `--absent` exit 0) 3 of 3 red. Restored to the HEAD blobs, tree clean. After merging `origin/main` (with objectstack-ai#33299) at 123588d, clean merge: `@objectstack/metadata` test 78/78 files, 2412 tests; typecheck exit 0. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw)_ <!-- signed: domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…e by the _packageId stamp alone; detector for 17.0.0–18.3.0 stamped environment rows (objectstack-ai#32985) (objectstack-ai#33416) <!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDZYUbJbnXUTqZoZ56k4czR)_ Refs objectstack-ai#32985 The card stays open (seat ruling 2026-11-14T19:48Z): the follow-up PR keeps column-bound rows an 18.4.0 boot bound unless history shows them stamped since create (kept on undetermined or with no history table), and notes that a future uninstall UI must use `unregisterPackageWithReport` and surface `kept` (`IMetadataService.unregisterPackage` has no force or result). Clause-②: yes (narrowing) — narrowed: `unregisterPackage(P)` keeps, until `{ force: true }`, items it used to remove (every item stored in a row with an empty `package_id` whose body names P by `_packageId` alone, including every `DatabaseLoader`-stored `object`/`view`/`app`/`page` of P); the boot bind and `migrateDatabaseLoaderRowPackages` leave such rows unbound. Widened: additive in-process surface (`unregisterPackageWithReport`, `{ force }`, `MetadataLoader.stampOnlyRows`, `detectStampOnlyRows`, the `'stamp-only'` left reason). Metadata-protocol: none **BREAKING** (review#3 M1, 6883260484): a caller of `MetadataManager.unregisterPackage` over a `DatabaseLoader` now keeps and reports items whose stored rows name the package by the `_packageId` stamp alone, every `object`/`view`/`app`/`page` item of the package among them. Run `detectStampOnlyRows`, then pass `{ force: true }` (or use `unregisterPackageWithReport`) to remove the package's own items as before. The changeset carries the adr-0087 not-required (no-migration-prescription) marker. The any-source guard (wider than the ruling's `source='database'`) was accepted by review because it only errs toward keeping. ## 维护者速读 - **改了什么**:`unregisterPackage` 遇到「`package_id` 列为空、正文只靠 `_packageId` 印记指向该包」的存储行时,默认保留该条目并报告(`{ force: true }` 才删);启动时的列绑定与运维迁移不再凭这种印记绑定 `package_id`;新增只读检测器 `detectStampOnlyRows`,按每行自己的历史判定印记来源;changeset 附升级说明。 - **为什么改**:17.0.0–18.3.0 在「声明 packageId 的 MetadataPlugin + eager 无 artifactSource + DatabaseLoader」组合下,把宿主印记写进了环境自有的行;main 上卸载宿主包会把这些环境数据连行删掉(18.3.0 实建库 37 行删 34 行),属静默数据丢失红线。 - **风险与回滚**:代价是误保留——非按包存储的类型(object/view/app…)的包自有行同样只有印记,卸载时会被保留并 warn,需 `force`;无数据迁移、无新写入,回滚即 revert 本 PR。 - **先看**:`packages/metadata/src/metadata-manager.ts` 的 `unregisterPackageWithReport`(先全量检查、后删除);`packages/metadata/src/loaders/database-loader.ts` 的 `bindReadRowPackage` 新跳过与 `stampOnlyRows`;`packages/metadata/src/migrations/detect-stamp-only-rows.ts` 的历史链判定。 - **两分钟验证**:`pnpm --filter @objectstack/metadata exec vitest run src/loaders/database-loader.test.ts -t 32985`,预期所有 objectstack-ai#32985 用例通过(18.3.0 形态的行全部保留、`force` 后删除)。 - **需要你做的**:无,席位落地。 ## What changes The binding ruling is the maintainer decision of 2026-11-14 on objectstack-ai#32985 (guard + detector + upgrade note; no ownership-changing migration now), as the seat recorded it on the card. Every `@objectstack/metadata` from 17.0.0 through 18.3.0, on a host whose `MetadataPlugin` declares its `packageId`, primed eagerly with no `artifactSource`, with a `DatabaseLoader`, saved each package-less row its boot pass read back stamped with the host (`_packageId`, `_provenance`). From the row alone such an environment row cannot be told from a row of the host's own item; the objectstack-ai#32986 mark does not reach it, because its stored body already names the host. **1. The guard (red line).** `unregisterPackage(P)` (and the new `unregisterPackageWithReport(P)`) keeps an item, registry entry and rows, when any loader holds a row of it whose `package_id` column is empty and whose stored body names P by `_packageId` alone, neither `packageId` nor the legacy `package` naming any package (`stampOnlyPackageOf`, new `src/stamp-only-row.ts`; `DatabaseLoader.stampOnlyRows`, new optional `MetadataLoader.stampOnlyRows`). Every row is checked before the first removal, so a failed read throws and removes nothing. Each kept item is reported in the result (`kept`, `reason: 'stamp-only-row'`, each row's loader, id and `source`) and in one `warn` naming the detector and `{ force: true }`; `force` removes them as before. The check reads storage at removal time rather than marking registry objects, so no copy a later writer registers can drop it (the hole objectstack-ai#33003 had to close for the objectstack-ai#32986 mark). - **Deliberately wider than the ruling's `source = 'database'`:** the check takes every writer's row. Measured on the 18.3.0-built fixture, the boot also stamped another writer's package-less row (`agent/api_agent`, `source = 'api'`), and `main` deleted it on `unregisterPackage(host)`. Under 64ce235's reading a body stamp in such a row binds nothing (it is the environment's for every column reader), so keeping it only ever keeps an environment row. - **`unregisterPackageWithReport` is a method of its own** because the spec's `IMetadataService.unregisterPackage` answers void and a class method cannot answer more under that signature; the published contract is not widened here. **2. `bindReadRowPackage` (the boot's column-only bind): it can skip stamp-only rows, and does.** FROM binding the empty `package_id` column of a legacy row whose body names its package by `_packageId` alone TO leaving it. Pinned both ways: such a row (the host's stamp, or another package's) is not bound and nothing is written; a legacy row naming its package by its own `packageId` is still bound; and the cost to a genuine pre-objectstack-ai#32246 legacy row is pinned by a CONTROL — a row the host's file item seeded is bound on the same boot by that item's own save (the save path's column-only binding, unchanged). What is left unbound is a legacy row no shipped code rewrites; reads of it are unchanged (the loader reads its package off the body). **3. `migrateDatabaseLoaderRowPackages`** leaves the same rows, new reason `'stamp-only'`. **4. Read-only detector:** `detectStampOnlyRows(store, { packageId? })` in `@objectstack/metadata/migrations`, next to the migration it pairs with and in the shape of the read-only `scrubHistoryDrainedKeys` count — chosen over an `os migrate meta --stored`-style CLI because it is the smallest thing an operator can run against a driver today, touches no package outside `@objectstack/metadata`, and a CLI can wrap it later. It takes `find` only and reports every row whose body names a package by `_packageId` alone with its column empty or naming that package (an 18.4.0 boot bound by-package rows to the host), each with a verdict from its own history, walked back from the row's `checksum` through `previous_checksum` (so another holder's history of the name is never read as its own): `stamp-added` (a version naming no package, then one adding the stamp; `onlyStampAdded` marks the boot's signature), `stamped-since-create`, or `undetermined`. **5. Upgrade note** in the changeset: affected releases 17.0.0–18.3.0, the composition, the symptoms (rows read as host-owned, phantom 409 holders, deletion on uninstall before this change, the 18.4.0 column bind), the detector, and the manual recipe for a `stamp-added` row. It makes no claim about first-party reach (the cloud product's `MetadataPlugin` configuration is owed a separate check). **6. Fold-in (review nit N1 of merged PR objectstack-ai#33299):** `keyedEntryBodies`'s doc comment now says the order handed on is the keyed entries first, then the unkeyed bodies, FROM `loadMany`'s row order. Text only. | Door | FROM | TO | |:---|:---|:---| | `unregisterPackage(P)` over an item a loader stores in a row with an empty `package_id` whose body names P by `_packageId` alone, any `source` | item and rows removed | kept and reported (result `kept`, one `warn`); nothing removed if a check fails | | `unregisterPackage(P, { force: true })` | — | removes them too, as before | | `unregisterPackage(P)` over an item whose body names P by its own `packageId` / `package`, or whose column is bound | removed | removed (unchanged) | | boot column-only bind of a legacy row named by `_packageId` alone | bound to that package | left empty; a row whose package's code still ships is bound by that item's own save | | `migrateDatabaseLoaderRowPackages` over such a row | bound | left `'stamp-only'` | ## Tests - New top-level `describe('[objectstack-ai#32985] …')` in `database-loader.test.ts` (rows seeded as 18.3.0 left them, by-package and other types): the boot binds no column and writes nothing; `unregisterPackageWithReport(host)` keeps every item and row and reports each, one `warn`; another writer's stamped row kept the same; the contract door answers nothing and keeps them, `force` removes them; CONTROL rows naming the host by their own `packageId` removed without `force`; CONTROL another package's removal moves nothing; a failing check throws before any removal. - R7-A pins: the stamp-only legacy agent row (host's stamp, another package's stamp) is not bound; the bind mechanics re-pinned on a row naming its package by its own `packageId`; the file-seeded legacy row CONTROL above. - `detect-stamp-only-rows.test.ts` (new, 8 cases): each verdict, the 18.4.0-bound column, `onlyStampAdded` false, an unprovisioned history table (`unavailable`) vs any other read failure (thrown), the per-row checksum chain beside another holder's history, the rows never reported, `packageId` narrowing, and `find`-only access. - Fixture triage of pins this moves, each re-judged rather than re-spelled in bulk: - **Re-spelled** (they pin binding mechanics, not the stamp): `bind-database-loader-row-packages.test.ts` fixtures `_packageId: A` to `packageId: A` (26 lines), and the two C3 `bindReadRowPackage` cases in `metadata-manager-match-endpoint.test.ts`; the migration's first case now also pins `stamp-only` for a flat and a wrapped stamp-only body and binding for a stamp beside the item's own `packageId`. - **Flipped** (they pinned exactly the removed behaviour): the objectstack-ai#32986 CONTROL "the host's own rows (stamp alone) are still removed" is now kept-and-reported, then removed with `force`; the objectstack-ai#32198 CONTROL for a type outside the set (a `_packageId`-only item's row, which `DatabaseLoader` never column-binds) is now kept-and-reported, then removed with `force`. - **Forced** (they pin what the objectstack-ai#32986/objectstack-ai#33003 mark alone keeps, which `force` does not lift): the objectstack-ai#33003 CONTROLs whose host rows carry the stamp alone (database-loader.test.ts, six writers plus three single cases) and the objectql late-bridge CONTROL (`plugin-late-bridge-environment-row.test.ts`); the objectstack-ai#32353 door-removal CONTROL. ## Acceptance notes - **Rows an 18.4.0 boot already bound are outside the guard.** 18.4.0 (published 2026-11-13) bound the `package_id` column of each stamped by-package row to the host at first boot. Such a row now names the host by its column, so the ruling's criterion (no package column) does not hold and `unregisterPackage(host)` still removes it. The detector reports it (`column` set, verdict from history). Whether the deletion door should also consult history for column-bound rows is a decision, raised in the report, not taken here. - **The guard is deletion-only.** On the replayed fixture the symptoms the upgrade note names still read the same: a stamped row is listed as the host's, and a bare read of `action/helper` is still refused `409 ambiguous-in-environment` naming the host as a holder, until the row is repaired by hand (recipe in the changeset). - **False positives are wide for one class:** `DatabaseLoader` writes no column for a type not stored per `(package, name)`, so every row it stores for a package's item of such a type names the package by the stamp alone and is now kept until `force`. `unregisterPackage` has no first-party production caller (its CHANGELOG records 0). - The detector does not report a row whose column names another package while its body stamp names the host (`flow/pkg_flow` in the fixture): the column owns it. - `MetadataManager.register` of a by-package item read from a stamp-only row still binds that row's column through the save path's column-only binding when it writes the row (unchanged; the boot no longer does). ## Verification Final head `7617d86917` unless a line says otherwise. Base `fca5f89cce`. <details><summary>metadata: typecheck + full suite (head 0ca9978; later commits touch tests only, re-run below)</summary> ``` pnpm --filter @objectstack/metadata typecheck && pnpm --filter @objectstack/metadata test Test Files 79 passed (79) Tests 2418 passed (2418) VERDICT command-exit 0 ``` `tsc --noEmit --listFiles` includes all four edited test files. Detector file re-run at the final head: `Tests 8 passed (8)`. </details> <details><summary>dependents that use the moved doors (head c90052e)</summary> `pnpm --filter @objectstack/objectql --filter @objectstack/runtime --filter @objectstack/metadata-protocol --filter @objectstack/mcp --filter @objectstack/service-datasource test`, after building their closures: ``` objectql Test Files 595 passed (595) Tests 12953 passed (12953) runtime Test Files 599 passed (599) Tests 10678 passed | 19 skipped (10697) metadata-protocol Test Files 339 passed | 9 skipped (348) Tests 22848 passed | 43 skipped (22891) mcp Test Files 64 passed (64) Tests 1174 passed (1174) service-datasource Test Files 75 passed (75) Tests 1317 passed (1317) VERDICT command-exit 0 ``` Chosen by `git grep` for every package outside `metadata` that calls `unregisterPackage`, `bindReadRowPackage`, `migrateDatabaseLoaderRowPackages` or `DatabaseLoaderRowLeftReason`, or whose tests build a `DatabaseLoader`. The rest of the 87-package affected set (`select-shard-packages.sh`, pull_request mode) is `Test Core`'s, in CI. </details> <details><summary>replay over a real 18.3.0-built SQLite database (the card's measurement fixture, 37 rows)</summary> Same probe script as the measurement, pointed at this branch's build: ``` boot bound to host unregisterPackage(host) deleted main stamped 12 34 this stamped 0 0 main control 0 0 this control 0 0 ``` Reads identical to `main` on every probed name; the one write-door difference is the column the boot no longer binds (`action/helper`'s stamped row stays column-empty). Detector over the same file, `packageId: com.host.app`: 37 scanned, 34 reported — 32 `stamp-added` (all `onlyStampAdded`, history `1 then 2`), 2 `undetermined` (rows the fixture inserted raw, without a create in history); the database file's hash is unchanged. Over the never-stamped control: 37 scanned, 0 reported. </details> <details><summary>ablations (head c90052e, restored; git diff HEAD empty afterwards)</summary> Through `scripts/ablation-replace.mjs` (anchor hit x1 then x0, replacement landed), each followed by the three pinning files: ``` A1 unregisterPackage check replaced by an empty row list Tests 6 failed | 1114 passed A2 bindReadRowPackage stamp-only skip removed Tests 5 failed | 1115 passed A3 migration stamp-only branch disabled Tests 12 failed | 1108 passed ``` </details> <details><summary>gates</summary> The 66 families `node scripts/pm/dispatch-gates.mjs --commands` derives for this diff were each run at head `7617d86917`, with each exit code captured before any pipe: **66 of 66 exited 0**. They include `check:where-matcher`, `check:engine-double-contract`, `check:nul-bytes` and `check:dual-build-cjs-loads`. On a first run, before the dependents' dists were built, `check:dual-build-cjs-loads` exited 3 (PREREQUISITE NOT MET); on the run cited here it exited 0. ``` node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack --ran ran-exit.txt Run reconciliation — 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN. ✓ dispatch-gates --ran: 66 derived famil(ies) accounted for — 66 run, 0 NOT-MEASURED (a DERIVED zero — all 66 recorded an exit code and none of them is 3). ``` `eslint --no-inline-config` over the 13 changed TypeScript files: exit 0. CI runs the rest: repo-wide `pnpm lint`, the artifact-roster and wide-population families, and the full `Test Core` matrix. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw)_ <!-- signed: domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw --> --------- Co-authored-by: Claude <noreply@anthropic.com>
…ers per (object, name), so the boot pass keeps a package-less row on another object beside the holder's (objectstack-ai#33422) <!-- claude-projects-attribution: {"github_login":"os-elon-musk"} --> _Requested by **Elon** · [project thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DDZYUbJbnXUTqZoZ56k4czR)_ Fixes objectstack-ai#32681 Clause-②: yes (narrowing) Metadata-protocol: none ## 维护者速读 - 改了什么:动作(`action`)的无包行在非限定的复数读取(`pluralEntryKeys`,`loadMany` / `loadManyKeyed` / `DatabaseLoader` 的非限定读取共用)里,按 `(对象, 名字)` 数持有者:只有当名字唯一的持有包也把该名字绑在同一个对象上时,无包行才并入它(它的定制);绑在没人绑的对象上的无包行是环境自己的条目,单独保留。 - 为什么改:席位裁决 A(2026-11-14T16:12Z)的后一半。之前 ALPHA 把 `approve` 绑在 `account`、一条无包行绑在 `contact` 时,复数读取按名字把两行并成一条、只留最后保存的那行,启动预载后注册表只剩一个;点名 ALPHA 的读取在预载后答出 `contact` 行(ALPHA 从没声明过的绑定),而冷读答 ALPHA 自己的 `account` 行。只有 BETA 绑 `contact`、无包行在 `account` 时同理。 - 风险与回滚:只影响接了 `DatabaseLoader` 的宿主(工作区内 0 处);库里的行不改不迁移,只改复数读取保留哪些行、预载注册哪些;同一对象上的单持有者、两个包持有同名的情形不变;回滚 = revert 本 PR。 - 先看:`packages/metadata/src/package-slotted-store.ts` 的 `pluralEntryKeys`(风险 hunk:`customizes` 判定)与新 helper `entryIdentitiesOf`。 - 两分钟验证:`pnpm --filter @objectstack/metadata exec vitest run src/loaders/database-loader.test.ts -t "counts an action name"`,预期 11 个用例全绿。 - 需要你做的:无,席位落地。 ## What changes Second half of seat ruling A on objectstack-ai#32681 (ADR-0150 D4: an action is keyed by `(package, objectName, name)`). The first half (objectstack-ai#33318) keyed `DatabaseLoader`'s saves and slot reads per `(object, name)`; this one does the same for the unscoped plural read, now that objectstack-ai#33299's keyed-entry stamping is on `main`. `pluralEntryKeys` (`packages/metadata/src/package-slotted-store.ts`) is the key `MetadataManager.loadMany`, `MetadataManager.loadManyKeyed` and `DatabaseLoader`'s unscoped reads keep one entry per. For `action`, an entry that carries no package is now folded into the name's one holder only when that holder binds the name to the entry's own object (or both are object-less): the holders of the entry's `(object, name)`, counted from the row's `bundle_member` column first, else its body's object, through a new helper `entryIdentitiesOf` that `pluralEntryCustomizedHolders` now shares. Bound to an object no package binds the name to, the row is the environment's own entry and keeps a key of its own, so the boot priming pass registers it beside the holder's item and the store's `(object, name)` write rule files it in the bare slot. Every moved answer, FROM to TO (host wiring a `DatabaseLoader`; stored rows; `approve` the action name): | Shape | Answer | FROM | TO | |:--|:--|:--|:--| | ALPHA on `account`, a package-less row on `contact` | plural read (`loadMany`) | one entry, the row saved last | both | | same | registry after the boot pass | `contact` key alone (package-less saved last) / ALPHA's `account` key alone (saved first) | ALPHA's `account` key and the `contact` key | | same, package-less row saved last | read naming ALPHA after the pass | the `contact` row | ALPHA's `account` item, as without the pass | | BETA on `contact` alone, a package-less row on `account` | plural read; registry after the pass | one entry; one key | both; BETA's `contact` key and the `account` key | | same, package-less row saved last | read naming BETA after the pass | the `account` row | BETA's `contact` item, as without the pass | | ALPHA on `account` + a package-less object-less row; ALPHA object-less + a package-less row on `account` | plural read; registry; reads after the pass | one entry, one key | both, both keys, reads equal to the reads without the pass | The narrowing: after the boot pass, a read naming a package no longer reaches a package-less row bound to an object that package never bound the name to. Re-measured with objectstack-ai#33299 merged: the fold no longer loosens a read naming BETA into ALPHA's item. In the mirror shape, a read naming BETA (which holds nothing) answers the environment's `contact` row before and after the pass, in both version orders, and never ALPHA's. Not changed: a name one package holds on one object beside a package-less row on that object (one entry, the row saved last); a name two packages hold (the package-less row keeps its own entry and `pluralEntryCustomizedHolders` names the holder it customizes, as in objectstack-ai#33318); the `/actions/OBJECT/NAME` route's declaration read (see Acceptance notes); types other than `action`; stored rows (no migration). ## Tests - `packages/metadata/src/loaders/database-loader.test.ts`, describe `[objectstack-ai#32681] the plural read counts an action name's holders per (object, name)…` (11 cases): four moved shapes in both version orders (plural read entries, cold reads, registry keys after the real `MetadataPlugin` boot pass, reads after the pass equal to the cold reads, no row updated); CONTROL one package on one object (both orders: one entry, the one saved last, its key); CONTROL two packages on one object (three entries, bare read refused naming both and the environment, before and after the pass). - Moved pin: `[objectstack-ai#32791]` "a package's row bound to an object and an object-less package-less row saved last" — the registry now holds ALPHA's `account` key beside the bare slot (FROM the bare slot alone); the bare reads are unchanged. - `packages/runtime/src/action-package-addressing.test.ts`, describe `[objectstack-ai#32681] /actions/account/approve…` (4 new cases): mirror shape and single-holder cell, both save orders, over the writable `sys_metadata` double, the real `MetadataPlugin` boot pass and the protocol: registry holds both keys, a read naming the holder answers its own item, and the package-less row's route judges that item and runs the environment's handler. ## Acceptance notes - The holder's own route (`/actions/account/approve` in the mirror shape, `/actions/contact/approve` in the single-holder cell) still judges no declaration, before and after this change alike (measured both ways, the metadata fix ablated and rebuilt): its declaration read is the protocol's execution face (`getMetaItemForExecution`), which beside one package holder answers the environment's item on the other object (`judgeBareActionRead` keeps main's answer on that face); the route then sees another object's action. That face is in `packages/metadata-protocol` (area E1), where objectstack-ai#32551 records it as followed up by its owner seat; filed as objectstack-ai#33456 (lease:E1). The route of the package-less row's object judges and runs that one item (pinned). - On the same route the environment's item is served with the holder's `_packageId` and `_provenance: 'package'` (the protocol's artifact envelope lookup goes by name, not `(object, name)`); the route's own `packageId` is unset and the environment's handler runs. Measured in the runtime harness, also area E1, carried by objectstack-ai#33456. - With one package holding the name on one object and a package-less row on that same object, the read naming the package without the pass answers the package's own row, while after the pass it answers the package-less row when that row was saved last (saved first, the pass registers the package's row alone). That fold (one entry per `(package, name)`, the row saved last) is unchanged here and pinned as a CONTROL. - No change in `packages/metadata-protocol/src/**`, `packages/metadata/src/metadata-manager.ts` or `packages/metadata/src/loaders/database-loader.ts`. ## Verification <details><summary>Local runs</summary> At 8efae7e (after merging `origin/main` with objectstack-ai#33193): `@objectstack/metadata` test 78/78 files, 2423 tests; `@objectstack/objectql` 595/595 files, 12978 tests; `@objectstack/runtime` 599/599 files, 10707 passed, 19 skipped; metadata and runtime typecheck exit 0; eslint on the three changed source/test files exit 0; dogfood battery 466 passed / 3 skipped files, 3944 passed / 42 skipped tests. Derived gates: 59 families, 58 exit 0, 1 NOT MEASURED (`check:dual-build-cjs-loads`, no full dist in the worktree; CI Build Core covers it); `dispatch-gates --ran` reconciles 59/59. Ablation (the `customizes` line mutated back to the by-name fold through `ablation-replace.mjs`, metadata rebuilt, `ablation-dist-preflight --absent` exit 0): metadata 8 moved cases red, every CONTROL and the first half's 11 cases green; runtime 4 of 4 new cases red (registry held one key). Route answers in that state equal the fixed state's (holder's route: no declaration; package-less row's route: that item, environment's handler). Restored to the HEAD blob (`git diff HEAD` empty), metadata rebuilt, fix marker back in `dist/`. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw)_ <!-- signed: domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw --> --------- Co-authored-by: Claude <noreply@anthropic.com>
Requested by Elon · project thread
Fixes #32680
Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill teaches how
MetadataManager's plural reads stamp a loader's bodies or whatloadManyKeyedentries carry; the moved answers live in the metadata service's internal read path.维护者速读
MetadataManager.loadMany对按包存放的类型,直接用加载器 keyed 条目里每行自己的 body 和包戳,不再按内容把loadMany的 body 配回行;loadManyKeyed返回的条目带上packageId。DatabaseLoader的宿主(工作区内 0 处);该形状下启动后裸读由答一个 body 改为 409 点名两个包(收窄,已声明);库里的行不动。回滚 = revert 本 PR。packages/metadata/src/metadata-manager.ts的keyedEntryBodies(风险 hunk:剩余 body 的按值比较只决定保留,不决定包);同文件keyedEntryOf;packages/metadata/src/loaders/database-loader.test.ts末尾的[#32680]describe。pnpm --filter @objectstack/metadata exec vitest run src/loaders/database-loader.test.ts -t 32680,预期 54 个用例全绿(本 PR 新增 53 个,加改写的 metadata: the boot priming pass hands a column-bound slotted row to register unstamped, so with two holders of a name the DatabaseLoader save inserts a package-less row (unbundled slotted types) #32458 用例 1 个)。What changes
MetadataManager.loadMany, for an unbundled type stored per(package, name)(PACKAGE_SLOTTED_STORE_TYPES) on a loader that holds items per package (loadManySlots:DatabaseLoader, the artifact door'sMemoryLoader), now hands on each keyed entry's own body, stamped (_packageId) with the package the loader holds that entry for when the body carries the entry's key as itsname(keyedEntryBodies). It no longer pairsloader.loadMany's bodies to the keyed entries by theirJSON.stringify(the formerwithLoaderEntryPackages). Bodies the keyed read cannot name (a row whosenamecolumn is empty) are still handed on after them, unstamped: they areloadMany's bodies less one per keyed entry whose body is the same value (key order aside), so the comparison decides only what is kept, never a package, and it runs only whenloadManyanswers more bodies than the keyed read.MetadataManager.loadManyKeyedentries carrypackageIdwhere the loader's entry carries one (keyedEntryOf), for the slotted path and the bundled one (email_template).Every moved answer, FROM to TO (the changeset carries the same list):
DatabaseLoader)MetadataManager.loadMany409 RESOURCE_CONFLICTnaming both packages (foractionalsoplatform, see notes); the same as without the passloadMany/ boot passloadMany(package, name)MetadataManager.loadManyKeyed{ name, data }{ name, data, packageId }where the loader holds it for a packageNot changed: a name one package holds with no other row's body saying it (CONTROL pins), a name no package holds, and a loader without
loadManySlots. The number of entries both plural reads hand on is unchanged for every shape but F2, where the other row's body is now kept beside both holders.Tests
New top-level describe
[#32680]inpackages/metadata/src/loaders/database-loader.test.ts(53 cases): F2 per boot-pass type with the other row stored first and last (bare read 409 naming both after the pass; reads naming ALPHA, BETA, GAMMA equal the cold read); F3 with a key-reordering loader, plus a row whose name column is empty kept once; F4 per slotted type andemail_template; one holder beside another row's body (every read equals the cold read); CONTROL one holder per type. The #32458 pin "two holders of a name and another row's body that says the same name" moves FROM[[null, ALPHA]]TO[[ALPHA, ALPHA], [BETA, BETA], [null, ALPHA]], its title rewritten to say so.BEFORE, on main
d4fbb4dbwith the same fixtures: 43 of the 53 new cases red, the 10 CONTROLs green. The F2 bare read after the pass answeredcom.alpha.appwith registry keys['helper']for every type.Downstream readers (
MetadataManager.loadMany/loadManyKeyedcallers), consumer direction: objectqlaction-governance,metadata-sync-flow-two-holders,plugin-governance-scoped-metadata,webhook-stored-row-boot-hydration(59 passed); runtimeaction-activation-unpackaged,actions-addressed-route,mcp-package-object-discovery,action-governance-scope-divergence(218 passed).Ablations (each through
scripts/ablation-replace.mjs, mutation landed on disk and restored to the HEAD blob withgit diff HEADempty; the suite readssrc/by relative import, so no build leg):loader.loadMany(no stamp at all): 42 red (the CONTROLs among them, since this drops every stamp), the 12 F4 cases green;keyedEntryOfwithoutpackageId: the 12 F4 cases red, nothing else;JSON.stringifyinstead of by value: the F3 case red (the empty-name row handed on twice);Acceptance notes
approveonaccount, BETA's oncontact, a package-less one onaccount; the cold read naming ALPHA answers ALPHA's row, after the boot pass it answers the package-less row. The mirror shape moves too: one holder ALPHA onaccountand a package-less row oncontacthand on one row (the package-less one, folded into ALPHA by the loader's per-name D4 rule), so after the pass a read naming ALPHA answers thecontactrow where the cold read answers ALPHA'saccountrow. ADR-0150 D4's action key(package, objectName, name)and its R15 row ("two holders → the ambiguous set") read the shape two ways, so it is not settled here.action, the F2 bare refusal after the pass also namesplatform: the other row (stored under its own key) is registered under its body's name in the bare slot, and an action name's package-less registry slot that no loader stores under that name counts as the platform's (metadata: in-process bare action reads disagree with the protocol on package-less holders, and a bare removal beside one package takes every slot (ADR-0150 D3/D4, follow-up of #32365) #32560). The boot pass registering a stored row under its body'snamerather than its row key is unchanged here.packages/metadata-protocol/src/**and none inpackages/metadata/src/loaders/database-loader.ts(open PR fix(metadata-protocol)!: history and rollback doors refuse a bare two-holder name and address one holder by ?package= #33193 edits it).Verification
metadata suite and typecheck on fad580c
Targeted gates run locally
Generated by Claude Code