Workspace, License, and CreditEvent describe required commercial behavior; they do not prescribe database table names.
Canonical entities
Workspace
The workspace is the top-level billing and administrative container. All plans, products, licenses, and credits belong to a workspace.Plan
A plan defines the commercial terms for a workspace. Plans are identified by aPlanKey.
Product
A product is a digital experience operated for end users. A product isactive once it has a live domain, backend, or app store release. A product that is in development but not yet released is a draft.
activatedAt is set. A product that is archived has archivedAt set and its slot is freed for a new product.
License
A license is a named entitlement tied to one human identity.userId must reference a single human identity. The implementation must deter shared-login exploitation through identity, device, concurrency, and audit controls.
AI Credit Ledger
The credit ledger records consumption, allocation, rollover, and top-up events.Entitlement fields
The canonical source of truth for workspace entitlements is the workspace record. Do not compute entitlements from plan metadata at the client side; always query the server-side workspace record.Per-plan entitlement matrix
Active product count
The number of active products is the count of products in the workspace wherestatus = 'active'. Draft products do not count. Archived products do not count.
activeProductCount exceeds maxActiveProducts, no new products can be activated. Existing active products are not affected.
Credit consumption
Credit consumption is measured per model call. The credit cost depends on the active model tier, task type, context, and modality according to the server-side rate card. Exact rates are internal and may change as provider pricing and routing evolve. The credit ledger is debited on call completion, not on call start. If a call fails, no credits are consumed.Credit exhaustion
When the credit balance reaches zero:- New AI build requests return
INSUFFICIENT_CREDITS. - Existing in-progress builds continue to completion.
- Products already running in production are not affected.
- Admins receive a notification.
- Admins can approve a top-up.
Credit rollover
On paid plans, at the end of each billing cycle, the remaining included-credit balance rolls into the next cycle up to a maximum of one cycle’s allocation. Hobby credits expire at renewal. Enterprise rollover behavior is contractual.Annual billing formula
Annual billing is priced at 10 times the monthly price and charged once per year. The displayed monthly equivalent is rounded to the nearest dollar.annualTotal. The displayed figure is for marketing purposes only.
License enforcement
When a license is assigned to a user, the platform recordsuserId on the license. All API calls and UI actions are checked against the user’s license role.
Reassignment
Reassignment is logged as areassigned event on the old license and a new assigned event on the new license. There is a cooldown between reassignments on the same license slot.
Concurrent reassignments are prevented by a lock on the license record during the reassignment transaction.
Concurrency enforcement
Concurrency limits how many agents can run simultaneously for a workspace.Channel entitlements
Channel entitlements are checked against the workspace plan and the product configuration.Agency white-label gates
White-label is a workspace-level entitlement. WhenwhiteLabel = true, the workspace can serve client-facing surfaces (previews, reports, client portal) under the agency’s branding.
Product lifecycle events
Lineage
Lineage is an immutable identifier assigned to a product at creation. It survives fork, clone, new repository, new domain, and workspace transfer. Lineage is used to prevent duplicate billing when a product is reconstructed from its history.Migration and versioning
When a workspace changes plans:- Preserve product history, identities, audit events, and the credit ledger.
- Apply the effective date and any proration or true-up shown at checkout or defined in the executed order.
- Do not silently archive products or remove a live entitlement.
- Before a downgrade, validate product, license, channel, and concurrency usage against the destination plan. Require remediation or an alternative plan when the workspace exceeds the destination allowance.
- Record both the previous and resulting entitlement snapshots for billing support and rollback.
Analytics and audit
The following events are required to be logged and queryable:license.assigned: userId, role, timestamplicense.released: userId, role, timestamplicense.reassigned: fromUserId, toUserId, role, timestampproduct.activated: productId, timestampproduct.archived: productId, timestampproduct.transferred: productId, fromWorkspaceId, toWorkspaceId, timestampcredit.consumption: workspaceId, amount, productId, userId, timestampcredit.topup: workspaceId, amount, adminUserId, timestampcredit.rollover: workspaceId, amount, timestampcredit.expiry: workspaceId, amount, timestampbilling.cycle: workspaceId, amount, cycleStart, cycleEnd, timestamp
Implementation acceptance checklist
Before shipping a billing or entitlement feature, verify:- Credit deduction is recorded atomically with the call completion, not on start
- Insufficient credit returns
INSUFFICIENT_CREDITSand does not silently allow overage (unless overage is explicitly configured) - Product activation is gated against
maxActiveProductsand returns a clear error - Archive frees the product slot immediately
- Reactivation reclaims the slot
- License role checks happen server-side on every action
- Concurrent reassignments are prevented by database-level locking
- Concurrency limit is enforced across all products and users in a workspace
- Annual billing charges exactly 10 times the monthly price at renewal
- Displayed monthly equivalent is
Math.round(monthly * 10 / 12) - Paid license additions are prorated for the remaining term, charged immediately on monthly billing and recorded for annual true-up on annual billing
- Paid license removals take effect at renewal
- Channel add-ons are per-product, not per-workspace
- White-label check is workspace-level, not per-product
- All billing events are logged with timestamp, amount, and actor
- Paid-plan included-credit rollover clears expired credits and rolls over no more than one cycle’s allocation
- Lineage is immutable and preserved across fork, clone, transfer, and new repository
- No new pricing page or nav description contains stale plan names or numbers