Skip to content

Ignore unknown quota values in plan detection#125

Merged
asizikov merged 1 commit into
mainfrom
asizikov/plan-detection
May 22, 2026
Merged

Ignore unknown quota values in plan detection#125
asizikov merged 1 commit into
mainfrom
asizikov/plan-detection

Conversation

@asizikov
Copy link
Copy Markdown
Member

Summary

Some billing report rows can include unknown high quota values such as 2147483647 alongside valid Business or Enterprise quotas. This PR updates plan detection to select the maximum known quota per user so those sentinel-like values do not override valid plan signals.

Changes

Commit Change
fix: ignore unknown quota values in plan detection Adds shared known-quota selection and applies it to included-credit pool sizing and user aggregation so license summaries stay aligned.

Testing

  • npm test -- --run src/pipeline/aicIncludedCredits.test.ts src/pipeline/aggregators/pruAggregation.test.ts src/pipeline/aggregators/aicDiscountAggregation.test.ts
  • npm test -- --run
  • npm run lint
  • npm run build

Checklist

  • Specs lint passes (npm run lint)
  • Tests updated if applicable
  • Documentation updated if applicable

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot AI review requested due to automatic review settings May 22, 2026 12:32
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR adjusts how total_monthly_quota is aggregated per user during plan detection so that sentinel-like “unknown” quota values (e.g. very large integers) don’t override known Business/Enterprise/Pro/Pro+ quotas and thereby skew included-credit pool sizing and license summaries.

Changes:

  • Added a shared “known quota” filter/selector (isKnownMonthlyQuota, selectKnownMonthlyQuota) in the included-credits pipeline utilities.
  • Updated included-credit context generation and UserUsageAggregator quota aggregation to use the selector.
  • Added tests covering sentinel-like quota rows and ensuring user aggregation + license summaries stay aligned.
Show a summary per file
File Description
src/pipeline/aicIncludedCredits.ts Introduces known-quota selection helpers and applies them when aggregating per-user quotas for pool sizing.
src/pipeline/aicIncludedCredits.test.ts Adds unit/integration tests for ignoring unknown-high quotas in pool sizing and keeping aggregations aligned.
src/pipeline/aggregators/userUsageAggregator.ts Updates per-user quota aggregation to prefer the maximum known quota instead of blindly taking the max numeric value.

Copilot's findings

Tip

Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

  • Files reviewed: 3/3 changed files
  • Comments generated: 1

Comment thread src/pipeline/aicIncludedCredits.ts
@asizikov asizikov merged commit 32f3a90 into main May 22, 2026
10 checks passed
@asizikov asizikov deleted the asizikov/plan-detection branch May 22, 2026 13:57
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