fix(server): a verify that hashes photos plans Reorganize again; keep refusals, bound planning

The kept-plan stamp left out whether a planned sequence's photos are hashed.
A verify writes frames.sha256 (and only status and verified_at on the row)
without another frames version, so after verifying never-hashed photos the
same dry run kept answering "verify the sequence first" for up to five
minutes, and its confirmation queued a job certain to fail.

- SequenceRepository.GetStampAsync adds, for every planned sequence, how many
  of its photos have their hash in the index (one grouped query over the
  archive with all, the selected ids in batches of 500 otherwise).
- ReorganizePlanCache keeps a refusal (nested_target, not_found) as it keeps
  a plan: for the same stamp and templates it is the same, and a long plan
  that ends refused after a cut-off is no longer planned again on every retry.
  Failures are still not kept.
- Planning is bounded: at most two plans are made at once, the others wait for
  their turn; a plan still being made 15 minutes after it was asked, let go at
  capacity, or when the server stops is cancelled, and whoever waits for it
  gets 503 plan_dropped. A read that hangs keeps its turn until it returns but
  no longer keeps its waiters.
- The Capacity summary now says what eviction does (the kept plan asked for
  first, else the plan being made asked for first); the stamp, protocol and
  endpoint docs say that a verify hashing photos is a change the plan reads.
- Tests: a scan's photos, verified, are planned again and renamed by the job;
  the stamp follows hashes of planned photos only; refusals kept, failures
  not; turns, eviction and deadline of plans being made, a hung read included.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 56582df45453fc555e525f19de7de1803204d12c)
This commit is contained in:
Alby96 committed 2026-10-27 19:16:42 +01:00
1 parent c3756d03c9
commit 1fb040afe6
8 files changed
+320 -58

No files matched your search

+6 -4
View File
@@ -87,10 +87,12 @@ public sealed record LibraryFacetsDto(IReadOnlyList<FacetDto> Years, IReadOnlyLi
/// templates applied to sequences already in the archive, <see cref="SequenceIds"/> or every one with <see cref="All"/>
/// (exactly one of the two). A null template keeps that part; at least one is given, each valid as the archive settings'
/// templates are. <see cref="DryRun"/> answers the plan (<see cref="ReorganizePlanDto"/>) and changes nothing; the server
/// keeps it a few minutes, so the same dry run again (also after one cut off) is answered from it. The change itself sends
/// that plan's <see cref="Fingerprint"/> back and runs as a <c>move</c> job (202): 409 <c>plan_changed</c> when the index
/// changed since in what the plan reads; a change made on disk alone, which the index does not have yet, is found by the
/// job, which then fails and changes nothing.
/// keeps it a few minutes, a refusal too, so the same dry run again (also after one cut off) is answered from it; 503
/// <c>plan_dropped</c> when the server stopped making it (it took too long, or too many were asked at once). The change
/// itself sends that plan's <see cref="Fingerprint"/> back and runs as a <c>move</c> job (202): 409 <c>plan_changed</c>
/// when the index changed since in what the plan reads (the sequences' rows, and which of their photos are hashed, as a
/// verify does); a change made on disk alone, which the index does not have yet, is found by the job, which then fails and
/// changes nothing.
/// </summary>
public sealed record ReorganizeRequest(IReadOnlyList<Guid>? SequenceIds, bool All, string? FolderTemplate, string? FileTemplate, string? TitleTemplate,
bool DryRun, string? Fingerprint = null);