Skip to content

fix(plugin-security)!: a delegated business-unit walk never starts at a unit outside the caller's organization - #31442

Merged
objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/sec-delegated-root-in-organization
Nov 8, 2026
Merged

objectstack-fleet[bot] merged 6 commits into
mainfrom
claude/sec-delegated-root-in-organization

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Clause-②: no (narrowing) — the delegated-administration gate holds the root of every delegated business-unit walk to the same organization as its descendants, so the range a self-delegation's anchor is judged against holds units of the caller's organization only. Nothing is widened: no export, error code or status is added.
Metadata-protocol: none
Skills-docs: none — a runtime authorization bound inside @objectstack/plugin-security; no authorable key, value or metadata type changes, and no skills/** or docs page teaches the self-delegation anchor range's organization bound.

维护者速读

  • 改了什么:委派管理按业务单元圈定的范围,其起点(根单元)与下级单元同一条规则:只能是调用者所在组织的单元。
  • 为什么改:ADR-0105 D6 红线 2 —— 一切业务单元机制只在一个组织内运作,没有跨组织的树;委派范围里的每个单元(含根)都属于调用者的组织。
  • 风险与回滚:只动 plugin-security 的委派管理闸门;组织内范围里的锚点、不带锚点的职务代理照旧通过,拒绝的答复与范围外锚点一致。按先例 c1e08fe 声明为收窄(BREAKING,patch 级):锚在本组织之外单元的自我委派从此被拒。回滚 = revert 本 PR。
  • 先看:packages/plugins/plugin-security/src/delegated-admin-gate.ts 的 resolveSubtreeById(根判定那一段);再看两个测试文件末尾新增的 describe。
  • 两分钟验证:pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/delegated-admin-own-name-set.posture.test.ts -t "never starts at a unit outside",预期 Tests 15 passed。
  • 需要你做的:无,席位落地。

What changes

Rule (ADR-0105 D6, red line 2: "Every BU mechanism — unit_and_subordinates sharing, adminScope delegation, depth scopes — operates within one organization. There is no cross-org tree."): a delegated business-unit walk never starts at a unit outside the caller's organization.

  • DelegatedAdminGate.resolveSubtreeById reads the walk's root under the bound organization's own scoped context and applies to it the same row predicate the walk already applies to every descendant. A root that is not a unit of that organization covers nothing.
  • Every subtree a self-delegation's anchor range is built from (ADR-0091 D3, rule 4b) therefore holds units of the caller's organization only. An anchor outside the range is refused with 403 PERMISSION_DENIED, the same answer whichever organization the unit belongs to.
  • resolveSubtree (a scope's by-name anchor) keeps its answers: its root is already resolved inside the organization, so the new predicate holds for it by construction. It gains one by-id read per resolved scope.
  • No refusal text, error code, schema or export changes.

Tests

  • delegated-admin-own-name-set.posture.test.ts, new describe a delegated business-unit walk never starts at a unit outside the caller's organization, on a real ObjectQL engine and SqlDriver with the real SecurityPlugin, in single, group and isolated (5 tests per posture, 15 in all):
    • an unanchored holding's range is the delegator's member units of its own organization; an anchor at a unit of another organization gets the same answer as an anchor outside the range;
    • a holding anchored at a unit of another organization makes no unit an admitted anchor;
    • CONTROL: a holding anchored at a unit of the caller's organization keeps its subtree as the range;
    • the data door stores no delegation anchored at a unit of another organization, and stores one inside the range;
    • CONTROLS throughout: an in-organization anchor inside the range is admitted, and so is an unanchored delegation.
  • delegated-admin-gate.test.ts, new describe on a double that scopes nothing, so the row predicate is the only thing standing: 3 tests, one of them a CONTROL, including an organization-less unit.
  • The posture rig's boot takes optional extra catalog entries, so the new describe's delegatable position does not change what the other describes enumerate.

Acceptance notes

  • Not added: a second anchor check in the self-delegation rule. Once every root is held to the organization predicate it is redundant, and a refusal reason of its own would answer ids that are units of the caller's organization differently from other ids.
  • Untouched, as ordered: the by-name root for a context that names no organization, with its docblocks and pins. The existing pins on the subtree staying inside one organization, with or without an organization on the context, hold unchanged.

Verification

Readings at 3de01b6fb unless stated. The final head b731e114b changes only the changeset (the narrowing declaration, its BREAKING paragraph and the ADR-0087 marker).

  • Dogfood battery at b731e114b: lock VERDICT command-exit 0, Test Files 438 passed | 3 skipped (441), Tests 3622 passed | 41 skipped (3663), no failures.
Package suite and typecheck
  • pnpm --filter @objectstack/plugin-security test: Test Files 249 passed (249), Tests 5886 passed | 45 skipped (5931), lock VERDICT command-exit 0.
  • pnpm --filter @objectstack/plugin-security typecheck: exit 0 (tsc src and scripts, plus check:test-typecheck OK).
  • These two ran at cf5c2456c. The commit after it changes only the changeset's declaration line.
Ablation (one-time, nothing left in the tree)
  • Mutation: the root predicate is removed on disk through scripts/ablation-replace.mjs (anchor hits 1 → 0, blob 4cd4659e28e4 → e0c1deb04f78). The subject resolves through relative src imports, so no dist is in the path.
  • With it removed, the two files report Tests 11 failed | 242 passed (253): the 9 posture legs (3 per posture) and the 2 fake-engine pins that are not controls. Every CONTROL stayed green.
  • Restored: the blob equals the one at HEAD (4cd4659e28e4) and git diff HEAD is empty. The same files then report Tests 253 passed (253).
Derived gates
  • node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack at 3de01b6fb: 66 commands. Each ran from the worktree, with its exit code captured before any pipe: 66 of 66 exit 0.
  • --ran reconciliation: 66 derived, 66 run, 0 NOT-MEASURED, 0 UNRUN (a derived zero: every line records its exit code).
  • At cf5c2456c, the first sweep had check:dual-build-cjs-loads and check:i18n refuse their prerequisite (exit 3, missing dist). After building the closure that check:i18n names, both measure green on the head re-run: 122 require entry points across 72 packages load, and 10 packages' bundles are in sync.
  • Changeset gates on the final changeset: check-adr-0087-registration, check-changeset-no-major and check-empty-changeset (all --base origin/main) exit 0, and so does check:nul-bytes.
  • Every family CI runs is read from this PR's check-runs. None of them is re-run locally.

…a unit outside the caller's organization

ADR-0105 D6 red line 2: every BU mechanism operates within one
organization. The walk's root is now held to the same organization
predicate as its descendants.

Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f
Co-authored-by: Claude <noreply@anthropic.com>
… a unit outside the caller's organization

Posture rig (single, group, isolated) at the gate and the data door,
and a fake-engine pin on a driver that scopes nothing.

Claude-Session: https://claude.ai/code/session_017xRBcT1w3zpekijraHJE4f
Co-authored-by: Claude <noreply@anthropic.com>
…root-in-organization

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

github-actions Bot commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

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

  • content/docs/automation/approvals.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/permissions/administrator-guide.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/permissions/authorization.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/permissions/delegated-administration.mdx (via DelegatedAdminGate (symbol, a top-level class), sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/permissions/permissions-matrix.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/permissions/positions.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/permissions/sharing-rules.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/protocol/objectql/security.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))

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

  • content/docs/releases/v13.mdx (via DelegatedAdminGate (symbol, a top-level class), sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/releases/v16.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/releases/v17/17-4.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))
  • content/docs/releases/v18/18-3.mdx (via sys_business_unit (literal, a string literal in resolveSubtreeById))

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 64 of 227 client-bound route-ledger rows — the other 163 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 163: 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; 104 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 — 17 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 37e2c14b9769b11457e9aaaba6f57b139f1b85ba → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 37e2c14b9769b11457e9aaaba6f57b139f1b85ba

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

@objectstack-fleet objectstack-fleet Bot changed the title fix(plugin-security): a delegated business-unit walk never starts at a unit outside the caller's organization fix(plugin-security)!: a delegated business-unit walk never starts at a unit outside the caller's organization Nov 8, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · sunhaolin · session_017xRBcT1w3zpekijraHJE4f

席位核对

ACCEPT at Head-sha: b731e114b69db52714ab7141753c827c142ef7c5 (2026-11-08T09:14Z).

  • Shape: a no-card order from the security#1 seat, in two rounds. Round 2 changed only the declaration. 4 files, +261 / −6. Not governed (check-governed-merges.mjs --pr 31442: 0 of 4 paths). Clause-②: no (narrowing) with BREAKING, following the precedent c1e08fe, which enforced the same ADR-0105 D6 red line for the same walk's descendants. Metadata-protocol: none · Skills-docs: none. Patch level. The title carries !.
  • Premise measured: at the gate and at the data door, in single, group and isolated, a self-delegation anchored outside the caller's organization is now refused with the same answer as an anchor outside the delegator's range, and nothing is stored. The in-range and unanchored controls are admitted. The ablation turned 11 tests red, every control stayed green, and the file was restored.
  • Gates: 48 check-runs on this head, each success or skipped. The body-guard checks re-run after the seat's body rewrite. The changeset gates (check-adr-0087-registration reads [BREAKING+bang+clause-②-narrowing] not-required (no-migration-prescription)), check-changeset-no-major and check-empty-changeset exit 0. The derived union ran 66 of 66 at the round-1 head; round 2 is changeset-only. Dogfood battery at this head: VERDICT command-exit 0, Test Files 438 passed, Tests 3622 passed, 0 failures.
  • Accepted deviations: the optional second anchor check was not added (a reason of its own would answer in-organization ids differently); one extra by-id root read per resolved scope; the 6-of-66 local union after the container restart is covered by the round-1 run and a changeset-only delta.
  • Out of scope: the organization-less by-name root stays with the maintainer's ruling and the follow-up order.
  • Landing: the seat lands it through the merge queue (pr_ready + automerge_enable).

Implemented-by: os-dev (security#1 order, session_017xRBcT1w3zpekijraHJE4f) · Reviewed-by: isolated contract-tier reviewer, PASS-WITH-OBJECTIONS; its one objection (the narrowing declaration) is resolved in this head.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 8, 2026 09:15
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 8, 2026 09:15
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit 669a8aa Nov 8, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/sec-delegated-root-in-organization branch November 8, 2026 09:38
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

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

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants