mirror of
https://github.com/AgentSeal/codeburn.git
synced 2026-11-29 02:39:13 +00:00
Vendors sometimes reset a usage window ahead of schedule as a goodwill gesture. Nothing in the app noticed, so the capacity that was handed back went unused. The decision is two pure pieces so it can be tested without a view or a network: a detector that takes the previous and current reading of one window and returns an optional event, and a summariser that reads a window's early-reset pattern out of the snapshots already on disk. Detection needs both signals to be defensible on their own. A reset time that jumps to a genuinely new cycle while the stored one still had time to run is one; usage emptying while the advertised reset time stands still is the other, for vendors that grant the reset without moving the time. Both carry the same identity for the cycle they cut short, so the second cannot re-announce what the first already said. The thresholds are deliberately conservative, because a false "you have your capacity back" is worse than silence. Inside a cycle reported usage only rises, moving down by a point or two of rounding, so the drop signal asks for a fall of at least 40 points that lands at or under 10% — far outside rounding, with room for a refresh interval of real use after the reset. A new cycle cannot start before our last look at the old one, so its reset time must sit about a window past that look; a reset time that merely creeps forward is a rolling window, not a reset. Silence is the answer for a scheduled reset, a plan change, clock or timestamp skew (the discipline QuotaPace already applies), a window appearing or disappearing, a window's first observation, a reconnect after a failure, and a reading that is missing or malformed. The monitor around it keeps the previous fetch's readings, the plan label and the reset times it has already announced, and delivers through the existing UpdateNotifier rather than a second notification stack. The snapshot store keeps each cycle's highest reading, which is right for "what did the cycle end at" and wrong for "what did the last fetch say", so the baseline is kept alongside the announcement record instead. History is derived from the stored reset times alone: a fixed window starting at t ends at t + length, so a cycle ending sooner than a full window after the previous cycle's scheduled end began early by the difference. No network, no external feed. |
||
|---|---|---|
| .. | ||
| AntigravityQuotaPresentation.swift | ||
| AntigravitySubscriptionService.swift | ||
| CapacityDockGlanceWindow.swift | ||
| CapacityDockInteractionState.swift | ||
| CapacityDockPreferences.swift | ||
| CapacityDockProviderCredential.swift | ||
| CapacityDockProviderQuotaService.swift | ||
| CapacityEstimator.swift | ||
| ClaudeCredentialStore.swift | ||
| ClaudeSubscriptionService.swift | ||
| CLIClaudeConfig.swift | ||
| ClinePassSubscriptionService.swift | ||
| CLIWatchdog.swift | ||
| CodeBurnCacheDirectory.swift | ||
| CodexBankedResets.swift | ||
| CodexCredentialStore.swift | ||
| CodexSubscriptionService.swift | ||
| CodexUsage.swift | ||
| CopilotExplicitDisconnect.swift | ||
| CopilotHostEndpoint.swift | ||
| CopilotQuotaPresentation.swift | ||
| CopilotSubscriptionService.swift | ||
| CursorSubscriptionService.swift | ||
| DataClient.swift | ||
| EarlyQuotaReset.swift | ||
| EarlyQuotaResetMonitor.swift | ||
| GeminiQuotaPresentation.swift | ||
| GeminiSubscriptionService.swift | ||
| GrokBuildSubscriptionService.swift | ||
| KimiQuotaPresentation.swift | ||
| KimiSubscriptionService.swift | ||
| MenubarPayload.swift | ||
| MenubarStatusCache.swift | ||
| ProviderConnectionCatalog.swift | ||
| ProviderReconnectPresentation.swift | ||
| ProviderStripPagingState.swift | ||
| QuotaPace.swift | ||
| QuotaPacePresentation.swift | ||
| QuotaSummary.swift | ||
| ServeConnection.swift | ||
| SubscriptionRefreshCadence.swift | ||
| SubscriptionSnapshotStore.swift | ||
| SubscriptionUsage.swift | ||
| UpdateChecker.swift | ||
| UpdateNotifier.swift | ||
| UsageDataChangeGuard.swift | ||
| UsageRefreshCadence.swift | ||
| ZaiSubscriptionService.swift | ||