feat: found copies foundation (contracts, migration 0012, store, wire, trash and job hooks, keys)

Owner review 6 asks Chronos to recognise the same time-lapse held under different ids on the
server and on this PC, compare the copies, and keep them apart or integrate and sync them. This
lays the shared foundation the later parcels build on, without any UI or detection yet.

- Migration 0012 adds found_copies (local-server and local-local pairs with evidence, scores,
  answer, policy and the 404 record) and copy_probes; every existing link with a local sequence
  becomes a Linked pair, so a server deletion and the per-link policy have a place.
- FoundCopyStore keeps the pairs: upserts that never touch the answer, a compare-and-set of the
  state with an Integrating backstop (a failed or cancelled job reads as the previous state),
  link promotion and demotion, the once-per-refresh 404 count, the merge's links stage
  (session keys, links reset, pairs moved, refused when both are linked on one server), the
  local overlap queries and the probes. SyncLinkStore.RekeyAsync moves pairs and probes with
  the links in the same transaction.
- Contracts for detection, review, plans, the Integrate and MergeSequences jobs (kinds 25/26,
  High level, new detail steps) and the Upload all rule that keeps suspected, kept-apart,
  deleted, busy and server-born sequences here.
- Wire: POST photos/lookup, uploads into a target (IntoTarget/Copied, trailing and optional),
  frames/delete on the client, capabilities photo-lookup and upload-into, cached per remote.
- The trash plans and deletes accept the job that holds the sequence (its own hold is not
  Busy) and a frames version checked under the lease; a Background job never interrupts a
  running one.
- Settings for linking, the photo policy and projects; the en and it keys of design section 9.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-16 19:39:04 +01:00
1 parent 43719bb5c5
commit 283d04d9cd
57 files changed
+3302 -26

No files matched your search

+13 -2
View File
@@ -6,11 +6,22 @@ namespace Chronos.Protocol;
/// from the target sequence is answered the same way, without a frame (owner review 2, R6), unless <see cref="Restore"/>
/// asks to file it there again: only an explicit user action sends it (the admin panel's "Upload again"), never sync or a
/// watch folder, and the completion repeats it (<c>complete?restore=true</c>). Filing it drops the photo's tombstone.
/// <para>
/// <see cref="IntoTarget"/> (owner review 6, #73; capability <see cref="ServerCapabilities.UploadInto"/>) files the photo into
/// <see cref="SequenceId"/> even when another sequence of the served archive holds it: the server copies its own file into
/// the target, no bytes on the wire, and answers <see cref="StartUploadResponse.Copied"/>. The caller must own the target,
/// be an admin or hold the Edit right; never with <see cref="Restore"/>.
/// </para>
/// </summary>
public sealed record StartUploadRequest(Guid? SequenceId, string FileName, long Size, string Sha256, DateTime? CapturedAt, string? SessionKey,
bool Restore = false);
bool Restore = false, bool IntoTarget = false);
public sealed record StartUploadResponse(Guid? UploadId, int ChunkSize, IReadOnlyList<int> Received, bool AlreadyExists, Guid? FrameId);
/// <summary>
/// The answer to <c>POST /api/v1/uploads</c>. <see cref="Copied"/>: the server filed the photo into the target from a file it
/// held in another sequence (<see cref="StartUploadRequest.IntoTarget"/>); <see cref="FrameId"/> is the new frame.
/// </summary>
public sealed record StartUploadResponse(Guid? UploadId, int ChunkSize, IReadOnlyList<int> Received, bool AlreadyExists, Guid? FrameId,
bool Copied = false);
/// <summary>Error codes of the frame upload calls that clients act on.</summary>
public static class UploadErrors