# User Suspension

## Objective

Block an account now, keep everything needed to restore it later.

A reversible suspension state that halts access immediately without deleting data or memberships.

## Before You Begin

This feature is being added to an application that already exists and already
works. Do not scaffold a new project, and do not assume a blank slate.

Inspect the codebase first and establish:

- The existing application structure and where code of this kind already lives.
- The framework and version in use.
- The existing design system — colours, spacing, typography, and component conventions.
- Existing UI components you can reuse instead of writing new ones.
- The existing database structure, if this feature needs to persist anything.
- The existing authentication and authorization system, if this feature is user-scoped.
- Dependencies already installed, so you don't add a library that duplicates one.
- The existing test setup and conventions.

Only start writing code once you understand the above. If the application
already implements part of this feature, extend it rather than replacing it.

## Implementation Instructions

1. Make suspension a state on the account, not a deletion or a role change. Memberships, roles, and owned records stay exactly as they were.
2. Revoke every active session and API credential the moment suspension takes effect. A suspended user who stays signed in until their cookie expires is not suspended.
3. Decide explicitly what happens to that user's background jobs, scheduled tasks, webhooks, and shared links, and enforce that decision — leaving them running is a real gap, and stopping them silently breaks other people's work.
4. Show the suspended user a plain, calm screen explaining they cannot sign in and who to contact. Do not show them the internal reason or the admin's note.
5. Record who suspended whom, when, and why, and require a reason. Suspension without an audit trail is indistinguishable from a bug.
6. Do NOT let suspension be a way around deletion requests. If a user asked to be deleted, suspension is not the answer.

## UI and UX Requirements

Match the application's existing design system exactly. Reuse its components,
spacing, and typography. This feature should look like it was always there.

## Responsive Requirements

Works on mobile, tablet, and desktop. Touch targets are large enough to hit on a
phone, and nothing overflows horizontally at 320px.

## Accessibility Requirements

- Fully keyboard navigable.
- Correct semantic elements and ARIA roles.
- Visible focus states.
- Meets WCAG AA contrast.
- Dynamic changes are announced to screen readers.
- Respects prefers-reduced-motion.

## Edge Cases

- Content owned by a suspended user must have a defined visibility rule — hidden, retained, or attributed but locked — and it must be consistent across the app, search, and exports.
- Suspending a member must not orphan the organization: block the suspension of a last owner, or force a transfer first.
- Reinstatement must restore the previous roles and memberships exactly, not re-create them at a default level.
- If the seat rule frees a seat on suspension, reinstatement can fail on a full plan — surface that before the admin suspends, not after.
- A suspended account must not be able to reset its password, accept invitations, or re-register with the same email as a route back in.
- Notification of suspension is a product decision, not an accident — decide whether the user is emailed, and use the same rule every time.
- Suspension must be reversible by a different admin than the one who applied it, in case the suspending admin is the problem.

## Testing

Exercise the feature end to end in the running application. Cover every edge case
above, then run the existing test suite and confirm nothing regressed.

## Acceptance Criteria

- [ ] Suspension halts sign-in and revokes all sessions and API credentials immediately.
- [ ] No data, membership, or role is destroyed by suspending.
- [ ] The suspended user sees a clear message with no internal reasons.
- [ ] Every suspension and reinstatement is audited with an actor and a reason.
- [ ] Reinstatement restores prior roles and memberships exactly.
- [ ] Background jobs, webhooks, and owned content follow a documented rule.
- [ ] A suspended account has no alternate route back in via reset, invite, or re-registration.
- [ ] The feature matches the existing design system.
- [ ] No existing functionality is broken.

## Adaptation Rules

- Match the existing design system. Do not introduce a new colour palette,
  spacing scale, or component library.
- Reuse existing components and utilities wherever they fit.
- Follow the naming, file layout, and code style already present.
- Do not upgrade, replace, or remove existing dependencies to make this
  feature fit. Adapt the feature to the app, not the app to the feature.
- Do not break existing functionality. If a change is genuinely required in
  existing code, make the smallest one that works and say so.
- If something in these instructions conflicts with how the application is
  built, follow the application and explain the deviation.

## Final Verification

Before you report the work as done:

1. Re-read the acceptance criteria above and check each one against what you
   actually built.
2. Run the application and exercise the feature end to end.
3. Run the existing test suite and confirm you have broken nothing.
4. Check the feature on mobile, tablet, and desktop widths.
5. Check keyboard navigation and focus handling.
6. Summarize what changed: files added, files modified, and anything you
   deliberately did differently because of how this application is built.

If any acceptance criterion is unmet, fix it before reporting completion.
