From 2aed51c4ed84c263f30630a210fee9d637079bea Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:00:38 +0000 Subject: [PATCH 1/4] test(objectql): pin the delete door's stored-expression fill for an own-package object extension (red on main) Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn Co-authored-by: Claude --- .../src/stored-expression-backfill.test.ts | 91 +++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/packages/objectql/src/stored-expression-backfill.test.ts b/packages/objectql/src/stored-expression-backfill.test.ts index 0406c0e5e5c..602a88c2a89 100644 --- a/packages/objectql/src/stored-expression-backfill.test.ts +++ b/packages/objectql/src/stored-expression-backfill.test.ts @@ -18,6 +18,7 @@ import { describe, it, expect, beforeEach } from 'vitest'; import { ObjectStackProtocolImplementation } from '@objectstack/metadata-protocol'; import { SysMetadataAuditObject, SysMetadataCommitObject, SysMetadataHistoryObject } from '@objectstack/metadata-core'; import { + DeleteMetaItemResponseSchema, PublishMetaItemResponseSchema, PublishPackageDraftsResponseSchema, RevertPackageCommitResponseSchema, @@ -1040,3 +1041,93 @@ describe('[#32700] a rollback or revert that makes a changed stored computed fie expect('advisories' in res).toBe(false); }); }); + +describe('[#32958] deleting an own-package object extension that re-declared a stored computed field fills the owner\'s expression back', () => { + const TIMES_EIGHT = { type: 'number', expression: cel('(record.end_day - record.start_day) * 8') }; + /** The package's own extension of the object, re-declaring `days` with another expression (merged over the owner's). */ + const extension = (fields: Record = { days: { name: 'days', label: 'Days', ...TIMES_EIGHT } }) => ({ extend: OBJ, fields }); + const saveExtension = (rig: Awaited>, item = extension()) => + (rig.protocol as any).saveMetaItem({ type: 'object_extension', name: OBJ, packageId: PKG, item }); + const deleteExtension = (rig: Awaited>, extra: Record = {}) => + (rig.protocol as any).deleteMetaItem({ type: 'object_extension', name: OBJ, packageId: PKG, ...extra }); + /** The expression the registry serves for `days` now. */ + const servedDays = (rig: Awaited>) => + (rig.engine.registry.getObject(OBJ) as any)?.fields?.days?.expression?.source; + + it('object saved first, then the extension: the delete rewrites every row the removed expression computed', async () => { + const rig = await populated(); + await rig.save(STORED); + expect((await saveExtension(rig)).success).toBe(true); + // CONTROL: the extension's expression is served and computed on every row before the delete. + expect(servedDays(rig)).toBe(TIMES_EIGHT.expression.source); + expect(await stored(rig)).toEqual([8, 16, 24]); + rig.updates.length = 0; + + const res = await deleteExtension(rig); + + expect(res.success).toBe(true); + expect(res.reset).toBe(true); + // The registry serves the owner's expression again… + expect(servedDays(rig)).toBe(DAYS.source); + // …and the rows hold what it computes, not the removed expression's values. + expect(await stored(rig)).toEqual([1, 2, 3]); + expect(await total(rig)).toBe(6); + expect(rig.updates).toHaveLength(3); + expect(notices(res, 'stored-expression-filled')).toEqual([expect.objectContaining({ + severity: 'info', + path: `objects.${OBJ}.fields.days`, + where: `object "${OBJ}" · field "days"`, + })]); + expect(notices(res, 'stored-expression-filled')[0].message).toContain('3 rows of 3 written'); + // The declared answer carries the notice through parse unstripped. + expect(DeleteMetaItemResponseSchema.parse(res).advisories).toEqual(res.advisories); + }); + + it('extension saved first, then the object: the delete rewrites every row the removed expression computed', async () => { + const rig = await populated(); + expect((await saveExtension(rig)).success).toBe(true); + await rig.save(STORED); + // CONTROL: the extension still wins over the object saved after it, on the registry and on every row. + expect(servedDays(rig)).toBe(TIMES_EIGHT.expression.source); + expect(await stored(rig)).toEqual([8, 16, 24]); + rig.updates.length = 0; + + const res = await deleteExtension(rig); + + expect(res.success).toBe(true); + expect(servedDays(rig)).toBe(DAYS.source); + expect(await stored(rig)).toEqual([1, 2, 3]); + expect(rig.updates).toHaveLength(3); + expect(notices(res, 'stored-expression-filled')[0].message).toContain('3 rows of 3 written'); + expect(DeleteMetaItemResponseSchema.parse(res).advisories).toEqual(res.advisories); + }); + + it('a delete of an extension that changed no stored computed field writes no row, and its answer carries no advisories key', async () => { + const rig = await populated(); + await rig.save(STORED); + expect((await saveExtension(rig, extension({ note: { name: 'note', label: 'Note', type: 'text' } }))).success).toBe(true); + expect(await stored(rig)).toEqual([1, 2, 3]); + rig.updates.length = 0; + + const res = await deleteExtension(rig); + + expect(res.success).toBe(true); + expect(res.reset).toBe(true); + expect(rig.updates).toEqual([]); + expect('advisories' in res).toBe(false); + }); + + it('a draft discard makes nothing live and fills nothing', async () => { + const rig = await populated(); + await rig.save(STORED); + await (rig.protocol as any).saveMetaItem({ type: 'object_extension', name: OBJ, packageId: PKG, item: extension(), mode: 'draft' }); + expect(await stored(rig)).toEqual([1, 2, 3]); + rig.updates.length = 0; + + const res = await deleteExtension(rig, { state: 'draft' }); + + expect(res.success).toBe(true); + expect(rig.updates).toEqual([]); + expect('advisories' in res).toBe(false); + }); +}); From 9144d8233f2c2f0f30de069e122fbf319a8596c3 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:08:38 +0000 Subject: [PATCH 2/4] fix(metadata-protocol): the delete door fills the stored computed fields a removed object extension hands back Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn Co-authored-by: Claude --- ...elete-extension-fill-stored-expressions.md | 13 ++++++++ .../src/protocol-diff-delete-load.ts | 32 +++++++++++++++++++ .../src/protocol-stored-expression-fill.ts | 10 +++++- packages/metadata-protocol/src/protocol.ts | 12 +++++++ packages/spec/src/api/protocol.zod.ts | 28 +++++++++++++--- 5 files changed, 89 insertions(+), 6 deletions(-) create mode 100644 .changeset/32958-delete-extension-fill-stored-expressions.md diff --git a/.changeset/32958-delete-extension-fill-stored-expressions.md b/.changeset/32958-delete-extension-fill-stored-expressions.md new file mode 100644 index 00000000000..5925eb3c5eb --- /dev/null +++ b/.changeset/32958-delete-extension-fill-stored-expressions.md @@ -0,0 +1,13 @@ +--- +'@objectstack/metadata-protocol': patch +'@objectstack/spec': minor +--- + +fix(metadata-protocol): deleting an object extension that re-declared a stored computed field fills the object's existing rows with the expression it hands back, as the save door does, and says so per field + +Clause-②: yes (widening) — adds an optional `advisories` key to `DeleteMetaItemResponseSchema` +Metadata-protocol: added + +`deleteMetaItem` (`DELETE /api/v1/meta/:type/:name`) removed the row and healed the registry, so the object served the definition beneath the removed one, but it ran no stored-expression fill. Deleting an own-package `object_extension` that re-declared a stored computed field (a non-`formula` field declaring `expression`) therefore left every existing row holding the value the removed expression computed, while the object now computed the owner's expression. Totals, filters and reports read those values with no error anywhere. + +The delete now captures the object's stored computed fields before its registry heal and runs the same fill the save, publish, rollback and revert doors run: each stored computed field the removal makes compute something new is recomputed over the object's existing rows and reported per field on the answer's new optional `advisories` (`stored-expression-filled`, or `stored-expression-fill-incomplete` with what is left and the `os migrate stored-expressions` command that fills it). A draft discard fills nothing. The key is omitted when there is nothing to report, so a clean delete's answer is byte-identical to before. The delete itself never fails on its fill. diff --git a/packages/metadata-protocol/src/protocol-diff-delete-load.ts b/packages/metadata-protocol/src/protocol-diff-delete-load.ts index 531a4f616ad..235e44294da 100644 --- a/packages/metadata-protocol/src/protocol-diff-delete-load.ts +++ b/packages/metadata-protocol/src/protocol-diff-delete-load.ts @@ -60,6 +60,8 @@ import { diffShallow } from './protocol-write-face.js'; import type { MutationProjectionOutcome } from './protocol-mutation-events.js'; import type { DeleteMetaItemRequest } from './protocol-door-requests.js'; import { withRefusalAudit } from './protocol-refusal-audit.js'; +import { captureStoredExpressionChange, fillStoredExpressionChange } from './protocol-stored-expression-fill.js'; +import type { RuntimeAuthoringIssue } from './runtime-authoring-gate.js'; import type { ProtocolHost } from './protocol-host.js'; export class ProtocolDiffDeleteLoadFacet { @@ -383,6 +385,8 @@ export class ProtocolDiffDeleteLoadFacet { seq?: number; /** [ADR-0094] Outcome of the awaited mutation projector, when one is registered. */ projectionApplied?: MutationProjectionOutcome; + /** [#32958] The stored-expression fill of the object the removal changed; omitted when nothing to report. */ + advisories?: RuntimeAuthoringIssue[]; }> { // [#28355] A refusal that carries no row of its own leaves its `denied` row here. return withRefusalAudit((entry) => host.recordMetadataAudit(entry), { @@ -399,6 +403,8 @@ export class ProtocolDiffDeleteLoadFacet { seq?: number; /** [ADR-0094] Outcome of the awaited mutation projector, when one is registered. */ projectionApplied?: MutationProjectionOutcome; + /** [#32958] The stored-expression fill of the object the removal changed; omitted when nothing to report. */ + advisories?: RuntimeAuthoringIssue[]; }> { // [ADR-0131 D6] FIRST: an organization-scoped delete is refused. // See {@link organizationScopedWriteRefusal}. @@ -810,6 +816,17 @@ export class ProtocolDiffDeleteLoadFacet { // overlay used to retire the plain-key entry belonging to the // ENV-WIDE row, i.e. one tenant's "reset to default" blanked // the item for every other tenant and the control plane. + // + // [#32958] The object's stored computed fields as served BEFORE + // the heal: removing an `object_extension` hands the object + // back the definition beneath it, which can give a stored + // computed field another expression. + // What the fill below diffs against, as the save door captures + // before its write-through and the revert door before its + // removal limb's heal. A draft discard changes nothing served. + const storedExpressions = targetState === 'active' + ? captureStoredExpressionChange(host.engine, singularTypeForRepo, request.name) + : undefined; if (targetState === 'active') { // [#32366] For the package of the row it deleted. await host.restoreArtifactRegistryView(request.type, request.name, null, packageId, member); @@ -856,12 +873,27 @@ export class ProtocolDiffDeleteLoadFacet { // [#32451] The package of the row it deleted, as the heal above. ...mutationEventPackage(packageId), }); + // [#32958] A stored computed field the removal made compute + // something new (the extended object's own expression handed + // back by a removed `object_extension`) is filled over the + // object's existing rows by the save door's fill + // (`protocol-stored-expression-fill.ts`, the one fill path), + // and reported per field on the omitted-when-empty + // `advisories`. After the audit row and the event, before the + // answer, as the save door orders it. A removed `object` + // serves no field afterwards, so it changes none and reads no + // row (its table may be gone with it). The delete itself is + // never failed by its fill. + const advisories = await fillStoredExpressionChange(storedExpressions); const deletedPackage = packageId !== null ? ` (package=${packageId})` : ''; return { success: true, reset: true, seq: result.seq, ...(deleteProjection ? { projectionApplied: deleteProjection } : {}), + // Omitted, never `[]`, when there is nothing to report: a + // clean delete's answer bytes are unchanged. + ...(advisories.length > 0 ? { advisories } : {}), // #5927 — the same split #5265/PR #5926 made on the save // side, on the reset path. `artifactBacked` is exactly the // difference between the two things a delete can be: diff --git a/packages/metadata-protocol/src/protocol-stored-expression-fill.ts b/packages/metadata-protocol/src/protocol-stored-expression-fill.ts index dbc7bcf9f4d..33faceef3aa 100644 --- a/packages/metadata-protocol/src/protocol-stored-expression-fill.ts +++ b/packages/metadata-protocol/src/protocol-stored-expression-fill.ts @@ -32,6 +32,14 @@ * (`POST /api/v1/packages/:id/rollback`), a loop of `revertCommit`, whose * answer carries every step's notices. * + * [#32958] …and the delete door that hands an object back the definition + * beneath it (`protocol-diff-delete-load.ts`): `deleteMetaItem` + * (`DELETE /api/v1/meta/:type/:name`) removing an `object_extension` that + * re-declared a stored computed field captures before its registry heal and + * fills after it. Like the + * revert door's removal limb it runs no storage sync, so its answer carries + * no refused sync. + * * A draft save makes nothing live and fills nothing. A peer applying another * node's mutation (`applyRemoteMetadataMutation`) fills nothing either: the * node whose door took the change filled the shared rows once. @@ -53,7 +61,7 @@ * write, an object it could not read, or a storage sync that was refused, * with what is left and how to fill it. * - * The save, publish, rollback or revert itself is never failed by its fill: + * The save, publish, rollback, revert or delete itself is never failed by its fill: * the definition is live and stays live, and the answer says what the rows hold. */ diff --git a/packages/metadata-protocol/src/protocol.ts b/packages/metadata-protocol/src/protocol.ts index 1ca6e7781a5..db1b83dc3ca 100644 --- a/packages/metadata-protocol/src/protocol.ts +++ b/packages/metadata-protocol/src/protocol.ts @@ -11028,6 +11028,14 @@ export class ObjectStackProtocolImplementation implements * next read falls through to the artifact-loaded default. Implements the * "Reset to factory default" semantic from ADR-0005. Whitelist is shared * with {@link saveMetaItem}. + * + * [#32958] A removal that hands an object back the definition beneath it + * (an `object_extension` that re-declared a stored computed field) fills + * every stored computed field it made compute something new over the + * object's existing rows, as + * the save door does (`protocol-stored-expression-fill.ts`), each reported + * on `advisories`, omitted when empty. An unfinished fill never fails the + * delete. */ async deleteMetaItem(request: DeleteMetaItemRequest): Promise<{ success: boolean; @@ -11036,6 +11044,8 @@ export class ObjectStackProtocolImplementation implements seq?: number; /** [ADR-0094] Outcome of the awaited mutation projector, when one is registered. */ projectionApplied?: MutationProjectionOutcome; + /** [#32958] The stored-expression fill of the object the removal changed; omitted when nothing to report. */ + advisories?: RuntimeAuthoringIssue[]; }> { // [#29985 codemod] The body moved to `protocol-diff-delete-load.ts`; it reaches this class through `protocol-host.ts`. return ProtocolDiffDeleteLoadFacet.deleteMetaItem(protocolHost(this), request); @@ -11049,6 +11059,8 @@ export class ObjectStackProtocolImplementation implements seq?: number; /** [ADR-0094] Outcome of the awaited mutation projector, when one is registered. */ projectionApplied?: MutationProjectionOutcome; + /** [#32958] The stored-expression fill of the object the removal changed; omitted when nothing to report. */ + advisories?: RuntimeAuthoringIssue[]; }> { // [#29985 codemod] The body moved to `protocol-diff-delete-load.ts`; it reaches this class through `protocol-host.ts`. return ProtocolDiffDeleteLoadFacet.deleteMetaItemUnaudited(protocolHost(this), request); diff --git a/packages/spec/src/api/protocol.zod.ts b/packages/spec/src/api/protocol.zod.ts index 57856cf5427..5fdd8174ddb 100644 --- a/packages/spec/src/api/protocol.zod.ts +++ b/packages/spec/src/api/protocol.zod.ts @@ -2158,11 +2158,14 @@ export const DeleteMetaItemRequestSchema = lazySchema(() => z.object({ * delete did not happen", and `projectionApplied` absent means "no projector * ran", never "the projection failed" — the same reading its siblings declare. * - * Two keys the siblings carry are deliberately NOT declared, because this - * branch provably never sends them: `version` (a delete mints no new content - * hash — the row is gone, so there is no ADR-0008 OCC token to echo) and - * `advisories` (the #4463 runtime authoring gate runs on the two WRITE doors - * by D1; a delete submits no body for it to judge). + * One key the siblings carry is deliberately NOT declared, because this + * branch provably never sends it: `version` (a delete mints no new content + * hash — the row is gone, so there is no ADR-0008 OCC token to echo). + * `advisories` is declared, and carries none of the #4463 runtime authoring + * gate's findings (that gate runs on the two WRITE doors by D1; a delete + * submits no body for it to judge): only the stored-expression fill of the + * object a removal hands back its underlying definition (#32958), on the + * repository path's row-deleted return alone. */ export const DeleteMetaItemResponseSchema = lazySchema(() => z.object({ success: z.boolean(), @@ -2196,6 +2199,21 @@ export const DeleteMetaItemResponseSchema = lazySchema(() => z.object({ + 'check `projectionApplied.success` rather than rely on the 200.', ), message: z.string().optional(), + advisories: z.array(RuntimeAuthoringIssueSchema).optional().describe( + 'What the delete did to the rows of the object it changed, in the same ' + + 'element shape and omitted-when-empty discipline as ' + + '`SaveMetaItemResponseSchema.advisories`. Present ONLY when at least one ' + + 'entry was raised: an empty array is never emitted, so a clean answer\'s ' + + 'bytes are unchanged and a caller that ignores this key behaves exactly ' + + 'as before. A removal that hands an object back the definition beneath ' + + 'it (an `object_extension` that re-declared a field) can make a stored ' + + 'computed field (a ' + + 'non-`formula` field declaring `expression`) compute something new; per ' + + 'such field, the fill of the object\'s existing rows the save door also ' + + 'runs: `stored-expression-filled` (`info`, the rows written) or ' + + '`stored-expression-fill-incomplete` (`warning`, what is left and how to ' + + 'fill it). The delete itself SUCCEEDED either way.', + ), })); /** From 7443d8072c44267ee25724b0e097688505659698 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 15:18:45 +0000 Subject: [PATCH 3/4] chore(spec): regenerate the authorable surface and reference docs for the delete answer's advisories Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn Co-authored-by: Claude --- content/docs/references/api/protocol.mdx | 13 +++++++++++++ packages/spec/authorable-surface/api.json | 1 + 2 files changed, 14 insertions(+) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 4f54de75b87..7657fcabc0d 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -749,6 +749,7 @@ A write-path strip event: caller-supplied fields legally dropped from the payloa | **seq** | `integer` | optional | Monotonic sequence number of the metadata event this delete appended to the item history (sys_metadata_history.event_seq) — the ordering token the history/audit trail is read by, and the same key both write-verb siblings declare. Unlike `version` it is not an OCC token. Optional HERE, unlike on those siblings, because only the repository path's delete-ful branch appends an event: a no-op reset (no overlay row existed) and the control-plane legacy raw-engine path both answer without one. Absence means "this branch appended no history event", never "nothing was deleted" — read `reset` for that. | | **projectionApplied** | `{ success: boolean; error?: string }` | optional | Outcome of the awaited ADR-0094 mutation projector — the post-persist step that materializes this metadata into its derived data-plane read model. The same receipt `{@link SaveMetaItemResponseSchema}` and `{@link PublishMetaItemResponseSchema}` carry, because the projector runs on all three verbs of this door: on a delete it re-reads the layered state and either retires the derived record or resets it to the artifact baseline. Present ONLY when a projector is registered for this metadata type AND a row was actually deleted, which is why it is optional: its absence means "no projector ran", never "the projection failed". Best-effort by design — a projector failure is reported here and logged, never thrown, so a caller that needs the read model to be live must check `projectionApplied.success` rather than rely on the 200. | | **message** | `string` | optional | | +| **advisories** | `{ rule: string; path: string; where: string; message: string; … }[]` | optional | What the delete did to the rows of the object it changed, in the same element shape and omitted-when-empty discipline as `SaveMetaItemResponseSchema.advisories`. Present ONLY when at least one entry was raised: an empty array is never emitted, so a clean answer's bytes are unchanged and a caller that ignores this key behaves exactly as before. A removal that hands an object back the definition beneath it (an `object_extension` that re-declared a field) can make a stored computed field (a non-`formula` field declaring `expression`) compute something new; per such field, the fill of the object's existing rows the save door also runs: `stored-expression-filled` (`info`, the rows written) or `stored-expression-fill-incomplete` (`warning`, what is left and how to fill it). The delete itself SUCCEEDED either way. | ### Nested Shape: `DeleteMetaItemResponse.projectionApplied` @@ -757,6 +758,18 @@ A write-path strip event: caller-supplied fields legally dropped from the payloa | **success** | `boolean` | ✅ | False when the projector threw; the metadata delete itself still succeeded. | | **error** | `string` | optional | Projector failure message, present only when `success` is false. | +### Nested Shape: `DeleteMetaItemResponse.advisories[number]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **rule** | `string` | ✅ | Stable diagnostic rule id (`flow-multi-write-unfiltered`, `approval-expression-invalid`, …). Machine-readable and stable across releases — the key a renderer groups or suppresses by. | +| **path** | `string` | ✅ | Config path inside the SUBMITTED body (`flows[0].nodes[1].config.multi`), so an editor can jump to the offending key. May be empty when the finding is about the item as a whole. The TOP-LEVEL collection entry follows one rule. The gate evaluates against a private per-write snapshot whose indexes no caller can resolve; a collection-resident write type is one whose collection that snapshot fills with the tenant's other stored items beside the written one, and there the entry is keyed by NAME, never by an array index — for example `objects.acme_invoice.sharingModel` (an `object` write) or `datasets.acme_invoice_metrics.dimensions[0].field` (a `dataset` write). Every other write type is the sole member of its own collection in that snapshot, so its `[0]` IS the written item and stays positional (for example `flows[0]...`). Which write types are collection-resident is derived, never listed: `@objectstack/lint`'s runtime gate computes the set (`NAME_KEYED_STACK_KEYS`) as the collections it carries as resolution context that a gated write type also lands in, so it changes with the gate, not with this text. An entry whose name cannot be spliced into a dotted path keeps its index. Nested positions inside one named item stay positional (`objects.acme_invoice.indexes[1]`): they index the author's own document. | +| **where** | `string` | ✅ | Human-readable location — `flow "leave_approval" · node "approve"`. Prose for a person; use `path` for anything mechanical. | +| **message** | `string` | ✅ | What is wrong, in the rule author's own words. | +| **hint** | `string` | ✅ | How to fix it. | +| **severity** | `Enum<'error' \| 'warning' \| 'info'>` | ✅ | How the gate treated this finding. `error` means the write was REFUSED (these appear on the 422, never on a 2xx); `warning` / `info` are advisory — the write succeeded and the finding is FYI. | +| **userMessage** | `string` | optional | The finding's user-facing sentence, composed by its producer in the request's locale (else the workspace default locale, else `en`) — the same field name and producer-marked meaning as `ApiErrorSchema.userMessage`. Present only when the producer authors a user sentence for this `rule`; absent, a consumer renders `message` as before. Consumers render it as received; `rule` stays the stable id and `message` / `hint` stay the developer-facing text. | + --- diff --git a/packages/spec/authorable-surface/api.json b/packages/spec/authorable-surface/api.json index 12942fd998e..4016573734c 100644 --- a/packages/spec/authorable-surface/api.json +++ b/packages/spec/authorable-surface/api.json @@ -525,6 +525,7 @@ "api/DeleteMetaItemRequest:parentVersion", "api/DeleteMetaItemRequest:state", "api/DeleteMetaItemRequest:type", + "api/DeleteMetaItemResponse:advisories", "api/DeleteMetaItemResponse:message", "api/DeleteMetaItemResponse:projectionApplied", "api/DeleteMetaItemResponse:reset", From d7dd7d7b1333eae9a128ba36a960735ebb9f595e Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 17:04:34 +0000 Subject: [PATCH 4/4] test(spec): the delete answer declares advisories for the stored-expression fill Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn Co-Authored-By: Claude --- packages/spec/src/api/protocol.test.ts | 28 ++++++++++++++++++++------ 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/packages/spec/src/api/protocol.test.ts b/packages/spec/src/api/protocol.test.ts index 71fa6bc7a22..c7aa7c864dd 100644 --- a/packages/spec/src/api/protocol.test.ts +++ b/packages/spec/src/api/protocol.test.ts @@ -1062,19 +1062,35 @@ describe('DeleteMetaItemResponseSchema (carries the declared = returned discipli expect(DeleteMetaItemResponseSchema.parse(realResponse).projectionApplied).toBeUndefined(); }); - it('declares neither `version` nor `advisories` — this branch provably sends neither', () => { + it('does not declare `version` — this branch provably never sends it', () => { // The mirror is the siblings' SHAPE, not their member list. A delete mints // no new content hash (the row is gone, so there is no ADR-0008 OCC token - // to echo as `If-Match`), and the #4463 authoring gate runs on the two - // WRITE doors by D1 — a delete submits no body for it to judge. Declaring - // either would be a contract for bytes no producer emits. + // to echo as `If-Match`). Declaring it would be a contract for bytes no + // producer emits. const parsed = DeleteMetaItemResponseSchema.parse({ ...realResponse, version: 'sha256:0000000000000000000000000000000000000000000000000000000000000000', - advisories: [], }) as Record; expect(parsed).not.toHaveProperty('version'); - expect(parsed).not.toHaveProperty('advisories'); + }); + + it('declares `advisories` — the stored-expression fill of a removal that hands an object back its definition (#32958)', () => { + // The #4463 authoring gate still runs on the two WRITE doors only; what + // rides a delete's `advisories` is the save door's fill of the object a + // removed `object_extension` hands back (the producer-side pin is + // `packages/objectql/src/stored-expression-backfill.test.ts`). + const advisory = { + rule: 'stored-expression-filled', + severity: 'info' as const, + where: 'object "leave_request" · field "days"', + path: 'objects.leave_request.fields.days', + message: "'leave_request.days' computes a new value at this change, so the platform filled the object's existing rows.", + hint: 'Nothing to do: every row holds what a write of it would store.', + }; + const parsed = DeleteMetaItemResponseSchema.parse({ ...realResponse, advisories: [advisory] }); + expect(parsed.advisories).toEqual([advisory]); + // Optional: a clean delete omits the key. + expect(DeleteMetaItemResponseSchema.parse(realResponse)).not.toHaveProperty('advisories'); }); });