fix(ingest): file uploads into API-made sequences and repair damaged frames

A sequence created with POST /api/v1/sequences had no folder, and the ingest
looked for its sidecar at the archive root: every upload into it failed with
503 commit_failed, so the Uploader's "New sequence" target never worked. Its
first frame now claims a folder by the rules of a sequence created by an
upload (folder template with its title, unique variant, sidecar with the
row's id, title, tags, rating, notes and project), and the row takes the
folder in one transaction (DOCKER-1).

A frame flagged missing or corrupt, or whose file is gone or has another
size, no longer stands for an upload: the start short-circuit and crash
recovery match only intact frames still on disk, and the ingest repairs such
a frame with the verified copy (same id and position, flags cleared, a damaged
file kept beside it as name.damaged-<time>) instead of calling it a
duplicate. The Uploader deletes a source only after the server received and
verified its bytes in that upload, never on "already on the server" (SRV-1).

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 09:40:27 +00:00
1 parent 23308c77dd
commit 94b13cc064
12 files changed
+441 -41

No files matched your search

+4 -1
View File
@@ -17,7 +17,10 @@ public sealed record IngestRequest(
DateTime? ClientCapturedAt,
Guid? UserId);
/// <summary>The committed frame; <see cref="Duplicate"/> when the sequence already held a frame with that SHA-256.</summary>
/// <summary>
/// The committed frame; <see cref="Duplicate"/> when an intact frame of the sequence already held that SHA-256 (the file
/// stays in staging). A frame with that SHA-256 that was missing or damaged is repaired with the file instead (not a duplicate).
/// </summary>
public sealed record IngestResult(Guid SequenceId, Guid FrameId, int Index, string RelativePath, bool Duplicate);
/// <summary>