Repository navigation
Commit 8fed00f
fix(platform-objects): Create User picks its permission set from a list, and a refused grant says in one line what to pick (#30701)
<!-- claude-projects-attribution: {"github_login":"os-elon-musk"} -->
_Requested by **Elon** · [project
thread](https://claude.ai/code/project/chan_01WedDzV26nniwxv7jC88B9D?thread=cmsg_01WedDzV26nniwxv7jC88B9DQWVv1Nxj3V5PkJPEMmeSk4)_
domain:server#3 · os-elon-musk · session_016WV4cwFtiPisvhAkegNCLQ
Fixes #30117
Clause-②: no (no new export, error code, accept set or schema key: a
platform-objects param uses the existing `ActionParamSchema.widget`; the
refusal keeps `400 VALIDATION_FAILED` / `reference_not_found`, only its
sentence changes)
Metadata-protocol: none
## 维护者速读
- 改了什么:「新建用户」的「权限集」从只认机器名的空文本框,改成按标签列出权限集的可搜索下拉(`widget:
'permission-ref'`,就是授权表本身用的选择器);Studio 的动作预览也画成下拉,和真实对话框一致。
- 拒绝提示:原来是一大段开发者说明;现在是一句业务话。输入的是某个权限集的标签时,直接说出它的名称,例如 "'Repair
Technician' is the label of the permission set named
'asset_repair_technician': choose it from the list, or enter
'asset_repair_technician'.";同一句话覆盖所有授权路径(Setup 的授权表单与新建用户)。
- 不变的:依旧只接受名称,不接受标签;拒绝依旧是原子的,不会留下用户;状态码与错误码不变。
- 边界:只提示调用者能授予的集合;代理上限权限集(MCP agent)从不提示;非租户级管理员先被委托管理闸门拒绝,听不到任何集合名。
- 先看:`grant-permission-set-name.ts` 的 `grantSetNotInCatalogMessage` /
`setsLabelled`,`sys-user.object.ts` 的 `permissionSet`
参数,`ActionPreview.tsx` 的 `runtimeWidgetFor`。
- 需要你做的:无,席位在 CI 绿后按落地授权落地。
## What changes
- **`packages/platform-objects/src/identity/sys-user.object.ts`.**
`create_user`'s inline `permissionSet` param adds `widget:
'permission-ref'` and keeps `type: 'text'`: the action dialog (since
#30260) draws the grant column's own picker, a searchable list of the
permission sets each shown by its label, submitting the chosen set's
name. The stale comment "its picker is a widget hint params do not
inherit" is retired. The param stays inline, so the dialog never needs
plugin-security metadata to open.
-
**`ui/packages/app-shell/src/views/metadata-admin/previews/ActionPreview.tsx`.**
`runtimeWidgetFor` now asks `paramToField` itself (with the authored
`widget`) which widget the dialog draws, instead of
`resolveParamWidgetType(type)`, so the preview's answer is
`authoredWidgetKey(param) ?? resolveParamWidgetType(type)`, the dialog's
expression, by construction (note 6662463937 line 2). A `permission-ref`
answer is mocked as a disabled picker ("Select LABEL"); an unregistered
widget name degrades to the `type` control, as in the dialog.
`paramToField.ts` is not edited.
-
**`packages/plugins/plugin-security/src/grant-permission-set-name.ts`.**
The shared refusal sentence (`grantSetNotInCatalogMessage`) is one line:
- the refused value is one set's label (trimmed, any case): `'Repair
Technician' is the label of the permission set named
'asset_repair_technician': choose it from the list, or enter
'asset_repair_technician'.`
- a label several sets carry: they are listed, none is picked;
- otherwise: `There is no permission set named 'xyz': choose one from
the list.`
The catalog is listed only on a refusal (`setsLabelled`); agent ceiling
sets (`MCP_AGENT_PERMISSION_SETS`) are never suggested, the same
exclusion the picker makes; a listing that throws leaves the plain
sentence and is reported at `warn`. A label is still never accepted as a
name.
- **`packages/plugins/plugin-auth/src/admin-user-endpoints.ts`.**
`grantRefusal` keeps "The permission set was not assigned, so no user
was created" and hands the reason on as its own sentence (`. ` instead
of `: `), so the composed answer reads as two sentences. Status, code,
`fields` and the rollback are unchanged.
- **Changesets**, one per package moved, all `patch`, both declaration
lines: `@objectstack/platform-objects`, `@objectstack/plugin-security`,
`@objectstack/plugin-auth`, `@object-ui/app-shell`.
## Why
### Before (measured at `origin/main` `b77c160a`)
| | `main` | this PR |
|:---|:---|:---|
| `create_user.params.permissionSet` | `{ type: 'text' }`, no widget |
`{ type: 'text', widget: 'permission-ref' }` |
| dialog control | text box (`ActionParamDialog.test.tsx` CONTROL cell,
#30260) | permission-set picker (same file, picker cell) |
| Studio preview control | text box (`runtimeWidgetFor` →
`resolveParamWidgetType('text')`) | disabled picker,
`data-testid="action-preview-permission-ref"` |
| refusal for `'Repair Technician'` (Create User) | `The permission set
was not assigned, so no user was created: Permission Set: no permission
set is named 'Repair Technician'. sys_user_permission_set.permission_set
takes the machine name of a permission set in the security catalog (a
package's set, a built-in, or one saved through the metadata door),
never a record id: write the name of an existing permission set, or
declare the set first.` | `The permission set was not assigned, so no
user was created. 'Repair Technician' is the label of the permission set
named 'asset_repair_technician': choose it from the list, or enter
'asset_repair_technician'.` |
| user created on refusal | no | no |
### Who the picker lists
`permission-ref` lists `GET /api/v1/meta/permission` minus the agent
ceiling sets; it is not filtered per caller. Create User is visible only
to a platform administrator (`current_user.isPlatformAdmin`), a
tenant-level administrator whom the ADR-0090 D12 gate admits for every
set except the agent ceilings, which the picker leaves out. So for this
action's audience the listed sets are the grantable sets. The picker
does not narrow per delegate on other surfaces; that is the picker's
existing behaviour and not changed here.
### The suggestion stays inside the caller's grant reach
The name check runs only after the D12 gate admitted the write. An
organization administrator or a delegate naming a value the catalog does
not hold is refused by the gate itself (`delegated-admin-gate.test.ts`,
"not in the security catalog"), and a caller who administers nothing is
refused 403 too, so neither hears a set name. Past the gate stand only
tenant-level administrators. Pinned below.
## Verification
Tests added or changed (all green locally):
- `plugin-security` `grant-permission-set-name.test.ts`, new describe
"the refusal says, in one line, what to pick instead" (7 cells, real
`ObjectQL` + SQL driver + `SecurityPlugin`): plain sentence with no
developer vocabulary; label → name; case/space-insensitive match; shared
label lists both; agent ceiling never suggested; caller refused by the
D12 gate hears no set name (403, nothing stored); unlistable catalog
still refuses with the plain sentence and warns. Every cell asserts
nothing is stored. File: 23 passed.
- `plugin-auth` `admin-user-endpoints.test.ts`: the refusal's composed
message, `fields` and rollback; the param pin adds `widget:
'permission-ref'`. 99 passed.
- `platform-objects` `sys-user-create-user-email-required.test.ts`, new
top-level describe pinning the param on the SOURCE (plugin-auth's pin
reads the built dist, see ablation B2). 6 passed.
- `ui` `ActionDesigner.paramVocabulary.test.tsx`, new top-level describe
(4 cells): the dialog's adapter answers `permission-ref`; the preview
draws the picker; CONTROL without widget is a text box; an unregistered
widget degrades to the text box. 23 passed.
- `qa/dogfood` `create-user-permission-set.dogfood.test.ts` (real
showcase boot, real route): G2 pins the composed message; new G4 sends
the label `Showcase Contributor` and gets 400 naming
`showcase_contributor`, zero users. 4 passed.
Ablations (old behaviour put back, red seen, restored):
- A1 old developer sentence: 6 of the new plugin-security cells red
(`Received: "Permission Set: no permission set is named 'qa_nowhere'.
sys_user_permission_set.permission_set takes the machine name …"`).
- A2 no label lookup: the 3 label cells and the unlistable-catalog warn
cell red (`Received: "There is no permission set named 'QA Alpha':
choose one from the list."`).
- A3 agent ceiling not excluded: the agent cell red (`Received: "'QA
Agent Reader' is the label of the permission set named
'mcp_agent_data_read': …"`).
- A4 reach cell run with a tenant-admin caller: red (the suggestion
appears), so the cell measures the gate's ordering.
- B1 old `: ` joiner: plugin-auth refusal cell red.
- B2 widget removed from the param: plugin-auth stays green (it reads
`@objectstack/platform-objects` dist), which is why the source pin C1
exists; C1 red (`- "widget": "permission-ref"`).
- D1 preview ignores `widget`: the preview picker cell red (`Unable to
find an element by: [data-testid="action-preview-permission-ref"]`).
Gates (head `b5c69de7`): `node scripts/pm/dispatch-gates.mjs --ran`
reconciles 71 derived families: 70 run, all exit 0; 1 NOT MEASURED,
`node scripts/check-plugin-teardown-shape.mjs --self-test` exit 3 (its
positive control is pinned to commit `621a4876`, unreachable in this
shallow clone; checker-health only). Also exit 0: `pnpm lint`;
`typecheck` and `test` for `@objectstack/platform-objects`,
`@objectstack/plugin-security`, `@objectstack/plugin-auth`. Record:
`gates-ran-b5c69de7.txt` in the seat's project folder.
Skills-docs: none owed by this diff. `git grep -n
"create_user\|permissionSet" -- skills` has no hit; `content/docs/**`
has no copy of the refusal sentence.
`content/docs/permissions/authentication.mdx` ("Create a User Directly")
documents `create-user` without the optional `permissionSet` at all, a
gap that predates this PR; follow-up candidate.
## Deviations
- File surface:
`packages/qa/dogfood/test/create-user-permission-set.dogfood.test.ts`
(test-only, outside the order's list), accepted by the seat for the
end-to-end label case.
- The refusal names a set's name when the refused value is a set's label
(a catalog list read on the refusal path only), beyond rewording; the
seat asked that the suggestion stay inside the caller's grant reach,
pinned above.
- `ActionPreview` mocks `permission-ref` as a picker, one key past the
eight `PARAM_TYPE_OPTS` the preview's mock vocabulary covered, because a
text box there would still contradict the dialog.
- Full `pnpm test` across the monorepo was not run; the four moved
packages' suites, the ui previews/designer suites and the dogfood file
were.
## Acceptance notes
- The result dialog's `Permission Set` row still shows the granted set's
name, not its label (`resultDialog.fields` path `permissionSet`); not in
the card's ask.
- A translated label (for example a zh-CN label) is not matched by the
suggestion: the catalog's `label` is the source string.
-
`ui/packages/app-shell/src/views/metadata-admin/AssignedUsersSection.test.tsx`
mocks a server message with the old wording as its fixture; it pins that
the form shows the server's words, whatever they are, so it is left as
is.
## Human Minimum
- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
(not touched)
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes.
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: n/a.
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.
---
_Generated by [Claude
Code](https://claude.ai/code/session_016WV4cwFtiPisvhAkegNCLQ)_
---------
Co-authored-by: Claude <noreply@anthropic.com>1 parent 05a30e6 commit 8fed00f
13 files changed
Lines changed: 354 additions & 27 deletions
File tree
- .changeset
- packages
- platform-objects/src/identity
- plugins
- plugin-auth/src
- plugin-security/src
- qa/dogfood/test
- ui/packages/app-shell/src/views/metadata-admin
- previews
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 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 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
80 | 80 | | |
81 | 81 | | |
82 | 82 | | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
355 | 355 | | |
356 | 356 | | |
357 | 357 | | |
358 | | - | |
359 | | - | |
| 358 | + | |
| 359 | + | |
| 360 | + | |
| 361 | + | |
| 362 | + | |
| 363 | + | |
360 | 364 | | |
361 | 365 | | |
362 | 366 | | |
363 | 367 | | |
364 | 368 | | |
365 | 369 | | |
366 | 370 | | |
| 371 | + | |
367 | 372 | | |
368 | 373 | | |
369 | 374 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1336 | 1336 | | |
1337 | 1337 | | |
1338 | 1338 | | |
1339 | | - | |
| 1339 | + | |
| 1340 | + | |
| 1341 | + | |
| 1342 | + | |
| 1343 | + | |
1340 | 1344 | | |
1341 | | - | |
| 1345 | + | |
1342 | 1346 | | |
1343 | 1347 | | |
1344 | 1348 | | |
| |||
1348 | 1352 | | |
1349 | 1353 | | |
1350 | 1354 | | |
| 1355 | + | |
1351 | 1356 | | |
1352 | 1357 | | |
| 1358 | + | |
1353 | 1359 | | |
1354 | 1360 | | |
1355 | 1361 | | |
| |||
1392 | 1398 | | |
1393 | 1399 | | |
1394 | 1400 | | |
1395 | | - | |
| 1401 | + | |
| 1402 | + | |
| 1403 | + | |
| 1404 | + | |
1396 | 1405 | | |
1397 | 1406 | | |
1398 | 1407 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1036 | 1036 | | |
1037 | 1037 | | |
1038 | 1038 | | |
| 1039 | + | |
| 1040 | + | |
| 1041 | + | |
| 1042 | + | |
| 1043 | + | |
1039 | 1044 | | |
1040 | 1045 | | |
1041 | 1046 | | |
| |||
1046 | 1051 | | |
1047 | 1052 | | |
1048 | 1053 | | |
1049 | | - | |
| 1054 | + | |
1050 | 1055 | | |
1051 | 1056 | | |
1052 | 1057 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
69 | 74 | | |
70 | 75 | | |
71 | 76 | | |
| |||
259 | 264 | | |
260 | 265 | | |
261 | 266 | | |
| 267 | + | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
| 298 | + | |
| 299 | + | |
| 300 | + | |
| 301 | + | |
| 302 | + | |
| 303 | + | |
| 304 | + | |
| 305 | + | |
| 306 | + | |
| 307 | + | |
| 308 | + | |
| 309 | + | |
| 310 | + | |
| 311 | + | |
| 312 | + | |
| 313 | + | |
| 314 | + | |
| 315 | + | |
| 316 | + | |
| 317 | + | |
| 318 | + | |
| 319 | + | |
| 320 | + | |
| 321 | + | |
| 322 | + | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
| 327 | + | |
| 328 | + | |
| 329 | + | |
| 330 | + | |
| 331 | + | |
| 332 | + | |
| 333 | + | |
| 334 | + | |
| 335 | + | |
| 336 | + | |
| 337 | + | |
| 338 | + | |
| 339 | + | |
| 340 | + | |
| 341 | + | |
| 342 | + | |
| 343 | + | |
| 344 | + | |
| 345 | + | |
| 346 | + | |
| 347 | + | |
| 348 | + | |
| 349 | + | |
| 350 | + | |
| 351 | + | |
| 352 | + | |
| 353 | + | |
| 354 | + | |
262 | 355 | | |
263 | 356 | | |
264 | 357 | | |
| |||
0 commit comments