diff --git a/.changeset/33277-publish-drafts-published-unregistered.md b/.changeset/33277-publish-drafts-published-unregistered.md new file mode 100644 index 00000000000..c9e6eaa8f4a --- /dev/null +++ b/.changeset/33277-publish-drafts-published-unregistered.md @@ -0,0 +1,26 @@ +--- +'@objectstack/spec': minor +'@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` + +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: 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: + +- `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. + +**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`. diff --git a/content/docs/references/api/protocol.mdx b/content/docs/references/api/protocol.mdx index 9673a02d599..1a0cc58beff 100644 --- a/content/docs/references/api/protocol.mdx +++ b/content/docs/references/api/protocol.mdx @@ -2625,12 +2625,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. | @@ -2659,6 +2660,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/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 8211d011666..2f82d0b0e1c 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} @@ -1540,8 +1540,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<{ @@ -1566,6 +1570,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[] }; /** @@ -2505,6 +2517,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 @@ -2540,7 +2556,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); @@ -2654,20 +2676,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 4dd416df86d..be4b1b474e0 100644 --- a/packages/metadata-protocol/src/protocol-publish-drafts-advisories.test.ts +++ b/packages/metadata-protocol/src/protocol-publish-drafts-advisories.test.ts @@ -509,9 +509,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'; @@ -533,7 +534,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(); @@ -544,9 +545,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')!; @@ -594,3 +595,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 e46a2e7eda5..5aa78f64cb9 100644 --- a/packages/metadata-protocol/src/protocol.ts +++ b/packages/metadata-protocol/src/protocol.ts @@ -10081,8 +10081,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<{ @@ -10107,6 +10111,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 3efcbdd3b24..8fe0ce29479 100644 --- a/packages/runtime/src/domains/packages.ts +++ b/packages/runtime/src/domains/packages.ts @@ -648,6 +648,12 @@ 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 (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). * @@ -659,6 +665,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 12ea4605ff3..8e227a57ff9 100644 --- a/packages/runtime/src/http-dispatcher.test.ts +++ b/packages/runtime/src/http-dispatcher.test.ts @@ -2502,6 +2502,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 (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, + 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/authorable-surface/api.json b/packages/spec/authorable-surface/api.json index 5f43ca93e09..5430bf051fe 100644 --- a/packages/spec/authorable-surface/api.json +++ b/packages/spec/authorable-surface/api.json @@ -1467,6 +1467,7 @@ "api/PublishPackageDraftsResponse:success", "api/PublishPackageDraftsResponse:unhiddenApps", "api/PublishPackageDraftsResponse:unhideError", + "api/PublishPackageDraftsResponse:unregistered", "api/PushDeliveryData:notificationId", "api/PushDeliveryData:origin", "api/PushDeliveryData:route", 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 1a1fcbf5c23..b1e67490963 100644 --- a/packages/spec/src/api/protocol.zod.ts +++ b/packages/spec/src/api/protocol.zod.ts @@ -1798,9 +1798,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). @@ -1812,13 +1813,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, ' @@ -1829,8 +1839,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 ' @@ -1904,6 +1916,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.', +}; 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..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'; @@ -177,4 +181,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..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'; @@ -180,6 +185,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..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'; @@ -198,6 +202,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(