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:
1 parent
e3cbe30b29
commit
03d32f18d3
51 files changed
+4917
-108
No files matched your search
@@ -1,3 +1,4 @@
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Data.Migrations;
|
||||
using Chronos.Data.Tests.Infrastructure;
|
||||
using Chronos.Testing;
|
||||
@@ -9,7 +10,7 @@ public abstract class MigrationTests(TestContext context) : RepositoryTest(conte
|
||||
private static readonly string[] Tables =
|
||||
[
|
||||
"archives", "sequences", "frames", "renders", "jobs", "media_cards", "import_history", "users", "tokens",
|
||||
"render_nodes", "settings", "tags", "sequence_tags", "audit_log", "uploads", "schedules", "frame_removals",
|
||||
"render_nodes", "settings", "tags", "sequence_tags", "audit_log", "uploads", "schedules", "frame_removals", "projects", "project_versions",
|
||||
];
|
||||
|
||||
[Test]
|
||||
@@ -41,6 +42,67 @@ public abstract class MigrationTests(TestContext context) : RepositoryTest(conte
|
||||
Assert.True(recorded[0].GetDateTimeOffset(2) > DateTimeOffset.UtcNow.AddMinutes(-5));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task ProjectsKeepOneMainAndOneLiveNamePerSequence()
|
||||
{
|
||||
var chronos = await OpenChronosAsync();
|
||||
var archive = TestData.Archive("Main");
|
||||
await chronos.Archives.UpsertAsync(archive, Ct);
|
||||
var sequence = TestData.Sequence(archive.Id);
|
||||
await chronos.Sequences.UpsertAsync(sequence, Ct);
|
||||
var now = DateTimeOffset.UtcNow;
|
||||
SequenceProject Project(string name, bool main) => new() { Id = Guid.CreateVersion7(), SequenceId = sequence.Id, Name = name, IsMain = main, CreatedAt = now, UpdatedAt = now };
|
||||
|
||||
var main = Project("Main", true);
|
||||
await chronos.Projects.InsertAsync(main, Ct);
|
||||
await Assert.ThrowsAsync<DatabaseException>(() => chronos.Projects.InsertAsync(Project("Other main", true), Ct));
|
||||
var vertical = Project("Vertical", false);
|
||||
await chronos.Projects.InsertAsync(vertical, Ct);
|
||||
await Assert.ThrowsAsync<DatabaseException>(() => chronos.Projects.InsertAsync(Project("Vertical", false), Ct));
|
||||
// A deleted project gives its name back.
|
||||
await chronos.Projects.UpdateAsync(vertical with { DeletedAt = now }, Ct);
|
||||
await chronos.Projects.InsertAsync(Project("Vertical", false), Ct);
|
||||
|
||||
// Versions: one number each, settings kept byte for byte, and they go with the sequence.
|
||||
const string settings = "{\n \"version\": 1,\n \"exposure\": {}\n}";
|
||||
var version = new ProjectVersion
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
ProjectId = main.Id,
|
||||
Number = 1,
|
||||
Kind = ProjectVersionKind.Imported,
|
||||
SettingsJson = settings,
|
||||
ContentHash = new string('0', 64),
|
||||
FramesVersion = 3,
|
||||
CreatedAt = now,
|
||||
StoredAt = now,
|
||||
};
|
||||
await chronos.Projects.InsertVersionAsync(version, Ct);
|
||||
await Assert.ThrowsAsync<DatabaseException>(() => chronos.Projects.InsertVersionAsync(version with { Id = Guid.CreateVersion7() }, Ct));
|
||||
var stored = Assert.NotNull(await chronos.Projects.GetVersionAsync(version.Id, Ct));
|
||||
Assert.Equal(settings, stored.SettingsJson);
|
||||
Assert.Equal((ProjectVersionKind.Imported, 3), (stored.Kind, stored.FramesVersion));
|
||||
Assert.True(await chronos.Projects.AdvanceHeadAsync(main.Id, 0, version.Id, 1, now, Ct));
|
||||
Assert.False(await chronos.Projects.AdvanceHeadAsync(main.Id, 0, version.Id, 1, now, Ct), "the head moved already");
|
||||
|
||||
var render = new Render
|
||||
{
|
||||
Id = Guid.CreateVersion7(),
|
||||
SequenceId = sequence.Id,
|
||||
PresetName = "MJPEG",
|
||||
OutputPath = "x/exports/a.avi",
|
||||
Created = now,
|
||||
ProjectId = main.Id,
|
||||
ProjectVersionId = version.Id,
|
||||
};
|
||||
await chronos.Renders.InsertAsync(render, Ct);
|
||||
Assert.Equal((main.Id, version.Id), ((await chronos.Renders.GetAsync(render.Id, Ct))!.ProjectId, (await chronos.Renders.GetAsync(render.Id, Ct))!.ProjectVersionId));
|
||||
|
||||
await chronos.Sequences.DeleteAsync(sequence.Id, Ct);
|
||||
Assert.Empty(await chronos.Projects.ListBySequenceAsync(sequence.Id, includeDeleted: true, Ct));
|
||||
Assert.Null(await chronos.Projects.GetVersionAsync(version.Id, Ct));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public async Task AppliesOnlyPendingMigrations()
|
||||
{
|
||||
|
||||
Reference in new issue
Block a user