fix(workspace): phase 5a fix round 2, workspace sync and copy

A Save both, a recorded conflict and a damaged version file could each leave
a local version out of the chain or a copy half-made at the home. This round
makes every one of these end with nothing lost and nothing half done.

- Save both retry: a journaled copy somebody else sent a version to (or one
  deleted since) is left as it is, and a new copy takes every local version.
  A divergence met at the copy while sending also makes a new copy, once.
- Keep mine, Take server, or a pull that settles a conflict after a Save both
  was cut short first send the rest of the journaled versions to that copy,
  if it is still this workspace's. The journal is cleared at the commit point.
- A conflict of format met past local versions the home already stored
  (their answer lost) now moves the base onto them, like any other conflict.
  The conflict, the base and the chain then name one version. A save-both
  journal follows the base when it moves.
- A conflict recorded before stays while the home holds no version after
  the base. A base that has reached the conflict's head clears it.
- Take server no longer replays or sends the version it saves first when,
  replayed, that version holds only the server's values. It stays in
  versions/.replaced for the undo. The test checks the exact history again.
- Version files after the base that cannot be read, or that do not follow
  from it, are listed (WorkspaceProject.UnreadableVersions). The new state
  WorkspaceState.Damaged shows them. Commit, push, pull and resolve refuse to
  go past them. A damaged file whose version the home holds takes the home's
  copy at the next sync, and the damaged file is kept aside. Remove local
  copy counts these files as unsent.
- PushOutcome.TooLarge raises its own WorkspaceSyncException message. The
  desktop says Errors.Workspace.VersionTooLarge for it and for
  ProjectVersionTooLargeException when a local commit is too large.
- The editor maps LeaseUnavailableException from opening a busy project to
  Errors.Workspace.Busy.
- The copy job no longer deletes, during the pass, a proxy that the editor's
  current media name. RemoveStale removes it after the commit. A resumed run
  does not keep such a file as a frame whose photo changed.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-03 11:31:18 +01:00
1 parent 8256b72913
commit e23cba3ee1
18 files changed
+646 -88

No files matched your search

@@ -115,10 +115,17 @@ internal sealed class CuttingHome(IProjectHome home) : IProjectHome
/// <summary>The push (counted from 1) the home stores and whose answer is lost.</summary>
public int? LoseAnswer { get; set; }
/// <summary>What the home answers every push with, storing nothing (a home with a smaller limit, say); null to store.</summary>
public PushOutcome? Answer { get; set; }
/// <summary>The home answers it holds no versions after any number (an index taken back from an older backup).</summary>
public bool Forgets { get; set; }
public async Task<PushResult> PushAsync(Guid projectId, ProjectVersion version, CancellationToken cancellationToken)
{
var push = ++Pushes;
if (push == Refuse) throw new HomeUnavailableException("The home cannot be reached.");
if (Answer is { } answer) return new PushResult(answer, null, await home.HeadAsync(projectId, cancellationToken));
var result = await home.PushAsync(projectId, version, cancellationToken);
if (push == LoseAnswer) throw new HomeUnavailableException("The answer was lost.");
return result;
@@ -136,7 +143,7 @@ internal sealed class CuttingHome(IProjectHome home) : IProjectHome
home.GetVersionAsync(projectId, versionId, cancellationToken);
public Task<IReadOnlyList<ProjectVersion>> VersionsAfterAsync(Guid projectId, int afterNumber, int limit, CancellationToken cancellationToken) =>
home.VersionsAfterAsync(projectId, afterNumber, limit, cancellationToken);
Forgets ? Task.FromResult<IReadOnlyList<ProjectVersion>>([]) : home.VersionsAfterAsync(projectId, afterNumber, limit, cancellationToken);
public Task<IReadOnlyList<ProjectVersion>> HistoryAsync(Guid projectId, int? beforeNumber, int limit, CancellationToken cancellationToken) =>
home.HistoryAsync(projectId, beforeNumber, limit, cancellationToken);