Skip to content

feat(billing): Add has_remaining_capacity - #384

Merged
armenzg merged 10 commits into
mainfrom
feat/has-remaining-free-capacity
Jul 30, 2026
Merged

feat(billing): Add has_remaining_capacity#384
armenzg merged 10 commits into
mainfrom
feat/has-remaining-free-capacity

Conversation

@armenzg

@armenzg armenzg commented Jul 27, 2026

Copy link
Copy Markdown
Member

Summary

  • Adds has_remaining_capacity on LineItemUsageSummary (field 8) and a pool-level mirror on SharedLineItemUsageSummary (field 5) so quota enforcement can detect remaining Engagement unit grant capacity without changing reserved_budget_exhausted / payg_budget_exhausted semantics.

Follow-up: getsentry bumps this package and uses both fields for UsagePricer + ContractBudgetEnforcer + get_unit_grants windows (https://github.com/getsentry/getsentry/pull/21233).

Test plan

  • Buf lint / format / breaking checks
  • getsentry consumes regenerated bindings and exercises mid-period grant windows

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>
@github-actions

github-actions Bot commented Jul 27, 2026

Copy link
Copy Markdown

The latest Buf updates on your PR. Results from workflow ci / buf-checks (pull_request).

BuildFormatLintBreakingUpdated (UTC)
✅ passed✅ passed✅ passed✅ passedJul 30, 2026, 1:02 PM

getsantry Bot and others added 2 commits July 27, 2026 18:38
"Free" suggested unpaid usage; the flag tracks leftover Engagement unit grants and trials.

Co-authored-by: Cursor <cursoragent@cursor.com>
@armenzg armenzg changed the title feat(billing): Add has_remaining_free_capacity to usage pricer summaries feat(billing): Add has_remaining_granted_capacity to usage pricer summaries Jul 28, 2026
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>
@armenzg armenzg changed the title feat(billing): Add has_remaining_granted_capacity to usage pricer summaries feat(billing): Add has_remaining_granted_capacity + RecurringCredit.date_added Jul 28, 2026
@armenzg armenzg self-assigned this Jul 28, 2026
Comment thread proto/sentry_protos/billing/v1/services/engagement/v1/recurring_credit.proto Outdated
armenzg and others added 3 commits July 28, 2026 17:31
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>
@armenzg armenzg changed the title feat(billing): Add has_remaining_granted_capacity + RecurringCredit.date_added feat(billing): Add has_remaining_capacity Jul 30, 2026

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes and found 1 potential issue.

Fix All in Cursor

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.

Create PR

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.

Comment thread rust/src/sentry_protos.billing.v1.services.engagement.v1.rs Outdated
@armenzg
armenzg marked this pull request as ready for review July 30, 2026 13:02
@armenzg
armenzg requested a review from a team as a code owner July 30, 2026 13:02
@armenzg
armenzg merged commit 7ad04a6 into main Jul 30, 2026
17 checks passed
@armenzg
armenzg deleted the feat/has-remaining-free-capacity branch July 30, 2026 15:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants