feat(billing): Add has_remaining_capacity - #384
Merged
Conversation
Allow quota enforcement to detect remaining Engagement unit grant/trial capacity without redefining reserved or PAYG exhaustion flags. Co-authored-by: Cursor <cursoragent@cursor.com>
|
The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).
|
"Free" suggested unpaid usage; the flag tracks leftover Engagement unit grants and trials. Co-authored-by: Cursor <cursoragent@cursor.com>
Expose the credit creation day so getsentry can start mid-period unit grants on date_added instead of the full on-demand window. Co-authored-by: Cursor <cursoragent@cursor.com>
noahsmartin
reviewed
Jul 28, 2026
noahsmartin
reviewed
Jul 28, 2026
Hide grants as an implementation detail of the usage-pricer API. Callers only need a boolean for whether a line item or pool still has capacity to accept usage. Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
There was a problem hiding this comment.
Cursor Bugbot has reviewed your changes and found 1 potential issue.
Bugbot Autofix prepared a fix for the issue found in the latest run.
- ✅ Fixed: Rust proto bindings out of sync
- Removed the date_added field (tag 4) from RecurringCredit Rust bindings to match the proto definition which only defines fields 1-3.
Or push these changes by commenting:
@cursor push 415b80a110
Preview (415b80a110)
diff --git a/rust/src/sentry_protos.billing.v1.services.engagement.v1.rs b/rust/src/sentry_protos.billing.v1.services.engagement.v1.rs
--- a/rust/src/sentry_protos.billing.v1.services.engagement.v1.rs
+++ b/rust/src/sentry_protos.billing.v1.services.engagement.v1.rs
@@ -202,11 +202,6 @@
pub r#type: i32,
#[prost(uint64, tag = "3")]
pub amount: u64,
- /// UTC calendar day the credit row was created. Unit-grant consumers use
- /// max(ondemand_period_start, date_added) so mid-period grants only drain
- /// against usage on/after the grant day (forward headroom).
- #[prost(message, optional, tag = "4")]
- pub date_added: ::core::option::Option<super::super::super::Date>,
}
/// Denomination of a RecurringCredit.
#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash, PartialOrd, Ord, ::prost::Enumeration)]You can send follow-ups to the cloud agent here.
Reviewed by Cursor Bugbot for commit abc020e. Configure here.
noahsmartin
approved these changes
Jul 30, 2026
4 tasks
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
has_remaining_capacityonLineItemUsageSummary(field 8) and a pool-level mirror onSharedLineItemUsageSummary(field 5) so quota enforcement can detect remaining Engagement unit grant capacity without changingreserved_budget_exhausted/payg_budget_exhaustedsemantics.Follow-up: getsentry bumps this package and uses both fields for UsagePricer + ContractBudgetEnforcer +
get_unit_grantswindows (https://github.com/getsentry/getsentry/pull/21233).Test plan