Skip to content

Commit 88f062f

Browse files
committed
test: the batch-door member pins draft into the pair; drop an unused binding
The package-batch member cases drafted into the read-only package itself, which the save door now refuses; they draft into its pair, declared, and assert the same member semantics. Claude-Session: https://claude.ai/code/session_01ADHkmTBQhj1HBQsdAopiJ8 Co-authored-by: Claude <noreply@anthropic.com>
1 parent 3eda44b commit 88f062f

2 files changed

Lines changed: 22 additions & 15 deletions

File tree

‎packages/metadata-protocol/src/protocol.named-base-overlay-write.test.ts‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -310,7 +310,7 @@ describe('CONTROLS: the writes the close leaves open, as on main', () => {
310310
});
311311

312312
it('a server-stated rewrite naming the base (`source` set) still writes the row it names', async () => {
313-
const { protocol, rows, storeBaseRow } = makeProtocol();
313+
const { rows, storeBaseRow } = makeProtocol();
314314

315315
await storeBaseRow(VIEW.type, VIEW.name, VIEW.body('Rewritten'));
316316

‎packages/objectql/src/environment-overlay-email-locale-restart.test.ts‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -204,8 +204,9 @@ async function boot(
204204
* delete that names no package, and adds the declaration to a saved body of a
205205
* member the package ships (one it does not ship is the pair's own item) —
206206
* the member semantics pinned below are the pair's, row for row, as they were
207-
* the package-less row's. A write that names a package (the drafts into
208-
* `PKG` below) is passed through untouched.
207+
* the package-less row's. A write that names a package (the drafts into the
208+
* pair below, declared; [#28905] a write naming `PKG` itself is refused) is
209+
* passed through untouched.
209210
*/
210211
const PAIR = 'com.acme.mail.custom';
211212
const DECLARATION = { package: PKG, basedOn: '1.0.0' };
@@ -633,11 +634,17 @@ describe('[#26699] the layered read addresses ONE member by the selector', () =>
633634
});
634635

635636
describe('the package-batch doors and the cluster fan-out carry the member (#22877, stage 2)', () => {
636-
/** A zh-CN draft bound to the package, beside an en-US active overlay that has none. */
637+
/**
638+
* A zh-CN draft bound to the package's pair, beside an en-US active
639+
* overlay that has none. [#28905, ADR-0146 D1] A draft naming the
640+
* read-only package itself is refused now, so the package-batch doors are
641+
* asked of the pair, whose drafts declare the override; the member
642+
* semantics pinned below are the same, row for row.
643+
*/
637644
async function bootWithZhDraft(stores: Map<string, Map<string, Record<string, unknown>>>) {
638645
const booted = await boot(stores);
639646
await booted.protocol.saveMetaItem({ type: T, name: NAME, item: template('en-US', 'ADMIN en') });
640-
await booted.protocol.saveMetaItem({ type: T, name: NAME, item: template('zh-CN', 'DRAFT zh'), mode: 'draft', packageId: PKG });
647+
await booted.protocol.saveMetaItem({ type: T, name: NAME, item: { ...template('zh-CN', 'DRAFT zh'), overrides: DECLARATION }, mode: 'draft', packageId: PAIR });
641648
return booted;
642649
}
643650
const draftRows = (stores: Map<string, Map<string, Record<string, unknown>>>) =>
@@ -649,7 +656,7 @@ describe('the package-batch doors and the cluster fan-out carry the member (#228
649656
const { protocol } = await bootWithZhDraft(stores);
650657
expect(draftRows(stores).map((r) => r.bundle_member)).toEqual(['zh-CN']);
651658

652-
const out: any = await protocol.publishPackageDrafts({ packageId: PKG });
659+
const out: any = await protocol.publishPackageDrafts({ packageId: PAIR });
653660
expect(out, JSON.stringify(out)).toMatchObject({ success: true, publishedCount: 1, failedCount: 0 });
654661
expect(draftRows(stores)).toEqual([]);
655662
expect(await servedSubjects(protocol)).toEqual({ 'en-US': 'ADMIN en', 'zh-CN': 'DRAFT zh' });
@@ -658,15 +665,15 @@ describe('the package-batch doors and the cluster fan-out carry the member (#228
658665
it('revertCommit: the revert of that publish removes the zh-CN row it created and leaves en-US', async () => {
659666
const stores = new Map<string, Map<string, Record<string, unknown>>>();
660667
const { protocol } = await bootWithZhDraft(stores);
661-
const published: any = await protocol.publishPackageDrafts({ packageId: PKG });
668+
const published: any = await protocol.publishPackageDrafts({ packageId: PAIR });
662669
expect(published.commitId, JSON.stringify(published)).toBeTruthy();
663670

664671
const reverted: any = await protocol.revertCommit({ commitId: published.commitId });
665672
expect(reverted, JSON.stringify(reverted)).toMatchObject({ success: true, revertedCount: 1 });
666673
expect(overlayRows(stores).map((r) => r.bundle_member ?? null)).toEqual([null]);
667674
expect(await servedSubjects(protocol)).toEqual({ 'en-US': 'ADMIN en', 'zh-CN': 'PKG zh' });
668675
// [#23073] The timeline serves each item's member: the publish and its revert, zh-CN both.
669-
const commits = await protocol.listCommits({ packageId: PKG });
676+
const commits = await protocol.listCommits({ packageId: PAIR });
670677
expect(commits.map((c) => c.items.map((it) => [it.type, it.name, it.member]))).toEqual([
671678
[[T, NAME, 'zh-CN']], [[T, NAME, 'zh-CN']],
672679
]);
@@ -675,33 +682,33 @@ describe('the package-batch doors and the cluster fan-out carry the member (#228
675682
it('discardPackageDrafts: the zh-CN draft is discarded as zh-CN', async () => {
676683
const stores = new Map<string, Map<string, Record<string, unknown>>>();
677684
const { protocol } = await bootWithZhDraft(stores);
678-
const out: any = await protocol.discardPackageDrafts({ packageId: PKG });
685+
const out: any = await protocol.discardPackageDrafts({ packageId: PAIR });
679686
expect(out, JSON.stringify(out)).toMatchObject({ success: true, discardedCount: 1, failedCount: 0 });
680687
expect(draftRows(stores)).toEqual([]);
681688
expect(await servedSubjects(protocol)).toEqual({ 'en-US': 'ADMIN en', 'zh-CN': 'PKG zh' });
682-
const listed = await protocol.listDrafts({ packageId: PKG });
689+
const listed = await protocol.listDrafts({ packageId: PAIR });
683690
expect(listed.drafts).toEqual([]);
684691
});
685692

686693
it('[#23073] the draft list and the commit timeline tell two languages of one template apart, and each listed member addresses its own item by name', async () => {
687694
const stores = new Map<string, Map<string, Record<string, unknown>>>();
688695
const { protocol } = await boot(stores);
689-
await protocol.saveMetaItem({ type: T, name: NAME, item: template('en-US', 'DRAFT en'), mode: 'draft', packageId: PKG });
690-
await protocol.saveMetaItem({ type: T, name: NAME, item: template('zh-CN', 'DRAFT zh'), mode: 'draft', packageId: PKG });
696+
await protocol.saveMetaItem({ type: T, name: NAME, item: { ...template('en-US', 'DRAFT en'), overrides: DECLARATION }, mode: 'draft', packageId: PAIR });
697+
await protocol.saveMetaItem({ type: T, name: NAME, item: { ...template('zh-CN', 'DRAFT zh'), overrides: DECLARATION }, mode: 'draft', packageId: PAIR });
691698
const wording: Record<string, string> = { 'en-US': 'DRAFT en', 'zh-CN': 'DRAFT zh' };
692699

693700
// Two drafts of one `type` and `name`, told apart by `member` alone.
694-
const listed = await protocol.listDrafts({ packageId: PKG });
701+
const listed = await protocol.listDrafts({ packageId: PAIR });
695702
expect(listed.drafts.map((d) => [d.type, d.name, d.member]).sort()).toEqual([[T, NAME, 'en-US'], [T, NAME, 'zh-CN']]);
696703
// The listed member round-trips through the by-name door: each reads its own draft.
697704
for (const d of listed.drafts) {
698705
const read: any = await protocol.getMetaItem({ type: d.type, name: d.name, state: 'draft', member: d.member });
699706
expect(read?.item?.subject).toBe(wording[d.member!]);
700707
}
701708

702-
const published: any = await protocol.publishPackageDrafts({ packageId: PKG });
709+
const published: any = await protocol.publishPackageDrafts({ packageId: PAIR });
703710
expect(published, JSON.stringify(published)).toMatchObject({ success: true, publishedCount: 2, failedCount: 0 });
704-
const [commit] = await protocol.listCommits({ packageId: PKG });
711+
const [commit] = await protocol.listCommits({ packageId: PAIR });
705712
expect(commit!.items.map((it) => [it.type, it.name, it.member]).sort()).toEqual([[T, NAME, 'en-US'], [T, NAME, 'zh-CN']]);
706713
for (const it of commit!.items) {
707714
const read: any = await protocol.getMetaItem({ type: it.type, name: it.name, member: it.member });

0 commit comments

Comments
 (0)