From 1a6abb30ddcf659a7b7f4dca23115384bbcd4a6d Mon Sep 17 00:00:00 2001 From: Claude Date: Tue, 17 Nov 2026 23:30:38 +0000 Subject: [PATCH] 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 36af6b05a7 (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 Claude-Session: https://claude.ai/code/session_01WGufzgwLiKcfujYUug7sPs --- ...3-tenancy-mode-and-membership-lifecycle.md | 35 ++++++++++++++++++- 1 file changed, 34 insertions(+), 1 deletion(-) diff --git a/docs/adr/0093-tenancy-mode-and-membership-lifecycle.md b/docs/adr/0093-tenancy-mode-and-membership-lifecycle.md index bc44594d34b..44f1ecee784 100644 --- a/docs/adr/0093-tenancy-mode-and-membership-lifecycle.md +++ b/docs/adr/0093-tenancy-mode-and-membership-lifecycle.md @@ -1,6 +1,6 @@ # ADR-0093: Tenancy mode as a first-class capability, and a single owner for the user→membership lifecycle -**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. +**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. - **Date:** 2026-07-13 - **Deciders:** ObjectStack Protocol Architects - **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 creation path (self sign-up, bulk import, SSO JIT, host hooks), still binds nothing in multi mode. +> **Amendment note (2026-11-17, maintainer ruling 6942842013 on #34535, option B — PR #34750, +> `36af6b05a7`): bulk import joins each row to the administrator's current organization.** The +> sentence above no longer holds for bulk import. Under a walled posture +> `POST /api/v1/auth/admin/import-users` follows this amendment's rule row by row, through the one +> settlement and the one join Create User runs: +> `packages/plugins/plugin-auth/src/admin-user-endpoints.ts#settleCurrentOrganizationJoin`, `#joinCurrentOrganization`. +> For the reconciler and the other creation paths that sentence names (self sign-up, SSO JIT, host +> hooks) it stands as ruled: they still bind nothing in multi mode. +> +> - **Settled once, before any row is written, on a dry run too.** An administrator with no current +> organization is refused whole (`400 NO_ACTIVE_ORGANIZATION`, Create User's code and sentence), +> and so is an import on a host that wires no unit of work for the creation, or whose better-auth +> offers no `addMember` (`501 NOT_IMPLEMENTED`). Nothing is created. A dry run that is not +> refused joins nothing. +> - **One unit of work per created row.** The row's account and its join, as `member` through +> better-auth's `addMember`, run inside the seam's `runAtomically` +> (`packages/plugins/plugin-auth/src/admin-import-users.ts#runAdminImportUsers`, its `inRowUnit`): +> the engine transaction, with the limit +> [ADR-0119](./0119-plugin-reachable-transactions-and-honest-atomic-batch.md) D1 declares for it. +> A refused join (the organization's member cap, say) rolls that row's account back: the row +> fails with the vendor's code, is handed no temporary password and is sent no invitation. The +> other rows go on. +> - **A row that matches an existing user (upsert) joins that user too** (the seat's reading in the +> same ruling record), whichever other organizations that user already belongs to. The profile +> update and the join are one unit of work, so a refused join fails the row and leaves the +> profile as it was. A user already in the current organization is not added twice. +> - **Single mode (a degraded wall included) is unchanged**: the import joins nothing, and the +> reconciler binds the default org. +> +> Pinned by the multi-org cases of +> `packages/plugins/plugin-auth/src/admin-import-users-manager-pass.test.ts` and, on the real +> engine, by I1 and I2 of `packages/qa/dogfood/test/create-user-organization-join.dogfood.test.ts`. + ### D4 — The `tenancy` kernel service Registered under the service name **`tenancy`**: