Skip to content

fix(aggregator): validate github-billing items at the aggregation boundary (#2493) - #3445

Merged
dezren39 merged 1 commit into
mainfrom
queue/5350-2493-billing-validate
Nov 1, 2026
Merged

dezren39 merged 1 commit into
mainfrom
queue/5350-2493-billing-validate

Conversation

@dezren39

@dezren39 dezren39 commented Nov 1, 2026 •

Copy link
Copy Markdown
Member

Fixes #2493. Queue task 5350 (repo-health-code-pilot, lane D); implementation of triage task 3732's pin.

Change — pm-stack/aggregator/src/sources/github-billing.ts

Validation moves to the aggregation boundary in aggregateBillingUsage; the collector (scripts/collect-github-billing.ts) is unchanged:

  • An item is skipped when its date's first 10 chars are not a real calendar date (validate.ts isIsoDate — the strict primitive isSnapshotRecord already gates on). Impossible dates (month 13, Feb 30) no longer create a day bucket, so no derived record can fail isSnapshotRecord and make the collector discard the whole month.
  • quantity / grossAmount / netAmount contribute only when finite and >= 0 (validate.ts isNonNegative), otherwise 0 — extending the existing non-number fallback. Negative or non-finite values are never summed into a day aggregate and never stored as usage.

Tests — test/github-billing.test.ts (+3)

  • Impossible dates never create a day bucket (valid sibling day unaffected).
  • Negative / NaN / Infinity quantity and amounts contribute 0.
  • Records derived from hostile items all pass isSnapshotRecord and are positive.

Laptop (worktree): bun test test/github-billing.test.ts — 10/10 pass. Full aggregator suite on this branch: 227 pass / 37 fail, but the failures are pre-existing — verified against clean main (efe3875) in a scratch worktree: test/quota-current.test.ts fails identically there (1 fail, feed.ts:358 Unexpected export), and the remaining failures are 5s hook timeouts under laptop load ~100. None are in the touched file or its dependents.

Acceptance: no billing item can make the collector discard a month; impossible dates never bucket; negative/non-finite never stored or summed; well-formed months aggregate exactly as before (existing tests unchanged and passing).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need.

#2493)

aggregateBillingUsage now skips items whose date (first 10 chars) is not a real calendar date (validate.ts isIsoDate), and quantity/grossAmount/netAmount contribute only when finite and non-negative (isNonNegative), otherwise 0. An impossible date previously derived records failing isSnapshotRecord, making the collector discard the whole month; negative amounts passed validation and were stored as usage. Regression tests cover both plus hostile-item records all passing isSnapshotRecord.
@dezren39
dezren39 requested a review from a team as a code owner November 1, 2026 09:19
@coderabbitai

coderabbitai Bot commented Nov 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 26 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used the included review currently available.

Learn how review limits work.

Review configuration:

Run configuration
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: defaults
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: 12e02baf-520d-462a-a835-7d6c7db02e9f
Commits

Reviewing files that changed from the base of the PR and between 98a4eb8 and 10663de.

Files selected for processing: 2
  • pm-stack/aggregator/src/sources/github-billing.ts
  • pm-stack/aggregator/test/github-billing.test.ts
  • 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

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 1, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-01T09:21:12.203538Z 10663de PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

1 participant