Skip to content

feat(billing): Define BillingAlert protos - #462

Merged
brendanhsentry merged 19 commits into
mainfrom
codex/feat/platform-spend-notification-event-v2
Oct 9, 2026
Merged

brendanhsentry merged 19 commits into
mainfrom
codex/feat/platform-spend-notification-event-v2

Conversation

@brendanhsentry

@brendanhsentry brendanhsentry commented Oct 8, 2026 •

Copy link
Copy Markdown
Member

Defines the BillingAlert service contract and its get, upsert, and claim requests. BillingAlertConfig names the percentage unit explicitly as threshold_percent and supports reserved or PAYG budgets over specific line items or all items.

Also adds BillingAlertEvaluationRequested, published from the quota task so a downstream handler can fetch usage, evaluate BillingAlerts, and deliver notifications.

Refs REVENG-611

Expose quota pricing output and publish it through an organization usage-evaluated event so spend notifications can evaluate the same result.

Refs REVENG-611
@linear-code

linear-code Bot commented Oct 8, 2026

Copy link
Copy Markdown

REVENG-611

@github-actions

github-actions Bot commented Oct 8, 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✅ passedOct 9, 2026, 6:41 PM

Represent each finite contract budget with an explicit metric, target, unit, used value, and effective limit. Pass those normalized summaries through quota enforcement and the usage-evaluated event instead of exposing the raw pricing response.

Refs REVENG-611
@brendanhsentry brendanhsentry changed the title feat(billing): Add usage evaluation event feat(billing): Add normalized budget usage evaluation Oct 8, 2026
Return only quota configs from contract budget evaluation; usage notification events are emitted where pricing is computed.

Refs REVENG-611
Replace the generic expression tree with an explicit budget kind and line-item scope. Reserved and PAYG percentages can now be derived from the existing rate card, contract caps, and usage pricer response.

Refs REVENG-611
@brendanhsentry brendanhsentry changed the title feat(billing): Add normalized budget usage evaluation feat(billing): Define spend notification contracts Oct 9, 2026
Define the line-item UID wrapper in the spend notification package instead of coupling the config to the contract-v1 parameter schema.

Refs REVENG-611
Clarify that reserved versus PAYG selects the budget type, while the oneof selects the line-item target.

Refs REVENG-611
@brendanhsentry brendanhsentry changed the title feat(billing): Define spend notification contracts feat(billing): Define spend notification protos Oct 9, 2026
brendanhsentry and others added 4 commits October 9, 2026 10:31
Replace the priced-usage event with an empty request event scoped by organization metadata.

Refs REVENG-611
@brendanhsentry
brendanhsentry marked this pull request as ready for review October 9, 2026 17:55
@brendanhsentry
brendanhsentry requested a review from a team as a code owner October 9, 2026 17:55

message ClaimSpendNotificationResponse {
bool claimed = 1;
uint64 claim_id = 2;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

what is this id for?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

good catch. i used it for something at first, but we don't need it anymore

Comment on lines +18 to +23
message SpendNotification {
uint64 id = 1;
uint64 organization_id = 2;
SpendNotificationConfig config = 3;
bool is_enabled = 4;
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

This PR is a little confusing linguistically. When I imagine a "Notification" I am thinking of a message that goes to a recipient. However I'm looking at this struct and not seeing a message payload, but it does have a configuration. I would recommend some clarification in the naming

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

I renamed it to BillingAlert


// Configuration persisted as JSON by the spend notification data service.
message SpendNotificationConfig {
uint32 threshold = 1;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

questions:

  1. why a 32 bit int?
  2. what is this threshold measured in? It's not clear from the code

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

It's supposed to be a percent. I renamed the field to threshold_percent.

brendanhsentry and others added 4 commits October 9, 2026 11:21
Require contract context and remove the unused enabled-state filter from the request.

Refs REVENG-611
Use billing alert terminology for the service contract, evaluation event, and generated Rust bindings.

Refs REVENG-611
Expose the alert threshold as a whole-number percentage in the proto contract.

Refs REVENG-611
@brendanhsentry brendanhsentry changed the title feat(billing): Define spend notification protos feat(billing): Define BillingAlert protos Oct 9, 2026
@brendanhsentry
brendanhsentry merged commit b72a103 into main Oct 9, 2026
17 checks passed
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.

2 participants