Skip to content

fix(metadata-protocol)!: publish judges an object draft by the current ObjectSchema - #38299

Draft
objectstack-fleet[bot] wants to merge 6 commits into
mainfrom
claude/issue-35924-publish-draft-refinement
Draft

objectstack-fleet[bot] wants to merge 6 commits into
mainfrom
claude/issue-35924-publish-draft-refinement

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Fixes #35924

Clause-②: no
Metadata-protocol: narrowed
Skills-docs: none — every body this refuses at publish is one a save of the same body already refuses; the published skills' procedure (fix what the refusal names, save the item again) is unchanged and is the remedy

维护者速读

  • 用户能看到什么变化:在 Studio 里发布对象草稿时,若草稿是在某条更严格的对象校验规则上线之前保存的,发布现在会像保存一样拒绝它,草稿原样保留;正常草稿照旧发布。
  • 为什么做:替数据域把保存与发布两道门对齐,避免旧草稿绕过新校验规则直接上线(例如封存审计对象缺少组织链列)。
  • 出错会怎样:升级时仍有待发布旧草稿的环境,这些草稿发布会被拒(已标为破坏性变更并写入升级指南);作者按提示修正后重新保存即可;改动可直接撤回,不涉及数据迁移。
  • 要你做什么:无

What changes

ProtocolHistoryAndPublish.promoteDraftForPublish now asks the save door's spec parse of an object draft before repo.promoteDraft writes. This is the one save-door judge the promotion did not re-run. Before this change, an object draft saved before a narrowing ObjectSchema refinement landed went live at publish without that refinement judging it.

  • New module packages/metadata-protocol/src/protocol-promoted-draft-spec-refusal.ts: promotedObjectDraftSpecRefusal(name, body) parses the draft against resolveOverlaySchema('object'), the save door's own resolver (it resolves to getMetadataTypeSchema('object')). It refuses with the save door's envelope: INVALID_METADATA / 422, issues[] from zodIssuesToMetadataIssues(..., { refusalParams: true }), and the save door's default-face sentence (object/NAME failed spec validation: ...).
  • The body judged is the body the publish serves. A stored row is read and registered through the ADR-0087 chain (applyConversionsToStoredItem), so the parse judges convertStoredItemDetailed('object', body).item, not the raw stored bytes. A draft stored in a spelling a later release retired, which the chain converts, still publishes exactly as before. Without this step the fix would falsely refuse such drafts (ablation 2 below shows it).
  • Placement: in the object block of the promotion, after the package-mismatch refusal and before the registry's objectRegistrationRefusal. That is the order the save door uses, so a body both refuse keeps the structured issues[] (元数据保存的 422 也丢掉 union 分支处方:一个 view 保存失败只回一条 path:"" message:"Invalid input",Studio 无字段可高亮 #5364). The block already skips sealed managed items, which the store refuses NOT_OVERRIDABLE anyway. The refusal is thrown before the judgeOnly return, so the judge pass of a package publish on a store that cannot roll back raises it too.
  • scripts/engine-double-contract.pinned.json: three rows recording the new test's engine-double pins, written by node scripts/check-engine-double-contract.mjs --write as the gate prescribes. It adds no other row.
  • .changeset/35924-publish-reparses-object-draft.md: @objectstack/metadata-protocol minor, @objectstack/spec patch, Metadata-protocol: narrowed, a BREAKING banner and a FROM → TO section with the author's fix, and the ADR-0087 disposition registered publish-refuses-object-draft-the-current-schema-refuses.
  • packages/spec/src/migrations/entries/semantic/19.publish-refuses-object-draft-the-current-schema-refuses.ts: the upgrade-guide entry that disposition names. It is notice only: no key is removed and no D2 conversion is added, because the fix is the author's choice. This is the shape of the landed 19.publish-refuses-views-and-dashboards-that-save-and-do-not-work.ts.

Why

