Skip to content

feat(rest,metadata-protocol,spec): the per-item publish takes a draft-version pin, so Save to this view never publishes a moved draft - #37387

Merged
objectstack-fleet[bot] merged 11 commits into
mainfrom
claude/issue-36350-view-draft-publish-pin
Nov 26, 2026
Merged

objectstack-fleet[bot] merged 11 commits into
mainfrom
claude/issue-36350-view-draft-publish-pin

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

Fixes #36350

Clause-②: yes (widening)
Metadata-protocol: added
Skills-docs: none — skills/** teaches no per-item metadata publish request: 0 hits over skills/ for a /meta/…/publish route, PublishMetaItem, publishMetaItem, draftVersion or parentVersion (the one If-Match hit is the data PATCH route's optimistic lock).

维护者速读

  • 用户能看到什么变化:管理员点「保存到此视图」时,若另一位管理员恰好在同一视图上改名、置顶或设为默认,这次发布会被拒绝,别人尚未审过的草稿不会被顺带发布;草稿栏的「发布」也只发布它显示的那份草稿。
  • 为什么做:维护者已裁定「别人尚未发布的草稿绝不替他发布」,此前实测这个空窗仍可复现,本次按维护者选定的方案在发布入口统一加草稿版本校验。
  • 出错会怎样:最坏情况是本应成功的保存或发布被误拒并提示冲突,草稿原样保留、不丢数据;「保存到此视图」可直接再存一次,草稿栏的「发布」需重新打开视图设置、看过最新草稿后再发布;改动可整体撤回。
  • 要你做什么:无。

What changes

Ruling 7168616260 (A1) on #36350, executed as ruled:

  • Spec — PublishMetaItemRequestSchema gains one optional member, draftVersion: the version token of the draft the caller wrote or read and means to publish; its describe says the draft is judged first and that an address refusal (404 NO_DRAFT) precedes both pins. parentVersion (If-Match) keeps its shipped meaning, the active row's token; its describe now points at the draft's own pin. MetadataConflictErrorSchema names the draft pin: on the publish door a refused draftVersion returns the draft's token, sent back as draftVersion, never as If-Match, and null there means nothing is pending to publish. The publish route's declaration in plugin-rest-api.zod.ts lists the 409 causes, both body read keys and the new 400. Generated reference (content/docs/references/api/protocol.mdx) and authorable-surface/api.json regenerated by the build / check:generated --fix.
  • Protocol (packages/metadata-protocol/src/protocol-history-and-publish.ts) — promoteDraftForPublish judges draftVersion against the draft row it just read, before any authoring rule judges that draft, with the save door's keyed comparison (storedParentForToken). A moved draft, or a pinned draft no longer pending, is refused 409 METADATA_CONFLICT with currentVersion = the draft's current token (null when none), nothing promoted, and the same optimistic-conflict audit row as the other publish conflicts. An off-type draftVersion from an in-process caller is refused 400 VALIDATION_ERROR, never read as unpinned. PublishMetaItemRequest (protocol-door-requests.ts, the public publishMetaItem type) now declares draftVersion and parentVersion. The existing expectedDraftHash keeps the promotion locked to that row through the write. The conflict-to-refusal mapping moved into one local helper shared by the pin and the promotion's own catch (same text and audit as before for the existing two conflicts).
  • REST door (packages/rest/src/meta-item-history-routes.ts) — POST /meta/:type/:name/publish reads draftVersion from its body beside message and forwards it when present; a present non-string is refused 400 VALIDATION_ERROR, never read as absent.
  • Client (ui/packages/data-objectstack) — MetadataClient.publish takes draftVersion and sends it in the body. ObjectStackAdapter.updateView's draft branch reads the draft through getDraft (the envelope carries version) BEFORE the layered read it merges from, and writes pinned to it (If-Match, or If-None-Match: * when the read saw no draft).
  • Console (ui/packages/app-shell/src/views/) — "Save to this view" (saveAndPublishRuntimeMetadata) passes the version its own draft write returned; a moved draft's 409 resolves 'pending-draft' and the moved draft is NOT discarded (it now holds the other writer's change); a 409 with currentVersion: null (the draft was published or discarded by someone else) rethrows, since there is no draft to review. The runtime draft bar's Publish (publishRuntimeMetadata) passes the draft token the bar shows: on open, the one its draft read (readRuntimeDraftForPublish, through getDraft) returned; after its host's own save, that save's receipt version, which the view settings panel hands it as savedDraftVersion from its draft-version guard (useDraftSaveGuard().heldDraftVersion). Never a blind re-read.

Absent draftVersion is unpinned everywhere, as before.

Why

Measured on main before any code (report 7164597391, re-run on the merged tree here): "Save to this view"'s draft write, then an updateView-style draft write, then the publish pinned with the only pin main offered (If-Match on the active row) answered 200 and published the interleaved draft. Ruling 7058616478 (#35955): an unpublished draft is never published on someone else's behalf.

Tests

  • Acceptance pin, in the publish door's existing harness packages/rest/src/meta-item-publish-version-pin.test.ts (new top-level describe, ruling record 6583487846), real stack at the HTTP door:
    • an updateView draft write (pinned, and unpinned) interleaved between Save's draft write and its publish: refused 409 METADATA_CONFLICT, currentVersion = the moved draft's token (parsed by MetadataConflictErrorSchema), active row unchanged, moved draft still pending;
    • control: no interleave, the pinned publish promotes; absent member: unpinned as before; pinned draft no longer pending: 409, currentVersion: null; a draft token sent as If-Match still answers the active row's refusal; non-string draftVersion (number, null, object): 400 VALIDATION_ERROR, nothing promoted; in process, an off-type draftVersion is refused 400 by the protocol; the acceptance refusal writes one publish / denied metadata_conflict audit row.
  • The measurement file meta-item-publish-draft-interleave-36350.test.ts is removed: its M1 is now the acceptance pin above; M0 (token identity) is asserted there (readDraft().version equals the receipt and the refusal's currentVersion); M2 and M3 measured options B-extended and C, which the ruling did not take, and their readings stay recorded in report 7164597391.
  • Spec: protocol.test.ts pins draftVersion preserved through parse, absent stays absent, non-strings refused.
  • Client / console: updateView.draft.test.ts (new describe: If-Match from the draft read, read before the layers; If-None-Match: * when the read saw none; a 409 reaches the caller; no version pins nothing), metadata-client.publishPackageBinding.test.ts (body carries draftVersion beside message; omitted, no key), runtime-metadata-persistence.test.ts (Save passes its receipt's version; a moved draft resolves pending-draft and is not discarded; currentVersion: null rethrows; draft bar passes the shown token), RuntimeDraftBar.test.tsx (Publish sends the shown version; refusal keeps the bar; after the host's own save the Publish is pinned to that save's receipt version with no re-read; the save-then-publish window refuses another writer's draft; a host with no receipt version stays unpinned), ViewConfigPanel.pinnedDraftSave-36137.test.tsx (each landed save hands the bar its own receipt version). Four existing draft-bar / updateView doubles now answer getDraft and the drafts ledger.
Readings (head a0b4863; first round at 8cee422/8eee7080 in report 7179271525)
  • pnpm --filter @objectstack/rest exec vitest run src/meta-item-publish-version-pin.test.ts — Tests 18 passed (18) (adds the in-process off-type pin and the audit-row assertion).
  • Ablation, door check (round 1): the draftVersion check mutated, metadata-protocol rebuilt, marker in dist/: Tests 3 failed | 14 passed (17); restored blob == HEAD, rebuilt, --absent clean: 17 passed.
  • Ablation, bar pin after the host's save (this round, source-resolved UI test, no build leg): shownDraftVersionRef.current = savedDraftVersion; replaced via scripts/ablation-replace.mjs (blob da8e79d7 -> e00baf11): RuntimeDraftBar.test.tsx Tests 2 failed | 11 passed (13) (the after-save pin and the save-then-publish window); restored, blob == HEAD, git diff HEAD empty.
  • pnpm --filter @objectstack/spec test — Test Files 895 passed (895), Tests 28420 passed | 1 todo.
  • pnpm --filter @objectstack/metadata-protocol test — Test Files 370 passed | 9 skipped (379), Tests 23435 passed | 45 skipped.
  • pnpm --filter @objectstack/rest test — Test Files 429 passed (429), Tests 8852 passed | 351 skipped.
  • ui (vitest run): the draft-bar, persistence, view-settings and report files plus all of packages/app-shell/src/views/metadata-admin/ — Test Files 810 passed (810), Tests 8717 passed | 1 skipped. packages/data-objectstack/ (unchanged this round) — 127 passed in round 1. The full packages/app-shell/ suite was not re-run this round; Test UI carries it.
  • Typecheck: @objectstack/spec, @objectstack/metadata-protocol, @objectstack/rest typecheck and @object-ui/app-shell type-check, chained with &&: VERDICT command-exit 0.

Acceptance notes

  • Where the draft pin is judged: right after the promotion's draft read, before the authoring rules judge that draft, so a moved draft answers the conflict rather than a rule refusal about someone else's body. The active-row pin (parentVersion) is still judged where Studio save goes live: two admins saving the same published object, the later save silently overwrites the earlier one (the published layer has no version a save can pin) #36601 put it, inside the promotion.
  • "Save to this view" on a moved draft resolves 'pending-draft' (the same answer as over a draft found pending before its write) and leaves the draft for review. That draft holds this save's body with the other writer's change on top; it is not discarded because it is no longer this call's own.
  • updateView now reads its draft sequentially (getDraft, then /layers) instead of in parallel, one extra round trip, so a pin can only be older than the body it merges, never newer.
  • The draft bar, after its host's own save (savedSignal, which the view settings panel bumps on every landed save), pins its Publish to that save's receipt version (savedDraftVersion). A host that gives no receipt version leaves that Publish unpinned, as before.
  • After a refused Publish the bar keeps the token it showed, so a second press is refused again until the author reopens the view settings and sees the current draft. That is the safe direction: the bar never re-pins itself to a draft it did not show.
  • Out of scope, carried by the seat to a close-out card: eight other draft-then-publish call sites in six files send no draftVersion yet (studio-design/studioSaveBar.tsx twice, metadata-admin/DraftConflictDialog.tsx, metadata-admin/detailSaveAtOnce.ts, recordTabsConfigSave.ts, objectExtensionArrangementSave.ts, layout/designModeMenuSave.ts twice), and @objectstack/client's publishItem can state neither pin. The member is opt-in by ruling; ruling item 3 named the four callers this PR pins.
  • Contract-review-tier L2: recorded FAIL on 8eee708 (7179921339); this head answers M1, M2, S1–S3 and N1–N5.

Verification

Gates (local subset, derived by dispatch-gates.mjs from the diff, on a0b4863)
  • node scripts/pm/dispatch-gates.mjs --ran (exit codes recorded): 125 derived, 123 run, 2 NOT-MEASURED, 0 UNRUN.
  • NOT MEASURED, node scripts/check-plugin-teardown-shape.mjs --self-test: exit 3, its positive control is pinned to a commit this shallow clone cannot reach. CI runs it.
  • NOT MEASURED, pnpm check:dual-build-cjs-loads: exit 3, packages outside this diff have no dist/ in this container (PREREQUISITE NOT MET). CI runs it.
  • pnpm --filter @objectstack/spec run check:skill-examples: exit 3 until client-react was built, then exit 0.
  • pnpm --filter @objectstack/spec check:generated: check:docs stale after the conflict-text edit, regenerated with --fix and committed; check:api-surface green on the built dist.
  • overlap-check: VERDICT clean against origin/main and the one PR head sharing a file (feat(security)!: View All and Modify All stop opening fields; viewAllFields is the one every-field bit #37371, generated reference page: merges cleanly).

Two-minute check: pnpm --filter @objectstack/rest exec vitest run src/meta-item-publish-version-pin.test.ts — expect Tests 18 passed (18), including the [#36350] describe.

Read first (by risk): packages/metadata-protocol/src/protocol-history-and-publish.ts (the pin and the shared conflict helper), ui/packages/app-shell/src/views/RuntimeDraftBar.tsx with ViewConfigPanel.tsx (the pin after the host's save), ui/packages/app-shell/src/views/runtime-metadata-persistence.ts (the no-discard and nothing-pending branches).

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (CI-owned run).
  • 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: its generated artifacts are regenerated and committed.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm


Generated by Claude Code

…asurement, M1 red on main)

Measurement only, for a needs_decision report: M1 shows the publish door's
active-row If-Match does not see a draft written between Save to this
view's draft write and its publish; M2 shows a client-side pin on
updateView's draft write does not either; M0 and M3 record the tokens and
the active-save door's answer. Not for landing.

Claude-Session: https://claude.ai/code/session_012MmDsSBHy5paNUz6zke9Re
Co-authored-by: Claude <noreply@anthropic.com>
…-version pin (draftVersion)

The publish door refuses a draft that moved since the caller wrote or read
it, 409 METADATA_CONFLICT naming the draft's current token, beside the
active-row If-Match pin. Ruling 7168616260 (A1).

Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm
Co-authored-by: Claude <noreply@anthropic.com>
…to the draft version

Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm
Co-authored-by: Claude <noreply@anthropic.com>
…e draft they read

Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm
Co-authored-by: Claude <noreply@anthropic.com>
…est.draftVersion

Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l 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 26, 2026
@github-actions

github-actions Bot commented Nov 26, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 3 package(s): @objectstack/metadata-protocol, @objectstack/rest, @objectstack/spec, touching 11 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/spec/authorable-surface/api.json), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

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

  • content/docs/api/client-sdk.mdx (via meta.publishItem (sdk, the route ledger binds it to POST /api/v1/meta/:type/:name/publish, selected by route anchor /:type/:name/publish), publishItem (sdk, the bare tail of client method meta.publishItem, bound to POST /api/v1/meta/:type/:name/publish))
  • content/docs/api/metadata-api.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))
  • content/docs/concepts/metadata-lifecycle.mdx (via parentVersion (symbol, a field of type PublishMetaItemRequest, an authorable key of api/PublishMetaItemRequest), /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))
  • content/docs/data-modeling/currency.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))
  • content/docs/deployment/cli.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))
  • content/docs/kernel/contracts/metadata-service.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))
  • content/docs/permissions/system-context.mdx (via registerMetaItemHistoryRoutes (symbol, a top-level function))
  • content/docs/protocol/kernel/error-handling.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))

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

  • content/docs/releases/v17/17-0.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))
  • content/docs/releases/v17/17-1.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))
  • content/docs/releases/v17/17-2.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))
  • content/docs/releases/v17/17-4.mdx (via /:type/:name/publish (route, bridged from symbol draftVersion — its route source's handler names it; bridged from symbol parentVersion — its route source's handler names it))

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
  • 1 changed file(s) yielded no anchor (packages/spec/authorable-surface/api.json) — pages documenting those are invisible to this run
  • 1 anchor(s) matched too much of the corpus to be a work list: VALIDATION_ERROR (literal, 38 pages)
  • 1 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 — 180 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 da7c559990d879de9038ccf54e294e58bbaa647f → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 0205816c29915f2e23d423a4b3c9eb3a72e1f6ba — the merge of head a586b8c54572f8a0307da2143e41d4292dff22c5 into base da7c559990d879de9038ccf54e294e58bbaa647f, 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 0205816c29915f2e23d423a4b3c9eb3a72e1f6ba && git checkout 0205816c29915f2e23d423a4b3c9eb3a72e1f6ba
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin da7c559990d879de9038ccf54e294e58bbaa647f a586b8c54572f8a0307da2143e41d4292dff22c5 && git checkout -B drift-repro da7c559990d879de9038ccf54e294e58bbaa647f && git merge --no-ff a586b8c54572f8a0307da2143e41d4292dff22c5

node scripts/docs-audit/affected-docs.mjs --json da7c559990d879de9038ccf54e294e58bbaa647f

⚠️ 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 da7c559990d879de9038ccf54e294e58bbaa647f → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8eee7080331c7d1a6c47c4dbb1b7369660cb94a2
Local-runs: none
Scope: packages/spec/src/api/protocol.zod.ts (the one hits path; packages/spec/authorable-surface/api.json is a generated shard the face reader does not count) + packages/metadata-protocol/src/protocol-history-and-publish.ts, packages/metadata-protocol/src/protocol.ts, packages/rest/src/meta-item-history-routes.ts, ui/packages/data-objectstack/src/metadata-client.ts, and the ruling's first consumers ui/packages/data-objectstack/src/index.ts, ui/packages/app-shell/src/views/runtime-metadata-persistence.ts, ui/packages/app-shell/src/views/RuntimeDraftBar.tsx
Security-touching: no
Rule-change-verified: none

Read: card #36350 with all ten comments (ruling record 7168616260, reports 7164597391 and 7179271525), ruling 7058616478 on #35955, the PR body, its 26-file list, and the net diff against main (merge base 80da086). Check-runs on the head, read at 2026-11-26T01:25Z: 70 runs, 60 success, 9 skipped, 1 failure (Check Changeset), none pending.

Two must-fix findings (M1, M2), three should-fix (S1 to S3), five nits. The door itself holds: I could not make it publish a draft the caller did not pin.

① Derived judgments

  • draftVersion on PublishMetaItemRequestSchema (z.string().optional()): right. One optional member, sent in the body beside message, as ruling item 1 words it. Absent stays unpinned. The schema refuses null and non-strings, which is right: the member is a token only, and a publish has nothing to assert about "no draft".
  • parentVersion: meaning unchanged, right (ruling item 2). Its describe gains one clause pointing at draftVersion. The harness pins that a draft token sent as If-Match still answers the active row's refusal.
  • REST door, 400 VALIDATION_ERROR on a present non-string: right. It agrees with the schema and keeps a malformed pin from being read as no pin. It sits after the capability and walled-catalog gates. Strictly, a body {"draftVersion": 42} was ignored before and is refused now. No sender of that key existed, and the sibling member was declared widening on the same shape (.changeset/36601-published-layer-version-pin.md), so Clause-②: yes (widening) holds.
  • 409 METADATA_CONFLICT, currentVersion = the draft's current token: right, the ruling's words. currentVersion: null for a pinned draft that is no longer pending is derived, not ruled. It is right, but it changes what currentVersion means on this door and the published text did not move with it: S1.
  • Metadata-protocol: wrong. The diff moves packages/spec/authorable-surface/api.json (api/PublishMetaItemRequest:draftVersion), which is added, not none: M1.
  • The implementation's request type: not derived. The public publishMetaItem request type did not gain the member: S2.

② Semver level

M1 (must-fix) — Check Changeset is red on this head, and it is right. The PR body and all five changesets declare Metadata-protocol: none, and @objectstack/spec is graded patch. The gate reads the moved authorable-surface/api.json shard as an authorable key added and asks for Metadata-protocol: added with at least minor on the package that carries it. The sibling pin on this same schema did exactly that: 36601-published-layer-version-pin.md declares added, @objectstack/spec minor, the others patch. Fix: Metadata-protocol: added on the PR body and in each changeset, and 36350-publish-draft-pin-spec.md to minor. The baseline is not edited.

The rest of ② holds. Every published package the diff touches has a changeset: spec, metadata-protocol, rest, data-objectstack, and app-shell with console. Clause-②: yes (widening) is on the PR body and all five. No breaking marker is owed.

③ Boundary flags

  • Dev open question (7179271525): the refused Save answers 'pending-draft'. Answered: option A stands for a moved draft. Ruling 7058616478: when the view has an unpublished draft, "Save does not publish that draft on someone's behalf: it says so and points to the view settings to publish or discard it first; the buttons stay." After the refusal the view does have such a draft, holding the other writer's change, and 'pending-draft' is the answer that says so. Not discarding it is required by the same sentence. One arm does not fit, S3.
  • S3 (should-fix) — runtime-metadata-persistence.ts:643 answers 'pending-draft' for every publish METADATA_CONFLICT, including currentVersion: null, where the pinned draft was published or discarded by someone else inside the window. No draft is pending then, so the author is sent to the view settings to review a draft that is not there, and if it was discarded their change is gone with no word. The envelope tells the two apart. For null, rethrow the refusal (the dev's option B) and keep 'pending-draft' for a moved draft.
  • Out-of-scope finding (7179271525): eight other draft-then-publish call sites, in six files, send no draftVersion. It does not touch the contract. The member is opt-in by ruling, absent is unpinned as before, and item 3 named four callers. The seat carries it to a close-out card. @objectstack/client's publishItem belongs on that list too: it can state neither pin (read, not reviewed). The PR's acceptance notes do not carry the finding (N5).
  • PR acceptance note, "no current host passes savedSignal": false on the tree, and it covers a gap in ruling item 3: M2.
  • Ruling record's execution parameter Metadata-protocol: none: contradicted by the gate (M1). The maintainer's word was 「A1」; the parameter was the seat's prediction beside it. The seat corrects it on the card, as 7168644634 corrected another line. Nothing to escalate.
  • Dev's two NOT MEASURED gates and the app-shell suite not re-run after the last commit: answered by CI. Lint · CI, release & engine gates, the other lint families, Test Core 10/10 and Test UI 16/16 are green on this head.
  • First report's confidence gap, two pins on one request: accepted by the ruling. What is left is a describe gap, N2.
  • SQL push-down: no finding. The server adds no query; the pin is judged on the draft row the promotion already read. Client side, updateView now makes its reads in sequence, which is ordering, not a join.

④ Design judgment

packages/spec/src/api/protocol.zod.ts — the member holds against ruling items 1 and 2 and against its first consumers: the REST door reads exactly this member and MetadataClient.publish sends it.

S1 (should-fix) — published contract text the diff leaves false.

  • MetadataConflictErrorSchema (protocol.zod.ts:1539, the schema the new harness parses the refusal with). Its currentVersion describe says "Send it as If-Match to overwrite deliberately (or If-None-Match: * when it is null)", and its docblock lists the causes as If-Match, If-None-Match: * or a lost race. On a draft-pin refusal the token is the draft's. Sent as If-Match on this door it is refused again, the mistake the harness pins. null there means no draft is pending, not "assert no active row". Name the draft pin: the token goes back as draftVersion, and null means there is nothing to publish.
  • packages/spec/src/api/plugin-rest-api.zod.ts:944-962, the publish route's declaration. Its description gives the 409 one cause, "the published row advanced while the draft was held". Its comment says the body's "only read key is message" and "the route cannot 400 a malformed body". Both are false at this head. The file is outside the diff, but this diff is what falsifies it.

packages/metadata-protocol/src/protocol-history-and-publish.ts — agrees with the contract. Probes:

  • Order. The pin is judged on the draft row read under the resolved package key and member, straight after that read and before the slot, ownership, registration and authoring gates. A moved draft answers the conflict, never a rule verdict on someone else's body. The address, lock, draftable and named-base refusals come first, as they do for the active-row pin.
  • Held through the write. The same row's hash is expectedDraftHash. repo.promoteDraft re-reads the draft, refuses another hash before the put, and drains by the promoted hash. A draft saved after the gate is neither promoted nor drained.
  • Draft gone. Before the gate's read: 409 with currentVersion: null, pinned by the harness. Between the gate and the write: the store's own conflict or NO_DRAFT. Nothing is promoted either way.
  • Token. storedParentForToken compares in keyed form. An empty string, a raw stored hash, a stale token and a token keyed before a restart are all refused, never read as no pin. The token is content-addressed, like parentVersion: one minted for another package, member or address matches only a byte-identical draft at the address this publish resolves, which promotes exactly the content the caller pinned.
  • Both pins. Draft first, then active; either refuses, and the harness pins the split.
  • Audit. One denied / metadata_conflict row rides the error and is written by publishMetaItemUnaudited's catch, as for the two existing conflicts. The shared helper keeps their text and the first-write hint. Read, not pinned: N3.
  • The package publish states no pin and is unchanged.

packages/metadata-protocol/src/protocol.ts

S2 (should-fix) — the member is added to the private promoteDraftForPublish parameter only. PublishMetaItemRequest (protocol-door-requests.ts:39-96), the type of the public publishMetaItem, declares neither draftVersion nor parentVersion. The pin reaches the promotion through the untyped spread in publishMetaItemUnaudited. A typed in-process caller cannot state it, and a later edit that picks members instead of spreading drops the pin and publishes unpinned. That file's own comment on packageId records this hazard, and the spec schema's docblock says it mirrors the implementation's type member for member. Declare draftVersion there. parentVersion is the same one-line gap and predates this PR.

packages/rest/src/meta-item-history-routes.ts — agrees with the contract. The member is read beside message, refused 400 when present and not a string, forwarded only as a string, and the If-Match mapping is untouched. A body the Hono transport cannot read as JSON is refused when the handler reads it, so a pin is not dropped that way.

ui/packages/data-objectstack/src/metadata-client.ts — agrees. The key is sent only when stated, and may ride beside ifMatch or ifNoneMatch.

ui/packages/data-objectstack/src/index.ts — holds ruling item 3 for updateView. The pin comes from the strict draft read taken before the layers, so it is never newer than the body merged. No draft seen pins If-None-Match: *. A 409 throws; nothing is merged over an unread body.

ui/packages/app-shell/src/views/runtime-metadata-persistence.ts — Save passes its own receipt's version, and each call mints its own token, so no stale token is re-sent on a retry. One arm: S3.

ui/packages/app-shell/src/views/RuntimeDraftBar.tsx

M2 (must-fix) — ruling item 3 is not met on the draft bar's main path. Item 3: the bar's Publish "passes the draft token it showed, which closes the dev's out-of-scope finding on that caller". Line 151 clears the shown version when savedSignal bumps, and the Publish then goes unpinned. ViewConfigPanel.tsx:500 passes savedSignal and :390 bumps it on every landed save. That panel is the view settings, where ruling 7058616478 sends the author to publish or discard. So: A saves in view settings, B's Rename lands through updateView (it reads A's draft, writes pinned, is accepted), A presses Publish, and B's unreviewed rename goes live. That is the window report 7164597391 named on this caller. The pin holds only when the bar opened on an existing draft and the panel never saved. Fix: after the host's own save, pin the Publish to that save's receipt version, which the panel's useDraftSaveGuard already holds, as Save to this view does with its receipt. A blind re-read is not the fix: after B's write it would pin B's draft, which the panel never showed. RuntimeDraftBar.test.tsx:211 pins the unpinned behaviour and changes with it. Correct the PR body sentence.

Nits:

  • N1 (nit) — at the protocol, an off-type draftVersion: null from an in-process caller passes storedParentForToken (it returns for null) and publishes unpinned. The REST door refuses null, and it is the only caller. A typeof guard at the pin closes it.
  • N2 (nit) — the draftVersion describe says the two pins "may be sent together" but not that the draft is judged first. A request stale on both learns only the draft's token. An address refusal also precedes the pin: no draft at the address while another package holds one answers 404 NO_DRAFT, not 409 with null.
  • N3 (nit) — the protocol changeset claims the conflict audit row; no test in the diff asserts it. The harness already registers the audit object.
  • N4 (nit) — after a refused Publish the bar keeps its stale token, so a second click is refused again until the panel is reopened. That is the safe direction, but the PR body's 「可直接再次操作」 is not true for the bar.
  • N5 (nit) — the out-of-scope finding is on the card, not in the PR's acceptance notes.

Implemented-by: claude/issue-36350-view-draft-publish-pin
Reviewed-by: session_012MmDsSBHy5paNUz6zke9Re

VERDICT: FAIL

…in — protocol kind, bar pin after the host's save, conflict text

Claude-Session: https://claude.ai/code/session_012MmDsSpwtcn5gbWrBDA3Jm
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/xl and removed size/l labels Nov 26, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: a0b4863e217f6d10874e82eeae0ea64cf5d75aed
Local-runs: none
Scope: packages/spec/src/api/plugin-rest-api.zod.ts, packages/spec/src/api/protocol.zod.ts (the two hits paths) + packages/metadata-protocol/src/protocol-history-and-publish.ts, packages/metadata-protocol/src/protocol-door-requests.ts, packages/metadata-protocol/src/protocol.ts, packages/rest/src/meta-item-history-routes.ts, ui/packages/data-objectstack/src/metadata-client.ts, and the ruling's first consumers ui/packages/data-objectstack/src/index.ts, ui/packages/app-shell/src/views/runtime-metadata-persistence.ts, ui/packages/app-shell/src/views/RuntimeDraftBar.tsx, ui/packages/app-shell/src/views/ViewConfigPanel.tsx, ui/packages/app-shell/src/views/metadata-admin/DraftConflictDialog.tsx
Security-touching: no
Rule-change-verified: none

This is a DELTA record on record 7179921339 (FAIL at 8eee708: M1, M2, S1 to S3, N1 to N5). Read: the two commits between that head and this one (18 files), the PR body as rewritten at 02:49Z, the seat's correction 7179935180 and the dev's reports 7181146930 and 7181181714 on #36350, and this head's check-runs.

Check-runs on this head, read at 2026-11-26T03:19Z with none pending: 74 runs, 62 success, 11 skipped, 1 failure. The failure is the Check Changeset run that started at 02:47:15Z and finished at 02:49:41Z, before the body edit; it read the old Metadata-protocol: none line. The Check Changeset run that started at 02:49:59Z, after the edit, is success, and it is the one I read for ②. Test Core 10/10, Test UI 16/16, the type-check and lint families, Build Core and Build & E2E UI are green.

All ten findings are closed. One new nit (N6), one changeset nit (N7). No must-fix, no should-fix.

① Derived judgments

  • Metadata-protocol: now right. The PR body and all five changesets declare added, the kind the moved authorable-surface/api.json shard records. The seat's correction 7179935180 withdraws the none parameter as its own prediction; the ruling's items 1 to 3 are untouched.
  • Skills-docs: none: right. Read on this head, skills/** and ui/skills/** name no per-item publish route, publishMetaItem, draftVersion or parentVersion; the only publish hits are the package batch door and a hook announcement.
  • MetadataConflictErrorSchema describe and docblock: now say what the door answers. The describe on currentVersion grew; its type and accept-set did not move.
  • PublishMetaItemRequest in the implementation: now declares draftVersion and parentVersion. A widening of the package's typed surface, in step with the spec.
  • Protocol 400 VALIDATION_ERROR on an off-type in-process draftVersion: new this round, right. It agrees with the schema and with the REST door's 400, and it sits behind the same draftVersion !== undefined test, so an absent member is still unpinned.
  • The four judgments of the first record that were right (draftVersion, parentVersion, the REST 400, the 409 with currentVersion) are unchanged by the delta.

② Semver level

M1: closed. @objectstack/spec is minor, the other four changesets stay patch, and every one carries Clause-②: yes (widening) and Metadata-protocol: added, as the sibling pin's changeset does. The gate's level axis reads it green: "declares clause-② yes (widening) and metadata-protocol added, and it grades a package whose published source it moves at minor or above". No new published package entered the diff: protocol-door-requests.ts is metadata-protocol, plugin-rest-api.zod.ts is spec, ViewConfigPanel.tsx and DraftConflictDialog.tsx are app-shell.

  • N7 (nit) — 36350-publish-draft-pin-console.md was not moved with the round. It does not mention that Save rethrows when the refusal carries currentVersion: null, or that the bar's Publish after the panel's own save is pinned to that save's receipt. Nothing in it is false.

③ Boundary flags

  • Dev open question (7181146930): who writes the PR body. Answered by the seat: it wrote the body at 02:49Z. The body now carries the corrected declaration lines, the savedSignal sentence, the bar's retry behaviour and the out-of-scope list.
  • Dev open question of round 1 ('pending-draft'): settled. Option A for a moved draft, the refusal rethrown for currentVersion: null. S3 below.
  • Hand-written docs pass (7181181714), eight pages, none changed. I read the cited lines on this head and agree: no page is made false by this PR.
    • api/metadata-api.mdx:75, kernel/contracts/metadata-service.mdx:506,514, deployment/cli.mdx:1536: name the route only; no body, 409 or currentVersion.
    • api/client-sdk.mdx:237: client.meta.publishItem(…, { message }), unchanged by this PR.
    • data-modeling/currency.mdx:109-112: "A draft is judged when it is published" still holds; a moved draft's 409 comes before the judging and the page says nothing about that.
    • protocol/kernel/error-handling.mdx: its currentVersion rows are the data route's CONCURRENT_UPDATE. permissions/system-context.mdx:213: the marketplace publish route.
    • concepts/metadata-lifecycle.mdx:238 (Conflict handling): describes the repository's own conflict at the four write doors and claims no exclusivity, so the draft pin falsifies nothing. It is the only hand-written METADATA_CONFLICT passage in content/docs outside the references. Its sentence "the console does not yet surface a dedicated conflict-resolution UI" was already untrue before this PR, and it names neither publish pin. That is a docs card for the seat, not this diff.
  • Out-of-scope finding: unchanged and still off the contract. Now in the PR's acceptance notes (N5 closed), with @objectstack/client's publishItem added.
  • Dev's two NOT MEASURED gates, and the app-shell suite not re-run locally: answered by CI on this head. The lint families and Test UI 16/16 are green.
  • SQL push-down: no finding. The delta adds no query.

④ Design judgment

packages/spec/src/api/protocol.zod.ts

S1: closed. MetadataConflictErrorSchema's docblock and its currentVersion describe now name the draft pin: the token goes back as draftVersion, never as If-Match, and null there means nothing is left to publish. The generated reference carries the same text.

N2: closed. The draftVersion describe states that the draft is judged first and that the address is resolved before either pin, with 404 NO_DRAFT. Both match the code (packagelessPublishNoDraftRefusal, 404).

packages/spec/src/api/plugin-rest-api.zod.ts — a hits path since this round. The publish route's description now lists the three 409 causes in the order the door judges them and the 400, and the comment names both body keys. Each sentence agrees with the route and the promotion as read. No generated copy of the old text remains in the tree. Keeping no requestSchema is right: the body is two optional keys, not the protocol request.

packages/metadata-protocol/src/protocol-door-requests.ts, protocol.ts

S2: closed. PublishMetaItemRequest declares both pins. The new in-process harness case has to cast to send null, which is the typed surface doing its job.

packages/metadata-protocol/src/protocol-history-and-publish.ts

N1: closed. An off-type draftVersion is refused 400 before the keyed comparison, and the harness pins it in process with nothing promoted.

N3: closed. The acceptance case asserts exactly one publish / denied row with code metadata_conflict, which also pins that the refusal is not audited twice.

The rest of the file is as reviewed at the last head.

packages/rest/src/meta-item-history-routes.ts, ui/packages/data-objectstack/src/metadata-client.ts, ui/packages/data-objectstack/src/index.ts — unchanged by the delta; the first record's reading stands.

ui/packages/app-shell/src/views/runtime-metadata-persistence.ts

S3: closed. A publish conflict whose body parses as MetadataConflictErrorSchema with currentVersion: null is rethrown, after the caches are dropped and with no draft reset. A moved draft still answers 'pending-draft' and is not discarded. The body is read off the error the client keeps (err.body), the same reading the save guard's overwrite already uses.

ui/packages/app-shell/src/views/RuntimeDraftBar.tsx, ViewConfigPanel.tsx, metadata-admin/DraftConflictDialog.tsx

M2: closed. The panel hands the bar the version its save guard holds after each landed save, and the bar pins its Publish to it with no re-read. Followed through on this head:

  • The host saves through the guard under (view, the view id, no package), and heldDraftVersion reads the same key.
  • A landed save leaves the guard holding that save's receipt version. An overwrite after a conflict holds the re-send's receipt.
  • A save the author resolved by reloading returns not-landed from the host, so no signal and no version reach the bar.
  • The version is set before the signal, so the bar's effect reads the new one whether or not the two updates batch.
  • A server that returns no receipt version leaves the Publish unpinned, as before, and a test says so.

So the window of the first record (A saves in view settings, B's rename lands, A presses Publish) now ends in a 409 with B's draft left pending. RuntimeDraftBar.test.tsx pins the bar's half, ViewConfigPanel.pinnedDraftSave-36137.test.tsx the panel's half, and the dev reports (7181146930) that ablating the one assignment reds both bar cases; I did not run it. The PR body's sentence is corrected.

N4: closed. The PR body no longer claims an immediate retry for the bar; it says the author reopens the view settings.

  • N6 (nit) — one path where that reopening is asked of an author who has already seen the draft. The panel opens on draft D1, another writer moves it to D2, the author's Save is refused and they choose "reload". The panel re-reads and shows D2, and its guard records D2. The bar is not told: it still holds D1, so the Publish of the draft now on screen is refused until the panel is reopened. Before this PR that Publish went through unpinned. It fails closed and nothing wrong is published. The fix is the one M2 used: hand the bar the version the reload's read recorded. For the lane seat or the close-out card.

N5: closed (see ③).

No must-fix, no should-fix.

Implemented-by: claude/issue-36350-view-draft-publish-pin
Reviewed-by: session_012MmDsSBHy5paNUz6zke9Re

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re

席位核对

ACCEPT · 2026-11-26T04:20Z · head a586b8c54572f8a0307da2143e41d4292dff22c5 · L1 by the dispatching seat, claim 7176924040, Ruling-ref: 7168616260 (A1). L2 at CONTRACT_REVIEW_TIER (owed: the published schema packages/spec/src/**):

  • FAIL 7179921339 at 8eee708 (M1, M2, S1–S3, N1–N5).

  • Delta PASS 7181638537 at a0b4863: all ten closed, nits N6 and N7 new, no must-fix or should-fix.

  • This head is a clean pr_update_branch merge of main into a0b4863 (K was 28). The patch-id is identical before and after (bbc3e6f46ba4), so the record carries over.

  • Ruling executed (A1):

    • Item 1: one optional draftVersion member on PublishMetaItemRequestSchema, judged against the draft row before any authoring rule. A moved draft gets 409 METADATA_CONFLICT with currentVersion = the draft's token (or null when none), nothing is promoted, and a conflict audit row is written.
    • Item 2: If-Match keeps its active-row meaning.
    • Item 3: "Save to this view", updateView, the draft bar's Publish (after the host's own save it uses that save's receipt version, never a re-read) and MetadataClient.publish all pin.
  • Ruling 7058616478 (在列表上的改动都改成临时的(排序、筛选、分组、列的显示和顺序):立即生效但不保存,出现「放弃」和「保存」;列宽、行高、标签页顺序只记在浏览器里;退掉服务端的个人列表偏好 #35955): a moved draft answers 'pending-draft' and is not discarded. A null refusal rethrows (S3), so no unreviewed draft is published or deleted on someone else's behalf.

  • Declarations: Clause-②: yes (widening) and Metadata-protocol: added, with spec at minor and the other four changesets at patch. This follows the seat's correction 7179935180 of its own execution parameter; the ruling itself is unchanged. Skills-docs: none was measured: skills/** teaches no per-item publish request.

  • Published text: MetadataConflictErrorSchema, the draftVersion and parentVersion describes, and the publish route declaration in plugin-rest-api.zod.ts were corrected (S1). The generated reference was regenerated. The dev's pass over 8 hand-written pages (7181181714) found none made false, and the delta L2 agreed.

  • Pins: the acceptance describe is in the publish door's existing harness, 18 tests: the interleave refused (pinned and unpinned), a control, absent unpinned, null when nothing is pending, a draft token sent as If-Match, non-string 400 at the door and in process, and the audit row.

    • Door ablation: 3 red. Bar-pin ablation: 2 red.
    • Client and console pins cover the bar, the panel, persistence, updateView and the client.
  • Gates (check-runs at this head): 61 success, 9 expected skip, 0 failed. Check Changeset, Lint & Repo Gates and TypeScript Type Check are all success. mergeable_state is clean.

  • Landing reads: check-governed-merges --pr 37387 read NOT governed (0 of 31 paths) on a0b4863, 1039 changed lines, under the 3000 threshold; the merge from main added none to the diff. K = 2 after the merge (merge-base da7c559). git merge-tree is clean.

  • Accepted as deviations (nits):

    • N6: after a "reload" in the panel's conflict dialog the bar keeps the old token, so Publish fails closed until the panel is reopened.
    • N7: the console changeset does not mention the two round-2 behaviours.
  • Out of scope, carried by the seat:

    • Eight other draft-then-publish call sites in six files, and @objectstack/client's publishItem, send no draftVersion. The member is opt-in by ruling, and item 3 named the four callers this PR pins. The seat lists them in its clock-out brief for a close-out card.
    • content/docs/concepts/metadata-lifecycle.mdx:238 says the console has no conflict-resolution UI, which was already untrue before this PR. It is a docs card for the next seat.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#6 · os-lizheng · session_012MmDsSBHy5paNUz6zke9Re

Landing (2026-11-26T04:20Z): head a586b8c54572f8a0307da2143e41d4292dff22c5, on L1 ACCEPT 7182511653 and the contract-tier delta L2 PASS 7181638537. The record carries over this head as a clean main merge with the same patch-id (bbc3e6f46ba4).

Probe Reading
check-governed-merges.mjs --pr 37387 NOT governed: 0 of 31 paths hit the register; 1039 changed lines, under the human-merge threshold
Check-runs at this head 61 success · 9 expected skip · 0 failed · 0 pending; mergeable_state clean
Landing K 2 after pr_update_branch (was 28); git merge-tree clean

State: pr_ready + automerge_enable; #36350 closes on merge through Fixes.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 26, 2026 04:21
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 26, 2026
Merged via the queue into main with commit 0002eaf Nov 26, 2026
71 checks passed
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/xl 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.

Publish of a view draft takes a draft-version precondition, so an unpinned draft write cannot be published by Save to this view (after #36137)

2 participants