Skip to content

feat: start trials from platform admin invites - #5920

Merged
alx-xo merged 4 commits into
mainfrom
GRW-62-admin-invite-trial
Sep 1, 2026
Merged

feat: start trials from platform admin invites#5920
alx-xo merged 4 commits into
mainfrom
GRW-62-admin-invite-trial

Conversation

@alx-xo

@alx-xo alx-xo commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Linear: GRW-62

Summary

  • Start the existing 14-day Enterprise trial when an organization's first user accepts an invitation sent by a current platform admin.
  • Keep local membership, role, entitlements, trial lifecycle, audit operation, and invitation acceptance atomic while serializing concurrent acceptances.
  • Refresh cached trial entitlements after commit and reconcile the accepted invitation role into WorkOS without making external failures roll back local acceptance.

Motivation

Organizations created and configured by platform admins previously missed the self-serve Enterprise trial lifecycle when their first customer joined. This reuses the established trial provisioning and lifecycle behavior while preserving whitelist settings, existing trial history, self-signup, and ordinary invitation behavior.


Summary by cubic

Starts the existing 14-day Enterprise trial when an organization's first user accepts an invite sent by a current platform admin. Organizations created by platform admins previously skipped the trial lifecycle; now the first customer to accept an invite gets the same self-serve Enterprise trial as signup.

  • Makes membership, role assignment, entitlements, trial lifecycle, audit entry, and invitation acceptance atomic and serializes concurrent acceptances.
  • Refreshes cached trial entitlements after commit.
  • Reconciles the accepted invitation role into WorkOS without rolling back local acceptance when external calls fail, and preserves any existing WorkOS roles on the membership.

Written for commit 76c1e02. Summary will update on new commits.

Review in cubic

@alx-xo
alx-xo requested a review from a team as a code owner September 1, 2026 00:01
@alx-xo alx-xo added enhancement New feature or request go Pull requests that update go code linear labels Sep 1, 2026
@linear-code

linear-code Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

GRW-62

@changeset-bot

changeset-bot Bot commented Sep 1, 2026

Copy link
Copy Markdown

⚠️ No Changeset found

Latest commit: 76c1e02

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

Running ultrareview automatically — This PR reworks invitation acceptance to arm enterprise trials atomically with row locks, serialized concurrency, and external WorkOS reconciliation—any subtle bug could corrupt trial lifecycle, membership, or audit data, so a deep multi-pass review is warranted.. I'll post findings when complete.

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

atlas migrate lint on server/migrations

Status Step Result
No migration files detected  
ERD and visual diff generated View Visualization
No issues found View Report
Read the full linting report on Atlas Cloud

@github-actions

github-actions Bot commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

atlas migrate lint on server/clickhouse/migrations

Status Step Result
No migration files detected  
ERD and visual diff generated View Visualization
No issues found View Report
Read the full linting report on Atlas Cloud

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ultrareview completed in 9m 13s

All reported issues were addressed across 12 files

Linked issue analysis

Linked issue: GRW-62: feat: start enterprise trial when first platform-admin invite is accepted

Status Acceptance criteria Notes
A first user accepting an organization invitation sent by a current platform admin starts an active 14-day Enterprise trial. The acceptance transaction detects a platform-admin inviter and first-user condition, arms the Enterprise trial, and the integration test verifies tier and 14-day duration.
The new membership, role assignments, entitlements, trial lifecycle, audit record, and invitation acceptance are atomic and concurrent first acceptances produce one trial. Acceptance locks the organization, performs local provisioning and trial arming in one transaction, and tests verify rollback on bundle failure plus serialized concurrent acceptance.
The invited first user retains the invitation's organization-admin role and role synchronization is preserved. The invitation role is persisted and synchronized transactionally, then reconciled with WorkOS after commit; tests verify the authoritative role and existing-membership reconciliation.
The organization's configured whitelist value and existing trial lifecycle remain unchanged where applicable. Trial arming updates account type without changing whitelist state, and the tests verify whitelist preservation and no changes to an existing lifecycle.
The successful first-user flow triggers the existing trial lifecycle messaging and PostHog onboarding event with created_via set to platform_admin_invite. Post-commit TrialStarted and PostHog capture/identify calls are implemented, with failures logged without rolling back acceptance; the test verifies the event shape and notification behavior.
Later invitations, ordinary organization invitations, existing trial records, and deleted/non-platform-admin inviters do not incorrectly start a new trial. Eligibility requires no other active users, a non-deleted platform-admin inviter, and no existing lifecycle; dedicated tests cover ordinary invites, existing lifecycles, and deleted inviters.

Reply with feedback, questions, or to request a fix.

Fix all with cubic | Re-trigger cubic

Comment thread server/internal/organizations/impl.go Outdated
@alx-xo
alx-xo force-pushed the GRW-62-admin-invite-trial branch from 706f8ef to 9f0317d Compare September 1, 2026 16:06
Refresh cached trial entitlements after commit and use the accepted invitation role for local and WorkOS membership reconciliation.
@alx-xo
alx-xo force-pushed the GRW-62-admin-invite-trial branch from 9f0317d to 76c1e02 Compare September 1, 2026 16:15
@alx-xo
alx-xo added this pull request to the merge queue Sep 1, 2026
Merged via the queue into main with commit d49b0d1 Sep 1, 2026
45 checks passed
@alx-xo
alx-xo deleted the GRW-62-admin-invite-trial branch September 1, 2026 18:25
@github-actions github-actions Bot locked and limited conversation to collaborators Sep 1, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

enhancement New feature or request go Pull requests that update go code linear

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants