fix(server): key kept Reorganize plans on what they read, plan apart from the request

A kept dry run was keyed on a stamp of every sequence row of the archive,
updated_at and verified_at included, so any upload, ingest status write,
verify or tag edit anywhere invalidated it and the confirm planned the whole
selection again. The plan was also bound to the request, so a proxy cutting
the request off cancelled it and a retry started over.

- The stamp (SequenceRepository.GetStampAsync) now hashes only what the
  planner reads from the index: every row's id and folder (collisions and
  what a moving folder carries), the planned rows' title, first capture,
  camera, lens, photo count and frames version, and the titles of the rows
  inside a planned folder. With all, every row is planned.
- ReorganizePlanCache makes a plan on the thread pool with the host's
  stopping token, once per key for concurrent requests; a request cut off
  only stops waiting, and the same request again waits for the plan or
  takes it. Refusals and failures are still not kept.
- A kept plan is dropped by its own timer five minutes after it was made
  (and never used past that), instead of staying until the next request.
- The protocol and endpoint docs say that plan_changed answers changes the
  index has; one made on disk alone is found by the job, which fails and
  changes nothing. The Capacity doc no longer claims a step per sequence.
- Tests: what the stamp follows and ignores, a kept plan surviving an upload
  elsewhere and a verify, one plan for concurrent requests and after a
  cut-off, the timer, an all:true apply carrying a nested sequence beside a
  blocked-only one, the first sequence told before a pause. The
  no-archive-module job_unavailable test expected a folder the planner no
  longer plans without a sidecar; it now expects the unreadable step.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit 7e01a4f85fe4b880ddd98a481fc8591649cec254)
This commit is contained in:
Alby96 committed 2026-10-27 18:09:46 +01:00
1 parent 6e99a4b269
commit 37800b28ef
7 files changed
+328 -80

No files matched your search

+5 -3
View File
@@ -86,9 +86,11 @@ public sealed record LibraryFacetsDto(IReadOnlyList<FacetDto> Years, IReadOnlyLi
/// <c>POST /api/v1/archive/reorganize</c> (owner review 2, R7; administrators of the archive): new folder, file and title
/// 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 change
/// itself sends that plan's <see cref="Fingerprint"/> back (409 <c>plan_changed</c> when the archive changed since) and runs
/// as a <c>move</c> job (202).
/// 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.
/// </summary>
public sealed record ReorganizeRequest(IReadOnlyList<Guid>? SequenceIds, bool All, string? FolderTemplate, string? FileTemplate, string? TitleTemplate,
bool DryRun, string? Fingerprint = null);