Fix what a second independent reading of the Phase 8 fixes found
ci / test (postgres) (push) Failing after 6m9s
ci / test (sqlite) (push) Successful in 7m6s
ci / image (push) Skipped
ci / test (postgres) (pull_request) Successful in 5m51s
ci / test (sqlite) (pull_request) Successful in 7m3s
ci / image (pull_request) Successful in 1m51s

One funded signal was enough to start the model for good, because the interval
of a few cases had no width: it now takes a hundred, weighed among themselves.
A computer always off at 03:00 never made the night of the model: a job to make
up for counts from the first start that knows it, and the night waits for the
bars of the absence. Stories are seen as they were when the decision was due, a
report already out does not close a label, an undone promotion starts the trial
again, and the trade card finds the estimate of an example born earlier.

ADR 0018 point 18 has the list; each defect has its test.

refs #67

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-12-01 14:27:03 +01:00
1 parent 0b0f4a5e75
commit c7e462b6f4
18 files changed
+371 -26

No files matched your search

+25 -2
View File
@@ -377,6 +377,11 @@ internal sealed partial class AnubisHost(
lastDues[name] = due;
}
if (!options.Demo)
{
await StartCountingAsync([.. SchedulerJobs(backups)], lastDues, cancellationToken).ConfigureAwait(false);
}
if (_sampler is not null)
{
await _sampler.TakeAsync(SampleKinds.Start, cancellationToken).ConfigureAwait(false);
@@ -506,13 +511,31 @@ internal sealed partial class AnubisHost(
!options.Demo && (overrides is null ? true : overrides.Trading == true) &&
environment.GetValueOrDefault("ANUBIS_TRADING") is not ("0" or "off" or "false");
private void StartScheduler(Scheduler scheduler, Backups backups, Dictionary<string, DateTimeOffset> lastDues)
private IEnumerable<ScheduledJob> SchedulerJobs(Backups backups)
{
// A backup missed while the bot was off is taken once at the restart, whenever it comes (SPEC 5.6).
var backup = new ScheduledJob("backup", "Salvataggio del database", Schedule.Daily(new TimeOnly(3, 30), Config.TimeZone),
async ct => await backups.TakeAsync(_db!, "notturno", ct).ConfigureAwait(false))
{ MaxLateness = TimeSpan.FromHours(2), CatchUpWithin = TimeSpan.FromDays(3650) };
foreach (var job in new[] { backup }.Concat(_sampler is { } sampler ? new[] { sampler.Job() } : []).Concat(_market?.Jobs() ?? []).Concat(_trading?.Jobs() ?? []).Concat(_telegram?.Jobs() ?? []))
return new[] { backup }.Concat(_sampler is { } sampler ? new[] { sampler.Job() } : []).Concat(_market?.Jobs() ?? []).Concat(_trading?.Jobs() ?? []).Concat(_telegram?.Jobs() ?? []);
}
/// <summary>
/// A job to make up for after an absence counts from the first start that knows it. Otherwise a computer always off at
/// its hour would never make it: without a first run there would be no run to find missed (SPEC 5.6).
/// </summary>
private Task StartCountingAsync(IReadOnlyList<ScheduledJob> jobs, Dictionary<string, DateTimeOffset> lastDues, CancellationToken cancellationToken) => _db!.WriteAsync(async s =>
{
foreach (var job in jobs.Where(j => j.CatchUpWithin is not null && !lastDues.ContainsKey(j.Name)))
{
await s.ExecuteAsync("INSERT INTO jobs (id, name, description, last_due_at, created_at, updated_at) VALUES (@id, @n, @d, @now, @now, @now) ON CONFLICT (name) DO NOTHING", cancellationToken,
("id", Ids.NewId(clock)), ("n", job.Name), ("d", job.Description), ("now", clock.UtcNow)).ConfigureAwait(false);
}
}, cancellationToken);
private void StartScheduler(Scheduler scheduler, Backups backups, Dictionary<string, DateTimeOffset> lastDues)
{
foreach (var job in SchedulerJobs(backups))
{
scheduler.Add(job, lastDues.TryGetValue(job.Name, out var due) ? due : null);
}