feat(copies): engine composition, automatic photos, metered hold and App wiring (owner review 6, P5)

CopyEngine puts the planners together behind ICopyEngine so the App can find,
compare, integrate, merge, link, unlink and keep pairs apart. It also moves
photos that one side deleted to the other side's trash. Each trash step
re-reads both sides when applied, and nothing moves if any photo was restored
since the dry run. The sync agent now queues the new photos of pairs that were
integrated with automatic photos, both ways, at background priority. Failures
back off, and three in a row are reported so the pair can show "not sent". On
a metered connection, integrations are held like other server transfers.
AppServices builds the engine and registers the Integrate and Merge handlers.
A CopyWatch looks for local copies after start and after jobs that change
photos. Merges wait for workspace work that has not been sent home.

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 12:03:56 +01:00
1 parent 461dfcf4a3
commit 96b5b4078b
11 files changed
+1377 -8

No files matched your search

@@ -430,6 +430,34 @@ public sealed partial class WorkspaceHost
return [.. (await ListAsync(cancellationToken).ConfigureAwait(false)).Where(e => e.SequenceId == sequenceId)];
}
/// <summary>
/// Whether a workspace project whose home is <paramref name="sequenceId"/> in this PC's archive holds work not sent home
/// (owner review 6, #73: a merge that removes the sequence waits for it): versions not pushed, or changes not saved as a
/// version. While the workspace folder moves, or when a project's state cannot be read, the answer is yes (the safe
/// side); a workspace that is off holds none.
/// </summary>
public async Task<bool> HasUnsentWorkAsync(Guid sequenceId, CancellationToken cancellationToken = default)
{
if (!IsEnabled) return false;
try
{
EnsureNotMoving();
foreach (var entry in await ListAsync(cancellationToken).ConfigureAwait(false))
{
if (entry.SequenceId != sequenceId || !entry.Home.IsArchive) continue;
if (!entry.IsReadable) return true;
var status = await StatusAsync(entry.ProjectId, askHome: false, cancellationToken).ConfigureAwait(false);
if (status.Ahead > 0 || (status.Modified && !status.ReadOnly)) return true;
}
return false;
}
catch (Exception ex) when (ex is not OperationCanceledException and not OutOfMemoryException)
{
Log.Info("workspace", $"Whether sequence {sequenceId} has workspace work not sent could not be read: {ex.Message}");
return true;
}
}
/// <summary>A workspace project by id (damaged or newer when this Chronos cannot read its working state); null when the workspace has none.</summary>
/// <exception cref="WorkspaceException">The workspace folder is being moved (<c>Errors.Workspace.Moving</c>).</exception>
public Task<WorkspaceEntry?> FindAsync(Guid projectId, CancellationToken cancellationToken = default) => Task.Run(async () =>