Skip to content

Commit c41b6ca

Browse files
docs(permissions): a three-officer split keeps the auditor's set outside the organization boundary (#34880)
Refs #34700 (item 2) Clause-②: no Metadata-protocol: none ## 维护者速读 - 改了什么:在委派管理文档里写明「三员分立」规则——审计员的权限集须带一个平台级能力,使其落在组织边界之外;并在 plugin-security 加 12 条真实引擎钉子测试。无源码改动。 - 为什么改:按维护者裁决 E,只写文档、不改契约;同时补一次裁决所欠的实测:委派管理员的白名单路径对这类权限集照旧放行或拒绝。 - 风险与回滚:只有文档与测试,运行时零变化;回滚即撤销本 PR。测试文件仍在原 20 秒预算内(按共享机比例推算 19.0 秒)。 - 先看:`content/docs/permissions/delegated-administration.mdx` 新增的「Separation of duties: the three-officer split」一节;其次是 `org-admin-assignment-boundary.posture.test.ts` 末尾新的 describe 及其期望矩阵 `OFFICER_EXPECTED`。 - 两分钟验证:`pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 src/org-admin-assignment-boundary.posture.test.ts -t three-officer`,预期 12 passed。 - 需要你做的:无,席位落地。 ## What changes - **Docs** (`content/docs/permissions/delegated-administration.mdx`): a new section, *Separation of duties: the three-officer split*, and one row in the gate table for the organization administrator's own right. The rule it teaches: in a three-officer split the auditor's set carries a platform-scoped capability, which keeps it outside the organization boundary, so only a delegated scope whose allowlist names the set, or the platform administrator, adds or removes its holders. It lists the four boundary conditions (ADR-0090 D12, as amended), shows an app-declared capability (whose `scope` defaults to `platform`) and the built-in `setup.access` as the two ways to carry one, and states the ceiling: the platform administrator can still assign any set, the auditor's included. - **Tests** (`packages/plugins/plugin-security/src/org-admin-assignment-boundary.posture.test.ts`): a new top-level describe in the existing posture harness (real ObjectQL engine over a real SQL driver, real `SecurityPlugin`, the protocol's bulk delete door), postures `single` and `isolated`. Three auditor variants (org-scoped only, plus `setup.access`, plus an app-declared capability) against six callers, four write shapes each (a direct grant, its removal by id, its removal through the bulk delete door, a position holding added and removed). No source file changes. ## Tests The expected matrix, every cell asserted on its ADR-0112 envelope and on the stored rows: | Caller | + `setup.access` | + app-declared capability | |---|---|---| | organization administrator (both sets) | `403 PERMISSION_DENIED`, naming the set | `403 PERMISSION_DENIED`, naming the set | | delegate whose allowlist leaves the auditor set out | `403 DELEGATION_SCOPE_VIOLATION` | same | | the same delegate, also an organization administrator | `403 DELEGATION_SCOPE_VIOLATION` | same | | delegate whose allowlist names the auditor set, with or without the organization administrator's set | admitted | admitted | The control variant, an auditor set carrying only the org-scoped `view_all_audit_log`, sits inside the boundary and is judged by the organization administrator's right as ADR-0090 D12 (as amended) states it, and by the allowlist on the delegated path; it proves each refusal above is caused by the platform-scoped capability. The last two rows are the owed measurement: the delegated allowlist path admits and refuses a set carrying a platform-scoped capability exactly as it does the org-scoped one. <details><summary>Run on head 4dc3566</summary> ``` pnpm --filter @objectstack/plugin-security exec vitest run --maxWorkers=2 --reporter=verbose src/org-admin-assignment-boundary.posture.test.ts Test Files 1 passed (1) Tests 104 passed (104) os-verify-lock: VERDICT command-exit 0 pnpm --filter @objectstack/plugin-security typecheck (tsc, scripts project, check:test-typecheck) check:test-typecheck: OK — 0 file(s) / 0 error(s) os-verify-lock: VERDICT command-exit 0 ``` </details> <details><summary>Mutation proof (one-off, restored)</summary> The boundary's capability-scope condition was disabled in place (`scripts/ablation-replace.mjs`, anchor hit 1 time, blob changed) and only the new describe was run: 6 failed, 6 passed — exactly the cases whose caller holds the organization administrator's set; the pure-delegate cases stayed green, as the matrix predicts. Restored: blob equals HEAD and `git diff HEAD` is empty. </details> <details><summary>Test budget</summary> The file keeps `test-budget: 20`. On one shared box the tests phase reads 29.0 s with the new cases and 20.8 s without them (ratio 1.39); the twelve cases share one boot per posture and remove every row each wrote. The last CI reading, 10.9 s, projects to 15.2 s, 19.0 s with the 1.25 headroom. The REASON line carries this reading. </details> ## Acceptance notes - Two existing docs lines predate the ADR-0090 D12 amendment and still say the organization administrator's set is read-only on the RBAC tables: `content/docs/permissions/authorization.mdx` (the anti-escalation paragraph) and the `organization_admin` row of the built-in sets table in `content/docs/permissions/permission-sets.mdx`. The shipped set grants create and delete on both assignment tables. Not changed here; noted for the docs lane. - No changeset: the diff is a docs page and a test file; `plugin-security` publishes `dist`, `README.md` and `CHANGELOG.md` only, so nothing a package ships changes (`skip-changeset`). ## Verification <details><summary>Local gate subset (dispatch-gates --commands, head 4dc3566)</summary> - `node scripts/pm/dispatch-gates.mjs --commands` derived 85 families for the 2 changed paths (the list is identical after a fresh fetch of `origin/main`). Ran all 85 with exit codes captured before any pipe: 81 exit 0, 4 exit 3 (prerequisite not met, read as NOT MEASURED, left to CI): - `node scripts/check-plugin-teardown-shape.mjs --self-test`: its positive control is pinned to a commit this shallow clone cannot reach; - `pnpm --filter @objectstack/spec run check:skill-examples`, `pnpm check:dual-build-cjs-loads`, `pnpm check:i18n`: each reads built output of packages outside this diff's build closure. - `dispatch-gates --ran` with the exit-annotated record: `85 derived famil(ies) accounted for — 81 run, 4 NOT-MEASURED (4 DERIVED from a recorded exit 3)`. - The last commit (ee854bc) changes one docs paragraph only; the 41 derived families that read docs, ADR links, citations and wording were re-run on it: 41 of 41 exit 0. The test file is unchanged since 4dc3566, where it ran. - Every family CI runs is read from this PR's check-runs, not re-run here. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_012MmDsQg43GaB78K8X6U1sL)_ --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent 0ee43d6 commit c41b6ca

