fix(analysis): one failed sequence is the job's error as logged; workers never fault while stopping

"1 sequenze su 3" read wrong in Italian: a single failure now reports its
own line (title and reason); the count is kept for two or more. A worker
whose job could not be finished while the engine stops logs it instead of
faulting, so disposing the engine never throws.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-03 09:45:29 +00:00
1 parent 40cdb19d5e
commit 5e2acc9f60
4 files changed
+10 -6

No files matched your search

@@ -30,6 +30,7 @@ internal sealed class AnalyseJobHandler(TitanoDatabase db, SequenceAnalyser anal
var total = units.Sum();
var done = Enumerable.Range(0, next).Where(i => !retry.Contains(i)).Sum(i => units[i]);
var failed = new List<int>();
string? failure = null;
int[] order = [.. retry, .. Enumerable.Range(next, targets.Count - next)];
for (var k = 0; k < order.Length; k++)
{
@@ -49,7 +50,8 @@ internal sealed class AnalyseJobHandler(TitanoDatabase db, SequenceAnalyser anal
{
await chain.FlushAsync().ConfigureAwait(false);
Core.Diagnostics.Log.Warning("processing", $"Analysis of sequence {targets[i]} failed", ex);
context.Log(Loc.L("Advisor.Log.Failed", await TitleAsync(targets[i], context.Cancellation).ConfigureAwait(false), ex.Message));
failure = Loc.L("Advisor.Log.Failed", await TitleAsync(targets[i], context.Cancellation).ConfigureAwait(false), ex.Message);
context.Log(failure);
failed.Add(i);
}
done += units[i];
@@ -57,7 +59,8 @@ internal sealed class AnalyseJobHandler(TitanoDatabase db, SequenceAnalyser anal
// Failed targets of an earlier attempt not retried yet stay listed.
await context.CheckpointAsync(Format(next, [.. failed, .. retry.Skip(k + 1)]), done, total).ConfigureAwait(false);
}
if (failed.Count > 0) throw new InvalidOperationException(Loc.L("Errors.Analysis.Failed", failed.Count, targets.Count));
// One failure is the job's error as it was logged; several are counted (the log names each).
if (failed.Count > 0) throw new InvalidOperationException(failed.Count == 1 ? failure : Loc.L("Errors.Analysis.Failed", failed.Count, targets.Count));
}
private async Task<string> TitleAsync(Guid sequenceId, CancellationToken cancellationToken) =>