fix(workspace): a cancelled copy clears only media no other copy writes; a deletion keeps late versions

Owner review 2, phase 5a, fix round 5.

- A cancelled workspace copy clears its partial media only under the project's
  lease, after checking again that the job is still cancelled, that no other
  copy of the same root and project is queued, running or paused, and that no
  copy in this process is writing. The engine now waits for a paused job's run
  to end before calling the cancel handler, so the clean-up is never skipped.
- The clean-up never recreates a project folder that was removed meanwhile
  (the lease no longer creates the folder). The next list removes a project
  folder that holds only lease files nobody holds, older than the lease.
- A Main this Chronos cannot read (newer or damaged) refuses the open at once
  only when nothing else can be offered. Otherwise Open in workspace lists it
  disabled, with the reason as its tooltip. The refusal's action tooltip is
  now Remove copy.
- The removal plan counts a conflict the same way the sync status does: a
  conflict that a settling replay took past its commit point is not work
  left.
- A healed record is stamped after both the record's time and the index's, so
  the next rename made elsewhere is taken.
- A trash folder holds back the rebuild of a lost record only when it is this
  sequence's deletion: its record names this sequence or cannot be read, or it
  has no record, is within a one-day grace and holds no version of another
  project. What was seen of folders that are gone or have a record again is
  forgotten.
- When a deletion wins, version files pushed into the live folder before the
  deletion arrived are moved beside the deleted record in the trash, never
  deleted.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Alby96andClaude Opus 5.5 committed 2026-11-03 15:10:44 +01:00
1 parent 93afe71639
commit 7692ab402e
16 files changed
+750 -61

No files matched your search

@@ -308,6 +308,34 @@ public sealed class WorkspaceHostTests(TestContext context)
Assert.Empty(host.Store.List());
}
[Test]
public async Task AConflictASettlingReplayTookPastItsCommitPointIsNoWorkLeftForTheRemoval()
{
await using var bed = await WorkspaceTestBed.CreateAsync(context, frames: 4);
var host = bed.Host(new AppSettings { WorkspaceAutoSync = false });
var mainId = await bed.CheckoutAsync(host);
var project = host.Store.Find(mainId)!;
var basis = project.ReadBundle().Workspace!.Base!;
var conflict = $$"""
"conflict": { "theirsVersionId": "{{basis.VersionId}}", "theirsNumber": {{basis.Number}}, "baseVersionId": "{{Guid.CreateVersion7()}}",
"mine": [], "differences": [], "found": "2026-11-01T10:00:00+00:00" }
""";
// A take of the library's values cut after its base moved (before sync.json said so): the choice is applied.
await File.WriteAllTextAsync(project.SyncPath,
$$"""{ {{conflict}}, "replay": { "ontoBase": "{{basis.VersionId}}", "replaced": [], "replayed": [], "adopted": [], "settles": true } }""");
Assert.NotNull(project.ReadSync().Conflict, "still in sync.json");
Assert.Null(project.OpenConflict());
Assert.Null((await host.StatusAsync(mainId)).Conflict);
var plan = await host.PlanRemovalAsync(mainId);
Assert.True(plan is { Conflict: false, IsSafe: true }, "counted as the status reads it");
// A conflict still waiting for a choice counts.
await File.WriteAllTextAsync(project.SyncPath, $$"""{ {{conflict}} }""");
Assert.NotNull(project.OpenConflict());
Assert.True((await host.PlanRemovalAsync(mainId)) is { Conflict: true, IsSafe: false });
}
[Test]
public async Task ACopyOfAProjectDeletedInTheLibraryReadsGoneAndGoesOnlyWhenDiscarded()
{