Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions .changeset/33113-import-users-positions-column.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
---
'@objectstack/plugin-auth': patch
'@object-ui/app-shell': patch
'@object-ui/i18n': patch
---

feat(plugin-auth): `POST /api/v1/auth/admin/import-users` takes a `positions` column, assigned in a second pass as Setup assigns a position

Clause-②: yes (widening)
Metadata-protocol: none

The user import gains one column, `positions`: position machine names, several separated by `;` (or an array on a JSON row) — the same column `admin/import-sso-users` reads. Nothing that worked before is refused: a file with no `positions` column imports exactly as before.

- Each named position is assigned after every row of the batch has landed, as a `sys_user_position` grant written under the importing administrator's own execution context, so it passes the same checks as assigning a position in Setup (the position catalog, delegated administration, the holder's organization membership).
- A position that does not exist (`unresolved`) or whose assignment is refused (`refused`, with the refusal's `code`) is reported on its row, and the user is still created. `rows[].positions` lists each named position's outcome (`assigned`, `already_assigned`, `unresolved`, `refused`), a cell that is not a list reads `'unreadable'`, and `summary.positions` counts them. The import only adds positions; it never removes one.
- When the positions cannot be judged at all, the users are still created and every named position is reported `refused` on its row: `NOT_IMPLEMENTED` on a server that cannot assign positions during an import, `PERMISSION_DENIED` when the caller's own access does not resolve. Dry runs do not assign.
- There is no permission-set column: a position carries its permission sets.

`@object-ui/app-shell`: the Users import wizard offers a `positions` target column, and its options panel explains the column (`console.identityImport.positionsHint`, in every `@object-ui/i18n` pack).
23 changes: 23 additions & 0 deletions content/docs/permissions/authentication.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -1269,6 +1269,29 @@ every row through better-auth so the accounts are login-capable:
updates only touch profile fields (`name`, `image`, `phone_number`, `role`)
— a re-imported file can never modify an existing user's email or reset
their password.
- A `positions` column assigns positions: position machine names, several
separated by `;` (an array on a JSON row) — the same column
`import-sso-users` reads. Each is assigned after every row has landed, as a
`sys_user_position` grant written under the importing admin's own access,
so it passes the checks Setup applies when you assign a position there (the
position must exist, and you must be allowed to assign it). A position that
does not exist or is refused is reported on its row and the user is still
created: `rows[].positions` is an array with one entry per named position
and its outcome (`assigned`, `already_assigned`, `unresolved`, or `refused`
with the refusal's `code`), and `summary.positions` counts them. A cell that
is not a list of names (a number or an object on a JSON row) assigns
nothing, and that row's `rows[].positions` is the **string**
`'unreadable'`, not an array — check for it before reading the entries. It
counts once under `summary.positions.unresolved`, and the user is still
created. The import only adds positions; it never removes one a user holds.
Permission sets come with the position (a position carries its sets); a
direct grant stays a Setup step.
- When a file's positions cannot be judged at all, the users are still
created and only the positions are refused: every named position is
reported `refused` on its row, with code `NOT_IMPLEMENTED` when the server
cannot assign positions during an import, or `PERMISSION_DENIED` when your
own access cannot be resolved. A dry run never assigns positions, and
reports `summary.positions` as zeros.
- Synchronous only, at most 500 rows per request (password hashing is
CPU-bound); split larger files into batches. Imports are not undoable.

Expand Down
38 changes: 19 additions & 19 deletions content/docs/permissions/tenant-audit-census.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ what moved this page's population from 225 to 227; nothing about the two sites
changed, only whether this instrument could see them.

**The expensive failure direction is a keyword.** Sites whose receiver the author
typed `any` have no type to read, and there are 66 of them — just over a fifth
typed `any` have no type to read, and there are 67 of them — just over a fifth
of the population, concentrated in exactly the seed and bootstrap paths this
control exists for. Scoring an unreadable receiver as "not an engine" would have
dropped every one of them silently, with a clean exit and a smaller number that
Expand Down Expand Up @@ -132,7 +132,7 @@ are reported as `undecidable` rather than assumed either way.

The same holds twice over for the context. An options argument spelled as a
literal can be read; one spelled `options`, `{ ...opts }`, or handed through a
forwarding shim cannot, and **59 of the 321 sites are spelled that way**. A
forwarding shim cannot, and **59 of the 322 sites are spelled that way**. A
context resolved from an inline literal or a local `const` can be tested for
`isSystem`; one arriving from a helper call cannot.

Expand Down Expand Up @@ -197,10 +197,10 @@ reproduce them. Where it disagrees, it disagrees on the page:

| carried figure | where it survives | this census |
| :--- | :--- | ---: |
| 175 write call sites | quoted in the merged changeset | **321** |
| 175 write call sites | quoted in the merged changeset | **322** |
| 24 carrying no tenant context | quoted in the merged changeset | **3** provable and tenancy-enabled; **32** more whose options argument is unreadable |
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **226 of 321** decidable, **95** undecidable |
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 181 decidably elevated, 0 decidably not, 128 undecidable |
| 127 of 175 statically decidable, 48 runtime-parameter-name sites | restated on the `isSystem`-scoping card | **227 of 322** decidable, **95** undecidable |
| 135 (77%) silenced by the `isSystem` guard before the posture gate | the lost issue body — **no surviving corroboration** | **not reproduced**: 181 decidably elevated, 0 decidably not, 129 undecidable |
| 141 and 132, two independent re-derivations | the card that filed this work | — |

**The differences are not reconciled, and deliberately so.** The old census's
Expand All @@ -210,18 +210,18 @@ be stated is what this instrument counts, which is written above and re-runnable
at any commit.

Two structural facts do plausibly widen this reading against any hand or regex
one, and both are counted in the generated tables below: the 66 sites reached
one, and both are counted in the generated tables below: the 67 sites reached
through an erased (`any`) receiver, and the 86 that name their object through a
`const` rather than inline. An instrument that read either the way a person does
would report a smaller number and would not say so.

The fourth row is the one worth flagging to anyone citing it. **The 135 / 77%
figure has no surviving corroboration anywhere in the tree.** This census reads
181 of 321 (56%) as decidably elevated, with 128 more whose elevation is a
181 of 322 (56%) as decidably elevated, with 129 more whose elevation is a
run-time fact — so the claim is neither confirmed nor refuted, and the honest
answer is that a static reading cannot settle it.

⇒ **Cite `3 / 321`, and say what it is**: the sites whose options argument was
⇒ **Cite `3 / 322`, and say what it is**: the sites whose options argument was
READ and holds no tenant context, against a decidably tenancy-enabled object.
That is the control's provable yield surface. ⛔ Do not cite it as "the sites
without tenant context" — **32 further sites** have an options argument this
Expand All @@ -233,28 +233,28 @@ cannot read, and they are neither in nor out.

| what | count |
| :--- | ---: |
| write call sites on the application surface | **321** |
| …whose object name is statically decidable | 226 |
| write call sites on the application surface | **322** |
| …whose object name is statically decidable | 227 |
| …whose object name is chosen at run time | 95 |
| …against an object with tenancy ENABLED | 219 |
| …against an object with tenancy ENABLED | 220 |
| …against an object that declares tenancy off | 7 |
| threading a tenant context | 250 |
| threading a tenant context | 251 |
| PROVABLY carrying none (options read, no context key) | **12** |
| …of those, against a decidably tenancy-enabled object | **3** |
| options argument UNREADABLE — may or may not carry one | 59 |
| …of those, against a decidably tenancy-enabled object | 32 |
| threading a decidably ELEVATED (`isSystem`) context | 181 |
| threading a context that is decidably NOT elevated | 0 |
| threading a context whose elevation is a run-time fact | 128 |
| threading a context whose elevation is a run-time fact | 129 |

| how the instrument reached the site | count |
| :--- | ---: |
| receiver carried a readable engine type | 255 |
| receiver erased, placed by the object NAME | 56 |
| receiver erased, placed by the object NAME | 57 |
| receiver erased, placed by an `object: string` PARAMETER | 5 |
| receiver erased, placed by an `UNTYPED_RECEIVERS` row | 5 |

| object name spelled inline | 140 |
| object name spelled inline | 141 |
| object name spelled through a `const` | 86 |
| object name is an `object: string` parameter | 10 |
| object name is some other run-time expression | 85 |
Expand Down Expand Up @@ -307,13 +307,13 @@ holds still. They are required to be HERE and to say WHEN they were true;
their values are not compared. The reasoning, and the measurement behind it,
are in `scripts/check-tenant-audit-census.mjs`.

Measured on 2026-11-15 at `2ab05f460`.
Measured on 2026-11-16 at `94cb58c3d`.

| corpus scale (not enforced) | count |
| :--- | ---: |
| tracked non-test sources scanned | 1176 |
| engine-shaped types recognised | 141 |
| tracked non-test sources scanned | 1186 |
| engine-shaped types recognised | 142 |
| declared objects in the registry | 137 |
| same-named calls subtracted as non-engine | 311 |
| same-named calls subtracted as non-engine | 323 |

{/* END GENERATED: tenant-audit-census */}
19 changes: 10 additions & 9 deletions docs/audits/2026-08-tenant-audit-write-call-sites.counts.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,19 +33,19 @@ silent, and `node scripts/tenant-audit-census.mjs --write` is the resolution.

| Measure | Value |
|---|---:|
| Write call sites | 321 |
| Object name statically decidable | 226 |
| Write call sites | 322 |
| Object name statically decidable | 227 |
| Object name chosen at run time | 95 |
| Against a tenancy-enabled object | 219 |
| Against a tenancy-enabled object | 220 |
| Against an object declaring tenancy off | 7 |
| Threading a tenant context | 250 |
| Threading a tenant context | 251 |
| Provably carrying none | 12 |
| …and decidably tenancy-enabled | 3 |
| Options argument unreadable | 59 |
| …and decidably tenancy-enabled | 32 |
| Threading a decidably elevated context | 181 |
| Threading a decidably non-elevated context | 0 |
| Threading a context of undecidable elevation | 128 |
| Threading a context of undecidable elevation | 129 |

## Subtractions the census could NOT defend — enforced

Expand Down Expand Up @@ -90,14 +90,14 @@ holds still. They are required to be HERE and to say WHEN they were true;
their values are not compared. The reasoning, and the measurement behind it,
are in `scripts/check-tenant-audit-census.mjs`.

Measured on 2026-11-15 at `2ab05f460`.
Measured on 2026-11-16 at `94cb58c3d`.

| corpus scale (not enforced) | count |
| :--- | ---: |
| tracked non-test sources scanned | 1176 |
| engine-shaped types recognised | 141 |
| tracked non-test sources scanned | 1186 |
| engine-shaped types recognised | 142 |
| declared objects in the registry | 137 |
| same-named calls subtracted as non-engine | 311 |
| same-named calls subtracted as non-engine | 323 |

## Every site

Expand Down Expand Up @@ -138,6 +138,7 @@ Measured on 2026-11-15 at `2ab05f460`.
| `packages/plugins/plugin-audit/src/stored-metadata-body-migration.ts` | `update` | `object` | undecidable | elevated | 1 |
| `packages/plugins/plugin-auth/src/admin-import-users.ts` | `insert` | `sys_audit_log` | enabled | options unreadable | 1 |
| `packages/plugins/plugin-auth/src/admin-import-users.ts` | `update` | `sys_user` | enabled | options unreadable | 2 |
| `packages/plugins/plugin-auth/src/admin-import-users.ts` | `insert` | `sys_user_position` | enabled | context, elevation undecidable | 1 |
| `packages/plugins/plugin-auth/src/admin-set-user-manager.ts` | `update` | `sys_user` | enabled | context, elevation undecidable | 1 |
| `packages/plugins/plugin-auth/src/admin-user-endpoints.ts` | `insert` | `sys_audit_log` | enabled | elevated | 1 |
| `packages/plugins/plugin-auth/src/admin-user-endpoints.ts` | `update` | `sys_user` | enabled | elevated | 1 |
Expand Down
Loading
Loading