Skip to content

fix(plugin-auth)!: a disabled or removed account keeps nothing running in its name - #36163

Merged
os-zhuang merged 8 commits into
mainfrom
claude/sec2-account-removal
Nov 22, 2026
Merged

os-zhuang merged 8 commits into
mainfrom
claude/sec2-account-removal

Conversation

@objectstack-fleet

Copy link
Copy Markdown
Contributor

Clause-②: no (narrowing)
Metadata-protocol: none
Skills-docs: none — the published skills teach neither the ban, the AI service account lifecycle doors nor who owns a SCIM credential; the two docs pages in this diff carry the new effects

维护者速读

  • 平台管理员封禁用户、身份目录停用或删除用户、管理员删除用户之后,该用户名下仍在运行的东西会一并停下:其负责的 AI 服务账号被暂停,其注册的 OAuth 应用被停用,其创建的目录同步凭据被吊销;解封或重新启用都不会恢复这些。
  • 为什么做:账号停用与删除的收尾规则(维护者 11 月 21 日裁定),与重置密码的收尾对齐,所有停用入口结果一致。
  • 出错会怎样:若封禁或停用了恰好创建目录同步凭据的管理员,该连接的同步会暂停,需要另一位管理员重新签发凭据(事先轮换可避免);封禁与删除的回执会写明收尾数量,删除收尾失败时整个删除被拒、不留半截状态。
  • 要你做什么:无。

What changes

One family rule (maintainer ruling 2026-11-21): an account disabled or removed by any door keeps nothing running in its name — what it is accountable for is suspended, what it registered is disabled, what it minted is revoked, and re-activation restores none of it.

  • An AI service account runs only while its accountable owner's account is active. A platform administrator's ban (/admin/ban-user) suspends every AI service account the person is accountable for, in every organization, with its own reason (Accountable owner banned by an administrator). register, set-owner and resume share ONE owner-is-active check (isAccountableOwnerActive, service-account-doors.ts) in place of the directory-reason match resume carried: an owner disabled by any door is refused (400 VALIDATION_FAILED at ownerId on register / set-owner, 409 RESOURCE_CONFLICT on resume). An unban or re-activation resumes none; a timed ban leaves the accounts suspended after it expires.
  • A ban, a directory deactivation or deletion, and an administrator's delete each run the password-reset arm (endWhatTheAccountRegistered) for the account's registrations, through one module (removed-account-registrations.ts): OAuth applications it registered are written disabled, SCIM credentials it minted are revoked, each revoke writing the audit row a reset writes (actor: the administrator; for the directory, the connection's service principal with no user_id). SSO providers are kept, as ruled for a reset.
    • Ban: after the ban write; answers data.revoked = { serviceAccounts, ownedApps, scimCredentials, failed, complete } and the same counts on its audit row, as the forced reset answers its own. A step that fails does not undo the ban (complete: false, one warn; banning again retries).
    • Directory: on every inactive reconcile, after the account suspension; never fails the deprovision. A revoked credential is said once at error, naming it and the remedy; an arm that does not finish is said once at error and the next inactive write retries it.
    • Administrator's delete: better-auth's user.delete.before database hook — after the vendor authorized the delete, inside the delete's unit of work (runSubjectErasureAtomically), before the row is deleted. An arm that cannot finish refuses the delete (503 SERVICE_UNAVAILABLE) and it rolls back. The request seam adds revoked: { ownedApps, scimCredentials } to a successful answer.
  • Texts: the Ban action's confirmation (all 10 translated locales too) and its AI-facing description, and the Unban action's AI-facing description, state the new effects (a ban is no longer "nothing is revoked" for these registrations); content/docs/permissions/authentication.mdx gains What a ban, a deactivation or a removal ends (with the known trades: directory sync pauses when the minting administrator is removed — rotate first; a timed ban leaves the accounts suspended after it expires); content/docs/ai/agents.mdx; the route ledger rows; checklist item identity-auth.ai-service-account-lifecycle revision 3 gains the clause.
  • Pinned, not changed: an administrator's delete of a person who is still accountable for an AI service account is refused today (400 VALIDATION_FAILED from the account's row rules, the cascade nulling its owner) and rolls back with what the arm ended; once a new owner is named, the delete goes through.

Tests

New pins, red on base 3543b51 (13 failed / 69 passed across the two files), green on the branch:

  • scim-deactivation-reconcile-user.test.ts — control pin (j) flipped: an administrator's ban of the owner now suspends the accounts with its own reason; unban resumes none; resume refused while banned, allowed once unbanned. New block (k): a timed ban's expiry leaves the accounts suspended; a deactivation over an administrator's ban keeps resume refused; register and set-owner refuse an owner disabled by either door (controls: an active owner accepted, an unbanned one accepted again); a directory deactivation and a SCIM delete disable the person's applications and revoke their credentials (recorded against the connection, said once at error), a re-activation restores none, another person's registrations untouched (control); an application that cannot be disabled still deprovisions, revokes the credential, says so once, and the next inactive write retries.
  • password-reset-ends-added-access.test.ts — through the real route mount: a ban ends the registrations and answers the counts on the response and ledger, unban restores none; an administrator's delete ends them and answers the counts; a delete whose arm fails is refused 503 SERVICE_UNAVAILABLE and rolls back (control: the same delete succeeds); an administrator's delete of an accountable owner is refused and rolls back what it ended (control: after the owner is changed it succeeds); an account with nothing registered is banned and removed with zero counts. The suite's existing control that a password change (not a reset) ends none of these stays green.
  • action-confirm-one-dialog.test.ts — the Ban warning's verbatim pin updated to the ruled text, plus the two new effects.

