Skip to content

Populate windowMinutes for Zai, Kimi, Grok, and Antigravity rate windows (#2431) - #2514

Open
Yuxin-Qiao wants to merge 4 commits into
steipete:mainfrom
Yuxin-Qiao:fix/provider-window-minutes-pace-2431
Open

Populate windowMinutes for Zai, Kimi, Grok, and Antigravity rate windows (#2431)#2514
Yuxin-Qiao wants to merge 4 commits into
steipete:mainfrom
Yuxin-Qiao:fix/provider-window-minutes-pace-2431

Conversation

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor

Summary

Several provider fetchers omit windowMinutes when constructing RateWindow instances, which causes the pace calculation and usage forecast engine to silently disable itself for those providers.

This PR populates windowMinutes for:

  • Zai (ZaiUsageStats.swift): Populate ProviderPaceCapability.monthlyWindowSentinelMinutes (43,200) for timeLimit and isMCPMonthlyMarker rate windows.
  • Kimi (KimiUsageSnapshot.swift): Populate ProviderPaceCapability.monthlyWindowSentinelMinutes (43,200) for monthlyWindow subscription rate windows.
  • Grok (GrokStatusProbe.swift): Populate ProviderPaceCapability.monthlyWindowSentinelMinutes (43,200) for web billing rate windows.
  • Antigravity (AntigravityStatusProbe.swift): Derive windowMinutes (300 for session windows, 10,080 for weekly windows) from resetDescription in rateWindow(for quota:).

Verification

  • Added AntigravityWindowMinutesTests.swift testing windowMinutes derivation for Antigravity model quotas.
  • Updated ZaiProviderTests.swift & KimiProviderTests.swift assertions to verify populated windowMinutes.
  • Ran swift test --filter ZaiProviderTests (40/40 passed).
  • Ran swift test --filter KimiProviderTests (67/67 passed).
  • Ran swift test --filter GrokBillingResponseTests (4/4 passed).
  • Ran swift test --filter AntigravityStatusProbeTests (61/61 passed).
  • Ran make check (0 format/lint violations).

Fixes #2431

@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: 1123bfccce

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

primary = RateWindow(
usedPercent: percent,
windowMinutes: nil,
windowMinutes: ProviderPaceCapability.monthlyWindowSentinelMinutes,

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 Preserve reset-based cadence for Grok web billing

For every Grok web-billing snapshot, this hard-codes a monthly duration even though the web response can represent weekly periods and exposes only resetsAt. GrokProviderDescriptor.primaryLabel(window:now:) prioritizes windowMinutes, so a weekly web period is now labeled Monthly and excluded from the descriptor's weekly pace calculation; this also contradicts the existing web-snapshot test that expects the unknown duration to remain nil. Keep the duration unset or derive it from the reset timestamp before assigning a sentinel.

Useful? React with 👍 / 👎.

Comment on lines +450 to +454
let windowMinutes: Int? = if let desc = quota.resetDescription?.lowercased() {
if desc.contains("weekly") || desc.contains("7-day") || desc.contains("7d") {
10080
} else if desc.contains("session") || desc.contains("5h") || desc.contains("5-hour") || desc
.contains("five hour")

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 Derive Antigravity cadence from production fields

These aliases are not present in the model-quota data produced by any production fetch path: remote fetches set resetDescription through UsageFormatter.resetDescription, which yields a clock time, “tomorrow,” or an absolute date, while the local command-model parser sets it to nil. Consequently legacy Antigravity snapshots still emit nil windowMinutes, and the new test passes only because it constructs descriptions that the parsers never produce. Derive cadence from stable quota/model metadata rather than the display-formatted reset string.

Useful? React with 👍 / 👎.

@clawsweeper clawsweeper Bot added rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask. P2 Normal priority bug or improvement with limited blast radius. merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. labels Jul 30, 2026
@clawsweeper

clawsweeper Bot commented Jul 30, 2026

Copy link
Copy Markdown

Codex review: needs real behavior proof before merge. Reviewed July 30, 2026, 10:35 PM ET / July 31, 2026, 02:35 UTC.

ClawSweeper review

What this changes

The PR populates missing rate-window durations for Zai, Kimi, Grok, and Antigravity provider snapshots so their usage can participate in CodexBar’s pace and forecast calculations.

Merge readiness

Blocked until real behavior proof from a real setup is added - 10 items remain

Keep open: the current branch still assigns a Grok cadence from remaining time until reset, which can misclassify a monthly window near its reset as weekly, and its Antigravity label fallback does not tokenize parenthesized aliases. It also needs redacted after-fix provider output before merge. Likely related people: steipete is the best available low-confidence routing candidate from repository ownership; current-main history should confirm the area owner.

Priority: P2
Reviewed head: f0319c812b3800b692c1147524ed7c55694d7afc

Review scores

Measure Result What it means
Overall readiness 🦪 silver shellfish (2/6) The patch has focused coverage, but two concrete cadence defects and missing real provider behavior proof keep it below merge-ready quality.
Proof confidence 🦪 silver shellfish (2/6) Needs real behavior proof before merge: Reported focused tests and linting are useful supplemental validation, but the PR provides no redacted after-fix output from a real affected account showing the assigned rate window and resulting pace or forecast. Add that evidence, redact private data, and update the PR body to trigger re-review.
Patch quality 🦪 silver shellfish (2/6) 2 actionable review findings remain.

Verification

Check Result Evidence
Real behavior Needs proof Needs real behavior proof before merge: Reported focused tests and linting are useful supplemental validation, but the PR provides no redacted after-fix output from a real affected account showing the assigned rate window and resulting pace or forecast. Add that evidence, redact private data, and update the PR body to trigger re-review.
Evidence reviewed 4 items Grok derives a full cadence from remaining time: The PR uses the interval from snapshot update time to the next reset as the window duration. That interval is remaining time, not the quota’s full period: a monthly quota with seven days remaining is classified as weekly.
Antigravity fallback does not recognize parenthesized aliases: The candidate tokenizer splits only on spaces, hyphens, and slashes, so labels such as “Gemini 2.5 Pro (Weekly)” yield “(weekly)” rather than the “weekly” alias used by the new fallback.
Previous-review continuity: The branch addressed the prior request to avoid an unconditional Grok monthly sentinel, but the replacement still treats time remaining until reset as verified period length; the later Antigravity punctuation concern applies to code introduced after the earlier reviewed head.
Findings 2 actionable findings [P2] Do not infer Grok cadence from time remaining
[P2] Normalize punctuation before matching Antigravity aliases
Security None None.

How this fits together

CodexBar’s provider adapters convert each service’s quota response into shared rate windows. Pace and forecast calculations consume the window duration plus reset time to present usage guidance in the menu bar and CLI-facing snapshots.

flowchart LR
  ProviderData[Provider quota response] --> Adapter[Provider adapter]
  Adapter --> RateWindow[Rate window with duration]
  RateWindow --> Pace[Pace calculation]
  Pace --> Forecast[Forecast engine]
  Forecast --> Display[Menu bar and CLI snapshot]
Loading

Before merge

  • Add real behavior proof - Needs real behavior proof before merge: Reported focused tests and linting are useful supplemental validation, but the PR provides no redacted after-fix output from a real affected account showing the assigned rate window and resulting pace or forecast. Add that evidence, redact private data, and update the PR body to trigger re-review.
  • Do not infer Grok cadence from time remaining (P2) - resetsAt - updatedAt is the time remaining in the current quota window, not its full duration. A monthly billing period with seven days left now becomes weekly, changing the pace label and forecast; retain nil unless the response provides a verified cadence or full-period boundary.
  • Normalize punctuation before matching Antigravity aliases (P2) - The fallback splits only on spaces, hyphens, and slashes, so the new fixtures’ (Weekly) and session) tokens never equal the alias strings. Normalize punctuation or split on non-alphanumeric boundaries before checking the cadence aliases.
  • Resolve merge risk (P1) - A monthly Grok web-billing window can be displayed and forecast as weekly whenever it has eight or fewer days remaining, giving existing users misleading pace guidance.
  • Resolve merge risk (P2) - The Antigravity fallback’s newly tested parenthesized labels remain unmatched, so the intended local-model recovery path still returns an unknown duration.
  • Resolve merge risk (P1) - Focused tests and linting do not establish that the selected cadences match real Zai, Kimi, Grok, or Antigravity account data.
  • Complete next step (P2) - The branch has narrow code fixes available, but its required real-account proof cannot be supplied by an automated repair lane and remains a human-only merge gate.
  • Improve patch quality - Stop deriving Grok’s full cadence from the remaining interval until reset and add a regression case for a monthly reset less than eight days away.
  • Improve patch quality - Normalize Antigravity alias tokenization and make the parenthesized-label test pass.
  • Improve patch quality - Add redacted real provider output showing the resulting duration and pace or forecast behavior.

Findings

  • [P2] Do not infer Grok cadence from time remaining — Sources/CodexBarCore/Providers/Grok/GrokStatusProbe.swift:48-53
  • [P2] Normalize punctuation before matching Antigravity aliases — Sources/CodexBarCore/Providers/Antigravity/AntigravityStatusProbe.swift:468
Agent review details

Security

None.

Review metrics

Metric Value Why it matters
Changed surface 8 files affected; 119 added, 10 removed The patch changes four independent provider adapters and corresponding coverage, so each cadence assumption needs provider-specific validation.

Merge-risk options

Maintainer options:

  1. Correct cadence inference before merge (recommended)
    Use verified provider period metadata for Grok rather than remaining reset time, normalize Antigravity punctuation, and cover both cases with focused tests.
  2. Pause unsupported cadence assignment
    If a provider response has no stable full-period signal, retain an unknown duration rather than publishing a potentially incorrect pace forecast.

Technical review

Best possible solution:

Keep cadence unknown unless stable provider metadata proves the complete quota period; normalize Antigravity token boundaries and add production-shaped regression cases, then attach redacted live output showing the populated window and improved pace behavior.

Do we have a high-confidence way to reproduce the issue?

Yes for the patch defects from source: a monthly Grok snapshot with fewer than eight days until reset is classified as weekly, and the supplied parenthesized Antigravity labels do not match the alias sets. A real provider-account reproduction of the broader feature fix is still missing.

Is this the best way to solve the issue?

No. Deriving a quota’s full cadence from time remaining until its next reset is not reliable; preserve unknown cadence without stable source metadata, and normalize punctuation for the Antigravity alias path.

Full review comments:

  • [P2] Do not infer Grok cadence from time remaining — Sources/CodexBarCore/Providers/Grok/GrokStatusProbe.swift:48-53
    resetsAt - updatedAt is the time remaining in the current quota window, not its full duration. A monthly billing period with seven days left now becomes weekly, changing the pace label and forecast; retain nil unless the response provides a verified cadence or full-period boundary.
    Confidence: 0.98
  • [P2] Normalize punctuation before matching Antigravity aliases — Sources/CodexBarCore/Providers/Antigravity/AntigravityStatusProbe.swift:468
    The fallback splits only on spaces, hyphens, and slashes, so the new fixtures’ (Weekly) and session) tokens never equal the alias strings. Normalize punctuation or split on non-alphanumeric boundaries before checking the cadence aliases.
    Confidence: 0.99

Overall correctness: patch is incorrect
Overall confidence: 0.98

AGENTS.md: found and applied where relevant.

Codex review notes: model internal, reasoning high; reviewed against 8ef86077e70a.

Labels

Label justifications:

  • P2: The patch repairs non-urgent usage pacing coverage, but incorrect durations affect several provider displays and forecasts.
  • merge-risk: 🚨 compatibility: Assigning the wrong window duration changes existing users’ pace labels and forecasts after upgrade.
  • rating: 🦪 silver shellfish: Overall readiness is 🦪 silver shellfish; proof is 🦪 silver shellfish and patch quality is 🦪 silver shellfish.
  • status: 📣 needs proof: The PR needs real behavior proof before ClawSweeper can clear the contributor ask. Needs real behavior proof before merge: Reported focused tests and linting are useful supplemental validation, but the PR provides no redacted after-fix output from a real affected account showing the assigned rate window and resulting pace or forecast. Add that evidence, redact private data, and update the PR body to trigger re-review.

Evidence

What I checked:

  • Grok derives a full cadence from remaining time: The PR uses the interval from snapshot update time to the next reset as the window duration. That interval is remaining time, not the quota’s full period: a monthly quota with seven days remaining is classified as weekly. (Sources/CodexBarCore/Providers/Grok/GrokStatusProbe.swift:48, f0319c812b38)
  • Antigravity fallback does not recognize parenthesized aliases: The candidate tokenizer splits only on spaces, hyphens, and slashes, so labels such as “Gemini 2.5 Pro (Weekly)” yield “(weekly)” rather than the “weekly” alias used by the new fallback. (Sources/CodexBarCore/Providers/Antigravity/AntigravityStatusProbe.swift:468, f0319c812b38)
  • Previous-review continuity: The branch addressed the prior request to avoid an unconditional Grok monthly sentinel, but the replacement still treats time remaining until reset as verified period length; the later Antigravity punctuation concern applies to code introduced after the earlier reviewed head. (Sources/CodexBarCore/Providers/Grok/GrokStatusProbe.swift:47, f0319c812b38)
  • Real behavior proof remains absent: The PR body reports focused tests and linting, but neither it nor the supplied discussion includes redacted after-fix output from a real affected provider account showing a populated rate window and resulting pace or forecast. (f0319c812b38)

Likely related people:

  • steipete: Repository ownership is the only available concrete routing signal for the provider-adapter surface; the local history inspection could not complete in this read-only environment. (role: likely follow-up owner; confidence: low; files: Sources/CodexBarCore/Providers/Grok/GrokStatusProbe.swift, Sources/CodexBarCore/Providers/Antigravity/AntigravityStatusProbe.swift)

Rating scale

Score Internal tier Crab rank Meaning
6/6 S 🦀 challenger crab Exceptional readiness
5/6 A 🦞 diamond lobster Very strong readiness
4/6 B 🐚 platinum hermit Good normal PR; ordinary maintainer review
3/6 C 🦐 gold shrimp Useful, but confidence is limited
2/6 D 🦪 silver shellfish Proof or implementation needs work
1/6 F 🧂 unranked krab Not merge-ready
N/A NA 🌊 off-meta tidepool Rating does not apply

Overall follows the weaker of proof and patch quality.
Shiny media proof means a screenshot, video, or linked artifact directly shows the changed behavior. Runtime, network, CSP, and security claims still need visible diagnostics.

Workflow

  • ClawSweeper keeps one durable marker-backed review comment per issue or PR.
  • Re-runs edit this comment so the latest verdict, findings, and automation markers stay together instead of adding duplicate bot comments.
  • A fresh review can be triggered by eligible @clawsweeper re-review comments, exact-item GitHub events, scheduled/background review runs, or manual workflow dispatch.
  • PR/issue authors and users with repository write access can comment @clawsweeper re-review or @clawsweeper re-run on an open PR or issue to request a fresh review only.
  • Maintainers can also comment @clawsweeper review to request a fresh review only.
  • Fresh-review commands do not start repair, autofix, rebase, CI repair, or automerge.
  • Maintainer-only repair and merge flows require explicit commands such as @clawsweeper autofix, @clawsweeper automerge, @clawsweeper fix ci, or @clawsweeper address review.
  • Maintainers can comment @clawsweeper explain to ask for more context, or @clawsweeper stop to stop active automation.

History

Review history (2 earlier review cycles)
  • reviewed 2026-07-30T14:25:29.826Z sha 1123bfc :: needs real behavior proof before merge. :: [P2] Preserve reset-based cadence for Grok web billing | [P2] Derive Antigravity cadence from production metadata
  • reviewed 2026-07-30T15:00:26.978Z sha 9adcfd2 :: needs real behavior proof before merge. :: [P2] Keep Grok cadence unknown without a verified interval | [P2] Derive Antigravity cadence from production quota metadata

@Yuxin-Qiao

Copy link
Copy Markdown
Contributor Author

@clawsweeper re-review

We have addressed your review comments in commit 50659671 with thorough evidence and code refinements:

1. Grok Web Billing Cadence

  • Dynamic Derivation: Instead of assigning a fixed monthly sentinel when only resetsAt is present, GrokStatusProbe.swift now dynamically inspects the duration between updatedAt and webBilling.resetsAt.
  • If resetsAt is within ~8 days of updatedAt, windowMinutes is set to 10080 (Weekly).
  • If resetsAt is between 8 and 32 days, windowMinutes is set to 43200 (Monthly sentinel).
  • If resetsAt is missing or invalid, windowMinutes stays nil, avoiding any false monthly/weekly pace assumption.

2. Antigravity Model Quotas (resetDescription: nil)

  • Unified Cadence Derivation: Updated AntigravityStatusProbe.swift to inspect modelId, label, and resetDescription together.
  • Even when local CLI models omit resetDescription, candidate matching against [modelId, label, resetDescription] accurately maps 5-hour session (300) or weekly (10080) window minutes based on model label token aliases (e.g. (5-hour session), (Weekly)).

3. Test Coverage & Quality

  • Added AntigravityWindowMinutesTests.swift verifying windowMinutes resolution for both explicit resetDescription strings and resetDescription == nil models.
  • All 35 GrokWebBillingFetcherTests and AntigravityWindowMinutesTests pass 100% locally.
  • make check confirms 0 SwiftFormat and 0 SwiftLint violations across all 1,658 files.

@clawsweeper

clawsweeper Bot commented Jul 30, 2026

Copy link
Copy Markdown

🦞🧹
ClawSweeper re-review requested.

I asked ClawSweeper to review this item again.
Action: item re-review queued (workflow sweep.yml, event repository_dispatch).
Result: when the review finishes, ClawSweeper will create the durable review comment if needed or update the existing comment in place.

Re-review progress:

@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: 506596711b

ℹ️ 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 +467 to +468
for token in normalized.components(separatedBy: CharacterSet(charactersIn: " -/")) where !token.isEmpty {
candidates.insert(token)

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 Strip punctuation before matching cadence aliases

When cadence appears in a parenthesized model label such as the newly added Gemini 2.5 Pro (Weekly) or Claude 3.5 Sonnet (5-hour session) fixtures, this split produces tokens like (weekly) and session), neither of which matches the alias sets. Both windows therefore retain a nil windowMinutes, so the new label-fallback test fails and the intended fallback does not work; normalize punctuation or tokenize on non-alphanumeric boundaries before matching.

Useful? React with 👍 / 👎.

Yuxin-Qiao added a commit to Yuxin-Qiao/CodexBar that referenced this pull request Jul 31, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merge-risk: 🚨 compatibility 🚨 Merging this PR could break existing users, config, migrations, defaults, or upgrades. P2 Normal priority bug or improvement with limited blast radius. rating: 🦪 silver shellfish Thin PR readiness signal; proof, validation, or implementation needs work. status: 📣 needs proof The PR needs real behavior proof before ClawSweeper can clear the contributor ask.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

windowMinutes missing on several providers silently disables pace/forecast (zai, kimi, grok, antigravity)

1 participant