Skip to content

Commit 2374556

Browse files
committed
test(spec, metadata-protocol): re-pin three cbp pins the optional master moves
Under ADR-0055 §1 as amended, an object's only master_detail declared required: false is an optional master. Three pins outside the earlier targeted runs still read it as refused: - stack-cbp-extension-master: an extension making the one master optional now passes like its declared control; beside a second master it is refused (the twin). - retired-key-removal-version pin: the parse reads an omitted required on the only master_detail as false, so the refusal it still answers on the defaulted conversion's surface is two master_detail fields with none. - metadata-protocol stored migration: the required:false row is counted canonical, no longer listed under cbp-master-relation-tiers-retired. And one docblock the change made false (UnservableControlledByParentMaster.field). Co-authored-by: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_016WV4cxZsyeZedvM4Ea8Ahs
1 parent 835c94d commit 2374556

4 files changed

Lines changed: 37 additions & 7 deletions

File tree

‎packages/metadata-protocol/src/protocol.stored-migration.test.ts‎

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1120,6 +1120,10 @@ describe('migrateStoredMetadata — the v18 stored shapes refused with no lossle
11201120
};
11211121

11221122
it('#23270 — each refused controlled_by_parent shape is listed by object; a conforming object is counted canonical', async () => {
1123+
// [ADR-0055 §1 as amended · #30905 ruling A] `crm_false` — its only
1124+
// `master_detail` declared `required: false` — is an optional master
1125+
// now, so it is counted canonical beside `crm_ok`, no longer listed.
1126+
// Its twin `crm_two` (two masters) still is.
11231127
const { engine, tables } = makeStubEngine([
11241128
cbpObject('crm_two', { quote: md('crm_quote', { required: true }), order: md('crm_order', { required: true }) }),
11251129
cbpObject('crm_none', {}),
@@ -1132,18 +1136,17 @@ describe('migrateStoredMetadata — the v18 stored shapes refused with no lossle
11321136

11331137
const report = await protocol.migrateStoredMetadata();
11341138

1135-
expect(report.canonical).toBe(1);
1139+
expect(report.canonical).toBe(2);
11361140
expect(report.rows.map((r) => [r.name, r.outcome, r.todos.map((t) => [t.conversionId, t.path])])).toEqual([
11371141
['crm_two', 'skipped', [['cbp-master-relation-tiers-retired', 'objects[0].fields']]],
11381142
['crm_none', 'skipped', [['cbp-master-relation-tiers-retired', 'objects[0].sharingModel']]],
11391143
['crm_lookup', 'skipped', [['cbp-master-relation-tiers-retired', 'objects[0].sharingModel']]],
1140-
['crm_false', 'skipped', [['cbp-master-relation-tiers-retired', 'objects[0].sharingModel']]],
11411144
]);
11421145
const text = formatStoredMigrationReport(report).join('\n');
11431146
expect(text).toContain('object/crm_two [env-wide]');
11441147
expect(text).toContain('TODO cbp-master-relation-tiers-retired:');
11451148
expect(text).toMatch(/which of them is the master is the owner's choice: the upgrade never picks one/);
1146-
expect(text).toMatch(/☐ TODO: 4 site\(s\) in 4 row\(s\) are left as stored/);
1149+
expect(text).toMatch(/☐ TODO: 3 site\(s\) in 3 row\(s\) are left as stored/);
11471150
// Listed, never written — on --apply too — and no verdict flips over it.
11481151
expect(storedMigrationClean(report)).toBe(true);
11491152
const applied = await protocol.migrateStoredMetadata({ apply: true });

‎packages/objectql/src/engine-top-level.ts‎

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4928,7 +4928,10 @@ export interface ReadableIdsChain {
49284928
export type UnservableControlledByParentMaster = {
49294929
/** The `controlled_by_parent` detail. */
49304930
readonly detail: string;
4931-
/** Its one required `master_detail` field. */
4931+
/**
4932+
* Its master `master_detail` field: the one required, or (ADR-0055 §1 as
4933+
* amended) its only `master_detail`, declared `required: false`.
4934+
*/
49324935
readonly field: string;
49334936
/** The object that field names. */
49344937
readonly master: string;

‎packages/spec/src/shared/retired-key-removal-version.pin.test.ts‎

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -341,14 +341,24 @@ const JOIN: Readonly<Record<string, readonly Renderer[]>> = {
341341
refusal("action:group member's patch", () => ActionGroupPropsSchema.safeParse({ actions: [{ label: 'Close', patch: { status: 'done' } }] }), 'actions'),
342342
refusal("action:menu member's patch", () => ActionMenuPropsSchema.safeParse({ actions: [{ label: 'Close', patch: { status: 'done' } }] }), 'actions'),
343343
],
344+
// [ADR-0055 §1 as amended · #30905 ruling A] The parse reads an omitted
345+
// `required` on an object's ONLY `master_detail` as `false` (the parsed field
346+
// map defaults it), so that shape is an optional master at the parse and no
347+
// longer refused there; the builder still forces it, this conversion still
348+
// converts it at rest, and `os lint` reports it. The refusal the parse still
349+
// answers on this surface is the shape the conversion leaves as stored: two
350+
// `master_detail` fields, neither declaring `required`.
344351
'cbp-master-detail-required-defaulted': [
345352
refusal(
346-
'a controlled_by_parent master_detail without `required`',
353+
'a controlled_by_parent object whose two master_detail fields declare no `required`',
347354
() => ObjectSchema.safeParse({
348355
name: 'cbp_line',
349356
label: 'Line',
350357
sharingModel: 'controlled_by_parent',
351-
fields: { order: { type: 'master_detail', label: 'Order', reference: 'cbp_order' } },
358+
fields: {
359+
order: { type: 'master_detail', label: 'Order', reference: 'cbp_order' },
360+
batch: { type: 'master_detail', label: 'Batch', reference: 'cbp_batch' },
361+
},
352362
}),
353363
'sharingModel',
354364
),

‎packages/spec/src/stack-cbp-extension-master.test.ts‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -110,9 +110,23 @@ describe('[#23210] defineStack judges a controlled_by_parent object on its merge
110110
expect(cbpIssues(withField(OTHER)).map(([p]) => p)).toEqual(['objectExtensions.0.fields']);
111111
});
112112

113+
it('an extension that makes the one master optional passes, as its declared control does; beside a second master it is refused', () => {
114+
// [ADR-0055 §1 as amended · #30905 ruling A] The object's only `master_detail`
115+
// declared `required: false` is an optional master — accepted on the merged
116+
// field set exactly as on the object declared directly.
117+
const optional = { type: 'master_detail', reference: 'cbpx_header', required: false };
118+
const stack = { manifest: MANIFEST, objects: OBJECTS(), objectExtensions: [{ extend: 'cbpx_line', fields: { header: optional } }] };
119+
expect(cbpIssues(stack)).toEqual([]);
120+
expect(ObjectStackDefinitionSchema.safeParse(stack).success).toBe(true);
121+
expect(cbpIssues({ manifest: MANIFEST, objects: OBJECTS({ header: optional }) })).toEqual([]);
122+
// The twin: the same optional master beside a second `master_detail` the
123+
// extension adds is no one master, and is refused at the extension.
124+
const twin = { manifest: MANIFEST, objects: OBJECTS({ header: optional }), objectExtensions: [{ extend: 'cbpx_line', fields: { other: { ...OTHER, required: false } } }] };
125+
expect(cbpIssues(twin).map(([p]) => p)).toEqual(['objectExtensions.0.fields']);
126+
});
127+
113128
it('an extension that demotes the one master is refused, in the words of the declared control', () => {
114129
for (const demoted of [
115-
{ type: 'master_detail', reference: 'cbpx_header', required: false },
116130
{ type: 'text' },
117131
{ type: 'lookup', reference: 'cbpx_header', required: true },
118132
]) {

0 commit comments

Comments
 (0)