Repository navigation
Superseded By #357 — Do Not Merge #356
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
7bed999
3889c2d
b6edac8
b451c6a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -462,14 +462,23 @@ public struct ResetAlarmTracker: Sendable { | |
| } | ||
| if window.identity == nil { window.identity = observation.identity } | ||
| window.lastSeenAt = now | ||
| if let period = observation.periodSeconds { window.periodSeconds = period } | ||
|
|
||
| // A reading older than one already processed cannot say anything new. | ||
| if let observed = observedAt, let last = window.lastObservedAt, observed < last { | ||
| state.windows[key] = window | ||
| return nil | ||
| } | ||
|
|
||
| // A producer may reuse a window ID while switching its cadence. Its reset time and remaining percentage no longer share the old baseline. Keep the new reading as a baseline instead of comparing across periods. | ||
| if let observedPeriod = observation.periodSeconds, | ||
| let previousPeriod = window.periodSeconds, | ||
| abs(observedPeriod - previousPeriod) > ResetAlarmPolicy.resetDriftTolerance { | ||
| state.windows[key] = firstReading() | ||
| return nil | ||
| } | ||
|
|
||
| if let period = observation.periodSeconds { window.periodSeconds = period } | ||
|
|
||
| let readAt = observedAt ?? now | ||
| var isReset = false | ||
| var isMidWindow = false | ||
|
Comment on lines
+474
to
484
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Timestamp-derived cadence changes across varying-length periods (such as 30 vs 31-day months) trigger window rebaselining, dropping genuine rollover alerts. Suggested FixAllow tolerance for expected calendar variations or normalize timestamp-derived periods into standard calendar-month intervals before comparing cadence changes against Prompt for AI AgentDid we get this right? 👍 / 👎 to inform future reviews. |
||
|
|
@@ -487,13 +496,17 @@ public struct ResetAlarmTracker: Sendable { | |
| : max(ResetAlarmPolicy.resetDriftTolerance, | ||
| window.periodSeconds.map { $0 * ResetAlarmPolicy.earlyResetShareOfPeriod } | ||
| ?? ResetAlarmPolicy.earlyResetUnknownPeriod) | ||
| // A provider that resets early may move the reset time by less | ||
| // than `required`; the percentage jumping back up settles it. | ||
| // A correction is not proof of restored quota when a readable percentage stays flat or falls; allow an unmeasured scheduled rollover only after the old end passes. | ||
| var climbed = false | ||
| if let reading, let last = window.lastRemaining { | ||
| climbed = reading >= last + ResetAlarmPolicy.earlyResetRiseMargin | ||
| } | ||
| if jump > required || (jump > ResetAlarmPolicy.resetDriftTolerance && climbed) { | ||
| let rose = reading.flatMap { current in | ||
| window.lastRemaining.map { current > $0 + ResetAlarmPolicy.riseEpsilon } | ||
| } ?? false | ||
| let resetHasQuotaEvidence = rose || (hasPassed && reading == nil) | ||
| if (jump > required && resetHasQuotaEvidence) | ||
| || (jump > ResetAlarmPolicy.resetDriftTolerance && climbed) { | ||
|
Comment on lines
+504
to
+509
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Scheduled rollover missed with first measured reading after nil history The check suppresses genuine resets because Prompt for LLMTalk to Kody by mentioning @kody Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction. |
||
| isReset = true | ||
|
Comment on lines
+504
to
510
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Genuine period rollovers without quota increases or with Suggested FixRefine Prompt for AI Agent |
||
| // When the window had *not* reached its own scheduled end, | ||
| // any reset is an early / mid-cycle vendor restore rather than | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cadence rebaseline drops known window identity on unstamped reading
The rebaseline discards the stored account binding because
firstReading()carriesnilforobservation.identity, letting a later different account merge into the same window. Preservewindow.identitywhenobservation.identityisnil.Prompt for LLM
Talk to Kody by mentioning @kody
Was this suggestion helpful? React with 👍 or 👎 to help Kody learn from this interaction.