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
@@ -5,6 +5,7 @@ using Chronos.Core.Project;
|
||||
using Chronos.Core.Video;
|
||||
using Chronos.Data.Archiving.Jobs;
|
||||
using Chronos.Data.Processing;
|
||||
using Chronos.Data.Projects;
|
||||
|
||||
namespace Chronos.App.Editor;
|
||||
|
||||
|
||||
@@ -4,6 +4,7 @@ using Chronos.Core.Imaging;
|
||||
using Chronos.Core.Model;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Archiving.Jobs;
|
||||
using Chronos.Data.Projects;
|
||||
|
||||
namespace Chronos.App.Editor;
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
using Chronos.Data.Projects;
|
||||
using System.IO;
|
||||
using System.Text.Json;
|
||||
using Chronos.Core.Advice;
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Projects;
|
||||
|
||||
namespace Chronos.App.Editor;
|
||||
|
||||
|
||||
@@ -1,82 +0,0 @@
|
||||
using System.Text.Json.Nodes;
|
||||
using Chronos.Core.Project;
|
||||
using Chronos.Data.Sync;
|
||||
|
||||
namespace Chronos.App.Editor;
|
||||
|
||||
/// <summary>
|
||||
/// Three-way merge of projects: the editor's edit (<c>ours</c>) and a change stored meanwhile by someone else
|
||||
/// (<c>theirs</c>: an analysis filling Auto values, another client through the server), both made from <c>basis</c>.
|
||||
/// Values are compared member by member down the JSON tree; a member only one side changed takes that side's value, a
|
||||
/// member both changed takes the editor's (the user is looking at it). <see cref="Conflicts"/> lists those members for
|
||||
/// a source that asks the user instead (a server sequence, BRIEF §14.5).
|
||||
/// </summary>
|
||||
public static class ProjectMerge
|
||||
{
|
||||
public static ProjectSettings Merge(ProjectSettings basis, ProjectSettings ours, ProjectSettings theirs)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(basis);
|
||||
ArgumentNullException.ThrowIfNull(ours);
|
||||
ArgumentNullException.ThrowIfNull(theirs);
|
||||
return new Rebase(basis, theirs).Apply(ours);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The members both sides changed to different values, in document order: the path below the project
|
||||
/// ("exposure.deflickerWindow.manual"), the editor's value and theirs as JSON (null when absent).
|
||||
/// </summary>
|
||||
public static IReadOnlyList<SettingsDifference> Conflicts(ProjectSettings basis, ProjectSettings ours, ProjectSettings theirs)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(basis);
|
||||
ArgumentNullException.ThrowIfNull(ours);
|
||||
ArgumentNullException.ThrowIfNull(theirs);
|
||||
var conflicts = new List<SettingsDifference>();
|
||||
Collect(JsonNode.Parse(basis.ToJson()), JsonNode.Parse(ours.ToJson()), JsonNode.Parse(theirs.ToJson()), string.Empty, conflicts);
|
||||
return conflicts;
|
||||
}
|
||||
|
||||
/// <summary>True when both projects store the same values.</summary>
|
||||
public static bool SameValues(ProjectSettings a, ProjectSettings b) => a.ToJson() == b.ToJson();
|
||||
|
||||
private static JsonNode? Merge(JsonNode? basis, JsonNode? ours, JsonNode? theirs)
|
||||
{
|
||||
if (JsonNode.DeepEquals(ours, basis)) return theirs?.DeepClone();
|
||||
if (JsonNode.DeepEquals(theirs, basis) || JsonNode.DeepEquals(theirs, ours)) return ours?.DeepClone();
|
||||
if (ours is not JsonObject mine || theirs is not JsonObject other) return ours?.DeepClone();
|
||||
var common = basis as JsonObject;
|
||||
var merged = new JsonObject();
|
||||
foreach (var name in mine.Select(p => p.Key).Union(other.Select(p => p.Key)))
|
||||
{
|
||||
var value = Merge(common?[name], mine[name], other[name]);
|
||||
if (value is not null || mine.ContainsKey(name)) merged[name] = value;
|
||||
}
|
||||
return merged;
|
||||
}
|
||||
|
||||
/// <summary>The members <see cref="Merge(JsonNode?, JsonNode?, JsonNode?)"/> settles for the editor although both sides changed them.</summary>
|
||||
private static void Collect(JsonNode? basis, JsonNode? ours, JsonNode? theirs, string path, List<SettingsDifference> conflicts)
|
||||
{
|
||||
if (JsonNode.DeepEquals(ours, basis) || JsonNode.DeepEquals(theirs, basis) || JsonNode.DeepEquals(theirs, ours)) return;
|
||||
if (ours is JsonObject mine && theirs is JsonObject other)
|
||||
{
|
||||
var common = basis as JsonObject;
|
||||
foreach (var name in mine.Select(p => p.Key).Union(other.Select(p => p.Key)))
|
||||
Collect(common?[name], mine[name], other[name], path.Length == 0 ? name : path + "." + name, conflicts);
|
||||
return;
|
||||
}
|
||||
conflicts.Add(new SettingsDifference(path.Length == 0 ? "settings" : path, ours?.ToJsonString(), theirs?.ToJsonString()));
|
||||
}
|
||||
|
||||
/// <summary>One outside change (<paramref name="basis"/> → <paramref name="theirs"/>) applied to any number of projects made from the basis.</summary>
|
||||
public sealed class Rebase(ProjectSettings basis, ProjectSettings theirs)
|
||||
{
|
||||
private readonly JsonNode? _basis = JsonNode.Parse(basis.ToJson());
|
||||
private readonly JsonNode? _theirs = JsonNode.Parse(theirs.ToJson());
|
||||
|
||||
public ProjectSettings Apply(ProjectSettings ours)
|
||||
{
|
||||
ArgumentNullException.ThrowIfNull(ours);
|
||||
return ProjectSettings.FromJson(Merge(_basis, JsonNode.Parse(ours.ToJson()), _theirs)?.ToJsonString() ?? "{}");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,3 +1,4 @@
|
||||
using Chronos.Data.Projects;
|
||||
using System.Collections.Concurrent;
|
||||
using System.IO;
|
||||
using System.Net;
|
||||
|
||||
Reference in new issue
Block a user