Ablations (each guard reverted through scripts/ablation-replace.mjs, on-disk anchor 1 → 0, restored blob == HEAD, git diff HEAD empty): ban's suspension call → (j) red; ban's registrations call → ban pin red; the shared owner-is-active check → 4 (k) pins red; the directory call → 3 (k) pins red; the delete hook's call → 4 delete pins red.

Acceptance notes

  • Owed, not in this PR: the dated add-only ADR-0151 D6 note (its own governed card, per the ruling). Further items in this family are held by the security seat.
  • L2: a declared narrowing — the contract-tier review is the security seat's, owed before queueing.
  • An administrator's delete of a user who has a two-factor enrolment row is refused by the engine (409 DELETE_RESTRICTED, sys_two_factor.user_id is required with no delete behaviour declared), whatever this rule does — measured in this PR's harness; the delete pins clear that fixture row. Not fixed here.
  • The delete's refusal of an accountable owner answers with the AI service account's own row-rule message ("An AI service account needs an accountable owner …"), which names the account rather than the person being deleted; wording left as is.

Verification

First read (by risk): packages/plugins/plugin-auth/src/auth-manager-database-hooks.ts (the user.delete.before hook: runs inside the delete's unit of work, fails the delete closed), packages/plugins/plugin-auth/src/removed-account-registrations.ts (the family module and the delete's answer), packages/plugins/plugin-auth/src/service-account-lifecycle.ts (resume now asks the shared check instead of the directory reason).

Two-minute check: pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2 src/scim-deactivation-reconcile-user.test.ts src/password-reset-ends-added-access.test.ts — expect 82 passed.

Local readings (tree at 64de2c2, before the merge of main, which touched none of these files):

  • @objectstack/plugin-auth: test 6193 passed / 3 failed — three exact-shape pins of the ban's audit row, stale by this change and updated (pending-sso-users.test.ts); the touched files re-run 186/186. typecheck (incl. the test layer) exit 0.
  • @objectstack/platform-objects: test 2117/2117, typecheck exit 0.
  • dispatch-gates --commands: 112 derived commands run (--ran: 112 accounted). 108 exit 0; check:test-source-alias red on the two edited suites, fixed (module-top egress import), now exit 0; 3 exit 3 PREREQUISITE NOT MET, NOT MEASURED locally, CI's: check-plugin-teardown-shape --self-test (shallow clone), check:skill-examples and check:dual-build-cjs-loads (unbuilt packages).
  • Dogfood battery (a declared narrowing): run on the final head; its reading is in the report comment.

Generated by Claude Code

…hing running in its name

Claude-Session: https://claude.ai/code/session_017xRBcRfrHiPiptXnSD15eu
Co-authored-by: Claude <noreply@anthropic.com>
…ccount ran in its name

Claude-Session: https://claude.ai/code/session_017xRBcRfrHiPiptXnSD15eu
Co-authored-by: Claude <noreply@anthropic.com>
…ved account keeping nothing running

Claude-Session: https://claude.ai/code/session_017xRBcRfrHiPiptXnSD15eu
Co-authored-by: Claude <noreply@anthropic.com>
…n in the edited suites

Claude-Session: https://claude.ai/code/session_017xRBcRfrHiPiptXnSD15eu
Co-authored-by: Claude <noreply@anthropic.com>
@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 21, 2026
@github-actions

Copy link
Copy Markdown
Contributor

📓 Docs Drift Check

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

21 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 0db6f8fbe0eb697022a548280a634163674cf2f7.

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

What this run could not see
  • 2 anchor(s) matched too much of the corpus to be a work list: sys_user (symbol, 56 pages), VALIDATION_FAILED (literal, 51 pages)
  • 7 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 — 23 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 0db6f8fbe0eb697022a548280a634163674cf2f7 → packageMentionDocs.

Which tree this was computed on

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

node scripts/docs-audit/affected-docs.mjs --json 0db6f8fbe0eb697022a548280a634163674cf2f7

⚠️ 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 0db6f8fbe0eb697022a548280a634163674cf2f7 → 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

security#2 · sunhaolin · session_017xRBcRfrHiPiptXnSD15eu
os-dev-report

