Skip to content

feat(api): enforce time-based subscription entitlement - #28

Merged
iamparmjeet merged 4 commits into
mainfrom
feat/subscription-entitlement
Sep 19, 2026
Merged

iamparmjeet merged 4 commits into
mainfrom
feat/subscription-entitlement

Conversation

@iamparmjeet

Copy link
Copy Markdown
Owner

Summary

Time-based subscription entitlement. Migration 0045_subscription_entitlement
(hand-authored, function-only, no schema drift) replaces
rently_assert_tenant_seat and rently_assert_pending_invite_quota so the plan
limit is entitlement-gated. Stacked base for the cancel and correction slices.
Rollback tag pre-subscription-entitlement.

  • Entitlement is time-based, not status-based: the latest subscription grants
    its plan limit while expired is not true and current_period_end is null or
    in the future.
  • A lapsed subscription yields limit 0; an owner with no subscription row keeps
    the legacy TENANT_LIMIT fallback.
  • getOwnerEntitlement in tenant-limit.ts mirrors the SQL predicates
    (compared in SQL against now() at time zone 'utc', since
    current_period_end is a zone-less UTC-wall-clock timestamp).
  • tenantPlanLimitError / pendingInviteQuotaError now report "subscription has
    ended" instead of "plan limit of 0".
  • Cancelled-with-future-end stays entitled; paused inside a paid period stays
    entitled; expired = true denies even mid-period.

Design record: docs/Decisions.md 2026-09-17 — "Time-based subscription
entitlement and cancel-at-period-end".

Verification

  • bun run db:generate — no drift
  • bun run check-types --force — 6/6
  • Focused Biome
  • bun run db:migrate:test
  • subscription-entitlement.test.ts (10) + invite suite 25/25
  • bun run build:admin

Behavior change (open design item)

A lapsed owner gets limit 0 and cannot add tenants or send invites. Existing
tenants and owner access are unaffected — only growth is frozen.

Owner wants a grace period where growth stays frozen but the account keeps a
limited feature set, rather than a hard cut at current_period_end. That is a
design decision, not part of this slice: it needs a grace window length, the
concrete limited-feature list, and (if the window defers the growth freeze) a
change to both SQL functions and getOwnerEntitlement together. Land it as a
follow-up slice on this branch, or amend before merge.

Not included

  • No UI/status label. Growth freeze is enforced at the SQL arbiters.
  • No grace period / limited feature set yet — see above.

@iamparmjeet
iamparmjeet force-pushed the feat/subscription-entitlement branch from b12980c to a08f000 Compare September 19, 2026 16:39
@vercel

vercel Bot commented Sep 19, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

4 Skipped Deployments
Project Deployment Actions Updated
rently-admin Ignored Ignored Sep 19, 2026 4:39pm UTC
rently-dashboard Ignored Ignored Sep 19, 2026 4:39pm UTC
rently-tenant Ignored Ignored Sep 19, 2026 4:39pm UTC
rently-web Ignored Ignored Sep 19, 2026 4:39pm UTC

@iamparmjeet
iamparmjeet merged commit f75e5bc into main Sep 19, 2026
7 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant