Repository navigation
Description
Summary
services/subscription_headroom_service.py::parse_unified_headers parses and persists overage_status (anthropic-ratelimit-unified-overage-status) and unified_status (anthropic-ratelimit-unified-status), and subscription_headroom_history stores both — but no predicate reads either. _headroom_indicates_limited / _headroom_indicates_healthy, classify_headroom, headroom_reading and the #2409 ranker key on the per-window -status values, the probe's HTTP status and the utilization figure only.
The provider's own client derives "serving on overage" as unified-status == rejected together with overage-status ∈ {allowed, allowed_warning}. So a subscription that has run past its cap and is being served on overage may report a top-level rejected while still serving requests. How Trinity's per-window predicates read that state is unknown: depending on what the per-window -status values carry during overage, such a subscription is either LIMIT-badged / saturated / dropped as refused everywhere while it is in fact serving, or its overage is invisible.
Context
Surfaced by the independent strategy review of #2419 (PR #2864), which fixed the utilization figure for readings past 1.0 but deliberately did not touch the status predicates. No overage header set has ever been captured: every local plan carries overage_status = rejected (blocks at 100%), so the questions "does 5h/7d utilization exceed 1.0 on overage?" and "what do the per-window statuses say during overage?" are both open.
#2864 added the capture path: _probe logs [#2419] subscription … reports utilization past its cap at INFO with the raw header strings (5h/7d utilization, overage-status, status, representative-claim) the first time a window reads past 100%. Standing query for the persisted side:
SELECT * FROM subscription_headroom_history
WHERE five_hour_utilization_pct > 100 OR seven_day_utilization_pct > 100;Acceptance Criteria
- One real overage header set captured (from the
[#2419]log line or the query above on an overage-enabled plan) and pinned in a test, replacing the synthetic set intests/unit/test_2419_utilization_fraction.py - The status predicates state, in code and test, how a serving-on-overage subscription is classified: it is not LIMIT-badged or dropped as refused while the provider is serving it, and its overage is visible on the row (utilization past 100 and/or an explicit overage marker)
-
overage_status/unified_statusare either consumed by a predicate or documented as display-only, so the columns do not read as coverage they are not - Existing feat: Subscription usage observability — 5h/7d usage dashboard, per-agent breakdown, and rate-limit event history #471 / ent#433 / ent#434 / auto-switch picks an alternative subscription without checking headroom — it can move agents onto a nearly-exhausted one #2409 /
_parse_utilizationreads a >1.0 fraction as an already-percent value — an overage subscription would display and rank as ~1% #2419 tests unchanged except where a captured sample corrects a synthetic one
Technical Notes
src/backend/services/subscription_headroom_service.py—parse_unified_headers(:161-176),_headroom_indicates_limited/_healthy(:595-659),classify_headroom,headroom_reading,_log_past_cap(the capture)src/frontend/src/utils/subscriptionPressure.js—NON_BLOCKING_WINDOW_STATUSES(pinned to the backend vocabulary bytest_2396_provider_warning_tier.py)- Related:
_parse_utilizationreads a >1.0 fraction as an already-percent value — an overage subscription would display and rank as ~1% #2419 / PR fix(subscriptions): read the utilization header as a fraction, past 1.0 too (#2419) #2864 (figure), bug: subscription reports "rate-limited" for the provider's own warning tier — allowed_warning fails the _headroom_indicates_limited catch-all #2396 (warning tier is not a rate limit), abilityai/trinity-enterprise#434 (weekly alert), auto-switch picks an alternative subscription without checking headroom — it can move agents onto a nearly-exhausted one #2409 (ranker)
Activity
docs(security): the #2419 diff audit's appendix item now cites its fo…
fix(subscriptions): read the utilization header as a fraction, past 1…