Skip to content

Commit 8627792

Browse files
committed
fix(changeset): declare the narrowing arm; source the legacy spelling from the retirement kit's fixture
Claude-Session: https://claude.ai/code/session_017xRBcRoJWF7MQr6HoRgBeC Co-authored-by: Claude <noreply@anthropic.com>
1 parent f7534a6 commit 8627792

2 files changed

Lines changed: 26 additions & 5 deletions

File tree

‎.changeset/35924-publish-reparses-object-draft.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
fix(metadata-protocol)!: publishing an object draft judges it by the current ObjectSchema
77

8-
Clause-②: no
8+
Clause-②: no (narrowing)
99
Metadata-protocol: narrowed
1010

1111
<!-- adr-0087: registered publish-refuses-object-draft-the-current-schema-refuses -->

‎packages/metadata-protocol/src/protocol.publish-draft-schema-reparse.test.ts‎

Lines changed: 25 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import { describe, expect, it } from 'vitest';
55
// cannot accept a call ObjectQL refuses (`check:engine-double-contract`).
66
import { assertEngineDeleteDispatch, assertEngineUpdateDispatch, assertEngineFindOnePredicate, hashSpec } from '@objectstack/metadata-core';
77
import { ObjectSchema } from '@objectstack/spec/data';
8+
import { ALL_CONVERSIONS } from '@objectstack/spec';
89
// The draft verdict reaches `import('@objectstack/lint')`; paid at collection,
910
// never inside a case's clock (`check:test-source-alias`).
1011
import '@objectstack/lint';
@@ -172,6 +173,22 @@ function rewriteStoredDraft(rows: Map<string, Row>, name: string, body: unknown)
172173
row.checksum = hashSpec(body, 'object');
173174
}
174175

176+
/** The ADR-0087 conversion whose retired object key the legacy-spelling CONTROL stores. */
177+
const LEGACY_SPELLING_CONVERSION = 'object-external-sharing-model-removed';
178+
179+
/**
180+
* The object keys conversion `id` strips, with the values its own fixture
181+
* stores: the keys of the fixture's first `before` object that the matching
182+
* `after` object no longer carries.
183+
*/
184+
function retiredObjectKeysOf(id: string): Record<string, unknown> {
185+
const conversion = ALL_CONVERSIONS.find((c) => c.id === id);
186+
if (!conversion) throw new Error(`no ADR-0087 conversion '${id}'`);
187+
const [before] = (conversion.fixture.before as { objects: Array<Record<string, unknown>> }).objects;
188+
const [after] = (conversion.fixture.after as { objects: Array<Record<string, unknown>> }).objects;
189+
return Object.fromEntries(Object.entries(before ?? {}).filter(([key]) => !(after && key in after)));
190+
}
191+
175192
const rowsFor = (rows: Map<string, Row>, name: string) =>
176193
Array.from(rows.values())
177194
.filter((r) => r.type === 'object' && r.name === name)
@@ -308,10 +325,14 @@ describe('[#35924] what the publish still promotes', () => {
308325
const { engine, rows } = makeStubEngine();
309326
const protocol = new ObjectStackProtocolImplementation(engine);
310327
const name = 'crm_ledger';
311-
// `externalSharingModel` is tombstoned on the object shape (a live
312-
// author is refused at parse) and stripped from a stored row by the
313-
// chain (`object-external-sharing-model-removed`).
314-
const legacy = { ...sealedLedger(name), externalSharingModel: 'private' };
328+
// The retired spelling comes from the retirement kit's own fixture,
329+
// never authored here: the keys the conversion's `before` object
330+
// carries and its `after` object does not. This file authors no
331+
// retired key, so the kit's tree-scoped absence pin keeps its radius.
332+
// Its key is tombstoned on the object shape (a live author is refused
333+
// at parse) and stripped from a stored row by the chain.
334+
const legacy = { ...sealedLedger(name), ...retiredObjectKeysOf(LEGACY_SPELLING_CONVERSION) };
335+
expect(Object.keys(retiredObjectKeysOf(LEGACY_SPELLING_CONVERSION))).not.toEqual([]);
315336
expect(ObjectSchema.safeParse(legacy).success).toBe(false);
316337
await stagePreRefinementDraft(protocol, rows, name, legacy);
317338

0 commit comments

Comments
 (0)