W018: Remove user from organization
Revokes a member's access to the organization. Triggered from Settings, Users.
Steps
-
Reject self-removal. A user cannot remove themselves through this workflow; they must demote first or transfer ownership. A future "leave organization" workflow is out of scope for v1.
-
Confirm the target is a member. Call
Platform.getMembership(targetUserId, orgId). If no row exists, reject. -
Guard against orphaning the org. If the target's role is
owner, callPlatform.countOwners(orgId). Reject if the count would drop to zero after the removal. -
Remove the membership. Call
Platform.removeMembership(targetUserId, orgId).
Returns
Nothing.
Business rules
- Owner-count invariant. Removing the last owner is rejected.
- No self-removal here. A user cannot remove themselves through this workflow. The leave-organization flow is out of scope for v1.
- Only owners can remove members. Enforced at the request boundary.
Errors
NotFoundError. The target user is not a member.ValidationError. The caller is targeting themselves.InvalidTransitionError. Removal would orphan the org.