feat(project): settle phase 4 contracts: conditional settings format, transforms, look, output size
Groundwork for owner review 1, phase 4, so the parallel packages build on fixed contracts and strings. - Settings: camera rotate/mirror/flip/straighten and a look, declared after the existing members and omitted at default. ToJson writes the lowest format that renders the same (2 only while a transform or look is used), so projects without them keep byte-identical text and hash; an old-build simulation test proves the order survives an older build's round trip. - RenderSize and RenderRules: proportions win over a fixed preset box, and the routing format a job needs. - FrameOrientation, CropFrame, OrientationEdit, LookFilter (identity) and FrameFinish (look, then knee) wired into the render pipeline and preview; RenderGeometry gains view-frame members equivalent to today. - Protocol trailing members for node, job and server formats; SyncText keys; EditPath counts transforms and the look as hand values. - New en/it strings and tooltips, five icons, test fixtures moved to v3 as the first unread format, and the 18 DECISIONS rows. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
4ad29977b9
commit
e4364c4f25
43 files changed
+1544
-178
No files matched your search
@@ -96,13 +96,13 @@ public sealed class ProjectBundleTests(TestContext context)
|
||||
{
|
||||
var workspace = new BundleWorkspace(Guid.CreateVersion7(), "Main", true, new BundleHome(BundleHome.ArchiveKind, SequenceId, ArchiveId), null,
|
||||
new BundleMedia(BundleMedia.Proxies, 0));
|
||||
var json = (Sample() with { Workspace = workspace }).ToJson().Replace("\"version\": 1", "\"version\": 2", StringComparison.Ordinal);
|
||||
var json = (Sample() with { Workspace = workspace }).ToJson().Replace("\"version\": 1", "\"version\": 3", StringComparison.Ordinal);
|
||||
var bundle = ProjectBundle.Parse(json);
|
||||
Assert.True(bundle.IsReadOnly);
|
||||
Assert.True(bundle.Project.IsNewerFormat);
|
||||
Assert.Equal(0.8, bundle.Project.Exposure.DeflickerStrength.Resolve(1.0));
|
||||
|
||||
var plain = Sample().ToJson().Replace("\"version\": 1", "\"version\": 2", StringComparison.Ordinal);
|
||||
var plain = Sample().ToJson().Replace("\"version\": 1", "\"version\": 3", StringComparison.Ordinal);
|
||||
Assert.Throws<InvalidDataException>(() => ProjectBundle.Parse(plain));
|
||||
}
|
||||
|
||||
|
||||
@@ -131,7 +131,7 @@ public sealed class ProjectContentTests
|
||||
Assert.Equal(saved, ProjectContent.Rebind(saved, Frames(Photo(7))));
|
||||
Assert.False(ProjectContent.SameChoices(saved, current, Frames(Photo(7))));
|
||||
// A newer Chronos's settings are its own to rename.
|
||||
var newer = """{ "version": 2, "pendingFrames": [ { "size": 1001, "capturedAt": "2026-09-28T18:00:10", "excluded": true } ] }""";
|
||||
var newer = """{ "version": 3, "pendingFrames": [ { "size": 1001, "capturedAt": "2026-09-28T18:00:10", "excluded": true } ] }""";
|
||||
Assert.Equal(newer, ProjectContent.Rebind(newer, now));
|
||||
}
|
||||
|
||||
@@ -329,12 +329,12 @@ public sealed class ProjectContentTests
|
||||
[Test]
|
||||
public void SettingsOfANewerFormatAreReadOnlyAndKeptAsTheyAre()
|
||||
{
|
||||
var newer = """{ "version": 2, "excludedFrames": [1], "exposure": { "exposureOffsetEv": 1.5 }, "grade": { "look": "film" } }""";
|
||||
var newer = """{ "version": 3, "excludedFrames": [1], "exposure": { "exposureOffsetEv": 1.5 }, "grade": { "look": "film" } }""";
|
||||
Assert.Throws<InvalidDataException>(() => ProjectSettings.FromJson(newer));
|
||||
var read = ProjectSettings.FromJson(newer, allowNewer: true);
|
||||
Assert.True(read.IsNewerFormat);
|
||||
Assert.Equal(1.5, read.Exposure.ExposureOffsetEv);
|
||||
Assert.Equal(2, ProjectContent.FormatOf(newer));
|
||||
Assert.Equal(3, ProjectContent.FormatOf(newer));
|
||||
Assert.Equal(1, ProjectContent.FormatOf("""{ "exposure": {} }"""));
|
||||
|
||||
// Its positions are a newer Chronos's to translate: only the text is made canonical.
|
||||
|
||||
@@ -77,7 +77,7 @@ public sealed class ProjectSettingsTests
|
||||
Assert.Equal("{date} {title} - {preset}", partial.Export.NameTemplate);
|
||||
Assert.SequenceEqual(new[] { 0.0, 1.0 }, partial.Timing.RemapCurve.Select(p => p.X));
|
||||
Assert.Equal(9, partial.Stack.Length);
|
||||
Assert.Equal(ProjectSettings.CurrentVersion, partial.Version);
|
||||
Assert.Equal(ProjectSettings.BaseVersion, partial.Version);
|
||||
|
||||
// An explicit null clears a nullable value; arrays are replaced, not merged.
|
||||
var cleared = ProjectSettings.FromJson("""{ "exposure": { "highlightKnee": null }, "timing": { "remapCurve": [ { "x": 0, "y": 0.5 } ] } }""");
|
||||
@@ -470,4 +470,156 @@ public sealed class ProjectSettingsTests
|
||||
Assert.Equal(24, s.GopLength);
|
||||
Assert.Equal(10, s.BitDepth);
|
||||
}
|
||||
|
||||
/// <summary>SHA-256 of the default project's canonical text, as format-1 builds write it: none of phase 4's members, version 1.</summary>
|
||||
private const string DefaultProjectHash = "df0b0f50b113475ece3753a80df0be05cc281cdaa1fa08a73a438ea9161358e0";
|
||||
|
||||
[Test]
|
||||
public void ProjectsWithoutTheNewMembersKeepTheirTextAndHash()
|
||||
{
|
||||
var defaults = new ProjectSettings().ToJson();
|
||||
Assert.Equal(DefaultProjectHash, ProjectContent.Hash(ProjectContent.Canonical(defaults)));
|
||||
Assert.Equal(OldBuild.Write(new OldProject()), defaults);
|
||||
Assert.Contains("\"version\": 1", defaults);
|
||||
foreach (var member in new[] { "rotate", "mirror", "flip", "straighten", "\"look\"" })
|
||||
Assert.False(defaults.Contains(member, StringComparison.Ordinal), member);
|
||||
|
||||
// A project written by a format-1 build reads and writes back the same, byte for byte.
|
||||
var older = new ProjectSettings
|
||||
{
|
||||
Camera = new CameraSettings { Crop = [0.1, 0.2, 0.5, 0.6], Aspect = new Auto<string>().WithManual("9:16"), Keyframes = [new CameraKey(3, 0.4, 0.5, 1.5, 2)] },
|
||||
Exposure = new ExposureSettings { ExposureOffsetEv = 0.3 },
|
||||
}.ToJson();
|
||||
Assert.Equal(older, ProjectContent.Canonical(older));
|
||||
Assert.Equal(older, OldBuild.Write(OldBuild.Read(older)));
|
||||
Assert.Equal(ProjectSettings.BaseVersion, ProjectContent.FormatOf(older));
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheNewMembersRoundTripAndRaiseTheFormatOnlyWhileUsed()
|
||||
{
|
||||
var plain = new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.5 } };
|
||||
Assert.Equal(ProjectSettings.BaseVersion, plain.RequiredFormat);
|
||||
var turned = plain with { Camera = plain.Camera with { Rotate = 90, Mirror = true, Flip = true, Straighten = -3.5 } };
|
||||
var looked = plain with { Look = new LookSettings { Filter = "sepia", Strength = 0.6 } };
|
||||
foreach (var settings in new[] { turned, looked, plain with { Camera = new CameraSettings { Straighten = 1 } }, plain with { Camera = new CameraSettings { Flip = true } } })
|
||||
{
|
||||
Assert.Equal(2, settings.RequiredFormat);
|
||||
var json = settings.ToJson();
|
||||
Assert.Contains("\"version\": 2", json);
|
||||
var back = ProjectSettings.FromJson(json);
|
||||
Assert.Equal(2, back.Version);
|
||||
Assert.False(back.IsNewerFormat);
|
||||
Assert.Equal(json, back.ToJson());
|
||||
}
|
||||
var read = ProjectSettings.FromJson(turned.ToJson());
|
||||
Assert.Equal((90, true, true, -3.5), (read.Camera.Rotate, read.Camera.Mirror, read.Camera.Flip, read.Camera.Straighten));
|
||||
Assert.Equal((1, true), (read.Camera.Turns, read.Camera.IsOriented));
|
||||
var look = Assert.NotNull(ProjectSettings.FromJson(looked.ToJson()).Look);
|
||||
Assert.Equal(("sepia", (double?)0.6), (look.Filter, look.Strength));
|
||||
|
||||
// Taken away again, the project is format 1 with the text it had before.
|
||||
var undone = ProjectSettings.FromJson(turned.ToJson()) with { Camera = plain.Camera };
|
||||
Assert.Equal(ProjectSettings.BaseVersion, undone.RequiredFormat);
|
||||
Assert.Equal(plain.ToJson(), undone.ToJson());
|
||||
Assert.Equal(plain.ToJson(), (ProjectSettings.FromJson(looked.ToJson()) with { Look = null }).ToJson());
|
||||
|
||||
// An identity look and a whole turn need nothing newer; an unknown look does (it is a newer Chronos's).
|
||||
Assert.Equal(1, (plain with { Look = new LookSettings { Filter = "none" } }).RequiredFormat);
|
||||
Assert.Equal(1, (plain with { Look = new LookSettings { Filter = "mono", Strength = 0 } }).RequiredFormat);
|
||||
Assert.Equal(1, (plain with { Camera = new CameraSettings { Rotate = 360 } }).RequiredFormat);
|
||||
Assert.Equal(2, (plain with { Look = new LookSettings { Filter = "film" } }).RequiredFormat);
|
||||
Assert.Equal(3, new CameraSettings { Rotate = -90 }.Turns);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void TheNewMembersComeAfterTheOldOnesSoAnOlderBuildWritesThemBackInPlace()
|
||||
{
|
||||
var settings = new ProjectSettings
|
||||
{
|
||||
Camera = new CameraSettings { Crop = [0.2, 0, 0.6, 1], Keyframes = [new CameraKey(1, 0.5, 0.5, 2, 0)], Rotate = 270, Straighten = 2.25 },
|
||||
HeroFrame = 4,
|
||||
Look = new LookSettings { Filter = "warm" },
|
||||
};
|
||||
var canonical = ProjectContent.Canonical(settings.ToJson());
|
||||
|
||||
// A format-1 build keeps them as members it does not know, and writes them where they were.
|
||||
var old = OldBuild.Read(canonical);
|
||||
Assert.True(old.Camera.Extra!.ContainsKey("rotate") && old.Extra!.ContainsKey("look"));
|
||||
Assert.Equal(canonical, OldBuild.Write(old));
|
||||
Assert.Equal(ProjectContent.Hash(canonical), ProjectContent.Hash(OldBuild.Write(old)));
|
||||
var camera = System.Text.Json.Nodes.JsonNode.Parse(canonical)!["camera"]!.AsObject().Select(p => p.Key).ToList();
|
||||
Assert.SequenceEqual(["crop", "aspect", "offsetX", "offsetY", "keyframes", "rotate", "straighten"], camera);
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void ANewerFormatStaysReadOnlyAndKeepsItsNumber()
|
||||
{
|
||||
const string newer = """{ "version": 3, "camera": { "rotate": 90 }, "look": { "filter": "film", "grain": 0.2 } }""";
|
||||
Assert.Throws<InvalidDataException>(() => ProjectSettings.FromJson(newer));
|
||||
var read = ProjectSettings.FromJson(newer, allowNewer: true);
|
||||
Assert.True(read.IsNewerFormat);
|
||||
Assert.Equal(3, read.WrittenFormat);
|
||||
var canonical = ProjectContent.Canonical(newer);
|
||||
Assert.Equal(3, ProjectContent.FormatOf(canonical));
|
||||
Assert.Contains("\"grain\": 0.2", canonical);
|
||||
Assert.Equal(canonical, ProjectContent.Canonical(canonical));
|
||||
|
||||
// A format-2 project is this Chronos's own (written as the format it needs); text without a version is format 1.
|
||||
Assert.False(ProjectSettings.FromJson("""{ "version": 2 }""").IsNewerFormat);
|
||||
Assert.Equal(1, ProjectSettings.FromJson("""{ "version": 2 }""").WrittenFormat);
|
||||
Assert.Equal(1, ProjectContent.FormatOf("""{ "camera": {} }"""));
|
||||
Assert.Equal(1, ProjectContent.FormatOf(null));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// The settings as a format-1 build reads and writes them: its camera without phase 4's members and its project without
|
||||
/// the look, with the same serialiser options. What it does not know lands in <c>Extra</c>.
|
||||
/// </summary>
|
||||
private static class OldBuild
|
||||
{
|
||||
public static OldProject Read(string json) => System.Text.Json.JsonSerializer.Deserialize(json, OldJson.Default.OldProject)!;
|
||||
|
||||
public static string Write(OldProject project) => System.Text.Json.JsonSerializer.Serialize(project, OldJson.Default.OldProject);
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>A format-1 build's camera (before owner review 1, phase 4).</summary>
|
||||
internal sealed record OldCamera
|
||||
{
|
||||
public double[]? Crop { get; init; }
|
||||
public Auto<string> Aspect { get; init; } = new();
|
||||
public double OffsetX { get; init; }
|
||||
public double OffsetY { get; init; }
|
||||
public IReadOnlyList<CameraKey> Keyframes { get; init; } = [];
|
||||
|
||||
[System.Text.Json.Serialization.JsonExtensionData]
|
||||
public Dictionary<string, System.Text.Json.JsonElement>? Extra { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>A format-1 build's project (before owner review 1, phase 4).</summary>
|
||||
internal sealed record OldProject
|
||||
{
|
||||
public int Version { get; init; } = 1;
|
||||
public TimingSettings Timing { get; init; } = new();
|
||||
public ExposureSettings Exposure { get; init; } = new();
|
||||
public MotionSettings Motion { get; init; } = new();
|
||||
public OldCamera Camera { get; init; } = new();
|
||||
public StackSettings Stack { get; init; } = new();
|
||||
public ExportSettings Export { get; init; } = new();
|
||||
public IReadOnlyList<int> ExcludedFrames { get; init; } = [];
|
||||
public int? HeroFrame { get; init; }
|
||||
public IReadOnlyList<PendingFrame>? PendingFrames { get; init; }
|
||||
|
||||
[System.Text.Json.Serialization.JsonExtensionData]
|
||||
public Dictionary<string, System.Text.Json.JsonElement>? Extra { get; set; }
|
||||
}
|
||||
|
||||
[System.Text.Json.Serialization.JsonSourceGenerationOptions(
|
||||
WriteIndented = true,
|
||||
PropertyNamingPolicy = System.Text.Json.Serialization.JsonKnownNamingPolicy.CamelCase,
|
||||
DefaultIgnoreCondition = System.Text.Json.Serialization.JsonIgnoreCondition.WhenWritingNull,
|
||||
UseStringEnumConverter = true,
|
||||
PropertyNameCaseInsensitive = true)]
|
||||
[System.Text.Json.Serialization.JsonSerializable(typeof(OldProject))]
|
||||
internal sealed partial class OldJson : System.Text.Json.Serialization.JsonSerializerContext;
|
||||
Reference in new issue
Block a user