Skip to content

Commit 1a6abb3

Browse files
committed
docs(adr): ADR-0093 D3 amendment note, bulk import joins the administrator's current organization
The D3 amendment of 2026-10-24 closes on a sentence that lists bulk import among the creation paths that bind nothing in multi mode. Since merge commit 36af6b0 (maintainer ruling 6942842013, option B) the admin import joins each row to the importing administrator's current organization. Add-only: a dated amendment note (2026-11-17) under that amendment records what landed, with symbol anchors into the shared settlement and join, and the status line gains its Amended entry. The ruled sentence is not rewritten. Co-Authored-By: Claude <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs
1 parent 4443014 commit 1a6abb3

1 file changed

Lines changed: 34 additions & 1 deletion

File tree

‎docs/adr/0093-tenancy-mode-and-membership-lifecycle.md‎

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# ADR-0093: Tenancy mode as a first-class capability, and a single owner for the user→membership lifecycle
22

3-
**Status**: Accepted (2026-07-13) — implemented: `tenancy` kernel service (`plugin-auth/src/tenancy-service.ts`), membership reconciler (`reconcile-membership.ts`), locked by `dogfood/test/membership-reconciler.dogfood.test.ts` · **Amended** (2026-11-08, [ADR-0151](./0151-ai-service-account-a-headless-agent-is-a-registered-principal-of-its-own.md) D1, proposed, adopted by its merge) — D7's machine / service-account row: the first-class marker it waited on is `sys_user.principal_kind`. The membership reconciler never binds an account of kind `agent`, whose one membership its registration creates. · **Amended** (2026-11-11, maintainer ruling 6796108313) — D8.1 reversed: under every tenancy posture, a person's data access requires a current membership in the organization, judged on each request; see the amendment note under D8.
3+
**Status**: Accepted (2026-07-13) — implemented: `tenancy` kernel service (`plugin-auth/src/tenancy-service.ts`), membership reconciler (`reconcile-membership.ts`), locked by `dogfood/test/membership-reconciler.dogfood.test.ts` · **Amended** (2026-11-08, [ADR-0151](./0151-ai-service-account-a-headless-agent-is-a-registered-principal-of-its-own.md) D1, proposed, adopted by its merge) — D7's machine / service-account row: the first-class marker it waited on is `sys_user.principal_kind`. The membership reconciler never binds an account of kind `agent`, whose one membership its registration creates. · **Amended** (2026-11-11, maintainer ruling 6796108313) — D8.1 reversed: under every tenancy posture, a person's data access requires a current membership in the organization, judged on each request; see the amendment note under D8. · **Amended** (2026-11-17, maintainer ruling 6942842013) — D3 amendment: under a walled posture, bulk import (`POST /api/v1/auth/admin/import-users`) joins each row to the administrator's current organization; see the amendment note under the D3 amendment.
44
- **Date:** 2026-07-13
55
- **Deciders:** ObjectStack Protocol Architects
66
- **Implementation:** #2882 (Phase 0 — tactical create-user bind, merged) → this PR (Phases 1–3 — `tenancy` service, fail-fast boot guard, membership reconciler, consumer migration, backfill, docs). One revision from the original plan, ratified in D2: the endpoint-level create-user bind **delegates to the shared reconciler** (one implementation, two call sites) instead of being deleted. Runtime verification confirmed the hook fires for `admin.createUser`, but better-auth *defers* `user.create.after` post-commit (#1881), so the endpoint keeps its delegated call to report `organizationId` / `membershipCreated` deterministically in its response. Cloud-host semantics (personal-org hook precedence, multi-org non-binding, D5 blast radius) verified against `objectstack-ai/cloud` — see D2/D3/D5.
@@ -273,6 +273,39 @@ This is not the reconciler guessing a tenant: the reconciler, and every other
273273
creation path (self sign-up, bulk import, SSO JIT, host hooks), still binds
274274
nothing in multi mode.
275275

276+
> **Amendment note (2026-11-17, maintainer ruling 6942842013 on #34535, option B — PR #34750,
277+
> `36af6b05a7`): bulk import joins each row to the administrator's current organization.** The
278+
> sentence above no longer holds for bulk import. Under a walled posture
279+
> `POST /api/v1/auth/admin/import-users` follows this amendment's rule row by row, through the one
280+
> settlement and the one join Create User runs:
281+
> `packages/plugins/plugin-auth/src/admin-user-endpoints.ts#settleCurrentOrganizationJoin`, `#joinCurrentOrganization`.
282+
> For the reconciler and the other creation paths that sentence names (self sign-up, SSO JIT, host
283+
> hooks) it stands as ruled: they still bind nothing in multi mode.
284+
>
285+
> - **Settled once, before any row is written, on a dry run too.** An administrator with no current
286+
> organization is refused whole (`400 NO_ACTIVE_ORGANIZATION`, Create User's code and sentence),
287+
> and so is an import on a host that wires no unit of work for the creation, or whose better-auth
288+
> offers no `addMember` (`501 NOT_IMPLEMENTED`). Nothing is created. A dry run that is not
289+
> refused joins nothing.
290+
> - **One unit of work per created row.** The row's account and its join, as `member` through
291+
> better-auth's `addMember`, run inside the seam's `runAtomically`
292+
> (`packages/plugins/plugin-auth/src/admin-import-users.ts#runAdminImportUsers`, its `inRowUnit`):
293+
> the engine transaction, with the limit
294+
> [ADR-0119](./0119-plugin-reachable-transactions-and-honest-atomic-batch.md) D1 declares for it.
295+
> A refused join (the organization's member cap, say) rolls that row's account back: the row
296+
> fails with the vendor's code, is handed no temporary password and is sent no invitation. The
297+
> other rows go on.
298+
> - **A row that matches an existing user (upsert) joins that user too** (the seat's reading in the
299+
> same ruling record), whichever other organizations that user already belongs to. The profile
300+
> update and the join are one unit of work, so a refused join fails the row and leaves the
301+
> profile as it was. A user already in the current organization is not added twice.
302+
> - **Single mode (a degraded wall included) is unchanged**: the import joins nothing, and the
303+
> reconciler binds the default org.
304+
>
305+
> Pinned by the multi-org cases of
306+
> `packages/plugins/plugin-auth/src/admin-import-users-manager-pass.test.ts` and, on the real
307+
> engine, by I1 and I2 of `packages/qa/dogfood/test/create-user-organization-join.dogfood.test.ts`.
308+
276309
### D4 — The `tenancy` kernel service
277310

278311
Registered under the service name **`tenancy`**:

0 commit comments

Comments
 (0)