The developer asked for a detailed breakdown of every reset (feedback of 2026-10-18). Limits do not only reset at the end of their week: most Codex weeks in the local history ended early. - Core: a limit's samples form a window series (provider, limit name and length), so the history follows Codex's week across slots (D7). Instance spans are built once. One backward walk gives each instance, real or inferred, the start of the instance after it. The hour that holds a boundary goes to the instance that starts in it, or else to the one that ends in it (#9). A stale sample that would put its instance after a later one is ignored. The reset history lists the real instances with their figures, totals and early-reset hours (D12). API value uses a dated list price table; unknown models stay unpriced (D13). - App: a Resets section per long window with totals, a timeline of burn-ups side by side with skipped time in lanes below, early resets by hour and weekday, and a sortable table (D8). The reset tooltip lists every model with its tokens and API value. Tall tooltips open beside the pointer, and Fluent's 320 px tooltip cap no longer wraps data values. - Docs: D12 and D13 are new; D7 and D8 cover window series, boundary hours and the Resets section. Closes #14 Closes #9
33 lines
1.6 KiB
C#
33 lines
1.6 KiB
C#
using Xunit;
|
|
|
|
namespace FinalToken.Core.Tests;
|
|
|
|
public sealed class ResetBoundaryTests
|
|
{
|
|
private static readonly DateTimeOffset Day = new(2026, 10, 15, 0, 0, 0, TimeSpan.Zero);
|
|
private static LimitWindow Window(DateTimeOffset start, DateTimeOffset sample, double used) =>
|
|
new(Provider.Codex, "codex:primary", "Session", used, start.AddHours(5), TimeSpan.FromHours(5), sample, "fixture");
|
|
|
|
[Fact] public void ResetHourBeforeAGapBelongsToTheEndingInstance()
|
|
{
|
|
var previous = Window(Day.AddHours(10).AddMinutes(13), Day.AddHours(14), 50);
|
|
var current = Window(Day.AddHours(20), Day.AddHours(21), 10);
|
|
ModelTokenPoint[] tokens = [new(Day.AddHours(10), "model", new(Input: 100, Total: 100)),
|
|
new(Day.AddHours(15), "model", new(Input: 50, Total: 50))];
|
|
var past = Assert.Single(LimitAnalysis.Analyze(current, [previous], tokens, current.SampleTime, TimeZoneInfo.Utc)!.Past);
|
|
Assert.Equal(75, past.Points.Last().Used);
|
|
Assert.Equal(UseOrigin.Estimated, past.Points.Last().Origin);
|
|
Assert.Equal(previous.ResetsAt, past.Points.Last().Time);
|
|
}
|
|
|
|
[Fact] public void EarlierSampleCannotPutAnInstanceAfterTheCurrentWindow()
|
|
{
|
|
var current = Window(Day.AddHours(10), Day.AddHours(12), 10);
|
|
var stale = Window(Day.AddHours(11), Day.AddHours(11.5), 90);
|
|
var result = LimitAnalysis.Analyze(current, [stale], [], current.SampleTime, TimeZoneInfo.Utc)!;
|
|
Assert.Equal(current.ResetsAt, result.Current.End);
|
|
Assert.Equal(10, result.Current.Peak);
|
|
Assert.Empty(result.Past);
|
|
}
|
|
}
|