Found on staging (sharna): the Keycloak organization and user were deleted by hand. The registry kept the tenant (archived), so the name couldn't be reused, and setting it back to trial didn't recreate the sign-in.
POST /v1/admin/tenants/{id}/reprovision{email?}. The admin defaults to the tenant's first admin.
If the org is missing: CreateOrgAndInvite.
If the org exists: InviteMember(IT_ADMIN), or ResendInvite when the admin is already a member.
Then SyncTenantStatus.
Audit tenant.signin_reprovisioned. An archived tenant gets 409; an address that belongs to another tenant gets 409 email_taken.
Order: S3 document files → Keycloak (PurgeTenant: the org, plus the accounts among its members and the first admin whose tenant_id names this tenant, never someone else's) → DELETE FROM tenants (FKs cascade; audit_log is SET NULL).
A failure at any step stops before the DB delete.
The ERP customer stays. tenant.purged (tenant-less, so it survives) records the staff member, the slug, and counts of removed accounts and documents.
Tests: server (memory + Postgres) for invited/resent/invite-into-org, rejections, purge guards, Keycloak failure leaving the tenant intact, name reusable afterwards; a stub-Keycloak test that only this tenant's accounts are deleted; OpenAPI.
The staff UI is in portal#56. Merge this one first.
**Found on staging (sharna):** the Keycloak organization and user were deleted by hand. The registry kept the tenant (archived), so the name couldn't be reused, and setting it back to trial didn't recreate the sign-in.
**`POST /v1/admin/tenants/{id}/reprovision`** `{email?}`. The admin defaults to the tenant's first admin.
- If the org is missing: `CreateOrgAndInvite`.
- If the org exists: `InviteMember(IT_ADMIN)`, or `ResendInvite` when the admin is already a member.
- Then `SyncTenantStatus`.
- Audit `tenant.signin_reprovisioned`. An archived tenant gets 409; an address that belongs to another tenant gets 409 `email_taken`.
**`DELETE /v1/admin/tenants/{id}?confirm=<slug>`**, archived tenants only:
- Order: S3 document files → Keycloak (`PurgeTenant`: the org, plus the accounts among its members and the first admin whose `tenant_id` names this tenant, never someone else's) → `DELETE FROM tenants` (FKs cascade; `audit_log` is SET NULL).
- A failure at any step stops before the DB delete.
- The ERP customer stays. `tenant.purged` (tenant-less, so it survives) records the staff member, the slug, and counts of removed accounts and documents.
Tests: server (memory + Postgres) for invited/resent/invite-into-org, rejections, purge guards, Keycloak failure leaving the tenant intact, name reusable afterwards; a stub-Keycloak test that only this tenant's accounts are deleted; OpenAPI.
The staff UI is in portal#56. Merge this one first.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Found on staging: a workspace whose Keycloak organization and admin
were deleted by hand stayed in the registry. Its name could not be
used again, and setting it back to trial did not bring the sign-in
back, because nothing re-creates the Keycloak side.
- POST /v1/admin/tenants/{id}/reprovision creates the organization with
the admin invited when it is missing, invites the admin into an
existing one, or sends the invitation again; then syncs the status.
- DELETE /v1/admin/tenants/{id}?confirm=<slug> removes an archived
tenant: document files, then the Keycloak organization and the
accounts whose tenant_id names this tenant, then the tenant row, whose
foreign keys take everything attached. The ERP customer and the audit
trail stay; tenant.purged records the staff member. The name is free.
- Store.DeleteTenant (memory and Postgres), Adapter.PurgeTenant (HTTP
and mock), OpenAPI, tests against both stores and a stub Keycloak.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Found on staging (sharna): the Keycloak organization and user were deleted by hand. The registry kept the tenant (archived), so the name couldn't be reused, and setting it back to trial didn't recreate the sign-in.
POST /v1/admin/tenants/{id}/reprovision{email?}. The admin defaults to the tenant's first admin.CreateOrgAndInvite.InviteMember(IT_ADMIN), orResendInvitewhen the admin is already a member.SyncTenantStatus.tenant.signin_reprovisioned. An archived tenant gets 409; an address that belongs to another tenant gets 409email_taken.DELETE /v1/admin/tenants/{id}?confirm=<slug>, archived tenants only:PurgeTenant: the org, plus the accounts among its members and the first admin whosetenant_idnames this tenant, never someone else's) →DELETE FROM tenants(FKs cascade;audit_logis SET NULL).tenant.purged(tenant-less, so it survives) records the staff member, the slug, and counts of removed accounts and documents.Tests: server (memory + Postgres) for invited/resent/invite-into-org, rejections, purge guards, Keycloak failure leaving the tenant intact, name reusable afterwards; a stub-Keycloak test that only this tenant's accounts are deleted; OpenAPI.
The staff UI is in portal#56. Merge this one first.
🤖 Generated with Claude Code
https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB
Found on staging: a workspace whose Keycloak organization and admin were deleted by hand stayed in the registry. Its name could not be used again, and setting it back to trial did not bring the sign-in back, because nothing re-creates the Keycloak side. - POST /v1/admin/tenants/{id}/reprovision creates the organization with the admin invited when it is missing, invites the admin into an existing one, or sends the invitation again; then syncs the status. - DELETE /v1/admin/tenants/{id}?confirm=<slug> removes an archived tenant: document files, then the Keycloak organization and the accounts whose tenant_id names this tenant, then the tenant row, whose foreign keys take everything attached. The ERP customer and the audit trail stay; tenant.purged records the staff member. The name is free. - Store.DeleteTenant (memory and Postgres), Adapter.PurgeTenant (HTTP and mock), OpenAPI, tests against both stores and a stub Keycloak. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01DmXxNULoSNPvjF7buKipsB