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:
Alby96andClaude Opus 5.5 committed 2026-11-04 19:10:12 +01:00
1 parent 4ad29977b9
commit e4364c4f25
43 files changed
+1544 -178

No files matched your search

@@ -21,6 +21,55 @@ public sealed class ProjectMergeTests
private static PendingFrame Waiting(FramePhoto photo, bool excluded = false, bool hero = false) =>
new() { Sha256 = photo.Sha256, Size = photo.Size, CapturedAt = photo.CapturedAt, Excluded = excluded, Hero = hero };
[Test]
public void ATurnOnOneSideAndALookOnTheOtherMergeIntoFormatTwo()
{
var basis = new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.2 } };
var ours = basis with { Camera = basis.Camera with { Rotate = 90, Straighten = 1.5 } };
var theirs = basis with { Look = new LookSettings { Filter = "sepia", Strength = 0.6 } };
var result = ProjectMerge.MergeWithConflicts(basis, ours, theirs);
Assert.False(result.HasConflicts);
Assert.Equal((90, 1.5), (result.Merged.Camera.Rotate, result.Merged.Camera.Straighten));
Assert.Equal("sepia", result.Merged.Look?.Filter);
Assert.Equal(2, result.Merged.Version);
Assert.Contains("\"version\": 2", result.Merged.ToJson());
// One side takes the turn away while the other keeps the look: the format the members need, not the one taken.
var undone = ProjectMerge.MergeWithConflicts(result.Merged, result.Merged with { Camera = basis.Camera }, result.Merged with { Look = null }).Merged;
Assert.Equal(1, ProjectContent.FormatOf(undone.ToJson()));
Assert.Equal(basis.ToJson(), undone.ToJson());
}
[Test]
public void BothSidesCroppingGiveOneCropConflict()
{
var basis = new ProjectSettings { Camera = new CameraSettings { Aspect = new Auto<string>().WithManual("9:16") } };
var ours = basis with { Camera = basis.Camera with { Crop = [0.1, 0, 0.3, 0.9] } };
var theirs = basis with { Camera = basis.Camera with { Crop = [0.5, 0.05, 0.2, 0.6], Mirror = true } };
var result = ProjectMerge.MergeWithConflicts(basis, ours, theirs);
// The box is one value: never the x of one side and the width of the other.
Assert.SequenceEqual(["camera.crop"], result.Conflicts.Select(c => c.Path));
Assert.SequenceEqual([0.1, 0, 0.3, 0.9], Assert.NotNull(result.Merged.Camera.Crop));
Assert.True(result.Merged.Camera.Mirror);
Assert.SequenceEqual([0.5, 0.05, 0.2, 0.6], Assert.NotNull(
ProjectMerge.MergeWithConflicts(basis, ours, theirs, new HashSet<string> { "camera.crop" }).Merged.Camera.Crop));
}
[Test]
public void AFormatThreeSideIsNeverMerged()
{
var basis = new ProjectSettings { Camera = new CameraSettings { Rotate = 90 } };
var newer = ProjectSettings.FromJson("""{ "version": 3, "camera": { "rotate": 180 }, "look": { "filter": "film" } }""", allowNewer: true);
var mine = basis with { Look = new LookSettings { Filter = "warm" } };
Assert.Throws<NewerSettingsException>(() => ProjectMerge.MergeWithConflicts(basis, mine, newer));
Assert.Throws<NewerSettingsException>(() => ProjectMerge.MergeWithConflicts(basis, newer, mine));
Assert.Equal(3, ProjectMerge.MergeWithConflicts(basis, basis, newer).Merged.Version);
}
[Test]
public void EntriesOfOnePhotoMergeAsOneWithThePositionsOfBoth()
{
@@ -69,7 +118,7 @@ public sealed class ProjectMergeTests
public void SettingsOfANewerChronosAreNeverMergedWithThisOnes()
{
var basis = new ProjectSettings { Exposure = new ExposureSettings { ExposureOffsetEv = 0.1 } };
var newer = ProjectSettings.FromJson("""{ "version": 2, "exposure": { "exposureOffsetEv": 0.5 }, "grade": { "look": "film" } }""", allowNewer: true);
var newer = ProjectSettings.FromJson("""{ "version": 3, "exposure": { "exposureOffsetEv": 0.5 }, "grade": { "look": "film" } }""", allowNewer: true);
var mine = basis with { Stack = new StackSettings { Mode = StackSetting.Median } };
// Both changed: refused, whichever side the newer one is, in a replay too.
@@ -327,7 +327,7 @@ public abstract class ProjectRecoveryTests(TestContext context) : DatabaseTest(c
var folder = fx.Paths.Sequence(sequence.Folder);
// A newer Chronos on another PC sharing the archive pushes version 2 in its settings format, and mirrors it.
var settings = """{ "version": 2, "exposure": { "exposureOffsetEv": 0.5 }, "futureThing": true }""";
var settings = """{ "version": 3, "exposure": { "exposureOffsetEv": 0.5 }, "futureThing": true }""";
var now = DateTimeOffset.UtcNow;
var future = new ProjectVersion
{
@@ -339,7 +339,7 @@ public abstract class ProjectRecoveryTests(TestContext context) : DatabaseTest(c
ClientName = "newer",
SettingsJson = settings,
ContentHash = ProjectContent.Hash(settings),
SettingsFormat = 2,
SettingsFormat = 3,
FramesVersion = head.FramesVersion,
CreatedAt = now,
StoredAt = now,
@@ -332,7 +332,7 @@ public abstract class WorkspaceMergeTests(TestContext context) : DatabaseTest(co
Assert.Equal(local.Id, sync.Unpushed(id).Single().Id);
Assert.Equal(local.SettingsJson, sync.Unpushed(id).Single().SettingsJson);
var working = (await sync.OpenAsync(id, fx.Ct)).Working;
Assert.Equal((ProjectSettings.CurrentVersion, 0.3), (working.Version, working.Exposure.ExposureOffsetEv));
Assert.Equal((ProjectSettings.BaseVersion, 0.3), (working.Version, working.Exposure.ExposureOffsetEv));
Assert.SequenceEqual([1], working.ExcludedFrames);
Assert.Equal(WorkspaceState.Conflict, (await sync.PullAsync(id, fx.Home, fx.Ct)).Status.State);
@@ -455,7 +455,7 @@ public abstract class WorkspaceTests(TestContext context) : DatabaseTest(context
var (_, sync) = fx.Workspace();
var project = await fx.CheckoutAsync(sync);
var bundle = project.ReadBundle();
File.WriteAllText(project.BundlePath, bundle.ToJson().Replace("\"version\": 1", "\"version\": 2", StringComparison.Ordinal));
File.WriteAllText(project.BundlePath, bundle.ToJson().Replace("\"version\": 1", "\"version\": 3", StringComparison.Ordinal));
var session = await sync.OpenAsync(project.ProjectId, fx.Ct);
Assert.True(session.IsReadOnly);