Skip to content

Commit 8715fce

Browse files
committed
fix(metadata-protocol): the re-enable heal records only the three declared overlay types, and two more pins run the holder set moving to the other holder alone and a permission row
Contract review s1: a package-less permission row wears its sole holder's envelope too, so the record now takes only email_template, dashboard and report, the types the narrowing declares. Review s2: one pin runs the heal's fourth outcome (A and B hold, B disabled, hydrated, A disabled, B enabled, then A enabled), asserting the slot at each step. Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4d1H7jxfU2FWB3HDdbs
1 parent 1484f1c commit 8715fce

2 files changed

Lines changed: 45 additions & 1 deletion

File tree

‎packages/metadata-protocol/src/protocol-registry-hydration.ts‎

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,16 @@ type EnvelopeRegistry = {
197197
onPackageEnabled?(listener: (packageId: string) => void): () => void;
198198
};
199199

200+
/**
201+
* [#32820] The overlay types whose package-less row the heal rebuilds: the
202+
* three the narrowing declares (its changeset and ADR-0087 entry
203+
* `package-less-overlay-row-holder-slot-on-reenable`). A package-less
204+
* `permission` row also wears its sole holder's envelope, but two holders of a
205+
* permission set are refused by the registry today; when that rule opens, the
206+
* heal widens to it only in a change that declares it (contract review s1).
207+
*/
208+
const HEALED_OVERLAY_TYPES: ReadonlySet<string> = new Set(['email_template', 'dashboard', 'report']);
209+
200210
/** Per registry, the {@link SoleHolderEnvelope} of each bare-slot key (`type`, `name`, member). */
201211
const soleHolderEnvelopes = new WeakMap<object, Map<string, SoleHolderEnvelope>>();
202212

@@ -768,7 +778,7 @@ export class ProtocolRegistryHydrationFacet {
768778
// of the key forgets it.
769779
const member = bundleMemberOf(type, data);
770780
recordSoleHolderEnvelope(registry, envelopeKey(type, rowName, member),
771-
!options.packageId && typeof envelopePackage === 'string' && envelope
781+
!options.packageId && typeof envelopePackage === 'string' && envelope && HEALED_OVERLAY_TYPES.has(canonicalType)
772782
? { host, type, canonicalType, name: rowName, member, data, holder: envelopePackage, registered }
773783
: undefined);
774784
await host.hydrateExpandedViewItems(type, data, options);

‎packages/objectql/src/package-scoped-exact-qualifier.test.ts‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2157,6 +2157,40 @@ describe('[#32820] re-enabling a holder: the package-less overlay row the hydrat
21572157
registry.enablePackage(B);
21582158
expect(registry.getItem('email_template', 'welcome', undefined, 'en-US')).toBe(written);
21592159
});
2160+
2161+
it('the holder set moves from A alone to B alone, then to both: the entry is built again under B\'s envelope, then under none (review s2)', async () => {
2162+
holderOwn('email_template', A);
2163+
holderOwn('email_template', B);
2164+
storeEnvRow('email_template');
2165+
registry.disablePackage(B);
2166+
await protocol.getMetaItems({ type: 'email_template' } as never);
2167+
const slotAt = (at: string) => {
2168+
const slot = registry.getPackageScopedItem('email_template', 'welcome', at) as { label?: string; _packageId?: string } | undefined;
2169+
return [slot?.label, slot?._packageId];
2170+
};
2171+
expect(slotAt(A), 'B disabled, hydrated: A alone served').toEqual(['env row', A]);
2172+
registry.disablePackage(A);
2173+
registry.enablePackage(B);
2174+
// B is now the one served holder: the row is its customization, recorded again under its envelope.
2175+
expect(slotAt(B), 'A disabled, B enabled: B alone served').toEqual(['env row', B]);
2176+
registry.enablePackage(A);
2177+
// Both served: the second heal builds it under no holder's envelope.
2178+
expect(await readers('email_template', A), 'both enabled').toEqual(own(A));
2179+
expect(await readers('email_template', B), 'both enabled').toEqual(own(B));
2180+
});
2181+
2182+
it('a package-less permission row is not recorded: an enable leaves the hydrated slot as the hydrator laid it (review s1; the heal moves only the three declared overlay types)', async () => {
2183+
admitSecondPermissionHolder();
2184+
holderOwn('permission', A);
2185+
holderOwn('permission', B);
2186+
storeEnvRow('permission');
2187+
registry.disablePackage(B);
2188+
await protocol.getMetaItems({ type: 'permission' } as never);
2189+
const hydrated = registry.getItem('permission', 'welcome') as { label?: string } | undefined;
2190+
expect(hydrated?.label, 'B disabled, hydrated: the row in A\'s slot').toBe('env row');
2191+
registry.enablePackage(B);
2192+
expect(registry.getItem('permission', 'welcome')).toBe(hydrated);
2193+
});
21602194
});
21612195

21622196
/**

0 commit comments

Comments
 (0)