{
 "issue": null,
 "status": "done",
 "branch": "claude/sec2-account-removal",
 "pr": "https://github.com/objectstack-ai/objectstack/pull/36163",
 "session": "session_017xRBcRfrHiPiptXnSD15eu",
 "premise_still_valid": true,
 "summary": "One family rule, ruled A on both orders: an account disabled or removed by any door keeps nothing running in its name. (1) An administrator's ban suspends the AI service accounts the person is accountable for with its own reason ('Accountable owner banned by an administrator'); register, set-owner and resume share ONE owner-is-active check (isAccountableOwnerActive, service-account-doors.ts) replacing resume's directory-reason match; unban/re-activation resume none. (2) The ban door, the SCIM inactive reconcile and an administrator's delete (better-auth user.delete.before hook, inside runSubjectErasureAtomically's unit of work, before the row delete, fail-closed 503) call the reset arm endWhatTheAccountRegistered through a new module removed-account-registrations.ts: owned OAuth apps disabled, minted SCIM credentials revoked with the reset's audit row (admin as actor; the connection's svc:scim principal with null user_id on the directory path); SSO providers kept; ban answers data.revoked {serviceAccounts, ownedApps, scimCredentials, failed, complete} plus ledger counts, delete answers revoked {ownedApps, scimCredentials}; the directory path logs one error line naming the revoked credential and the remedy. Ban/Unban action texts (human + AI-facing, 10 locales), authentication.mdx (new section with both known trades), agents.mdx, route ledger rows and checklist item identity-auth.ai-service-account-lifecycle (revision 3) updated. Measured and pinned rather than changed: an administrator's delete of a person still accountable for an AI service account is refused today (400 VALIDATION_FAILED from the account row rules via the cascade set_null) and rolls back with what the arm ended.",
 "tests": "Red on base 3543b51d (source reverted to BASE, tests kept): 13 failed / 69 passed across scim-deactivation-reconcile-user.test.ts + password-reset-ends-added-access.test.ts; green on branch 82/82 (flipped control pin (j); new (k) block: timed-ban expiry, deactivation over a ban, register/set-owner refusal by both doors with active-owner controls, directory deactivate/delete ends registrations + error line + re-activation restores none + unrelated person untouched, incomplete-arm retry; real-mount ban/delete pins incl. counts, 503 fail-closed rollback with control, accountable-owner delete refused + rolled back with control, empty-account control). Existing 'a password change disables and revokes nothing' control stays green. plugin-auth full suite: 6193 passed / 3 failed — three exact-metadata pins of the ban audit row in pending-sso-users.test.ts, stale by this change, updated; touched files re-run 186/186. platform-objects test 2117/2117 (Ban warning verbatim pin updated to the ruled text). Ablations via scripts/ablation-replace.mjs (anchor 1→0 on disk, restore blob == HEAD, git diff HEAD empty each leg; tests import src, no dist leg): ban suspension call → (j) red; ban registrations call → ban pin red; shared owner-is-active predicate → 4 (k) red; directory call → 3 (k) red; delete hook call → 4 delete pins red.",
 "gates": "Local (tree 64de2c2f; main merged after, touching none of these files): plugin-auth typecheck (tsc + examples + test layer) exit 0; platform-objects typecheck exit 0; check-i18n-bundles --write exit 0 (en bundle regenerated); check-platform-checklist OK; dispatch-gates --commands 112 derived, all run (--ran: 112 accounted): 108 exit 0, check:test-source-alias exit 1 then fixed (module-top egress import in the two edited suites) and re-run exit 0, 3 exit 3 PREREQUISITE NOT MET = NOT MEASURED locally (check-plugin-teardown-shape --self-test: shallow clone; check:skill-examples and check:dual-build-cjs-loads: unbuilt packages). PR check-runs on head 507cc0de: Lint & Repo Gates success, TypeScript Type Check success, Test Core success (10/10 shards success), Build Core success, Governed Surface Queue Guard success, Test UI success, Live E2E UI success, Dogfood Regression Gate success (PR-speed; shards run in queue), Check Changeset success, Build Docs success, Flag docs affected by code changes success, Spec property liveness success, Check PR Size success, PR-body guards success; Lint UI / Type Check UI / Build & E2E UI skipped by path filter.",
 "dogfood_battery": "507cc0de · os-verify-lock: VERDICT command-exit 0 (held 40m24s) · Test Files 483 passed / 3 skipped (486) · Tests 4101 passed / 68 skipped (4169) · no failure. A first run was killed with the paused turn before its verdict and is not counted.",
 "mcp_calls": "3 — claude-code-remote subscribe_pr_activity x1; GitHub MCP read-only pull_request_read(get_check_runs) x1; ToolSearch load x1 (not GitHub). No GitHub MCP write tool.",
 "api_writes": "3 relay/tool writes — fleet-write advisory_read x2 (GHSA-45p8-r2x4-xh7m, GHSA-f9wh-5w94-j255; read ops through the relay dispatch), fleet-write pr_create x1 (POST /repos/objectstack-ai/objectstack/pulls, draft, body read back byte-identical, no labels/assignees), plus this report comment via post-stamped.mjs (POST /repos/objectstack-ai/objectstack/issues/36163/comments). git push is not a REST write.",
 "deviations": [
  "Worktree: the dispatched branch was checked out in the shared checkout; detached that checkout and added a linked worktree on the branch (../objectstack-sec2) before any edit.",
  "File surface beyond plugin-auth/src: packages/platform-objects (sys-user.object.ts Ban/Unban texts, the 10 hand-written ban_user translations, the regenerated en bundle, action-confirm-one-dialog.test.ts pin) — the producer of the ordered action texts.",
  "Touched auth-manager.ts (import + reconcileScimUserLifecycle inactive branch + one new private method), auth-manager-database-hooks.ts (user.delete.before) and auth-manager-request-routing.ts (remove-user tally) — possible overlap with claude/sec2-ggfh only in auth-manager.ts; hunks kept minimal. None of client-address.ts, objectql-adapter.ts touched.",
  "Commit trailers use the model-free pair AGENTS.md prescribes (Claude-Session + Co-authored-by: Claude), not the harness's model-named Co-Authored-By.",
  "Translations for ar/de/fr/ko/pt-BR/ru/es-ES/ja-JP/zh-CN/zh-Hant appended by the dev, not a native translator."
 ],
 "line_budget": "29 files before the merge of main, +1217 / -86 (dispatch-gates count), under the 3000-line human-merge threshold",
 "files_changed": [
  ".changeset/sec2-account-removal.md",
  "content/docs/ai/agents.mdx",
  "content/docs/permissions/authentication.mdx",
  "docs/qa/platform-checklist/areas/identity-auth.json",
  "packages/platform-objects/src/apps/translations/{ar,de,en,es-ES,fr,ja-JP,ko,pt-BR,ru,zh-CN,zh-Hant}.objects.generated.ts",
  "packages/platform-objects/src/identity/sys-user.object.ts",
  "packages/platform-objects/src/identity/action-confirm-one-dialog.test.ts",
  "packages/plugins/plugin-auth/src/{admin-ban-endpoints,auth-manager,auth-manager-database-hooks,auth-manager-request-routing,auth-route-ledger,forced-reset-revocation,password-reset-ends-added-access,removed-account-registrations(new),service-account-doors,service-account-lifecycle,service-account-owner-leaves}.ts",
  "packages/plugins/plugin-auth/src/{password-reset-ends-added-access,scim-deactivation-reconcile-user,pending-sso-users}.test.ts"
 ],
 "open_questions": [
  {
   "question": "An administrator's delete of a person still accountable for an AI service account is refused with the account's own row-rule message (400 VALIDATION_FAILED at accountable_user_id), which names the account rather than the person being deleted. Pinned as-is here.",
   "options": [
    "A keep the refusal (pinned), names nothing new",
    "B declare deleteBehavior 'restrict' on sys_user.accountable_user_id so the engine answers 409 DELETE_RESTRICTED naming the dependent accounts — a platform-objects metadata/semantic change, its own card",
    "C have the delete suspend and detach the accounts — conflicts with the row rule that an agent always names an owner"
   ],
   "recommendation": "A in this PR, B as a follow-up card: same outcome (nothing runs in a removed person's name), clearer refusal, small change, but a contract change the order did not rule."
  },
  {
   "question": "The delete arm fails closed (503, delete refused and rolled back) while the ban and directory arms are best-effort. Chosen because the row delete is the last moment the registrations can be found by owner.",
   "options": [
    "A fail closed (as built)",
    "B best-effort with complete:false like the ban"
   ],
   "recommendation": "A; a best-effort delete would leave owner-less live registrations nothing retries."
  },
  {
   "question": "The directory path's audit row names the connection's service principal (actor svc:scim:CONNECTION_ID, user_id null), via an optional servicePrincipal flag added to CredentialRevokeTrail; the ruling said 'the audit row a reset writes' without naming the directory's actor.",
   "options": [
    "A service principal, no user (as built)",
    "B the deactivated person as actor"
   ],
   "recommendation": "A; it matches how every SCIM write is attributed (authSystemWriteContext)."
  }
 ],
 "security_findings": "withheld",
 "out_of_scope_findings": [
  "class: a · reach: measured through POST /api/v1/auth/admin/remove-user on the real route mount with a real AuthManager over ObjectQL/sqlite (password-reset-ends-added-access.test.ts harness; the vendor two-factor plugin not mounted there) — a user holding a sys_two_factor row is refused 409 DELETE_RESTRICTED ('still referenced by 1 Two Factor record(s) through User, which is required'), because sys_two_factor.user_id is required with no deleteBehavior declared · evidence: first run of the delete pin before the fixture row was cleared · dedupe words: remove-user two_factor DELETE_RESTRICTED; sys_two_factor user_id deleteBehavior; admin delete user 2FA 409",
  "carrier: security#2 seat · the dated add-only ADR-0151 D6 note is owed as its own governed card (named in the PR's Acceptance notes)",
  "carrier: security#2 seat · L2 contract-tier review owed (declared narrowing); not knocked"
 ]
}

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Contract review

