You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Commit 8f9eb3d
Browse filesBrowse the repository at this point in the historyBrowse files
feat(metadata-protocol, spec): a publish whose registry refused an object answers published_unregistered naming it (#33528)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9D75mRNRrsy6GfiJD9q7La4j)_Fixes#33277
Clause-②: yes (widening)
Metadata-protocol: semantic
## 维护者速读
- 改了什么:发布整个应用(publish-drafts)时,如果运行时注册表拒收了某个对象,返回不再说「published」,而是新的
`published_unregistered`(`success: false`),并在 `unregistered[]`
里点名这些对象,沿用 #33005 的规则码 `object-registry-refused`。
- 为什么改:按 #33005 的裁决「D 先告警,A 后续跟上」,这是 A:程序化调用方(托管云的 AI
搭建)以前看到「发布成功」就去灌示例数据,结果报找不到表。
- 风险与回滚:新增枚举值,注册表全部接受时返回逐字节不变;应用可见性翻转和控制台的提示保持现状(待裁决)。回滚即 revert 本 PR。
-
先看:`packages/metadata-protocol/src/protocol-history-and-publish.ts`(outcome
推导)、`packages/runtime/src/domains/packages.ts`(翻转白名单,新值保持翻转)、`packages/spec/src/api/protocol.zod.ts`(契约)。
- 两分钟验证:`pnpm --filter @objectstack/metadata-protocol exec vitest run
src/protocol-publish-drafts-advisories.test.ts`,预期 14 个用例全绿,含 `[#33277]`
四个。
- 需要你做的:裁决两件事——新值是否继续触发应用可见性翻转,以及控制台对它是否继续显示「发布成功」(本 PR 均保持现状)。
## What changes
- **Spec** (`PublishPackageDraftsResponseSchema`): `outcome` gains
`published_unregistered`; the response gains optional `unregistered: [{
type, name, rule: 'object-registry-refused' }]`, present if and only if
the outcome is `published_unregistered`. `success` stays exactly
`outcome === 'published'`, so it is false on the new value. Describes
updated; reference docs, `authorable-surface/api.json` and the
strictness counts regenerated. One ADR-0087 semantic entry for major 18
(`publish-drafts-outcome-published-unregistered`), because a caller
branching on `success` or `outcome` now takes a different branch for the
same server event.
- **Producer** (`publishPackageDrafts`, metadata-protocol): each object
whose registry write-through was refused (the #33005 `registryRefused`
receipt) is collected in publish order; the batch answers
`published_unregistered`, `success: false`, `unregistered[]`. Nothing
else moves: the drafts landed and stay live, every object is still in
`published[]` with its warning, `failed[]` stays empty, and commit,
seeds, probes and receipts are unchanged. Return types in
`protocol-history-and-publish.ts` and `protocol.ts` widened.
- **Runtime flip** (`PUBLISH_OUTCOMES_THAT_FLIP`):
`published_unregistered` is added, so the ADR-0045 visibility flip and
the `metadata:reloaded` announce run exactly as they did when this
answer read `published`. Kept as the status quo pending a ruling
(below).
- **Client SDK**: the `packages.publishDrafts` docblock no longer says
`success: false` on a 200 means nothing landed; it names the three
non-success outcomes.
- **Console** (`ui/packages/app-shell`): Studio's publish, the package
sheet, Home's Publish all and the AI chat card treated every `success:
false` as a failed publish. Each now reads `published_unregistered` as
it read the `published` answer the server gave for this before: the
refused object's `object-registry-refused` warning still reaches the
author through the client's advisory sink, and no caller reports "Action
failed" / "Publish failed" for drafts that landed.
## Tests
- `protocol-publish-drafts-advisories.test.ts` (the shared harness): a
new `[#33277]` describe pins the refused object named in
`unregistered[]` with `published_unregistered` / `success: false` in
both publish orders (refused object first and second), two refused
objects named in publish order, and a CONTROL that a batch the registry
takes whole still answers `published`, `success: true`, with no
`unregistered` key. The #33005 case no longer pins `outcome:
'published'`.
- `packages/spec/src/api/protocol.test.ts`: the new value and key parse
and round-trip; an entry with an unknown rule or no rule is refused; the
vocabulary stays closed.
- `packages/runtime/src/http-dispatcher.test.ts`: the flip still runs
after `published_unregistered` (status-quo pin).
- UI: one case each in `PackagesPage.publishRefusal-11922`,
`usePublishAllDrafts.refusal-11922`,
`AiChatPage.publishAdvisoryReachesAuthor` and
`StudioDesignSurface.publishCount-11807`.
- Ablation (once, on the negative pin, after the fix was committed):
`scripts/ablation-replace.mjs` replaced the `unregistered.push(...)`
line with a no-op (anchor 1 to 0, blob 8035b04 to 78b920f646cd);
the pin file went to 3 failed / 11 passed, exactly the three negative
`[#33277]` cases, CONTROL and the #33005 cases green; restored to blob
8035b04 equal to HEAD, `git diff HEAD` empty. The test imports
`./protocol.js` from `src`, so no rebuild was needed.
## Acceptance notes
- **Open choice 1, the visibility flip.** `published_unregistered` still
flips `_unpublished` apps (status quo: this answer used to read
`published`). Alternative: drop it from the allow-list so an app whose
object is not served stays hidden until a re-publish. Listed for a
ruling; not changed here.
- **Open choice 2, the console's presentation.** The console keeps
showing a successful publish plus the object's warning toast (the
presentation ruled for #33005). Alternative: a distinct "published, but
N objects are not served" message. Listed for a ruling; not changed
here.
- **The card's premise detail:**
`ui/packages/data-objectstack/src/metadata-client.ts` does not switch on
the outcome (it returns a 2xx unexamined and only emits advisories); the
switches are in the four `app-shell` callers above, which this PR
adapts.
- **Hosted cloud (outside this repo):** the AI build path must stop or
retry before seeding on `published_unregistered`, keyed on
`unregistered[]` or the `object-registry-refused` rule. Cloud already
ships a bounded retry for the seed race; it should now branch on the
outcome instead.
- **Not in this card:** the single-item doors (`publishMetaItem`, a
publish-mode save) still answer success with the warning on
`advisories`; the other write-through callers #33005's report listed
stay warn-only.
- Shared files with #33276 (now merged into this branch):
`protocol-history-and-publish.ts`, `protocol.ts`, `protocol.zod.ts`,
`packages.ts`, the advisories test, `http-dispatcher.test.ts`; the merge
was clean and every suite below was re-run on the merged head.
## Verification
Premise measured first, at `origin/main` ba35dfd (producer file
restored from that commit, blob 884d24a): a publish with the
registry refusing `ticket` answered
`{"success":true,"outcome":"published","publishedCount":2,"failedCount":0}`
with `ticket` carrying `object-registry-refused`, in both publish
orders. At this branch:
`{"success":false,"outcome":"published_unregistered",...,"unregistered":[...]}`
in both orders.
<details><summary>Package suites, final head 28691d1 (merged with
origin/main), under os-verify-lock</summary>
- `@objectstack/metadata-protocol` typecheck exit 0 (`tsc
--listFilesOnly` includes the advisories test); `test`: Test Files 340
passed, 9 skipped (349); Tests 22870 passed, 43 skipped.
- `@objectstack/spec` `src/api/protocol.test.ts` + `src/migrations/`:
Test Files 6 passed; Tests 451 passed.
- `@objectstack/runtime` `http-dispatcher.test.ts`,
`packages-publish-drafts-change-note.integration.test.ts`,
`packages-publish-drafts-response-conformance.test.ts`: Test Files 3
passed; Tests 275 passed.
- `@objectstack/objectql`
`publish-package-drafts-response-conformance.test.ts`: 16 passed.
- `@object-ui/app-shell`, the four UI files: Test Files 4 passed; Tests
23 passed.
</details>
<details><summary>Gates (local subset; CI owns the rest)</summary>
Exit 0 at the final head: `check:generated` (all 14 artifacts current),
`check:strictness-ledger`, `check:api-surface` (unchanged),
`check:doc-authoring`, `check-adr-0087-registration` (no breaking
changeset), `check-nul-bytes`. Exit 0 before the merge:
`check:spec-changes`, `check:upgrade-guide`, `check:authorable-surface`,
`check:docs`, `check-changeset-no-major`, `check-empty-changeset`,
`check:durability-log-level`; eslint `--no-inline-config` on the nine
touched package files and eslint on the four UI files (0 errors).
`dispatch-gates --ran`: 12 of 123 derived families run locally, 111 left
to CI by declared narrowing (the verify lock was held 3h20m by another
run).
NOT MEASURED locally: app-shell `type-check` (needs every `@object-ui/*`
dist built; Type Check UI owns it); the `check:test-typecheck` leg of
runtime and client typecheck (their main `tsc --noEmit` passed; the test
layer reported errors in test files this diff does not touch, which
import packages not built here).
</details>
Session: https://claude.ai/code/session_016WV4cy1y7UNVbT2QAdmgdn
🤖 Generated with [Claude Code](https://claude.com/claude-code)
<!-- signed: domain:server#5 · os-elon-musk ·
session_016WV4cy1y7UNVbT2QAdmgdn -->
---------
Co-authored-by: Claude <noreply@anthropic.com>
feat(metadata-protocol, spec): a package publish whose runtime registry refused an object answers `published_unregistered` and names the object, instead of `published`
10
+
11
+
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.
12
+
Metadata-protocol: semantic
13
+
14
+
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`.
15
+
16
+
**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:
17
+
18
+
-`outcome: 'published_unregistered'` and `success: false` (`success` is still exactly `outcome === 'published'`);
19
+
-`unregistered: [{ type: 'object', name, rule: 'object-registry-refused' }]`, one entry per refused object, in publish order;
20
+
- 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.
21
+
22
+
**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.
23
+
24
+
**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.
25
+
26
+
**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`.
Copy file name to clipboardExpand all lines: content/docs/references/api/protocol.mdx
+11-2Lines changed: 11 additions & 2 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -2625,12 +2625,13 @@ The authoring surface of a metadata write. Closed: `copilot` is an AI assistant'
2625
2625
2626
2626
| Property | Type | Required | Description |
2627
2627
| :--- | :--- | :--- | :--- |
2628
-
|**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`. |
2629
-
| **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. |
2628
+
|**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`. |
2629
+
| **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. |
2630
2630
|**publishedCount**|`integer`| ✅ | Number of drafts promoted to active — `published.length`. 0 on every refusal path (the batch is all-or-nothing, ADR-0067 D2). |
2631
2631
|**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. |
2632
2632
|**published**|`{ type: string; name: string; version: string; advisories?: object[] }[]`| ✅ | Every draft promoted to active, in publish order. Empty on every refusal path. |
2633
2633
|**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`. |
2634
+
|**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. |
2634
2635
|**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. |
2635
2636
|**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`. |
2636
2637
|**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'
2659
2660
|**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. |
2660
2661
|**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". |
|**type**|`string`| ✅ | Metadata type of the published item the registry refused (`object`). |
2668
+
|**name**|`string`| ✅ | Name of the object that is published but not served. |
2669
+
|**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. |
0 commit comments