The card's Done-when items:

  1. Reach measured once on main. It reproduces. On origin/main at e3bdc748, the harness below saved a valid sealed audit object draft and rewrote its stored row to the pre-ADR-0154-D10 body (no tenant_id chain column, the checksum the store would write). The save door refuses that body 422 INVALID_METADATA. Then:
    • per-item publish answered {"success":true,"version":"hmac-sha256:a77d...","seq":1,"message":"Published draft — type=object, name=crm_ledger [seq=1]"}, and the stored rows became [{"state":"active","package_id":"com.acme.alpha"}];
    • package publish answered {"success":true,"outcome":"published","publishedCount":1,"failedCount":0,...} with the same active row.
  2. The promotion parses an object draft against the current ObjectSchema and refuses with the save door's envelope (422) before repo.promoteDraft writes. Judge-only batches judge it too.
  3. Pins: a pre-refinement draft is refused at publish (per item, per package, and in the judge-only pass), with CONTROLs where a valid draft still publishes.
  4. Declaration: a narrowing, by the seat's ruling below. A pending object draft that published before is refused at publish now.

The card's triage comment (7049063373), verbatim: "Triage: lands in domain:server (metadata publish) · pm:queue; rationale: area:data · Bug · a draft saved before an ObjectSchema refinement landed is promoted at publish without being parsed again; latent for every schema narrowing; no wrong answer measured → p3 as filed · size S." The card has no ruling comment.

Seat ruling — the declaration

The claim carried Metadata-protocol: none. The card's Done-when 4 says: "Declare it as a narrowing if a body that published before is now refused at publish." That condition holds as measured (200 on main, 422 with the fix), so the dev reported the fork rather than shipping it under none. The seat (repo:objectstack#8, session session_017xRBcSAaBEfQpU2yJexSJ8, 2026-11-28T10:00Z) ruled, verbatim: "Q2 = A — narrowed (the card's own Done-when 4 criterion is met as measured)." The declaration lines above, the changeset, the ! in the title and the upgrade-guide entry follow that ruling.

Tests

New file packages/metadata-protocol/src/protocol.publish-draft-schema-reparse.test.ts (9 cases). The harness is the real save, publish and repository paths over a stub engine whose write verbs are held to ObjectQL's own dispatch decisions:

  • PREMISE: the two fixtures straddle the refinement (one parses, the other does not).
  • The save door refuses the pre-refinement body INVALID_METADATA / 422, and nothing is stored.
  • The per-item publish refuses the pre-refinement draft with code: 'INVALID_METADATA' and status: 422. Its lifecycle.seal issues equal the save door's for the same body, and the draft stays a draft.
  • The package publish refuses it into failed[] (outcome: 'refused', code: 'INVALID_METADATA'), and nothing is promoted.
  • The package publish on a store that cannot roll back (judge-only pass) refuses it, and neither it nor a valid sibling draft goes live.
  • CONTROL: a fresh valid draft publishes per item, per package, and per package on a store that cannot roll back.
  • CONTROL: a draft stored with the tombstoned externalSharingModel, which the chain strips (object-external-sharing-model-removed), still publishes.
Run readings (local, at the head named)
  • New file, with the fix: Tests 9 passed (9), lock VERDICT command-exit 0.
  • Package suite at c3c5411f, run as pnpm --filter @objectstack/metadata-protocol exec vitest run --maxWorkers=2 (the following commit only adds three JSON ledger rows): Test Files 373 passed | 9 skipped (382) · Tests 23614 passed | 45 skipped (23659) · VERDICT command-exit 0.
  • pnpm --filter @objectstack/metadata-protocol typecheck: VERDICT command-exit 0. tsc --listFiles lists both new files, so the test is type-checked.
  • Ablation 1 (scripts/ablation-replace.mjs, anchor if (specRefusal) throw specRefusal; deleted; anchor 1 -> 0, blob 9f79c4ba1d1c -> e7959dfad426): Tests 3 failed | 6 passed (9). The three failures are the per-item, package and judge-only refusal pins. The premise, the save-door pin and all four CONTROLs stay green. Restored: blob == HEAD (9f79c4ba1d1c) and git diff HEAD is empty.
  • Ablation 2 (the converted body replaced by the raw stored body, const served = body;; anchor 1 -> 0, blob 3528de18409b -> 0c1293f4f03d): Tests 1 failed | 6 passed (7). The one failure is the legacy-spelling CONTROL. This run is from before the judge-only pins were added. Restored: blob == HEAD (3528de18409b).
  • The subject is imported as ./protocol.js, a relative source specifier, so neither ablation needed a dist/ rebuild.
  • pnpm --filter @objectstack/spec exec vitest run --maxWorkers=2 src/migrations (the new ledger entry): Test Files 5 passed (5) · Tests 207 passed (207) · VERDICT command-exit 0.
  • Dogfood battery at f7534a646 (the title carries !), run as CI runs it: the closure was built with pnpm --workspace-concurrency=2 --filter '@objectstack/dogfood^...' build (VERDICT command-exit 0), then pnpm --filter @objectstack/dogfood test was run under the lock with no shard and no path. Result: Test Files 491 passed | 3 skipped (494) · Tests 4148 passed | 68 skipped (4216) · VERDICT command-exit 0, with no failures. A first attempt is void and not counted: I mis-spelled the concurrency flag, which forwarded --concurrency=2 into the CLI's build script and broke it, so the test step ran against a partial closure. I stopped that run.

