Repository navigation
Commit 1366740
fix(plugin-security): every delegable-scope branch leaves out the built-in identity positions (#24826)
Fixes #24737
Clause-②: no
## What changed
`GET /security/my-delegable-scope` answers from
`DelegatedAdminGate.describeDelegableScope`
(`packages/plugins/plugin-security/src/delegated-admin-gate.ts`). Its
tenant-level branch and its delegated branch listed the four ADR-0068 D2
identity names (`platform_admin`, `org_owner`, `org_admin`,
`org_member`) in `assignablePositions`. `sys_user_position.position`
refuses those names from every writer with `400 VALIDATION_FAILED`, so
the invite dialog and Setup's position picker offered choices that could
only fail. The organization-level branch already skipped them through
the shared `isReservedIdentityName` predicate.
All three branches read one local listing, `allPositions()`. That
listing already left out the two audience anchors. It now also leaves
out the identity names, through the same `isReservedIdentityName`
predicate that the write's validation is generated from. The
organization-level branch's own copy of the skip is gone, because the
listing it reads now does the skip once. Its behaviour is unchanged.
Unchanged, as the card bounds it:
- the write path's refusal, and the reserved list
(`objects/reserved-identity-names.ts`);
- every other position in every branch;
- `placeableBusinessUnitIds`.
`packages/spec/**` and `packages/rest/**` are not touched.
## Why the shared listing, not a second copy (decision frame)
Option A applies the predicate once, in the listing all three branches
read. Option B adds a skip to each of the other two branch loops, which
makes three copies of one rule. Option C filters in the catalog reader
(`@objectstack/core`), which would also change the metadata door, and
that door is meant to list the built-ins.
- **Real business need.** The consumer is real and named on the card:
objectui `InviteMemberDialog.tsx` renders `assignablePositions`
verbatim. A and B serve it equally. C reaches surfaces with no such
need.
- **Long-term soundness.** A keeps one rule in one place inside the
report. A future fourth branch reads the same listing and inherits the
skip. B is the copy-per-branch shape that produced this defect: one
branch had the skip and two did not.
- **Making AI mistakes harder.** Under A, a new branch cannot forget the
skip, because there is nothing to remember. Under B, the next branch has
to know to add it.
- **No scope spread.** A is a one-line filter plus the deletion of a
copy. It adds no new gate, no new surface and no spec change.
Recommendation: A, which is what this PR implements.
## Pin
New:
`packages/plugins/plugin-security/src/delegable-scope-no-identity-positions.posture.test.ts`.
It runs on a real `ObjectQL` engine over a real `SqlDriver`, with the
real `SecurityPlugin` registered (its own declared built-in positions
included), in the postures `single`, `group` and `isolated`. There is
one enumerated case per branch: tenant-level (`admin_full_access`),
organization-level (`organization_admin`) and delegated (an `east_admin`
placing `adminScope`). Nine cases in total. Each case asserts:
- **ground truth:**
- the catalog this stack serves lists all four identity names and the
control position (otherwise the absence check would pass over a catalog
that never held them);
- the real write refuses each identity name from the same caller with
the ADR-0112 envelope `[400, VALIDATION_FAILED]` and stores nothing;
- **branch identity:** `isTenantAdmin` and the `scopes` set names show
which branch answered;
- **the rule:**
- `assignablePositions` contains none of the four names;
- the control position `field_rep` is still listed;
- every listed position is admitted by the real `sys_user_position`
insert (`{ status: 200 }`), and the stored row is read back.
This case is modelled on the PR #24793 suite (card #24736),
`delegated-admin-own-name-set.posture.test.ts`.
## Ablation (both legs at head `5e6b336871`, run under the shared verify
lock)
- **Leg 1:** the listing's new predicate is removed with
`scripts/ablation-replace.mjs`. Anchor `x1 -> x0`, blob `08da6da24c92 ->
616808d66e5d`.
- Result: `Tests 9 failed (9)`. All three branches go red, which shows
the one predicate now guards the organization-level branch too. First
failure: `platform_admin offered: expected [ 'platform_admin',
'org_owner', …(3) ] to not include 'platform_admin'`.
- Restored: blob `08da6da24c92` matches HEAD, and `git diff HEAD` is
empty.
- **Leg 2:** the whole gate file is put back at the base `6b222464ce`
(`git restore --source=BASE`, blob `2a202d1153`). This is the old
listing plus the organization-level branch's own copy.
- Result: `Tests 6 failed | 3 passed (9)`. The tenant-level and
delegated cases are red in all three postures, and the
organization-level cases are green. That is exactly the defect the card
reports.
- Restored with `git checkout HEAD -- PATH`: blob `08da6da24c92` matches
HEAD, `git diff HEAD` is empty, and `git status --porcelain` is empty.
## Verification (head `5e6b336871`)
- Closure build `pnpm --filter '@objectstack/plugin-security^...'
build`: `VERDICT command-exit 0`.
- New file alone: `Tests 9 passed (9)`, test time 634 ms (measured on a
shared box).
- `pnpm --filter @objectstack/plugin-security test`: `Test Files 194
passed (194)`, `Tests 4040 passed | 45 skipped (4085)`, `VERDICT
command-exit 0`.
- `pnpm --filter @objectstack/plugin-security typecheck`: `VERDICT
command-exit 0`. `tsc -p tsconfig.test.json --listFiles` lists the new
test file (1 hit).
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 68 families. All were run locally, each
exit captured before any pipe.
- `--ran` result: `68 derived famil(ies) accounted for — 66 run, 2
NOT-MEASURED`.
- NOT MEASURED locally: `check:dual-build-cjs-loads` and `check:i18n`,
each exit 3 `PREREQUISITE NOT MET`. They read whole-repo build output,
and this run built only the plugin-security closure. CI owns both
families.
- `test:repo` was not run locally. CI's `Test Core` runs it.
## Acceptance notes
- Two prose sentences outside this card's surface still say a
tenant-level admin's report enumerates "everything":
- the `DelegableScope.isTenantAdmin` TSDoc in
`packages/spec/src/contracts/security-service.ts`;
- `content/docs/permissions/delegated-administration.mdx` ("with
everything enumerated").
Both already excluded the audience anchors before this PR. This is
wording drift only, not a defect: no reader parses those sentences. This
PR's own `DelegableScopeReport` comment now says "everything the write
path admits". No carrier has been named for the two sentences.
- The branch is 3 commits behind `origin/main`. None of those commits
touches `plugin-security`, and CI tests the merge ref.
Related, for reference only: card #24136 and its PR #24732 (the
organization-level branch's skip), and card #24736 and its PR #24793
(the delegated walk's own-name set).
---
_Generated by [Claude
Code](https://claude.ai/code/session_011TdZ8GjixNZFLz1xJD9zzK)_
Co-authored-by: Claude <noreply@anthropic.com>1 parent 08d201a commit 1366740
3 files changed
Lines changed: 251 additions & 8 deletions
File tree
- .changeset
- packages/plugins/plugin-security/src
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
| 158 | + | |
| 159 | + | |
| 160 | + | |
| 161 | + | |
| 162 | + | |
| 163 | + | |
| 164 | + | |
| 165 | + | |
| 166 | + | |
| 167 | + | |
| 168 | + | |
| 169 | + | |
| 170 | + | |
| 171 | + | |
| 172 | + | |
| 173 | + | |
| 174 | + | |
| 175 | + | |
| 176 | + | |
| 177 | + | |
| 178 | + | |
| 179 | + | |
| 180 | + | |
| 181 | + | |
| 182 | + | |
| 183 | + | |
| 184 | + | |
| 185 | + | |
| 186 | + | |
| 187 | + | |
| 188 | + | |
| 189 | + | |
| 190 | + | |
| 191 | + | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 195 | + | |
| 196 | + | |
| 197 | + | |
| 198 | + | |
| 199 | + | |
| 200 | + | |
| 201 | + | |
| 202 | + | |
| 203 | + | |
| 204 | + | |
| 205 | + | |
| 206 | + | |
| 207 | + | |
| 208 | + | |
| 209 | + | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
| 216 | + | |
| 217 | + | |
| 218 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
224 | 224 | | |
225 | 225 | | |
226 | 226 | | |
227 | | - | |
| 227 | + | |
| 228 | + | |
| 229 | + | |
| 230 | + | |
| 231 | + | |
228 | 232 | | |
229 | 233 | | |
230 | 234 | | |
| |||
553 | 557 | | |
554 | 558 | | |
555 | 559 | | |
556 | | - | |
557 | | - | |
| 560 | + | |
| 561 | + | |
| 562 | + | |
| 563 | + | |
558 | 564 | | |
559 | 565 | | |
560 | 566 | | |
| |||
570 | 576 | | |
571 | 577 | | |
572 | 578 | | |
| 579 | + | |
| 580 | + | |
| 581 | + | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
573 | 588 | | |
574 | 589 | | |
575 | 590 | | |
576 | 591 | | |
577 | 592 | | |
578 | 593 | | |
579 | | - | |
| 594 | + | |
580 | 595 | | |
581 | 596 | | |
582 | 597 | | |
| |||
636 | 651 | | |
637 | 652 | | |
638 | 653 | | |
639 | | - | |
640 | | - | |
641 | | - | |
| 654 | + | |
| 655 | + | |
642 | 656 | | |
643 | 657 | | |
644 | 658 | | |
645 | 659 | | |
646 | 660 | | |
647 | | - | |
| 661 | + | |
648 | 662 | | |
649 | 663 | | |
650 | 664 | | |
| |||
0 commit comments