fix(analysis): record nothing for frames that changed while an analysis ran

A light or deep analysis read its frames at the start and, under the
sequence lock, recorded AnalyzedLight, the warning count and the advisor's
Auto values for them whatever happened meanwhile. Frames added by an upload,
an import or a scan's reconcile then kept advice and warnings counted on the
old frame count, over a newer light analysis, and scans never queued another
one because AnalyzedLight was set again.

Under the lock the analysis now compares the row's frames version with the
one it read. When it moved and no light analysis is queued for the
sequence, it records nothing (a deep pass keeps only analysis.json and its
per-frame measurements), and the job logs it and queues a light analysis of
the frames as they are. A queued light analysis replaces what the pass
records, as for image passes.

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-12 21:37:00 +00:00
1 parent bb2f40c29f
commit d064719c11
7 files changed
+143 -7

No files matched your search

@@ -126,6 +126,18 @@ internal sealed class GateDecoder : IImageDecoderProvider
Hold = ProcessingFixture.FileName(index);
}
/// <summary>File name whose tier probe waits until <see cref="Release"/> (a light analysis probes frames whose tier is
/// not known yet, and decodes nothing); null probes everything.</summary>
public string? HoldProbe { get; private set; }
/// <summary>Holds the next tier probe of frame <paramref name="index"/>'s file, as <see cref="HoldFrame"/> holds a decode.</summary>
public void HoldProbeOf(int index)
{
Holding = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
_released = new TaskCompletionSource(TaskCreationOptions.RunContinuationsAsynchronously);
HoldProbe = ProcessingFixture.FileName(index);
}
/// <summary>Lets the held decode go on, as a slow read would.</summary>
public void Release() => _released.TrySetResult();
@@ -147,8 +159,16 @@ internal sealed class GateDecoder : IImageDecoderProvider
public FileTier Probe(string path, ImageFileFormat format) => Probe(path, format, null);
public FileTier Probe(string path, ImageFileFormat format, string? companion) =>
Tiers.TryGetValue(Path.GetFileName(path), out var tier) ? tier : _managed.Probe(path, format, companion);
public FileTier Probe(string path, ImageFileFormat format, string? companion)
{
var name = Path.GetFileName(path);
if (HoldProbe is { } hold && name == hold)
{
Holding.TrySetResult();
_released.Task.Wait(TimeSpan.FromSeconds(30));
}
return Tiers.TryGetValue(name, out var tier) ? tier : _managed.Probe(path, format, companion);
}
public DecodedImage? Decode(DecodeRequest request, CancellationToken cancellationToken = default)
{