Repository navigation
fix(metadata)!: a package-less object-bound action row is keyed per (object, name) on the stored side, so a package-less save never lands in another object's holder - #33318
Conversation
… (object, name) on the stored side DatabaseLoader's save keys rows as the in-memory store keys items (storeRowSlotKey), so storeRowWriteKey counts the holders of the written action's (object, name), never every package holding the name. Its slot read hands a package-less row bound to an object exactly one package binds the name to (under a name two packages hold) on as that package's customization, first in its slot, as the boot pass files it. Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
…es not carry Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
📓 Docs Drift CheckThis PR changes 1 package(s): 1 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 344dfb668826d42ae886163477947fe1588170d4 && git checkout 344dfb668826d42ae886163477947fe1588170d4
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin e0ce1b523c9cdb625211fc866593f57aee9223ee 123588d87515bcb6c762cec4d1a0357d4d6d604f && git checkout -B drift-repro e0ce1b523c9cdb625211fc866593f57aee9223ee && git merge --no-ff 123588d87515bcb6c762cec4d1a0357d4d6d604f
node scripts/docs-audit/affected-docs.mjs --json e0ce1b523c9cdb625211fc866593f57aee9223ee
|
…ess action row Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
…lumn as stored Keyed per (object, name), the o1 row is another slot in a bucket the o2 save does not write; a package-less object-less save names it first. Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
…ver the stored rows, in both save orders Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
…age-less action row Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
|
Contract-review-claim: session_016WV4d1PGptBW3QRQNmy5e6 · head df6d261 · 2026-11-14T16:56:44Z review#3. |
Contract reviewServed-tier: ① Derived judgments
② Semver level
③ Boundary flags
④ Design judgmentSeat ruling A on #32681 (ADR-0150 D4: a customization is keyed per Implemented-by: VERDICT: PASS |
…h the engine dispatch asserts, bound before copy Claude-Session: https://claude.ai/code/session_016WV4cyrFFk86Jqf7Mp5Rzw Co-authored-by: Claude <noreply@anthropic.com>
Review carry — PASS standsHead: From my PASS at
The PASS carries to this head. The ACCEPT cites this note as Regen-provenance and re-reads every check at the landing head. The mirror and single-holder boot fold stays a follow-up on #32681 ( |
|
domain:server#5 · os-elon-musk · session_016WV4cyrFFk86Jqf7Mp5Rzw
|
…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
Part of #32681
Clause-②: yes (narrowing)
Metadata-protocol: none
维护者速读
DatabaseLoader存一条不属于任何包、绑在某对象上的action行时,按(对象, 名字)数持有者(和内存注册表一致),不再按名字数所有包;它按槽读行时,把"名字被两个包持有、只有一个包绑了同一对象"的包外行当作那个包的定制,排在该包自己的行前面交出。(对象, 名字)归属。之前 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,预期新增用例全绿。account、包外行绑contact)的启动预载修复依赖 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 先合入,见 Acceptance notes。What changes
Seat ruling A on #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).DatabaseLoader.savethroughslottedSaveTarget): rows are keyed as the in-memory store keys items (storeRowSlotKey), andstoreRowWriteKeycounts the holders of the written body's identity (slotIdentityOf: an object-bound action's object and name), asstoreWriteKeyalready 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).DatabaseLoader.loadManySlots, andloadSlots, 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, itspackage_idstays empty.Every moved answer, FROM to TO (host wiring a
DatabaseLoader; ALPHA and BETA are two packages,approvethe action name):approveonaccount, BETA's oncontact; a package-less save ofapproveonaccountaccountaccountrow (its customization, D4)approveoncontactalone; a package-less save ofapproveonaccountpackage_idBETA bound toaccount(a binding BETA never declared)accountapproveonaccountalone; a package-less save of an object-lessapprovepackage_idALPHA, object-lessapproveoncontactand a package-less row onaccount; ALPHA's first save ofapproveonaccountaccount, BETA's oncontact, a stored package-less row onaccount(any version order)MetadataManager.get)list('action')without the pass409naming ALPHA and BETA; BETA's row; as listedo1, then a package's save ono2o1row overo1row keeps its column (moved #32540 pin)account, BETA oncontact, package-less save (A-B-save / B-save-A)/actions/account/approvedeclarationambiguous-in-environment(andcontact: no declaration)The second row is the narrowing: an address naming BETA no longer reaches an
accountbinding 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.tsdescribe[#32681](11 cases); the moved metadata: one package's action name bound to two objects keeps ONEDatabaseLoaderrow, so the later save overwrites the earlier binding (ADR-0150 D3/D4) #32540 pin inmetadata-manager-match-endpoint.test.ts;packages/runtime/src/action-package-addressing.test.tsdescribe[#32681](3 cases: real ObjectQL registry, protocol over a MetadataManager from the real MetadataPlugin boot pass, DatabaseLoader over a writablesys_metadatadouble routed through the engine dispatch asserts).accountrouteambiguous-in-environmentand found nocontactdeclaration; the single-holder save stored a[BETA, account]row.Acceptance notes
approveonaccount, a package-less row oncontact) is not in this PR.DatabaseLoader's unscoped plural read folds the package-lesscontactrow into ALPHA by name, so after the boot pass a read naming ALPHA answers thecontactrow where the read without the pass answers ALPHA'saccountrow. Counting per(object, name)there hands both rows on, butmain'sMetadataManager.loadManythen 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 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's keyed-entry stamping first; it is not stacked here (AGENTS.md: a stacked series is not a supported form).approveoncontactalone and a package-less row onaccount, a read naming BETA after the boot pass still answers theaccountrow and/actions/contact/approvefinds no declaration — as onmain. Carried by the follow-up on this card.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.packages/metadata-protocol/src/**orpackages/metadata/src/metadata-manager.ts; indatabase-loader.tsonlyslottedSaveTarget,loadManySlots, the imports and one doc paragraph move (open PR fix(metadata-protocol)!: history and rollback doors refuse a bare two-holder name and address one holder by ?package= #33193 edits the history functions).Verification
Local runs
At c7e35e3:
@objectstack/metadatatest 77/77 files, 2325 tests;@objectstack/objectql595/595 files, 12942 tests;@objectstack/runtime599/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[#32681]10 failed / 1 CONTROL green, the moved o1 pin red; runtime (metadata dist rebuilt, preflight--absentexit 0) 3 of 3 red. Restored to the HEAD blobs, tree clean.After merging
origin/main(with #33299) at 123588d, clean merge:@objectstack/metadatatest 78/78 files, 2412 tests; typecheck exit 0.Generated by Claude Code