Skip to content

fix(plugin-security)!: a delegated business-unit subtree stays inside one organization, whether or not the caller's context names one - #31295

Merged
objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/sec-subtree-org-bound
Nov 8, 2026
Merged

objectstack-fleet[bot] merged 3 commits into
mainfrom
claude/sec-subtree-org-bound

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

security#1 · os-bob · session_012dn2AdqWnb3ndnEacKvJvF
Clause-②: no (narrowing)
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 delegated subtree's organization bound.

维护者速读

  • 改了什么:委派管理(adminScope)覆盖的业务单元子树只含一个组织的单元——调用方上下文指明组织时是该组织,未指明时是作用域根单元自己的组织;子树遍历的组织参数改为每个调用方必填。
  • 为什么改:落实规则「委派的业务单元子树永不跨越组织边界,无论调用方上下文是否指明组织」(安全加固,细节归 security#1 席)。
  • 风险与回滚:低。上下文指明组织时所有答案不变;回滚即 revert 本 PR(一个源文件、两个测试文件、一个 changeset)。
  • 先看:packages/plugins/plugin-security/src/delegated-admin-gate.ts(resolveSubtree 末行传入的组织界、resolveSubtreeById 的必填组织参数与逐行过滤、delegatorAnchorSubtree 的无组织早返回);delegated-admin-own-name-set.posture.test.ts 末尾的新 describe。
  • 两分钟验证:pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/delegated-admin-own-name-set.posture.test.ts src/delegated-admin-gate.test.ts,预期全部通过,其中新 describe 两个(三种部署形态各四例加 single 一例,桩引擎四例)。
  • 需要你做的:无,席位落地。

What changes

  • Rule. A delegated business-unit subtree never crosses an organization boundary, whether or not the caller's context names an organization. The subtree is the units of ONE organization — the caller's when its context names one (every answer unchanged), otherwise the scope root's own — and a unit stamped with another organization is outside it, as is every unit below it, even where its parent link names a unit inside the scope.
  • Structure. The subtree walk (resolveSubtreeById) now takes that organization as a required argument from every caller, so no caller can ask for an unbounded walk; it reads and keeps that organization's units only. The by-name scope path passes the caller's organization, else the root row's own. The self-delegation anchor path answers nothing for a context naming no organization (a holding takes effect only in its own organization, so there is no holding to anchor and no organization to bound a walk to), which is what it already answered.
  • An organization-less root (a store whose units carry no organization at all) keeps its organization-less descendants only: such a store's tree stays whole, and no stamped unit is reached from it or reaches it. The alternative, an organization-less root approving only itself, was measured (Verification) and not taken.
  • Every answer that reads the subtree follows, with no second traversal: the delegated business-unit read (the read door, canReadObject, getReadFilter, security/explain), assignment and direct-grant writes under the scope, describeDelegableScope and scopesCoverUser.
  • Rulings carried unchanged: ADR-0090 D12 (and its 2026-10-17 amendment, ruling of record 6228728551), rulings of record 5985885287, 6663849489 ("no unit outside the scopes the caller holds … A scope that cannot be resolved admits nothing (fail closed)"), 6649064874, and the ruling on RBAC + 组织架构权限:真实 UI 测试结论 — 后端判定全部正确,但「记录范围(readScope/writeScope)」在 Setup/Studio 无法配置与查看,另有 7 项管理体验缺口(待 PM 确认排期) #26059 Q3. Nothing here widens any of them; the refusal class for a unit outside the subtree stays 403 DELEGATION_SCOPE_VIOLATION.

Tests

  • delegated-admin-own-name-set.posture.test.ts (the posture rig: a real ObjectQL over a real SqlDriver with the real SecurityPlugin), new top-level describe, run in single, group and isolated: ground truth on the store; the gate's covered units, placeable units and user coverage, with and without an organization on the context; the read door; the write gate refusing an assignment anchored in, and a direct grant to a member of, another organization's unit with 403 DELEGATION_SCOPE_VIOLATION while admitting one inside the scope; and, under single with its Default Organization installed, the write door refusing and storing nothing, then storing the in-scope control.
  • delegated-admin-gate.test.ts, new top-level describe on the file's existing context-ignoring double: a stamped root and an organization-less root, each with a control that a unit of the root's own organization under the same link stays inside.
  • Rejections assert the envelope (code + status), never a bare throw; every refusal pin has an admitted control beside it.

Acceptance notes

  • No card: a security#1 no-card order. No Fixes line.
  • Clause-②: no (narrowing) confirmed against the diff: answers the gate gave for a unit outside its subtree's organization become refusals or omissions; no export, error code, status or authorable key is added.
  • Local scope per the dispatch contract: the package's own test and typecheck, the derived gate families, and the full dogfood battery (owed by the (narrowing) arm). The repo vitest project and the whole-repo build gates are CI's.
  • origin/main was merged once before this PR (merge base fe97d85b0); it has moved since with no change under packages/plugins/plugin-security/, so it is not merged again here.

Verification

Head 19f8d05ea. Every reading below names its run; restores are proven by blob hash against HEAD and an empty git diff HEAD.

Red, then green: the source file at the dispatch base, the tests at head (commit fbd64ad97)
  • Three gate test files (delegated-admin-gate.test.ts, delegated-admin-own-name-set.posture.test.ts, delegated-admin-gate-cross-organization.test.ts): 10 failed / 229 passed with the source at the dispatch base — only new rule pins red; every control and ground-truth case green.
  • Restored to HEAD: 239 / 239 passed.
Ablation: the walk's per-row organization guard deleted
  • 6 failed / 233 passed over the same three files; restored (blob equal to HEAD, empty diff): 239 / 239.
The organization-less root: the alternative bound, measured and not taken
  • An organization-less root approving only itself: 26 failed / 946 passed across the 20 test files of the package that exercise delegated scopes, all in the gate's own unit file (organization-less stores). Kept: organization-less descendants only. Restored (blob equal to HEAD).
Package, gates, dogfood
  • @objectstack/plugin-security full suite: 248 files passed; 5841 passed / 45 skipped.
  • @objectstack/plugin-security build and typecheck (tsc, the scripts project, and the test layer: 0 files / 0 errors in its debt ledger): exit 0. ESLint over the three changed source files: clean.
  • Derived gate families (dispatch-gates.mjs --commands, reconciled with --ran): 62 derived, 61 run at exit 0, 1 NOT MEASURED — check:dual-build-cjs-loads (PREREQUISITE NOT MET: it reads a whole-repo build; CI runs it). check:dts-closure and check:type-check-debt were re-run after a concurrent closure build and the lock queue respectively, both exit 0.
  • second-object-read-exposure.pin.test.ts (@objectstack/core, repo project): the diff adds no call of the reference-target arbiter; 4 / 4 passed.
  • Dogfood battery (pnpm --filter @objectstack/dogfood test, closure built first): 435 files passed / 3 skipped; 3609 passed / 41 skipped, exit 0.
  • Control-byte scan over the four changed files: no hits.

Generated by Claude Code

…one organization, whether or not the caller's context names one

The subtree a delegated adminScope covers is bounded to one organization:
the caller's when its context names one (unchanged), otherwise the scope
root's own. The walk now requires that bound from every caller, so no
caller can ask for an unbounded walk.

Pinned on the posture rig in all three postures (the gate's covered and
placeable units, its user coverage, the write gate, the read door, and
under `single` with its Default Organization the write door) and on the
gate's context-ignoring double for a stamped and an organization-less root.

Claude-Session: https://claude.ai/code/session_012dn2AdqWnb3ndnEacKvJvF
Co-authored-by: Claude <noreply@anthropic.com>
…ubtree stays inside one organization

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

github-actions Bot commented Nov 7, 2026

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

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

  • content/docs/permissions/delegated-administration.mdx (via DelegatedAdminGate (symbol, a top-level class))

⛔ 1 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))

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 63 of 226 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 7c523aa108650e48d19419ae9b76924c64707741 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 7c523aa108650e48d19419ae9b76924c64707741

