Adopt entitlement-first credit resolution + multi-unit preflight#142
Merged
bpapillon merged 2 commits intoJun 22, 2026
Conversation
bpapillon
commented
Jun 21, 2026
c4fb114 to
d2c830c
Compare
Replace the structural credit-condition scan and the reserve-then-cancel round-trip in the lease path with a single entitlement-first probe: read creditId / consumptionRate / eventSubtype straight off the matched plan entitlement (immune to flag-shape drift), and skip lease + reserve entirely when the match isn't credit-metered. Gate the substituted eval with credit_cost (quantity x consumptionRate) for multi-unit preflight. Remove the bespoke getCreditBalance method — the lease-aware remaining/reserved/settled split now rides on the entitlement from a check.
b028d3b to
2fef7e6
Compare
The API now emits a single credit_lease_balance partial on lease acquire/extend (remaining + reserved together) instead of separate credit_balances and credit_reserved messages. This SDK is lease-aware, gates on remaining locally, and derives no settled balance, so apply remaining exactly like the credit_balances partial and ignore reserved. Without this case the new partial would fall through to the silent unknown-key skip and the cached remaining would go stale, since acquire/extend no longer emit a standalone credit_balances message.
schematic-bot
approved these changes
Jun 22, 2026
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.
Adds proper support for preflight requests against credit conditions with a consumption rate. Also, using new datastream fields, we can now simplify our previous lease implementation somewhat and remove some unneeded code (eg custom getCreditBalance method) that was needed to be able to get the Metronome integration working previously.