Acceptance notes

  • Other types (read only, not measured): the save door parses every type with a registered schema, but the promotion now re-parses only object, the type this card names. Whether every type's stored draft should be re-parsed at promotion is not asked here. The stored-draft populations differ: a flow is judged through storedFlowVerdictBody, and a view stores its parsed projection. carrier: none.
  • File surface: beyond the claimed publish path, co-located test and changeset, the diff writes two more files. (1) The three scripts/engine-double-contract.pinned.json rows the gate requires for any new pinned engine double, generated by the gate's own --write; the diff adds no other row. (2) One file under packages/spec/src/migrations/entries/semantic/, the ledger entry check:adr-0087-registration requires for a declared narrowing, written on the seat's order ("whatever ADR-0087 registration check:adr-0087-registration then demands (ledger entry under semantic/19.*)"). No other file in packages/spec/src/** is touched, and no ObjectSchema refinement.
  • overlap-check.mjs before each push: VERDICT clean exit 0. At the last run it merges cleanly with origin/main (e2a0e9002); an earlier run also showed it merging cleanly with feat(spec)!: retire the ask_ai action type (ADR-0160 D7) #37924, which shares the engine-double ledger file.

Verification

Read first, by risk:

  1. packages/metadata-protocol/src/protocol-promoted-draft-spec-refusal.ts: the parse, the conversion step and the envelope.
  2. The new block in packages/metadata-protocol/src/protocol-history-and-publish.ts, right after the overlayPackageMismatchError throw in promoteDraftForPublish.
  3. packages/metadata-protocol/src/protocol.publish-draft-schema-reparse.test.ts: the rewriteStoredDraft setup and the CONTROLs.

Two-minute check: pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.publish-draft-schema-reparse.test.ts should show 9 passed. Delete the if (specRefusal) throw specRefusal; line and run it again: the three refusal pins go red.

Local gates: the full dispatch-gates.mjs --commands list for this diff, 102 families at f7534a646, was run and reconciled (--ran: 102 derived famil(ies) accounted for). The 25 families the spec ledger entry added all exit 0, among them check:spec-changes, check:upgrade-guide, check:api-surface (unchanged), check:authorable-surface, check:docs, check:liveness and the CLI's migrate-meta-engine-guidance test (3/3). spec check:generated: all 14 artifacts are up to date after a spec build. check:adr-0087-registration: 1 declared-breaking changeset(s), each carrying an ADR-0087 disposition … registered publish-refuses-object-draft-the-current-schema-refuses (new here …). All exit 0 except one that is NOT MEASURED locally and is carried by CI: check-plugin-teardown-shape --self-test exits 3 because it needs an unshallow clone. check:dual-build-cjs-loads and check:lean-entry-closure first exited 3 (no dist/); after the dogfood closure build they exit 0 at f7534a646. check:engine-double-contract went red until its ledger rows were written, then exited 0.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (The only packages/spec change is one data-only upgrade-guide entry.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint is left to CI.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched (one migration-ledger entry): spec rebuilt and check:generated reports all 14 artifacts up to date, so there is nothing to regenerate. The registry it feeds is gitignored.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English, except the Chinese maintainer summary the repo requires.

🤖 Generated with Claude Code

https://claude.ai/code/session_017xRBcRoJWF7MQr6HoRgBeC


Generated by Claude Code

… ObjectSchema

The draft promotion re-ran the save door's refusals on a stored draft but
never its spec parse, so an object draft saved before a narrowing
ObjectSchema refinement landed went live unjudged by it. The promotion now
asks the parse of the draft as the publish serves it (ADR-0087 chain
applied), with the save door's 422 INVALID_METADATA envelope, before
anything is written; judge-only batches raise it too.

Claude-Session: https://claude.ai/code/session_017xRBcRoJWF7MQr6HoRgBeC
Co-authored-by: Claude <noreply@anthropic.com>
…refinement object draft

Claude-Session: https://claude.ai/code/session_017xRBcRoJWF7MQr6HoRgBeC
Co-authored-by: Claude <noreply@anthropic.com>
…upgrade-guide entry

Claude-Session: https://claude.ai/code/session_017xRBcRoJWF7MQr6HoRgBeC
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/m documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Nov 28, 2026
@github-actions

github-actions Bot commented Nov 28, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/metadata-protocol, @objectstack/spec, touching 7 documentable anchor(s).

12 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/api/error-catalog.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/automation/email-templates.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/data-modeling/currency.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/data-modeling/external-datasources.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/data-modeling/field-types.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/deployment/cli.mdx (via /api/v1/packages/:id/publish-drafts (route, a path literal in surface))
  • content/docs/deployment/install-modes.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/deployment/validating-metadata.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/permissions/authorization.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/permissions/capabilities.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/protocol/kernel/error-handling.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/ui/forms.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))

⛔ 7 release-owned page(s) also name something this change touched. These are read-only:

  • content/docs/releases/v17/17-0.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/releases/v17/17-5.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/releases/v17/17-6.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/releases/v17/17-7.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/releases/v18/18-0.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/releases/v18/18-1.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal))
  • content/docs/releases/v18/18-2.mdx (via INVALID_METADATA (literal, a string literal in PromotedDraftSpecRefusal; a string literal in promotedObjectDraftSpecRefusal), /api/v1/packages/:id/publish-drafts (route, a path literal in surface))

content/docs/releases/ is RELEASE-OWNED (AGENTS.md "Documentation Guardrails"): release
notes are written centrally at release time, and a code PR that edits them is the exact PR
that guardrail exists to stop. They are still audited — read-only. If one of them is actually
wrong, file an issue or open a dedicated docs-only PR; do not edit it here.

What this run could not see
  • 3 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 69 of 252 client-bound route-ledger rows — the other 183 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 183: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 124 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 178 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json 3ad3b415997e28d37e74cc50ea05af9fac7faeaf → packageMentionDocs.

Which tree this was computed on

This run read content/docs from fb194fa4659bac82f81e7ee2019ff1cbd7ec4100 — the merge of head 8627792974c5ca88f4c6e1682ed3feec7a5cd66b into base 3ad3b415997e28d37e74cc50ea05af9fac7faeaf, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin fb194fa4659bac82f81e7ee2019ff1cbd7ec4100 && git checkout fb194fa4659bac82f81e7ee2019ff1cbd7ec4100
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 3ad3b415997e28d37e74cc50ea05af9fac7faeaf 8627792974c5ca88f4c6e1682ed3feec7a5cd66b && git checkout -B drift-repro 3ad3b415997e28d37e74cc50ea05af9fac7faeaf && git merge --no-ff 8627792974c5ca88f4c6e1682ed3feec7a5cd66b

node scripts/docs-audit/affected-docs.mjs --json 3ad3b415997e28d37e74cc50ea05af9fac7faeaf

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs 3ad3b415997e28d37e74cc50ea05af9fac7faeaf → pass the list as
args.docs, on the commit named under Which tree this was computed on.

… from the retirement kit's fixture

Claude-Session: https://claude.ai/code/session_017xRBcRoJWF7MQr6HoRgBeC
Co-authored-by: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

metadata publish: a draft saved before an ObjectSchema refinement landed is promoted without being parsed again

2 participants