core: plan the daily budget per day, start forecasts at 2 % and follow the limit week
agent-review agent review: fail
agent-review agent review: fail
The budget was the rest of the week over the time left, so each use today lowered it and a partial first day was held to a full day. Now each day of the instance has its share, its even pace and its budget. Today's budget starts from the use at the day start and does not move with today's use (D7). Forecasts start at 2 % of a window, so an early reset no longer hides them for most of a day. Limit tiles of one kind show the same rows, with placeholders that say why a value is missing. The week chart draws per-day steps and marks the instance start and reset (D8). Week token totals follow the provider's limit week and say since when, with the calendar week as fallback (D9). Refs #13
This commit is contained in:
@@ -10,7 +10,7 @@ public sealed class ViewModelTests
|
||||
[InlineData(40, false)]
|
||||
public void HistoryForecastsUseTheSnapshotsConfiguredPace(double threshold, bool eligible)
|
||||
{
|
||||
var model = FakeData.ForecastModel(threshold);
|
||||
var model = FakeData.ForecastModel(threshold, beforeStart: true);
|
||||
Assert.Equal(eligible, model.History.Limits.Single(l => l.Window!.Window.Id == "primary").Forecast is not null);
|
||||
Assert.Equal(eligible, model.History.Details.Single(d => d.Id == "primary").Recent is not null);
|
||||
}
|
||||
@@ -166,12 +166,13 @@ public sealed class ViewModelTests
|
||||
|
||||
internal static class FakeData
|
||||
{
|
||||
public static PanelViewModel ForecastModel(double threshold = 10)
|
||||
public static PanelViewModel ForecastModel(double threshold = 10, bool beforeStart = false)
|
||||
{
|
||||
var now = new DateTimeOffset(2026, 10, 15, 16, 45, 0, TimeSpan.Zero);
|
||||
var ahead = new LimitWindow(Provider.Codex, "primary", "Week", 39,
|
||||
new(2026, 10, 22, 6, 18, 0, TimeSpan.Zero), TimeSpan.FromDays(7), now, "fixture");
|
||||
var early = ahead with { Id = "secondary", Label = "Week · early on track", UsedPercent = 1, ResetsAt = now.AddDays(7).AddHours(-1) };
|
||||
if (beforeStart) ahead = ahead with { Length = TimeSpan.FromDays(28), ResetsAt = now.AddDays(28).AddHours(-4) };
|
||||
var early = ahead with { Id = "secondary", Length = TimeSpan.FromDays(7), Label = "Week · early on track", UsedPercent = 1, ResetsAt = now.AddDays(7).AddHours(-1) };
|
||||
var store = new HistoryStore(Path.Combine(Path.GetTempPath(), Guid.NewGuid().ToString("N")), new DiagnosticLog(), new FixedClock(now));
|
||||
store.AddLimits([ahead with { SampleTime = now.AddHours(-4), UsedPercent = 20 }, ahead,
|
||||
early with { SampleTime = now.AddHours(-1), UsedPercent = 0 }, early]);
|
||||
@@ -190,6 +191,24 @@ internal static class FakeData
|
||||
};
|
||||
private static WindowSnapshot Window(Provider provider, string id, string label, double percent, DateTimeOffset now, int hours, int resetHours)
|
||||
{ var w = new LimitWindow(provider, id, label, percent, now.AddHours(resetHours), TimeSpan.FromHours(hours), now.AddMinutes(-3), "fixture"); return new(w, Pace.Calculate(w, now)); }
|
||||
public static PanelViewModel BudgetModel()
|
||||
{
|
||||
var now = new FixedClock().GetUtcNow();
|
||||
var clock = new FixedClock(now);
|
||||
var start = new DateTimeOffset(2026, 10, 10, 22, 40, 0, clock.LocalTimeZone.BaseUtcOffset);
|
||||
var store = new HistoryStore(Path.Combine(Path.GetTempPath(), "finaltoken-budget", Guid.NewGuid().ToString("N")), new DiagnosticLog(), clock);
|
||||
var snapshot = Snapshot(now);
|
||||
snapshot = snapshot with { Providers = snapshot.Providers.Select(p =>
|
||||
{
|
||||
var w = new LimitWindow(p.Provider, "week", "Week", p.Provider == Provider.Claude ? 40 : 32, start.AddDays(7), TimeSpan.FromDays(7), now, "fixture");
|
||||
store.AddLimits([w with { SampleTime = CalendarDays.Start(now, clock.LocalTimeZone), UsedPercent = 30 }, w]);
|
||||
for (var i = 0; i < 4; i++)
|
||||
store.Add(new(p.Provider, start.AddDays(i), "fixture", "Fixture/Project", new(Input: 100, Total: 100), $"{p.Provider}-{i}"));
|
||||
return p with { Windows = [new(w, Pace.Calculate(w, now))], Session = null,
|
||||
WeekStart = start, WeekWindow = p.Provider == Provider.Claude ? "week" : null };
|
||||
}).ToArray() };
|
||||
return new() { Snapshot = snapshot, History = PanelViewModel.QueryHistory(store, snapshot, HistoryRange.Days7, null, now) };
|
||||
}
|
||||
public static PanelViewModel EarlyResetModel()
|
||||
{
|
||||
var now = new FixedClock().GetUtcNow();
|
||||
|
||||
Reference in New Issue
Block a user