feat(governance): external workspace users from outside org#4313
feat(governance): external workspace users from outside org#4313icecrasher321 merged 10 commits intostagingfrom
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
PR SummaryHigh Risk Overview Reworks workspace invitations to a server-side Updates org roster and seat/billing calculations to exclude external invites from seat occupancy while still listing external workspace-access holders, adds removal support for external members (revoking workspace permissions, permission-group membership, and credential memberships), and introduces optional post-removal seat reduction with a new Stripe outbox handler to sync subscription seat quantities. Reviewed by Cursor Bugbot for commit 774caa1. Configure here. |
Greptile SummaryThis PR introduces external workspace members: existing Sim users who already belong to another organisation can be invited to a workspace without joining the host org, consuming a seat, or appearing in the org roster. The core changes are a new Confidence Score: 5/5Safe to merge; all P2 findings are low-probability edge cases or clarity improvements with no data-integrity risk. All findings are P2. The seat-exclusion logic is correctly guarded by the NOT NULL migration default; transfer-ownership correctly filters externals; the invite/accept/remove paths are logically sound. The one status-code mismatch (500 vs 409 on a race-condition guard) and the archived-workspace inconsistency are minor operational concerns that do not affect correctness under normal usage. apps/sim/app/api/organizations/[id]/members/[memberId]/route.ts — status-code mapping for the external-removal guard; apps/sim/lib/billing/organizations/membership.ts — archived workspace filter inconsistency. Important Files Changed
Sequence DiagramsequenceDiagram
participant Admin
participant InviteAPI as POST /workspaces/invitations
participant DB
participant Email
participant Invitee
Admin->>InviteAPI: invite email, workspaceId, permission
InviteAPI->>DB: lookup existingUser by email
alt User exists & in a different org
InviteAPI->>DB: getUserOrganization(existingUser.id)
DB-->>InviteAPI: existingOrgId != invitePolicy.organizationId
Note over InviteAPI: membershipIntent = 'external'<br/>skip seat validation
else User exists, no org
InviteAPI->>DB: validateSeatAvailability
Note over InviteAPI: membershipIntent = 'internal'
else User does not exist
InviteAPI->>DB: validateSeatAvailability
Note over InviteAPI: membershipIntent = 'internal'
end
InviteAPI->>DB: createPendingInvitation(membershipIntent)
InviteAPI->>Email: sendInvitationEmail
Email-->>Invitee: invitation link
Invitee->>DB: acceptInvitation(token)
alt membershipIntent = 'external'
Note over DB: skip ensureUserInOrganization<br/>skip setActiveOrg<br/>grant workspace permissions only
else membershipIntent = 'internal'
DB->>DB: ensureUserInOrganization (seat consumed)
DB->>DB: grant workspace permissions
DB->>DB: setActiveOrganization
end
DB-->>Invitee: redirect to workspace
Admin->>DB: DELETE /organizations/:id/members/:userId
DB->>DB: check targetMember in org
alt is org member
DB->>DB: removeUserFromOrganization (full billing logic)
else is external (no org-member row)
DB->>DB: removeExternalUserFromOrganizationWorkspaces
end
Reviews (2): Last reviewed commit: "edge case improvements" | Re-trigger Greptile |
|
bugbot run |
|
@greptile |
|
bugbot run |
|
bugbot run |
|
bugbot run |
|
bugbot run |
|
bugbot run |
There was a problem hiding this comment.
✅ Bugbot reviewed your changes and found no new issues!
Comment @cursor review or bugbot run to trigger another review on this PR
Reviewed by Cursor Bugbot for commit 4b0b362. Configure here.
|
bugbot run |
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.
Reviewed by Cursor Bugbot for commit 774caa1. Configure here.

Summary
External Workspace Users allowed if they already belong to another org. Do not count against your own org seat count. Clearly tagged as external.
Type of Change
Testing
Tested manually
Checklist