Skip to content

fix(aggregator): validate quota-current windows - #4182

Merged
dezren39 merged 2 commits into
mainfrom
queue/5318-2416-quota-windows
Nov 2, 2026
Merged

dezren39 merged 2 commits into
mainfrom
queue/5318-2416-quota-windows

Conversation

@dezren39

@dezren39 dezren39 commented Nov 2, 2026 •

Copy link
Copy Markdown
Member

Fixes #2416

Summary

parseQuotaCurrent
  keep valid providers
  drop malformed providers/windows and record counts
  overlay only validated window fields
live quota provenance
  report dropped entry counts

Evidence

  • Before: windows: [null] passed parsing and threw during overlay; malformed name / resetsAt values also reached quota windows (reproduced in the issue triage).
  • After: bun test test/quota-current.test.ts — 31 pass, 0 fail; regression keeps valid overlays for multiple providers while dropping malformed entries.
  • bun run typecheck could not run to completion: TypeScript reports missing type definitions for bun (TS2688).

Merge Danger

Door: Two-way — the parser change can be reverted.

Blast Radius: Low — quota-current ingest and its live provenance only.


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

@dezren39
dezren39 requested a review from a team as a code owner November 2, 2026 05:02
@coderabbitai

coderabbitai Bot commented Nov 2, 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 7 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: 7d3ef589-3faf-41df-b6bc-f5d628afa75c
Commits

Reviewing files that changed from the base of the PR and between 3f06639 and 6aee703.

Files selected for processing: 4
  • pm-stack/aggregator/src/model.ts
  • pm-stack/aggregator/src/quota-current.ts
  • pm-stack/aggregator/src/sources/live.ts
  • pm-stack/aggregator/test/quota-current.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 2, 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-02T07:32:25.788645Z 6aee703 Manual request
ℹ️ 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.

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: 531992d517

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

Comment on lines +90 to +92
const windows = arrayOf(isQuotaCurrentWindow)(provider.windows)!;
droppedWindows += windows.dropped;
return { ...provider, windows: windows.values };

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Downgrade providers whose windows are entirely discarded

When a fresh ok provider has only malformed windows, sanitization leaves it as an ok entry with an empty window list. overlayQuotaCurrent still selects it as the newest fresh entry, and applyEntry stamps the pool's existing dated windows with fresh ok provenance without replacing them. It also prevents an older valid fresh credential for the same service from supplying the headline windows. For example, a newest entry with windows: [null] and a valid sibling reporting 80% leaves the base pool's 11% displayed as freshly measured. Distinguish an entry emptied by validation from a legitimate balance-only read, and drop or downgrade the malformed entry so it cannot claim freshness or suppress a valid overlay.

Useful? React with 👍 / 👎.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Fixed in 6aee703. parseQuotaCurrent now downgrades an "ok" entry whose windows were entirely dropped by sanitization to state "error" (error: "all quota windows were malformed and dropped at ingest"), so it can no longer win fresh-ok precedence, stamp the pool's dated windows with fresh provenance, or block a valid fresh sibling. Entries that arrived windowless (balance-only reads) keep their state. Regression tests added in quota-current.test.ts: the sibling case (valid 80% read supplies the headline, freshness measuredAt from the sibling) and the sole-entry case (pool surfaces error, base windows keep their dated 11%).

…dropped (#2416)

Codex P2 on PR #4182 (4439072783): parseQuotaCurrent kept an ok entry
whose windows were all discarded by sanitization. overlayQuotaCurrent
then selected it as the newest fresh entry and applyEntry stamped the
pools older windows with fresh ok provenance, while a valid older
fresh sibling for the same service was blocked from supplying the
headline. Downgrade such an entry to error at the ingest boundary; an
entry that arrived windowless (balance-only) keeps its state.

Tests: sibling case (valid 80% read supplies the headline, freshness
from the sibling) and sole-entry case (surfaces error, base windows
keep their dated values).
@dezren39

dezren39 commented Nov 2, 2026

Copy link
Copy Markdown
Member Author

@codex review

@dezren39 dezren39 added work/assigned Queue worker lifecycle state queue/parked Queue task is parked (waiting on CI, time, or an event) status/parked Deliberately paused with a recorded resume condition labels Nov 2, 2026
@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. What shall we delve into next?

Reviewed commit: 6aee703dc5

ℹ️ 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".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".

@dezren39 dezren39 added queue/claimed Queue worker lifecycle state status/in-progress Queue worker lifecycle state and removed status/parked Deliberately paused with a recorded resume condition queue/parked Queue task is parked (waiting on CI, time, or an event) labels Nov 2, 2026
@dezren39
dezren39 merged commit 712663c into main Nov 2, 2026
1 of 2 checks passed
@dezren39
dezren39 deleted the queue/5318-2416-quota-windows branch November 2, 2026 14:00
@dezren39 dezren39 removed status/in-progress Queue worker lifecycle state queue/claimed Queue worker lifecycle state work/assigned Queue worker lifecycle state labels Nov 2, 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

1 participant