Head-sha: 507cc0de1212a85dd740f0acd2c92879ad70f9f7

PASS at CONTRACT_REVIEW_TIER on the narrowing face (Clause-②: no (narrowing)). Served-tier: CONTRACT_REVIEW_TIER. Reviewer: an isolated thread, read-only. It read both advisories, the developer's report, the net diff, a git archive export of the head, and the vendor code.

What holds

  • Every door and every effect. The administrator's ban, the directory's deactivation and delete, and the administrator's delete each end the account's registrations; the delete does so inside its unit of work.
  • Nothing is restored on unban or re-activation. This is pinned.
  • Owner-is-active is one function, called by register, resume and set-owner. It reads the person's ban, whatever its cause.
  • The trade-offs are documented in the changeset and docs: provisioning pauses when the minting administrator is removed, and a timed ban leaves accounts suspended after it expires. The Ban and Unban texts, both the human ones and the AI-facing ones, state the effects.
  • The declarations are true: the BREAKING banner, the ADR-0087 marker, patch, and the dogfood battery recorded on this head (comment 7073804413).
  • Public text is rule-level.
  • CI and merge. 55 check-runs are success or skipped. The PR merges cleanly into origin/main.

Nits (not blocking)

  • Header jsdoc of removed-account-registrations.ts.
  • The 503 refusal text.
  • An unrecorded revoke when no actor resolves; not reachable behind the gated doors.
  • One test title.
  • The administrator-guide summary row.

The developer's three open questions are accepted as recommended (option A on each).

@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

席位记录 · ACCEPT · head 507cc0de1212a85dd740f0acd2c92879ad70f9f7

维护者速读

  • 改了什么:员工无论是被管理员封禁、被企业目录停用或删除,还是被管理员删号,他负责的 AI 服务账号都会暂停,他注册的接入应用会被停用,他签发的目录同步凭据会被吊销。重新启用他的账号,这些都不会自动恢复。
  • 为什么:落实 11 月 21 日的两项裁决(都选 A),属安全席位的无卡派单。
  • 若出错:只会多停、多拒,不会多放。可以直接撤回,但已吊销的凭据要重新签发。
  • 要你做什么:请用授权账号批准当前 head 507cc0de1(契约审核 PASS 记录:评论 7074100407)。批准后由席位翻 ready、入队落地。