⚠️ 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 7c523aa108650e48d19419ae9b76924c64707741 → 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

security#1 · os-bob · session_012dn2AdqWnb3ndnEacKvJvF
os-dev-report

{
  "issue": null,
  "status": "done",
  "branch": "claude/sec-subtree-org-bound",
  "pr": "https://github.com/objectstack-ai/objectstack/pull/31295",
  "session": "session_012dn2AdqWnb3ndnEacKvJvF",
  "premise_still_valid": true,
  "summary": "The delegated-administration gate now bounds every delegated business-unit subtree to ONE organization: the caller's when its context names one (unchanged), otherwise the scope root row's own; a unit stamped with another organization, and everything below it, is outside the subtree even where its parent link names a unit inside the scope. resolveSubtreeById takes that organization as a REQUIRED argument from every caller (string | null), reads in it and filters each child on it; resolveSubtree passes organizationId ?? rowOrganizationId(root); delegatorAnchorSubtree returns empty for a context naming no organization (unreachable before: activeHoldings already yields nothing there). One walk, no second traversal; every answer on the walk follows (scopedBusinessUnitIds -> the read door, canReadObject, getReadFilter, security/explain; assignment and direct-grant writes; describeDelegableScope; scopesCoverUser). Organization-less root: organization-less descendants only, chosen because failing closed reds 26 existing gate tests on organization-less stores and on a stamped single store (Default-Organization invariant) a null root never occurs. Clause-② confirmed: no (narrowing). Rulings carried unchanged: ADR-0090 D12 + 2026-10-17 amendment (6228728551), 5985885287, 6663849489, 6649064874, #26059 Q3; the one ⛔ hit in the file (unreadable catalog is not 'distributes nothing') is untouched. Deviations: merged origin/main once (fe97d85b0); main has since moved to 7c523aa10 with no change under packages/plugins/plugin-security, not re-merged (AGENTS §10). pr_create carries no assignees (AGENTS.md and fleet-write ops.mjs say a dev's create carries none; os-dev rule 2 says Account: rides pr_create) -- see open_questions. Commit trailers are AGENTS' model-free pair, not the harness reminder's model-named one. Coordinator resume notes described earlier states (rig edit already committed fbd64ad97 before the first pause; gate derivation already done before the second); resumed from the actual state.",
  "tests": "Head 19f8d05ea. New pins: posture rig (delegated-admin-own-name-set.posture.test.ts) top-level describe, 4 cases x single/group/isolated + 1 single-with-Default-Organization write-door case; gate double (delegated-admin-gate.test.ts) top-level describe, stamped and organization-less root x rule + control. Reverse verification (fbd64ad97; source at dispatch base 8ef4d3090, tests at head; restore blob == HEAD, git diff HEAD empty): 3 gate files 10 failed / 229 passed -- only new rule pins red, every control green; restored 239/239. Ablation via ablation-replace --delete of the per-row guard line: 6 failed / 233 passed, restored. Fail-closed variant for an organization-less root: 26 failed / 946 passed over the 20 delegated-scope test files (first attempt refused by ablation-replace, replacement contained the anchor; void, rerun). Full @objectstack/plugin-security suite on 19f8d05ea: 248 files passed, 5841 passed / 45 skipped (pre-merge fbd64ad97: 5837/45). build + typecheck (tsc, scripts project, test layer 0/0): exit 0. ESLint on the 3 source files: clean. Control-byte scan on 4 files: no hits. Not run locally: the vitest repo project (CI Test Core), except second-object-read-exposure.pin.test.ts: 4/4 (diff adds no referenceTargetOf call).",
  "gates": "dispatch-gates --commands --repo objectstack-ai/objectstack at 19f8d05ea: 62 derived; each run with exit captured before any pipe; --ran: 62 accounted, 61 run exit 0, 1 NOT MEASURED. NOT MEASURED: check:dual-build-cjs-loads (exit 3 PREREQUISITE NOT MET: reads a whole-repo build). Re-runs: check:dts-closure first exit 1 because a concurrent dogfood closure build had cleaned dist dirs, re-run after it: exit 0 (69 packages, 227/227 declarations); check:type-check-debt first exit 3 (lock queue-timeout behind my own dogfood hold), re-run under the lock: exit 0 (0 ledger entries, 0 raw errors). check-adr-0087-registration: 1 declared-breaking changeset with a not-required (no-migration-prescription) disposition. PR check-runs at 19f8d05ea when reported: Lint (7 jobs), Type Check (4 jobs), Check Changeset, Check PR Size, Governed Surface Queue Guard, PR-body guards, Flag docs affected, filter = in_progress; 18.x upgrade harness, Packed-tarball smoke, Schedule gate = skipped. Test Core / Build Core / UI jobs not yet listed.",
  "dogfood_battery": "19f8d05ea · os-verify-lock: VERDICT command-exit 0 (held 1849s; closure build VERDICT command-exit 0) · Test Files 435 passed | 3 skipped (438) · Tests 3609 passed | 41 skipped (3650) · no failures",
  "mcp_calls": "0",
  "api_writes": "2 -- relay strokes only (POST /repos/objectstack-ai/objectstack/dispatches each): pr_create -> POST /repos/objectstack-ai/objectstack/pulls (#31295, draft, no labels, no assignees); this report -> POST /repos/objectstack-ai/objectstack/issues/31295/comments via scripts/pm/post-stamped.mjs. git push (branch) not counted.",
  "open_questions": [
    {
      "question": "Who sets the PR assignee for a dev's pr_create? AGENTS.md (claim paragraph) and scripts/pm/fleet-write/ops.mjs say a dev's create carries no assignees and the seat sets it at hand-over; .claude/agents/os-dev.md rule 2 and its write-budget line say the claim's Account: rides pr_create.",
      "options": [
        "A: seat sets os-bob at hand-over (what was done: none set)",
        "B: amend os-dev.md to match AGENTS.md",
        "C: amend AGENTS.md and ops.mjs to match os-dev.md"
      ],
      "recommendation": "A now, plus B, because AGENTS.md declares it wins on conflict and the relay code already encodes it."
    }
  ],
  "security_findings": "withheld",
  "out_of_scope_findings": []
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#1 · os-bob · session_012dn2AdqWnb3ndnEacKvJvF

席位核对

ACCEPT · Head-sha: 19f8d05ea1ed84d485fcc2c9e9d99031fe94e18c · 2026-11-08T00:04Z

Contract-tier review (isolated reviewer, rule level): PASS-WITH-NITS at this head, no must-fix.

  1. Shape: four files: packages/plugins/plugin-security/src/delegated-admin-gate.ts, delegated-admin-gate.test.ts, delegated-admin-own-name-set.posture.test.ts, and one changeset (patch, ! banner, ADR-0087 not-required (no-migration-prescription)). No governed path. Draft, base main.
  2. Premise measured: red on main for the rule pins only, every control green (10 red / 229 green across the three gate test files); green on head (239/239). The per-row guard ablation reds 6. Full @objectstack/plugin-security suite on head: 5841 passed. Dogfood battery on head: 3609 passed, no failures.
  3. Rulings: ADR-0090 D12 and its amendment, rulings of record 5985885287, 6663849489 (with its fail-closed clause), 6649064874 and RBAC + 组织架构权限:真实 UI 测试结论 — 后端判定全部正确,但「记录范围(readScope/writeScope)」在 Setup/Studio 无法配置与查看,另有 7 项管理体验缺口(待 PM 确认排期) #26059 Q3 are byte-identical to main; the file's ⛔ line is untouched. With a caller organization, behaviour is unchanged (controls in single, group, isolated and single with the Default Organization).
  4. Gate check-runs on this head: 35 success, 13 skipped, 0 failed or pending. The skips are the UI, docs-build, opt-in harness, schedule-gate and matrix-placeholder jobs, which this diff does not reach (the filter job succeeded). check-expected-skips.mjs could not run in the seat's checkout (missing module), so the skip list was checked by hand.
  5. Accepted deviations: a business-unit tree whose root carries no organization keeps only organization-less descendants rather than failing closed (failing closed reds 26 existing tests on organization-less stores; a stamped single store cannot hold such a root). Whether such trees should be refused outright is a policy question for the maintainer, recorded on the seat, not decided here.
  6. Out of scope: two further items seen while fixing went privately to the security#1 seat and are on its ledger. Clause-②: no (narrowing), Metadata-protocol: none, Skills-docs: none.
  7. Landing: no governed path, so ready and auto-merge through the merge queue.

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review November 8, 2026 00:05
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge November 8, 2026 00:05
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit c1e08fe Nov 8, 2026
49 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/sec-subtree-org-bound branch November 8, 2026 01:26
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