Skip to content

Commit b61bcd2

Browse files
committed
fix(metadata-protocol): an action's list slot takes its object only where a package's action of the name binds it
#33904's list slot keyed every action by (name, object). That split a platform item bound to `lead` from the environment's object-less row of its name, which the action route reads as one slot whose key is the platform item's, so `/actions/_env/lead/approve` served the platform item instead of answering 404 (runtime action-package-addressing.test.ts, red on CI). The object now joins the slot only where a package's contribution of the name binds it: a package-less row there is that package's customization and shares its slot, and package-less contributions on no package's object keep the name's slot, as on main. The #33904 cell (a package's action on one object, the environment's own on another) still lists both. The local helper is renamed from `actionObjectKey`, the #14878 dead-member name the tree-wide repo pins refuse, to `actionSlotSuffix`. Claude-Session: https://claude.ai/code/session_01ADHkmQmQ1jpFsNcARMbY56 Co-authored-by: Claude <noreply@anthropic.com>
1 parent b0e3f1d commit b61bcd2

1 file changed

Lines changed: 32 additions & 9 deletions

File tree

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

Lines changed: 32 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -409,18 +409,41 @@ export function mergePackageAwareOverlay(
409409
const buckets = new Map<string, Contribution[]>();
410410
const order: string[] = []; // first-seen slot order → stable output
411411
// [#33904, ADR-0150 D4] An `action` is keyed `(package, objectName,
412-
// name)`: its slot is `(name, object)` (object-less is its own key), so
413-
// the environment's own action on an object no package's action binds is
414-
// listed beside the package's, as the read naming no package and the
415-
// action route serve it, and never stands in for the package's slot on
416-
// another object. Slotted by name alone, the list dropped it.
417-
const actionObjectKey = (item: unknown): string => {
418-
const object = canonicalMetaUrlType(type) === 'action' ? boundObjectOf(item) : undefined;
419-
return object === undefined ? '' : `\u0001${object}`;
412+
// name)`: a package's action on one object and the environment's own
413+
// package-less action of the name on an object no package's action binds
414+
// are two items, so the latter is listed beside the package's, as the read
415+
// naming no package and the action route serve it, and never stands in
416+
// for the package's slot on another object. Slotted by name alone, the
417+
// 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).
424+
const canonicalSlotType = canonicalMetaUrlType(type);
425+
const actionObjectOf = (item: unknown): string => boundObjectOf(item) ?? '';
426+
const packageHeldObjects = new Map<string, Set<string>>();
427+
if (canonicalSlotType === 'action') {
428+
const hold = (name: unknown, item: unknown, pkg: unknown) => {
429+
if (name === undefined || typeof pkg !== 'string' || pkg === '') return;
430+
const objects = packageHeldObjects.get(String(name)) ?? new Set<string>();
431+
objects.add(actionObjectOf(item));
432+
packageHeldObjects.set(String(name), objects);
433+
};
434+
for (const raw of baseItems) hold(listSlotNameOf(canonicalSlotType, raw), raw, (raw as any)?._packageId);
435+
for (const { data, packageId, stored } of records) {
436+
hold(listSlotNameOf(canonicalSlotType, data) ?? (stored?.name || undefined), data, packageId);
437+
}
438+
}
439+
const actionSlotSuffix = (item: unknown, name: unknown): string => {
440+
if (canonicalSlotType !== 'action') return '';
441+
const object = actionObjectOf(item);
442+
return object !== '' && packageHeldObjects.get(String(name))?.has(object) === true ? `\u0001${object}` : '';
420443
};
421444
const slotOf = (item: unknown, name: unknown): string => {
422445
const disc = itemDiscriminator(type, item);
423-
return (disc === undefined ? String(name) : `${String(name)}\u0000${disc}`) + actionObjectKey(item);
446+
return (disc === undefined ? String(name) : `${String(name)}\u0000${disc}`) + actionSlotSuffix(item, name);
424447
};
425448
// [#32606] The name each slot is of, so a slot's name grain reads its
426449
// sibling members' slots too.

0 commit comments

Comments
 (0)