Skip to content

Adopt entitlement-first credit resolution + multi-unit preflight#142

Merged
bpapillon merged 2 commits into
mainfrom
bpapillon/sch-6597-schematic-node-adopt-entitlement-first-credit-resolution
Jun 22, 2026
Merged

Adopt entitlement-first credit resolution + multi-unit preflight#142
bpapillon merged 2 commits into
mainfrom
bpapillon/sch-6597-schematic-node-adopt-entitlement-first-credit-resolution

Conversation

@bpapillon

@bpapillon bpapillon commented Jun 21, 2026

Copy link
Copy Markdown
Contributor

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.

Comment thread src/credits/check.ts
@bpapillon bpapillon force-pushed the bpapillon/sch-6597-schematic-node-adopt-entitlement-first-credit-resolution branch from c4fb114 to d2c830c Compare June 21, 2026 04:10
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.
@bpapillon bpapillon force-pushed the bpapillon/sch-6597-schematic-node-adopt-entitlement-first-credit-resolution branch from b028d3b to 2fef7e6 Compare June 21, 2026 19:48
@bpapillon bpapillon marked this pull request as ready for review June 21, 2026 21:53
@bpapillon bpapillon requested a review from a team as a code owner June 21, 2026 21:53
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.
@bpapillon bpapillon merged commit 20dd168 into main Jun 22, 2026
5 checks passed
@bpapillon bpapillon deleted the bpapillon/sch-6597-schematic-node-adopt-entitlement-first-credit-resolution branch June 22, 2026 18:45
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