fix(usage): let an active weekly_scoped cap outvote the all-models window #1537
All Vouch review confidence checks passed
Residual risk 0.26 = Change Risk (0.47) × (1 − Review Confidence (0.45)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.47 · 278 lines diff across 3 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.02 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Shallow Review Depth
shallow_review_depth
0.344
Diff Size
diff_size
0.337
Real PR Conversation Timeline
1 comments
"Review active on #1537"
general
weight: 0.35
alexey-pelykh
Problem
parse_usageresolves the weekly dimension from the top-levelseven_dayobject (or aweekly_alllimits[]entry) and never looks atlimits[]entries of kindweekly_scoped— the per-model weekly caps the API now reports.Live payload observed 2026-09-18 on a Team account (tokens and identifiers omitted):
| window | percent |
is_active||---|---|---|
|
seven_day/weekly_all| 44 | false ||
weekly_scoped·scope.model.display_name = "Fable"| 74 | true |The daemon reported 44 % weekly for an account whose binding constraint was the 74 % Fable cap. For a Fable-heavy operator the account exhausts ~30 pp before any weekly trigger can fire.
Change
After the existing
dimension()resolution, scanlimits[]forweekly_scopedentries that are active (is_activetrue or absent; explicitfalseskipped) and, if the highest such fraction is strictly greater than the resolved weekly fraction, take that entry's(fraction, resets_at, severity)instead.dimension(), the session dimension, andUsageReportare unchanged. No new dependencies.Rationale for max-not-replace:
weekly_allaggregates every model, so a scoped cap can only be the binding limit when it is above the aggregate; when it is below, the aggregate still binds.Tests
Four new unit tests in
src/usage.rs::tests, using the observed payload shape:weekly_scoped_higher_than_weekly_all_wins— 0.74 and the scopedresets_atwin; session unaffectedweekly_scoped_lower_than_weekly_all_is_ignored— 10 % scoped leaves 0.44inactive_weekly_scoped_is_ignored— 90 % scoped withis_active: falseleaves 0.44no_limits_array_still_parses— top-level objects only (regression guard)cargo test --locked: 2389 passed, 0 failed, 14 ignored.cargo clippy --locked --all-targets -- -D warningsandcargo fmt --checkclean.Verified against a live daemon: after swapping in the patched binary the same account reads 74–81 % weekly in
sessiometer status, matching Claude Code's own/usageFable bar.Not in scope
Whether the scoped cap should be surfaced separately in
status(a second weekly column) — this PR only makes the existing weekly dimension honest.