Skip to content

Commit d5f9db8

Browse files
committed
wip: refusal sentence fix-first, under the REST door's 500-character cap
Claude-Session: https://claude.ai/code/session_01FEkQ5ni5yjiTswP6crgAkX Co-Authored-By: Claude <noreply@anthropic.com>
1 parent cdecf0f commit d5f9db8

3 files changed

Lines changed: 25 additions & 26 deletions

File tree

‎packages/metadata-protocol/src/protocol-packaged-base-refusal.ts‎

Lines changed: 15 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -259,25 +259,23 @@ export function packagelessOverlayWriteRefusal(
259259
const sole = pairs.length === 1 ? pairs[0]! : undefined;
260260
// One base: its pair, by name. Several: the pair of the base the writer
261261
// customizes, each named — never guessed (the ceremony lists such a row).
262-
const into = sole
263-
? `'${sole.pair}' (?package=${sole.pair})`
264-
: `the pair of the package it customizes (${pairs.map((p) => `'${p.pair}'`).join(' or ')}, as ?package=<that pair>)`;
262+
const pair = sole ? `'${sole.pair}' (?package=${sole.pair})` : `the pair of the package it customizes (${pairs.map((p) => `'${p.pair}'`).join(' or ')})`;
265263
const declared = sole ? `overrides: { package: '${sole.base}', basedOn }` : 'overrides: { package: <that base>, basedOn }';
264+
// The fix first, then the rule and the ceremony: the REST door bounds a
265+
// refusal's text (`CLIENT_MESSAGE_MAX`, 500 characters, `@objectstack/types`),
266+
// and Setup shows that text as sent.
266267
const ceremony = sole
267-
? 'A package-less customization stored before this release is still served; run '
268-
+ `\`os migrate packageless-overlays\` first to move it into '${sole.pair}'.`
269-
: 'A package-less customization stored before this release is still served; run '
270-
+ '`os migrate packageless-overlays` first: it lists a name several packages ship for you to place.';
271-
const fix = operation === 'delete'
272-
? `Remove it from ${into}. ${ceremony}`
273-
: operation === 'rollback'
274-
? `Its customization belongs in ${into}: run \`os migrate packageless-overlays\` to move the row there, then roll it back.`
275-
: `${operation === 'publish' ? 'Publish' : 'Save'} it into ${into}, declaring ${declared}. ${ceremony}`;
276-
const what = operation === 'rollback' ? 'a rollback of its package-less row' : 'a write naming no package';
277-
const err = new Error(
278-
`${item} ${shipped}, and ${what} onto a packaged item is closed: a customization of an installed package `
279-
+ `lives in its paired .custom package (ADR-0146 D11). ${fix}`,
280-
);
268+
? `\`os migrate packageless-overlays\` moves it into '${sole.pair}'`
269+
: '`os migrate packageless-overlays` lists it for you to place';
270+
const closed = 'A write naming no package onto a packaged item is closed (ADR-0146 D11); '
271+
+ `a package-less customization stored before it is still served until ${ceremony}.`;
272+
const message = operation === 'rollback'
273+
? `${item} ${shipped}, and a rollback of its package-less row is closed (ADR-0146 D11): run `
274+
+ `\`os migrate packageless-overlays\` to move the row into ${pair}, then roll it back there.`
275+
: operation === 'delete'
276+
? `${item} ${shipped}: remove its customization from ${pair}. ${closed}`
277+
: `${item} ${shipped}: ${operation === 'publish' ? 'publish' : 'save'} it into ${pair}, declaring ${declared}. ${closed}`;
278+
const err = new Error(message);
281279
(err as any).code = 'NOT_OVERRIDABLE';
282280
(err as any).status = 403;
283281
return err;

‎packages/metadata-protocol/src/protocol.packageless-save-address.test.ts‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -426,6 +426,10 @@ describe('an item a CODE package ships: the package-less write is closed (ADR-01
426426
expect(resolveThrownHttpError(e)).toMatchObject({ status: 403, code: 'NOT_OVERRIDABLE' });
427427
expect(String((e as Error).message)).toContain(`'${PAIR}'`);
428428
expect(String((e as Error).message)).toContain('os migrate packageless-overlays');
429+
// The REST door cuts a refusal's text at 500 characters
430+
// (`CLIENT_MESSAGE_MAX`, `@objectstack/types`), and Setup shows it as
431+
// sent: the whole sentence fits, the ceremony included.
432+
expect(String((e as Error).message).length).toBeLessThan(500);
429433
};
430434

431435
it('with no stored row: the package-less save is refused naming the pair, and nothing is written', async () => {

‎ui/packages/app-shell/src/views/metadata-admin/ResourceEditPage.packagelessWriteClosed-28576.test.tsx‎

Lines changed: 6 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -41,16 +41,13 @@ const PAIR = `${BASE}.custom`;
4141
const doc = (content: string) => ({ name: NAME, label: NAME, content, group: 'reference' });
4242

4343
/** The server's sentences, worded as the framework words them; read back verbatim below. */
44+
const CLOSED =
45+
'A write naming no package onto a packaged item is closed (ADR-0146 D11); a package-less customization stored ' +
46+
`before it is still served until \`os migrate packageless-overlays\` moves it into '${PAIR}'.`;
4447
const SAVE_CLOSED =
45-
`'doc/${NAME}' ships in '${BASE}', and a write naming no package onto a packaged item is closed: a customization ` +
46-
`of an installed package lives in its paired .custom package (ADR-0146 D11). Save it into '${PAIR}' ` +
47-
`(?package=${PAIR}), declaring overrides: { package: '${BASE}', basedOn }. A package-less customization stored ` +
48-
`before this release is still served; run \`os migrate packageless-overlays\` first to move it into '${PAIR}'.`;
49-
const RESET_CLOSED =
50-
`'doc/${NAME}' ships in '${BASE}', and a write naming no package onto a packaged item is closed: a customization ` +
51-
`of an installed package lives in its paired .custom package (ADR-0146 D11). Remove it from '${PAIR}' ` +
52-
`(?package=${PAIR}). A package-less customization stored before this release is still served; run ` +
53-
`\`os migrate packageless-overlays\` first to move it into '${PAIR}'.`;
48+
`'doc/${NAME}' ships in '${BASE}': save it into '${PAIR}' (?package=${PAIR}), declaring ` +
49+
`overrides: { package: '${BASE}', basedOn }. ${CLOSED}`;
50+
const RESET_CLOSED = `'doc/${NAME}' ships in '${BASE}': remove its customization from '${PAIR}' (?package=${PAIR}). ${CLOSED}`;
5451

5552
const server = {
5653
/** The packaged item's stored package-less row, as an unmigrated deployment holds it. */

0 commit comments

Comments
 (0)