Skip to content

fix(metadata-protocol): duplicating a package copies a permission set that grants on an optional plugin's object not installed here - #30414

Merged
objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-9dm0ks
Nov 5, 2026
Merged

objectstack-fleet[bot] merged 4 commits into
mainfrom
claude/project-thread-9dm0ks

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Bill · project thread

domain:server#2 · os-bill · session_01Utp6CYSw4nSVJDr6XpcWLJ

Fixes #30319

Clause-②: no
Metadata-protocol: none

维护者速读

  • 改了什么: 复制包(duplicatePackage)时,复制出的权限集把源权限集在库中存储的授权对象名作为 inheritedGrantObjects 交给保存门,与 main red: Dogfood Regression Gate (2/3) fails permission-set-clone-door after PR #30222 (member_default grants sys_comment) #30255 的权限集克隆门同一条规则。没装 plugin-audit 的部署里,授权 sys_comment 的权限集现在能随包一起复制;非托管导入按席位裁定 A 保持拒收,未改。
  • 为什么改: 修 fix(runtime, metadata-protocol): the permission-set clone door copies a set that grants on an object this deployment does not install, and member_default's feed grants re-land #30310 时只改了克隆门,复制包这扇门仍把这类权限集放进 failed[],整次复制回 success: false,用户复制一个正常的包却丢了权限集。
  • 风险与回滚: 只放行源行本来就持有的授权键;被命名空间改写过的键(源包自己的对象改名为副本的对象)不算继承,仍照常判;键只从库中的源行取,不读请求。非托管导入的包是请求体,不是存储行,所以仍逐条判(裁定 A)。回滚即撤 PR。
  • 先看: packages/metadata-protocol/src/protocol-package-commits.ts 的复制门 saveMetaItem 调用(inheritedGrantObjects 一行)与文件头的 storedGrantObjectKeys;再看 protocol.copy-doors-inherited-grants.test.ts 的第二个用例(改名后的授权仍拒)。
  • 两分钟验证: pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.copy-doors-inherited-grants.test.ts,预期 4 个用例全过。
  • 需要你做的: 无,席位落地。

What changes

Measured first (on main at 870ebce3, before the fix)

Harness: the stateful sys_metadata stub of the new test file, registry registering no object (no plugin-audit), a source package com.example.leave holding object leave_ticket and set leave_staff granting leave_ticket + sys_comment.

Duplicate door — refused (200, success: false, the set in failed[])
"success": false, "copiedCount": 1, "failedCount": 1,
"copied": [{ "type": "object", "name": "leave_copy_ticket" }],
"failed": [{ "type": "permission", "name": "leave_staff",
  "error": "permission/leave_copy_staff failed spec validation: objects.sys_comment: Permission 'leave_copy_staff' grants on object 'sys_comment' which is not defined in objects: no package registers an object of that name and none is saved here, so the grant applies to nothing. …" }]
Unmanaged import — refused (422 INVALID_METADATA, rolled back whole)
422 INVALID_METADATA The unmanaged install of 'com.example.crm' was rolled back: permission 'crm_rep' could not be written — permission/crm_rep failed spec validation: objects.sys_comment: … the new base 'com.example.crm-copy' was removed, so nothing of the package remains.
issues: [{"path":"objects.sys_comment", "code":"custom", …}]
sys_metadata rows after: []

Tests

packages/metadata-protocol/src/protocol.copy-doors-inherited-grants.test.ts, 4 cases:

  1. Duplicate: a set granting on sys_comment (absent) and the source's own object is copied; the copy grants leave_copy_ticket + sys_comment.
  2. Duplicate: a grant the rewrite renames onto an object that did not copy (leave_copy_ticket, its source row unparseable) is still refused — the exact failed[] entry, one finding at objects.leave_copy_ticket, sys_comment not judged; nothing stored.
  3. Duplicate: a grant the source holds outside its namespace on an absent object (other_gone, not renamed) is the source's and is copied.
  4. Unmanaged import: a set granting on sys_comment is refused 422 INVALID_METADATA at objects.sys_comment (code, status, path, first sentence) and the import is rolled back (no row, no base) — pinned as intended by ruling A.

Ablations (each through scripts/ablation-replace.mjs, mutation proven on disk, restored to the HEAD blob with git diff HEAD empty; the test imports ./protocol.js from source, so no dist/ is involved):

Mutation Expected Observed
A. drop the inheritedGrantObjects argument at the duplicate door 1, 3 red 1, 2, 3 red (2 gains the sys_comment finding)
B. derive inherited keys from the REWRITTEN copy instead of the stored row 2 red 2 red (renamed grant passes), 1/3/4 green
C. pass the import body's own keys as inheritedGrantObjects at the import door 4 red 4 red (import resolves, no 422)

A first attempt at C was a no-op refused by the tool (replacement contained the anchor; anchor count 1 → 1); re-run with a distinct replacement.

Verification