2 files changed

Lines changed: 259 additions & 10 deletions

File tree

‎content/docs/permissions/delegated-administration.mdx‎

Lines changed: 69 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,13 +81,82 @@ set, and the gate resolves the name in the security catalog. The gate's rules:
8181
| Tenant-level assets stay tenant-level | The `everyone`/`guest` audience anchors and security-domain publishes are untouchable from any delegated scope |
8282
| Membership is not delegable | `sys_member` writes are tenant-admin-only: no `adminScope` axis expresses org membership, and an admin-grade membership row is auto-elevated to `organization_admin` — writing one would mint a tenant admin. Adding people *is* delegable, through an [invitation](#letting-a-delegate-invite-delegated_admin) |
8383
| No scope, no admin | Holders of plain CRUD on the RBAC tables with **no** scope are refused: administration is a scoped capability now, not a side effect of table access |
84+
| Organization administrators assign inside the boundary | A holder of `organization_admin` or `organization_admin_no_bypass` for the organization creates and removes its own members' assignment rows — never edits one in place — when every set the row distributes is inside the [organization boundary](#separation-of-duties-the-three-officer-split); outside it, a scope it also holds judges the write as for any delegate |
8485

8586
The showcase permission zoo exercises the gate end-to-end
8687
(`packages/qa/dogfood/test/showcase-permission-zoo.dogfood.test.ts`): the
8788
in-subtree allowlisted assignment passes with a `granted_by` stamp; the
8889
out-of-subtree anchor and the off-allowlist grant (to self) are each
8990
refused.
9091

92+
## Separation of duties: the three-officer split
93+
94+
Some deployments split administration between three officers whose powers do
95+
not overlap: a system administrator who runs the deployment, a security
96+
administrator who decides who holds what, and an auditor who reads the
97+
compliance ledger (`view_all_audit_log`) and is appointed and removed by
98+
neither of the other two. The platform ships no officer sets — you author all
99+
three as ordinary permission sets, and the security administrator's set is a
100+
delegated scope like the one above, whose allowlist leaves out the auditor's
101+
set.
102+
103+
That allowlist bounds the delegated path only. An **organization
104+
administrator** — a holder of `organization_admin` or
105+
`organization_admin_no_bypass` for the organization, which an owner- or
106+
admin-grade membership confers — has a right of its own (ADR-0090 D12, as
107+
amended): it creates and removes its organization's assignment rows for any
108+
set inside the **organization boundary**. A set is inside when all four hold:
109+
110+
1. its `objects['*']` entry carries neither `viewAllRecords` nor `modifyAllRecords`;
111+
2. it carries no `adminScope`;
112+
3. every capability in its `systemPermissions` is declared `scope: 'org'`;
113+
4. it is not one of the sets kept outside by name (`admin_full_access`, the
114+
two organization-administrator sets, the agent ceilings).
115+
116+
`view_all_audit_log` is declared `scope: 'org'`, so an auditor set built from
117+
it alone is inside the boundary, and every organization administrator can
118+
change who holds it.
119+
120+
**Rule: in a three-officer split, the auditor's set carries a platform-scoped
121+
capability.** One capability that is not declared `scope: 'org'` puts the set
122+
outside the organization boundary. From then on only a delegated scope whose
123+
allowlist names the set, or the platform administrator, adds or removes its
124+
holders — by a direct grant, by a position that distributes it, by a removal
125+
by id or through the bulk delete door alike. A capability your app declares is
126+
platform-scoped unless it says otherwise:
127+
128+
```typescript
129+
export const AuditOfficer = defineCapability({
130+
name: 'audit_officer',
131+
label: 'Audit Officer',
132+
description: 'Marks the auditor officer set: keeps it outside the organization boundary.',
133+
// scope defaults to 'platform'
134+
});
135+
136+
export const Auditor = definePermissionSet({
137+
name: 'auditor',
138+
label: 'Auditor',
139+
systemPermissions: ['view_all_audit_log', 'audit_officer'],
140+
objects: { sys_audit_log: { allowRead: true } },
141+
});
142+
```
143+
144+
A built-in platform-scoped capability the auditor needs anyway, such as
145+
`setup.access` to reach Setup, serves the same way. What does not change:
146+
147+
- **The delegated path judges the set as before.** A scope whose allowlist
148+
names the auditor's set — the auditor's own administrator — still assigns
149+
and removes it, whether or not its holder is also an organization
150+
administrator; a scope whose allowlist leaves it out is still refused
151+
`403 DELEGATION_SCOPE_VIOLATION`.
152+
- **An organization administrator is refused** unless a scope it holds
153+
allowlists the set: `403 PERMISSION_DENIED`, naming the set and the boundary
154+
condition it fails — or, when it also holds a delegated scope that leaves the
155+
set out, that scope's `403 DELEGATION_SCOPE_VIOLATION`.
156+
- **The ceiling.** The platform administrator (`admin_full_access`) can still
157+
assign any set, the auditor's included. The split separates the officers
158+
below that ceiling; it does not bind the platform administrator.
159+
91160
## The assignment anchor
92161

93162
Positions never bind to a business unit at the *definition* level — that

0 commit comments

Comments
 (0)