Skip to content

fix(platform-objects): offer Ban / Unban without the better-auth admin plugin - #33989

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

objectstack-fleet[bot] merged 5 commits into
mainfrom
claude/project-thread-5jq3wa

Conversation

@objectstack-fleet

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

Copy link
Copy Markdown
Contributor

Requested by Steve · project thread

Fixes #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 特性的门禁登记表同步去掉这两项。
  • 为什么改:feat(auth)!: a managed environment adds pending, SSO-only people, and ban works without the admin plugin #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 #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 [#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 (#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.

Ablations (each leg rebuilt platform-objects and read the built artifact)
  • 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.
Package suites
  • 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.
Derived gates

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.

Human Minimum

  • 1. Schemas start as Zod; packages/spec holds no runtime logic.
  • 2. Every name I added uses the casing for its kind.
  • 3. No formatter ran; pnpm lint passes (CI-owned).
  • 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 (none stale).
  • 7. No hand edits to content/docs/references/, packages/*/CHANGELOG.md or content/docs/releases/.
  • 8. Title, body and comments are in English.
  • The Before Submitting list in CONTRIBUTING.md is done.

Generated by Claude Code

@github-actions github-actions Bot added size/m 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 15, 2026
@github-actions

github-actions Bot commented Nov 15, 2026 •

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

This PR changes 2 package(s): @objectstack/platform-objects, @objectstack/spec, touching 1 documentable anchor(s).

1 hand-written doc(s) NAME something this change touched and may need an implementation-accuracy re-verification:

  • content/docs/automation/approvals.mdx (via /api/v1/auth/admin/* (route, a path literal in a comment in actions))
What this run could not see

Coarse fallback — 173 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 bc6b7ffd454ba9c2c420975c84a400779cb02262 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json bc6b7ffd454ba9c2c420975c84a400779cb02262

⚠️ 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 bc6b7ffd454ba9c2c420975c84a400779cb02262 → 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:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 8631da39e567beadd0b908f03c77a6faa9197138
Local-runs: none
Scope: packages/spec/src/kernel/public-auth-features.ts + packages/platform-objects/src/identity/sys-user.object.ts

Inputs read: card #33759 with its Claim (6896010564) and os-dev-report (6896885009); this PR's body, file list and net diff against main; the check-runs on the head (58 success, 13 skipped, none failed, none pending when this record was written). The four remaining files (two test files, platform-objects.test.ts, the changeset) are the lane seat's ACCEPT at TIER_DEFAULT; they were read only to judge the two files above.

① Derived judgments

  1. sys_user.ban_user / unban_user lose the lowered && features.admin == true conjunct. Right. The parsed visible is now the authored predicate alone (standing, then the row's banned state); requiredPermissions, target, recordIdParam, params and ai are byte-identical. The offer set widens to every kernel serving features.admin false, which auth-manager.ts computes as pluginConfig.admin ?? resolveScimEnabled(pluginConfig).
  2. No accept set moves. Right. ActionSchema is untouched, requiresFeature stays authorable with the same vocabulary, and no door changes: the diff holds no server file.
  3. PUBLIC_AUTH_FEATURES.admin.gatedInputs goes from six booked paths to four. Right, and forced: feature-gate-guard.test.ts walks registry to objects (a booked path must carry the gate as a conjunct) and objects to registry, so the two edits can only land together. Export name, kind and declared entry shape (PublicAuthFeatureEntry) are unchanged; packages/spec/api-surface/kernel.json records PUBLIC_AUTH_FEATURES (const) and is not in the diff, and the Type Check lanes that carry check:api-surface and check:generated are green on the head.
  4. Server-side exposure is unchanged. Right. packages/runtime/src/action-dispatch.ts and packages/runtime/src/domains/mcp.ts hold no features read at the head; the action door and MCP list_actions judge requiredPermissions (platform-admin-action-gate.ts), which this diff leaves alone. Only the console's offer changes.
  5. The four remaining admin actions keep the gate. Right. unlock_user, create_user, set_user_password, impersonate_user still carry requiresFeature: 'admin', and the new CONTROL roster pins that exact list.

② Semver level

Clause-②: no — upheld; see ③ for the open question on the spec half.

The changeset names @objectstack/platform-objects and @objectstack/spec, both patch, with Metadata-protocol: none. That matches what the diff publishes: a behaviour fix in one package and a registry value in the other, no key an author can write added, removed or re-meant, so none and therefore patch on each moved package. Check Changeset is green. The spec line is owed, not optional: the registry constant ships in @objectstack/spec/kernel.

③ Boundary flags

  • open_question (Clause-② for the spec half, literal tuple type loses two members): answer A, keep Clause-②: no. Reasons, each read in the tree:
    • The contract an entry declares is PublicAuthFeatureEntry, where gatedInputs is readonly string[], optional; as const satisfies holds every entry to it. Membership of that array is the registry's data, not its surface: the file's own header calls it a classification registry held in lockstep by CI guards, and it changes whenever an input gains or loses a gate.
    • The repository's instrument for the public surface, api-surface/kernel.json, snapshots name and kind, and it does not move.
    • The readers at the head are the two lockstep guards (spec/src/kernel/public-auth-features.test.ts, platform-objects/src/feature-gate-guard.test.ts); the second already reads the field through a readonly string[] cast. Type Check UI, which compiles the Console against this PR's spec, is green, so nothing under ui/ depended on the two literals.
    • Read against the narrowing face's own question (does it take a declared capability away at the consumer, or make the spec's refusal real?): neither. The removal records that two inputs are offered in MORE places.
    • Residual, stated so it is not lost: a consumer outside this repository that typed against the two literal members (an index past 3, or the literal passed to includes on the uncast tuple) would stop compiling. No such reader exists here, and the dev's measurement and mine agree; this is not enough to make the PR a breaking narrowing.
  • Deviation, file surface widened by two forced edits (public-auth-features.ts, platform-objects.test.ts): accepted. Both are forced by the lockstep in ① 3 and are named in the PR body; the spec edit is what brings this PR to the contract tier, correctly.
  • Deviation, suites and ablations on a1fd372, head 8631da3 adds only the changeset's spec line: accepted. The net diff confirms the changeset is the only file that could differ, and the head's own check-runs are green.
  • Deviation, first ablation was a refused no-op: accepted as declared; no reading was taken from it.
  • Deviation, PR-body slip ("Root changeset: @objectstack/platform-objects patch" while the changeset also carries @objectstack/spec): confirmed, see N4.
  • out_of_scope_finding (unlock_user keeps the gate while its door looks unconditional): confirmed as a real open measurement, not a defect of this PR. auth-plugin.ts mounts admin/unlock-user with no plugin condition, and sys-user-set-manager-action.test.ts says so in prose. The card's ask is explicit that every other admin action stays as it is, so leaving it is right. It needs its own card: measure whether unlock-user works with the plugin off, then keep or drop the gate. See N1 for the sentence in this diff that touches it.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/kernel/public-auth-features.ts (hits). Holds against the card and against its first consumer. The inline comment's two claims were read in the cited code: the doors are ObjectStack mounts (auth-plugin.ts, the admin/ban-user and admin/unban-user routes sit in an unconditional block beside admin/create-user), and they work without the vendor plugin (getBanWriter returns the data-engine writer when isAdminPluginMounted() is false; user-session-admission.ts refuses a banned row 403 BANNED_USER when the plugin is not mounted and lifts an expired ban as the vendor does). The gatedInputs XOR exempt rule still holds for admin (four paths remain), and the path grammar test is unaffected.

packages/platform-objects/src/identity/sys-user.object.ts (implementing). Agrees with the contract, sentence by sentence, for the two actions. Attempts to break it:

  • The row predicate on a plugin-off kernel. banned, ban_reason and ban_expires are declared on sys_user unconditionally (banned with defaultValue: false, and in the default list columns), so has(record.banned) does not silently hide both buttons where the vendor plugin never added its columns.
  • The flag and the mount can disagree. plugins.admin: false with SCIM on serves features.admin false while the vendor plugin is mounted. The door picks its writer from the built instance, not from the flag, so the action works on either side of that disagreement.
  • A member, or an org admin, on a plugin-off kernel. The standing leg is untouched and the door runs gateAdmin first; the new tests pin the standing leg with the plugin off.
  • A managed environment. The host seam may refuse a deactivation (an organization owner or admin 409, a host fault 503); the button is offered and the door answers the host's refusal. That is the behaviour feat(auth)!: a managed environment adds pending, SSO-only people, and ban works without the admin plugin #33227 shipped and the card names managed environments as in scope.
  • AI exposure. ① 4.

The live pin is the right shape for the claim: it reads the DECLARED action's visible, target, recordIdParam and params, evaluates the offer under the features that kernel actually serves, and drives the real door through to a refused sign-in and back. The CONTROL is not vacuous: it derives the gated roster from the parsed object and expects exactly the four names.

Nits (no effect on correctness or the contract):

  • N1 (nit) — the rewritten block header in sys-user.object.ts keeps the rationale "the UI hides them instead of rendering buttons that 404" and now attaches it by name to unlock_user and create_user. For unlock_user the tree does not support it (unconditional mount, above). The gate itself is out of this card's scope; the sentence would be truer as "gated on the admin plugin" without the 404 claim for unlock_user. Leave as an accepted deviation and carry it into the unlock_user card.
  • N2 (nit) — the same header still says banned "stays true past ban_expires until better-auth clears it at the user's next sign-in". On the kernels this PR newly reaches, user-session-admission.ts clears it, not better-auth. Display reasoning is unchanged. The header rewording also orphans a verbatim quote in sys-user-set-manager-action.test.ts ("only wired when auth.plugins.admin is enabled"), which no longer appears in the header.
  • N3 (nit, follow-up card, outside the diff) — two published texts still teach that ban-user needs the admin plugin, and this PR makes the first-party action contradict both: content/docs/protocol/objectui/actions.mdx uses ban_user with requiresFeature: admin as the worked example of the sugar ("Hidden entirely when the admin plugin is off (instead of a button that 404s)"), and AuthFamiliesSchema.admin in packages/spec/src/api/discovery.zod.ts lists ban-user in the family whose routes "answer a plain 404" when the flag is false. The second has been untrue since feat(auth)!: a managed environment adds pending, SSO-only people, and ban works without the admin plugin #33227. The Docs Drift Check on this PR listed approvals.mdx and missed the first. Neither is in the diff; the doc example wants another action (impersonate_user fits), and the describe() wants ban-user taken out of its list (a check:docs regeneration).
  • N4 (nit, prose faces) — the PR body's "Root changeset" bullet omits @objectstack/spec; and the Clause-②: line, in the body and in the changeset, still ends with the dispatch-time clause "the dev measures the gaining kernels and the seat amends if the diff reads otherwise", which will ship in two CHANGELOG.md files. The measurement is done and the answer is no; the body can be fixed without moving the head, the changeset copy is an accepted deviation unless the seat chooses to move the head for it.

Implemented-by: claude/project-thread-5jq3wa
Reviewed-by: session_01ADHkmT2NE3iyG1o6TDg3sf

VERDICT: PASS

Reviewed 2026-11-15T16:01Z.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

席位核对

Verdict: ACCEPT · head 8631da39 · 2026-11-15T16:04Z

  1. Shape. Draft → main, Fixes #33759. 6 files on the claimed surface (claim 6896010564): sys-user.object.ts drops requiresFeature: 'admin' from ban_user / unban_user only (predicates, requiredPermissions, targets unchanged); PUBLIC_AUTH_FEATURES.admin.gatedInputs unbooks the two (forced lockstep with feature-gate-guard.test.ts); lowering-matrix rows in platform-objects.test.ts; offer pins + CONTROL roster in action-state-visibility.test.ts; live ban → 403 BANNED_USER → unban through the declared targets in plugin-auth's pending-sso-users.test.ts (managed and unmanaged); one changeset (@objectstack/platform-objects + @objectstack/spec patch).
  2. Premise. Held on 895783a1; gaining kernels measured by the dev: features.admin false (plugins.admin ?? SCIM) = self-hosted default and managed Free/Team.
  3. Contract record. CONTRACT_REVIEW_TIER PASS 6897296837 on this head: no must-fix, no should-fix; four nits. The dev's open question is answered there: Clause-②: no kept (registry membership is data; api-surface/kernel.json does not move). N1 (unlock_user rationale) and the dev's out-of-scope note → Setup: Unlock User may be hidden without the admin plugin although its door is mounted unconditionally — measure, then drop the gate if so #34010; N3 (docs + AuthFamiliesSchema.admin describe still say ban needs the plugin) → Docs and spec still say ban-user / unban-user need the admin plugin (true before #33227): actions.mdx worked example and AuthFamiliesSchema.admin describe #34008; N2 rides with Setup: Unlock User may be hidden without the admin plugin although its door is mounted unconditionally — measure, then drop the gate if so #34010; N4: the PR-body changeset bullet was fixed by the dev (no head move), the dispatch-time tail on the Clause-②: line is an accepted deviation.
  4. Gates on 8631da39. 71 check runs: 58 success, 13 skipped, none failed. Locally 88/88 derived gates exit 0; ban / unban ablations each red, restored green.
  5. K. 26 first-parent commits on main since the merge base (≥ 15): a merge-only sync of origin/main is owed before the queue, and the contract record is carried onto the synced head (merge-only carry) before landing.
  6. Governed. check-governed-merges --pr 33989: NOT governed; 208 changed lines.
  7. Serial. PR fix(platform-objects): hide Resend Invitation on a cloud-managed environment #33956 (Setup: Resend Invitation is offered on a cloud-managed environment, where its door refuses with 409 #33758) edits the cloudManaged block of the same registry file and other rows of platform-objects.test.ts; whichever lands second merges main. Setup → Users on a managed environment: add-person and CSV-import UI with per-row invitation status (reverses objectui#13330 for adding) #33187 (parked on needs-user-decision) merges main after this lands.
  8. Landing. Held: this seat's --land is refused by the session's auto-mode classifier until the maintainer approves landing in the seat thread (same hold as PR fix(plugin-list): on a phone the list toolbar keeps the view name readable #33957, 6896702944).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 9d6dba495fe8727febe113a7252bac82e99ed10f
Local-runs: none
Scope: packages/spec/src/kernel/public-auth-features.ts + packages/platform-objects/src/identity/sys-user.object.ts

Inputs read: card #33759 with its Claim (6896010564) and os-dev-report (6896885009); this PR's body, file list, comments and net diff against main at this head; the check-runs on this head. This head is a merge of main (bc6b7ffd) into 8631da39; the earlier record 6897296837 on 8631da39 was read as an input and every judgment below was re-made on this head's tree. The net diff against main is the same six files with the same hunks as on 8631da39. The four files outside Scope (two test files, platform-objects.test.ts, the changeset) are the lane seat's ACCEPT at TIER_DEFAULT; they were read only to judge the two files in Scope.

Check-runs on this head when this record was written: 67 runs, all concluded: 56 success, 11 skipped, none failed, none pending. Among the successes: Check Changeset, the four Type Check lanes and Type Check UI, Build Core, the Lint lanes, Test Core 1/8 to 8/8 (the shards that carry the lockstep guard, the lowering matrix and the two new pins), Test UI 1/16 to 16/16, Live E2E UI, Spec property liveness and Dogfood Regression Gate. The skipped runs are opt-in or path-filtered lanes (Build Docs, Lint UI, Dogfood Verify CLI, UI Published Artifacts, Temporal Conformance, the 18.x upgrade harness, the packed-tarball smoke, the queue-verdict and schedule lanes).

① Derived judgments

  1. sys_user.ban_user and unban_user lose the lowered features.admin == true conjunct. Right. Each action's parsed visible is now its authored predicate alone (the platform-admin standing, then the row's banned state). target, requiredPermissions, recordIdParam, params and ai are untouched by the diff. The offer widens to every kernel that serves features.admin false, which auth-manager.ts computes as pluginConfig.admin ?? resolveScimEnabled(pluginConfig): a self-hosted kernel on the default config and a managed Free or Team environment.
  2. No accept set moves. Right. ActionSchema is not in the diff, requiresFeature stays authorable with the same flag vocabulary, and the diff holds no server file, so no door accepts or refuses anything new.
  3. PUBLIC_AUTH_FEATURES.admin.gatedInputs goes from six booked paths to four. Right, and forced. feature-gate-guard.test.ts walks registry to objects (a booked path must carry the gate as a top-level conjunct) and objects to registry, so the registry edit and the two requiresFeature removals can only land together. The export keeps its name, its kind and its entry type PublicAuthFeatureEntry; packages/spec/api-surface/kernel.json lists PUBLIC_AUTH_FEATURES (const) and is not in the diff.
  4. The four other admin actions keep the gate. Right. unlock_user, create_user, set_user_password and impersonate_user still carry requiresFeature: 'admin' at this head, and stay booked.
  5. Nothing server-side reads the offer. Right. The two doors run gateAdmin first whatever visible says; the block header's own sentence, "no door reads visible", holds for both mounts in auth-plugin.ts.

② Semver level

Clause-②: no — upheld. Offering two existing actions on more kernels widens no accepted input and removes no declared capability; the spec half is answered under ③.

The changeset names @objectstack/platform-objects and @objectstack/spec, both patch, with Metadata-protocol: none. That matches what the diff publishes: a console-offer fix in one package and a registry value in the other, with no authorable key added, removed or re-meant. The spec line is owed, because the registry constant ships in @objectstack/spec/kernel.

③ Boundary flags

  • open_question (spec half: the as const tuple type of admin.gatedInputs loses two literal members): answer A, keep Clause-②: no. The declared contract of an entry is PublicAuthFeatureEntry, where gatedInputs is an optional readonly string[]; the registry is held to it by satisfies. Which paths the array holds is the registry's data, and the file's header describes it as a classification registry kept in lockstep by CI guards. Readers of gatedInputs at this head are spec/src/kernel/public-auth-features.test.ts and platform-objects/src/feature-gate-guard.test.ts, plus a comment in sys-user-set-manager-action.test.ts and two test-typecheck-debt.json ledgers; no runtime or ui/ reader. Residual, stated so it is not lost: a consumer outside this repository that typed against the two removed literals would stop compiling. That does not make the change a narrowing of a declared capability.
  • Deviation, file surface widened by two forced edits (public-auth-features.ts, platform-objects.test.ts): accepted. Both follow from ① 3 and both are named in the PR body. The spec edit is what puts this PR on the schema face.
  • Deviation, suites and ablations ran on a1fd3723, derived gates on 8631da39: accepted for those heads. Neither is this head; this head's evidence is its own check-runs, reported above.
  • Deviation, first ablation was a refused no-op: accepted as declared; no reading was taken from it.
  • Deviation, PR-body slip on the changeset bullet: closed on the prose face. The body now reads "@objectstack/platform-objects patch and @objectstack/spec patch".
  • out_of_scope_finding (unlock_user keeps the gate while its door is mounted unconditionally): confirmed as an open measurement and not a defect of this PR. auth-plugin.ts mounts admin/unlock-user with no plugin condition, and the card asks that every other admin action stay as it is. The seat's comment 6897338167 carries it to Setup: Unlock User may be hidden without the admin plugin although its door is mounted unconditionally — measure, then drop the gate if so #34010.

④ Design judgment

No must-fix, no should-fix.

packages/spec/src/kernel/public-auth-features.ts (hits). The change holds against the card and against its first consumer, the lockstep guard. The new comment makes two claims, both read in the cited code at this head:

  • "their doors are ObjectStack mounts": auth-plugin.ts registers admin/ban-user and admin/unban-user in a bare block beside admin/create-user, under no plugin condition.
  • "that work without the admin plugin": getBanWriter returns the data-engine writer when isAdminPluginMounted() is false, and isAdminPluginMounted() asks the built instance for its banUser endpoint. refuseInactiveUserSession in user-session-admission.ts then refuses a banned row with FORBIDDEN and code BANNED_USER, only when the plugin is not mounted (enforceBan in auth-manager-database-hooks.ts).

The rule "gatedInputs or exempt, never both and never neither" still holds for admin: four paths remain. The cloudManaged entry books neither action, so a managed kernel hides neither through that flag.

packages/platform-objects/src/identity/sys-user.object.ts (implementing). The code agrees with the contract for the two actions. Attempts to break it:

  • The row predicate on a kernel whose better-auth user model has no ban fields. banned, ban_reason and ban_expires are fields of sys_user itself, declared unconditionally, banned with defaultValue: false. The existing truth table in action-state-visibility.test.ts covers a null banned as not banned, so Ban is offered on a row the vendor never wrote the column for.
  • The flag and the mount disagreeing. plugins.admin: false with SCIM effective is refused at construction (assertScimAdminCoherence), so the served flag and the plugin list come from one expression. If the plugin failed to mount while the flag reads true, the door still picks its writer from the built instance, so the action works either way.
  • A caller without the standing. The standing leg of both predicates is untouched, requiredPermissions still carries PLATFORM_ADMIN_USERS_GATE, and the door answers any other caller a refusal before reading the body.
  • An expired ban on a plugin-off kernel. refuseInactiveUserSession lifts it and admits the session, as the vendor does, so Unban on a row that still reads banned stays harmless.
  • A managed environment. With an environment-user host wired, a deactivation may be refused by the host (an organization owner or admin) or refused when the host does not answer; the button is offered and the door carries the host's answer. The card names managed environments as in scope.
  • The action's own promise. The description says the banned person is signed out; runAdminBanUser calls deleteUserSessions after the write on either writer.

The block header's new paragraph was read sentence by sentence against the same code and holds. The remaining findings are nits; none changes correctness or the contract.

  • N1 (nit) — the rewritten header keeps "the UI hides them instead of rendering buttons that 404" and now attaches it by name to unlock_user and create_user. Both doors are ObjectStack mounts registered without a plugin condition, so a plain 404 is not what the tree shows for them. Accepted deviation; it belongs to the unlock_user measurement the seat filed as Setup: Unlock User may be hidden without the admin plugin although its door is mounted unconditionally — measure, then drop the gate if so #34010.
  • N2 (nit) — the header still says banned "stays true past ban_expires until better-auth clears it at the user's next sign-in". On the kernels this PR newly reaches, user-session-admission.ts clears it. The display reasoning is unchanged.
  • N3 (nit, outside the diff, follow-up) — two published texts still teach that ban-user needs the admin plugin: the requiresFeature example in content/docs/protocol/objectui/actions.mdx uses ban_user with requiresFeature: admin ("Hidden entirely when the admin plugin is off"), and the describe() of AuthFamiliesSchema.admin in packages/spec/src/api/discovery.zod.ts lists ban-user among routes that "answer a plain 404" when the flag is false. content/docs/permissions/authentication.mdx already states the opposite. The seat's comment 6897338167 carries this to Docs and spec still say ban-user / unban-user need the admin plugin (true before #33227): actions.mdx worked example and AuthFamiliesSchema.admin describe #34008.
  • N4 (nit, prose face) — the Clause-②: line in the changeset and the PR body still ends with the dispatch-time clause "the dev measures the gaining kernels and the seat amends if the diff reads otherwise", which will ship in two changelogs. The measurement is done and the answer is no. Accepted deviation in the changeset, since a fix there moves the head.

Implemented-by: claude/project-thread-5jq3wa
Reviewed-by: session_01ADHkmT2NE3iyG1o6TDg3sf

VERDICT: PASS

Reviewed 2026-11-15T16:42Z.

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

domain:ui#1 · os-steve · session_01ADHkmT2NE3iyG1o6TDg3sf

落地

Landing approved by the maintainer in the seat thread at 2026-11-15T16:10Z ("批准席位 本班复核通过的 PR 执行 --land"). The ACCEPT head 8631da39 was synced with origin/main by a merge-only relay pr_update_branch (K was 27); the PR's own delta is unchanged. The record carry was refused (pending-sso-users.test.ts moved on main too), so the contract review was re-made on the new head: record 6897821241, PASS, no must-fix, no should-fix. This stroke: pr_ready + automerge_enable on head 9d6dba49 · 2026-11-15T16:43Z.

Reading Value
Queue membership not queued before this stroke; mergeable_state clean; 67 check runs on 9d6dba49: 56 success, 11 skipped, 0 failed; check-governed-merges: NOT governed
origin/main 04d4114a4b; K = 13 first-parent commits since the merge base (< 15, no sync owed)

State change: on MERGED, Fixes #33759 closes the card; the seat then removes pm:dispatched and the assignee there, and #33187 (parked on needs-user-decision) takes sys-user.object.ts next. Record nits N1/N3 ride on #34010/#34008.

scbdzhwl pushed a commit to scbdzhwl/objectstack-analysis that referenced this pull request Nov 16, 2026
…e admin plugin (objectstack-ai#34119)

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

Fixes objectstack-ai#34008

Clause-②: no
Metadata-protocol: none

## 维护者速读

- 改了什么:三处 spec
描述(`authFamilies.admin`、`features.admin`、`plugins.admin`)和 actions
文档示例不再说「停用/恢复、解锁、重设密码需要 admin 插件」,按实测列出真正依赖插件的操作;引用文档随之重新生成。
- 为什么改:停用/恢复、解锁、重设密码这四个接口是平台自带的,不装 admin 插件也能用;旧说法会让 AI 和开发者给这些按钮错误地加上
admin 门控。
- 风险与回滚:只改文字,没有任何 schema 接受或拒绝的结果变化;回滚即还原本 PR。
-
先看:`packages/spec/src/api/discovery.zod.ts`、`content/docs/protocol/objectui/actions.mdx`、`packages/spec/src/api/auth-endpoints.zod.ts`。
- 两分钟验证:`git grep -n "update-user, ban-user" -- packages/spec/src
content/docs` 应无结果。
- 需要你做的:无,席位落地。

## What changes

- `AuthFamiliesSchema.admin` describe
(`packages/spec/src/api/discovery.zod.ts`): the example family member
`ban-user` is replaced by `impersonate-user`, and one sentence says
`ban-user` and `unban-user` are not in the family: they are ObjectStack
mounts, served whatever the flag says. Still one paragraph.
- `features.admin` describe
(`packages/spec/src/api/auth-endpoints.zod.ts`): creating and
impersonating users are the operations that need the plugin; banning,
unbanning, unlocking and setting a password answer without it, and the
describe says the console still shows its unlock and set-password
actions only when the flag is true.
- `plugins.admin` describe and JSDoc
(`packages/spec/src/system/auth-config.zod.ts`): the JSDoc lists the
endpoints that need the plugin (`create-user`, which answers `501`
without it, `impersonate-user` / `stop-impersonating`, `set-role`,
`remove-user`, `GET list-users`, `list-user-sessions`,
`revoke-user-session(s)`) apart from the four ObjectStack mounts served
without it (`ban-user`, `unban-user`, `unlock-user`,
`set-user-password`), described as mounts rather than the plugin's
routes, with no claim about how they write. "better-auth enforces this
internally" is replaced: the ObjectStack mounts, `create-user`,
`remove-user` and the rebuilt `impersonate-user` run the ADR-0068 gate,
the vendor routes keep better-auth's legacy `user.role` check, and
`stop-impersonating` is neither: better-auth admits it on the
impersonated session with the signed `admin_session` cookie
`impersonate-user` set (read from
`better-auth/dist/plugins/admin/routes.mjs` 1.7.12, which also declares
`list-users` as `GET`). "assign global platform roles" is gone. The
describe follows the same split.
- `content/docs/protocol/objectui/actions.mdx`: the `requiresFeature:
admin` worked example gates `impersonate_user`
(`/api/v1/auth/admin/impersonate-user`) in place of `ban_user`. The
second example (`disable_oauth_application`) is unchanged.
- Regenerated:
`content/docs/references/api/{discovery,protocol,auth-endpoints}.mdx`,
`content/docs/references/system/auth-config.mdx` (`check:generated
--fix`, which named only `check:docs` stale).
- `.changeset/34008-ban-without-admin-plugin-prose.md`: `patch` on
`@objectstack/spec`.

## Why

The measurement, on `origin/main` at `27c2f1ea`. A throwaway probe (the
`pending-sso-users.test.ts` harness, one platform admin, deleted after
the run, not committed) fired each door with `plugins.admin` off and on:

| door | off | on |
|---|---|---|
| `features.admin` | false | true |
| `/admin/unlock-user` | 200 | 200 |
| `/admin/set-user-password` | 200 | 200 |
| `/admin/ban-user` | 200 | 200 |
| `/admin/unban-user` | 200 | 200 |
| `/admin/set-role` | 404 | 200 |
| `/admin/create-user` | 501 `NOT_IMPLEMENTED` | 200 |
| `/admin/impersonate-user` | 404 | 200 |

Source reading:

- `packages/plugins/plugin-auth/src/auth-plugin.ts`: `POST
{basePath}/admin/ban-user` and `/admin/unban-user` are raw Hono mounts
with no admin-plugin condition. Without the plugin, `getBanWriter`
writes through the data engine (`isAdminPluginMounted()` false) and the
session refusal enforces the ban. `pending-sso-users.test.ts` pins this
("a row banned while the admin plugin was on stays refused after the
plugin is turned off", the ban / unban cases with the plugin off, and a
CONTROL with it on).
- `sys_user.ban_user` / `unban_user` carry no `requiresFeature`, and
`PUBLIC_AUTH_FEATURES.admin.gatedInputs`
(`packages/spec/src/kernel/public-auth-features.ts`) books neither, with
a note saying why.
- Routes that still answer 404 when `features.admin` is false: the
better-auth vendor routes with no ObjectStack mount: `list-users`,
`set-role`, `update-user`, `list-user-sessions`,
`revoke-user-session(s)`, `stop-impersonating`, and `impersonate-user`
(replaced on the admin plugin's own `endpoints` record by
`admin-impersonate-endpoint.ts`, so it exists only with the plugin). The
dogfood pin `discovery-auth-families.dogfood.test.ts` reads `GET
/auth/admin/list-users` as 404 with the plugin off and not 404 with it
on. `sys_user.impersonate_user` declares `requiresFeature: 'admin'`,
which is why it is the docs example now.
- ObjectStack mounts such as `create-user` stay mounted without the
plugin but answer `501 NOT_IMPLEMENTED`; the describe's family list does
not name them, so this PR does not touch that wording.

## Tests

- `pnpm --filter @objectstack/spec test` at `6fe7a568`: Test Files 843
passed (843), Tests 26966 passed | 1 todo. Lock VERDICT command-exit 0.
- No test edit was forced. No test pins the old wording (`git grep` of
the three old phrases outside `packages/spec/src`, references and
CHANGELOGs finds only the two out-of-scope copies listed below).
- No ablation: prose only.

## Acceptance notes

- Out of the card's paths, two copies of a related phrase, not changed
here:
- `packages/plugins/plugin-auth/src/auth-manager-plugin-list.ts:312`, a
code comment "Platform admin: ban/unban, set-password, impersonate,
set-role." beside the admin plugin's registration. With the plugin on,
the vendor's ban hook still enforces, so it is loose rather than false.
`domain:server`.
- `docs/qa/platform-checklist/areas/identity-auth.json` item
`identity-auth.admin-lifecycle-operations` title lists ban/unban among
"admin user-lifecycle operations"; it makes no plugin claim.
`domain:devx`.
- `content/docs/releases/v18/18-5.mdx` and `packages/spec/CHANGELOG.md`
keep their historical wording (release-owned).
- `content/docs/permissions/authentication.mdx` already says ban / unban
answer without `plugins.admin`; unchanged.
- No `skills/**` file teaches the old rule (`git grep -n
"ban-user\|ban_user\|unban" -- skills` is empty), so no skills
follow-up.
- The console's `sys_user.unlock_user` and `sys_user.set_user_password`
declare `requiresFeature: 'admin'`
(`packages/platform-objects/src/identity/sys-user.object.ts`) and
`PUBLIC_AUTH_FEATURES.admin.gatedInputs` books both, while their doors
answer 200 with the plugin off (probe above). On a deployment without
the admin plugin the two buttons are hidden though the doors work: the
same shape the ban / unban buttons had before PR objectstack-ai#33989. Not changed
here (platform-objects + kernel feature table); for the seat to file.
The `features.admin` describe states the current console behaviour as it
is.
- File surface: the claim names `discovery.zod.ts` and
`content/docs/**`; the delta also asks for other `packages/spec/**`
copies, which added `auth-endpoints.zod.ts` and `auth-config.zod.ts`.

## Verification

<details><summary>Derived gates at 6fe7a56: 104 derived, 103 run green,
1 NOT MEASURED</summary>

- `node scripts/pm/dispatch-gates.mjs --ran` on the final record: "104
derived famil(ies) accounted for — 103 run, 1 NOT-MEASURED".
- NOT MEASURED: `pnpm check:dual-build-cjs-loads` exit 3, PREREQUISITE
NOT MET (reads every package's `dist/`; this container built only the
spec, lint and client-react closures). CI runs it.
- Every derived gate ran once at `6fe7a568`, with
`NODE_OPTIONS=--max-old-space-size=4096` exported for the whole run, and
all 103 exited 0 on that first run. Earlier heads needed reruns: at
`97b9f14c`, `spec check:generated` ran its `check:test-typecheck` `tsc`
out of heap without that flag; at `36887238`,
`check-plugin-teardown-shape.mjs --self-test` needed its pinned fixture
commit fetched into the shallow clone.
- Record: project share `spec-seat2/34008-gates-ran-r3.txt`.

</details>

🤖 Generated with [Claude Code](https://claude.com/claude-code)

https://claude.ai/code/session_01ADHkmNsjxB7oSL12vpVvW6

<!-- signed: domain:spec#2 · os-steve · session_01ADHkmQjrEpxMVxEiDUJHqC
-->

---------

Co-authored-by: Claude <noreply@anthropic.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/m tests tooling Fix lands in tooling, not a product package — enters pm:queue only with Unblocks: or a named surface

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Setup: Deactivate and Reactivate are hidden without the admin plugin, though both doors now work there

2 participants