Skip to content

feat(tenancy): let reseller owners create root-tenant workspaces and pool their quota - #1732

Merged
realcodesiman merged 3 commits into
mainfrom
feat/reseller-owner-root-workspaces-pool
Nov 17, 2026
Merged

realcodesiman merged 3 commits into
mainfrom
feat/reseller-owner-root-workspaces-pool

Conversation

@realcodesiman

Copy link
Copy Markdown
Contributor

Summary

  • A reseller owner now chooses their tenant or root when creating a workspace, based on the server-resolved request host (resolveRequestTenantId). It is never taken from client input. With no request context (workers, scripts) the owner-derived tenant is kept.
  • The owner's quota pool now covers their tenant plus the root-tenant workspaces they own (poolWorkspaceScope). Reconcile and MAC sums use the same scope.
  • A sub-account can't be created with its tenant owner's email (tenantOwnerEmailReserved, 409), enforced in provisionResellerAccount and the better-auth user.create.before hook.
  • Tenant suspend/downgrade only tears down the tenant's own workspaces. The owner's root workspaces keep running.
  • Docs updated: docs/tenancy.md, invariants 10 and 12, and the generated mirrors.

Test plan

  • pnpm lint
  • pnpm check-types
  • Reseller owner creates a workspace on a custom domain: gets the tenant. On the platform host: gets root.
  • Quota reconcile counts root workspaces owned by a reseller owner.
  • Provisioning a sub-account with the tenant owner's email returns 409.

…pool their quota

A reseller owner now picks their tenant or root by the server-resolved request host when creating a workspace. Quota reconcile covers the owner's pool (tenant plus owned root workspaces), and a tenant owner's email can't be reused for a sub-account.
@github-actions github-actions Bot added the feature New feature or request label Nov 17, 2026
Reuse an existing first/empty workspace only when it belongs to the tenant
the request targets, hide workspaces of other tenants on a host, and share
one owner-tenancy read between the tenant resolvers. Pool-scope helper
counts a reseller's tenant workspaces plus the root ones they own.
@realcodesiman
realcodesiman merged commit f42866f into main Nov 17, 2026
14 checks passed
@realcodesiman
realcodesiman deleted the feat/reseller-owner-root-workspaces-pool branch November 17, 2026 14:33
hello-jackytruong referenced this pull request in hello-jackytruong/ChatWorkAI Nov 22, 2026
…pool their quota (#1732)

* feat(tenancy): let reseller owners create root-tenant workspaces and pool their quota

A reseller owner now picks their tenant or root by the server-resolved request host when creating a workspace. Quota reconcile covers the owner's pool (tenant plus owned root workspaces), and a tenant owner's email can't be reused for a sub-account.

* fix(tenancy): scope reseller owner workspaces to the request host tenant

Reuse an existing first/empty workspace only when it belongs to the tenant
the request targets, hide workspaces of other tenants on a host, and share
one owner-tenancy read between the tenant resolvers. Pool-scope helper
counts a reseller's tenant workspaces plus the root ones they own.

* test(auth): mock userService.findEmailCached in tenant-owner-email test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant