feat(copies): detection and sync integration (owner review 6, P1b)

A refresh no longer links copies by content behind the user's back. After the
gate is released, CopyFinder looks for copies whose ids differ: the server's
photo lookup (or 1.1's gate and the hints on an older server), session keys,
and an exact comparison by manifest, bounded per refresh and remembered in
copy_probes so nothing is compared twice while neither side moves. What a pair
becomes is the Link matches setting's call: asked by default, linked by itself
only as the setting allows, through a compare-and-set that a Keep apart wins.
Local detection finds copies inside this PC's archives and never links them.

SyncService gives every link its pair, adds Unlink (kept apart, observation
kept), marks pairs whose server sequence answers 404 (once per refresh, twice
reads deleted, never on an address key or in a 404 sweep), keeps deletion
counts current at each comparison, writes an Integrate's agreed details to both
sides by content (ApplyAgreedAsync) and queues uploads at a given priority.
CopyReviewBuilder assembles what the Compare dialog shows.

Refs #73

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-17 10:25:25 +01:00
1 parent 9912baf78a
commit ade908cb6d
11 files changed
+2035 -89

No files matched your search

@@ -2,6 +2,7 @@ using Chronos.Core.Localization;
using Chronos.Core.Model;
using Chronos.Core.Project;
using Chronos.Data.Archiving;
using Chronos.Data.Copies;
using Chronos.Data.Sync;
using Chronos.Data.Tests.Archiving;
using Chronos.Protocol;
@@ -763,14 +764,14 @@ public sealed class SyncServiceTests(TestContext context)
other.FirstCapture = local.FirstCapture;
other.CameraModel = local.CameraModel;
await f.RefreshAsync();
await f.RefreshAsync(new SyncPolicy { Linking = CopyLinking.WhenHalfShared });
var entry = await f.EntryAsync("Comet");
Assert.Equal(remote.Id, entry.Link?.RemoteId);
Assert.Equal((0, 0), (entry.Link!.MissingRemote, entry.Link.MissingLocal));
Assert.Null((await f.EntryAsync("Other card")).Local);
var manifests = f.Remote.ManifestCalls;
await f.RefreshAsync();
await f.RefreshAsync(new SyncPolicy { Linking = CopyLinking.WhenHalfShared });
Assert.Equal(manifests, f.Remote.ManifestCalls);
}