席位意见:ACCEPT。一条规则覆盖了全部入口;修前红、修后绿,守卫消融也齐全。

席位核对

  1. 形态: draft PR,以 main 为基,无卡。改动 plugin-auth 和 platform-objects 两个包(都升 patch)、两个文档页、11 个翻译包和一个 changeset。
  2. 前提实测: dev 在基座上测出 13 个红,修后全绿,守卫消融后会变红。审核方另外读了第三方库代码,确认一共只有两个写入方会封禁一个人。
  3. 门禁: head 上 55 个 check-run 全部成功或按路径跳过,其中包括 Test Core 10/10 和 Governed Surface Queue Guard。dogfood 套件已在本 head 上跑过并留了记录(7073804413)。
  4. 接受的偏差: dev 的 3 个开放问题都按推荐选 A:维持拒绝;删号失败时整体回滚;操作人记为服务主体。
  5. 范围外去向,Skills-docs::
    • 范围外的安全事项已由安全席位另行记录。
    • 另有一个非安全问题:删除开了二次验证的用户时会被拒(409),要另开普通车道卡。
    • 没有改 skills/**。
  6. 落地条款:
    • 申报为收窄,合并队列要两半齐备:授权账号对当前 head 的批准,加上本 head 上的契约审核 PASS。
    • 批准后,席位先做落地前检,再执行 pr_ready 和 automerge_enable。
    • 合并后,把公告 GHSA-45p8 的残留 1–3 和 GHSA-f9wh 的 R7 标为已修,记进台账。公告本身先保持草稿,因为还有残留待裁。

@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 22, 2026
@os-zhuang
os-zhuang marked this pull request as ready for review November 22, 2026 05:02
@os-zhuang
os-zhuang added this pull request to the merge queue Nov 22, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 22, 2026
@objectstack-fleet

Copy link
Copy Markdown
Contributor Author

security#2 · sunhaolin · session_017xRBcW9L8Noz9BxEwjwiov

Contract review

Served-tier: CONTRACT_REVIEW_TIER
Head-sha: 507cc0de1212a85dd740f0acd2c92879ad70f9f7
Local-runs: none
Scope: packages/platform-objects/src/apps/translations/ar.objects.generated.ts, packages/platform-objects/src/apps/translations/de.objects.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/fr.objects.generated.ts, packages/platform-objects/src/apps/translations/ja-JP.objects.generated.ts, packages/platform-objects/src/apps/translations/ko.objects.generated.ts, packages/platform-objects/src/apps/translations/pt-BR.objects.generated.ts, packages/platform-objects/src/apps/translations/ru.objects.generated.ts, packages/platform-objects/src/apps/translations/zh-CN.objects.generated.ts, packages/platform-objects/src/apps/translations/zh-Hant.objects.generated.ts, packages/platform-objects/src/identity/action-confirm-one-dialog.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/auth-manager-database-hooks.ts, packages/plugins/plugin-auth/src/auth-manager-request-routing.ts, packages/plugins/plugin-auth/src/auth-manager.ts, packages/plugins/plugin-auth/src/auth-route-ledger.ts, packages/plugins/plugin-auth/src/forced-reset-revocation.ts, packages/plugins/plugin-auth/src/password-reset-ends-added-access.test.ts, packages/plugins/plugin-auth/src/password-reset-ends-added-access.ts, packages/plugins/plugin-auth/src/pending-sso-users.test.ts, packages/plugins/plugin-auth/src/removed-account-registrations.ts, packages/plugins/plugin-auth/src/scim-deactivation-reconcile-user.test.ts, packages/plugins/plugin-auth/src/service-account-doors.ts, packages/plugins/plugin-auth/src/service-account-lifecycle.ts, packages/plugins/plugin-auth/src/service-account-owner-leaves.ts + none

① Derived judgments

Every door (administrator ban, directory deactivation and delete, administrator delete) ends the account's registrations by one arm; unban and re-activation restore none (pinned); owner-is-active is one function read by register, resume and set-owner. Prior record: comment 7074100407.

② Semver level

patch with the BREAKING banner and ! title, as declared (Clause-②: no (narrowing), Metadata-protocol: none).

③ Boundary flags

Dev open questions 1-3 answered A (accepted). SQL push-down: no new id materialisation or in-app join.

④ Design judgment

The narrowing holds against the published spec on main: it makes an existing refusal real and takes no declared capability away. No must-fix or should-fix is open at this head; nits only, recorded in the prior record.

Implemented-by: session_017xRBcRfrHiPiptXnSD15eu
Reviewed-by: session_017xRBcW9L8Noz9BxEwjwiov

VERDICT: PASS

@os-zhuang
os-zhuang added this pull request to the merge queue Nov 22, 2026
Merged via the queue into main with commit bc2aaf1 Nov 22, 2026
61 checks passed
@os-zhuang
os-zhuang deleted the claude/sec2-account-removal branch November 22, 2026 07:46
Nenzyz pushed a commit to Nenzyz/objectstack that referenced this pull request Dec 1, 2026
…password; a re-activation restores access through SSO only (objectstack-ai#34738)

Fixes objectstack-ai#32115

Clause-②: yes (narrowing)
Metadata-protocol: none
Skills-docs: none — no skill under `skills/**` teaches the SCIM
deactivation lifecycle; `content/docs/permissions/authentication.mdx`
gains the rule in this change.

## 维护者速读

- 改了什么:SCIM 目录停用(`active: false`)、删除(`DELETE
/Users/{id}`)、让用户失去最后一个活跃来源的连接退役,以及目录把用户保持为停用时的任何后续写入,在 main 已有的封禁、吊销
API key、暂停 AI 服务账号、结束其注册的 OAuth 应用与 SCIM
凭证之外,现在还删除该用户的本地密码(`sys_account` 中 `provider_id = 'credential'`
的行),之后该用户读作目录托管(`idp_provisioned`)。目录重新启用(`active: true`
解除目录自己的封禁)时先删除用户此刻持有的本地密码再解封,访问只经 SSO 恢复;删除未完成则重新启用失败,用户保持停用。
- 为什么改:在案裁决(objectstack-ai#32004 评论 6787890900,「Directory
deactivation」条)写明「移除目录用户的本地密码是后一步」;API key 一半(objectstack-ai#33075)、AI
服务账号(objectstack-ai#33109)与注册结束(objectstack-ai#36163)已在 main 上,本 PR 合入 main 之后只剩本地密码这一半。维护者 11-17
的「这个不用处理」只免去回填扫尾,修复本身仍欠。
- 风险与回滚:收窄(BREAKING,标题带
`!`):被目录停用过的用户重新启用后没有本地密码,需要时要在重新启用之后有意设置。不做迁移或回填。管理员封禁/解封、管理员封禁之上的
`active: true`、未被封禁用户的目录同步、末位管理员被拒的停用都不删密码。回滚 = 回退本 PR;已删除的密码行不会随回滚恢复。
- 先看:`packages/plugins/plugin-auth/src/auth-manager.ts` 的
`reconcileScimUserLifecycle`(本轮合并解决处:停用分支里 main 的注册结束之后、目录标记之前删除;重新启用分支
fail-closed);`scim-deactivation-password-removal.ts`;`scim-deactivation-reconcile-user.test.ts`
的 (l) describe。
- 两分钟验证:`pnpm --filter @objectstack/plugin-auth exec vitest run
src/scim-deactivation-reconcile-user.test.ts`,预期 60/60 通过(main 的 45 条 +
本 PR 的 15 条 (l) 用例)。
- 需要你做的:无,席位落地(收窄所需的 L2 契约复审由席位路由)。

## What changes

- **The rule.** A directory deactivation removes the user's local
password; a re-activation by the directory restores access through SSO
only.
- On every inactive call of `AuthManager#reconcileScimUserLifecycle`,
after what `main` already does there (the ban write, the API key
revocation, the AI service account suspension, and the ending of the
user's OAuth applications and SCIM credentials), and before the
directory-managed mark, every `sys_account` row of the user with
`provider_id = 'credential'` is deleted. The inactive calls are PATCH
`active: false`, `DELETE /Users/{id}`, a create with `active: false`, a
tombstone re-link that arrives inactive, a connection decommission pass
that removes the user's last active source, and any later SCIM write
while the directory holds the user inactive. The trigger is the
directory's state, never the ban column.
- On the `active: true` call that lifts the directory's own ban
(`SCIM_DEACTIVATION_BAN_REASON`), the same writer removes any such row
the user holds at that moment, inside the same SCIM transaction, before
the directory-managed mark and before the unban. A re-activation after a
directory deactivation therefore restores no credential from before it,
a password an administrator set while the directory held the user
deactivated included.
- The user row, the user's other account links (SSO / OAuth) and the
history that names the user are kept (ADR-0134 D3).
- **Writer**
`packages/plugins/plugin-auth/src/scim-deactivation-password-removal.ts`
(package-internal): reads the row ids only and deletes them through the
engine in the system context, attributed to the SCIM connection as a
service principal (`authSystemWriteContext`). Idempotent, never throws.
`complete` is a measured zero: after deleting, it re-reads and reports
`complete` only when no local-password row is left; a row read without
an id counts as not removed. At most 100 rows of one user per call,
documented in the module header. No audit row follows a delete:
`sys_account` is on the audit mirror's skip list.
- **Failure posture, one per branch.** Deactivation: the ban lands
first, so an incomplete removal is logged once at `error` and the
deprovision still succeeds; the next inactive write runs it again.
Re-activation: the ban stays until the removal is complete; an
incomplete removal is logged once at `error` and fails the SCIM request,
which the vendor rolls back, so the user stays deactivated until the
directory retries.
- **Order and the mark.** On a deactivation the removal runs after the
ban, so a ban the last-administrator guard refuses throws first and
removes nothing. On both branches it runs before the directory-managed
mark (ADR-0135 D4), so a user whose password the removal took reads
`idp_provisioned`.
- **Sessions.** Unchanged: the vendor deletes the user's sessions after
the callback for an inactive state.
- **Unchanged, each pinned by a control:** an administrator's ban and
unban; an `active: true` over an administrator's ban; an attribute sync
or `active: true` for a user who is not banned; a user with no local
password.
- **The directory's ban reason.** A ban whose reason reads `Deactivated
via SCIM` is the directory's whoever wrote it: the directory's next
active write lifts it and removes the local password (docblock,
changeset, docs). Reserving that string on the administrator's ban mount
is not done here (L2 N4, Acceptance notes).
- **Docs:** a bullet in `content/docs/permissions/authentication.mdx`,
after `main`'s registration-ending bullet: the removal, the decommission
door, the `idp_provisioned` mark, the re-activation half, and that no
migration or backfill runs. `scim-identity-source.ts`'s header says what
the mark reads after the removal.
- **Changeset:**
`.changeset/32115-directory-deactivation-local-password.md`,
`@objectstack/plugin-auth` patch, BREAKING, ADR-0087 disposition
not-required (no-migration-prescription). Its BREAKING paragraph now
lists the registration ending `main` gained beside the ban, keys and AI
service accounts.
- **Census:**
`docs/audits/2026-08-tenant-audit-write-call-sites.counts/plugins/plugin-auth.md`
regenerated by `node scripts/tenant-audit-census.mjs --write` after the
merge (never hand-merged): 111 sites, `main`'s 110 plus the writer's one
`delete` of `SystemObjectName.ACCOUNT`.

## Tests

Top-level describe in
`packages/plugins/plugin-auth/src/scim-deactivation-reconcile-user.test.ts`,
through `@better-auth/scim` over a real better-sqlite3 engine: "a
directory deactivation removes the user's local password, and a
re-activation restores access through SSO only". Its fifteen cases are
now face **(l)**: `main` added its own (k) describes (an account
disabled by any door keeps nothing running in its name), so the merge
keeps `main`'s (k) whole and renames this PR's face; no case changed
subject.

- (l) `active: false` removes the local password and keeps every other
link; the mark reads `idp_provisioned`; `active: true` lifts the ban and
restores no password (sign-in `401 INVALID_EMAIL_OR_PASSWORD`); the
delete is the SCIM connection's write (`isSystem: true`, actor
`svc:scim:okta-14360`, no user credited).
- (l) `DELETE /Users/{id}` removes it the same way; a re-link through
the tombstone restores none.
- (l) a repeated inactive write sends no delete.
- (l) a deactivation over an administrator's ban removes the password
too and keeps the administrator's reason.
- (l) CONTROL: an administrator's ban and unban leave the password
alone.
- (l) CONTROL: an attribute sync or an `active: true` for a user who is
not banned removes nothing; only lifting the directory's ban does
(positive leg: one delete).
- (l) a re-activation after a directory deactivation restores no
credential from before it, the deactivated state seeded directly;
attribution asserted.
- (l) CONTROL: `active: true` over an administrator's ban lifts nothing
and removes nothing.
- (l) CONTROL: a user with no local password is a no-op.
- (l) a refused deactivation of the last administrator (PATCH and
DELETE) attempts no delete.
- (l) a deactivation that fails after the removal rolls the removal back
with the ban.
- (l) a removal that cannot be written on a deactivation still bans,
logs once at `error`, and the next inactive write removes it.
- (l) a removal that cannot be written on a re-activation fails it
(status ≥ 500), logs once, and keeps the user deactivated; the retry
re-activates with no password.
- (l) a removal is complete only when a re-read finds no local password.
- (l) a local-password row read without an id counts as not removed.

Cases changed because the behaviour changed (unchanged from the earlier
rounds): "(b) active:true ⇒ the SCIM ban is lifted, and the
re-activation restores no local password from before it", and the faces
(a), (d), (f) and the cause cases, which set the password again after
the deactivation before signing in.

## Acceptance notes

- Premise re-measured on `origin/main` `f46ce5b4af`: the API-key half
(objectstack-ai#33075, `revokeDirectoryDeactivatedApiKeys`), the AI service account
suspension (objectstack-ai#33109) and the registration ending (objectstack-ai#36163,
`endScimDeactivatedRegistrations`) are on `main`; the inactive branch
deletes no `credential` row and the active branch only unbans. Only the
local-password half still reproduces, and it is this PR's whole delta
against `main` (7 paths, +1027 / −26).
- Merge of `origin/main` `f46ce5b4af` (merge commit `c7c85d60c3`, no
rebase, no force push): four files conflicted. `auth-manager.ts` keeps
`main`'s registration ending and runs the removal after it, before the
mark; the test file keeps `main`'s new describes whole and renames this
PR's face to (l); `authentication.mdx` keeps both bullets; the census
shard was taken from `main` and regenerated (`f635db10e8`).
- The maintainer's 「这个不用处理」 (11-17) waives only the residual backfill
sweep. No migration or backfill runs: a user deactivated before this
version keeps their local credential until the directory next writes
that user. An administrator's unban removes nothing.
- Seat answers on the round-0 questions (delta r1): the removal runs on
every inactive write, a connection decommission pass included; the
last-local-credential guard stays off on the SCIM path; the break-glass
last-administrator guard still refuses first.
- L2 nits (record 6946949332, at `1540d3a270`): N1, N2, N3 and N5
applied in round 3; N4 documented, not reserved (reserving the string
adds a refusal to the administrator's ban door, outside this card); N6
and S1 belong to the ADR bookkeeping card.
- ADR bookkeeping: objectstack-ai#34820
- The connection decommission door is named from the vendor's code path
(`reconcileSCIMProjectionDomainBatch` calls `identity.reconcileUser`),
not driven by a case in this file.
- Records on file are at `1540d3a270` (L1 ACCEPT 6946960271, L2 PASS
6946949332) and do not cover this head; the round-3 delta and this merge
are unreviewed.
- `scim-deactivation-reconcile-user.test.ts` now runs 60 cases (45 on
`main`). Budget line `test-budget: 20` stands, re-measured LOCALLY at 60
cases (10.52 s, the slowest of four runs of the file alone, × 1.25); the
line says the reading is local.

## Verification

All readings on head `9d96795467` (the merge `c7c85d60c3`, the census
regeneration `f635db10e8`, and the wording commit `9d96795467`) unless
stated. Wall-clock figures are shared-box readings.

<details>
<summary>plugin-auth: red before, green after, full suite, typecheck,
census</summary>

- Closure build: `pnpm exec turbo run build --concurrency=2
--filter='@objectstack/plugin-auth...'` under the lock: `Tasks: 36
successful, 36 total`.
- `pnpm --filter @objectstack/plugin-auth exec vitest run --maxWorkers=2
src/scim-deactivation-reconcile-user.test.ts`: `Tests 60 passed (60)`,
four runs (tests 10.48 s, 10.09 s, 10.52 s, 10.31 s).
- Red before: the same file with `auth-manager.ts` restored from
`origin/main` (worktree only; blob 32d8b3f vs HEAD 10e6399): `Tests 17
failed | 43 passed (60)`, VERDICT command-exit 1. The 17 red are eleven
(l) cases (the attribute-sync control among them, on its positive leg)
plus (a), (b), (d), (f) and the two cause cases, whose fixtures follow
the rule; the three remove-nothing controls and the last-administrator
case stay green. Restored with `git checkout HEAD -- PATH`: blob
10e6399 == HEAD, `git diff HEAD` empty, `git status` clean.
- `bash scripts/pm/os-verify-lock.sh -c 'pnpm --filter
@objectstack/plugin-auth test'` (on `9d96795467`): `Test Files 295
passed (295)`, `Tests 6289 passed | 10 skipped (6299)`, VERDICT
command-exit 0.
- `pnpm --filter @objectstack/plugin-auth typecheck` after building it,
under the lock: VERDICT command-exit 0; `check:test-typecheck: OK`, debt
ledger unchanged.
- `node scripts/check-tenant-audit-census.mjs`: `OK -- 345 write call
sites certified across 18 package shard(s)`.
- Ablations of the writer and of both call sites ran in round 3 on
`fcc2c1cfbc` (a4–a9) and round 2 (a1–a3); the merge moved no line they
mutate except the inactive-branch neighbourhood, which the red-before
leg above covers.
</details>

<details>
<summary>Gate round</summary>

- `env -u OS_SKIP_DTS pnpm build --concurrency=2` under the lock:
`Tasks: 120 successful, 120 total`.
- `node scripts/pm/dispatch-gates.mjs --commands --repo
objectstack-ai/objectstack`: 108 commands (7 changed paths vs merge base
`f46ce5b4a`); each run with stdin from `/dev/null`, its exit code
captured before any pipe.
- 106 exited 0 in the round. Two answered exit 3 (PREREQUISITE NOT MET,
nothing measured) and exited 0 on re-run: `node
scripts/check-plugin-teardown-shape.mjs --self-test` (its positive
control is a pinned commit outside the shallow clone; that commit was
fetched) and `pnpm check:type-check-debt` (queued behind the dogfood
battery's hold on the lock; re-run under the lock:
`check-type-check-coverage: OK`, `--re-measure: OK`).
- `node scripts/pm/dispatch-gates.mjs --repo objectstack-ai/objectstack
--ran FILE` (each line carrying its exit code): `108 derived, 108 run, 0
NOT-MEASURED, 0 UNRUN`, a derived zero (all 108 recorded an exit code).
- CI on `9d96795467`, read once: 55 check runs completed, each `success`
or `skipped`, none failed. Test Core 1/10 to 10/10 and the `Test Core`
aggregate, Build Core, Build Docs, Test UI, Live E2E UI, Dogfood
Regression Gate, TypeScript Type Check, Lint & Repo Gates and every Lint
/ Type Check lane, Check Changeset, Check PR Size, Governed Surface
Queue Guard, the PR-body guards, Check Documentation Links, Spec
property liveness and Flag docs affected by code changes: `success`.
Path-gated UI jobs, the queue verdicts and the opt-in jobs: `skipped`.
</details>

<details>
<summary>Dogfood battery (the title carries `!`)</summary>

- On `9d96795467`, after the full build above (it covers the
`@objectstack/dogfood` closure): `bash scripts/pm/os-verify-lock.sh -c
'pnpm --filter @objectstack/dogfood test'` (no `OS_TEST_SHARD`, no
path): `Test Files 487 passed | 3 skipped (490)`, `Tests 4126 passed |
68 skipped (4194)`, VERDICT command-exit 0, held the lock 45m38s (shared
box). No failure.
</details>

**Seat-written update.** Seat `repo:objectstack#4` (os-justin,
`session_01QSeKYpEsWWE9Y5YtSsDgqZ`) wrote this body on the maintainer's
ruling in the seat session, verbatim 「一选1+」 (2026-11-24): option 1+ —
the seat performs only the writes the dev session's permission
classifier refused, each checked against the branch; no standing allow
rule is added (evidence card objectstack-ai#36936). Refused once in dev session
`session_01QSeKYkTjJ5ybZ2ydLHnMbv`, reason `[Undermining Oversight]`:
`node scripts/pm/fleet-write/dispatch.mjs --repo
objectstack-ai/objectstack --actions-file FILE` carrying this
`issue_patch`. The text above is the dev's, unchanged (15,575 bytes,
sha256 prefix `6be7afe46bc08eda`, matching the dev's hand-off); head
checked at `9d96795467`.

<!-- signed: repo:objectstack#4 · os-justin ·
session_01QSeKYkTjJ5ybZ2ydLHnMbv -->

---------

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 pm:awaiting-merge PR only: landing waits on the maintainer's own review and merge (SKILL.md 复核 ②); never on an issue 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

Development

Successfully merging this pull request may close these issues.

2 participants