From 413ab0398ff511bcfea6fce9f5630f46d60521a8 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:37:15 +0000 Subject: [PATCH 1/7] feat(metadata-protocol, spec): a publish whose registry refused an object answers published_unregistered naming it The batch publish answers outcome published_unregistered, success false, and unregistered[] naming each object the runtime registry refused, under the object-registry-refused rule. The REST door's visibility flip keeps following this outcome, as it followed the published answer before. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- ...7-publish-drafts-published-unregistered.md | 21 +++++ packages/client/src/index.ts | 9 +- .../src/protocol-history-and-publish.ts | 50 ++++++++--- ...protocol-publish-drafts-advisories.test.ts | 88 +++++++++++++++++-- packages/metadata-protocol/src/protocol.ts | 14 ++- packages/runtime/src/domains/packages.ts | 6 ++ packages/runtime/src/http-dispatcher.test.ts | 25 ++++++ packages/spec/src/api/protocol.test.ts | 29 +++++- packages/spec/src/api/protocol.zod.ts | 48 ++++++++-- ...h-drafts-outcome-published-unregistered.ts | 43 +++++++++ 10 files changed, 304 insertions(+), 29 deletions(-) create mode 100644 .changeset/33277-publish-drafts-published-unregistered.md create mode 100644 packages/spec/src/migrations/entries/semantic/18.publish-drafts-outcome-published-unregistered.ts diff --git a/.changeset/33277-publish-drafts-published-unregistered.md b/.changeset/33277-publish-drafts-published-unregistered.md new file mode 100644 index 00000000000..6d6e47842f9 --- /dev/null +++ b/.changeset/33277-publish-drafts-published-unregistered.md @@ -0,0 +1,21 @@ +--- +'@objectstack/spec': patch +'@objectstack/metadata-protocol': patch +'@objectstack/runtime': patch +'@objectstack/client': patch +--- + +feat(metadata-protocol, spec): a package publish whose runtime registry refused an object answers `published_unregistered` and names the object, instead of `published` + +Clause-②: yes (widening) — `PublishPackageDraftsResponseSchema.outcome` gains the value `published_unregistered`, and the response gains the optional member `unregistered[]`. Every other answer is byte-identical: a publish the registry takes whole still answers `published` with `success: true` and no `unregistered` key. +Metadata-protocol: none + +**What answers differently.** `POST /api/v1/packages/:id/publish-drafts` (and the protocol's `publishPackageDrafts`, and `client.packages.publishDrafts()`) used to answer `outcome: 'published'` and `success: true` when the runtime registry refused one of the objects it had just made live. The object carried the `object-registry-refused` warning on its `published[]` element, but a caller that read `success` or `outcome` saw a clean publish, and a seed load or data read right after it answered `OBJECT_NOT_FOUND`. The same publish now answers: + +- `outcome: 'published_unregistered'` and `success: false` (`success` is still exactly `outcome === 'published'`); +- `unregistered: [{ type: 'object', name, rule: 'object-registry-refused' }]`, one entry per refused object, in publish order; +- everything else as before: the drafts landed and stay live, so every object is still in `published[]` (the refused one still carries its warning), `failed[]` is empty, and the commit, seeds, probes and receipts are as they were. + +**What to do.** Handle the new value wherever you branch on the batch publish answer. Do not treat it as "nothing landed": the metadata is live. Do not seed or read an object `unregistered[]` names until it is registered: publish it again, which re-runs the registration, or restart, which registers every stored object. + +**Unchanged on purpose.** The REST door's app visibility flip (ADR-0045 §3) still runs after this outcome, as it ran after the `published` answer this used to be. The single-item doors (`publishMetaItem`, a publish-mode save) still answer success with the warning on their `advisories`. diff --git a/packages/client/src/index.ts b/packages/client/src/index.ts index 04191eb1cd1..a72aac93c26 100644 --- a/packages/client/src/index.ts +++ b/packages/client/src/index.ts @@ -3304,8 +3304,13 @@ export class ObjectStackClient { * Nameable at the type level only since #9406, which declared * `PublishPackageDraftsResponseSchema` — the batch sibling of #7294's * single-item declaration; this method resolved to `any` before that. - * The batch is all-or-nothing (ADR-0067 D2): `success: false` on a 200 - * means NOTHING landed — read `failed[]`. Each `published[]` element's + * The batch is all-or-nothing (ADR-0067 D2), but `success: false` on a + * 200 does not by itself mean nothing landed — read `outcome`: `refused` + * means NOTHING landed (read `failed[]`), `nothing_to_publish` means there + * was nothing to promote, and `published_unregistered` (#33277) means the + * drafts landed but the runtime registry refused the objects + * `unregistered[]` names, which are not served until registered: publish + * them again or restart before seeding or reading them. Each `published[]` element's * `version` is the ADR-0008 OCC token (pass to `saveItem` as * `options.ifMatch`, which sends it as `If-Match`), and the * conditional receipts (`seedApplied` / `materializeApplied` / diff --git a/packages/metadata-protocol/src/protocol-history-and-publish.ts b/packages/metadata-protocol/src/protocol-history-and-publish.ts index 884d24a1313..8035b04df7e 100644 --- a/packages/metadata-protocol/src/protocol-history-and-publish.ts +++ b/packages/metadata-protocol/src/protocol-history-and-publish.ts @@ -65,7 +65,7 @@ import type { SysMetadataRepository } from './sys-metadata-repository.js'; import type { HistoryVersionOwner } from './sys-metadata-repository.js'; import { historySlotOf, refusePackageSelectorOutsideSlottedTypes } from './protocol-history-slots.js'; import { captureStoredExpressionChange, fillStoredExpressionChange, type StoredExpressionFillCapture } from './protocol-stored-expression-fill.js'; -import { reportObjectRegistryRefusal } from './protocol-registry-hydration.js'; +import { OBJECT_REGISTRY_REFUSED, reportObjectRegistryRefusal } from './protocol-registry-hydration.js'; /** * [#32396] A promotion a package publish wrote: what {@link undoLandedPromotions} @@ -1533,8 +1533,12 @@ export class ProtocolHistoryAndPublishFacet { * `success === (outcome === 'published')` — `success` keeps its exact * pre-#10462 value and is now derivable. Values are lowercase snake, * matching the `sys_metadata_audit` outcome vocabulary. + * [#33277] `published_unregistered`: the drafts landed as on + * `published`, but the runtime registry refused a promoted object, so + * it is not served; `unregistered` is present if and only if this is + * the outcome, and `success` is false on it. */ - outcome: 'published' | 'refused' | 'nothing_to_publish'; + outcome: 'published' | 'published_unregistered' | 'refused' | 'nothing_to_publish'; publishedCount: number; failedCount: number; published: Array<{ @@ -1559,6 +1563,14 @@ export class ProtocolHistoryAndPublishFacet { advisories?: RuntimeAuthoringIssue[]; }>; failed: Array<{ type: string; name: string; error: string; code?: string }>; + /** + * [#33277] Each promoted object the runtime registry refused, in + * publish order, under the rule its `published[]` element's warning + * carries. Present only on `outcome: 'published_unregistered'`, and + * then non-empty; the object stays in `published[]` (its metadata is + * live) but is not served until something registers it. + */ + unregistered?: Array<{ type: string; name: string; rule: 'object-registry-refused' }>; /** Aggregate result of materializing every published `seed` (absent when no seeds). */ seedApplied?: { success: boolean; inserted: number; updated: number; error?: string; errors?: unknown[]; landed?: SeedAppliedLandedParsed[] }; /** @@ -2495,6 +2507,10 @@ export class ProtocolHistoryAndPublishFacet { if (capture && !storedExpressions.has(capture.object)) storedExpressions.set(capture.object, { capture, at }); }); const storageRefusedObjects = new Set(); + // [#33277] The promoted objects the registry refused at their own + // write-through below, in publish order: what turns the answer into + // `published_unregistered`. + const unregistered: Array<{ type: string; name: string; rule: typeof OBJECT_REGISTRY_REFUSED }> = []; await registerAdmittedBatchRows(this, promotedObjects, admittedOrder); for (const p of promoted) { // [#9343] Omitted-when-empty, never `advisories: []` — the #4717 @@ -2530,7 +2546,13 @@ export class ProtocolHistoryAndPublishFacet { // `object-registry-refused`: the batch still answers // `published` (outcome and `success` unchanged), and this is // the element a caller reads to learn the object is not served. - if (eff.registryRefused) element.advisories = [...(element.advisories ?? []), eff.registryRefused]; + // [#33277] …and the batch no longer answers `published` over + // it: the object is named in `unregistered[]` under the same + // rule, and the outcome below is `published_unregistered`. + if (eff.registryRefused) { + element.advisories = [...(element.advisories ?? []), eff.registryRefused]; + unregistered.push({ type: p.d.type, name: p.d.name, rule: OBJECT_REGISTRY_REFUSED }); + } if (eff.storageRefused) { element.advisories = [...(element.advisories ?? []), eff.storageRefused]; storageRefusedObjects.add(p.d.name); @@ -2644,20 +2666,28 @@ export class ProtocolHistoryAndPublishFacet { ); } + const outcome = failed.length > 0 + ? 'refused' + : published.length === 0 + ? 'nothing_to_publish' + : unregistered.length > 0 ? 'published_unregistered' : 'published'; return { - success: failed.length === 0 && published.length > 0, + // [#33277] Still exactly `outcome === 'published'`: a batch whose + // drafts landed while the registry refused an object among them is + // not a successful publish for a caller about to use that object. + success: outcome === 'published', // [#10462] Derived, never stored: 'refused' the moment anything is // in `failed[]` (defensive — every failure on this route unwinds - // through the Phase-1 catch above today), else 'published' iff - // something landed, else the no-op. Exactly the three-way fact - // `success` compresses into one boolean. - outcome: failed.length > 0 - ? 'refused' - : published.length > 0 ? 'published' : 'nothing_to_publish', + // through the Phase-1 catch above today), else the no-op when + // nothing landed, else [#33277] 'published_unregistered' when the + // registry refused a promoted object, else 'published'. Exactly the + // fact `success` compresses into one boolean. + outcome, publishedCount: published.length, failedCount: failed.length, published, failed, + ...(unregistered.length > 0 ? { unregistered } : {}), ...(seedApplied ? { seedApplied } : {}), ...(materialize.any ? { materializeApplied: { diff --git a/packages/metadata-protocol/src/protocol-publish-drafts-advisories.test.ts b/packages/metadata-protocol/src/protocol-publish-drafts-advisories.test.ts index adfd5284f7a..571ca27b62d 100644 --- a/packages/metadata-protocol/src/protocol-publish-drafts-advisories.test.ts +++ b/packages/metadata-protocol/src/protocol-publish-drafts-advisories.test.ts @@ -475,9 +475,10 @@ describe('[#30693] publishPackageDrafts reports a refused object-storage sync on // The registry write-through runs after the metadata commit (ADR-0067 D2) and // used to keep a refused `registerObject` to a `warn` line: the batch answered // `published` with nothing naming the object, and a seed load right after it -// answered OBJECT_NOT_FOUND. The ruled interim answer (option D): outcome and -// `success` unchanged, one `error` line for the operator, and one warning under -// the stable rule `object-registry-refused` on the refused object's element. +// answered OBJECT_NOT_FOUND. The ruled interim answer (option D): one `error` +// line for the operator, and one warning under the stable rule +// `object-registry-refused` on the refused object's element. Its follow-up +// (#33277, below) moves the batch's outcome off `published`. const REGISTRY_REFUSED_RULE = 'object-registry-refused'; @@ -499,7 +500,7 @@ describe('[#33005] publishPackageDrafts reports a registry-refused object on tha vi.restoreAllMocks(); }); - it('the batch still answers published; exactly the refused element carries the rule, logged at error once', async () => { + it('exactly the refused element carries the rule, logged at error once', async () => { vi.spyOn(console, 'warn').mockImplementation(() => {}); const error = vi.spyOn(console, 'error').mockImplementation(() => {}); const { engine } = makeStubEngine(); @@ -510,9 +511,9 @@ describe('[#33005] publishPackageDrafts reports a registry-refused object on tha const res = await protocol.publishPackageDrafts({ packageId: PKG }); - // Option D changes neither the outcome nor `success`. + // Nothing is refused or rolled back: both drafts landed. expect(res.failed).toEqual([]); - expect(res).toMatchObject({ success: true, outcome: 'published', publishedCount: 2, failedCount: 0 }); + expect(res).toMatchObject({ publishedCount: 2, failedCount: 0 }); const byName = new Map(res.published.map((p) => [p.name, p])); const refused = byName.get('ticket')!; @@ -560,3 +561,78 @@ describe('[#33005] publishPackageDrafts reports a registry-refused object on tha expect(registryRefusedLines(error, 'invoice')).toHaveLength(1); }); }); + +// --------------------------------------------------------------------------- +// [#33277] A batch whose registry refused an object answers a distinct outcome. +// --------------------------------------------------------------------------- +// The follow-up the #33005 ruling named (option A): the drafts landed and stay +// live, so the object stays in `published[]` with its warning, but the batch +// no longer answers `published`. It answers `published_unregistered`, +// `success: false`, and names each refused object in `unregistered[]` under +// the same rule id, in publish order. + +describe('[#33277] publishPackageDrafts answers published_unregistered naming each object the registry refused', () => { + afterEach(() => { + vi.restoreAllMocks(); + }); + + // Publish order follows the staging order here, so both orders put the + // refused object on either side of a sibling the registry accepts. + for (const order of [['ticket', 'invoice'], ['invoice', 'ticket']] as const) { + it(`names the refused object and does not answer published (publish order ${order.join(', ')})`, async () => { + vi.spyOn(console, 'warn').mockImplementation(() => {}); + vi.spyOn(console, 'error').mockImplementation(() => {}); + const { engine } = makeStubEngine(); + refuseRegistration(engine, new Set(['ticket'])); + const protocol = new ObjectStackProtocolImplementation(engine); + for (const name of order) await stageObjectDraft(protocol, name); + + const res = await protocol.publishPackageDrafts({ packageId: PKG }); + + expect(res.outcome).toBe('published_unregistered'); + expect(res.success).toBe(false); + expect(res.unregistered).toEqual([{ type: 'object', name: 'ticket', rule: REGISTRY_REFUSED_RULE }]); + // The drafts landed: nothing failed, both are published, and the + // refused object's element still carries the warning it names. + expect(res.failed).toEqual([]); + expect(res).toMatchObject({ publishedCount: 2, failedCount: 0 }); + expect(res.published.map((p) => p.name)).toEqual([...order]); + const refused = res.published.find((p) => p.name === 'ticket')!; + expect((refused.advisories ?? []).map((a) => a.rule)).toEqual([REGISTRY_REFUSED_RULE]); + }); + } + + it('names every refused object, in publish order', async () => { + vi.spyOn(console, 'warn').mockImplementation(() => {}); + vi.spyOn(console, 'error').mockImplementation(() => {}); + const { engine } = makeStubEngine(); + refuseRegistration(engine, new Set(['ticket', 'invoice'])); + const protocol = new ObjectStackProtocolImplementation(engine); + for (const name of ['invoice', 'account', 'ticket']) await stageObjectDraft(protocol, name); + + const res = await protocol.publishPackageDrafts({ packageId: PKG }); + + expect(res.outcome).toBe('published_unregistered'); + expect(res.success).toBe(false); + expect(res.unregistered).toEqual([ + { type: 'object', name: 'invoice', rule: REGISTRY_REFUSED_RULE }, + { type: 'object', name: 'ticket', rule: REGISTRY_REFUSED_RULE }, + ]); + expect(res.publishedCount).toBe(3); + }); + + it('CONTROL: a batch the registry takes whole still answers published, with no unregistered key', async () => { + vi.spyOn(console, 'warn').mockImplementation(() => {}); + vi.spyOn(console, 'error').mockImplementation(() => {}); + const { engine } = makeStubEngine(); + refuseRegistration(engine, new Set()); + const protocol = new ObjectStackProtocolImplementation(engine); + await stageObjectDraft(protocol, 'ticket'); + await stageObjectDraft(protocol, 'invoice'); + + const res = await protocol.publishPackageDrafts({ packageId: PKG }); + + expect(res).toMatchObject({ success: true, outcome: 'published', publishedCount: 2, failedCount: 0 }); + expect('unregistered' in res).toBe(false); + }); +}); diff --git a/packages/metadata-protocol/src/protocol.ts b/packages/metadata-protocol/src/protocol.ts index 35d7a6b39d7..c317f151b89 100644 --- a/packages/metadata-protocol/src/protocol.ts +++ b/packages/metadata-protocol/src/protocol.ts @@ -10075,8 +10075,12 @@ export class ObjectStackProtocolImplementation implements * `success === (outcome === 'published')` — `success` keeps its exact * pre-#10462 value and is now derivable. Values are lowercase snake, * matching the `sys_metadata_audit` outcome vocabulary. + * [#33277] `published_unregistered`: the drafts landed as on + * `published`, but the runtime registry refused a promoted object, so + * it is not served; `unregistered` is present if and only if this is + * the outcome, and `success` is false on it. */ - outcome: 'published' | 'refused' | 'nothing_to_publish'; + outcome: 'published' | 'published_unregistered' | 'refused' | 'nothing_to_publish'; publishedCount: number; failedCount: number; published: Array<{ @@ -10101,6 +10105,14 @@ export class ObjectStackProtocolImplementation implements advisories?: RuntimeAuthoringIssue[]; }>; failed: Array<{ type: string; name: string; error: string; code?: string }>; + /** + * [#33277] Each promoted object the runtime registry refused, in + * publish order, under the rule its `published[]` element's warning + * carries. Present only on `outcome: 'published_unregistered'`, and + * then non-empty; the object stays in `published[]` (its metadata is + * live) but is not served until something registers it. + */ + unregistered?: Array<{ type: string; name: string; rule: 'object-registry-refused' }>; /** Aggregate result of materializing every published `seed` (absent when no seeds). */ seedApplied?: { success: boolean; inserted: number; updated: number; error?: string; errors?: unknown[]; landed?: SeedAppliedLandedParsed[] }; /** diff --git a/packages/runtime/src/domains/packages.ts b/packages/runtime/src/domains/packages.ts index 29dc2a6d33e..0eb6daa0134 100644 --- a/packages/runtime/src/domains/packages.ts +++ b/packages/runtime/src/domains/packages.ts @@ -648,6 +648,11 @@ function packageIsUnknown(registry: unknown, id: string): boolean { * someone else's success, so it runs only on a success the producer NAMES. * * - `published` — the drafts landed; the package is live and becomes visible. + * - `published_unregistered` — the drafts landed exactly as on `published`, + * but the runtime registry refused an object among them (#33277), which + * `unregistered[]` names. Kept in the list on purpose, pending a ruling: this + * answer used to read `published`, so the flip ran on it, and dropping it + * would change visibility beyond what the outcome change was asked to do. * - `nothing_to_publish` — kept on purpose: for a materialized (additive) * build there are no drafts, and this flip IS the publish (ADR-0045 §3). * @@ -659,6 +664,7 @@ function packageIsUnknown(registry: unknown, id: string): boolean { */ const PUBLISH_OUTCOMES_THAT_FLIP: ReadonlySet = new Set([ 'published', + 'published_unregistered', 'nothing_to_publish', ]); diff --git a/packages/runtime/src/http-dispatcher.test.ts b/packages/runtime/src/http-dispatcher.test.ts index e7c5d84b1b6..fafc9d61584 100644 --- a/packages/runtime/src/http-dispatcher.test.ts +++ b/packages/runtime/src/http-dispatcher.test.ts @@ -2498,6 +2498,31 @@ describe('HttpDispatcher', () => { expect(trigger, JSON.stringify(outcome)).not.toHaveBeenCalled(); } }); + + // #33277 — a batch whose drafts landed while the registry refused an + // object answers `published_unregistered`; it used to answer + // `published`, and the flip keeps following it until ruled otherwise. + it('POST /packages/:id/publish-drafts still runs the visibility flip after published_unregistered', async () => { + const { getMetaItems, saveMetaItem, trigger } = flipDoubles({ + success: false, outcome: 'published_unregistered', publishedCount: 1, failedCount: 0, + published: [{ type: 'object', name: 'ticket', version: 'v1' }], failed: [], + unregistered: [{ type: 'object', name: 'ticket', rule: 'object-registry-refused' }], + }); + + const result = await dispatcher.handlePackages('/app.crm/publish-drafts', 'POST', {}, {}, PKG_ADMIN()); + + expect(result.response?.status).toBe(200); + const data = (result.response as any)?.body?.data; + expect(data?.outcome).toBe('published_unregistered'); + expect(data?.unregistered).toEqual([{ type: 'object', name: 'ticket', rule: 'object-registry-refused' }]); + expect(getMetaItems).toHaveBeenCalledTimes(1); + expect(saveMetaItem).toHaveBeenCalledWith(expect.objectContaining({ type: 'app', name: 'crm' })); + expect(data?.unhiddenApps).toEqual(['crm']); + expect(trigger).toHaveBeenCalledWith( + 'metadata:reloaded', + expect.objectContaining({ changed: ['object/ticket', 'app/crm'] }), + ); + }); }); // ═══════════════════════════════════════════════════════════════ diff --git a/packages/spec/src/api/protocol.test.ts b/packages/spec/src/api/protocol.test.ts index 74d51275f90..904c0bcee84 100644 --- a/packages/spec/src/api/protocol.test.ts +++ b/packages/spec/src/api/protocol.test.ts @@ -1529,12 +1529,39 @@ describe('PublishPackageDraftsResponseSchema (declares the batch publish respons published: [], failed: [], }; - for (const key of ['seedApplied', 'materializeApplied', 'probes', 'commitId', 'unhiddenApps', 'unhideError', 'rebindError'] as const) { + for (const key of ['seedApplied', 'materializeApplied', 'probes', 'commitId', 'unhiddenApps', 'unhideError', 'rebindError', 'unregistered'] as const) { expect(minimal).not.toHaveProperty(key); } expect(PublishPackageDraftsResponseSchema.safeParse(minimal).success).toBe(true); }); + it('declares published_unregistered: the drafts landed, unregistered[] names each object the registry refused (#33277)', () => { + const unregistered = { + ...realResponse, + success: false, + outcome: 'published_unregistered', + published: [ + ...realResponse.published, + { type: 'object', name: 'ticket', version: 'sha256:2cad99c8d969efb5067fff275fb3e5be7ec90f9cd610d41709fcddbf8c34b1f2' }, + ], + publishedCount: 3, + unregistered: [{ type: 'object', name: 'ticket', rule: 'object-registry-refused' }], + }; + const parsed = PublishPackageDraftsResponseSchema.parse(unregistered); + expect(parsed).toEqual(unregistered); + // The rule is the declared id, not any string: an entry must say why. + expect(PublishPackageDraftsResponseSchema.safeParse({ + ...unregistered, + unregistered: [{ type: 'object', name: 'ticket', rule: 'registry-said-no' }], + }).success).toBe(false); + expect(PublishPackageDraftsResponseSchema.safeParse({ + ...unregistered, + unregistered: [{ type: 'object', name: 'ticket' }], + }).success).toBe(false); + // The vocabulary stays closed around the new value. + expect(PublishPackageDraftsResponseSchema.safeParse({ ...realResponse, outcome: 'partial' }).success).toBe(false); + }); + it('does not fabricate any key: parse of a lean body adds nothing (byte-stability half)', () => { // No `.default()` anywhere — a declaration that invents keys on the // consumer side would make "absent" unobservable and change what callers diff --git a/packages/spec/src/api/protocol.zod.ts b/packages/spec/src/api/protocol.zod.ts index a69512cff09..c82a28dcf07 100644 --- a/packages/spec/src/api/protocol.zod.ts +++ b/packages/spec/src/api/protocol.zod.ts @@ -1775,9 +1775,10 @@ export const PublishPackageDraftsRequestSchema = lazySchema(() => z.object({ * `success: false` on a 200 with `publishedCount: 0`, `published: []` and the * whole batch in `failed[]` (`BATCH_ABORTED` marks the non-causal items). * `success: false` alone does NOT mean a refusal — a publish with no pending - * drafts answers it too, with `failed: []`; `outcome` (#10462) names which of - * the three exits answered, so no consumer has to reverse-engineer that from - * `failed.length`. + * drafts answers it too, with `failed: []`, and so does a publish whose drafts + * landed while the runtime registry refused an object among them (#33277); + * `outcome` (#10462) names which of the four exits answered, so no consumer + * has to reverse-engineer that from `failed.length`. * * **`probes` is deliberately OPAQUE** — see its own note below. Do not model * it here without a consumer-driven card (#9406 ruling). @@ -1789,13 +1790,22 @@ export const PublishPackageDraftsResponseSchema = lazySchema(() => z.object({ + 'rollback answers false on a 200 — but so does a publish with nothing ' + 'to promote, so false alone is NOT a refusal: read `outcome`, ' + 'not this boolean or the HTTP status. Always equal to ' - + '`outcome === \'published\'` (pinned). It does NOT cover the ' - + 'best-effort receipts below, each of which reports its own `success`.', + + '`outcome === \'published\'` (pinned), so it is also false on ' + + '`published_unregistered`, where the drafts landed but an object is not ' + + 'served. It does NOT cover the best-effort receipts below, each of ' + + 'which reports its own `success`.', ), - outcome: z.enum(['published', 'refused', 'nothing_to_publish']).describe( + outcome: z.enum(['published', 'published_unregistered', 'refused', 'nothing_to_publish']).describe( 'First-class discriminant for WHICH exit answered — the fact ' + '`success` compresses into one boolean. `published`: at least one draft ' - + 'promoted and none refused. `refused`: the batch was refused — a ' + + 'promoted, none refused, and the runtime registry took every promoted ' + + 'object. `published_unregistered`: the drafts landed exactly as ' + + 'on `published` — the metadata is live and stays live — but the runtime ' + + 'registry refused at least one promoted object, so that object is not ' + + 'served: until something registers it, data reads, writes and seed ' + + 'loads against it answer OBJECT_NOT_FOUND. `unregistered[]` names each ' + + 'such object; do not seed or read it before it is registered (publish ' + + 'it again, or restart). `refused`: the batch was refused — a ' + 'pre-flight violation or the ADR-0067 D2 all-or-nothing rollback; the ' + 'per-item story is in `failed[]`, which is non-empty exactly on this ' + 'outcome (the invariant consumers previously had to reverse-engineer, ' @@ -1806,8 +1816,10 @@ export const PublishPackageDraftsResponseSchema = lazySchema(() => z.object({ + 'invariants, pinned in the conformance suites: ' + '`success === (outcome === \'published\')`; `refused` if and only if ' + '`failed.length > 0`; `nothing_to_publish` if and only if ' - + '`published.length === 0 && failed.length === 0`. Values are lowercase ' - + 'snake, matching the `sys_metadata_audit` outcome vocabulary.', + + '`published.length === 0 && failed.length === 0`; ' + + '`published_unregistered` if and only if `unregistered` is present. ' + + 'Values are lowercase snake, matching the `sys_metadata_audit` outcome ' + + 'vocabulary.', ), publishedCount: z.number().int().describe( 'Number of drafts promoted to active — `published.length`. 0 on every ' @@ -1881,6 +1893,24 @@ export const PublishPackageDraftsResponseSchema = lazySchema(() => z.object({ + '(ADR-0067 D2), a non-empty list means NOTHING landed: ' + '`published: []`, `publishedCount: 0`.', ), + unregistered: z.array(z.object({ + type: z.string().describe('Metadata type of the published item the registry refused (`object`).'), + name: z.string().describe('Name of the object that is published but not served.'), + rule: z.enum(['object-registry-refused']).describe( + 'Why it is not served, as a stable rule id: the same id as the ' + + 'warning on this object\'s `published[]` element, whose `message` ' + + 'and `hint` say what happened and how to fix it.', + ), + })).optional().describe( + 'Present ONLY on `outcome: \'published_unregistered\'`, and then ' + + 'non-empty: each promoted object the runtime registry refused, in ' + + 'publish order. Every entry also appears in `published[]` — ' + + 'its metadata IS live, nothing was rolled back (ADR-0067 D2 runs the ' + + 'registration after the metadata commit) — but the object is not ' + + 'served until something registers it, so a caller about to seed or ' + + 'read it should publish it again or restart first. Absent on every ' + + 'other outcome; an empty array is never emitted.', + ), seedApplied: z.object({ success: z.boolean().describe( 'False when the seed rows did not fully land. The publish itself ' diff --git a/packages/spec/src/migrations/entries/semantic/18.publish-drafts-outcome-published-unregistered.ts b/packages/spec/src/migrations/entries/semantic/18.publish-drafts-outcome-published-unregistered.ts new file mode 100644 index 00000000000..5043a4b4258 --- /dev/null +++ b/packages/spec/src/migrations/entries/semantic/18.publish-drafts-outcome-published-unregistered.ts @@ -0,0 +1,43 @@ +// Copyright (c) 2026 ObjectStack. Licensed under the Apache-2.0 license. + +import type { SemanticMigration } from '../../types.js'; + +// The follow-up the object-registry-refused advisory was ruled with (option A): +// a batch publish whose runtime registry refused a promoted object stops +// answering `published`. Registered because a caller that branched on +// `success` or on `outcome === 'published'` now takes a different branch for +// the same server event, and the new value is one an exhaustive switch over +// the outcome vocabulary has never seen. +export const entry: SemanticMigration = { + id: 'publish-drafts-outcome-published-unregistered', + surface: + 'PublishPackageDraftsResponseSchema.outcome and .success (the answer of ' + + '`POST /api/v1/packages/:id/publish-drafts`, `client.packages.publishDrafts()` and the ' + + 'protocol\'s `publishPackageDrafts`), and its new `unregistered[]` member', + replacement: + 'read `outcome`, which now has four values: `published`, `published_unregistered`, `refused` ' + + 'and `nothing_to_publish`. On `published_unregistered` the drafts landed and stay live, and ' + + '`unregistered[]` names each object the runtime registry refused (rule ' + + '`object-registry-refused`, the id of the warning on that object\'s `published[]` element); ' + + 'publish those objects again, or restart, before seeding or reading them', + reason: + 'A publish whose registry write-through refused an object used to answer `outcome: ' + + '\'published\'` and `success: true` while the object was not served: a seed load or data read ' + + 'right after it answered OBJECT_NOT_FOUND. The warning on the element made the refusal visible ' + + 'to a reader of `published[].advisories`; a programmatic caller that branched on `success` or ' + + 'on `outcome` still read a clean publish. Now that same event answers `outcome: ' + + '\'published_unregistered\'` and `success: false` (`success` stays exactly `outcome === ' + + '\'published\'`). Nothing was rolled back — ADR-0067 D2 runs the registration after the ' + + 'metadata commit — so a caller that treats every `success: false` as "nothing landed" is now ' + + 'wrong on this value, and a caller with an exhaustive switch over the outcome has a new case ' + + 'to handle. The REST door\'s app visibility flip still follows this outcome, as it followed ' + + 'the `published` answer before.', + acceptanceCriteria: + 'Every consumer of the batch publish answer handles `published_unregistered` explicitly: it does ' + + 'not report "nothing landed" for it (the drafts are live), and it does not seed or read the ' + + 'objects `unregistered[]` names until they are registered. A test that publishes with the ' + + 'registry refusing one object sees `outcome: \'published_unregistered\'`, `success: false`, ' + + 'that object named in `unregistered[]` and still present in `published[]`; the same publish ' + + 'with the registry accepting every object still answers `published`, `success: true`, and no ' + + '`unregistered` key.', +}; From 28592673736e9d510a52227c1aeb78f91a2d3508 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:38:15 +0000 Subject: [PATCH 2/7] fix(app-shell): the publish callers read published_unregistered as the published answer it used to be Studio, the package sheet, Publish all and the AI chat card treated every success false as a failed publish. The new outcome answers success false over drafts that landed, with the refused object's warning already reported by the client, so each caller keeps the presentation it had. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- .../app-shell/src/console/ai/AiChatPage.tsx | 7 +++- ...Page.publishAdvisoryReachesAuthor.test.tsx | 35 +++++++++++++++++++ ...usePublishAllDrafts.refusal-11922.test.tsx | 19 ++++++++++ .../src/preview/usePublishAllDrafts.ts | 6 +++- ...PackagesPage.publishRefusal-11922.test.tsx | 18 ++++++++++ .../src/views/metadata-admin/PackagesPage.tsx | 10 +++++- ...oDesignSurface.publishCount-11807.test.tsx | 19 ++++++++++ .../studio-design/StudioDesignSurface.tsx | 8 ++++- 8 files changed, 118 insertions(+), 4 deletions(-) diff --git a/ui/packages/app-shell/src/console/ai/AiChatPage.tsx b/ui/packages/app-shell/src/console/ai/AiChatPage.tsx index 9295a180415..e7c426e2a6f 100644 --- a/ui/packages/app-shell/src/console/ai/AiChatPage.tsx +++ b/ui/packages/app-shell/src/console/ai/AiChatPage.tsx @@ -3044,6 +3044,7 @@ export function ChatPane({ const payload = (await metadataClient.publishPackageDrafts(packageId)) as | (Record & { success?: boolean; + outcome?: string; error?: { message?: string }; failedCount?: number; failed?: PublishFailure[]; @@ -3053,7 +3054,11 @@ export function ChatPane({ // A non-2xx now throws inside the client with the server's own // message, caught below like any other failure. What is left here // is the 2xx batch verdict. - if (payload?.success === false) { + // objectstack#33277 — `published_unregistered` answers `success: + // false` over drafts that DID land (the registry refused an object, + // whose warning the client has already reported): not a failure + // here, as it was not while the server answered `published`. + if (payload?.success === false && payload?.outcome !== 'published_unregistered') { // The status is no longer in hand — a non-2xx threw above — so // the last rung is a sentence rather than "HTTP 200". throw new Error( diff --git a/ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.publishAdvisoryReachesAuthor.test.tsx b/ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.publishAdvisoryReachesAuthor.test.tsx index 295fc56dfd1..691e7458802 100644 --- a/ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.publishAdvisoryReachesAuthor.test.tsx +++ b/ui/packages/app-shell/src/console/ai/__tests__/AiChatPage.publishAdvisoryReachesAuthor.test.tsx @@ -245,4 +245,39 @@ describe('AiChatPage — the server’s advisory reaches the author (objectui#10 await waitFor(() => expect(publishResult).toMatchObject({ ok: true })); expect(toast.warning).not.toHaveBeenCalled(); }); + + // objectstack#33277 — the registry refused the object of a batch that + // landed: the batch answers `published_unregistered` with `success: false`, + // and the object's element carries the `object-registry-refused` warning. + // The author reads that warning and the card its published verdict, as they + // did while the server answered `published` for this, never "Publish failed". + it('a published_unregistered batch still reaches the author as its warning, not as a failure', async () => { + const refused = { + severity: 'warning' as const, + rule: 'object-registry-refused', + where: 'object "ticket"', + path: '', + message: "object 'ticket' was published, but the runtime registry refused it, so it is NOT served", + hint: 'Resolve the registry\'s refusal, then publish the object again, or restart the server.', + }; + batchBody = { + success: true, + data: { + success: false, + outcome: 'published_unregistered', + publishedCount: 1, + failedCount: 0, + published: [{ type: 'object', name: 'ticket', advisories: [refused] }], + failed: [], + unregistered: [{ type: 'object', name: 'ticket', rule: 'object-registry-refused' }], + }, + }; + await publishFromAChatCard(); + + await waitFor(() => expect(publishResult).toMatchObject({ ok: true })); + await waitFor(() => expect(toast.warning).toHaveBeenCalled()); + const [, options] = vi.mocked(toast.warning).mock.calls[0] as [string, { description?: string } | undefined]; + expect(options?.description).toContain(refused.rule); + expect(toast.error).not.toHaveBeenCalled(); + }); }); diff --git a/ui/packages/app-shell/src/preview/__tests__/usePublishAllDrafts.refusal-11922.test.tsx b/ui/packages/app-shell/src/preview/__tests__/usePublishAllDrafts.refusal-11922.test.tsx index e4cec4b6554..f0b698f8f4f 100644 --- a/ui/packages/app-shell/src/preview/__tests__/usePublishAllDrafts.refusal-11922.test.tsx +++ b/ui/packages/app-shell/src/preview/__tests__/usePublishAllDrafts.refusal-11922.test.tsx @@ -177,4 +177,23 @@ describe('control: a published batch reads as before (objectui#11922)', () => { expect(calls(toast.success)).toEqual(['home.pendingDrafts.publishedVerified:3']); expect(calls(toast.error)).toEqual([]); }); + + // objectstack#33277 — the registry refused an object of a batch that landed: + // `success` is false and `failed[]` empty. The hook reads it as it read the + // `published` answer the server gave for this before, not as a failure. + it('a published_unregistered batch reads as published, not as a failure', async () => { + batchBody = batch({ + outcome: 'published_unregistered', + publishedCount: 1, + failedCount: 0, + published: [{ type: 'view', name: 'lead_list', version: 'sha256:0' }], + failed: [], + unregistered: [{ type: 'object', name: 'lead', rule: 'object-registry-refused' }], + }); + const outcome = await publishAll(); + expect(outcome).toEqual({ ok: true, attempted: 2 }); + expect(posts).toHaveLength(2); + expect(calls(toast.error)).toEqual([]); + expect(calls(toast.success)).toEqual(['home.pendingDrafts.published']); + }); }); diff --git a/ui/packages/app-shell/src/preview/usePublishAllDrafts.ts b/ui/packages/app-shell/src/preview/usePublishAllDrafts.ts index dabcec7fa8d..011b5e19461 100644 --- a/ui/packages/app-shell/src/preview/usePublishAllDrafts.ts +++ b/ui/packages/app-shell/src/preview/usePublishAllDrafts.ts @@ -110,7 +110,11 @@ export function usePublishAllDrafts(t: TranslateFn) { // refusal answers both, and only `failed[]` says which item and why. const failed = Array.isArray(payload.failed) ? payload.failed : []; if (failed.length > 0) throw new Error(refusedItemsText(failed)); - if ((payload as { success?: boolean }).success === false) { + // objectstack#33277 — `published_unregistered` answers `success: false` + // over drafts that DID land (the registry refused an object, whose + // warning the client has already reported): not a failure here, as it + // was not while the server answered `published` for it. + if ((payload as { success?: boolean }).success === false && payload.outcome !== 'published_unregistered') { const error = (payload as { error?: { message?: string } }).error; throw new Error(error?.message || 'publish-drafts did not publish this package'); } diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.publishRefusal-11922.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.publishRefusal-11922.test.tsx index dbff2a4f053..2a8f38ffd12 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.publishRefusal-11922.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.publishRefusal-11922.test.tsx @@ -180,6 +180,24 @@ describe('controls: the answers that are not a refusal read as before (objectui# expect(await publishAndRead((text) => text === ok)).toBe(ok); }); + // objectstack#33277 — the registry refused an object of a batch that landed: + // `success` is false, nothing is in `failed[]`, and the object's warning + // rides its element. The sheet keeps the success row it showed while the + // server answered `published` for this, not "Action failed". + it('a published_unregistered batch keeps the success row', async () => { + batchBody = batch({ + outcome: 'published_unregistered', + publishedCount: 2, + failedCount: 0, + published: DRAFTS.map((d, i) => ({ ...d, version: `sha256:${i}` })), + failed: [], + unregistered: [{ type: 'object', name: 'lead', rule: 'object-registry-refused' }], + }); + const ok = t('engine.packages.detail.publishDraftsOk', 'en'); + expect(await publishAndRead((text) => text === ok)).toBe(ok); + expect(screen.queryByText(t('engine.packages.detail.actionFailed', 'en'))).toBeNull(); + }); + it('a batch whose envelope carries an error and an empty failed[] still shows the envelope’s text', async () => { const message = 'Publishing is temporarily unavailable. Nothing was changed.'; batchBody = batch({ diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx index 2997dda93be..afc0aab5c64 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.tsx @@ -759,7 +759,15 @@ export function PackageDetailSheet({ // where its items and reasons are. Asked in the other order, every // refusal reached the author as "Action failed". const failedList = Array.isArray(r.failed) ? r.failed : []; - if (failedList.length === 0 && (r as { success?: boolean }).success === false) { + // objectstack#33277 — except `published_unregistered`: its drafts DID + // land (the registry refused an object, whose warning the client has + // already reported), so it keeps the success row it had while the + // server answered `published` for it. + if ( + failedList.length === 0 && + (r as { success?: boolean }).success === false && + r.outcome !== 'published_unregistered' + ) { // Preserves what `apiJson` did for this call: a batch that did not // publish is an error on this surface, read through the same // envelope ladder. The status is no longer in hand — a non-2xx diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx index df6f269af66..1c262fcd33d 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx @@ -198,6 +198,25 @@ describe('the package publish names how many items went live, and what was refus expect(toasts().success).toEqual([tFormat('engine.studio.publishedAllCountOne', 'en', { count: 1 })]); }); + // objectstack#33277 — the registry refused an object of a batch that landed: + // `success` is false and `failed[]` empty. Studio names the count, as it did + // while the server answered `published` for this (the object's warning rides + // its element and reaches the author through the client), never "Action failed". + it('a published_unregistered batch: the count row, not a failure', async () => { + batchBody = batch({ + outcome: 'published_unregistered', + publishedCount: 2, + failedCount: 0, + published: published('repairs_repair_ticket', 'visit'), + failed: [], + unregistered: [{ type: 'object', name: 'visit', rule: 'object-registry-refused' }], + }); + await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1); + await waitFor(() => expect(toast.success).toHaveBeenCalled()); + expect(toasts().success).toEqual([tFormat('engine.studio.publishedAllCount', 'en', { count: 2 })]); + expect(toasts().error).toEqual([]); + }); + it('nothing to publish: said as such, neither a success nor a failure', async () => { batchBody = batch({ outcome: 'nothing_to_publish', publishedCount: 0, failedCount: 0, published: [], failed: [] }); await publishAt(`/studio/${PACKAGE_ID}/interfaces`, 1); diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx index b66f6816ef7..03687b1d6b8 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.tsx @@ -1111,7 +1111,13 @@ function StudioDesignSurfaceBody({ aiSlot, area }: StudioDesignSurfaceProps): Re // the dispatcher's envelope and so hands back the batch's own // `success`), every refusal reached the author as "Action failed". await keepRefusals(failed); - } else if (payload?.success === false) { + } else if (payload?.success === false && payload?.outcome !== 'published_unregistered') { + // objectstack#33277 — `published_unregistered` answers `success: false` + // over drafts that DID land: the registry refused an object, and that + // object's `published[]` element carries the warning the client has + // already reported. It reads as the published branch below, as it did + // while the server answered `published` for it. + // // The status is no longer in hand — a non-2xx threw above — so the // last rung is a sentence rather than "HTTP 200". throw Object.assign( From 113de5f651def04a41ee0b4d2175387b6711db66 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 21:38:35 +0000 Subject: [PATCH 3/7] chore(changeset): name app-shell in the 33277 changeset Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- .changeset/33277-publish-drafts-published-unregistered.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/.changeset/33277-publish-drafts-published-unregistered.md b/.changeset/33277-publish-drafts-published-unregistered.md index 6d6e47842f9..d536093b91d 100644 --- a/.changeset/33277-publish-drafts-published-unregistered.md +++ b/.changeset/33277-publish-drafts-published-unregistered.md @@ -3,6 +3,7 @@ '@objectstack/metadata-protocol': patch '@objectstack/runtime': patch '@objectstack/client': patch +'@object-ui/app-shell': patch --- feat(metadata-protocol, spec): a package publish whose runtime registry refused an object answers `published_unregistered` and names the object, instead of `published` @@ -18,4 +19,6 @@ Metadata-protocol: none **What to do.** Handle the new value wherever you branch on the batch publish answer. Do not treat it as "nothing landed": the metadata is live. Do not seed or read an object `unregistered[]` names until it is registered: publish it again, which re-runs the registration, or restart, which registers every stored object. +**The console.** Studio's publish, the package sheet, Home's *Publish all* and the AI chat card read `published_unregistered` as they read the `published` answer the server gave for this before: the refused object's warning reaches the author through the client, and none of them reports the publish as failed. + **Unchanged on purpose.** The REST door's app visibility flip (ADR-0045 §3) still runs after this outcome, as it ran after the `published` answer this used to be. The single-item doors (`publishMetaItem`, a publish-mode save) still answer success with the warning on their `advisories`. From e101b6902c9df59ba080aa1cc902a56da8bb6cb0 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 23:12:18 +0000 Subject: [PATCH 4/7] chore(spec): regenerate the reference, authorable surface and strictness counts for unregistered[] Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- content/docs/references/api/protocol.mdx | 13 +++++++++++-- .../api.md | 2 +- packages/spec/authorable-surface/api.json | 1 + 3 files changed, 13 insertions(+), 3 deletions(-) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 4c9f2a86416..4251f21e762 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -2624,12 +2624,13 @@ The authoring surface of a metadata write. Closed: `copilot` is an AI assistant' | Property | Type | Required | Description | | :--- | :--- | :--- | :--- | -| **success** | `boolean` | ✅ | True only when every pending draft promoted (`failed` empty) AND at least one item published. A pre-flight refusal or an ADR-0067 D2 rollback answers false on a 200 — but so does a publish with nothing to promote, so false alone is NOT a refusal: read `outcome`, not this boolean or the HTTP status. Always equal to `outcome === 'published'` (pinned). It does NOT cover the best-effort receipts below, each of which reports its own `success`. | -| **outcome** | `Enum<'published' \| 'refused' \| 'nothing_to_publish'>` | ✅ | First-class discriminant for WHICH exit answered — the fact `success` compresses into one boolean. `published`: at least one draft promoted and none refused. `refused`: the batch was refused — a pre-flight violation or the ADR-0067 D2 all-or-nothing rollback; the per-item story is in `failed[]`, which is non-empty exactly on this outcome (the invariant consumers previously had to reverse-engineer, now stated by the producer). `nothing_to_publish`: the package had no pending drafts — nothing landed AND nothing was refused; `success` stays false (a no-op is not a successful publish), which before this field made that answer indistinguishable from a refusal. Producer invariants, pinned in the conformance suites: `success === (outcome === 'published')`; `refused` if and only if `failed.length > 0`; `nothing_to_publish` if and only if `published.length === 0 && failed.length === 0`. Values are lowercase snake, matching the `sys_metadata_audit` outcome vocabulary. | +| **success** | `boolean` | ✅ | True only when every pending draft promoted (`failed` empty) AND at least one item published. A pre-flight refusal or an ADR-0067 D2 rollback answers false on a 200 — but so does a publish with nothing to promote, so false alone is NOT a refusal: read `outcome`, not this boolean or the HTTP status. Always equal to `outcome === 'published'` (pinned), so it is also false on `published_unregistered`, where the drafts landed but an object is not served. It does NOT cover the best-effort receipts below, each of which reports its own `success`. | +| **outcome** | `Enum<'published' \| 'published_unregistered' \| 'refused' \| 'nothing_to_publish'>` | ✅ | First-class discriminant for WHICH exit answered — the fact `success` compresses into one boolean. `published`: at least one draft promoted, none refused, and the runtime registry took every promoted object. `published_unregistered`: the drafts landed exactly as on `published` — the metadata is live and stays live — but the runtime registry refused at least one promoted object, so that object is not served: until something registers it, data reads, writes and seed loads against it answer OBJECT_NOT_FOUND. `unregistered[]` names each such object; do not seed or read it before it is registered (publish it again, or restart). `refused`: the batch was refused — a pre-flight violation or the ADR-0067 D2 all-or-nothing rollback; the per-item story is in `failed[]`, which is non-empty exactly on this outcome (the invariant consumers previously had to reverse-engineer, now stated by the producer). `nothing_to_publish`: the package had no pending drafts — nothing landed AND nothing was refused; `success` stays false (a no-op is not a successful publish), which before this field made that answer indistinguishable from a refusal. Producer invariants, pinned in the conformance suites: `success === (outcome === 'published')`; `refused` if and only if `failed.length > 0`; `nothing_to_publish` if and only if `published.length === 0 && failed.length === 0`; `published_unregistered` if and only if `unregistered` is present. Values are lowercase snake, matching the `sys_metadata_audit` outcome vocabulary. | | **publishedCount** | `integer` | ✅ | Number of drafts promoted to active — `published.length`. 0 on every refusal path (the batch is all-or-nothing, ADR-0067 D2). | | **failedCount** | `integer` | ✅ | Number of items that did not publish — `failed.length`. On a rollback this counts the WHOLE batch: the causal item plus every sibling marked BATCH_ABORTED. | | **published** | `{ type: string; name: string; version: string; advisories?: object[] }[]` | ✅ | Every draft promoted to active, in publish order. Empty on every refusal path. | | **failed** | `{ type: string; name: string; error: string; code?: string; … }[]` | ✅ | Items that did not publish. Because the batch is all-or-nothing (ADR-0067 D2), a non-empty list means NOTHING landed: `published: []`, `publishedCount: 0`. | +| **unregistered** | `{ type: string; name: string; rule: Enum<'object-registry-refused'> }[]` | optional | Present ONLY on `outcome: 'published_unregistered'`, and then non-empty: each promoted object the runtime registry refused, in publish order. Every entry also appears in `published[]` — its metadata IS live, nothing was rolled back (ADR-0067 D2 runs the registration after the metadata commit) — but the object is not served until something registers it, so a caller about to seed or read it should publish it again or restart first. Absent on every other outcome; an empty array is never emitted. | | **seedApplied** | `{ success: boolean; inserted?: integer; updated?: integer; error?: string; … }` | optional | Aggregate outcome of materializing EVERY published `seed` body in one multi-pass loader run (cross-seed references need the whole set). Present ONLY when the batch published at least one seed. Two producers, one key: the batch itself self-applies (`applySeedBodies`), and the REST door back-fills the same key for custom protocols that do not — never both (an externalId-less seed would double-insert). Best-effort: a seed problem is surfaced here, never thrown. | | **materializeApplied** | `{ success: boolean; inserted: integer; updated: integer; failures: object[] }` | optional | ADR-0086 P2 — aggregate result of publish-time materializers across the batch (e.g. `flow`, whose draft credentials become the live ones), including side-effect failures surfaced by the per-item effects loop. Present ONLY when at least one published item had a registered materializer or a side-effect failure. Best-effort, same contract as `seedApplied`. | | **probes** | `any` | optional | ADR-0038 L3 post-publish runtime probe report — one real read per published artifact (seeded objects have rows, views are readable, widget dataset selections execute). DELIBERATELY OPAQUE in this contract: the key is declared and carried through verbatim, but its inner shape is intentionally not modeled until a consumer needs a field of it. Present only when something was publishable; probes never fail the publish. | @@ -2658,6 +2659,14 @@ The authoring surface of a metadata write. Closed: `copilot` is an AI assistant' | **code** | `string` | optional | Machine code for the refusal class (SCREAMING_SNAKE, ADR-0112 vocabulary) — e.g. a pre-flight violation code, or BATCH_ABORTED on the non-causal items of a rolled-back batch. | | **issues** | `{ rule: string; path: string; where: string; message: string; … }[]` | optional | The structured findings behind the refusal, when the refusing error carried them — today the author-time gate's INVALID_METADATA refusal on the causal item. The producer has emitted this key; declaring it is what lets a typed consumer read it back, and what lets `error` stay a headline without losing the per-path detail. Same element shape as `published[].advisories` and the single-item 422's `issues[]` (— one dialect, declared once). Present ONLY on the causal item and only when the refusal produced structured findings; BATCH_ABORTED siblings never carry it. Absent means "this refusal carried no structured findings", never "no problems". | +### Nested Shape: `PublishPackageDraftsResponse.unregistered[number]` + +| Property | Type | Required | Description | +| :--- | :--- | :--- | :--- | +| **type** | `string` | ✅ | Metadata type of the published item the registry refused (`object`). | +| **name** | `string` | ✅ | Name of the object that is published but not served. | +| **rule** | `Enum<'object-registry-refused'>` | ✅ | Why it is not served, as a stable rule id: the same id as the warning on this object's `published[]` element, whose `message` and `hint` say what happened and how to fix it. | + ### Nested Shape: `PublishPackageDraftsResponse.seedApplied` | Property | Type | Required | Description | diff --git a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md index a764782fbf3..0db232128e9 100644 --- a/docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md +++ b/docs/audits/2026-07-unknown-key-strictness-ledger.counts/api.md @@ -19,4 +19,4 @@ hand-patch a number here** — fix the code or the verdict and regenerate. | Dir | Sites | |---|---| -| `api/` | 507 | +| `api/` | 508 | diff --git a/packages/spec/authorable-surface/api.json b/packages/spec/authorable-surface/api.json index 2cd44225745..015fd3aa159 100644 --- a/packages/spec/authorable-surface/api.json +++ b/packages/spec/authorable-surface/api.json @@ -1466,6 +1466,7 @@ "api/PublishPackageDraftsResponse:success", "api/PublishPackageDraftsResponse:unhiddenApps", "api/PublishPackageDraftsResponse:unhideError", + "api/PublishPackageDraftsResponse:unregistered", "api/PushDeliveryData:notificationId", "api/PushDeliveryData:origin", "api/PushDeliveryData:route", From 28691d1fedf1fe1325f397c02fbb03b885b15650 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 23:33:16 +0000 Subject: [PATCH 5/7] chore(spec): regenerate the reference and authorable surface over the merge Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- content/docs/references/api/protocol.mdx | 2 ++ packages/spec/authorable-surface/api.json | 2 ++ 2 files changed, 4 insertions(+) diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 4251f21e762..1a0cc58beff 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -2538,6 +2538,7 @@ The authoring surface of a metadata write. Closed: `copilot` is an AI assistant' | **message** | `string` | optional | Optional human-readable note recorded with the publish history event. | | **packageId** | `string \| null` | optional | ADR-0048 — the software package the draft being promoted was listed under, when the caller has one to state (`?package=` on the REST door). Named, the publish promotes that package's draft and no other. ABSENT names no package: the publish promotes the draft a draft save that names no package writes — the draft of the one package the item's active rows are bound to, else its package-unbound draft, promoted into that package — and answers `404 NO_DRAFT` when neither exists, as the strict draft read does. For an item never published into a package it is the package-unbound draft, else the one package's draft. It is refused `409 RESOURCE_CONFLICT` when the active rows (or, with none and no package-unbound draft, the drafts) are bound to two or more packages. ⚠️ `null` is NOT the same as absent: the implementation branches on the KEY BEING PRESENT, and `null` pins the lookup to the package-UNBOUND row. Spread it in conditionally; a present-and-`undefined` key coerces to `null` downstream and makes a package-bound draft unfindable — a silent `no_draft`. | | **member** | `string` | optional | Bundle member selector, for a metadata type whose identity is a pair (today only `email_template`, identified by `(name, locale)`): the member this request addresses, spelled as its discriminator value (`zh-CN`). Absent, the canonical member (`en-US` for `email_template`), which is what a bare-name read answers; naming the canonical value is the same request. It is not the response translation locale, which `?locale=` and `Accept-Language` choose. Refused with 400 `VALIDATION_ERROR` on a type that has no members, and for a blank value or one longer than a stored member can be (100 characters). A well-formed member with nothing stored or shipped answers as that door answers an absent item. | +| **userTextLocales** | `string[]` | optional | The locales the user-facing sentences of this write's findings (`advisories[].userMessage`, and `issues[].userMessage` on its 422) are composed in, in ladder order: the locale the request names, then the workspace default. Each is read against the platform locale table, whole and then one subtag shorter at a time; a value that names no table language is passed over, and `en` is the last rung. Stated by the door that holds the request (the REST door and the dispatcher state `[ExecutionContext.locale, ExecutionContext.workspaceLocale]`), never read from a wire body. ABSENT ⇒ the sentences are composed in `en`. It selects a language only: what is judged, refused or saved does not depend on it. | --- @@ -2917,6 +2918,7 @@ Answer to a device registration: the device id the client keeps | **writeFace** | `Enum<'package-duplicate' \| 'meta-envelope' \| 'meta-dispatch' \| 'external-import'>` | optional | Which write door a refusal is being rendered FOR — stated by the SERVER, never by a remote caller: every door builds this request field by field and never spreads a request body into it, so there is no path for a client to smuggle a face in, and a face arriving in a wire body is simply never read. Two refusals branch on it, for different questions: the 409 destructive-change remedy names the acknowledgement mechanism that actually exists on the refusing door (`?force=true` on the REST doors; the dispatcher, the duplicate-package door and the external-table import have none), and the 422 invalid-metadata message adapts to whether a structured `issues[]` channel reaches the consumer beside it. Absent = the conservative default wording. | | **surface** | `Enum<'copilot' \| 'mcp' \| 'studio' \| 'api'>` | optional | The authoring surface this save is made through (see `MetadataAuthoringSurfaceSchema`). A draft save (`mode: 'draft'`) stamps it as `by` on every key path it changes, the entries the strict draft read serves as `draftChanges`; an active save records no per-key provenance. ABSENT stamps `api`. On the REST door and the runtime dispatcher it is the `?surface=` query parameter, which takes `studio` or `api` and refuses every other value `400 VALIDATION_ERROR`, `copilot` and `mcp` included: `copilot` is stated only by an in-process AI tool calling the save and `mcp` only by the MCP build door after it verified the client's token, never by a remote caller, so an HTTP request cannot mark its own write as the copilot's or an MCP agent's. A value outside the set in-process is refused `400 INVALID_REQUEST`, before anything is written. | | **client** | `{ id: string; name?: string }` | optional | The OAuth client this save is made by (see `MetadataAuthoringClientSchema`), stated only by the MCP build door, in-process, from the token it verified. Only with `surface: 'mcp'`: a `client` beside any other surface, or a malformed one, is refused `400 INVALID_REQUEST` before anything is written. A draft save stamps it as `client` beside `by: 'mcp'` on every key path it changes; an active save records it nowhere. No HTTP door reads it: the REST door and the dispatcher build this request member by member, so a `client` in a wire body or query is never read. | +| **userTextLocales** | `string[]` | optional | The locales the user-facing sentences of this write's findings (`advisories[].userMessage`, and `issues[].userMessage` on its 422) are composed in, in ladder order: the locale the request names, then the workspace default. Each is read against the platform locale table, whole and then one subtag shorter at a time; a value that names no table language is passed over, and `en` is the last rung. Stated by the door that holds the request (the REST door and the dispatcher state `[ExecutionContext.locale, ExecutionContext.workspaceLocale]`), never read from a wire body. ABSENT ⇒ the sentences are composed in `en`. It selects a language only: what is judged, refused or saved does not depend on it. | ### Nested Shape: `SaveMetaItemRequest.client` diff --git a/packages/spec/authorable-surface/api.json b/packages/spec/authorable-surface/api.json index 015fd3aa159..5430bf051fe 100644 --- a/packages/spec/authorable-surface/api.json +++ b/packages/spec/authorable-surface/api.json @@ -1442,6 +1442,7 @@ "api/PublishMetaItemRequest:name", "api/PublishMetaItemRequest:packageId", "api/PublishMetaItemRequest:type", + "api/PublishMetaItemRequest:userTextLocales", "api/PublishMetaItemResponse:advisories", "api/PublishMetaItemResponse:materializeApplied", "api/PublishMetaItemResponse:message", @@ -1771,6 +1772,7 @@ "api/SaveMetaItemRequest:parentVersion", "api/SaveMetaItemRequest:surface", "api/SaveMetaItemRequest:type", + "api/SaveMetaItemRequest:userTextLocales", "api/SaveMetaItemRequest:writeFace", "api/SaveMetaItemResponse:advisories", "api/SaveMetaItemResponse:message", From 719d31d01cb14b9b721e5ed6d37b1b613845d261 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 23:47:50 +0000 Subject: [PATCH 6/7] chore(spec): declare the publish-drafts outcome change as semantic, spec minor Contract review of the publish-drafts outcome change: the authorable surface gained PublishPackageDraftsResponse:unregistered and the same event answers outcome/success differently, so the declaration is semantic and spec is minor. The two status-quo choices now cite that review instead of a pending ruling. Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- .changeset/33277-publish-drafts-published-unregistered.md | 6 ++++-- packages/runtime/src/domains/packages.ts | 7 ++++--- packages/runtime/src/http-dispatcher.test.ts | 2 +- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.changeset/33277-publish-drafts-published-unregistered.md b/.changeset/33277-publish-drafts-published-unregistered.md index d536093b91d..c9e6eaa8f4a 100644 --- a/.changeset/33277-publish-drafts-published-unregistered.md +++ b/.changeset/33277-publish-drafts-published-unregistered.md @@ -1,5 +1,5 @@ --- -'@objectstack/spec': patch +'@objectstack/spec': minor '@objectstack/metadata-protocol': patch '@objectstack/runtime': patch '@objectstack/client': patch @@ -9,7 +9,9 @@ feat(metadata-protocol, spec): a package publish whose runtime registry refused an object answers `published_unregistered` and names the object, instead of `published` Clause-②: yes (widening) — `PublishPackageDraftsResponseSchema.outcome` gains the value `published_unregistered`, and the response gains the optional member `unregistered[]`. Every other answer is byte-identical: a publish the registry takes whole still answers `published` with `success: true` and no `unregistered` key. -Metadata-protocol: none +Metadata-protocol: semantic + +The authorable-surface shard gains `api/PublishPackageDraftsResponse:unregistered`, and the same server event answers `outcome` / `success` differently; ADR-0087 entry `18.publish-drafts-outcome-published-unregistered`. **What answers differently.** `POST /api/v1/packages/:id/publish-drafts` (and the protocol's `publishPackageDrafts`, and `client.packages.publishDrafts()`) used to answer `outcome: 'published'` and `success: true` when the runtime registry refused one of the objects it had just made live. The object carried the `object-registry-refused` warning on its `published[]` element, but a caller that read `success` or `outcome` saw a clean publish, and a seed load or data read right after it answered `OBJECT_NOT_FOUND`. The same publish now answers: diff --git a/packages/runtime/src/domains/packages.ts b/packages/runtime/src/domains/packages.ts index b0546f6c1fb..8fe0ce29479 100644 --- a/packages/runtime/src/domains/packages.ts +++ b/packages/runtime/src/domains/packages.ts @@ -650,9 +650,10 @@ function packageIsUnknown(registry: unknown, id: string): boolean { * - `published` — the drafts landed; the package is live and becomes visible. * - `published_unregistered` — the drafts landed exactly as on `published`, * but the runtime registry refused an object among them (#33277), which - * `unregistered[]` names. Kept in the list on purpose, pending a ruling: this - * answer used to read `published`, so the flip ran on it, and dropping it - * would change visibility beyond what the outcome change was asked to do. + * `unregistered[]` names. Kept in the list on purpose (contract review of + * PR #33528): the drafts are live, the flip concerns the package's apps, and + * dropping it would hide the parts that are served while the refused object + * stays unserved either way. * - `nothing_to_publish` — kept on purpose: for a materialized (additive) * build there are no drafts, and this flip IS the publish (ADR-0045 §3). * diff --git a/packages/runtime/src/http-dispatcher.test.ts b/packages/runtime/src/http-dispatcher.test.ts index 5168e29d9e3..8e227a57ff9 100644 --- a/packages/runtime/src/http-dispatcher.test.ts +++ b/packages/runtime/src/http-dispatcher.test.ts @@ -2505,7 +2505,7 @@ describe('HttpDispatcher', () => { // #33277 — a batch whose drafts landed while the registry refused an // object answers `published_unregistered`; it used to answer - // `published`, and the flip keeps following it until ruled otherwise. + // `published`, and the flip keeps following it (contract review of PR #33528). it('POST /packages/:id/publish-drafts still runs the visibility flip after published_unregistered', async () => { const { getMetaItems, saveMetaItem, trigger } = flipDoubles({ success: false, outcome: 'published_unregistered', publishedCount: 1, failedCount: 0, From 85137fb0e84f3d42845f2a4799a15520bc0902d1 Mon Sep 17 00:00:00 2001 From: Claude Date: Sat, 14 Nov 2026 23:54:30 +0000 Subject: [PATCH 7/7] test(app-shell): pay the lint and formula first load at collection in the publish-outcome tests Co-Authored-By: Claude Claude-Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn --- .../__tests__/usePublishAllDrafts.refusal-11922.test.tsx | 4 ++++ .../PackagesPage.publishRefusal-11922.test.tsx | 5 +++++ .../StudioDesignSurface.publishCount-11807.test.tsx | 4 ++++ 3 files changed, 13 insertions(+) diff --git a/ui/packages/app-shell/src/preview/__tests__/usePublishAllDrafts.refusal-11922.test.tsx b/ui/packages/app-shell/src/preview/__tests__/usePublishAllDrafts.refusal-11922.test.tsx index f0b698f8f4f..31f1fd74dc7 100644 --- a/ui/packages/app-shell/src/preview/__tests__/usePublishAllDrafts.refusal-11922.test.tsx +++ b/ui/packages/app-shell/src/preview/__tests__/usePublishAllDrafts.refusal-11922.test.tsx @@ -39,6 +39,10 @@ vi.mock('sonner', () => ({ })); import { toast } from 'sonner'; +// The source under test reaches `@objectstack/lint` through a dynamic import; its +// first load is paid here, at collection, never inside a case's clock +// (`check:test-source-alias`). +import '@objectstack/lint'; import { usePublishAllDrafts } from '../usePublishAllDrafts'; const PKG_ID = 'com.acme.crm'; diff --git a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.publishRefusal-11922.test.tsx b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.publishRefusal-11922.test.tsx index 2a8f38ffd12..8a91d27103b 100644 --- a/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.publishRefusal-11922.test.tsx +++ b/ui/packages/app-shell/src/views/metadata-admin/PackagesPage.publishRefusal-11922.test.tsx @@ -32,6 +32,11 @@ import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'; import { cleanup, fireEvent, render, screen, waitFor } from '@testing-library/react'; import { MemoryRouter } from 'react-router-dom'; +// The source under test reaches `@objectstack/formula` and `@objectstack/lint` through a dynamic import; its +// first load is paid here, at collection, never inside a case's clock +// (`check:test-source-alias`). +import '@objectstack/formula'; +import '@objectstack/lint'; import { PackageDetailSheet, type InstalledPackageRow } from './PackagesPage'; import { t, tFormat } from './i18n'; diff --git a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx index 1c262fcd33d..59ebc5357f2 100644 --- a/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx +++ b/ui/packages/app-shell/src/views/studio-design/StudioDesignSurface.publishCount-11807.test.tsx @@ -79,6 +79,10 @@ vi.mock('../../preview/DraftChangesPanel', () => ({ })); import { toast } from 'sonner'; +// The source under test reaches `@objectstack/lint` through a dynamic import; its +// first load is paid here, at collection, never inside a case's clock +// (`check:test-source-alias`). +import '@objectstack/lint'; import { StudioDesignSurface } from './StudioDesignSurface'; import { t, tFormat } from '../metadata-admin/i18n';