honor the operator on credit balance conditions - #32
Merged
Conversation
cbrady
approved these changes
Sep 3, 2026
A credit burndown entitlement is written as an entitling rule with an lt credit condition and a usage-exceeded rule with a gte one, but the engine returned balance >= cost for both, so the exceeded rule could never match. A drained balance fell through to the flag default with no rule_type, which is indistinguishable from a plan that lacks the feature and stays entitled on any flag whose default is true.
ryanechternacht
force-pushed
the
honor-credit-condition-operator
branch
from
September 4, 2026 15:14
0fae2a1 to
7142f16
Compare
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.
When credits run out on a credit burndown entitlement, CheckFlag falls through to the flag default with
rule_type: nulland "No rules matched". The API writes two rules for the entitlement, an entitlingplan_entitlementrule whose credit condition usesltand aplan_entitlement_usage_exceededrule whose condition usesgte, butcheckCreditBalanceConditionignored the operator and evaluatedbalance >= costfor both. The exceeded rule could never match, so a drained balance was indistinguishable from a plan that lacks the feature, and a flag with a true default kept entitling companies with zero credits.The operator now picks the direction of the balance check:
gt/gtematch when the balance does not cover the cost, everything else when it does. Overage still short-circuits to "covered", so the exceeded rule stays quiet when overage is on. A drained balance returnsvalue: falsewithrule_type: plan_entitlement_usage_exceeded, matching numeric entitlements. The API only writes credit conditions throughNumericLimitCondition, which has always usedltfor the entitling rule andgtefor the exceeded rule, so existing rules pick up the fix without a migration.Mirrors the same change to rulesengine-rust in schematichq/schematic-api. The API needs a
go.modbump to the tag cut from this.