Skip to content

feat(auth)!: a managed environment adds pending, SSO-only people, and ban works without the admin plugin - #33227

Merged
objectstack-fleet[bot] merged 13 commits into
mainfrom
claude/project-thread-cl505i
Nov 15, 2026
Merged

objectstack-fleet[bot] merged 13 commits into
mainfrom
claude/project-thread-cl505i

Conversation

@objectstack-fleet

@objectstack-fleet objectstack-fleet Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

domain:server#7 · os-tesla · session_01L9qibvhGW6DCBPjrcAPjvh

Requested by Tesla · project thread

Fixes #33181

Clause-②: yes (narrowing) — narrowed: ban works without the admin plugin — admin/ban-user now works without the admin plugin, and a banned row is refused a session, with the admin plugin's own 403 BANNED_USER answer; both ban doors answered 501 NOT_IMPLEMENTED there. Widened: two doors, POST /admin/add-sso-user and POST /admin/import-sso-users (cloud-managed environments only; 409 RESOURCE_CONFLICT elsewhere); the idp_pending value of sys_user.source, which every password door and every session refuses; the auth plugin's optional environmentUserHost option; AuthManager#isAdminPluginMounted(); the exports of pending-sso-marker, environment-user-host and pending-sso-users; and, re-exported from the package root, the helpers bindUserToSoleOrganization, writeAdminAudit, joinCurrentOrganization and multiOrgCreationJoinsCurrentOrganization, the class CreationRefused, the type AdminAuditDecisions (with its user.admin_added_pending event), SetInitialPasswordOptions (the optional third argument of runSetInitialPassword) and the optional getBanWriter, host, getDataEngine and logger members of AdminBanEndpointDeps. The cloud-managed refusals of create-user, import-users and the invitation doors point to Setup → Users.
Metadata-protocol: none
Skills-docs: none — no skill under skills/** teaches the admin user doors, the ban doors or the cloud-managed refusals; content/docs/permissions/authentication.mdx gains the two doors, the pending state, the host option and the ban change in this change.

Owes a contract review. This draft owes a contract review at CONTRACT_REVIEW_TIER (narrowing arm), run in an isolated sub-agent and adopted by the seat, and is not landed before it.

Wording is final. The four cloud-managed 409 sentences (invitation, invitation link, create-user, import-users), kept in one block in cloud-managed.ts, are final per the maintainer's decision 6878953650 on the card.

维护者速读

  • 改了什么:托管环境的管理员可以在「设置 → 用户」通过两个新接口直接加人或导入 CSV,同时带上岗位、权限集和上级;这些人以「待激活」(idp_pending)状态存在,没有密码,在通过云端登录绑定之前,任何设密码、重置密码和其他登录方式都会被拒绝。
  • 为什么改:卡片 plugin-auth: pending, SSO-only users on a managed environment — add and CSV import with position, permission sets and manager, refused by every password door, with a host seam on create, deactivate and reactivate #33181(cloud#4465 子项 1a):种子数据和审批流需要在员工第一次登录前就能指向他们;Free/Team 托管环境没有 admin 插件,原来既不能加人也不能停用人。
  • 风险与回滚:patch 级;对未装 admin 插件的部署是破坏性收紧(BREAKING):停用/恢复(ban/unban)在那里开始生效,被停用的账号拿不到会话;装了 admin 插件的部署行为不变。其余都是新增;回滚就是还原本 PR。
  • 先看:packages/plugins/plugin-auth/src/pending-sso-users.ts(两个入口)、user-session-admission.ts(会话拒绝)、admin-ban-endpoints.ts 与 user-ban-write.ts(无插件时的停用)。
  • 两分钟验证:pnpm --filter @objectstack/plugin-auth exec vitest run src/pending-sso-users.test.ts src/pending-sso-seams.test.ts,预期全部通过。
  • 需要你做的:四句托管 409 文案已按你的决定(6878953650)定稿;合约评审 6879138774 为 PASS,修复后的 delta 复审进行中;改动超过 3000 行人工合并线,复审通过后需你批准。

What changes

Adding a pending person (managed only). Two platform-admin-gated doors, both mounted by the plugin itself and needing no admin plugin:

Door Takes Answers
POST /admin/add-sso-user email, name, optional positions, permissionSets, manager (the manager's email); a closed key set 201; 200 with alreadyPending for a person still pending (the host is told again); 409 for an address already held by someone not pending
POST /admin/import-sso-users { csv } (columns email, name, positions, permission_sets, manager_id, lists ;-separated) or { rows }, at most 500 200 with summary and one result per row; a bad row fails alone, managers resolve in a second pass

Off a managed environment both answer 409 RESOURCE_CONFLICT. The row is written by one engine insert as the system, attributed to the administrator (the AI service-account door's pattern), so it is born idp_pending: no sys_account, email_verified: false, and no moment where it reads env_native. Positions and permission sets are inserted under the caller's own execution context (create-user's grant seam, one unit of work), membership comes from create-user's organization bind, and the manager link is admin/set-user-manager's. An audit row user.admin_added_pending is written after the commit.

What a pending row is refused. admin/set-user-password, set-initial-password (judged after the body is read, through an optional beforeWrite on runSetInitialPassword), /reset-password and /phone-number/reset-password answer 409 RESOURCE_CONFLICT with their own sentence (pending-sso-marker.ts), in every mode. Session creation answers 403 PERMISSION_DENIED (user-session-admission.ts, composed into session.create.before after the AI service-account refusal, and reading the user row in that refusal's one read). The first sign-in through the platform identity provider binds to the row (implicit-linking rule 2) and stampIdentitySource moves it to idp_provisioned in account.create.after, before that sign-in's session; an enterprise provider does not bind (rule 1), and its link does not clear the marker either, since the stamp moves a pending row only on the platform provider's link.

Ban works without the admin plugin. admin/ban-user and admin/unban-user no longer answer 501 there: the ban columns are written through the data engine (engineUserBanWriter, the vendor-shaped write mapped to banned / ban_reason / ban_expires / updated_at; the last-administrator guard judges engine writes in every context), sessions are revoked as before, and session.create.before refuses a banned row with the vendor's own 403 BANNED_USER code and sentence, lifting an expired ban at sign-in as the vendor does. It runs only when the admin plugin is not mounted (AuthManager#isAdminPluginMounted()), so a kernel with the plugin answers exactly as before.

The host seam. environmentUserHost (auth plugin option, read per call) is told userAdded after the person's unit of work commits, and asked userDeactivated / userReactivated before the ban or unban write. It is never called inside a transaction (execution terms, comment 6870710213). A member that throws EnvironmentUserHostRefusal (409, an organization owner or admin; 403, for example DEVELOPER_ORGANIZATION_MEMBER_LIMIT_REACHED) refuses the operation with its own status, code and sentence. A refused deactivation or reactivation writes nothing. A refused add takes that person back out (grants, membership, row) and fails alone on its import row. A refused re-add of a still-pending person leaves that row as it was. Any other throw from a wired host refuses a deactivation (503 SERVICE_UNAVAILABLE, nothing written), since only the host can say whether the person is an organization owner or admin (ruling 5). It never undoes or blocks an add or a reactivation: the answer carries host: { notified: false, reason: 'host_failed' | 'no_host' } and the failure is logged at warn. On the ban doors host appears only when a host is wired. Every event carries actorCloudUserId, the account_id of the administrator's linked objectstack-cloud account, read from sys_account and never from the request (ruling 3), absent where there is no such link; on an impersonation session it also carries impersonatedBy, the administrator at the keyboard, read from the session. A session minted by the host's own sign-in handoff carries no record of its by in the environment; attributing those stays with ruling 9's work.

Re-adding a pending person re-tells the host and changes nothing else: positions, permission sets or a manager sent with the re-add are named on the answer (and on the import row) as notApplied. Only the platform provider's link clears the pending marker; a pending row that already holds its platform account but missed its stamp is stamped at its next session. An import row that faults answers the generic sentence, as the single-add door does.

Elsewhere. sys_user.source gains the option idp_pending ("Pending SSO Sign-In") with its description; the eleven translation bundles are regenerated with check-i18n-bundles.mjs --write. The cloud-managed 409 sentences point to Setup → Users (final, above). Route ledger rows for the two doors; the tenant audit census regenerated for the new write sites; authentication.mdx documents it all.

Unchanged: every env_native and idp_provisioned row at every door; create-user and import-users off a managed environment; the vendor's ban enforcement where the admin plugin is mounted.

Breaking

BREAKING for a deployment without the better-auth admin plugin (auth.plugins.admin off and SCIM off): admin/ban-user now works without the admin plugin, and a banned row is refused a session, with the admin plugin's own 403 BANNED_USER code and sentence; admin/unban-user lifts the ban there too. Level stays patch. ADR-0087 disposition: not-required (no-migration-prescription), in the changeset.

Why

Card #33181, child 1a of objectstack-ai/cloud#4465: a managed environment needs people to exist, with their positions, permission sets and manager, before their first sign-in, so seeds and approval flows can name them; on Free and Team hosted kernels (no admin plugin) there was no add door and no working deactivation. Seat rulings on the card: claim amendments 6869729952 and 6870557312.

Verification

Delta at 032dcc50 (the contract review record 6879138774 on f5a084c7, its should-fixes 1 to 7 and nit 10): pins added in pending-sso-users.test.ts (fail-closed deactivation and its CONTROLs, notApplied on both doors, the generic import fault, impersonatedBy on ban and add) and implicit-account-linking.test.ts (only the platform link clears the marker, with its CONTROL; a missed stamp healed at the next session, with its CONTROL). Ablations, each red: C1 the stamp's provider scope (1 failed), C2 the heal (1), C3 the heal's provider filter (2), C4 fail-closed deactivation (2), C5 notApplied on add (1), C6 on import (1), C7 the generic import sentence (1), C8 impersonatedBy (2). The tenant audit census was regenerated for the new write site (320 sites) and check-tenant-audit-census passes. Typecheck exits 0, pnpm lint exits 0, and check-issue-citations, check-comment-mask-adoption, check-adr-0087-registration, check-empty-changeset, check-i18n-bundles, check:cross-package-test-inputs and check:test-source-alias all exit 0. The plugin-auth full suite passes after a seam-test fake was taught to answer per object (271 files). The check-runs on 032dcc50 are the gate verdicts.

Readings below were taken at be43f4e1 (one commit on origin/main 7257f57a). Head f5a084c7 merges origin/main e540baf8. Only the generated tenant audit census conflicted: it was regenerated with tenant-audit-census.mjs --write, its prose figures were updated to the new count (319 sites), and check-tenant-audit-census passes. After the merge and a rebuild of the packages: plugin-auth typecheck exits 0, check-i18n-bundles exits 0, and the plugin-auth full suite passes (271 files, 5177 passed, 10 skipped). The check-runs on f5a084c7 are the gate verdicts for the merged tree.

Measured at main first

At origin/main 88355328, managed (OS_CLOUD_MANAGED=1) with the admin plugin off, as on a Free or Team hosted kernel: admin/create-user and admin/import-users answer the managed 409, and admin/ban-user / admin/unban-user answer 501 NOT_IMPLEMENTED, so no door adds or deactivates a person there. admin/set-user-password writes a credential on a credential-less env_native row, which is why the pending marker is its own value. The platform provider (objectstack-cloud) binds to an unverified credential-less row and stampIdentitySource restamps it idp_provisioned, while an enterprise provider is refused (rule 1). The new test files fail against main's wiring.

Ablations (each leg mutated through `scripts/ablation-replace.mjs`, red recorded, restored to HEAD)
  • A1 set-user-password pending arm: 2 failed. A2 set-initial-password arm: 2 failed. A3 reset-door arm: 2 failed.
  • A4 session refusal of a pending row: 3 failed. A5 session refusal of a banned row: 7 failed. A6 enforceBan wiring (admin plugin mounted or not): 4 failed. A8 a user-row read fault answers 503: 1 failed. A16 the one session read carries the admission columns: 6 failed.
  • A7 ban writer selection: 2 failed. A13 the engine ban writer refuses an unknown field: 1 failed.
  • A9 off a managed environment: 1 failed. A10 an address held by a non-pending row: 2 failed. A11 an unknown add key: 1 failed. A12 an unknown import column: 1 failed. A15 the marker on the insert itself: 7 failed.
  • A14 the host told on ban: 3 failed.
  • B1 a host refusal stops the ban: 1 failed. B2 stops the unban: 1 failed. B3 only 403 / 409 refusals are honoured: 1 failed. B4 a typed refusal is recognised at all: 5 failed. B5 a refused add takes the person back out: 2 failed. B6 a refused re-add fails the request: 1 failed. B7 the cloud id is read only from the objectstack-cloud account: 3 failed. B8 the ban event carries the cloud id: 2 failed. B9 the take-back removes grants and membership: 1 failed.
  • The dogfood sweeps' classification of the two new doors: both sweeps failed by name before the entries were added (POST /api/v1/auth/admin/add-sso-user, POST /api/v1/auth/admin/import-sso-users), and pass after.
Gates and suites
  • dispatch-gates --commands derived 108 families. All 108 ran with </dev/null, with exit codes recorded first, and --ran reconciles: ✓ 108 derived famil(ies) accounted for — 108 run, 0 NOT-MEASURED (a DERIVED zero — all 108 recorded an exit code and none of them is 3). After the dogfood-table change, the gates that read test sources were re-run: check-issue-citations, check-comment-mask-adoption, check:cross-package-test-inputs and check:test-source-alias, all exit 0.
  • pnpm lint: exit 0. @objectstack/plugin-auth and @objectstack/platform-objects built with declarations: exit 0.
  • @objectstack/plugin-auth full suite: 270 files, 5169 passed, 10 skipped. @objectstack/platform-objects: 122 files, 1958 passed.
  • @objectstack/dogfood: the full run had two failures, the admin-route sweeps naming the two new doors. Both are now classified (ADR-0068 gate first; the admin gets 409 RESOURCE_CONFLICT off a managed environment), and the two sweep files re-run green (15 passed). The rest of the run was green: 461 files passed.

Acceptance notes

  • The cloud-managed 409 sentences are final per the maintainer's decision 6878953650 on the card; a later rewording is its own card.
  • An unreadable source at the three password-door pending arms falls through to the existing arms (the pending arm does not narrow main on a read fault). Session admission refuses 503 on a read fault, as the AI service-account refusal composed before it does.
  • Managed, a pending caller without platform-admin standing meets the cloud-managed set-initial-password refusal first; a pending caller with that standing meets the pending refusal.
  • Follow-up plugin-auth: the environment-user host seam cannot cancel a pending person's invitation, and has no durable retry or per-row invitation status #33228: a pending-only remove door that cancels the invitation, and where the durable outbox with retry and per-row invitation status lives (host-owned or a framework object). Both are execution terms in comment 6870710213 that this PR does not cover.
  • Follow-ups for Managed environments: re-show the add-people actions in Setup → Users (reverse #25295 / #25309's visible predicates for adding) #33186, not in this PR: Setup → Users has no console entry for the two doors yet, and the sys_user ban_user / unban_user actions keep requiresFeature: 'admin', so the console hides them on Free and Team kernels although the doors now answer there.
  • The non-English bundles carry the English option label the generator writes until translated.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic. (packages/spec untouched.)
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes.
  • 4. One issue, one branch off an up-to-date main, one pull request.
  • 5. A change that publishes carries a changeset, and both declaration lines are filled in here and in the changeset.
  • 6. packages/spec touched: its generated artifacts are regenerated and committed. (Not touched; the translation bundles were regenerated by their generator.)
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English. (The 维护者速读 section is the frame's Chinese summary.)
  • The Before Submitting list in CONTRIBUTING.md is done.

🤖 Generated with Claude Code

https://claude.ai/code/session_01L9qibvhGW6DCBPjrcAPjvh

… ban works without the admin plugin

On a cloud-managed environment a platform administrator adds a person
ahead of their first sign-in (admin/add-sso-user) or many from CSV
(admin/import-sso-users), with positions, permission sets and a manager.
The row is born idp_pending: no password, refused by every password door
and by every session until the first sign-in through the platform
identity provider binds to it.

admin/ban-user and admin/unban-user now work without the admin plugin:
the ban columns are written through the data engine and a banned row is
refused a session with the admin plugin's own BANNED_USER answer.

An optional environment-user host is told when a person is added, and
asked before one is deactivated or reactivated; it may refuse with a
typed 409 or 403. Events carry the administrator's cloud user id from
their linked platform account.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvhGW6DCBPjrcAPjvh
…-cl505i

# Conflicts:
#	content/docs/permissions/tenant-audit-census.mdx
#	docs/audits/2026-08-tenant-audit-write-call-sites.counts.md
@github-actions github-actions Bot added size/xl 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 Nov 14, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibvhGW6DCBPjrcAPjvh

Contract-review-claim: session_01L9qibvhGW6DCBPjrcAPjvh · head f5a084c · 2026-11-14T14:40Z

The review runs at CONTRACT_REVIEW_TIER (narrowing face) in an isolated sub-agent of this card thread; the record and its brief follow on this PR, for the seat to adopt.

@github-actions

github-actions Bot commented Nov 14, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/platform-objects, @objectstack/plugin-auth, touching 200 documentable anchor(s). ⚠️ 1 changed file(s) yielded no anchor (packages/plugins/plugin-auth/src/index.ts), so the pages documenting them are NOT COVERED by this run — this is not a clean bill of health for those files.

89 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 6ff3eee7ca595cf1bb5c47e9fc09bb127c0a57d0.

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

What this run could not see
  • 1 changed file(s) yielded no anchor (packages/plugins/plugin-auth/src/index.ts) — pages documenting those are invisible to this run
  • 1 cross-cutting symbol(s) contributed no route anchor: userId (5 routes)
  • 3 anchor(s) matched too much of the corpus to be a work list: sys_user (symbol, 54 pages), PERMISSION_DENIED (literal, 54 pages), sys_user (literal, 54 pages)
  • 22 name(s) were too generic to anchor anything (single lowercase words)
  • the SDK route bridge reached 65 of 247 client-bound route-ledger rows — the other 182 have no registrar path: tail to select them, so pages documenting THEIR client methods cannot appear above, on this or any run. Of those 182: 0 are remediable by widening that discovery convention (an in-repo file declares the path; the convention did not scan it); 59 are structural — on a ledger where NOT ONE row is declared in-repo, so no discovery change reaches them at any price; 123 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 — 24 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 6ff3eee7ca595cf1bb5c47e9fc09bb127c0a57d0 → packageMentionDocs.

Which tree this was computed on

This run read content/docs from 32d1ab8e0dca74a3f04d555351490bc84818515f — the merge of head 58f53919d8a041d1ccbcfba1a1e87fa6c934f31d into base 6ff3eee7ca595cf1bb5c47e9fc09bb127c0a57d0, 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 32d1ab8e0dca74a3f04d555351490bc84818515f && git checkout 32d1ab8e0dca74a3f04d555351490bc84818515f
# afterwards, rebuild it from the two parents, which stay fetchable
git fetch origin 6ff3eee7ca595cf1bb5c47e9fc09bb127c0a57d0 58f53919d8a041d1ccbcfba1a1e87fa6c934f31d && git checkout -B drift-repro 6ff3eee7ca595cf1bb5c47e9fc09bb127c0a57d0 && git merge --no-ff 58f53919d8a041d1ccbcfba1a1e87fa6c934f31d

node scripts/docs-audit/affected-docs.mjs --json 6ff3eee7ca595cf1bb5c47e9fc09bb127c0a57d0

⚠️ 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 6ff3eee7ca595cf1bb5c47e9fc09bb127c0a57d0 → 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

domain:server#7 · os-tesla · session_01L9qibvhGW6DCBPjrcAPjvh

The brief the isolated reviewer was given for the record on head f5a084c7, from record-recognisers.mjs --brief-template, verbatim:

Contract review brief — PR #33227 @ f5a084c771de8823e3fd0a872640441e0518a57f (card #33181)

You review at CONTRACT_REVIEW_TIER. Render ONE ## Contract review record on this head — its shape is
node scripts/pm/record-recognisers.mjs --template — with a PASS or FAIL verdict, and post it as ONE comment
on the PR or its card.

Inputs — these and nothing else:
· card #33181: its body and EVERY comment (rulings and earlier records included)
· PR #33227: its body, its file list, and the net diff against main at f5a084c771de8823e3fd0a872640441e0518a57f
· the check-runs on f5a084c771de8823e3fd0a872640441e0518a57f: their conclusions ARE the gate verdicts
⛔ Not the dispatch order, ⛔ not the dispatching seat's own conclusions — this brief is adversarial by design.

Scope — the paths reviewFace returns as hits on this PR's file list: packages/platform-objects/src/identity/sys-user-identity-source-label.test.ts, packages/platform-objects/src/identity/sys-user.object.ts, packages/plugins/plugin-auth/src/admin-ban-endpoints.ts, packages/plugins/plugin-auth/src/admin-user-endpoints.ts, packages/plugins/plugin-auth/src/auth-manager-before-hook.ts, packages/plugins/plugin-auth/src/auth-manager-database-hooks.ts, packages/plugins/plugin-auth/src/auth-manager.ts, packages/plugins/plugin-auth/src/auth-plugin.ts, packages/plugins/plugin-auth/src/auth-route-ledger.conformance.test.ts, packages/plugins/plugin-auth/src/auth-route-ledger.ts, packages/plugins/plugin-auth/src/cloud-managed.ts, packages/plugins/plugin-auth/src/environment-user-host.ts, packages/plugins/plugin-auth/src/implicit-account-linking.test.ts, packages/plugins/plugin-auth/src/implicit-account-linking.ts, packages/plugins/plugin-auth/src/index.ts, packages/plugins/plugin-auth/src/password-reset-ends-sessions.test.ts, packages/plugins/plugin-auth/src/pending-sso-marker.ts, packages/plugins/plugin-auth/src/pending-sso-seams.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.ts, packages/plugins/plugin-auth/src/service-account-identity.ts, packages/plugins/plugin-auth/src/set-initial-password.ts, packages/plugins/plugin-auth/src/user-ban-write.ts, packages/plugins/plugin-auth/src/user-session-admission.ts, packages/qa/dogfood/test/admin-platform-admin-standing.dogfood.test.ts, packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts;
plus every file IN THIS DIFF that directly implements or enforces them — the gate that enforces a rule, the code
a jsdoc or schema line describes, the validator a skill teaches — reviewed for agreement with the contract.
Widen it freely, ⛔ never below hits; the record's Scope: line names the implementing files apart from hits.
The rest of the diff (tests, unrelated modules, lockfiles, generated output, changesets) is the lane seat's
ACCEPT at TIER_DEFAULT, exactly as a standalone PR of those files.
④ judges the hits files and those implementing files ONLY:
lockfiles, generated output, changesets and prose elsewhere in the PR are not reviewed;
code outside the diff is READ to judge them, never reviewed.

⛔ READ-ONLY. No worktree, no checkout, no build, no test run, no gate re-run, no ablation: the check-runs
on the head already answered every derived gate family, and a local run costs more than it returns.
If ONE probe is unavoidable, the record's Local-runs: line says probe — REASON; otherwise none.
Scratch space is /tmp/claude-0/-home-user/07cb9531-6242-5ae5-ac54-8e9b6b690f1d/scratchpad/pr-33227/ alone; nothing there you did not write this round is read.

Judge, in the record's own sections:
① Derived judgments — every accept-set and public-surface change the diff implies, each named right or wrong.
② Semver level — the changeset (or skip-changeset) matches what the diff publishes, and the Clause-②: line.
③ Boundary flags — every dev flag and every open_questions entry answered, or escalated.
④ Design judgment — for EVERY hits file: does the change hold against the code it cites and the
scenario it is accepted against? A skill file against the card's eval prompt and the spec it teaches
on main; a schema file against the ruling or ADR it implements and its first consumer; an ADR
against its first consumer and its execution plan. For EVERY implementing file in the diff: does the
code agree with the contract, sentence by sentence? Read the cited code in the live tree, and try to
break the design.
Grade each finding must-fix, should-fix or nit — a nit has no effect on correctness or the contract.
A must-fix is a FAIL; a must-fix or should-fix earns a delta review of its fix; nits alone end the round.
A nit is fixed only on the prose faces, or left as an accepted deviation or a follow-up card: a fix
anywhere else moves the head, and this record no longer covers it.
⛔ Judge the tree, never the PR body's account of it.
Sign Implemented-by: with the dev's branch and Reviewed-by: with your session id — the value is the FIRST
thing after each colon.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibvhGW6DCBPjrcAPjvh

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: f5a084c771de8823e3fd0a872640441e0518a57f
Local-runs: none
Scope: packages/platform-objects/src/identity/sys-user-identity-source-label.test.ts, packages/platform-objects/src/identity/sys-user.object.ts, packages/plugins/plugin-auth/src/admin-ban-endpoints.ts, packages/plugins/plugin-auth/src/admin-user-endpoints.ts, packages/plugins/plugin-auth/src/auth-manager-before-hook.ts, packages/plugins/plugin-auth/src/auth-manager-database-hooks.ts, packages/plugins/plugin-auth/src/auth-manager.ts, packages/plugins/plugin-auth/src/auth-plugin.ts, packages/plugins/plugin-auth/src/auth-route-ledger.conformance.test.ts, packages/plugins/plugin-auth/src/auth-route-ledger.ts, packages/plugins/plugin-auth/src/cloud-managed.ts, packages/plugins/plugin-auth/src/environment-user-host.ts, packages/plugins/plugin-auth/src/implicit-account-linking.test.ts, packages/plugins/plugin-auth/src/implicit-account-linking.ts, packages/plugins/plugin-auth/src/index.ts, packages/plugins/plugin-auth/src/password-reset-ends-sessions.test.ts, packages/plugins/plugin-auth/src/pending-sso-marker.ts, packages/plugins/plugin-auth/src/pending-sso-seams.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.ts, packages/plugins/plugin-auth/src/service-account-identity.ts, packages/plugins/plugin-auth/src/set-initial-password.ts, packages/plugins/plugin-auth/src/user-ban-write.ts, packages/plugins/plugin-auth/src/user-session-admission.ts, packages/qa/dogfood/test/admin-platform-admin-standing.dogfood.test.ts, packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts + .changeset/33181-pending-sso-users.md, content/docs/permissions/authentication.mdx

Inputs: card #33181 body and all 8 comments, PR #33227 body and its 51-file list, the net diff against main at this head, and the head's check-runs. Cited code outside the diff was read, not reviewed: sso-only-local-password.ts, last-admin-guard.ts, stampIdentitySource in auth-manager-database-hooks.ts, packages/types/src/thrown-http-error.ts, and better-auth 1.7.12's email-verification, magic-link and email-otp routes.

Check-runs when read (54 total):

  • success: Check Changeset (both runs), PR-body guards (both runs), Governed Surface Queue Guard, Spec property liveness, Flag docs affected by code changes, Check Documentation Links, Check PR Size, Auto Label, filter, Plan Test Core shards, Dogfood Regression Gate, Test UI, Build Docs, Lint · ESLint, Lint · docs & code guards, Lint · repo & tooling gates, Lint · CI, release & engine gates, Lint · PM dispatch-gates, Lint · scoped · tooling self-tests, Lint · scoped · query-options erasure, Type Check · source gates, Type Check · debt ledger.
  • in progress: Test Core 1/8 to 8/8, Build Core, Live E2E UI, Type Check · workspace, Type Check · consumer gates, Lint · scoped · slot lookup & corpus.
  • failed: none. The rest are skipped.
  • This verdict is a design verdict. The in-progress runs remain the gate verdicts, and the PR does not land before they conclude.

① Derived judgments

  • Narrowing, declared, right: admin/ban-user now works without the admin plugin, and a banned row is refused a session. admin/unban-user lifts it there too. The admission runs only when isAdminPluginMounted() is false, so a kernel with the plugin is untouched.
  • Widening, declared, right:
    • POST /admin/add-sso-user and POST /admin/import-sso-users, platform-admin gated first, 409 RESOURCE_CONFLICT off a managed environment.
    • The idp_pending option of sys_user.source.
    • The environmentUserHost option and AuthManager#isAdminPluginMounted().
    • The exports of pending-sso-marker, environment-user-host and pending-sso-users.
    • The audit event user.admin_added_pending, two route-ledger rows and two dogfood sweep entries.
  • Widening, not declared, wrong (should-fix 1): index.ts re-exports admin-user-endpoints.js, set-initial-password.js and admin-ban-endpoints.js with export *. The diff therefore publishes bindUserToSoleOrganization, writeAdminAudit, CreationRefused, joinCurrentOrganization, multiOrgCreationJoinsCurrentOrganization, AdminAuditDecisions, SetInitialPasswordOptions with the third parameter of runSetInitialPassword, and three new optional members of AdminBanEndpointDeps. The Clause-②: line names none of them.
  • New 409 for a pending row at set-user-password, set-initial-password, /reset-password and /phone-number/reset-password: right, and it narrows nothing, since no row carries the marker on main. The four doors are the same set sso-only-local-password.ts names as every door that writes a hash without proving a current one.
  • resolveResetDoorUserId now runs on both reset doors in every mode, where it ran only in SSO-only mode: right. The read spends nothing, swallows its own faults, and a { ok: false } answer is ignored outside SSO-only mode.
  • readSessionUserRow replacing refuseAgentAccountSession's body: right. Same guards, same read fault, same refusal; the old entry point is kept.
  • The four cloud-managed 409 sentences: right, final per decision 6878953650.

② Semver level

Clause-②: yes (narrowing) — matches the tree. One arm from the closed pair, with the BREAKING banner in both the PR body and the changeset.

  • patch on @objectstack/plugin-auth and @objectstack/platform-objects is the level AGENTS.md gives a non-protocol change, breaking or not.
  • Metadata-protocol: none is right: sys_user.source is a system-managed column of a platform object, not something a metadata author writes.
  • The ADR-0087 disposition not-required (no-migration-prescription) is present, and nothing stored needs rewriting.
  • Both Check Changeset runs concluded success.
  • The declaration line is incomplete on the widened side (should-fix 1).

③ Boundary flags

  • Open question, the provisional 409 wording: answered by decision 6878953650.
  • Cancel-on-delete door, durable outbox with retry, per-row invitation status (execution terms, 6870710213): not in this PR, deferred to plugin-auth: the environment-user host seam cannot cancel a pending person's invitation, and has no durable retry or per-row invitation status #33228 as the release comment 6872883193 states. Accepted as a named follow-up. Until it lands, a host failure has no retry other than the administrator repeating the call.
  • Console entry and requiresFeature: 'admin' on the sys_user ban actions: deferred to Managed environments: re-show the add-people actions in Setup → Users (reverse #25295 / #25309's visible predicates for adding) #33186. Accepted.
  • "Adding an email that already has an environment row: decide in child 1a": decided. A pending row answers 200 alreadyPending and re-tells the host; any other row answers 409. See should-fix 4 for what the re-add drops.
  • Escalated to the maintainer (should-fix 2): the term "An owner or admin 409 refuses the whole deactivation" holds only while the host answers. A host that throws anything but a typed refusal lets the ban go ahead. That is the seat's choice in 6869729952, made before the rulings were quoted on the card.
  • Escalated (should-fix 5): the term "attributed through the handoff's by" has no carrier in the event. actorCloudUserId is always read from the session user's own linked account.
  • "Console-side removal: the roster shows that state" is not this child's surface; no finding.

④ Design judgment

A row of the new files per contract sentence, then the findings.

  • pending-sso-marker.ts, sys-user.object.ts and its label test: hold. The marker is its own value, never env_native, as the execution terms require.
  • pending-sso-users.ts: holds for the insert, the grants, the host call and the take-back.
    • The row is born pending in one engine insert, so there is no env_native moment.
    • Grants run under the caller's own context (ruling 2).
    • The host is called outside the unit of work (no transaction across the invite call).
    • A typed refusal takes the person back out, children first.
    • Findings 3, 4, 6 and 7 are here.
  • user-session-admission.ts, auth-manager-database-hooks.ts, service-account-identity.ts: hold. One read per session, 503 on a read fault. Findings 3 and 8.
  • admin-ban-endpoints.ts, user-ban-write.ts, auth-manager.ts, auth-plugin.ts: hold for writer selection, the closed field map and the self-ban refusal. The host is asked before the write. Findings 2, 5, 9 and 10.
  • auth-manager-before-hook.ts, admin-user-endpoints.ts, set-initial-password.ts: the pending arms hold. A source that cannot be read falls through to the existing arms. The PR declares this, and it departs from the fail-closed convention of sso-only-local-password.ts. Accepted as a declared deviation; its one consequence is in finding 3.
  • implicit-account-linking.ts (header only), cloud-managed.ts, environment-user-host.ts, index.ts, the ledger and its conformance list, the two dogfood tables, the two appended test files: agree with the code. environment-user-host.ts carries findings 5 and 10.

Findings:

  1. should-fix — undeclared public exports (see ①), index.ts:86-88 and admin-user-endpoints.ts:478, 525, 607, 953, 980, 1023. Name them on the Clause-②: line in the PR body and the changeset, or stop publishing the helpers.
  2. should-fix, escalated — environment-user-host.ts:175, 192 with admin-ban-endpoints.ts:265. A host that is unreachable cannot say whether the person is an organization owner or admin, and the deactivation proceeds. Ruling 5 says such a person "cannot be removed from the environment side". Either fail closed on deactivated when a host is wired and does not answer, or record the maintainer's word that fail-open stands.
  3. should-fix — the pending marker clears only through stampIdentitySource, which is fail-soft and runs once.
    • It runs only in account.create.after, catches every error, and logs that "the sign-in is fine".
    • If that one write fails, the account link exists, the row still reads idp_pending, and user-session-admission.ts:105 refuses the session.
    • Later sign-ins create no account, so the stamp never re-runs.
    • The stamp also skips a row that holds a credential account, which the declared read-fault fall-through can produce.
    • No door in this PR clears the marker, so the person is locked out.
    • Fix: let admission admit and stamp a pending row that already holds an objectstack-cloud account, or make a failed stamp on a pending row fail the link.
  4. should-fix — pending-sso-users.ts:343 and the second pass at :633. Re-adding a pending person answers ok with alreadyPending and drops the positions, permission sets and manager sent with it. Neither the answer nor authentication.mdx says so, so a corrected CSV reads as applied. Say what was not applied, on the row and in the docs, or apply it.
  5. should-fix — admin-ban-endpoints.ts:167 and pending-sso-users.ts:426. Under an impersonation session actor.id is the impersonated administrator, and the event carries their cloud id; actor.impersonatedBy is dropped. Ruling 3 attributes each invitation to the acting administrator. Carry impersonatedBy on the event; the handoff's by needs the same slot.
  6. should-fix — pending-sso-users.ts:618. The import's per-row catch answers the raw thrown message of any fault, driver text included. The single-add door answers the generic INTERNAL_ERROR_MESSAGE for the same fault. Use the generic sentence for an undeclared 5xx.
  7. One should-fix was reported privately.
  8. nit — user-session-admission.ts: the expired-ban lift writes no updated_at, and a failed lift surfaces as an unshaped error.
  9. nit — admin-ban-endpoints.ts:265: the host is asked before the write. If the write is then refused (the engine's last-administrator guard) or faults, the host has acted and the door answers 500 with no host field. Repeating the call recovers it. This belongs with the outbox on plugin-auth: the environment-user host seam cannot cancel a pending person's invitation, and has no durable retry or per-row invitation status #33228.
  10. nit — three comments disagree with the code:
    • auth-plugin.ts:385-387: the environmentUserHost jsdoc says the host is told "after the operation has committed" and "never undoes the operation". The ban and unban doors ask before the write, and a typed refusal does undo an add.
    • environment-user-host.ts:46: occurredAt is described as the time the operation committed.
    • auth-plugin.ts:4059: "a session that predates the marker" describes a state a born-pending row cannot have.
  11. nit — a re-add that re-tells the host writes no audit row. manager_id names a column that holds an email address.

No must-fix. Findings 1 to 7 each earn a delta review of their fix.

This record was rendered by an isolated sub-agent at CONTRACT_REVIEW_TIER, fed only the brief's inputs.

Implemented-by: claude/project-thread-cl505i
Reviewed-by: session_01L9qibvhGW6DCBPjrcAPjvh

VERDICT: PASS

…ivation waits for the host, re-adds name what they skip

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvhGW6DCBPjrcAPjvh
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibvhGW6DCBPjrcAPjvh

Contract-review-claim: session_01L9qibvhGW6DCBPjrcAPjvh · head 032dcc5 · 2026-11-14T15:09Z

The delta review of record 6879138774 should-fixes 1 to 7, by the same isolated reviewer at CONTRACT_REVIEW_TIER.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibvhGW6DCBPjrcAPjvh

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 032dcc50d16098c43dcbf446e54e98095f96cc37
Local-runs: none
Scope: packages/plugins/plugin-auth/src/admin-ban-endpoints.ts, packages/plugins/plugin-auth/src/auth-manager-database-hooks.ts, packages/plugins/plugin-auth/src/auth-plugin.ts, packages/plugins/plugin-auth/src/environment-user-host.ts, packages/plugins/plugin-auth/src/implicit-account-linking.test.ts, packages/plugins/plugin-auth/src/pending-sso-seams.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.ts, packages/plugins/plugin-auth/src/user-session-admission.ts + .changeset/33181-pending-sso-users.md, content/docs/permissions/authentication.mdx

This is the delta review of record 6879138774 (head f5a084c7), rendered by the same isolated sub-agent at CONTRACT_REVIEW_TIER, fed only the brief's inputs.

Inputs: the delta f5a084c7..032dcc50 (4 commits, 13 files), the PR body as it stands on this head, the changeset, the seat rulings relayed with the delta order, and the head's check-runs. The regenerated tenant audit census and its counts file are generated output and were not reviewed. Cited code read, not reviewed: isPlatformIdpSource in implicit-account-linking.ts, auth-manager-auth-instance.ts, and packages/types/src/error-leak.ts through its index.

Check-runs when read (46 total):

  • success: Governed Surface Queue Guard, PR-body guards (the later run), Spec property liveness, Flag docs affected by code changes, Check Documentation Links, Check PR Size, Auto Label, filter, Lint · PM dispatch-gates, Lint · scoped · tooling self-tests.
  • cancelled: PR-body guards (the earlier run, superseded by the later success).
  • in progress: Check Changeset (both runs), Plan Test Core shards, Build Core, Build Docs, Test UI, Dogfood Regression Gate, Live E2E UI, Lint · ESLint, Lint · docs & code guards, Lint · repo & tooling gates, Lint · CI, release & engine gates, Lint · scoped · query-options erasure, Lint · scoped · slot lookup & corpus, Type Check · workspace, Type Check · source gates, Type Check · debt ledger, Type Check · consumer gates.
  • failed: none. The rest are skipped.
  • This verdict is a design verdict. The in-progress runs remain the gate verdicts, and the PR does not land before they conclude.

① Derived judgments

  • Narrowing arm: unchanged by the delta and still right. admin/ban-user now works without the admin plugin, and a banned row is refused a session.
  • New refusal, right: with a host wired, a host failure that is not a typed refusal now answers 503 SERVICE_UNAVAILABLE on admin/ban-user and writes nothing. This is new on a door that is itself new in this PR for hosts, so it narrows nothing on main. The changeset, the docs and the PR body all state it.
  • Widening, declared, right:
    • impersonatedBy on EnvironmentUserEvent.
    • The exports EnvironmentUserActor and environmentUserAttribution. They fall under "the exports of environment-user-host" already on the line.
    • notApplied on the add answer and on ImportSsoUserRowResult.
  • Behaviour change, right: stampIdentitySource leaves idp_pending on a link from any provider but the platform one. It costs one extra sys_user read per non-platform federated link on every deployment, and changes nothing for a row that is not pending.
  • Behaviour change, right: session admission stamps and admits a pending row that already holds its platform account. One more sys_account read, on pending rows only.
  • Answer change, right: an import row that faults at 5xx answers the generic sentence; a declared refusal keeps its own.

② Semver level

Clause-②: yes (narrowing) — the line is byte-identical in the PR body and the changeset, and matches the tree.

  • The widened side now names every helper, class, type and optional member the package root publishes from this diff.
  • Level patch on both packages, Metadata-protocol: none, the BREAKING banner and the ADR-0087 disposition are unchanged and still right.
  • The changeset's "What to do" paragraph now carries an operator step to run before upgrading. It replaces "nothing" and is consistent with the narrowing arm.
  • Both Check Changeset runs were still in progress when read.

③ Boundary flags

④ Design judgment

Each finding of record 6879138774, against the delta:

  1. Resolved. The eight published names are on the Clause-②: line in both places.
  2. Resolved. admin-ban-endpoints.ts returns the 503 before applyUserBan when the outcome is host_failed.
    • Both failure sources produce host_failed: an accessor that throws, and a member that throws untyped.
    • A typed refusal with a status the seam does not honour also lands here.
    • Reactivation still goes ahead, with host_failed on the answer.
    • Pinned, with three CONTROL legs.
  3. Resolved. healPendingPlatformLink in user-session-admission.ts admits and stamps a pending row that holds an objectstack-cloud account.
    • This covers both a stamp that failed and a stamp skipped because a credential account exists.
    • A read or write fault refuses 503.
    • The ban check still runs after the heal, on the same row.
    • Pinned, with a CONTROL for a row holding only another provider's account.
  4. Resolved. A re-add names the fields or columns it did not apply as notApplied, on the add answer and on the import row. The docs and the changeset say the re-add changes nothing else.
  5. Resolved as ruled. environmentUserAttribution reads impersonatedBy from the gate's actor, never from the body. Both doors use it; pinned on ban and add.
  6. Resolved. pending-sso-users.ts answers INTERNAL_ERROR_MESSAGE for a row fault at 5xx. Pinned, with a CONTROL for a declared refusal.
  7. Resolved. The fix holds against the code it cites, and is pinned with its CONTROL.
  8. Resolved (nit). The expired-ban lift writes updated_at, and a failed lift refuses 503.
  9. Resolved (nit). The environmentUserHost jsdoc, the occurredAt jsdoc and the set-initial-password comment now agree with the code.

New in the delta:

  • nit A — admin-ban-endpoints.ts:284. The fail-closed arm keys on host_failed only. An accessor that is wired but answers no host (no_host) lets the deactivation go ahead, as an unwired option does. That matches "read per call, so a host wired late is still found". It does mean a managed host must return a host or throw; it must never answer undefined while it starts. This is a sentence for the host's contract in environment-user-host.ts, or for plugin-auth: the environment-user host seam cannot cancel a pending person's invitation, and has no durable retry or per-row invitation status #33228.
  • nit B — PR body, "What a pending row is refused": it still gives rule 1 as the only reason an enterprise provider does not bind. The stamp's provider scope is the second reason, and the body states it two paragraphs later. Prose only.
  • One nit was reported privately.

No must-fix and no should-fix. The nits end the round.

Implemented-by: claude/project-thread-cl505i
Reviewed-by: session_01L9qibvhGW6DCBPjrcAPjvh

VERDICT: PASS

…double

The sys_account matcher in the admission test double read `$and`/`$or` as
field names. It now refuses any operator key, per the where-matcher
conformance gate. The host accessor's contract comment also states that a
managed host answers a host or throws, never `undefined` while starting.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvhGW6DCBPjrcAPjvh
The import-fault test wrapped the engine's `insert` and passed a third
argument its declared signature does not take, which the test-layer
typecheck reports. The wrapper now forwards whatever it receives.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvhGW6DCBPjrcAPjvh
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 84a7069f3fc371157db6d470bb0f6f49178a0cc4
Local-runs: none
Scope: packages/plugins/plugin-auth/src/environment-user-host.ts, packages/plugins/plugin-auth/src/pending-sso-seams.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.test.ts

The seat's own read of the part of this head no record covers: 032dcc50..84a7069f, two commits, three files, +14 / -5. Everything else on this head is judged by record 6879138774 (f5a084c7, PASS) and its delta 6879497274 (032dcc50, PASS), both under brief 6879131946.

① Derived judgments

  • environment-user-host.ts: a jsdoc on EnvironmentUserHostAccessor only (delta nit A). It states what the code at admin-ban-endpoints.ts already does: an accessor that answers no host is treated as no host wired, and the deactivation goes ahead. No type, value or export moves. Right.
  • pending-sso-seams.test.ts: the sys_account test double now throws on any $ key in where instead of reading it as a field name (the WHERE-matcher conformance gate). A test double only. Right.
  • pending-sso-users.test.ts: the import-fault test's insert wrapper forwards rest arguments instead of a declared third parameter the signature lacks (TS2554 under check:test-typecheck). Test only; the assertion is unchanged. Right.

② Semver level

Unchanged: Clause-②: yes (narrowing), patch on both packages, Metadata-protocol: none. Nothing in this delta publishes.

③ Boundary flags

None new. Delta nit A is answered by the comment; nit B was a PR-body edit.

④ Design judgment

No design moves in this delta. The comment narrows nothing and the two test edits keep their assertions. Check-runs on this head: 38 success, 15 skipped, 0 failed.

Implemented-by: claude/project-thread-cl505i
Reviewed-by: session_01L9qibzuZJBQY4wUQFJbkfx

VERDICT: PASS

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

维护者速读 · PR #33227 @ 84a7069f · 2026-11-14T16:12Z

  • 改了什么:托管环境的管理员可以通过两个新接口(POST /admin/add-sso-user、POST /admin/import-sso-users)直接加人或导入 CSV,带上岗位、权限集和上级。这些人以「待激活」(sys_user.source = idp_pending)存在,没有密码,在通过平台登录绑定之前,设密码、重置密码和其他登录方式都会被拒绝。没有 admin 插件的部署上,停用/恢复(admin/ban-user / unban-user)开始生效,被停用的账号拿不到会话。
  • 为什么改:plugin-auth: pending, SSO-only users on a managed environment — add and CSV import with position, permission sets and manager, refused by every password door, with a host seam on create, deactivate and reactivate #33181(cloud#4465 子项 1a):种子数据和审批流需要在员工第一次登录前就能指向他们;Free/Team 托管环境没有 admin 插件,原来既不能加人也不能停用人。
  • 权限与边界:这是收窄(标题带 !):对没有 admin 插件的部署,停用开始生效;装了 admin 插件的部署行为不变。宿主接上时,若宿主不回答「此人是否组织所有者/管理员」,停用以 503 拒绝(按裁定 5,失败即关闭)。两个新接口只对平台管理员开放,非托管环境答 409。
  • 风险与回滚:升级前,没有 admin 插件的部署应先检查已被标记停用的行(尤其唯一的平台管理员)并先恢复,changeset 的 "What to do" 写了步骤。回滚即 revert;idp_pending 只出现在新接口建的行上。
  • 先看:packages/plugins/plugin-auth/src/pending-sso-users.ts(两个入口)、user-session-admission.ts(会话拒绝与自愈)、admin-ban-endpoints.ts 与 user-ban-write.ts(无插件时的停用)。
  • 需要你做的:改动 3392 行,超过 3000 行人工合并线,需要你(os-zhuang)在 GitHub 上批准,批准后席位按队列落地。现 head 84a7069f 的 PASS:席位记录 6880408199(覆盖 032dcc50..84a7069f),其余由 6879138774 与 6879497274 覆盖。
  • 席位意见:落地。Clause-② yes (narrowing),CONTRACT_REVIEW_TIER 复审 PASS(7 条应修),修复后 delta PASS;CI 无失败,完整 dogfood 通过,非受管面。

席位核对

  • 形态: draft → main,Fixes #33181,合并后卡关闭;正文其他地方没有挨着别的 open 卡号的闭合关键词。
    • 申报 Clause-②: yes (narrowing)(收窄面:无插件时停用生效;加宽面逐项列出,含 delta 后补上的八个公开名字)、Metadata-protocol: none、Skills-docs: none,changeset 对 @objectstack/plugin-auth 与 @objectstack/platform-objects 各 patch,带 BREAKING 横幅与 ADR-0087 标记。
    • 文件面 = 认领 6869596244 加修订 6869729952、6870557312;本席恢复认领 6880041500。
  • 前提实测: dev 报告 6872845977:在 origin/main 上先测了卡里的行号与 Free 托管内核上 admin/ban-user 的 501;宿主拒绝、动作者云 id 等 B1-B9 消融全部变红。修复轮每条应修都有钉(含 CONTROL)。plugin-auth 全量 5177 条通过(合并 main 后)。
  • 门禁 check-runs @ 84a7069f: 38 success、15 skipped、0 失败、0 进行中。
  • 完整 dogfood(标题带 !)@ e1637d82: 先重建 plugin-auth dist,os-verify-lock: VERDICT command-exit 0,测试文件 464 通过 / 3 跳过,测试 3927 通过 / 42 跳过。84a7069f 只在其上改了一个测试文件的类型(dogfood 不加载它),结论覆盖当前头。
  • 契约复审: CONTRACT_REVIEW_TIER(收窄面)。卡线程的隔离审读子代理按简报 6879131946 出记录,认领 6879011881;本席核对简报、范围与独立性后采纳。
    • 全量记录 6879138774 在 f5a084c7 上 PASS,7 条应修:1 公开导出未申报;2 宿主不回答时停用照样进行(席位改为失败即关闭,裁定 5);3 待激活标记只靠一次失败即放过的写清除;4 重复添加悄悄丢掉岗位等;5 代管会话下事件丢了 impersonatedBy;6 导入逐行把驱动原文回给调用方;7 一条私下报告的应修。
    • delta 记录 6879497274 在 032dcc50 上 PASS:1-7 全部解决,细节 8、10 解决。
    • 032dcc50..84a7069f 只改测试替身(WHERE 匹配器遇到 $ 运算符即抛出)、pending-sso-users.test.ts 的一处类型错误、environment-user-host.ts 的一句注释(delta 细节 A);席位自读记录 6880408199 在 84a7069f 上 PASS。
  • 接受的偏差:
    • PR 正文顶部仍写着「Owes a contract review」和维护者速读里「delta 复审进行中」,已过期,以本评论为准:两轮复审都已 PASS。
    • delta 细节 A(宿主访问器接上但返回空时停用照样进行):已在 environment-user-host.ts 的合同注释里写明宿主必须返回宿主或抛出。
    • 细节 11(重复添加再次通知宿主时不写审计行;manager_id 存的是邮箱)。
  • 范围外去向: 待激活行的删除与取消邀请、持久化发件箱与重试、逐行邀请状态 → plugin-auth: the environment-user host seam cannot cancel a pending person's invitation, and has no durable retry or per-row invitation status #33228(细节 9「宿主在写之前已行动」同去);控制台入口与 requiresFeature: 'admin' → Managed environments: re-show the add-people actions in Setup → Users (reverse #25295 / #25309's visible predicates for adding) #33186;交接的 by 字段 → 裁定 9 的工作。
  • 落地条款: 维护者常设落地令 「按 pm-dispatch 审过的pr你可以自主落地」 (2026-10-30T14:20Z),按 「车道座位应该使用pm-dispatch 技能审核和落地pr」 (2026-11-14T14:32Z)。
    • 非受管面:check-governed-merges --pr 33227 判定 0/51 命中。3392 行(+3279 / -113)> 3000:人工合并线(2026-09-18 裁定)。本席不转 ready、不入队、不开自动合并,直到 GOVERNED_APPROVERS 中的账号批准;同笔 PR 加 pm:awaiting-merge,并请 os-zhuang 与 hotlong 审查。
    • K = 6(PRBASE 199e3624,取自 Plan Test Core shards 的 Affected-set diff base;其后 main 中 fix(plugin-auth): a SCIM bearer write carrying a Cookie and no Origin is no longer refused 403 MISSING_OR_NULL_ORIGIN #33243 a2be78d0 也改 plugin-auth(SCIM 写的 Origin 检查),与本 PR 的文件不重叠)。git merge-tree 无冲突。
    • 没有新的语种包。

@objectstack-fleet objectstack-fleet Bot added the pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue label Nov 14, 2026
The implicit account-linking suite conflicted with the SSO proven-domain
rule's tests. Both describe blocks are kept whole, in order.

Co-Authored-By: Claude <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01L9qibvhGW6DCBPjrcAPjvh
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:server#7 · os-tesla · session_01L9qibzuZJBQY4wUQFJbkfx

Re-land · 2026-11-15T07:27Z · PR #33227 @ 58f53919

  • Why it left the queue: MERGE_CONFLICT at 04:45Z in the two tenant-audit census files after main moved.
  • Carried record for the hop 2ab05f46..d734f195 (seat self-read: PASS): one merge of main (3c0033f9). git show --cc d734f195 touches three paths:
    • content/docs/permissions/tenant-audit-census.mdx and docs/audits/2026-08-tenant-audit-write-call-sites.counts.md: regenerated on the merged tree with the census script (--write), plus prose figures moved to the regenerated counts (321 sites; 226 decidable; 181 elevated; 128 undecidable; cite 3 / 321). Numbers only; check-tenant-audit-census OK.
    • packages/plugins/plugin-auth/src/admin-user-endpoints.ts: an automatic merge of main's new membershipCreated rule (a yielded bind now answers true) with this PR's export of bindUserToSoleOrganization, with no hand edit. The PR's caller in pending-sso-users.ts reads only organizationId, so the rule change does not reach it.
    • The review seat's delta 6889074200 (PASS at 2ab05f46) and records 6879138774, 6879497274, 6880408199 and 6885176188 still judge the branch's own code.
  • Hop d734f195..f16792da (seat self-read: PASS): CI was green at d734f195, but K = 16 since PRBASE 3c0033f9, so the branch merged main (b95d9156) once more. git show --cc f16792da is empty, and the commit's tree 776e3617 equals git merge-tree --write-tree d734f195 b95d9156: no conflict, no hand edit, no os-regen path. The card thread reports the census still at 321 (check-tenant-audit-census OK) and plugin-auth typecheck, suite (277 files / 5437 tests), eslint, where-matcher, i18n-bundles and issue-citations all green.
  • Hop f16792da..58f53919 (seat self-read: PASS): f16792da got no CI because fix(plugin-auth)!: with SSO domain verification on, an SSO sign-in links to an existing account, or changes its email address, only at a domain the provider has proven #33307 (de5eb084) landed and made the PR dirty in plugin-auth/src/implicit-account-linking.test.ts. The branch merged main (6ff3eee7). git show --cc 58f53919 touches two paths, and every line in it comes from one parent or the other, with no line new to the merge:
  • Approval: os-zhuang review 5907242051 stands across main merges per the maintainer (re-land 6885182578).
  • Gates at 58f53919: green, 53 check runs: 38 success, 15 skipped, none failed.
  • K = 9 (PRBASE 6ff3eee7). git merge-tree is clean.
  • The jump audit 6888826889 (letters (b) and (c)) still holds for this head.

@objectstack-fleet
objectstack-fleet Bot added this pull request to the merge queue Nov 15, 2026
Merged via the queue into main with commit cbb876c Nov 15, 2026
53 checks passed
@objectstack-fleet
objectstack-fleet Bot deleted the claude/project-thread-cl505i branch November 15, 2026 08:07
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract-review-claim: session_01FEkQ5nhu4dRbKVQKDB4CDB · head 58f5391 · 2026-11-15T08:10Z

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

review#2 · os-project-manager · session_01FEkQ5nhu4dRbKVQKDB4CDB

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 58f53919d8a041d1ccbcfba1a1e87fa6c934f31d
Local-runs: probe — blob-level three-way merge comparison of the hop's merges in scratch (git merge-file on downloaded blobs, tree-listing compares); no build, test or gate run
Scope: docs/audits/2026-08-tenant-audit-write-call-sites.counts.md, packages/platform-objects/src/apps/translations/ar.objects.generated.ts, packages/platform-objects/src/apps/translations/ar.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/de.objects.generated.ts, packages/platform-objects/src/apps/translations/de.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/en.objects.generated.ts, packages/platform-objects/src/apps/translations/es-ES.objects.generated.ts, packages/platform-objects/src/apps/translations/es-ES.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/fr.objects.generated.ts, packages/platform-objects/src/apps/translations/fr.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts, packages/platform-objects/src/apps/translations/ja-JP.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/ko.objects.generated.ts, packages/platform-objects/src/apps/translations/ko.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts, packages/platform-objects/src/apps/translations/pt-BR.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/ru.objects.generated.ts, packages/platform-objects/src/apps/translations/ru.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts, packages/platform-objects/src/apps/translations/zh-CN.source-hashes.generated.ts, packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts, packages/platform-objects/src/apps/translations/zh-Hant.source-hashes.generated.ts, packages/platform-objects/src/identity/sys-user-identity-source-label.test.ts, packages/platform-objects/src/identity/sys-user.object.ts, packages/plugins/plugin-auth/src/admin-ban-endpoints.ts, packages/plugins/plugin-auth/src/admin-user-endpoints.ts, packages/plugins/plugin-auth/src/auth-manager-before-hook.ts, packages/plugins/plugin-auth/src/auth-manager-database-hooks.ts, packages/plugins/plugin-auth/src/auth-manager.ts, packages/plugins/plugin-auth/src/auth-plugin.ts, packages/plugins/plugin-auth/src/auth-route-ledger.conformance.test.ts, packages/plugins/plugin-auth/src/auth-route-ledger.ts, packages/plugins/plugin-auth/src/cloud-managed.ts, packages/plugins/plugin-auth/src/environment-user-host.ts, packages/plugins/plugin-auth/src/implicit-account-linking.test.ts, packages/plugins/plugin-auth/src/implicit-account-linking.ts, packages/plugins/plugin-auth/src/index.ts, packages/plugins/plugin-auth/src/password-reset-ends-sessions.test.ts, packages/plugins/plugin-auth/src/pending-sso-marker.ts, packages/plugins/plugin-auth/src/pending-sso-seams.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.test.ts, packages/plugins/plugin-auth/src/pending-sso-users.ts, packages/plugins/plugin-auth/src/service-account-identity.ts, packages/plugins/plugin-auth/src/set-initial-password.ts, packages/plugins/plugin-auth/src/user-ban-write.ts, packages/plugins/plugin-auth/src/user-session-admission.ts, packages/qa/dogfood/test/admin-platform-admin-standing.dogfood.test.ts, packages/qa/dogfood/test/admin-route-nonadmin-refusal.dogfood.test.ts + .changeset/33181-pending-sso-users.md, content/docs/permissions/authentication.mdx, content/docs/permissions/tenant-audit-census.mdx

This is the delta review of record 6889074200 (head 2ab05f46), for the hop 2ab05f46..58f53919. Records 6879138774, 6879497274, 6880408199, 6885176188 and 6889074200 still judge the branch's own code, which this hop does not change. The scope line is the earlier record's; the hop adds no implementing file.

Landing note: the PR merged as cbb876c1 at this head before this seat's claim 6891504565 was posted, on the lane's own self-read of the three hops (re-land 6891065471). This record judges the landed head after the fact; it does not stand in as the pre-landing gate.

Inputs: record 6889074200, every PR comment after it, the hop's compare, the tree of each merge and of both its parents, the PR's net diff against each head's main parent, and the head's check-runs. Read at the head, not reviewed: reconcile-membership.ts, auth-manager-auth-instance.ts, sso-sign-in-options.ts, and main's side of objectql-adapter.ts, direct-sign-in.ts and sign-in-method-floor.ts.

What the hop is, read from the tree:

  • 94 commits. 91 are main's own. Three are merges of main: d734f195 (parents 2ab05f46, 3c0033f9), f16792da (parents d734f195, b95d9156) and 58f53919 (parents f16792da, 6ff3eee7). The PR adds no commit of its own.
  • In all three merges, every path changed on one side only carries that side's blob, and no path changed by neither side moved.
  • d734f195: 25 paths changed on both sides. 23 of them (the 21 translation bundles, admin-user-endpoints.ts, auth-manager.ts) are byte-identical to an automatic three-way merge. The two tenant audit census files conflicted and were regenerated; they are the only files in the hop holding lines that come from neither parent.
  • f16792da: no path changed on both sides. Every blob is one parent's.
  • 58f53919: 3 paths changed on both sides. auth-manager.ts and implicit-account-linking.ts are byte-identical to an automatic merge. implicit-account-linking.test.ts had one conflict; the resolved file holds no line that is absent from both parents.
  • Net diff against the main parent, at 2ab05f46 and at this head: the same 51 files. On 49 of them the added and removed lines are identical; only hunk positions and context lines moved. The two census files differ by one more changed line each, numbers only.

Check-runs on this head (54): 39 success, 15 skipped, 0 failed, 0 in progress.

① Derived judgments

  • The net diff did not change on any scope file other than the census counts file. Right.
  • implicit-account-linking.ts: the PR's net change is still the same 14 doc lines, the pending-person section, and no code. main (fix(plugin-auth)!: with SSO domain verification on, an SSO sign-in links to an existing account, or changes its email address, only at a domain the provider has proven #33307) adds rule 4 around it. The composed rule set is coherent:
    • Rule 4 is judged only for an SSO provider source with domain verification on, and it can only refuse. It runs before rules 1 to 3 and relaxes none of them.
    • The pending person's one link, the platform identity provider's sign-in, is not an SSO provider source. Rule 4 does not judge it, so that link lands exactly as it did at the earlier head.
    • An enterprise provider's implicit link to a pending row is still refused. Rule 4 may refuse it first; when rule 4 admits the address, rule 1 refuses it as before. Nothing the pending path refused is admitted, and nothing it admitted is refused.
    • Rule 4's second half judges a sign-in into an account the SSO provider is already linked to. A pending row has no account, so it is not reached.
    • The PR section's sentence that an enterprise provider gets no such link by rule 1 is still true of the tree. Right.
  • implicit-account-linking.test.ts: the PR's 139 added lines are identical. Its pending-person describe is whole, followed by main's proven-domain describe whole. Right.
  • admin-user-endpoints.ts: the PR's added and removed lines are identical; only main's jsdoc context moved. bindUserToSoleOrganization now answers membershipCreated: true for a yielded bind as well as a bound one.
    • The PR's caller in pending-sso-users.ts reads only organizationId and writes its audit row's membershipCreated as "an organization was returned".
    • The reconciler returns an organization for bound and yielded and for no other outcome, so the caller's value equals main's new rule on every outcome. Before the hop the caller already answered true on yielded; main now agrees with it.
    • joinCurrentOrganization always returns its organization and now always reports true, which is again what the caller writes. The caller gets what it relies on. Right.
  • auth-manager.ts: main changed it twice in the hop (fix(auth)!: a SAML provider keys its accounts on a stable attribute (Entra object id by default), so the app and the IdP portal reach one account #33490, a SAML account key; fix(plugin-auth)!: with SSO domain verification on, an SSO sign-in links to an existing account, or changes its email address, only at a domain the provider has proven #33307, one jsdoc paragraph). Both merged automatically, far from the PR's two hunks, whose lines are identical. This is the overlap ③ of record 6889074200 read ahead as disjoint; in the tree it is. Right.
  • The 21 translation bundles: main and the PR both changed them, on different keys. The merged files equal an automatic merge and the PR's net lines are identical. The generated checks on this head are green.
  • The census files: main moved from 314 to 315 write sites. The PR's net change is still plus 6, over the same five per-file rows; the totals read 321. The census gate is green on this head.
  • main's other changes near the PR's code (objectql-adapter.ts at a SAML sign-in only, direct-sign-in.ts, sign-in-method-floor.ts, sso-account-at-proven-domain.ts) touch no PR path. None is imported by the PR's new modules.

② Semver level

Unchanged: Clause-②: yes (narrowing), patch on @objectstack/plugin-auth and @objectstack/platform-objects, Metadata-protocol: none. The declaration line is the same in the PR body and the changeset at this head. The merges publish nothing of their own. Check Changeset is green.

③ Boundary flags

④ Design judgment

Each finding of record 6889074200: it carried no new finding. Its one boundary flag, the main commit #33490 then outside the head, is now inside it and composes as that record read it.

Findings still open from the earlier records, against this hop:

New in the hop:

  • The net diff is unchanged on every scope file but the census counts, and the composition holds on both files main changed under the PR: the pending-person rule beside rule 4, and the PR's caller under the new membershipCreated rule. No must-fix, no should-fix.
  • Nit, accepted as a deviation: the regenerated census files carry the stamp 2ab05f460, the branch head before the merge, while the counts are those of the merged tree. The gate judges the counts and is green; the next regeneration restamps.
  • Nit, accepted as a deviation: pending-sso-users.ts derives its audit row's membershipCreated from the returned organization instead of reading the helper's own flag. The two agree on every outcome the reconciler produces. No effect on correctness or the contract.

Implemented-by: claude/project-thread-cl505i
Reviewed-by: session_01FEkQ5nhu4dRbKVQKDB4CDB

VERDICT: PASS

This was referenced Nov 15, 2026
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
… is no longer refused 403 MISSING_OR_NULL_ORIGIN (objectstack-ai#33243)

Fixes objectstack-ai#33237

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 改了什么:`AuthManager.handleRequest` 在把请求交给 better-auth 之前,对带
`Authorization: Bearer` 的 `/scim/v2/*` 请求去掉 `Cookie` 头;其余路由一律不动。
- 为什么改:better-auth 的来源检查只要请求带任何 Cookie 就要求 `Origin`,于是带 Cookie 罐(如
Cloudflare `__cf_bm`、粘性会话 Cookie)的身份提供方(Okta 已实测)做 SCIM 开通与停用全部被拒
403,离职员工的访问无法由目录撤销。SCIM 只认 bearer,Cookie 在该路径上不带任何权限。
- 风险与回滚:风险面只有「`/scim/v2/*` 且带 bearer」这一种请求;无 bearer 的 SCIM
请求与所有浏览器路由仍走原来的来源检查。回滚即 revert 本 PR 的那一个 `if` 块。
-
先看:`packages/plugins/plugin-auth/src/auth-manager-request-routing.ts`(新增的
`if`
块,判定条件三项是风险点);`packages/plugins/plugin-auth/src/scim-bearer-cookie-origin.test.ts`(四个用例与
`boot()` 里把来源检查打开的那几行)。
- 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/scim-bearer-cookie-origin.test.ts`,预期 4 个用例全绿。
- 需要你做的:无,席位落地。

## What changes

`packages/plugins/plugin-auth/src/auth-manager-request-routing.ts`,
`handleRequest`: right after the vendor client-address rewrite, a
request whose better-auth endpoint path is under `/scim/v2`
(`isScimProtocolPath`, the predicate the SCIM request scope already keys
on) AND that carries `Authorization: Bearer` followed by a credential
AND that carries a `Cookie` is rebuilt without the `Cookie` header
before better-auth sees it. This is the route that relaxes no check: no
global or per-path origin-check exemption is added, and
`skipOriginCheck` / `disableCSRFCheck` are not touched.

Why it is safe, measured on better-auth 1.7.12 and `@better-auth/scim`
1.7.12 as installed:

- `validateOrigin` (`dist/api/middlewares/origin-check.mjs`) reads
`useCookies = headers.has("cookie")` off the request `handleRequest`
hands it; with a cookie and no Origin or Referer it throws
`MISSING_OR_NULL_ORIGIN`. That is the whole defect.
- Every `/scim/v2/*` mutation endpoint is `use: [authMiddleware]`, and
that middleware (`createSCIMConnectionMiddleware`) authenticates from
`Authorization: Bearer` alone: no bearer is `401 SCIM bearer token is
required`. The platform's `verifyBearerToken`
(`auth-manager-plugin-list.ts`) reads only `input.token`.
- SCIM writes are attributed to the verified connection
(`authSystemWriteContext` returns `actor: svc:scim:CONNECTION_ID` first
and never consults the session resolver when a SCIM connection is in
scope), so stripping the cookie changes no attribution either.
- A SCIM request with NO bearer keeps its cookie and still meets the
origin check (pinned below).

The landing is the expected file; no producer elsewhere was needed.
`auth-manager.ts`, `auth-plugin.ts` and the better-auth pin are
untouched.

`.changeset/33237-scim-bearer-cookie-origin.md`:
`@objectstack/plugin-auth` patch.

## Tests

New file
`packages/plugins/plugin-auth/src/scim-bearer-cookie-origin.test.ts`
(real `AuthManager`, real `ObjectQL` on better-sqlite3, SCIM on, a
minted connection credential: the `scim-transaction-scope.test.ts`
harness shape). Four cases:

1. SCIM bearer `POST /Users` with `Cookie: __cf_bm=...;
better-auth.session_token=` and no Origin: 201 and the `sys_user` row
exists.
2. SCIM bearer `PATCH /Users/{id}` `active:false` with the same Cookie
and no Origin: 200, resource `active: false`.
3. SCIM `POST /Users` with the Cookie and NO bearer: still 403, `code`
`MISSING_OR_NULL_ORIGIN`, no `sys_user` row written.
4. CONTROL: a real session cookie (from sign-up) on `POST /sign-out`
with no Origin: still 403, `code` `MISSING_OR_NULL_ORIGIN`.

How production semantics are ensured: two things would mask the bug
under vitest, and the harness turns off both. `handleRequest`
synthesizes a same-origin Origin outside production: every case runs
with `vi.stubEnv('NODE_ENV', 'production')` and asserts it reads back.
And better-auth reads NODE_ENV once at module load
(`@better-auth/core/env`), so under vitest it defaults `skipOriginCheck`
to `true` (`create-context.mjs`: `disableOriginCheck` unset means
`isTest()`): `boot()` sets the production value `false` on the live
`$context` and asserts `skipCSRFCheck` is `false`. Before that line was
added, cases 3 and 4 were red on the unfixed tree (the control POST
answered 200), which is how the masking was found.

Red on the unfixed tree (commit e9076fa, test only): cases 1 and 2
fail with `{"message":"Missing or null
Origin","code":"MISSING_OR_NULL_ORIGIN"}: expected 403 to be 201` (and
`to be 200`); cases 3 and 4 pass.

Ablation (one-time, on the fix commit c8abb27, through
`scripts/ablation-replace.mjs`): the anchor `headers.delete('cookie');`
replaced by a comment, anchor 1 to 0, blob 944e5a3 to efaf0d39e2b3;
cases 1 and 2 red again with 403, cases 3 and 4 green; restored, blob
after restore 944e5a3 equals HEAD and `git diff HEAD` empty. The
test imports `./auth-manager.js` relatively, so the subject resolves to
`src/`, no `dist/` step.

## Acceptance notes

- Behaviour change beyond the card's three cases, stated so it is not a
surprise: a `/scim/v2/*` bearer request that carries a Cookie AND an
untrusted Origin used to be refused 403 `INVALID_ORIGIN`; it now reaches
the SCIM bearer check like any bearer client. Same reasoning: the origin
check guards cookie authority, and there is none on this path.
- The vendor's origin check is skipped wholesale under a test NODE_ENV,
so any plugin-auth test that means to observe it must put
`skipOriginCheck = false` on the context as `boot()` here does.
Observation only; no card.
- The cloud hosted proxy strip (cloud#4498) can retire once a release
carrying this reaches cloud's pin; that is cloud's and the maintainer's
call on cloud#4491.

## Verification

All readings at head c8abb27 (worktree on `origin/main` 6c5d31f).

<details>
<summary>plugin-auth tests and typecheck: 270/270 files, 5118 passed,
typecheck exit 0</summary>

- `pnpm --filter @objectstack/plugin-auth exec vitest run
--maxWorkers=2` (whole package): `Test Files 270 passed (270)`, `Tests
5118 passed | 10 skipped (5128)`, lock `VERDICT command-exit 0`.
- `pnpm --filter @objectstack/plugin-auth typecheck`: exit 0;
`check:test-typecheck: OK ... 10 file(s) / 72 error(s) / 23 pinned
signature(s) held` (the new file adds none).

</details>

<details>
<summary>lint: exit 0</summary>

- `pnpm lint` (repo-wide, run on the dispatch's request): lock `VERDICT
command-exit 0`.
- `eslint --no-inline-config` on the two changed TS files: exit 0.

</details>

<details>
<summary>derived gate families: 65 exit 0, 1 NOT MEASURED</summary>

- `node scripts/pm/dispatch-gates.mjs --commands`: 66 derived families,
each run locally; `--ran` reconciliation: `66 derived famil(ies)
accounted for — 65 run, 1 NOT-MEASURED (1 DERIVED from a recorded exit
3)`.
- `pnpm check:dual-build-cjs-loads` exit 3 `PREREQUISITE NOT MET` (it
needs every package's `dist/`; this worktree built only plugin-auth's
closure): NOT MEASURED locally, CI runs it.
- `node scripts/check-nul-bytes.mjs`: exit 0.
- Not run locally, owned by CI: `test:repo`, the dogfood battery (no `!`
in the title, no narrowing arm), the UI lanes.

</details>

Overlap check before push: open drafts objectstack-ai#33227 and objectstack-ai#33221 do not touch
`auth-manager-request-routing.ts`; no open PR from objectstack-ai#32115 was found.

---
_Generated by [Claude
Code](https://claude.ai/code/session_017xRBcSZ51q2s3nMfakhdJ3)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
… Add User and Import Users through the pending-person doors (objectstack-ai#33755)

<!-- claude-projects-attribution: {"github_login":"os-project-manager"}
-->
_Requested by **Leehom** · [project
thread](https://claude.ai/code/project/chan_01TenzsRopZj4jMbvjX8uz1X?thread=cmsg_01TenzsRopZj4jMbvjX8uz1XKSWb4HPT3fyiV3DGoyqSS4)_

domain:ui#1 · os-project-manager · session_01FEkQ5o1t4Dbyp8n9chrc65

Fixes objectstack-ai#33186

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

## 维护者速读

- 改了什么:托管环境(`OS_CLOUD_MANAGED=1`)的「设置 →
用户」重新出现两个按钮:「添加用户」(邮箱、姓名,可选岗位、权限集、上级邮箱)和「导入用户」(粘贴 CSV)。两者都走 objectstack-ai#33227
新加的待激活用户接口,添加的人没有密码,首次通过组织的身份提供方登录。只有平台管理员看得到。
- 为什么改:objectstack-ai#25309 为了「托管只走云端邀请」把加人的按钮全藏了;按 cloud#4465 的裁决,人员改为在环境里添加,objectstack-ai#33227
已经提供了接口,但界面上还没有入口。
- 风险与回滚:只新增两个 `sys_user`
动作和它们的多语言文案;原来的「创建用户」「设置密码」和四个「邀请用户」在托管环境仍然隐藏,非托管环境什么都没变。回滚即 revert 本
PR。
- 先看:`packages/platform-objects/src/identity/sys-user.object.ts` 的
`MANAGED_ADD_PERSON_VISIBLE` 与 `add_sso_user` / `import_sso_users`
两段;`packages/platform-objects/src/feature-gate-guard.test.ts` 新增的
`SHOWN_WHEN_ON`(为什么不改 spec 见 Acceptance notes)。
- 两分钟验证:`pnpm --filter @objectstack/platform-objects exec vitest run
src/identity/cloud-managed-visibility.test.ts`,预期全绿:托管时平台管理员只看到两个新按钮,非托管时只看到原来的六个。
- 需要你做的:无,席位落地。

## What changes

On a cloud-managed environment the password and invitation actions are
hidden (`features.cloudManaged`, objectstack-ai#25309), and since objectstack-ai#33227 the
environment has its own add-person doors, `POST
/api/v1/auth/admin/add-sso-user` and `POST
/api/v1/auth/admin/import-sso-users`. Nothing in Setup reached them.
This PR adds their two first-party actions on `sys_user`:

- **`add_sso_user`** ("Add User", list toolbar, `type: 'api'`, target
`admin/add-sso-user`). Params: `email` and `name` (field-backed),
`positions` (`widget: 'position-ref'`), `permissionSets` (`widget:
'permission-ref'`), `manager` (`type: 'email'`). Each picker submits one
name; the door reads a string as a list of one. The result dialog shows
the address, and only when present on the answer: `notApplied` (a re-add
of a person still pending), `managerError` and `host.reason` (the
hosting organisation was not told).
- **`import_sso_users`** ("Import Users", list toolbar, target
`admin/import-sso-users`). One `csv` param (`textarea`); the result
dialog shows `summary.added` / `alreadyPending` / `failed` and the
per-row answer as JSON. The row-by-row UI is objectstack-ai#33187's.

Both are offered by `current_user.isPlatformAdmin == true &&
has(features.cloudManaged) && features.cloudManaged == true`:

- The standing is the door's own gate (`gateAdmin` →
`judgePlatformAdmin`, ADR-0068 D4), and both declare
`requiredPermissions: [...PLATFORM_ADMIN_USERS_GATE]` like every other
door in that family. No `requiresFeature: 'admin'`: the doors mount
without the better-auth admin plugin, which Free and Team kernels do not
carry.
- `features.cloudManaged == true` is where the door answers; off it the
door answers `409 RESOURCE_CONFLICT`.
- `has()` keeps both hidden while the console holds no served flag: an
action `visible` that faults SHOWS the action (`RequiresFeatureSlot`
docs in `public-auth-features.ts`), the trap `create_user`'s second
email param already guards against.

No existing predicate is edited. `create_user`, `set_user_password`, the
four `invite_user` mirrors and `copy_invitation_link` stay hidden on a
managed environment.

**Measured first** (tree `a199be81` = `origin/main` `ee627c67` plus the
two actions; the measuring script evaluates every identity action whose
target is a person-adding, invitation or password door through
`@objectstack/formula`'s `celEngine`, as a platform admin who also holds
`org_owner`):

| action | target | managed | unmanaged | adds a person | sets or resets
a local credential |
|:--|:--|:--|:--|:--|:--|
| `sys_user.invite_user` | `organization/invite-member` | hidden |
offered | yes, by invitation | the invitee sets a password at accept |
| `sys_member.invite_user` | `organization/invite-member` | hidden |
offered | yes, by invitation | same |
| `sys_invitation.invite_user` | `organization/invite-member` | hidden |
offered | yes, by invitation | same |
| `sys_organization.invite_user` | `organization/invite-member` | hidden
| offered | yes, by invitation | same |
| `sys_user.create_user` | `admin/create-user` | hidden | offered | yes
| yes (password) |
| `sys_user.set_user_password` | `admin/set-user-password` | hidden |
offered | no | yes |
| `sys_invitation.copy_invitation_link` | script | hidden | offered |
hands out the accept link | no |
| `sys_invitation.resend_invitation` | `organization/invite-member` |
**offered** | offered | re-sends an invitation | no |
| `sys_member.add_member` | `organization/add-member` | offered |
offered | no (an existing user joins an organization) | no |
| **`sys_user.add_sso_user`** (new) | `admin/add-sso-user` | **offered**
| hidden | yes, pending | no |
| **`sys_user.import_sso_users`** (new) | `admin/import-sso-users` |
**offered** | hidden | yes, pending | no |

The six doors of objectstack-ai#25309 are the first six rows. The doors answer as the
card says: `admin/add-sso-user` and `admin/import-sso-users` add a
person on a managed boot and answer `409 RESOURCE_CONFLICT` off it (the
live pins below drive both legs). `resend_invitation` is offered on a
managed environment although its door refuses there; see Acceptance
notes.

## Tests

-
`packages/platform-objects/src/identity/cloud-managed-visibility.test.ts`,
a new top-level `describe` beside the six-door one. The real served
predicates through `celEngine`, bound as the console binds them:
  - each new action targets its door and declares no `requiresFeature`;
- offered to the platform admin when managed; hidden when the flag is
off; hidden (`false`, not a fault) when no flag is served; hidden from
an organization owner below the rung, even when managed;
- on a managed environment the admin is offered exactly the two new
actions and none of the six; off it, exactly the six and neither new
one.
- `packages/plugins/plugin-auth/src/pending-sso-users.test.ts`, a new
top-level `describe` in the existing harness (a real `AuthManager`
behind `AuthPlugin.registerAuthRoutes` on a real Hono app). Each leg
reads the DECLARED action from `@objectstack/platform-objects/identity`,
posts its dialog's body to its `target`:
- `add_sso_user` on a managed boot answers `201`; the row reads `source
= idp_pending`, no `sys_account`, the picked position and permission
set, and the manager linked;
- `import_sso_users` on a managed boot: a two-row CSV answers `200`,
summary `{ total: 2, added: 2, alreadyPending: 0, failed: 0 }`, both
rows `idp_pending`;
- CONTROL: an unmanaged boot answers both targets `409
RESOURCE_CONFLICT` and adds no one.
- `platform-admin-affordance-standing.test.ts` now evaluates both
managed modes: a member counts as offered to the platform admin when one
mode offers it, and no refused principal may be offered a member in
either mode. The two new actions join its family floor.
- `platform-objects.test.ts`: the byte rows for the two served
predicates.
- `feature-gate-guard.test.ts`: the reverse walk (every `features.*`
reference is booked) reads a new test-local `SHOWN_WHEN_ON` list for the
two actions, and a new `describe` holds each to the inverse conjuncts
`has(features.cloudManaged)` and `features.cloudManaged == true`, on a
flag whose semantics are `hide-when-on`, and not booked the other way.

Runs at head `e6eb15eb`: `@objectstack/platform-objects` full suite 122
files, 1992 tests passed; `pending-sso-users.test.ts` 48 passed (3 new),
run at `a199be81`; neither it nor `sys-user.object.ts` changed after,
and the three new legs passed again on the restored tree after A5.

Ablations at head `71185c1d`, each through
`scripts/ablation-replace.mjs`, each restored to the HEAD blob with `git
diff HEAD` empty:

<details><summary>A1 drop the managed half of the predicate → 7
red</summary>

```text
anchor "  'current_user.isPlatformAdmin == true && has(features.cloudManaged) && features.cloudManaged == true';"
     → "  'current_user.isPlatformAdmin == true';"
ablation-replace: ok mutation landed: anchor 1 -> 0, blob cde955f -> e8790049342b
× sys_user.add_sso_user is hidden when the flag is off: its door answers 409 there
× sys_user.import_sso_users is hidden when the flag is off: its door answers 409 there
× sys_user.add_sso_user is hidden, not faulted, while no flag is served
× sys_user.import_sso_users is hidden, not faulted, while no flag is served
× off a managed environment the platform admin is offered the six as before and neither pending-person door
× (platform-objects.test.ts) the two byte rows
Tests  7 failed | 187 passed (194)
ablation-replace: ok restored: blob == HEAD (cde955f) and `git diff HEAD` is empty
```

</details>

<details><summary>A2 drop the platform-admin standing → 6 red</summary>

```text
     → "  'has(features.cloudManaged) && features.cloudManaged == true';"
× sys_user.add_sso_user is hidden from an organization owner below the platform-admin rung, even when managed
× sys_user.import_sso_users is hidden from an organization owner below the platform-admin rung, even when managed
× each member serves a visible that carries the standing term
× no principal the gate refuses is offered a member, on any row
× (platform-objects.test.ts) the two byte rows
Tests  6 failed | 188 passed (194)
ablation-replace: ok restored: blob == HEAD (cde955f) and `git diff HEAD` is empty
```

</details>

<details><summary>A3 drop the has() guard → 4 red</summary>

```text
     → "  'current_user.isPlatformAdmin == true && features.cloudManaged == true';"
× sys_user.add_sso_user is hidden, not faulted, while no flag is served
× sys_user.import_sso_users is hidden, not faulted, while no flag is served
× (platform-objects.test.ts) the two byte rows
Tests  4 failed | 190 passed (194)
ablation-replace: ok restored: blob == HEAD (cde955f) and `git diff HEAD` is empty
```

</details>

<details><summary>A4 / A5 point each action at the password door → its
live pin red; dist rebuilt both legs</summary>

plugin-auth reads `@objectstack/platform-objects` from `dist/`, so each
leg rebuilt it and proved the marker with
`scripts/ablation-dist-preflight.mjs`.

```text
A4 "target: '/api/v1/auth/admin/add-sso-user'," → "target: '/api/v1/auth/admin/create-user?abl=A4',"
ablation-replace: ok mutation landed: anchor 1 -> 0, blob cde955f -> 06a9f37a88b5
✓ dist/: marker present in 6 built files
× add_sso_user on a managed boot: the dialog adds a pending person with the picked grants and manager
× CONTROL: off a managed environment the same targets answer 409 and add no one
Tests  2 failed | 1 passed | 45 skipped (48)
ablation-replace: ok restored: blob == HEAD (cde955f) and `git diff HEAD` is empty
✓ dist/: marker absent from all 66 built files  ✓ tree: working tree clean against HEAD

A5 "target: '/api/v1/auth/admin/import-sso-users'," → "target: '/api/v1/auth/admin/import-users?abl=A5',"
ablation-replace: ok mutation landed: anchor 1 -> 0, blob cde955f -> c330612f4396
✓ dist/: marker present in 6 built files
× import_sso_users on a managed boot: the dialog's CSV adds each row as a pending person
× CONTROL: off a managed environment the same targets answer 409 and add no one
Tests  2 failed | 1 passed | 45 skipped (48)
ablation-replace: ok restored ...  ✓ dist/: marker absent ...  ✓ tree clean

restored tree: Tests  3 passed | 45 skipped (48)
```

</details>

## Acceptance notes

- **No spec change, so the feature-gate registry does not book the two
actions.** `PUBLIC_AUTH_FEATURES.cloudManaged`
(`packages/spec/src/kernel/public-auth-features.ts`) books inputs under
one predicate, `features.cloudManaged != true`, and
`feature-gate-guard.test.ts` holds every booked input to it, so an input
the flag SHOWS cannot be booked there without a new registry member. The
order rules out a spec change, and the registry has no runtime reader
(only this guard), so the two inputs are listed in a test-local
`SHOWN_WHEN_ON` beside the reverse walk, and pinned. The question
whether the registry should model that polarity is in the report.
- **`sys_invitation.resend_invitation` is offered on a managed
environment, and its door refuses there.** Measured in the table: its
predicate has no `cloudManaged` term, and `organization/invite-member`
answers `409` on a managed environment, resends included
(`auth-manager-before-hook.ts`). It is not an add-person action and this
PR leaves its predicate as it is; reported for the seat.
- **`ban_user` / `unban_user` keep `requiresFeature: 'admin'`.** objectstack-ai#33227
made both doors work without the admin plugin, and its hand-over names
this card for dropping that gate. The order scopes this card to adding
people and does not name it, so it is left alone and raised in the
report.
- **Neither new action is exposed to AI agents**: no `ai` block.
ADR-0011's identity-actions note lists the actions assessed so far;
these two postdate it and are human-only until assessed, as
`list_platform_admins` is.
- The resultDialog of `import_sso_users` shows the per-row answer as
JSON. The row-by-row UI, re-send and the status display are objectstack-ai#33187.
- Clause-② widening, what it widens: two new published `sys_user`
actions and their `en` plus ten translated locale keys
(`add_sso_user.*`, `import_sso_users.*`). Nothing previously offered is
hidden.

## Verification

Gates derived by `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on the final head, each run with its exit
code captured before any pipe, reconciled with `--ran`: 68 derived
families on `e6eb15eb`: 67 exit 0, 1 NOT MEASURED (`pnpm
check:dual-build-cjs-loads` exit 3, PREREQUISITE NOT MET: it needs every
package's `dist/`; CI runs it). `--ran`: "68 derived famil(ies)
accounted for — 67 run, 1 NOT-MEASURED". Plus `pnpm --filter
@objectstack/platform-objects typecheck` exit 0 and `pnpm --filter
@objectstack/plugin-auth typecheck` exit 0 (lock VERDICT command-exit 0
each), `pnpm --filter @objectstack/platform-objects test` 122 files /
1992 tests passed, `pending-sso-users.test.ts` 48 passed (see Tests).
`test:repo` and `pnpm lint` are CI's. Full dogfood not run: no `!` in
the title and no `(narrowing)` arm.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01FEkQ5o1t4Dbyp8n9chrc65)_

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…n plugin (objectstack-ai#33989)

<!-- claude-projects-attribution: {"github_login":"os-steve"} -->
_Requested by **Steve** · [project
thread](https://claude.ai/code/project/chan_01FdL1XeUyvVNxLreh3F4Qi9?thread=cmsg_01FdL1XeUyvVNxLreh3F4Qi95zbTp65UwtoUVvRXG2cC9v)_

Fixes objectstack-ai#33759

Clause-②: no — offering an existing action in more kernels widens no
accepted input set or public export; the dev measures the gaining
kernels and the seat amends if the diff reads otherwise
Metadata-protocol: none

## 维护者速读

- 改了什么:Setup → 用户里的「封禁 / 解封」(`ban_user` / `unban_user`)去掉了
`requiresFeature: 'admin'`,没开 better-auth admin 插件的环境(自托管默认、托管的
Free/Team 环境)现在也会显示这两个按钮;规格里 admin 特性的门禁登记表同步去掉这两项。
- 为什么改:objectstack-ai#33227 之后这两个接口不依赖 admin 插件也能用(封禁后会话被 `403 BANNED_USER` 拒绝),但按钮仍要求
admin 插件才显示,管理员在这些环境里看不到停用入口。
- 风险与回滚:只改显示条件,接口、权限(`requiredPermissions`)和按行状态切换的判断都不变;其他 admin
插件专属动作(解锁、建用户、设密码、模拟登录)保持隐藏。回滚即还原这一个 PR。
-
先看:`packages/platform-objects/src/identity/sys-user.object.ts`(两处删除与块头注释)、`packages/spec/src/kernel/public-auth-features.ts`(登记表去掉两项)、`packages/plugins/plugin-auth/src/pending-sso-users.test.ts`(新的实跑钉子)。
- 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/pending-sso-users.test.ts -t 33759`,预期 3
个用例全绿(未托管、托管两种内核各一次封禁/解封实跑,加一个对照)。
- 需要你做的:无,席位落地。

## What changes

- `sys_user.ban_user` and `sys_user.unban_user` drop `requiresFeature:
'admin'`. Their `visible` predicates (the platform-admin standing, then
the row's `banned` state) and `requiredPermissions` are unchanged. The
admin block header in `sys-user.object.ts` now says which actions keep
the admin-plugin gate and why these two do not.
- `PUBLIC_AUTH_FEATURES.admin.gatedInputs`
(`packages/spec/src/kernel/public-auth-features.ts`) no longer books the
two actions. This is forced, not chosen: `feature-gate-guard.test.ts`
holds the registry and the lowered predicates in lockstep in both
directions, so a booked input without the gate reds its forward walk.
- Root changeset: `@objectstack/platform-objects` patch and
`@objectstack/spec` patch (the registry edit ships in spec).

## Why

Since objectstack-ai#33227 (`cbb876c1`) `POST /api/v1/auth/admin/ban-user` and
`unban-user` work on a kernel without the better-auth admin plugin: the
ban is written through the data engine and the banned row is refused a
session with `403 BANNED_USER`. The two actions were still hidden
wherever `features.admin` is off, so a platform admin there had no
Deactivate / Reactivate in the console.

### Clause-② reading (measured)

- **Which kernels gain the two actions.** `features.admin` is served as
`pluginConfig.admin ?? resolveScimEnabled(pluginConfig)`
(`plugin-auth/src/auth-manager.ts`, the `admin:` row of the public
features). So every kernel where the admin plugin is not configured on
and SCIM is not effective gains them: self-hosted kernels on the default
config, and cloud-managed Free / Team environments, where the plugin
mounts only with SCIM. Measured in the live pin below: the harness
kernel with `plugins.admin: false` serves `features.admin === false`
both with `OS_CLOUD_MANAGED` unset and set, and the declared actions are
offered on both; with `plugins.admin: true` it serves `true`. Kernels
with the plugin (or SCIM) on already offered both and see no change.
- **No door or accepted input moves.** The doors were already mounted
unconditionally (`auth-plugin.ts`, the `admin/ban-user` /
`admin/unban-user` mounts). Nothing server-side reads `visible`:
`packages/runtime/src/action-dispatch.ts` and
`packages/runtime/src/domains/mcp.ts` carry zero `visible` / `features`
reads (tree a1fd372), so the AI / MCP exposure of the two `ai.exposed`
actions is the same as before. Only the console's offer changes.
- **The spec export.** `PUBLIC_AUTH_FEATURES` keeps its name and
declared entry shape; its `admin.gatedInputs` value loses two strings,
and since the object is `as const`, its literal tuple type loses two
members. Readers of `gatedInputs` in this repository (packages, ui,
scripts, apps; tree a1fd372):
`spec/src/kernel/public-auth-features.test.ts` and
`platform-objects/src/feature-gate-guard.test.ts` only, plus a comment
in `sys-user-set-manager-action.test.ts`. `check:api-surface` and
`check:generated` are green. Read as not a narrowing of a public export;
the seat amends the line if it reads otherwise.

## Tests

- `identity/action-state-visibility.test.ts`, new describe `sys_user Ban
/ Unban are offered without the admin plugin`: evaluated through
`@objectstack/formula`'s `celEngine` on the parsed object, with
`features.admin` off on an unmanaged and a managed feature set: Ban is
offered on a not-banned row and Unban on a banned one; the standing leg
still hides both from a non-admin; CONTROL, exactly `unlock_user`,
`create_user`, `set_user_password`, `impersonate_user` still read
`features.admin`, and each stays hidden with it off and is offered with
it on.
- `plugin-auth/src/pending-sso-users.test.ts`, new top-level describe
`[objectstack-ai#33759] Ban / Unban are offered and work without the admin plugin` in
the existing shared harness (a real `AuthManager` behind
`AuthPlugin.registerAuthRoutes` on a Hono app, `plugins.admin: false`):
for an unmanaged and a managed kernel, the DECLARED `ban_user` is
offered under the features this kernel serves
(`getPublicConfig().features`), its `target` with its `recordIdParam`
and `banReason` answers 200, the banned row's next sign-in is `403` with
code `BANNED_USER` and no session row, then `unban_user` is offered,
answers 200, and sign-in is 200 again. CONTROL: `impersonate_user` is
hidden on that kernel and offered on one with the plugin on.
- Forced test edits: `platform-objects/src/platform-objects.test.ts`
(the `feature-gate lowering matrix (objectstack-ai#2874)` rows for `ban_user` /
`unban_user` now pin the bare predicate, since nothing is lowered onto
it). `feature-gate-guard.test.ts` needed no edit; its forward rows are
derived from the registry.

## Acceptance notes

- First ablation attempt was a no-op and is declared: the anchor (the
ban `visible` line) was contained in its own replacement, so
`ablation-replace.mjs` refused it (anchor 1 to 1) and restored the file;
no run was read from it. The legs below re-anchor on the `visible` /
`recordIdParam` pair.
- Not changed, by the card's scope: `unlock_user` keeps
`requiresFeature: 'admin'`, though the `set_user_manager` comment calls
`admin/unlock-user` a mount registered unconditionally. Whether that
door works without the plugin was not measured here.

## Verification

Code and tests are final at a1fd372; 8631da3 adds only the changeset's
`@objectstack/spec` line. Suites and ablations ran on a1fd372, the
derived gates on 8631da3.

<details><summary>Ablations (each leg rebuilt platform-objects and read
the built artifact)</summary>

- Leg ban: re-add `requiresFeature: 'admin'` to `ban_user`
(ablation-replace, anchor 1 to 0). Built `dist` read: `ban_user.visible
= (current_user.isPlatformAdmin == true && has(record.banned) &&
record.banned != true) && features.admin == true`.
`action-state-visibility.test.ts`: 2 failed (the offer case and the
CONTROL roster). `pending-sso-users.test.ts -t 33759`: 2 failed
(unmanaged and managed, `expected false to be true` at the Ban offer),
CONTROL green. Restore: blob equals HEAD, `git diff HEAD` empty,
rebuilt, `dist` read shows the bare predicate, both files green (18/18,
3 passed).
- Leg unban: same on `unban_user`. 2 failed in each file, same cases;
restored green.

</details>

<details><summary>Package suites</summary>

- `pnpm --filter @objectstack/platform-objects test`: 122 files, 1995
tests passed. Typecheck green.
- `pnpm --filter @objectstack/plugin-auth test`: 277 files, 5488 passed,
10 skipped. Typecheck green.
- `pnpm --filter @objectstack/spec test`: 842 files, 26956 passed, 1
todo. Typecheck green.
- `pnpm --filter @objectstack/spec build && pnpm --filter
@objectstack/spec check:generated`: all 14 generated artifacts up to
date.

</details>

<details><summary>Derived gates</summary>

`node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack` on 8631da3 derived 88 commands; each was
run after a full `turbo run build --filter='./packages/**'` (81/81
tasks) and all 88 exited 0. `--ran` reconciliation: `88 derived, 88 run,
0 NOT-MEASURED, 0 UNRUN` (a derived zero). Two first-round exit-3
prerequisites were cleared before that round:
`check-plugin-teardown-shape --self-test` needed its pinned fixture
commit fetched into the shallow clone, and `check:dual-build-cjs-loads`
/ `check:i18n` needed the full package build. CI-owned families (`pnpm
lint`, `test:repo`, dogfood) are read from the PR's check-runs.

</details>

## Human Minimum

- [x] 1. Schemas start as Zod; `packages/spec` holds no runtime logic.
- [x] 2. Every name I added uses the casing for its kind.
- [x] 3. No formatter ran; `pnpm lint` passes (CI-owned).
- [x] 4. One issue, one branch off an up-to-date `main`, one pull
request.
- [x] 5. A change that publishes carries a changeset, and both
declaration lines are filled in here and in the changeset.
- [x] 6. `packages/spec` touched: its generated artifacts are
regenerated and committed (none stale).
- [x] 7. No hand edits to `content/docs/references/`,
`packages/*/CHANGELOG.md` or `content/docs/releases/`.
- [x] 8. Title, body and comments are in English.
- [x] The *Before Submitting* list in CONTRIBUTING.md is done.

---
_Generated by [Claude
Code](https://claude.ai/code/session_01ADHkmRTCRCDzKb12eoW83s)_
<!-- signed: domain:ui#1 · os-steve · session_01ADHkmRTCRCDzKb12eoW83s
-->

---------

Co-authored-by: Claude <noreply@anthropic.com>
Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
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/xl tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

3 participants