core: add limit forecasts, week days and per-model series (D7)

LimitAnalysis computes the use at reset at the average rate, a
recent-rate forecast from the last 24 h of samples, and for windows
longer than a day the use of each local day, today's use, the even
pace and the daily budget. Pace now projects the date of reaching
100 % whenever usage is over pace, not only past the threshold.
Samples whose resets lie within 15 minutes form one window instance,
because Claude's reset times drift by a minute between probes.
TokenSeriesByModel replaces one query per chart point, and a missing
settings.json on first start is no longer a diagnostic.

Refs #5
This commit is contained in:
Florian Schmidt
2026-10-14 22:59:24 +02:00
parent c7086e9760
commit a20d0ab9dc
8 changed files with 292 additions and 5 deletions
+9
View File
@@ -29,6 +29,15 @@ public class PaceTests
[Fact] public void ProjectionAfterResetIsHidden() => Assert.Null(Pace.Calculate(Window(10), Now).Projection);
[Fact] public void ZeroElapsedDoesNotProject() => Assert.Null(Pace.Calculate(Window(50, 0), Now).Projection);
[Fact] public void ZeroUsageDoesNotProject() => Assert.Null(Pace.Calculate(Window(0), Now).Projection);
[Fact] public void BelowAlertThresholdStillProjectsWithoutPopup()
{
var window = Window(55);
var pace = Pace.Calculate(window, Now);
Assert.Equal(PaceState.OnTrack, pace.State);
Assert.NotNull(pace.Projection);
Assert.True(pace.Projection < window.ResetsAt);
Assert.Null(new PopupDecider().Observe(window, pace, new Settings()));
}
[Fact]
public void PopupHysteresisPreventsFlappingAndRearmsAfterClear()