Conversation
Run smaller license transitions synchronously and preserve explicit carry-over semantics across retained and pooled entitlements. Co-authored-by: Cursor <cursoragent@cursor.com>
Unused assignment CPs should receive add/replace/delete, and migration item replaces must keep carrying usage after the default-reset change. Co-authored-by: Cursor <cursoragent@cursor.com>
Prevent historical refunds from reducing multiple replacement charges when reconstructing prorated invoice credits. Co-authored-by: Cursor <cursoragent@cursor.com>
fix(billing): allocate stored refunds to one charge
|
The latest updates on your projects. Learn more about Vercel for GitHub. 2 Skipped Deployments
|
Comment on lines
+24
to
+34
| const customerEntityCount = hasTransitions | ||
| ? await countEntitiesByInternalCustomerId({ | ||
| db: ctx.db, | ||
| internalCustomerId: | ||
| customerLicenseTransitions![0].incomingCustomerLicense | ||
| .internal_customer_id, | ||
| cap: SYNC_BATCH_TRANSITION_MAX_ENTITIES, | ||
| }) | ||
| : 0; | ||
| const runSynchronously = | ||
| customerEntityCount < SYNC_BATCH_TRANSITION_MAX_ENTITIES; |
Contributor
There was a problem hiding this comment.
Entity count underestimates transition size
If a customer has fewer than 1,000 live entities but many unused license seats, this count runs the transition synchronously even though the batch queries now process all license-linked seat products. For example, 10 entities and 50,000 unused seats execute the large entitlement mutation inside the billing request, where a timed-out batch can fail the plan change after license state updates have started.
Knowledge Base Used: Billing lifecycle and payment flows
Prompt To Fix With AI
This is a comment left during a code review.
Path: server/src/internal/billing/v2/execute/executeAutumnActions/executeCustomerLicenseTransitions.ts
Line: 24-34
Comment:
**Entity count underestimates transition size**
If a customer has fewer than 1,000 live entities but many unused license seats, this count runs the transition synchronously even though the batch queries now process all license-linked seat products. For example, 10 entities and 50,000 unused seats execute the large entitlement mutation inside the billing request, where a timed-out batch can fail the plan change after license state updates have started.
**Knowledge Base Used:** [Billing lifecycle and payment flows](https://app.greptile.com/autumn-org-2/-/custom-context/knowledge-base/useautumn/autumn/-/docs/billing-lifecycle.md)
---
For each issue above, determine whether it is valid and should be fixed. If so, fix it directly.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
carryOverUsagesis enabled (or allocated /carry_from_previous). Migration replace pages pin carry-over so a 100→200 grant with 60 consumed increments by +100 instead of SET 200.internal_entity_id; unused seats participate in add/replace/delete transitions.No new database migrations in this release.
maincurrently has theaisubmodule bump (#9491faab) not yet ondev; this merge brings both sides together.Test plan
Made with Cursor
Summary by cubic
Fixes three license billing bugs: entitlement usage now resets on plan transitions unless carry-over is opted in, unused assignment seats participate in batch operations, and prorated refunds are no longer double-counted across sequential quantity updates.
License transitions
carry_from_previous, andcarry_over_usages; everything else resets to the incoming grant.internal_entity_id) are included in add/replace/delete operations.Invoice refunds
No new database migrations in this release. Merges
mainintodev, bringing theaisubmodule bump.Written for commit b561e78. Summary will update on new commits.
Greptile Summary
This release changes license usage transitions, brings unused seats into entitlement updates, and assigns stored invoice refunds to one historical charge.
Confidence Score: 4/5
The synchronous license-transition threshold should be corrected before merging because customers with few entities but many unused seats can execute a very large transition inside the billing request.
The new threshold measures entity records, while the changed batch queries process assigned and unused seat customer products; this mismatch can route large entitlement mutations through the synchronous request path and cause the plan change to time out after state updates have started.
Files Needing Attention: server/src/internal/billing/v2/execute/executeAutumnActions/executeCustomerLicenseTransitions.ts
Important Files Changed
Flowchart
%%{init: {'theme': 'neutral'}}%% flowchart TD A[License plan transition] --> B[Count live entities] B -->|Below 1,000| C[Run transition in billing request] B -->|1,000 or more| D[Queue transition] C --> E[Update assigned and unused seats] D --> E E --> F[Replace, add, or delete entitlements]Prompt To Fix All With AI
Reviews (1): Last reviewed commit: "Merge branch 'main' into dev" | Re-trigger Greptile
Context used: