Skip to content

Commit 73c2de8

Browse files
committed
fix(metadata-protocol): a package's object-less action is a list key of its own, and the list's moved cells are declared
L2 S2: beside a package's OBJECT-LESS action, the read and the bare delete naming no package served and removed the environment's own action on another object, while the list slotted both by name and named the package's only. Object-less is now a key of its own in the list slot too, so the list names both, as the read does. L2 S1: the list's key slotting moves two cells with no environment-own action (two packages on two objects with a package-less row on one; a list scoped to a package beside the environment's row on another object). Each is pinned with its BASE in protocol.action-list-slot-key.test.ts and given its FROM and TO in the changeset and the ADR-0087 entry. N1: packagelessHolderRefusal's docblock keeps the one-enabled-shipper gap (#38769). N2: the bare-write entry's surface excludes a stored package-less row. N3: the hydrated-doc entry counts a disabled shipper, as the code does. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude <noreply@anthropic.com>
1 parent b61bcd2 commit 73c2de8

8 files changed

Lines changed: 156 additions & 24 deletions

‎.changeset/34452-same-name-writes-and-hydration.md‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,10 @@ Metadata-protocol: none
1212

1313
**BREAKING** for a caller that writes or reads a shared name without naming a package, shipped as `patch`: no key an author writes changes (`Metadata-protocol: none`). Four doors that name no package answered by save or registration order, or disagreed with the read of the same name; each now gives the read's answer. Naming the package (`?package=ID`, or `packageId` in process) writes or reads that package's item exactly as before.
1414

15-
- **A bare write beside a disabled package's row** (#34346). Two enabled packages ship the name and its stored rows are bound to a disabled package and to one shipper. FROM the bare publish save answering 200 and writing that shipper's row, and the bare draft save and delete refusing naming that shipper and the disabled package, TO all three refusing `409 RESOURCE_CONFLICT` naming the two shippers, as the bare read does, never the disabled package, and writing or removing nothing.
16-
- **A doc row hydrated after a restart beside two holders** (#34417, ruling 6942962369). FROM the row wearing the first registered holder's envelope, so `?package=FIRST` served the environment's row and every read naming no package refused 409, TO every read naming no package serving the environment's row and `?package=FIRST` serving that holder's own doc.
17-
- **The environment's own action on another object** (#33904, ADR-0150 D4). A package holds an action name on one object and the environment stores its own package-less action of the name on another. FROM the plain read, `/layers` and `/published` naming no package serving the package's action, the merged list naming only it, and the bare delete removing the package's row, TO those reads serving the environment's action, the list naming both, and the bare delete removing the environment's row.
15+
- **A bare write beside a disabled package's row** (#34346). Two enabled packages ship the name and its stored rows are bound to a disabled package and to one shipper, with no package-less row of the name. FROM the bare publish save answering 200 and writing that shipper's row, and the bare draft save and delete refusing naming that shipper and the disabled package, TO all three refusing `409 RESOURCE_CONFLICT` naming the two shippers, as the bare read does, never the disabled package, and writing or removing nothing.
16+
- **A doc row hydrated after a restart beside two holders, a disabled one counted** (#34417, ruling 6942962369). FROM the row wearing the first registered holder's envelope, so `?package=FIRST` served the environment's row and every read naming no package refused 409, TO every read naming no package serving the environment's row and `?package=FIRST` serving that holder's own doc.
17+
- **The environment's own action on another object** (#33904, ADR-0150 D4). A package holds an action name on one object (or object-less) and the environment stores its own package-less action of the name on another. FROM the plain read, `/layers` and `/published` naming no package serving the package's action, the merged list naming only it, and the bare delete removing the package's row, TO those reads serving the environment's action, the list naming both, and the bare delete removing the environment's row.
18+
- **The merged action list where a package binds the object** (#33904, ADR-0150 D4). The list now slots an action at its `(package, objectName, name)` key wherever a package's action of the name binds the object, object-less being a key of its own. Two cells move with no environment-own action. Two packages hold the name on two objects and a package-less row is stored on one: FROM the row listed under both packages and the second package's own action dropped, TO the row listed under its object's package and the second package's own action listed. A list scoped to a package whose action is bound to one object, beside the environment's row on another: FROM that package's slot serving the environment's row, TO its own action. Where no package holds the name, the list slots by name as before.
1819
- **A package-less action row beside an enabled and a disabled holder on its object** (#34258). FROM the read naming no package answering 404 when the disabled holder registered first, TO 200 serving the row as the enabled holder's customization in both orders. And where every holder on the row's object is disabled while an enabled package holds the name on another object: FROM 200 serving the row (the name, not the key, was judged, and it had an enabled holder) TO 404, as a key whose every holder is disabled answers with no other holder of the name.
1920

2021
The registry's heal for a package-less overlay row whose every holder is disabled (#33127) now keeps it recorded with no holder, so enabling one holder rebuilds it under that holder's envelope; no door's answer moves.

‎packages/metadata-protocol/src/protocol-overlay-merge.ts‎

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -415,12 +415,12 @@ export function mergePackageAwareOverlay(
415415
// naming no package and the action route serve it, and never stands in
416416
// for the package's slot on another object. Slotted by name alone, the
417417
// list dropped it. The object joins the slot only where a PACKAGE's
418-
// contribution of the name binds it (object-less is its own key): a
419-
// package-less row there is that package's customization and shares its
420-
// slot, and package-less contributions on no package's object keep the
421-
// name's slot, as before (a platform item and the environment's
422-
// object-less row of its name stay one slot, which the action route reads
423-
// as the platform item's key).
418+
// contribution of the name binds it, object-less being a key of its own
419+
// (`\u0001` alone): a package-less row there is that package's
420+
// customization and shares its slot, and package-less contributions on no
421+
// package's object keep the name's slot, as before (a platform item and
422+
// the environment's object-less row of its name stay one slot, which the
423+
// action route reads as the platform item's key).
424424
const canonicalSlotType = canonicalMetaUrlType(type);
425425
const actionObjectOf = (item: unknown): string => boundObjectOf(item) ?? '';
426426
const packageHeldObjects = new Map<string, Set<string>>();
@@ -439,7 +439,7 @@ export function mergePackageAwareOverlay(
439439
const actionSlotSuffix = (item: unknown, name: unknown): string => {
440440
if (canonicalSlotType !== 'action') return '';
441441
const object = actionObjectOf(item);
442-
return object !== '' && packageHeldObjects.get(String(name))?.has(object) === true ? `\u0001${object}` : '';
442+
return packageHeldObjects.get(String(name))?.has(object) === true ? `\u0001${object}` : '';
443443
};
444444
const slotOf = (item: unknown, name: unknown): string => {
445445
const disc = itemDiscriminator(type, item);

‎packages/metadata-protocol/src/protocol-save.ts‎

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3641,10 +3641,15 @@ export async function packagelessRowHeldBaseDraftAddress(
36413641
* leave to the write), a type the registry does not read by package, or a
36423642
* registry without the reads.
36433643
*
3644-
* [#34346] With an enabled and a disabled holder, the draft save and the
3645-
* delete take their address from the rows, so their refusal of rows bound to
3646-
* two or more packages is judged by {@link disabledRowHoldersRefusal}, which
3647-
* never names the disabled package.
3644+
* [#34346] With two or more ENABLED shippers and a disabled holder, the draft
3645+
* save and the delete take their address from the rows, so their refusal of
3646+
* rows bound to two or more packages is judged by
3647+
* {@link disabledRowHoldersRefusal}, which never names the disabled package.
3648+
*
3649+
* Known gap (#38769): with ONE enabled shipper and the rows bound to it and to
3650+
* a disabled package, that helper answers `undefined` and the draft save and
3651+
* the delete still refuse `409` naming the disabled package, where the read
3652+
* serves the enabled shipper and the publish save writes its row.
36483653
*/
36493654
export function packagelessHolderRefusal(
36503655
host: Pick<ProtocolHost, 'engine' | 'shippedArtifactsOf'>,
Lines changed: 87 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license.
2+
3+
/**
4+
* [#33904, ADR-0150 D4] The merged action list slots an action at D4's key
5+
* `(package, objectName, name)` where a PACKAGE's contribution of the name
6+
* binds the object (object-less being a key of its own), and by name
7+
* elsewhere, as before.
8+
*
9+
* Each cell names its FROM (the list slotted every action by name) and its TO.
10+
* A package-less row on a package's object is that package's customization
11+
* and shares its slot; a package-less row on no package's object is the
12+
* environment's own item and is listed beside the packages'. Package-less
13+
* contributions with no package holding the name keep one slot, which the
14+
* action route reads as the platform item's key
15+
* (runtime `action-package-addressing.test.ts`).
16+
*
17+
* The read and delete halves, through the protocol, are pinned in
18+
* `protocol.packageless-save-address.test.ts`.
19+
*/
20+
21+
import { describe, expect, it } from 'vitest';
22+
import { mergePackageAwareOverlay } from './protocol-overlay-merge.js';
23+
24+
const NAME = 'approve';
25+
const action = (label: string, objectName?: string, packageId?: string) => ({
26+
name: NAME, label, type: 'url', target: `https://example.invalid/${label}`,
27+
...(objectName ? { objectName } : {}),
28+
...(packageId ? { _packageId: packageId } : {}),
29+
});
30+
const row = (data: object, packageId?: string, standIn = false) => ({
31+
data, packageId, stored: { type: 'action', name: NAME }, ...(standIn ? { standIn: true } : {}),
32+
});
33+
/** `[label, objectName, package]` of each listed item, in list order. */
34+
const listed = (out: unknown[]) => (out as any[]).map((i) => [i.label, i.objectName ?? null, i._packageId ?? null]);
35+
36+
describe('[#33904] the list slots an action at its key where a package binds the object', () => {
37+
it('two packages on two objects, a package-less row on one of them: the row is that package\'s customization, and the other package\'s own item is listed (BASE: the row under both packages, P2\'s item dropped)', () => {
38+
const out = mergePackageAwareOverlay('action', [action('p1', 'account', 'P1'), action('p2', 'contact', 'P2')], [row(action('env', 'account'))]);
39+
expect(listed(out)).toEqual([['env', 'account', 'P1'], ['p2', 'contact', 'P2']]);
40+
});
41+
42+
it('a list scoped to a code package P on `account`, the environment\'s row on `contact` passed as a stand-in: P\'s slot is P\'s own item, and the stand-in seats none (BASE: P\'s slot served the environment\'s body)', () => {
43+
const unseated = new WeakSet<object>();
44+
const out = mergePackageAwareOverlay('action', [action('p', 'account', 'P')], [row(action('env', 'contact'), undefined, true)], undefined, unseated);
45+
expect(listed(out)[0]).toEqual(['p', 'account', 'P']);
46+
// The stand-in reaches a slot of its own: emitted and recorded, so the
47+
// caller drops it once the last layer has merged.
48+
expect((out as any[]).slice(1).every((item) => unseated.has(item))).toBe(true);
49+
});
50+
51+
it('a package\'s OBJECT-LESS action stored, the environment\'s row on `contact`: both listed (BASE: P\'s item only)', () => {
52+
const out = mergePackageAwareOverlay('action', [], [row(action('p'), 'P'), row(action('env', 'contact'))]);
53+
expect(listed(out)).toEqual([['p', null, 'P'], ['env', 'contact', null]]);
54+
});
55+
56+
it('a code package\'s OBJECT-LESS action, the environment\'s row on `contact`: both listed (BASE: the environment\'s body under P\'s name)', () => {
57+
const out = mergePackageAwareOverlay('action', [action('p', undefined, 'P')], [row(action('env', 'contact'))]);
58+
expect(listed(out)).toEqual([['p', null, 'P'], ['env', 'contact', null]]);
59+
});
60+
61+
it('a package on `account`, the environment\'s OBJECT-LESS row: both listed (BASE: P\'s item only)', () => {
62+
const out = mergePackageAwareOverlay('action', [], [row(action('p', 'account'), 'P'), row(action('env'))]);
63+
expect(listed(out)).toEqual([['p', 'account', 'P'], ['env', null, null]]);
64+
});
65+
66+
describe('CONTROLs (unchanged)', () => {
67+
it('a package-less row on the object a package binds is its customization', () => {
68+
const out = mergePackageAwareOverlay('action', [action('p', 'account', 'P')], [row(action('env', 'account'))]);
69+
expect(listed(out)).toEqual([['env', 'account', 'P']]);
70+
});
71+
72+
it('a package-less OBJECT-LESS row beside a package\'s object-less action is its customization', () => {
73+
const out = mergePackageAwareOverlay('action', [action('p', undefined, 'P')], [row(action('env'))]);
74+
expect(listed(out)).toEqual([['env', null, 'P']]);
75+
});
76+
77+
it('no package holds the name: a platform item on `lead` and the environment\'s object-less row stay one slot', () => {
78+
const out = mergePackageAwareOverlay('action', [action('platform', 'lead')], [row(action('env'))]);
79+
expect(listed(out)).toEqual([['env', null, null]]);
80+
});
81+
82+
it('another type is slotted by name alone', () => {
83+
const out = mergePackageAwareOverlay('flow', [{ name: NAME, label: 'p', objectName: 'account', _packageId: 'P' }], [row({ name: NAME, label: 'env', objectName: 'contact' })]);
84+
expect(listed(out)).toEqual([['env', 'contact', 'P']]);
85+
});
86+
});
87+
});

‎packages/metadata-protocol/src/protocol.packageless-save-address.test.ts‎

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -766,6 +766,27 @@ describe('[ADR-0150 D4] a package-less save of an ACTION on an object the holder
766766
});
767767
}
768768

769+
// [#33904, ADR-0150 D4] P's OBJECT-LESS action is a key of its own, so
770+
// the environment's row on `task` is its own item beside it: the list
771+
// names both, as the read and the delete naming no package already serve
772+
// and remove the environment's (BASE: the list named P's item only).
773+
it('[#33904] P\'s action OBJECT-LESS, the environment\'s on `task`: the list names both, the read naming no package serves the environment\'s, and the delete naming no package removes it', async () => {
774+
const { protocol, rows } = makeProtocol();
775+
await protocol.saveMetaItem({ type: 'action', name: NAME, item: action(NAME, 'p'), packageId: WRITABLE });
776+
await protocol.saveMetaItem({ type: 'action', name: NAME, item: action(NAME, 'env', 'task') });
777+
expect(stored(rows('action', NAME))).toEqual([[WRITABLE, null, 'p'], [null, 'task', 'env']]);
778+
const face = (item: any) => [item?.objectName ?? null, item?.label ?? null];
779+
780+
const listed = ((await protocol.getMetaItems({ type: 'action' })).items as any[])
781+
.filter((item) => item?.name === NAME).map(face)
782+
.sort((a, b) => String(a[0]).localeCompare(String(b[0])));
783+
expect(listed).toEqual([[null, 'p'], ['task', 'env']]);
784+
expect(face((await protocol.getMetaItem({ type: 'action', name: NAME })).item)).toEqual(['task', 'env']);
785+
786+
await protocol.deleteMetaItem({ type: 'action', name: NAME });
787+
expect(stored(rows('action', NAME))).toEqual([[WRITABLE, null, 'p']]);
788+
});
789+
769790
it('[#33904] CONTROL: with no environment row on another object, the delete naming no package removes P\'s row, as the generic re-addressing does', async () => {
770791
const { protocol, rows } = makeProtocol();
771792
await protocol.saveMetaItem({ type: 'action', name: NAME, item: action(NAME, 'p', 'invoice'), packageId: WRITABLE });

‎packages/spec/src/migrations/entries/semantic/19.bare-write-beside-disabled-row-refused-naming-shippers.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ export const entry: SemanticMigration = {
1818
'The save that names no package (PUT /api/v1/meta/TYPE/NAME, as a publish save and as a draft save, and the '
1919
+ 'in-process save with no packageId) and the delete that names no package (DELETE /api/v1/meta/TYPE/NAME and the '
2020
+ 'in-process delete with no packageId) of a name two or more enabled packages ship while its stored rows are '
21-
+ 'bound to a disabled package and to one of the shippers',
21+
+ 'bound to a disabled package and to one of the shippers, and no package-less row of the name is stored',
2222
replacement:
2323
'Name the package: PUT or DELETE /api/v1/meta/TYPE/NAME?package=PACKAGE (and the in-process save and delete with '
2424
+ 'packageId) writes or removes that enabled package\'s row, as before. The write that names no package answers '

0 commit comments

Comments
 (0)