Repository navigation
Commit c063734
fix(metadata): a skill the platform registers keeps its own slot beside an app's same-named skill (#37021)
<!-- claude-projects-attribution: {"github_login":"os-warren"} -->
_Requested by **Warren** · [project
thread](https://claude.ai/code/project/chan_01U5RdnAAmkSQmZbqh6FtqZ8?thread=cmsg_01U5RdnAAmkSQmZbqh6FtqZ8VxWpZoGVso4DL2WGJUUUeV)_
Fixes #37013
Part of #37130
Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none — no skills/ page names `_provenance` or its values,
and the new value is one no author writes: the artifact door refuses it
## 维护者速读
-
平台自带的技能和应用里同名的技能以后各存一份、互不覆盖:应用装上不会顶掉平台那份,平台启动或撤回时也不会改写或删掉应用那份;重启、集群其他节点读回来也是两份。
- 属于云端问数加载应用技能这条线,是云端那张卡需要的平台这一半。
- 出错的话最多是同名技能里某一份没被读到,不碰业务数据,可直接撤回。
- 本 PR 带了 ADR-0150 D4 和 ADR-0010 §3.5 的修订说明,属受治理改动(Tier
H):由维护者合并,或经维护者批准后合并。
## Governed
This PR touches `docs/adr/**` and is governed (Tier H): it is landed by
the maintainer, or after the maintainer's approval.
Surface: `packages/spec/src/**` (one enum value, describes, comments),
`content/docs/references/**` (generated), `packages/metadata/src/**`,
`packages/metadata-protocol/src/**` (the save and restore doors, the
boot census), `ui/packages/data-objectstack/src/metadata-client.ts`,
`docs/adr/**` (two amendment notes), `.changeset/**`.
## What changes
The metadata store keyed a package-less write under a name one package
held as that package's customization (ADR-0150 D4), let a package's
first item take over the name's bare slot, and let a removal naming no
package take every slot of a one-holder name. A skill the platform's own
code registers at boot is package-less, so it and an app's same-named
skill overwrote each other in both directions. This gives the platform's
record a marked slot of its own. The mark (`_provenance: 'platform'`) is
a store-slot marker only, and it has one place on an item: the item's
own top-level `_provenance` key. A key of that name nested in the body
(an authored `metadata` record, for one) is the author's data, never the
mark.
**Write and removal.**
- `MetadataManager.register(type, name, data, { origin: 'platform' })`
stamps the body `_provenance: 'platform'` and fills the name's bare slot
whatever packages hold the name, in the registry and in `sys_metadata`
(`slottedWriteKey`, shared by `storeWriteKey` and `storeRowWriteKey`).
- A package's first item never takes over a bare slot holding the
platform's record. `DatabaseLoader` reads the stamp off the stored row's
body, and for a bundled type (`email_template`) off the written member's
row. The environment's own item in the bare slot is still taken over, as
before.
- A package-less environment write under a platform name keeps today's
rule (card item 3 as amended): it takes the bare slot without the stamp,
and the platform's next registration restores its record.
- On a host that declares a package id, the boot pass leaves the
platform's stored record without the host's package, for every type
(`unstampedStoredRow`).
- `MetadataManager.unregister(type, name, { origin: 'platform' })` takes
only the record the platform registered (`storePlatformRemovalKeys`),
for every type, carried to every loader
(`MetadataLoaderDeleteOptions.platformOnly`; `DatabaseLoader` and
`MemoryLoader` check each stored body) and every cluster peer
(`ClusterMetadataRemoval.platformOnly`, dropped when malformed). A
package's item of the name and the environment's own item stay, and
nothing is refused however many packages hold the name.
**Reads and the readers that rebuild the store.**
- `MetadataManager.getPlatformItem(type, name)` reads the platform's
record only: never a package's item, never the environment's own.
- The plural read (`pluralEntryKeys`, behind `loadMany` and
`loadManyKeyed`) gives the platform's entry a key of its own beside a
one-holder name, so the boot pass is handed both rows.
- `list`'s loader admission (`admitLoaderSlots`): the platform's record
shadows, and is shadowed by, the platform's record only.
- A read naming a package is never answered from the platform's record
(`readIdentity`): the registry's platform slot defers to the loaders,
where the package's item may be stored.
- For `action`, a package-less registry slot the platform's registration
stamped is the platform's (`platformSlotsOf`) whether or not a loader
stores it, as an unstored one already was (#32560).
- Reads naming no package keep their rules (card item 4).
**Where the stamp can enter (card item 1 as sharpened).** It is set only
by `register` with the option. One definition of where it lives
(`carriesPlatformStamp`, `isPlatformOrigin`, `withoutPlatformOrigin`,
exported by `@objectstack/metadata`) is read by the store, the artifact
door, and the metadata protocol's restore doors and boot census, so each
refuses or strips it exactly where the store would read it. Every other
write strips or refuses it:
- `register` without the option strips it. A stored row the boot pass
re-registers keeps it only when the `datasource:` row held it as read
(`storedPlatformRows`, recorded in `loadMany`), never because its caller
set it after the read.
- `registerInMemory`, `save` and `rollback` strip it. A `rollback` whose
row is the platform's own record is refused, `409 RESOURCE_CONFLICT`
naming the fix, with nothing written: only the platform's registration
writes that record.
- The metadata protocol's save door strips it: its strip of derived
provenance keys (#16702) already removes the item's own top-level
`_provenance`, the one place the mark lives. Its restore doors
(`rollbackMetaItem`, `revertCommit`'s restore limb, through one body
writer) write a history version back without it.
- The metadata protocol's two undo writes, of a refused batch publish's
landed promotions (`undoLandedPromotions`) and of a failed batch row
write (`undoBatchRowWrite`), put a row back as the same operation found
it, byte for byte: the mark comes back only where the row held it before
that operation.
- A body served from any loader other than a `datasource:` one (`file:`,
`memory:`) is served without it (`servedLoaderBody`, at every loader
read of the manager).
- `getPublished` serves it on the answer's top level only when the
stored item carries it there, and never inside a publish snapshot
(`withoutServedPlatformMarks`).
- The artifact door refuses an item that carries it, with or without a
manifest id: `VALIDATION_ERROR` / 400 at `_provenance`, naming the fix
(`artifactItemPlatformStampRefusal`).
- A body that names a package is that package's item, whatever
`_provenance` it carries (`isPlatformOrigin`).
Class-level options, as `MetadataUnregisterOptions.packageId` already
is: the spec's `MetadataWriteOptions` is not widened.
**Spec.** `MetadataProvenanceSchema`
(`packages/spec/src/kernel/metadata-protection.zod.ts`) gains
`'platform'`, so the stamp is a declared value of the `_provenance`
envelope key every schema spreads and survives a parse. Describe strings
and comments updated; `content/docs/references/**` regenerated by
`gen:docs` (44 reference pages, one enum cell each).
**Metadata protocol.** Besides its doors above, its boot census
`metadata_sealed_overlay_unserved` does not name the platform's own row
beside a package that ships the name. Its other readers read the same
rows by ADR-0150 D4 and ADR-0131 D6, unchanged.
**UI.** `ui/packages/data-objectstack/src/metadata-client.ts` types the
layered read's `provenance` from the spec's `MetadataProvenance`, so it
accepts the new value and cannot trail the enum again.
**Declaration and level.** `_provenance` is on the authorable surface
(`authorable-surface.base.json`), and `SkillSchema` now accepts a value
it refused, so by AGENTS.md's Post-Task Checklist step 3 the kind is
`added`. The kind sets the level: `minor` on the four packages the diff
moves (`@objectstack/spec`, `@objectstack/metadata`,
`@objectstack/metadata-protocol`, `@object-ui/data-objectstack`).
`Clause-②: yes (widening)` stands: nothing an author could write before
is refused now (the artifact door's strict parse refused the value
before this PR, and the door refuses it now). The authorable key set is
unchanged.
The consumer (cloud#4935) passes `{ origin: 'platform' }` from its boot
registration and withdrawal.
## Tests
- `packages/metadata/src/package-slotted-store.test.ts` (10 cases): the
write, takeover, removal and read rules over the registry store, and
copy semantics of stamp/strip; CONTROL: the environment's bare item is
still taken over and D4 still folds a package-less write.
- `packages/metadata/src/loaders/database-loader.test.ts`, first #37013
describe (9 cases): one per Acceptance line, registry plus
`DatabaseLoader` over the shared mock driver, a primed restart included.
- Same file, second #37013 describe (11 cases), from the stored rows and
at every seam: platform, package, then platform again, read by a process
primed from the rows (`get` naming the package, `getPlatformItem`,
`list`, `loadMany`); a node whose registry holds nothing of the name,
with the door's loader ahead of the rows and after them; a read naming
the package beside the registry's platform slot; `registerInMemory`;
`save`; a row given the stamp by its caller after the read; a `file:`
loader's and a `memory:` loader's stamped body; the platform's
withdrawal beside the door's package copy; `MemoryLoader.delete` with
`platformOnly`; a type outside the by-package set (registry, cold node,
an in-memory-only item, the door's copy; CONTROL: the platform's own
record is withdrawn).
- Same file: `action` (the platform's stored record named as the
platform in a refusal beside two packages); `email_template` (the
environment's `fr-FR`, then the platform's `en-US`, then a package's
first `en-US`: the platform's row stays and a cold read finds it).
- `packages/metadata/src/metadata-manager-cluster.test.ts` (3 cases): a
peer drops the platform's record and keeps the package's, in its
registry (an in-memory-only item included) and its door; for a type
outside the by-package set, a peer keeps another writer's item held in
memory alone; a removal whose platform scope is not `true` is dropped
and deletes nothing, with a door that holds the platform's copy beside
the package's.
- `packages/metadata/src/plugin-artifact-platform-stamp.test.ts` (5
cases): the artifact door refuses the value with and without a manifest
id, and on a view container, before storing anything; a connector whose
authored `metadata` record carries the value is stored as authored and
is not the platform's record; CONTROL: no provenance or the package's is
stored.
- `packages/metadata/src/loaders/database-loader.test.ts`, third #37013
describe (19 cases): the value inside a connector's authored `metadata`
record is never the platform's record, at the stored row, at the
platform's withdrawal and at `register`; `rollback` to a version the
platform registered writes it back without the mark; a rollback whose
row is the platform's own record is refused 409 with nothing written,
for a skill beside a package's item (a primed read naming the package
still answers the package's item) and for a view; `getPublished` of a
skill whose snapshot carries the value, of a connector whose authored
`metadata` record carries it, and of a snapshot nested in the platform's
record's snapshot serves it without the value; CONTROL: the platform's
own record is served with it; a host that declares a package id
withdraws the platform's view after a restart; `getPlatformItem` of a
type outside the by-package set answers the platform's row only; every
site that serves a loader's body (`list` over a keyed and a plain
loader, `get`/`load`/`getPlatformItem`, `loadManyKeyed` of both type
kinds over both loader kinds) serves it without the value.
-
`packages/metadata-protocol/src/protocol.platform-mark-rollback.test.ts`
(3 cases): the save door stores a body that carried the value without
it; `rollbackMetaItem` and `revertCommit`'s restore limb, to a history
version that carries the value, store the body without it.
-
`packages/metadata-protocol/src/protocol.reads-environment-only.test.ts`
(1 case added): the boot census does not name the platform's row beside
a package that ships the name; a hook beside it is still named.
- `packages/spec/src/ai/skill.test.ts`: a stored skill carrying
`_provenance: 'platform'` parses; CONTROL: a value outside the enum is
refused at `_provenance`.
<details><summary>Ablations (each mutation landed on disk, the #37013
cases run, restored to HEAD)</summary>
Cases red per ablation, measured at head `a49b8e71`: a metadata-side
mutation over the #37013 cases of the four metadata test files above, a
protocol-side one over the two metadata-protocol files. 42 ablations,
every one red:
| Ablated | Red |
|:--|:--|
| strip in `register` off | 3 |
| boot exception read by loader, not by the row's stamp | 1 |
| `registerInMemory` strip off | 1 |
| `save` strip off | 1 |
| `servedLoaderBody` returns the body as stored | 9 |
| artifact door refusal off | 1 |
| `readIdentity` answers a package read from the platform slot | 1 |
| `admitLoaderSlots`: a loader's platform row shadowed by a package slot
| 1 |
| `admitLoaderSlots`: a platform slot shadows a loader's package item |
1 |
| `pluralEntryKeys` folds the platform entry into the holder's | 1 |
| `platformSlotsOf` ignores the stamp | 1 |
| bundled row predicate reads the slot's first row | 1 |
| non-slotted removal keys unfiltered | 2 |
| `DatabaseLoader.delete` non-slotted row check off | 1 |
| `MemoryLoader.delete` non-slotted check off | 1 |
| `MemoryLoader.delete` slotted `platformOnly` branch off | 3 |
| peer registry branch off | 2 |
| `receivedRemovalOf` `platformOnly` line off | 3 |
| `DatabaseLoader.delete` slotted row check always true | 2 |
| the mark read at a place other than the item's own top-level key | 6 |
| `rollback` strip off | 1 |
| protocol restore strip off | 2 |
| boot census names the platform's row | 1 |
| boot pass stamps the host's package on the platform's row of a type
outside the by-package set | 1 |
| serve strip off at `loaderSlotEntries` | 1 |
| serve strip off at `loaderEntries`, plural arm | 1 |
| serve strip off at `loadDiagnosed` | 1 |
| serve strip off at the keyed-slotted read, keyed arm | 1 |
| serve strip off at the keyed-slotted read, list arm | 1 |
| serve strip off at `admitKeyed`, keyed arm | 1 |
| serve strip off at `admitKeyed`, list arm | 1 |
| view container refusal off | 1 |
| peer branch for by-package types only | 1 |
| `getPlatformItem` of a type outside the by-package set unchecked | 2 |
| a malformed platform scope read as `true` | 1 |
| serve strip off at `loaderSlotsNamed` | 1 |
| serve strip off at `loadMany` | 1 |
| `getPublished` strip off | 3 |
| `getPublished` snapshot strip off | 1 |
| `getPublished` keeps no top-level mark | 1 |
| refusal of a rollback whose row is the platform's record off | 2 |
| `_provenance` dropped from the save door's derived-provenance keys | 1
|
</details>
## Acceptance notes
- A read naming a package that holds no slot no longer falls back to the
platform's record: the platform's record is never a package's item. It
still falls back to the environment's own item (D3), unchanged.
- The realtime `deleted` event of a platform withdrawal names the type
and name with no package, as a removal by name does; only the cluster
payload carries `platformOnly`.
- ADR-0150 D4 and ADR-0010 §3.5 carry dated amendment notes for this
change (ADR-0150's cites cloud ADR-0118, merged as `e738843b`), so the
recorded rules and the code agree (Prime Directive 13).
## Verification
Read first:
1. `packages/metadata/src/package-slotted-store.ts`:
`carriesPlatformStamp` (the mark's one place), `slottedWriteKey` (the
two platform branches), the platform helpers above `isPackageCaller`,
`readIdentity`, `pluralEntryKeys`, `platformSlotsOf`.
2. `packages/metadata/src/metadata-manager.ts`: the stamp/strip in
`register` and `rollback`, `storedPlatformRows` and `servedLoaderBody`,
`registerInMemory`, `save`, `admitLoaderSlots`, the platform branch in
`unregisterAt`, `getPlatformItem`, the peer branch.
3. `packages/metadata/src/loaders/database-loader.ts`: the row predicate
in `slottedSaveTarget` and the `platformOnly` deletes;
`memory-loader.ts` delete.
4. `packages/metadata/src/plugin.ts`: `artifactItemPlatformStampRefusal`
and `unstampedStoredRow`.
5. `packages/spec/src/kernel/metadata-protection.zod.ts`: the one enum
value.
6. `docs/adr/0150-…md` (end of D4) and
`docs/adr/0010-metadata-protection-model.md` (§3.5): the two amendment
notes.
7. `packages/metadata-protocol/src/protocol-package-bindings.ts`
(`stripDerivedProvenance`), `protocol-authoring-gate.ts`
(`restoredBodyWriter`), `protocol-diff-delete-load.ts` (the boot
census): the three protocol sites.
Two-minute check: `pnpm --filter @objectstack/metadata exec vitest run
src/loaders/database-loader.test.ts -t 37013` → 42 passed.
## Local runs (head `a49b8e71`, `main` merged at `f588898c`)
- `@objectstack/metadata`: `tsc --noEmit` exit 0; `vitest run` 83 files,
2698 passed. `database-loader.test.ts -t 37013` 42 passed.
- `@objectstack/metadata-protocol`: `tsc --noEmit` exit 0. Its source
change this round is the removal of one redundant line (the save door's
derived-provenance strip already removes the key), with its two #37013
files green; its full suite ran at `34a193c6`: 23391 passed, 45 skipped.
- `ui/packages/data-objectstack`: `tsc --noEmit` reports no error in
`metadata-client.ts`.
- Derived gates (`dispatch-gates --commands`, 133 commands, derived at
the head): every one exit 0. The spec `.d.ts`-reading gates and
`check:generated` were re-run against a dist `check:generated --fix`
built at the head: exit 0, no file regenerated. NOT MEASURED locally,
exit 3, left to CI: `check-plugin-teardown-shape --self-test` (shallow
clone).
- Correction to an earlier body: the merge of `main` under head
`b934aafc` has second parent `bfd1049f22`, not `8e4ac50d4`.
---
_Generated by [Claude
Code](https://claude.ai/code/session_01JQwxbXCpczENRnUvAvzGDD)_
<!-- signed: repo:objectstack#1 · os-warren ·
session_01JQwxbXCpczENRnUvAvzGDD -->
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent a1b26ff commit c063734
68 files changed
Lines changed: 1600 additions & 134 deletions
File tree
- .changeset
- content/docs/references
- ai
- api
- automation
- data
- identity
- integration
- kernel
- security
- system
- ui
- docs/adr
- packages
- metadata-protocol/src
- metadata/src
- loaders
- spec/src
- ai
- api
- kernel
- ui
- scripts
- ui/packages/data-objectstack/src
Some content is hidden
Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
63 | 63 | | |
64 | 64 | | |
65 | 65 | | |
66 | | - | |
| 66 | + | |
67 | 67 | | |
68 | 68 | | |
69 | 69 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
46 | 46 | | |
47 | 47 | | |
48 | 48 | | |
49 | | - | |
| 49 | + | |
50 | 50 | | |
51 | 51 | | |
52 | 52 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
44 | 44 | | |
45 | 45 | | |
46 | 46 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
91 | 91 | | |
92 | 92 | | |
93 | 93 | | |
94 | | - | |
| 94 | + | |
95 | 95 | | |
96 | 96 | | |
97 | 97 | | |
| |||
115 | 115 | | |
116 | 116 | | |
117 | 117 | | |
118 | | - | |
| 118 | + | |
119 | 119 | | |
120 | 120 | | |
121 | 121 | | |
| |||
139 | 139 | | |
140 | 140 | | |
141 | 141 | | |
142 | | - | |
| 142 | + | |
143 | 143 | | |
144 | 144 | | |
145 | 145 | | |
| |||
163 | 163 | | |
164 | 164 | | |
165 | 165 | | |
166 | | - | |
| 166 | + | |
167 | 167 | | |
168 | 168 | | |
169 | 169 | | |
| |||
187 | 187 | | |
188 | 188 | | |
189 | 189 | | |
190 | | - | |
| 190 | + | |
191 | 191 | | |
192 | 192 | | |
193 | 193 | | |
| |||
0 commit comments