All on this branch; the code under test is identical from 83a51faa to the head (later commits: changeset wording, the engine-double ledger row, a merge of main).

  • New pins: pnpm --filter @objectstack/metadata-protocol exec vitest run src/protocol.copy-doors-inherited-grants.test.ts src/protocol.unknown-grant-object-refusal.test.ts on c718acd3 (after merging main at 7d7babb1): 23/23.
  • Package suite: pnpm --filter @objectstack/metadata-protocol test on c718acd3: Test Files 315 passed, 4 skipped; Tests 22410 passed, 26 skipped. pnpm --filter @objectstack/metadata-protocol typecheck: exit 0 (--listFiles includes the new test file).
  • Full dogfood (pnpm --filter @objectstack/dogfood test under the verify lock, closure built first, no shard): Test Files 419 passed, 3 skipped (422); Tests 3492 passed, 36 skipped (3528). Lock VERDICT command-exit 0, held 29m40s.
  • Derived gates (dispatch-gates.mjs --commands, 67 families on 4463c9f7): 66 exit 0, 1 NOT MEASURED — check:dual-build-cjs-loads exit 3, PREREQUISITE NOT MET (studio, client-react and five plugin/service packages have no dist/ in this worktree); left to CI. --ran reconciliation: "67 derived famil(ies) accounted for — 66 run, 1 NOT-MEASURED". check:engine-double-contract asked for the new test file's doubles to be recorded: --write added one seam row set, committed. After the merge, node scripts/check-engine-double-contract.mjs exit 0.
  • pnpm lint: exit 0 on 4463c9f7.

Main's known red (check-liveness query/searchFields, #30367 / PR #30368) is not touched by this diff.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (No spec change.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 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: n/a.
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English (the 维护者速读 block is the dispatch contract's Chinese summary).
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01Utp6CYSw4nSVJDr6XpcWLJ


Generated by Claude Code

… that grants on an optional plugin's object not installed here

The package-duplicate door now passes the source row's stored grant keys as
inheritedGrantObjects, as the permission-set clone door does. The unmanaged
import keeps judging every grant: its package is request input.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01Utp6CYSw4nSVJDr6XpcWLJ
@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 5, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#2 · os-bill · session_01Utp6Cbvcmv8YWFhFJwzjKL

维护者速读

席位核对 — ACCEPT · domain:server#2 · head c718acd3

Served-tier: TIER_DEFAULT (declaration face: Clause-②: no, Metadata-protocol: none, no packages/spec/** and no governed path). Implemented-by session_01Utp6CYSw4nSVJDr6XpcWLJ; Reviewed-by session_01Utp6Cbvcmv8YWFhFJwzjKL.

  • 形态: draft, author objectstack-fleet[bot] (relay pr_create), no assignee, no review request; 4 files, +308 −0, merged with main 7d7babb1; check-governed-merges --pr 30414: NOT governed (0 of 4 paths), 308 lines ≤ 3000.
  • Diff read (seat): at the package-duplicate door, inheritedGrantObjects is the objects keys of body, the SOURCE row as read from the store (before deepRewrite), passed only for singular === 'permission'; a key the rewrite renames onto the target namespace is not in that list and is judged by the save door as before. The unmanaged-import door passes none, with a comment naming the ruling (seat ruling on the card thread, 08:58Z: the import package is the request's body, so its sets are new writes). storedGrantObjectKeys restates the clone door's inheritedGrantObjectsOf because @objectstack/runtime depends on this package (no reverse import). scripts/engine-double-contract.pinned.json adds the new test file's three double verbs, as that gate requires (a file outside the claim's surface, accepted).
  • Declarations: Clause-②: no holds: a copy the clone door already accepts stops being refused at the sibling door; no export, error code or schema moves. Metadata-protocol: none; changeset patch for @objectstack/metadata-protocol, same two lines in body and changeset.
  • Pins: three duplicate-door cases (absent optional object copied; renamed grant onto a missing object still refused alone; source grant outside its namespace copied) and the import-door refusal with rollback. Dev: ablations A (argument dropped), B (keys from the rewritten copy), C (import fed the body) red then restored; package tests 22410 passed, typecheck 0, lint 0, full dogfood 419 / 3492 passed; derived gates 66/67 (dual-build-cjs-loads left to CI).
  • 门禁 check-runs: 9 success, 13 skipped, 15 in progress, 0 failed at ACCEPT; auto-merge waits on the required contexts.
  • 落地条款: Fixes Package duplicate and unmanaged import refuse a copied permission set that grants on an optional plugin's object not installed here (same 422 the clone door had, #30255) #30319 (both doors measured; the import door stays refused by ruling and is pinned). Ordinary queue landing by this seat: pr_ready + automerge_enable on this head.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 5, 2026 10:22
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 5, 2026 10:22
@github-actions

github-actions Bot commented Nov 5, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 1 package(s): @objectstack/metadata-protocol, touching 3 documentable anchor(s).

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

  • content/docs/releases/v18/18-3.mdx (via duplicatePackage (symbol, a method of class ProtocolPackageCommitsFacet))

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
  • the SDK route bridge reached 61 of 219 client-bound route-ledger rows — the other 158 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 158: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 103 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 6fa842af1e3137c93d7de2c823965c52fc5d524c → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 6fa842af1e3137c93d7de2c823965c52fc5d524c

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

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

1 participant