From 7b29dbff7e43e87741476f47df17ad1582b16546 Mon Sep 17 00:00:00 2001 From: "Somhairle H. Marisol" Date: Mon, 21 Sep 2026 00:58:15 +0800 Subject: feat(pipeline): add runnable artifact pipeline increment [Change Nature] - This commit adds the first runnable increment of the F# artifact pipeline: CLI, server, frontend bundle, stage fixture, and tests. It is feature work, not a bug fix. [New Capability] - CLI `run` executes the three-step Blender fixture through the process bridge and writes GLBs, step logs, events, and a manifest; `verify` validates a manifest without Blender. - Server exposes run start, run-scoped SSE, artifact manifest/file routes, and serves the Fable frontend from its build output. - Frontend starts runs, follows run-scoped SSE progress, and links the artifact manifest on completion. [Implementation] - Shared layer holds domain, run state, replay, and artifact contracts; Modeling holds the pipeline, 120s bridge timeout, and result-file protocol; stage/blender/fixture.py owns geometry in Python (bpy owns geometry, F# owns orchestration). - Fable bundle is regenerated into public/ and copied by the server project; solution includes all projects with warnings-as-errors. - README documents build, Fable, server, interpreter/env, fixture limitations, and current verification status. [Impact] - Verified: 40/40 solution tests pass; Release build 0 warnings/errors; real CLI run with bpy 5.0.1 produced 3 GLBs, 3 logs, and a verify-clean manifest; isolated-port server smoke flow succeeded. - Not yet verified: browser end-to-end behavior and production fidelity. Artifacts and caches are gitignored. --- .../CoordinatorTests.fs | 83 ++++++++++++++++++++++ 1 file changed, 83 insertions(+) create mode 100644 tests/SomhairlesDream.Server.Tests/CoordinatorTests.fs (limited to 'tests/SomhairlesDream.Server.Tests/CoordinatorTests.fs') diff --git a/tests/SomhairlesDream.Server.Tests/CoordinatorTests.fs b/tests/SomhairlesDream.Server.Tests/CoordinatorTests.fs new file mode 100644 index 0000000..e9689bb --- /dev/null +++ b/tests/SomhairlesDream.Server.Tests/CoordinatorTests.fs @@ -0,0 +1,83 @@ +module SomhairlesDream.Server.Tests.CoordinatorTests + +open System +open System.IO +open System.Threading +open Xunit +open SomhairlesDream.Modeling +open SomhairlesDream.Server +open SomhairlesDream.Shared + +let private ids : RunIds = + { ProjectId = "heritage-001" + RunId = "run-20260920-001" + BaseId = "heritage" + TargetId = "heritage-001" } + +let private withTempDirectory action = + let path = Path.Combine(Path.GetTempPath(), "somhairles-dream-server-" + Guid.NewGuid().ToString("N")) + Directory.CreateDirectory(path) |> ignore + + try + action path + finally + if Directory.Exists(path) then + Directory.Delete(path, true) + +type private TestBridge() = + interface IArtifactBridge with + member _.Export(request, _) = + File.WriteAllBytes(request.GlbPath, [| 0x67uy; 0x6Cuy; 0x54uy; byte request.Step.Index |]) + Directory.CreateDirectory(Path.GetDirectoryName(request.LogPath)) |> ignore + File.WriteAllText(request.LogPath, $"bridge log for {request.Step.StepId}") + + Ok + { BlenderVersion = "5.0.1" + ExportedAt = DateTimeOffset.Parse("2026-09-20T12:00:05Z") + ObjectIds = request.Step.ObjectIds + VerifiedObjectIds = request.Step.ObjectIds + GlbBytes = 4L + RenderPath = None + RenderedAt = None } + +let private waitFor predicate = + let deadline = DateTime.UtcNow.AddSeconds(5.) + let mutable matched = predicate () + + while not matched && DateTime.UtcNow < deadline do + Thread.Sleep(10) + matched <- predicate () + + matched + +[] +let ``coordinator starts one shared pipeline and publishes its manifest`` () = + withTempDirectory (fun root -> + let clock () = DateTimeOffset.Parse("2026-09-20T12:00:00Z") + let coordinator = + ArtifactRunCoordinator( + root, + (fun () -> TestBridge() :> IArtifactBridge), + clock, + TimeSpan.FromSeconds 15. + ) + + match coordinator.Start(ids, false) with + | Error message -> failwith message + | Ok(Accepted snapshot) -> + Assert.Equal(ids.ProjectId, snapshot.ProjectId) + Assert.Equal(ids.RunId, snapshot.RunId) + | Ok(Conflict _) -> failwith "expected the first start to be accepted" + + let completed = + waitFor (fun () -> + coordinator.TryFind(ids.ProjectId, ids.RunId) + |> Option.exists (fun store -> store.Snapshot().Status = "complete")) + + Assert.True(completed) + + match coordinator.Manifest(ids.ProjectId, ids.RunId) with + | Error failure -> failwith $"manifest lookup failed: {failure}" + | Ok manifest -> + Assert.Equal("complete", manifest.Status) + Assert.Equal(3, manifest.Steps.Length)) -- cgit v1.2.3