core: plan the daily budget per day, start forecasts at 2 % and follow the limit week
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:
Florian Schmidt
2026-10-18 09:55:41 +02:00
parent a8785fa453
commit 941a597680
22 changed files with 422 additions and 66 deletions
+18
View File
@@ -61,11 +61,29 @@ public class CliTests
Assert.Equal(0, await CliApplication.RunAsync(["status", "--no-probe"], output, error, directory,
path => new(path, claudeDirectory: path, codexDirectory: path, cliDiscovery: (_, _) => new(null, "Fixture CLI missing.")), TestContext.Current.CancellationToken));
Assert.Contains("Tokens today: 0", output.ToString());
Assert.Contains("Calendar week: since ", output.ToString());
Assert.NotNull(SnapshotFile.Read(directory).Snapshot);
}
finally { Directory.Delete(directory, true); }
}
[Fact]
public async Task TextNamesLimitWeekAndItsStart()
{
var directory = Path.Combine(Path.GetTempPath(), "finaltoken-cli-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(directory);
try
{
using var storeLock = StoreLock.TryAcquire(directory);
var start = new DateTimeOffset(2026, 10, 10, 22, 40, 0, TimeSpan.Zero);
await SnapshotFile.WriteAsync(directory, new Snapshot { MadeAt = DateTimeOffset.UtcNow, RefreshInterval = TimeSpan.FromMinutes(1),
Providers = [new(Provider.Codex, ProviderStatus.Available, null, [], new(), null, new(Total: 30), start, "week")] }, TestContext.Current.CancellationToken);
using var output = new StringWriter(); using var error = new StringWriter();
Assert.Equal(0, await CliApplication.RunAsync(["status"], output, error, directory, cancellationToken: TestContext.Current.CancellationToken));
Assert.Contains($"Limit week: since {start:O} (week)", output.ToString());
}
finally { Directory.Delete(directory, true); }
}
[Fact]
public async Task BusyStoreWithoutSnapshotExitsOne()
{
var directory = Path.Combine(Path.GetTempPath(), "finaltoken-cli-" + Guid.NewGuid().ToString("N"));