Repository navigation
fix(plugin-security)!: a delegated business-unit subtree stays inside one organization, whether or not the caller's context names one - #31295
Conversation
…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>
📓 Docs Drift CheckThis PR changes 1 package(s): 1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:
⛔ 1 release-owned page(s) also name something this change touched. These are read-only:
What this run could not see
Coarse fallback — 17 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): Which tree this was computed onThis run read A worktree cut from an older # 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
|
|
security#1 · os-bob · session_012dn2AdqWnb3ndnEacKvJvF {
"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": []
} |
|
security#1 · os-bob · session_012dn2AdqWnb3ndnEacKvJvF 席位核对ACCEPT · Head-sha: Contract-tier review (isolated reviewer, rule level): PASS-WITH-NITS at this head, no must-fix.
|
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 noskills/**or docs page teaches the delegated subtree's organization bound.维护者速读
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
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.canReadObject,getReadFilter,security/explain), assignment and direct-grant writes under the scope,describeDelegableScopeandscopesCoverUser.403 DELEGATION_SCOPE_VIOLATION.Tests
delegated-admin-own-name-set.posture.test.ts(the posture rig: a realObjectQLover a realSqlDriverwith the realSecurityPlugin), new top-level describe, run insingle,groupandisolated: 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 with403 DELEGATION_SCOPE_VIOLATIONwhile admitting one inside the scope; and, undersinglewith 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.code+status), never a bare throw; every refusal pin has an admitted control beside it.Acceptance notes
security#1no-card order. NoFixesline.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.testandtypecheck, the derived gate families, and the full dogfood battery (owed by the(narrowing)arm). Therepovitest project and the whole-repo build gates are CI's.origin/mainwas merged once before this PR (merge basefe97d85b0); it has moved since with no change underpackages/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 againstHEADand an emptygit diff HEAD.Red, then green: the source file at the dispatch base, the tests at head (commit
fbd64ad97)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.HEAD: 239 / 239 passed.Ablation: the walk's per-row organization guard deleted
HEAD, empty diff): 239 / 239.The organization-less root: the alternative bound, measured and not taken
HEAD).Package, gates, dogfood
@objectstack/plugin-securityfull suite: 248 files passed; 5841 passed / 45 skipped.@objectstack/plugin-securitybuildandtypecheck(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.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-closureandcheck:type-check-debtwere re-run after a concurrent closure build and the lock queue respectively, both exit 0.second-object-read-exposure.pin.test.ts(@objectstack/core,repoproject): the diff adds no call of the reference-target arbiter; 4 / 4 passed.pnpm --filter @objectstack/dogfood test, closure built first): 435 files passed / 3 skipped; 3609 passed / 41 skipped, exit 0.Generated by Claude Code