Repository navigation
Commit 27b3f1f
feat: the position list says who holds each position and which permission sets it grants (#25369)
<!-- claude-projects-attribution: {"github_login":"os-tesla"} -->
_Requested by **Tesla** · [project
thread](https://claude.ai/code/project/chan_01AXsQkLFKRdQCqQ3RTr6Jao?thread=cmsg_01AXsQkLFKRdQCqQ3RTr6JaoWnNJDmFSk7m68Yejj9bevh)_
Fixes #25333
Clause-②: yes (widening)
Metadata-protocol: none
## What
Setup → Positions can now say who holds each position and which
permission sets it grants. Both answers come from the rules the
authorization resolver enforces with. They are not a second copy of
those rules.
- `GET /meta/position?include=grants` adds two read-only keys to each
position: `_holderCount` and `_grantedPermissionSets: [{ name, via }]`.
Both transports serve it, through the shared list chain
(`createMetaListAnswer`). Without `?include=grants`, the list is
byte-for-byte unchanged, so the pickers and assignment pages that read
it pay no extra read.
- `via: 'definition'` marks a set the position's `permissionSets` names.
`via: 'name'` marks the set that shares the position's name, which the
position-name fold grants although the definition does not list it. That
is the set #24757 found in force and invisible. The fold's retirement is
on hold, so the list shows it rather than hiding a grant that is live.
- `_holderCount` counts holders in the caller's active organization by
the rule the resolver uses to give a caller positions:
`sys_user_position` rows in their validity window, membership roles, and
`everyone` for every active member. A switched-off position keeps its
holders (ADR-0049). The count is `null`, never `0`, in these cases:
- there is no active organization;
- the position is `platform_admin` or `guest`;
- the read was truncated;
- the caller may not read `sys_user_position`.
## How
- **`@objectstack/core`.** Two readers are lifted out of
`resolveUserAuthzGrants`: `readPositionGrantsInForce` (the §6a rule: the
definition's sets in force, with disabled positions and sets dropped)
and `countPositionHolders`, which uses the §3/§4 holding rule through
the shared `heldPositionNames`. The resolver now calls the same helpers
and resolves exactly what it resolved before; the core security suite is
green.
- **`@objectstack/spec`.** `ISecurityService` gains the optional
`describePositionGrants(positions, context)` and its
`PositionGrantSummary` type. A security service without it serves the
list undecorated, never with empty values.
- **`@objectstack/plugin-security`.** It serves `describePositionGrants`
by running the evaluator's own `resolvePermissionSets` plus
`dropDeactivatedFoldedSets` over `[position, ...declared]`, the same
steps `resolvePermissionSetsForContext` takes. The holder count is gated
on `canReadObject('sys_user_position', context)`.
- **`@objectstack/rest`.** Step 8 of `createMetaListAnswer` decorates a
`position` list when asked with `include=grants`. An anonymous caller,
or a service without the method, gets the list unchanged.
## Acceptance (the card's *Done when*)
- **Holder count and sets per row.** Served as above. The console half
(the columns and the whole-row click) is objectstack-ai/objectui's own
draft PR on the same branch name, `claude/project-thread-kuevbz`.
- **Matches what the server enforces.** This is pinned as agreement, not
as the reader's own output:
- `position-catalog-readers.test.ts` checks that, user by user,
`countPositionHolders` counts a user for P exactly when
`resolveUserAuthzGrants` gives that user P, and that a position's sets
in force are exactly what the resolver grants a holder of it alone.
- `describe-position-grants.test.ts` checks that each described
position's sets equal `resolvePermissionSetsForContext` for a holder of
that position alone, the same-named set included.
- **Same-named set case.** `sales_manager` lists `crm_sales_user` and
`forecasting` (`via: 'definition'`) and `sales_manager` (`via: 'name'`).
Three controls go with it:
- a set declared under the position's own name is a declaration, not a
fold;
- a fold whose set is switched off grants nothing;
- `guest` folds nothing.
- **Both transports.** `meta-list-projection-parity.test.ts` runs the
`?include=grants` probe through RestServer and the runtime dispatcher.
## Ablations
Each was run with `scripts/ablation-replace.mjs` and restored to the
HEAD blob.
- Removing the fold from `describePositionGrants` turns 2 tests red.
- Removing the `canReadObject` gate on the holder count turns 1 test red
(the null-for-a-member-without-the-read case).
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01K9LFkQaGHiensHNgGGgKvD
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent ee63b47 commit 27b3f1f
12 files changed
Lines changed: 783 additions & 26 deletions
File tree
- .changeset
- packages
- core/src/security
- plugins/plugin-security/src
- rest/src
- runtime/src/domains
- spec
- api-surface
- export-origins
- src/contracts
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
207 | 207 | | |
208 | 208 | | |
209 | 209 | | |
| 210 | + | |
| 211 | + | |
| 212 | + | |
| 213 | + | |
| 214 | + | |
| 215 | + | |
210 | 216 | | |
211 | 217 | | |
212 | 218 | | |
| |||
| 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 | + | |
0 commit comments