Cap members per plan with Autumn max_seats (Pro: 5)

SA
25d ago
+217-16

Summary

Caps how many members an organization can have, per plan. Pro allows 5; Team, Ultra, legacy Pro and Enterprise are unlimited.

  • The cap is max_seats in Autumn plan metadata. max_seats in a customer's metadata overrides it, for orgs we let keep more members.
  • Billing state exposes it as seatLimit.
  • Enforced in three places:
    • beforeAddMember: refuses a member at the cap. Domain auto-join no longer bypasses this; it still bypasses the free plan's 1-member limit.
    • beforeCreateInvitation: counts members plus pending, unexpired invitations, so nobody is invited into a full org.
    • /autumn/attach and /autumn/previewAttach: refuse a plan the org is already over, e.g. moving down from Team with 8 members.
  • Fails closed. A paid plan with no max_seats refuses new members. During an Autumn outage the check uses the last-known billing state, and refuses if there is none. Cached billing state from before this change has no seatLimit and is re-read from Autumn, not treated as a refusal. Stripe billing mode skips the check.

Autumn (already applied in live)

max_seats is set on all 11 paid parent plans. Metadata is shared across versions, so every plan is still v1 with no item, price or license changes.

Plansmax_seats
pro_v2, pro_v2_annual5
team, team_annual, ultra, ultra_annual, pro, pro_annual, enterprise, two custom enterprise plans2147483647

No Pro v2 org is affected: the largest has 3 members. Legacy Pro stays unlimited until those subscribers move to pro_v2. Any new paid plan, including custom enterprise ones, needs max_seats before it's sold, or its customers can't add members. This is documented in docs/autumn-seat-licenses.md.

Test plan

  • bun test src/lib/billing in packages/auth: 86 pass, including new tests for the plan cap, the customer override, an undeclared cap, and the refusal messages
  • Typecheck: shared, auth, trpc
  • Biome check
  • Not run end to end. On a Pro v2 org with 5 members: inviting a 6th is refused; accepting an invite created before the cap is refused; moving a 6+ member Team org to Pro is refused in preview and attach

Summary by cubic

Brings plan-level member caps to organizations via Autumn's max_seats metadata. Pro now allows 5 members; Team, Ultra, legacy Pro, and Enterprise are effectively unlimited (2147483647). An org's own max_seats customer metadata overrides its plan's cap, and billing state now exposes the result as seatLimit.

The cap is enforced when adding a member — domain auto-join no longer bypasses it (it still bypasses the free plan's 1-member limit) — when creating an invitation (members plus pending, unexpired invites count), and when buying a plan with a lower cap. The check fails closed: a paid plan without a declared cap refuses new members, and an Autumn outage uses last-known billing state or refuses if none exists. Stripe billing mode and the free plan's 1-member limit are unchanged.

Migration

  • The 11 paid Autumn plans already carry max_seats in live. Any new paid plan needs max_seats set before it's sold.
  • Cached billing state from before this change lacks seatLimit; it's re-read from Autumn rather than treated as a refusal.