feat(projects): workspace projects with linear versions, the local archive as their home

Owner review 2, phase 5a (R8): editing moves out of the library into a workspace on a fast disk, and a
sequence gets several projects, each with a linear version history pushed and pulled like git.

- Core: ProjectSettings keeps members a newer Chronos wrote (Extra) and reads a newer settings format
  read-only; ProjectContent is the portable form of a version (every frame position parked by photo,
  canonical text, SHA-256 content hash); ProjectBundle format 2 adds the workspace section, and a file
  without it is still written as format 1. JobKind.WorkspaceCopy = 20 (19 kept for Convert).
- Data: migration 0009 (projects, project_versions, the render's project columns); ProjectService on
  ArchiveService.Projects keeps projects as sidecars first (.chronos/projects/<id>/), then the index,
  under the sequence lease: create, rename, delete into the projects' trash, history, push with
  fast-forward, idempotent repeat, divergence and hash checks. Main is made from the sequence's settings
  and mirrored both ways, so every older code path keeps working; outside writes become "external"
  versions, a mirror a crash cut short is completed or merged. Full scans and rebuilds take the projects
  back from their sidecars.
- ProjectMerge moves from the App to Data/Projects, merges pending frames photo by photo and replays
  unpushed commits on a moved head.
- Workspaces: WorkspaceStore, WorkspaceSync (checkout, save, commit, push, pull with replay and merge,
  conflicts settled by keep mine / take server / save both, restore, status) and the WorkspaceCopy job
  (proxies copied hash-verified and resumable; originals refused until phase 5c).
- Renders of a project version place its positions on the frames and record the project and version.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
(cherry picked from commit c4c1802884e403db8759ed0501f770a67a047f20)
This commit is contained in:
Alby96 committed 2026-10-27 22:51:32 +01:00
1 parent e3cbe30b29
commit 03d32f18d3
51 files changed
+4917 -108

No files matched your search

@@ -64,6 +64,52 @@ public sealed class RenderJobTests(TestContext context)
Assert.Equal(3, (await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!.RenderedCount);
}
[Test]
public async Task AProjectVersionRendersWithItsPositionsPlacedOnTheFramesAndIsRecordedWithIt()
{
await using var fx = await ProcessingFixture.CreateAsync(context);
var sequence = await fx.AddAsync(Scene());
var frames = await fx.Db.Frames.ListBySequenceAsync(sequence.Id, cancellationToken: fx.Ct);
var photos = new FramePhotos(frames.Select(f => (f.Index, new FramePhoto(f.Sha256, f.Size, f.CapturedAt))));
var projects = fx.Archive.Service.Projects;
var vertical = await projects.CreateAsync(sequence.Id, "Vertical", cancellationToken: fx.Ct);
var head = await projects.HeadAsync(vertical.Id, fx.Ct);
// The version holds its positions parked by photo (the adopted frames are not hashed: size and capture time name them).
var settings = new ProjectSettings { ExcludedFrames = [3, 5], Timing = new TimingSettings { Mode = new Auto<TimingMode>().WithManual(TimingMode.Constant) } };
var portable = ProjectContent.ToPortable(settings, photos);
Assert.Empty(ProjectSettings.FromJson(portable).ExcludedFrames);
var draft = head with
{
Id = Guid.CreateVersion7(),
ParentId = head.Id,
Number = 2,
Kind = ProjectVersionKind.Commit,
SettingsJson = portable,
ContentHash = ProjectContent.Hash(portable),
StoredAt = null,
};
var version = (await projects.PushAsync(vertical.Id, draft, fx.Ct)).Version!;
await fx.StartEngineAsync();
var requests = ProcessingJobs.RenderVersion(sequence, version, Mjpeg with { Preset = new Auto<string>().WithManual("png-sequence") }, 96, 64);
var job = await fx.EnqueueAsync(requests.Single());
await fx.Archive.WaitForAsync(job.Id, JobState.Done, (int)TestTiming.Budget(60));
Assert.Equal(Frames - 2, Directory.GetFiles(Path.Combine(fx.Folder(sequence).Exports, "clip-PNG")).Length);
var render = (await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct)).Single();
Assert.Equal((vertical.Id, version.Id), (render.ProjectId, render.ProjectVersionId));
Assert.SequenceEqual([3, 5], ProjectSettings.FromJson(render.SettingsJson!).ExcludedFrames);
// A render of another project leaves the sequence's own settings alone.
Assert.Empty(ProjectSettings.FromJson((await fx.Db.Sequences.GetAsync(sequence.Id, fx.Ct))!.SettingsJson ?? "{}").ExcludedFrames);
// A job naming the version without its settings renders them too.
var named = Chronos.Protocol.ProtocolJson.Default.RenderJobParameters;
var parameters = System.Text.Json.JsonSerializer.Deserialize(requests[0].ParametersJson!, named)! with { SettingsJson = null };
var second = await fx.EnqueueAsync(requests[0] with { ParametersJson = System.Text.Json.JsonSerializer.Serialize(parameters, named) });
await fx.Archive.WaitForAsync(second.Id, JobState.Done, (int)TestTiming.Budget(60));
Assert.True((await fx.Db.Renders.ListBySequenceAsync(sequence.Id, fx.Ct)).All(r => r.ProjectVersionId == version.Id));
}
[Test]
public async Task FramesThisHostCannotDecodeRenderFromTheirProxies()
{