Skip to content

test(billing): reproduce exhausted free tier carry-over - #5365

Closed
turip wants to merge 5 commits into
fix/om-588-keep-deliberate-zero-detailed-linesfrom
feat/pr-5361-zero-carryover-reproducer
Closed

turip wants to merge 5 commits into
fix/om-588-keep-deliberate-zero-detailed-linesfrom
feat/pr-5361-zero-carryover-reproducer

Conversation

@turip

@turip turip commented Oct 26, 2026 •

Copy link
Copy Markdown
Member

Adds a deliberately failing regression test against #5361: after the first two progressive invoices account for all free-tier usage, the third rating still emits an empty free-tier detail.

Synthetic example: the first 10 units are free, then usage costs $1/unit.

Invoice Cumulative usage Expected details
1 5 5 units × $0
2 15 5 units × $0, plus 5 units × $1
3 20 5 units × $1 only

The actual third result also contains 0 units × $0 for graduated-tiered-1-price-usage. The cumulative free-tier quantity remains 10, and subtracting the 5 + 5 previously booked units yields an empty delta that is retained by WithDeliberateZeroLinesKept().

The test uses the production delta engine and existing three-phase harness, carrying every prior result forward as billed history. It checks rating output rather than creating persisted invoices. No production behavior is changed.

Validation: the focused test was run during reproduction on parent revision 8f50747cf02b5ed72a06eddc7dd0d969da984152; phases 1 and 2 pass and phase 3 fails on the extra zero-value detail. This draft intentionally preserves that failure.

RetriggerView in GreptileConfidence Score: 5/5

No additional changes are required by this review; the draft's intentionally failing third phase remains as acknowledged.

Summary

Adds a three-phase regression test for exhausted free-tier carry-over. Production behavior is unchanged.

  • The rating test expects only paid usage after the free tier runs out.

Reviews (1) · Last reviewed commit: "test(billing): reproduce exhausted free ..." · Reviewed by Greptile

borosr and others added 5 commits October 26, 2026 15:09
Charge-based delta rating dropped every zero-total detailed line, which
removed free usage and zero-usage tier lines that legacy invoices display.

Subtraction now keeps a current line when the pricer emitted it as a
deliberate zero (zero quantity or zero unit price), on both the current-only
and matched-delta paths. Deliberateness is judged per source line before
aggregation so offsetting corrections never qualify, and the behaviour is
opt-in so correction arithmetic against already billed periods stays silent.

Un-skips the two compatibility tests that preserved the legacy expectations.
…detection

A negative quantity at a zero unit price is a correction, not a pricer-emitted
free usage line. Guard the predicate against it and cover the default matched
delta path that drops a deliberate zero when the option is not passed.
State the non-negative quantity requirement and that an unchanged deliberate
zero is emitted on every run.
The deliberate zero flag describes the current source line, but the matched
delta is a new line. A free usage decrease yields a negative quantity at a
zero unit price, which is a correction and must not be kept.
@coderabbitai

coderabbitai Bot commented Oct 26, 2026

Copy link
Copy Markdown
Contributor

Important

Draft PR not reviewed

Draft PRs are not automatically reviewed by default.

  • Trigger a manual review

To automatically review draft PRs, update your CodeRabbit configuration:

reviews:
  auto_review:
    drafts: true
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@borosr
borosr force-pushed the fix/om-588-keep-deliberate-zero-detailed-lines branch 3 times, most recently from a882689 to 0f1841a Compare October 26, 2026 22:46
@borosr

borosr commented Oct 27, 2026

Copy link
Copy Markdown
Contributor

This is part of the #5361 pr

@borosr borosr closed this Oct 27, 2026
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