Skip to content

feat(plugin-auth): Create User can grant a permission set in the same step, through the delegated-administration gate - #25381

Merged
objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-bdbiuf
Oct 23, 2026
Merged

objectstack-fleet[bot] merged 7 commits into
mainfrom
claude/project-thread-bdbiuf

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Requested by Tesla · project thread

Fixes #25338

Clause-②: yes (widening: POST /api/v1/auth/admin/create-user and the sys_user create_user action accept an optional permissionSet; a request without it is answered exactly as before)
Metadata-protocol: none

Companion UI half: objectstack-ai/objectui#13347 (a member who may read none of an app's objects lands on one access page instead of a grid of refusals).

What changes

Create User can grant one permission set in the same step.

  • create_user gains an optional inline permissionSet param (text, the set's machine name). The result dialog shows it when one was granted.
  • runAdminCreateUser (plugin-auth) parses permissionSet. When one is named, it resolves the calling administrator's OWN execution context through resolveRequestExecutionContext (@objectstack/core, session-only, fail-closed) before anything is written, then runs the account creation and engine.insert('sys_user_permission_set', { user_id, permission_set }, { context: <caller's context> }) inside one engine.transaction().
  • A refused grant answers the refusal's own status and code (403 PERMISSION_DENIED from the delegated-administration gate, 400 VALIDATION_FAILED with fields for a name the catalog does not hold), and the transaction rolls the user back.
  • Refused before any write: a non-string permissionSet (400), a caller whose own context does not resolve (403), a host that wires no grant seam (501).
  • Cloud-managed is unchanged: create_user stays hidden under features.cloudManaged (platform-objects: hide invite_user ×4, create_user and set_user_password when features.cloudManaged is on (visible predicates, hide-when-on) #25295).

Security floor

  • No new assignment path. The grant is the same non-system insert into sys_user_permission_set that Setup's grant form makes, under the caller's context, so the security middleware, the ADR-0090 D12 DelegatedAdminGate (which stamps granted_by) and the catalog name check (grant-permission-set-name.ts) judge it exactly as they judge the form. No isSystem context is used for the grant.
  • No widening of who can grant what. The route's existing platform-admin gate decides who may create a user. It never decides what that user may be granted; the D12 gate does. Dogfood G1 reads granted_by = the administrator, which is the gate's own stamp.
  • Ruling carried: hotcrm#2194 record 6354968262 ("25251 B hotcrm B").

Verification

  • plugin-auth admin-user-endpoints.test.ts: 65/65, 8 new cases (none asked; assigned under the actor's context, not system; 403 refusal rolls back and writes no audit; unknown name gives 400 with fields and rolls back; no seam 501; unresolved context 403; non-string 400; the param is inline, never field-backed).
  • New dogfood create-user-permission-set.dogfood.test.ts (showcase boot): 3/3. G1 assigned showcase_contributor with granted_by = admin; G2 no_such_set_25338 gives 400 and no user; G3 a member caller gets 403 and no user.
  • Ablation: runAtomically replaced with a plain work() call (a ctx.logger.debug marker, proven in dist/ by ablation-dist-preflight.mjs). G2 goes red: the user survives the refused grant ("expected [ …(26) ] to have a length of +0 but got 1"). Restored to HEAD's blob, rebuilt, --absent passes. A first leg used a comment marker that the build stripped, so preflight refused it and it measured nothing; it is not counted.
  • platform-objects: 88 files, 1318 tests pass (the create-user result-dialog pin now lists permissionSet). tsc --noEmit clean for plugin-auth and platform-objects. check-i18n-bundles OK (zh-CN, ja-JP, es-ES translated).
  • Tenant-audit census re-counted for the one new write site (237 → 238) with tenant-audit-census.mjs --write, and the page's hand-written figures updated to match.

Acceptance notes

  • The param is INLINE text, not field-backed on sys_user_permission_set.permission_set. That object belongs to plugin-security, and the console's ActionParamDialog refuses the whole action when a field-backed param's object metadata is not loaded. The field-backed form would not have given a picker anyway: a field-backed param takes the field's type (text), not its widget: 'permission-ref' hint. A picker for this param needs params to honour a widget hint (objectui), noted here, not filed.
  • A datasource whose driver has no beginTransaction runs the account and the grant unatomically, the engine's declared limit (ADR-0119 D1).

🤖 Generated with Claude Code

https://claude.ai/code/session_01TpToTVFniSfCoKfhPL16Nz

…mission set, granted under the caller's own context

Claude-Session: https://claude.ai/code/session_01TpToTVFniSfCoKfhPL16Nz
Co-authored-by: Claude <noreply@anthropic.com>
…ine param

A field-backed param on plugin-security's grant object is refused by the
console dialog whenever that object's metadata is not loaded, so the param
is declared inline. Re-counts the tenant-audit census for the new write site.

Claude-Session: https://claude.ai/code/session_01TpToTVFniSfCoKfhPL16Nz
Co-authored-by: Claude <noreply@anthropic.com>
…e-user grant pins

Claude-Session: https://claude.ai/code/session_01TpToTVFniSfCoKfhPL16Nz
Co-authored-by: Claude <noreply@anthropic.com>
Re-counts the tenant-audit census on the merged tree.

Claude-Session: https://claude.ai/code/session_01TpToTVFniSfCoKfhPL16Nz
Co-authored-by: Claude <noreply@anthropic.com>
Re-counts the tenant-audit census on the merged tree.

Claude-Session: https://claude.ai/code/session_01TpToTVFniSfCoKfhPL16Nz
Co-authored-by: Claude <noreply@anthropic.com>
@github-actions github-actions Bot added size/l documentation Improvements or additions to documentation tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface labels Oct 23, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/platform-objects, @objectstack/plugin-auth, touching 23 documentable anchor(s).

38 hand-written doc(s) name something this change touched — list omitted above 15 rows. Re-derive on the tree named below: node scripts/docs-audit/affected-docs.mjs --json b22ab8d6fb3462bff05142efc6b6cc040c95f646.

⛔ 11 release-owned page(s) also affected — read-only, see AGENTS.md Documentation Guardrails.

What this run could not see
  • 2 anchor(s) matched too much of the corpus to be a work list: sys_user (symbol, 42 pages), PERMISSION_DENIED (literal, 42 pages)
  • 6 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 54 of 206 client-bound route-ledger rows — the other 152 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 152: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 55 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 97 are undecided (no in-repo declaration, on a ledger that has other in-repo registrars — absence and an unreadable spelling are not distinguishable here). The rows themselves: node scripts/docs-audit/affected-docs.mjs --bridge-coverage
  • a page that states a rule by its inputs shares no identifier with the emitter that implements the rule, so an emitter-only diff cannot list it — not on this run and not on any run. Measured on fix(driver-sql): emit varchar(maxLength) for a text field a declared index keys on #11430: content/docs/protocol/objectql/types.mdx documents the text-family column mapping by the ObjectQL type names it maps FROM (text / textarea / html) while the diff changed createColumn; it went unlisted, and it was the page that diff falsified, in four places. No shared token exists to detect this on, so a rule your change carries has to be re-read by hand in the pages that restate it.
  • a key NAME is not a key, so the hand re-read the line above prescribes can land on the wrong schema. The same spelling is authorable on one governed type and a [REMOVED] tombstone on another for each of active, aria, joins, objects, template, tools and version (censused on [finding] tools is a key on BOTH AgentSchema (tombstoned, dead) and SkillSchema (live, cloud-attested), so a name-based search attributes skill examples to the agent key — it produced a false stop-the-line alarm on PR #19059 #19093 over the liveness ledger's governed types, top-level keys); nothing in a search result distinguishes the two, so a grep hit on a LIVE example reads as evidence about the DEAD key. Measured on fix(spec): the agent.tools liveness row says dead — it claimed live on a key the schema tombstoned #19059: content/docs/ai/agents.mdx was reported as contradicting the agent.tools tombstone over its tools: example at :161, which is inside the defineSkill({ block opened at :155 — the page was already correct. Settle ownership by PARSING the value against both schemas, never by the name: that literal PASSES SkillSchema, and as an AgentSchema it FAILS at tools with the tombstone prescription. ⛔ These names are not the whole class — a key retired through a .strict() guidance map leaves no tombstone in the walked shape and none of them here (tool.category, live as AIToolDefinition.category).

Coarse fallback — 21 page(s) merely mention a changed package (the pre-#9192 predicate, kept for the deliberately-wide backstop): node scripts/docs-audit/affected-docs.mjs --json b22ab8d6fb3462bff05142efc6b6cc040c95f646 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from dad3e1dedd57761105eae1cba78d469a2b0462b6 — the merge of head 74d73286de8229ce79ebe7c631f7c84cd0f5a96b into base b22ab8d6fb3462bff05142efc6b6cc040c95f646, which is what actions/checkout gives a pull_request run. Not the PR head.

A worktree cut from an older main holds a different content/docs, so re-deriving there can legitimately return a different list — that is a different tree, not a wrong row. To answer on the same tree:

# while this PR is open — GitHub drops the merge commit once it closes
git fetch origin dad3e1dedd57761105eae1cba78d469a2b0462b6 && git checkout dad3e1dedd57761105eae1cba78d469a2b0462b6
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin b22ab8d6fb3462bff05142efc6b6cc040c95f646 74d73286de8229ce79ebe7c631f7c84cd0f5a96b && git checkout -B drift-repro b22ab8d6fb3462bff05142efc6b6cc040c95f646 && git merge --no-ff 74d73286de8229ce79ebe7c631f7c84cd0f5a96b

node scripts/docs-audit/affected-docs.mjs --json b22ab8d6fb3462bff05142efc6b6cc040c95f646

⚠️ That checkout carried uncommitted changes, so the commit above does not fully identify what was read.

Advisory only, and a precision-first one (#9192): a page is listed because it names a
symbol, wire route or SDK method this diff touched — not because it mentions a changed
package. Each row says which anchor put it there, so a wrong row is reportable rather than
merely annoying. To re-verify, run the docs-accuracy-audit workflow scoped to these files:
node scripts/docs-audit/affected-docs.mjs b22ab8d6fb3462bff05142efc6b6cc040c95f646 → pass the list as
args.docs, on the commit named under Which tree this was computed on.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

席位核对

ACCEPT · domain:engine seat 1 · os-tesla · session_014Hse9cj2i4o5UAVrd21NKr · 2026-10-23T07:44Z · head 74d73286d · #25338 (Fixes, with the console half objectstack-ai/objectui#13347 landing in the same stroke)

  • Shape: 13 files, +570 / −62:

    • plugin-auth admin-user-endpoints.ts + auth-plugin.ts: create-user accepts an optional permissionSet.
    • sys_user create_user gains an inline permissionSet param and a result-dialog field.
    • Regenerated bundles and the tenant-audit census (+1 write site: 237 → 238).
    • Unit and dogfood pins, and a patch changeset.

    Read from the diff. NOT GOVERNED, under the 3000-line threshold.

  • Clause-② (yes) seat review, TIER_DEFAULT: an optional body key and action param. A request without it is answered exactly as before. No authorable spec key is added: the param uses existing ActionParamSchema keys.

  • Security floor, read on the diff:

    • The grant is a sys_user_permission_set insert under the calling administrator's OWN execution context, never SYSTEM_CTX. The context comes from resolveRequestExecutionContext (session-only, anonymous: 'fail-closed').
    • So the security middleware, the ADR-0090 D12 delegated-administration gate (which stamps granted_by) and the catalog name check judge it exactly as they judge Setup's grant form.
    • The platform-admin gate still decides only who may create a user.
    • The account and the grant run in one engine.transaction, so a refused grant answers the refusal's own status and no user is left behind. The dogfood test pins this against a real kernel: G1 granted_by = admin, G2 a 400 with 0 users, G3 a 403 with nothing written.
    • No boundary is widened. Security: a runAs system flow writes identity-assignment rows (sys_user_position, sys_invitation) past the delegated-administration gate #25251's ruling (hotcrm#2194 6354968262) is carried.
  • Cross-lane: plugin-auth was declared on [PM seat] domain:services — ⏳ vacant · archive of domain:server seat 1 (#6367) #6021 (6357791125). No objection was posted.

  • Gates: 42 check-runs on 74d73286d: 36 success, 6 skipped, 0 failed; mergeable clean. Two main merges resolved the census conflicts, regenerated from main's tree and checked by the census and i18n gates.

  • Accepted deviation: permissionSet is an inline text param, not field-backed. A field-backed param on plugin-security's object makes the dialog refuse the action when that metadata isn't loaded. A permission-set picker is a noted gap and is not filed.

  • Landing: both halves are marked ready and auto-merge is enabled. The console half (the no-readable-object landing) stands on its own, so landing order is free.


Generated by Claude Code

@objectstack-fleet
objectstack-fleet Bot marked this pull request as ready for review October 23, 2026 07:46
@objectstack-fleet
objectstack-fleet Bot enabled auto-merge October 23, 2026 07:46
@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Oct 23, 2026
Merged via the queue into main with commit 3306cad Oct 23, 2026
43 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-bdbiuf branch October 23, 2026 08:16
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Improvements or additions to documentation size/l tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

2 participants