Skip to content

Commit 89d815c

Browse files
docs(adr-0135): D4 gains a dated note for the SCIM provisioning writer and its boot backfill (#32484)
<!-- claude-projects-attribution: {"github_login":"os-bill"} --> _Requested by **Bill** · [project thread](https://claude.ai/code/project/chan_016iMXWSZDzqWRWvWzdNo8wg?thread=cmsg_016iMXWSZDzqWRWvWzdNo8wgSnFirZ8ynCmAemTPrCvXpF)_ Fixes #32450 Clause-②: no Metadata-protocol: none Skills-docs: none — ADR bookkeeping only ## 维护者速读 - 改了什么:ADR-0135 D4 下新增一条带日期的 Note,记录 `sys_user.source` 的第三个写入方(SCIM 开通写入)、它的两种失败姿态,以及启动时的一次性补标。只动这一个 ADR 文件,51 行纯新增。 - 为什么改:D4 正文只写了「两个写入方、都 fail open」。上一个已合并的 SCIM 改动加了第三个写入方,而且它在激活态是 fail closed;读 ADR 的人要靠这份写入方清单知道标记从哪来。 - 风险与回滚:纯文档,无行为变化、无发布内容。回滚即 revert 本 PR。 - 先看:`docs/adr/0135-identity-and-access-architecture.md` 中 D4 末尾新增的 Note,重点是最后一段「为什么 SCIM 写入不 fail open」的理由是否与您的判断一致。 - 两分钟验证:`pnpm check:adr-symbol-anchors`,预期末行 `3544 anchors across 156 records resolve`(Note 里三个代码锚点都能解析)。 - 需要你做的:审阅并合并(`docs/adr/**` 是 Tier H,由您落地)。 ## What changes One dated Note is added under `### D4 — Source-of-truth marking: managed vs env-native` in `docs/adr/0135-identity-and-access-architecture.md`, after the existing 2026-10-23 note and in its form. D4's own paragraphs are not edited. The note: - **Names the SCIM provisioning writer.** `auth-manager.ts#reconcileScimUserLifecycle` (the vendor's `identity.reconcileUser` host callback) calls `scim-identity-source.ts#markDirectoryProvisionedUsers` through the data engine, inside the vendor's SCIM transaction. It also says why the two existing writers never see a SCIM create: the vendor writes no `sys_account` row. - **Names its two postures.** Active state: the mark is written first and fails closed. Inactive state (a deactivation, a `DELETE`, a create with `active: false`): the deprovision write goes first and the mark after it is best-effort, logged at `error` when refused and re-run by the next active write and the boot backfill. - **Names the boot backfill.** The `kernel:ready` pass in `auth-plugin.ts` running `scim-identity-source.ts#backfillScimProvisionedIdentitySource`, keyed on the stored `sys_scim_subject` row, idempotent, run on every boot. - **Gives the reason for the posture.** A sign-in is a person's act that nothing retries, so the first two writers let it succeed and log. A provisioning request is one transaction the identity provider retries, so refusing it costs a delay and leaves nothing half-written, while letting it through unmarked would create a managed user who is offered the local-credential actions D5.2 hides. - **Cites** #32400 (merge commit `2830f31d75`), the contract review record `6792533556` on it, and this card. The note is read from the code at merge commit `2830f31d7510bacbfad4df79786aadea3a31d9f4`, not from the card's prose. `git diff 2830f31 HEAD` over `scim-identity-source.ts`, `auth-manager.ts`, `auth-plugin.ts` and `auth-manager-database-hooks.ts` is empty at this head, so the note describes today's tree as well. No changeset: `docs/adr/**` publishes nothing from any released package, so the PR carries `skip-changeset` (AGENTS.md, Post-Task Checklist step 3). ## Tests None owed. The diff is prose in one ADR; no package is touched, so there is no build closure, no package test and no ablation. ## Acceptance notes - **Where the code is more exact than the card.** The card says the mark is best-effort "on deactivation and delete". The code's branch is the inactive state, which also covers a create with `active: false`; the note says so. The card says the writer runs "inside the directory's transaction"; the code writes through the data engine, which joins the vendor's SCIM transaction as its ambient one; the note says "inside the vendor's SCIM transaction". - **A reading left out of the note.** `reconcileScimUserLifecycle` throws when the host has no data engine, before it branches on the state, so with no engine a deprovision request fails too. Read from the source only, not exercised; a composition with no data engine has no identity tables. Noted here, not written into the ADR. - **`docs/adr/README.md` is stale on `main`, and is not touched here.** `pnpm check:adr-index` (report-only, exit 0) warns that the index is behind. Regenerating it on this branch changes only the record counts (154 to 155) and adds the row for ADR-0150, none of it from this note; the file was restored (`git diff HEAD` empty) because the card's file surface is the one ADR. - **Pre-existing D4 wording, untouched.** D4 places the `account.create.after` stamp in `auth-manager.ts`; the method `AuthManager#stampIdentitySource` is declared there and its body now lives in `auth-manager-database-hooks.ts`. Not a false sentence, and not this card's. ## Round 2 (head `887b96d5a`, after contract review 6810927430) The contract review of record on `79633651b` passed with two should-fix findings and three nits; all five are fixed in one commit and the delta review 6810994159 on `887b96d5a` is PASS with no remaining finding: - the rollback claims are bounded to a datasource that honours transactions, and the declared degrade (ADR-0119 D1: no `transaction` API, or a driver that cannot open one) is named: the request still fails, nothing rolls back, the rows are marked by the next SCIM write or boot; - the inactive-state bullet claims only that the deprovision write already made stands, and names the two cases outside that (a mark failure that aborts the driver transaction; the no-engine throw ahead of the state branch); - the backfill reads "once a pass has completed, a later boot writes only a mark missed since"; the local-password rule is cited at D5.2's second bullet; "no user is left active and unmarked" replaces "no SCIM user is created unmarked". Round-2 gates at `887b96d5a`: `check-adr-links` exit 0 (1124 destinations), `check-adr-symbol-anchors` exit 0 (3544 anchors, 156 records), `check-nul-bytes` exit 0. The Verification block below is the round-1 record at `79633651b`. ## Verification All on `objectstack-ai/objectstack`, head `79633651b` (`origin/main` at `f0f729e71` merged: already up to date). <details><summary>Derived gates: 21 of 21 exit 0</summary> `node scripts/pm/dispatch-gates.mjs --commands --repo objectstack-ai/objectstack` derived 21 commands from the change set (1 path against merge base `f0f729e71`). Each was run with its exit code captured before any pipe: - exit 0: `node scripts/check-adr-links.mjs` (and `--self-test`), `node scripts/check-closing-keyword-parity.mjs` (and `--self-test`), `node scripts/check-comment-mask-corpus.mjs`, `node scripts/ci/plan-test-core-shards.mjs --self-test`, `pnpm check:adr-anchors`, `pnpm check:adr-index`, `pnpm check:adr-symbol-anchors`, `pnpm check:ci-filter-parity`, `pnpm check:closed-ceremony-text`, `pnpm check:cross-package-test-inputs`, `pnpm check:doc-authoring`, `pnpm check:driver-memory-census`, `pnpm check:gitlink-declared`, `pnpm check:nul-bytes`, `pnpm check:pm-governed-merges`, `pnpm check:pm-prior-rulings`, `pnpm check:refd-timer-probe`, `pnpm check:watch-hint-literal`. - `pnpm --filter @objectstack/lint run check:doc-formula-expressions`: first run exit 3, PREREQUISITE NOT MET (`@objectstack/formula` and `@objectstack/lint` not built), read as NOT MEASURED. After `pnpm exec turbo run build --concurrency=2 --filter=@objectstack/formula --filter=@objectstack/lint` under `scripts/pm/os-verify-lock.sh` (VERDICT command-exit 0), the re-run is exit 0. - Verdict lines: `check-adr-links: 1123 relative link destination(s) under docs/adr/ resolve`; `check-adr-symbol-anchors: 3543 anchors across 156 records resolve`; `check:doc-formula-expressions: 25 record-scoped formula example(s) across 566 files / 1840 TS blocks judged clean`. - Reconciliation: `dispatch-gates --ran`: `21 derived famil(ies) accounted for — 21 run, 0 NOT-MEASURED (a DERIVED zero — all 21 recorded an exit code and none of them is 3)`. - NOT MEASURED locally, left to CI: the path-scheduled `Plan Test Core shards` job and the whole-root families the derivation names as too wide to place. </details> --- _Generated by [Claude Code](https://claude.ai/code/session_01Utp6CaqHXh17Qc3C7MRAQw)_ <!-- signed: domain:skills#3 · os-bill · session_01Utp6CaqHXh17Qc3C7MRAQw --> --------- Co-authored-by: Claude <noreply@anthropic.com>
1 parent e424552 commit 89d815c

1 file changed

Lines changed: 51 additions & 0 deletions

File tree

‎docs/adr/0135-identity-and-access-architecture.md‎

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,57 @@ Two markings do that work, at two levels:
151151
> It is marked by role on `sys_member`, not by `sys_user.source`, and D4's markings are unchanged.
152152
> Cloud ADR-0024's own text is not amended here.
153153
154+
> **Note (2026-11-12, objectstack, #32400 landed as `2830f31d75`; contract review `6792533556` on
155+
> #32400, filed as #32450) — a third writer marks SCIM-provisioned users, and it does not fail
156+
> open.** The two writers above both key on an account link. A SCIM directory creates none: the
157+
> vendor keeps its directory links in `sys_scim_user` and `sys_scim_subject` and writes no
158+
> `sys_account` row, so neither writer sees a SCIM create. A user a directory provisions is marked
159+
> by the **SCIM provisioning writer**, on the one seam every SCIM user write passes through — the
160+
> vendor's `identity.reconcileUser` host callback,
161+
> `packages/plugins/plugin-auth/src/auth-manager.ts#reconcileScimUserLifecycle`, which calls
162+
> `packages/plugins/plugin-auth/src/scim-identity-source.ts#markDirectoryProvisionedUsers` through
163+
> the data engine, inside the vendor's SCIM transaction. It has two postures, and the order of the
164+
> writes is the contract:
165+
>
166+
> - **Active state** (a create, a link or re-link, a reprovision, any later write that leaves the
167+
> user active): the mark is written first and **fails closed**. A mark that cannot be written
168+
> fails the SCIM request, and the identity provider retries. On a datasource that honours
169+
> transactions the directory's write rolls back with it, so no user is left active and unmarked.
170+
> On a declared degrade — an engine with no `transaction` API, or a driver that cannot open one
171+
> ([ADR-0119](./0119-plugin-reachable-transactions-and-honest-atomic-batch.md) D1; both are
172+
> named in `packages/plugins/plugin-auth/src/objectql-adapter.ts`) — the request still fails but
173+
> nothing rolls back: the vendor's rows stay committed and unmarked until the next SCIM write
174+
> for that user, or the next boot, marks them.
175+
> - **Inactive state** (a deactivation, a `DELETE`, a create with `active: false`): the deprovision
176+
> write goes first and the mark after it is **best-effort**. A refused mark is logged at `error`
177+
> and swallowed, so the deprovision write already made stands; the next active write for that
178+
> user and the boot backfill re-run the mark. Two cases sit outside that guarantee: a mark
179+
> failure that aborts the driver transaction itself fails the deprovision write with it (that
180+
> is the database, not the mark), and a host with no data engine fails the callback before
181+
> either posture is reached.
182+
>
183+
> The **boot backfill** covers users a directory provisioned before that writer existed: a
184+
> `kernel:ready` pass in `packages/plugins/plugin-auth/src/auth-plugin.ts` runs
185+
> `packages/plugins/plugin-auth/src/scim-identity-source.ts#backfillScimProvisionedIdentitySource`,
186+
> which finds them from a stored fact — each owns a `sys_scim_subject` row — and marks them. It
187+
> runs on every boot and is idempotent: it writes only a row whose value is wrong, so once a pass
188+
> has completed, a later boot writes only a mark missed since (a best-effort mark that did not
189+
> land, or a row a degrade left unmarked). A pass that cannot complete is logged at `error` and
190+
> the boot goes on.
191+
>
192+
> Why this writer does not fail open as the first two do. Those run inside a person's sign-in or
193+
> account link: nothing retries a sign-in, and a provenance write must never break one, so they let
194+
> it succeed and log the stamp that did not land. A provisioning request has no person waiting on
195+
> it, and the identity provider retries what fails, so refusing it costs a delay and, where the
196+
> transaction is real, leaves nothing half-written; letting it succeed unmarked would create a
197+
> managed user who reads `env_native`, and is offered the local-credential actions D5.2 exists to
198+
> hide, until the directory next writes that user or the process next boots. On a deprovision the
199+
> priority inverts: disabling the account is the request's whole purpose, so that write goes
200+
> first and a refused mark does not undo it. The local-password rule is unchanged (D5.2's second
201+
> bullet: gaining a local credential flips the row to `env_native`): the SCIM writer and the
202+
> backfill leave the row of a user who holds a local password as it is, and neither writes
203+
> `env_native` itself. Cloud ADR-0024's own text is not amended here.
204+
154205
### D5 — Identity comes from the IdP; authorization is decided in the environment
155206

156207
Authentication may be delegated. **Authorization never is.** What a signed-in principal may do is

0 commit comments

Comments
 (0)