Skip to content

Commit 616dbbd

Browse files
committed
fix(metadata-protocol): scope the two-holder judgment to flow and action, and pin the mixed case
The every-shipper judgment of a declared override moves the action only; the six sealed types keep the single-owner judgment. The env-wide list drops a two-shipper override's pair slot for flow and action only; every other type keeps the pair's entry. Pins two holders where only one has a declared override, in both registration orders. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cwJFqk2CMKeRryL5aB
1 parent c0b7cb1 commit 616dbbd

4 files changed

Lines changed: 67 additions & 7 deletions

File tree

‎.changeset/32613-two-holder-override-slots.md‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,6 @@ Two packages ship a flow or an action of the same name. Each has a declared over
1717
- **An action's override.** The reads judged an action's stored row as a declared override against the name's first registered shipper only. So the second package's declared override was declined at its own address (`?package=`, plain and layered), in its served-overrides list, in the served list and in the execution view, all of which served that package's shipped action instead. Alpha first, the lists gave `alpha:OVR-A` twice and `beta:SHIPPED-beta`. Beta first, they gave `alpha:SHIPPED-alpha` and `beta:OVR-B` twice. With the first package disabled, the enabled package's override was still declined. Now each package's address and both lists serve its own override: exactly `alpha:OVR-A` and `beta:OVR-B`, in either order. A flow was already judged against every shipper.
1818
- **The boot pull.** The hydration decides which stored row holds a flow name's bare registry slot. It judged a row as a declared override against the first holder only. So the second holder's override counted as a plain stored row. If a package-less row was read after it, that row took the slot and the override was lost. The automation boot pull then armed that holder's shipped flow until `kernel:ready` re-armed from the protocol's view. A record change in that window ran the wrong body. Now a row is judged against every package that ships the name, and each override is armed in its own package's slot from the first pull.
1919

20+
Only flow and action move. For the six sealed types (page, app, dataset, doc, book, mapping), a second holder's declared override is still judged against the name's first registered shipper, and for every other overlay type the env-wide list keeps the pair's entry, as before. Those, and what a registry reader gets for each holder of an action name, are carried to #33131.
21+
2022
No door refuses a request it answered before, and no key, value or stored shape changes. The flow's by-name reads (`?package=`) already answered each package's own override and are unchanged.

‎packages/metadata-protocol/src/protocol-lock-state.ts‎

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -158,6 +158,8 @@ export function declinesStoredRow(
158158
// never only the override of whichever shipper the by-name lookup happens
159159
// to find first (the first holder to register), which made the answer
160160
// depend on registration order (red line 2).
161+
// Used for a flow and an action only (the six sealed types below keep the
162+
// single-owner judgment).
161163
// No row, no override: the shippers are not read for a name-only question.
162164
const servedOverrideOfAShipper = (shippedType: string, shippedName: string): boolean => row !== undefined && row !== null
163165
&& (isServedOverrideRowOf(row, this.packagedArtifactOwner({ type: shippedType, name: shippedName }), installed)
@@ -182,13 +184,19 @@ export function declinesStoredRow(
182184
// way: its declared override is served over the base's name from its
183185
// row, so the layered read's `effective` and a by-name read answered by
184186
// the metadata service see it as the registry's readers do.
185-
// [#32613] …against every package that ships the name, as the flow's
186-
// above: with two holders of an action name, the second holder's declared
187-
// override was judged against the first's package and declined at its own
188-
// address, in the served list and in the execution view, so which
189-
// holder's override ran depended on which package registered first.
190-
return !((servesSealedOverrideRow(type) || canonicalMetaType(type) === 'action')
191-
&& servedOverrideOfAShipper(type, name));
187+
// [#32613] …for an `action`, against every package that ships the name,
188+
// as the flow's above: with two holders of an action name, the second
189+
// holder's declared override was judged against the first's package and
190+
// declined at its own address, in the served list and in the execution
191+
// view, so which holder's override ran depended on which package
192+
// registered first.
193+
if (canonicalMetaType(type) === 'action') return !servedOverrideOfAShipper(type, name);
194+
// The six sealed types keep the single-owner judgment (the name's first
195+
// registered shipper) here: moving them to every shipper changes what a
196+
// read naming no package answers for each of them, which is measured and
197+
// pinned on its own follow-up card (#33131), not by this change.
198+
return !(servesSealedOverrideRow(type)
199+
&& isServedOverrideRowOf(row, this.packagedArtifactOwner({ type, name }), installed));
192200
}
193201

194202
/** The body of `ObjectStackProtocolImplementation#isUnservedSealedOverlay`; the method's docblock there is its contract. */

‎packages/metadata-protocol/src/protocol-meta-list-reads.ts‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,15 @@ function decorateListedItem(type: string, item: unknown): unknown {
9292
return { ...served, name: (item as { name: string }).name, ...(_diagnostics !== undefined ? { _diagnostics } : {}) };
9393
}
9494

95+
/**
96+
* [#32613] The types whose env-wide list drops a two-shipper override's pair
97+
* slot: the two whose answer, for a name two or more packages ship, each with
98+
* its declared override, is measured and pinned (each override once, in its
99+
* own package's slot, in either registration order). Any other type of such a
100+
* name keeps its pair's entry, as before.
101+
*/
102+
const TWO_HOLDER_PAIR_SLOT_TYPES: ReadonlySet<string> = new Set(['flow', 'action']);
103+
95104
/** The body of `ObjectStackProtocolImplementation#readFlattenedMetaItems`; the method's docblock there is its contract. */
96105
export async function readFlattenedMetaItems(host: Pick<ProtocolHost, 'artifactLockLayerAt' | 'baseServesBundleMember' | 'convertStoredItem' | 'declinesStoredRow' | 'disabledActionsOf' | 'engine' | 'environmentId' | 'expandStoredViewContainers' | 'findEnvironmentRows' | 'flowRegistrationsOf' | 'foldObjectExtendersFromRegistry' | 'getServicesRegistry' | 'governServedObject' | 'hydrateOverlayIntoRegistry' | 'isStoredEntryOfDeclinedName' | 'isUnservedSealedOverlay' | 'isWritablePackage' | 'lookupArtifactItem' | 'namesWithOwnStoredRow' | 'readActiveOverlayRows' | 'rethrowUnlessMetadataStoreUnprovisioned' | 'shippedArtifactsOf' | 'shippingPackagesOf' | 'shipsBundleName' | 'storedOverlayEntries'>, request: { type: string; packageId?: string; names?: readonly string[]; previewDrafts?: boolean },
97106
audience: 'served' | 'execution',
@@ -793,6 +802,8 @@ export async function readFlattenedMetaItems(host: Pick<ProtocolHost, 'artifactL
793802
// and body, against each shipper. Every other item of such a name is kept
794803
// as before (ADR-0048 §3.3), and a name one package ships is narrowed
795804
// above as before, which already drops the pair's slot.
805+
// Only for `flow` and `action` ({@link TWO_HOLDER_PAIR_SLOT_TYPES}): any
806+
// other type of such a name keeps its pair's entry, as before.
796807
if (servedOverride && !packageId && request.type !== 'package') {
797808
const typeShipping = host.shippingPackagesOf(request.type);
798809
const isBundle = ITEM_KEY_DISCRIMINATORS[request.type] !== undefined;
@@ -807,6 +818,10 @@ export async function readFlattenedMetaItems(host: Pick<ProtocolHost, 'artifactL
807818
const shippers = shippersOf.get(itemName)!;
808819
if (shippers.has(bound)) return true;
809820
if (shippers.size > 1) {
821+
// Scoped to the two types whose two-holder answer is measured
822+
// and pinned (flow, action); every other type keeps the item
823+
// as before, carried to its own follow-up card (#33131).
824+
if (!TWO_HOLDER_PAIR_SLOT_TYPES.has(PLURAL_TO_SINGULAR[request.type] ?? request.type)) return true;
810825
return ![...shippers].some((shipper) =>
811826
isServedOverrideRowOf({ type: request.type, package_id: bound, metadata: it }, shipper, installed));
812827
}

‎packages/objectql/src/protocol-flow-custom-override.test.ts‎

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,41 @@ describe('[#32613] two packages ship one name, each with its declared override:
485485
}
486486
});
487487

488+
// Mixed (review n1): two holders, only one with a declared override.
489+
// Flow: the overridden holder's override and the other holder's
490+
// shipped body, each once, in its own slot, whichever holder is
491+
// overridden. Action: the overridden holder's override is listed in
492+
// its own slot and served at its own address. The other holder's list
493+
// slot is NOT pinned here: when the second holder to register is the
494+
// overridden one, the first holder's slot lists that override too, on
495+
// `main` as on this change (the registry face: the hydrator registers
496+
// the override row under the bare name wearing the first shipper's
497+
// envelope), carried to #33131.
498+
it(`flow and action, ${first} registered first, one holder overridden: its override in its own slot`, async () => {
499+
for (const [overridden, other] of [[ALPHA, BETA], [BETA, ALPHA]] as const) {
500+
const protocol = await bootHolders(order);
501+
const p: any = protocol;
502+
const label = overridden === ALPHA ? 'OVR-A' : 'OVR-B';
503+
const shipped = `SHIPPED-${other === ALPHA ? 'alpha' : 'beta'}`;
504+
for (const type of ['flow', 'action'] as const) {
505+
await overrideEach(protocol, type, [overridden]);
506+
const name = type === 'flow' ? FLOW : SHARED_ACTION;
507+
for (const face of ['served', 'execution'] as const) {
508+
const listed = await entries(protocol, type, face);
509+
if (type === 'flow') {
510+
expect(listed, `${type} ${face}, ${overridden} overridden`).toEqual([`${overridden}:${label}`, `${other}:${shipped}`].sort());
511+
} else {
512+
expect(listed.filter((e) => e.startsWith(`${overridden}:`)), `${type} ${face}, ${overridden} overridden`).toEqual([`${overridden}:${label}`]);
513+
}
514+
}
515+
expect((await p.getMetaItem({ type, name, packageId: overridden })).item.label, `${type} at ${overridden}`).toBe(label);
516+
if (type === 'flow') {
517+
expect((await p.getMetaItem({ type, name, packageId: other })).item.label, `${type} at ${other}`).toBe(shipped);
518+
}
519+
}
520+
}
521+
});
522+
488523
// The served holder set (#32497): with one holder disabled, the
489524
// enabled holder's override is the one listed and served at its
490525
// address, whichever holder is disabled (the first to register, which

0 commit comments

Comments
 (0)