Skip to content

Commit dd283fa

Browse files
committed
fix(objectql): the exact read's adoption counts a package holding the name through its own stored row, as packageScopedHoldersOf does
SchemaRegistry#overlayRowBinding counted composite slots only, so a package holding the name only through its own stored row in the bare slot was no owner there: the App's undeclared pair row bound to the pair and the exact read withheld it at that package's address, where main served it. The holders are now the ones packageScopedHoldersOf counts: every composite slot, then the package each bare-slot entry binds to. Pinned in both registration orders beside the composite-slot CONTROL. Claude-Session: https://claude.ai/code/session_016WV4cwzajrQVjjx4Dh1CA5 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 5a9d589 commit dd283fa

2 files changed

Lines changed: 49 additions & 4 deletions

File tree

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

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1062,6 +1062,40 @@ describe('[#31699 F2] a pair member row two holders could own is refused on both
10621062
expect(await listed(X)).not.toContain('pair de-DE');
10631063
});
10641064

1065+
// [#32561 contract review n1] The adoption counts the holders as
1066+
// `packageScopedHoldersOf` counts the exact read's owner: every composite
1067+
// slot, then the package a bare-slot entry binds to. X holding the name
1068+
// only through its own stored row (a row with `package_id` X hydrated
1069+
// into the bare slot, no composite slot) is still X's holding, so the
1070+
// App's undeclared de-DE pair row is X's member on X's address, as on
1071+
// main. Counting composite slots only leaves X out, the row binds to the
1072+
// pair, and X's address would lose it: ablation.
1073+
for (const holding of ['its own stored row in the bare slot', 'CONTROL: its composite slot'] as const) {
1074+
it.each([['holding first', true], ['pair row first', false]] as const)(`${holding === 'CONTROL: its composite slot' ? 'CONTROL' : 'UNCHANGED'} — X holds the name through ${holding} (%s): X's address and lists keep the App's undeclared pair row`, async (_order, holdingFirst) => {
1075+
const xEn = { name: 'welcome', label: 'suitex en-US', locale: 'en-US', subject: 'suitex en-US', bodyHtml: '<p>x</p>' };
1076+
const pairDe = { name: 'welcome', label: 'pair de-DE', locale: 'de-DE', subject: 'pair de-DE', bodyHtml: '<p>p</p>' };
1077+
const registerHolding = () => {
1078+
if (holding === 'CONTROL: its composite slot') { tpl('en-US', X); return; }
1079+
rows.push({ id: 'row_x', type: 'email_template', name: 'welcome', state: 'active', package_id: X, bundle_member: 'en-US', metadata: JSON.stringify(xEn) });
1080+
registry.registerItem('email_template', { ...xEn, _packageId: X, _provenance: 'org' }, 'name' as never);
1081+
};
1082+
const registerPairRow = () => {
1083+
rows.push({ id: 'row_de', type: 'email_template', name: 'welcome', state: 'active', package_id: PAIR, bundle_member: 'de-DE', metadata: JSON.stringify(pairDe) });
1084+
registry.registerItem('email_template', { ...pairDe, _packageId: PAIR, _provenance: 'org' }, 'name' as never);
1085+
};
1086+
if (holdingFirst) { registerHolding(); registerPairRow(); } else { registerPairRow(); registerHolding(); }
1087+
expect(registry.overlayRowBinding('email_template', 'welcome', { ...pairDe, _packageId: PAIR }), 'the adoption counts X as the exact read does').toBe(X);
1088+
expect(labelOf(await read(X, 'de-DE'))).toBe('pair de-DE');
1089+
expect(labelOf(await read(X, 'en-US'))).toBe('suitex en-US');
1090+
// The lists are pinned for the composite slot only: with X holding through its stored row alone, X's
1091+
// lists leave the row out on main and here alike (the list door's own count, outside this card).
1092+
if (holding === 'CONTROL: its composite slot') {
1093+
expect(await listed(X)).toContain('pair de-DE');
1094+
expect(await forSend(X)).toContain('pair de-DE');
1095+
}
1096+
});
1097+
}
1098+
10651099
});
10661100

10671101
it('a sole owner keeps its member: another package of the pair does not serve it (delta review S2; through the doors the qualifier refuses the non-holder first)', async () => {

‎packages/objectql/src/registry.ts‎

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9137,24 +9137,35 @@ export class SchemaRegistry {
91379137
* bundle-addition rule ({@link ownersHoldingAName}) is settled over EVERY
91389138
* holder, so a disable never promotes a dependent's addition to an owner
91399139
* (a package that adds only to a disabled holder's bundle stays an
9140-
* addition, as the exact read counts it). {@link overlaySlotBinding}
9140+
* addition, as the exact read counts it). The holders are the ones
9141+
* {@link packageScopedHoldersOf} counts: every composite slot, then the
9142+
* package a bare-slot entry binds to, so a package holding the name only
9143+
* through its own stored row is a holder here too. {@link overlaySlotBinding}
91419144
* itself counts every holder, so a disable never moves the binding the
91429145
* registry's own readers answer.
91439146
*/
91449147
overlayRowBinding(type: string, name: string, item: unknown): string | null | undefined {
91459148
const collection = this.metadata.get(type);
91469149
if (!collection) return undefined;
91479150
const composite = new Set(this.compositeHoldersOf(collection, name));
9148-
const served = new Set([...composite].filter((id) => !this.isPackageDisabled(id)));
9151+
const servedComposite = new Set([...composite].filter((id) => !this.isPackageDisabled(id)));
91499152
const stamped = (item as { _packageId?: unknown } | null | undefined)?._packageId;
9150-
if (typeof stamped === 'string' && stamped !== '' && stamped !== 'sys_metadata' && !served.has(stamped)) {
9153+
if (typeof stamped === 'string' && stamped !== '' && stamped !== 'sys_metadata' && !composite.has(stamped)) {
9154+
const holders = new Set(composite);
9155+
for (const { item: entry } of this.bareSlotEntriesOf(type, collection, name)) {
9156+
const bound = this.overlaySlotBinding(type, entry, name, collection, composite);
9157+
if (typeof bound === 'string') holders.add(bound);
9158+
}
9159+
// The pair's own rows bind to it when no composite slot pairs it; it holds no name of its own here.
9160+
const served = new Set([...holders].filter((id) => id !== stamped && !this.isPackageDisabled(id)));
91519161
const settled = this.settledPairRowBinding(stamped, item, served);
91529162
if (Array.isArray(settled)) {
91539163
const named = this.ownersHoldingAName(type, name, collection, settled as readonly string[], item, composite, stamped);
91549164
return named.length === 1 ? named[0] : undefined;
91559165
}
9166+
if (settled !== NOT_A_PAIR_ROW_OF_A_HOLDER) return settled as string | undefined;
91569167
}
9157-
return this.overlaySlotBinding(type, item, name, collection, served);
9168+
return this.overlaySlotBinding(type, item, name, collection, servedComposite);
91589169
}
91599170

91609171
/**

0 commit comments

Comments
 (0)