Skip to content

fix(metadata-protocol): a package's rollback, revert or package rollback of its own permission set restores beside another namespace's shipped set - #34550

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-jaiwnp
Nov 17, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/project-thread-jaiwnp

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #34401

Clause-②: yes (widening) — a rollback, a commit revert or a package rollback of a package's own permission set N, refused 403 NOT_OVERRIDABLE ("provided by a managed package and is sealed") while a package of another namespace ships N, now restores; a delete of that set answers "Deleted permission 'N' (package=P) — it no longer exists." in place of "Customization overlay deleted (package=P) — permission/N reset to artifact default.", with reset: true as before; nothing the doors accepted is refused
Metadata-protocol: none

维护者速读

  • 改了什么:包 crm 发布了权限集 N 时,另一命名空间的包 hr 现在可以把自己的 N 回滚到旧版本、回退改过 N 的提交、或把整个包回滚到更早提交,旧版本会恢复且 hr 的授权生效旧版本;hr 删除自己的 N 时,回执改为「已删除、不再存在」,不再说「重置为制品默认」。
  • 为什么改:保存、草稿发布、发布撤销已经按「包 + 名称」判断(fix(metadata-protocol, plugin-security): judge a permission set's seal, lock and write intent by (package, name) #34359),回滚和回退仍只看名称,把 crm 的同名集当成被覆盖的封存基线,误拒了 hr 对自己集合的恢复;删除回执也读同一个只看名称的事实。
  • 风险与回滚:风险在恢复写入意图的收窄;它只复用保存门已在用的同一个判定 isOwnPermissionSetWrite,凡是覆盖 crm 所发布 N 的恢复(不绑包、绑 crm、绑 crm 的定制配对包、绑 crm 或 fin 同命名空间的包)仍按原来的错误码拒绝。回滚即 revert 本 PR,无数据迁移。
  • 先看:packages/metadata-protocol/src/protocol-class-head.ts(restoreWriteFor 一行收窄,回滚与提交回退共用),packages/metadata-protocol/src/protocol-diff-delete-load.ts(删除回执的同一判定)。
  • 两分钟验证:pnpm --filter @objectstack/plugin-security exec vitest run src/packaged-permission-set-lock-gate.test.ts,预期 71 个全部通过,其中 [#34401] 一组覆盖两种注册顺序下的恢复、删除回执和全部拒绝对照。
  • 需要你做的:评审本次声明的放宽(回滚、提交回退、包回滚三处门,以及删除回执文字)。

What changes

A permission set is (package, name) (ADR-0150 D2/D9). #34359 made the save door, the draft publish and the publish undo judge a write of a package's own set N by the package it is addressed to (isOwnPermissionSetWrite, protocol-packaged-base-refusal.ts). The per-item rollback and a commit revert's restore limb still handed restoreWriteFor the name-wide isArtifactBacked, so a restore into hr's own N, while crm of another namespace ships N, was told override-artifact and refused by the store's managed seal.

  • restoreWriteFor (protocol-class-head.ts), the one derivation both restore sites share, narrows the artifactBacked it receives by isOwnPermissionSetWrite(engine, type, name, binding), where binding is the row the restore writes (the rollback's resolved row binding, the revert's commit package). A restore into a package's own set is a runtime-only write, as that package's save is. Every other restore keeps the intent and the pair handling it had. One place covers all three doors: POST /api/v1/meta/:type/:name/rollback, POST /packages/:id/commits/:commitId/revert, and POST /packages/:id/rollback, which reverts commit by commit.
  • deleteMetaItem (protocol-diff-delete-load.ts): the two repository-path receipts that claim a code-shipped item sits under the deleted address (the success receipt and the "no row" receipt) read the same verdict at the resolved address. A delete of hr's own N answers "Deleted permission 'N' (package=hr) — it no longer exists."; a delete naming hr when hr holds no N answers "No permission 'N' found — nothing to delete.". The delete's write intent is unchanged (the store already admits it; see Acceptance notes).
Request about N (crm ships N) FROM (main) TO (this PR)
rollback of hr's own N to v1 403 NOT_OVERRIDABLE, v2 kept v1 restored; hr's grant confers v1
revert of hr's commit that edited N N in failed[], NOT_OVERRIDABLE v1 restored, failed: []
rollbackToPackageCommit to hr's earlier commit the revert in failed[] v1 restored
the same with crm AND fin shipping N refused restored
delete of hr's own N reset: true, "Customization overlay deleted (package=hr) — permission/N reset to artifact default." reset: true, "Deleted permission 'N' (package=hr) — it no longer exists."
delete naming hr, no hr row "No customization overlay found … already at artifact default." "No permission 'N' found — nothing to delete."
rollback of a row bound to crm / crm's pair 403 NOT_OVERRIDABLE unchanged
rollback of a row bound to no package 409 RESOURCE_CONFLICT unchanged
rollback of a row bound to a co-owner of crm's (or, with fin shipping, fin's) namespace 422 NAMESPACE_CONFLICT unchanged
revert of a commit of N bound to crm / crm's pair failed[] NOT_OVERRIDABLE unchanged
revert of a commit of N bound to no package / a co-owner failed[] NAMESPACE_CONFLICT unchanged
delete of crm's pair's customization of N reset: true, "… reset to artifact default." unchanged

Tests

packages/plugins/plugin-security/src/packaged-permission-set-lock-gate.test.ts, the #34226 pin file:

  • New top-level describe [#34401] restoring or deleting a package's own set N beside another namespace's shipped N, every case in both registration orders: the rollback, the commit revert and the package rollback restore v1 (and hr's grant confers it); crm and fin both shipping still restores; ten CONTROL cases (5 rollback, 5 revert) assert the code and status main answered, measured before the fix, and that the active row is untouched; the two delete receipts; a CONTROL that the pair's customization delete still reads as a reset.
  • The composition the metadata-protocol, plugin-security: the managed seal and the packaged permission-set lock judge a permission set by name alone, so one package's save of its own set N is refused because another package ships N #34226 describe used (packages, N, composition, confers) moved from inside that describe to module scope, unchanged, so both describes share it. git diff -w shows the move as whitespace.
  • The file's fake engine (forced change, named): a row of a table other than sys_metadata is keyed by its own id, so a second package commit no longer overwrites the first, and the history rows are exposed for the CONTROL rebind. No findOne/update/delete double was added (check:engine-double-contract counts unchanged).

Acceptance notes

  • Deviation from comment 6917777398: it asked for reset: false on the delete of hr's own N. DeleteMetaItemResponseSchema defines reset === true as "a row was deleted" and false as "nothing was removed", so reset stays true (a row was deleted) and only the receipt text changes. Amended claim 6932622107 records this.
  • Not changed: the delete's write intent and revertCommit's removal limb (isArtifactBacked alone). Both hand the store override-artifact for hr's own N, and assertDeleteAllowed admits it for a supportsOverlay type, so nothing is refused and the change would not be observable. The card names the removal limb as not refused.
  • The rollback CONTROL bound to no package answers 409 RESOURCE_CONFLICT, and the co-owner CONTROLs answer 422 NAMESPACE_CONFLICT. Those refusals are judged ahead of the restore, on main as on this branch.

Verification

FROM on main source, ablations, suites and gates
  • FROM (the new describe on unchanged source, bdd51769): 22 failed / 10 passed. Rollback 403 NOT_OVERRIDABLE; revert failed[] NOT_OVERRIDABLE; package rollback failed; delete receipt "reset to artifact default". The CONTROL envelopes were read from this run and pinned.
  • TO: pnpm --filter @objectstack/plugin-security exec vitest run src/packaged-permission-set-lock-gate.test.ts, 71 passed (71).
  • Ablation R1 (restoreWriteFor narrowing removed, const overridesShipped = artifactBacked;): 8 failed / 63 passed. The failures are the rollback, revert, package rollback and two-shipper cases, both orders. Restored: blob == HEAD.
  • Ablation D1 (delete receipt narrowing removed): the first attempt replaced the anchor with ; and was a no-op that ablation-replace.mjs refused (replacement count did not move), so no reading. Re-run with a marker replacement: 4 failed / 67 passed, the two delete-receipt cases in both orders. Restored: blob == HEAD.
  • The suite resolves @objectstack/metadata-protocol to source (vitest.config.ts alias), so no rebuild is needed between legs.
  • After merging origin/main, under os-verify-lock, VERDICT command-exit 0: closure build, metadata-protocol typecheck, plugin-security typecheck, plugin-security test (274 files, 6883 passed / 45 skipped), metadata-protocol test (346 passed / 9 skipped files, 22968 passed / 45 skipped).
  • Derived gate families at head bf5dccdba2: 74 derived, 74 run, 0 NOT-MEASURED (dispatch-gates.mjs --ran). The first pass had 3 exit-3 prerequisites (check-plugin-teardown-shape --self-test on a shallow clone; check:dual-build-cjs-loads and check:i18n on an unbuilt workspace). Each re-ran to exit 0 after git fetch --unshallow and a full pnpm build (VERDICT command-exit 0).

… set beside another namespace's shipped set

Claude-Session: https://claude.ai/code/session_01ADHkmPhrvD6HH5p4xPZ2jX
Co-authored-by: Claude <noreply@anthropic.com>
…permission set as a top-level describe; add its changeset

Claude-Session: https://claude.ai/code/session_01ADHkmPhrvD6HH5p4xPZ2jX
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 17, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

3 anchor(s) derived from 1 changed package(s); no hand-written page names any of them, so this run has nothing to list — not a clean bill of health. This check sees only pages that NAME a derived anchor: one that documents this change in prose, or enumerates it in an authoring dialect, names none and stays invisible to it on every run.

What this run could not see
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 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; 123 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 — 10 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 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 631d77f3021ca00e36a3cb51e19a4d8ee361fdc6

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

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

Final head for review: bf5dccdba278ebed573762619fb96bf7d9bdcde8 (card #34401, branch claude/project-thread-jaiwnp). CI on this head: 35 success, 16 skipped, 0 failed. The four changed files are inside the claim's file surface (6932589826, amended 6932622107). Owed: L1 first review, and the L2 review the Clause-②: yes (widening) declaration asks for. A push after this comment restarts both on the new head.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmPZf3MhxKeGaxV4P3W

席位核对

L1 first review · ACCEPT · head bf5dccdba278ebed573762619fb96bf7d9bdcde8 · card #34401 · read 2026-11-17T00:58Z

Checklist (read on GitHub at this head, not from the report)

  • Shape: draft, base main, attribution header then Fixes #34401. Closing-keyword scan of the whole body: one hit, #34401; #34359 and #34226 carry no keyword. Fixes is right: the card's three refused restores (per-item rollback, commit revert, package rollback) and the delete receipt are all in the diff.
  • File surface: 4 files from get_files, inside claim 6932589826 and amendment 6932622107: protocol-class-head.ts, protocol-diff-delete-load.ts, the metadata-protocol, plugin-security: the managed seal and the packaged permission-set lock judge a permission set by name alone, so one package's save of its own set N is refused because another package ships N #34226 pin file, the changeset.
  • The widening, read in the source: restoreWriteFor narrows artifactBacked by isOwnPermissionSetWrite(engine, type, name, binding) before both uses (the pair probe and the intent). That verdict is the one the save, publish and undo doors already read since fix(metadata-protocol, plugin-security): judge a permission set's seal, lock and write intent by (package, name) #34359 (protocol-packaged-base-refusal.ts:206): false for any type but permission, for no binding, and whenever the binding overrides a shipped set (shipper, its pair, a co-owner of a shipper's namespace, all shippers checked). So only a restore into a package's own set beside another namespace's shipped set changes intent, to runtime-only; every other restore keeps the intent and pair handling it had. One derivation covers all three doors, as the body says.
  • Delete receipts: shippedUnderAddress uses the same verdict at the resolved packageId, and only the two message ternaries read it; reset, the write intent and the removal limb are untouched. The deviation from 6917777398 (reset stays true) is accepted: that comment is a seat note, not a ruling, and DeleteMetaItemResponseSchema defines reset: true as "a row was deleted".
  • Changeset: .changeset/34401-own-permission-set-restore.md, @objectstack/metadata-protocol patch (published); @objectstack/plugin-security is touched by a test only. Metadata-protocol: none holds: no authorable key, value or default moves. Sentences checked: "now restores" (intent runtime-only); "A restore into a row bound to no package, to the shipper, to the shipper's customization pair or to a package that shares the shipper's set of the name is refused exactly as before" (the narrowing is false for each, and the CONTROLs pin each code); the two receipt texts match the new ternary branches verbatim; "The receipts for a customization of a shipped set are unchanged" (pair delete CONTROL).
  • Test move: git diff -w on the pin file: the metadata-protocol, plugin-security: the managed seal and the packaged permission-set lock judge a permission set by name alone, so one package's save of its own set N is refused because another package ships N #34226 composition and its describe header moved to module scope; the only non-move removal is const k = keyOf(data, table); in the fake engine, the forced change the body names (rows of other tables keyed by their own id).
  • Rejection assertions: the five rollback CONTROLs assert [code, status] via envelope(err) (RESOURCE_CONFLICT 409, NOT_OVERRIDABLE 403 ×2, NAMESPACE_CONFLICT 422 ×2) and that the active row still carries v2; the five revert CONTROLs assert the failed[] code. All were measured on main source first (FROM: 22 failed / 10 passed on the new describe), then pinned.
  • Positive control: ablation R1 (narrowing removed) turns the 8 restore cases red; ablation D1 (receipt narrowing removed), after the body records a refused no-op first attempt, turns the 4 receipt cases red. Both restored to the HEAD blob.
  • Gates at this head: check-runs on bf5dccdb…: 51 runs, 35 success, 16 skipped, 0 failed; Lint & Repo Gates, TypeScript Type Check, Dogfood Regression Gate success. Derived-gate round 74/74.

Owed after this

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

Contract review

Served-tier: TIER_DEFAULT
Head-sha: bf5dccdba278ebed573762619fb96bf7d9bdcde8
Local-runs: none

The face is the declaration only: record-recognisers --paths finds no schema or rules face on the three non-changeset paths (no packages/spec/src, no governed path), and the L2 review seat returned it to the area for that reason. Read: card #34401 and its comments, the claim 6932589826 and amendment 6932622107, the net diff against the merge base, and the head's check-runs (51: 35 success, 16 skipped, none failed or pending).

① Derived judgments

  • ProtocolClassHeadFacet.restoreWriteFor (protocol-class-head.ts): artifactBacked is narrowed to overridesShipped = artifactBacked && !isOwnPermissionSetWrite(engine, type, name, binding), the verdict the save, publish and undo doors already read (fix(metadata-protocol, plugin-security): judge a permission set's seal, lock and write intent by (package, name) #34359). Where the verdict is true, the binding is by that verdict's definition neither a shipper's pair nor a package meeting a shipper, so pairRow was already false there: the only move is the intent override-artifact → runtime-only for a restore into a package's own permission set. Every restore that overrides a shipped set keeps its intent and its pair-row body writer. Right.
  • The three doors that reach it (rollbackMetaItem, revertCommit's restore limb, rollbackToPackageCommit through revertCommit) share this one function, so one narrowing serves all three, as the card's acceptance 5 asks. Right.
  • protocol-diff-delete-load.ts: the delete door's two receipts read shippedUnderAddress (the same verdict at the resolved package) instead of the name-wide artifactBacked. The delete intent, the store call and reset are unchanged; only the receipt text for a package's own set moves ("Deleted …, it no longer exists" / "nothing to delete" in place of "reset to artifact default"). The customization receipts for a shipped set read as before. Right.
  • isOwnPermissionSetWrite answers false for every type but permission, so no other type's restore or receipt moves. Right.

② Semver level

Clause-②: yes (widening)

A rollback, a commit revert or a package rollback refused 403 NOT_OVERRIDABLE (or listed in failed[]) now restores; nothing any door accepted is refused, and the CONTROL pins hold every override of a shipped set refused with its code and status as on main. The receipt text change answers the same success with truer words. Metadata-protocol: none is right: nothing a metadata author writes changes. The changeset is @objectstack/metadata-protocol patch, which AGENTS.md rule 3 gives a non-protocol widening, and carries both declaration lines. Check Changeset: success.

③ Boundary flags

  • Dev deviation, protocol-diff-delete-load.ts: inside the claim's amended surface (6932622107), receipt text only.
  • Dev deviation, reset kept true against comment 6917777398's reset: false: answered. DeleteMetaItemResponseSchema defines reset === true as "a row was deleted", which holds here.
  • Dev deviation, revertCommit's removal limb not narrowed: answered. The store already admits that delete (assertDeleteAllowed lets an override-artifact delete through for a supportsOverlay type), so the change would not be observable; the card says the same.
  • Forced test changes (the metadata-protocol, plugin-security: the managed seal and the packaged permission-set lock judge a permission set by name alone, so one package's save of its own set N is refused because another package ships N #34226 composition fixture lifted to module level, git diff -w a move only; the fake engine keeping non-sys_metadata rows by id and exposing historyRows): test harness only.
  • No open questions; no security finding.
  • SQL push-down: no finding. The verdict reads the installed manifests already in memory; no new id materialisation or in-app join.

Implemented-by: claude/project-thread-jaiwnp
Reviewed-by: session_01ADHkmRXuRn93HphKp7kXEz

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

repo:objectstack#2 · os-steve · session_01ADHkmRXuRn93HphKp7kXEz

Landing bf5dccdba278ebed573762619fb96bf7d9bdcde8 (card #34401) on L1 ACCEPT 6934373228 and the TIER_DEFAULT contract-review record 6934375284 (declaration face, PASS), both at this head.

probe reading
check-governed-merges.mjs --pr 34550 NOT governed; 317 changed lines ≤ 3000
git merge-tree --write-tree of this head against origin/main 107d2e849 exit 0; main is 16 first-parent commits past the merge base

State: ready, auto-merge armed.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 17, 2026 01:00
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 17, 2026
Merged via the queue into main with commit 1e4656d Nov 17, 2026
52 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-jaiwnp branch November 17, 2026 01:29
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

2 participants