feat(pipeline): render queue, worker service and automated preview generation

One "Queue Export" click now renders the EXR sequence, then rebuilds the shot
headlessly with the studio slate/overlay template to produce the delivery MOV
and review MP4. Implements RenderPipeline2 phases 1-2 plus the preview stage.

Server:
- New models Export, RenderJob, ExportEvent, Machine, WorkerHeartbeat, plus
  Project.deliveryConfig and per-submission slate fields (Export.vfxScope,
  Export.submissionNote, inherited from the shot's previous export).
  Both migrations are purely additive; no existing column is touched.
- lib/render-pipeline: server-enforced state machine, transactional version
  increment with supersede, atomic FOR UPDATE SKIP LOCKED claim gated by
  machine availability windows, and a lease reaper run from instrumentation.ts.
- /api/ext/* endpoints for the panel and workers; session-auth mirrors under
  /api/render and /api/machines for the web UI.
- Pipeline pages: render queue, export detail, machine monitoring, plus an
  Exports tab on shot detail.

RenderWorker (.NET 8 Windows service, new):
- Registration, heartbeat as cancel channel, claim loop, aerender runner with
  progress parsing and stall watchdog, crash recovery and disk-spooled
  reporting that survives server downtime.
- Preview stage: headless AE assembles the preview comp into a throwaway AEP
  with both output modules queued, then a single aerender pass renders them.
  Preview jobs are not claimed while an interactive AE session is open, so an
  artist's project is never taken over.

AE panel: Queue Export with live status polling, urgent flag, retry, and the
VFX Scope / Submission Note fields. Every existing panel action is unchanged.

Preview chaining ships disabled behind SystemConfig preview.enabled.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
twotalesanimation
2026-08-02 14:34:34 +02:00
parent 6b15bae62a
commit cc89415a29
71 changed files with 11767 additions and 1 deletions
@@ -0,0 +1,87 @@
using VFXReviewWorker;
using Xunit;
namespace VFXReviewWorker.Tests;
public class PathMapperTests
{
private static PathMapper Mapper(params (string from, string to)[] maps) =>
new(maps.Select(m => new PathMapping { From = m.from, To = m.to }));
[Fact]
public void MapsUncToDriveLetter()
{
var mapper = Mapper(("//SAN/", "S:/"));
Assert.Equal(@"S:\renders\UNG_S1\106\shot\v004", mapper.Map("//SAN/renders/UNG_S1/106/shot/v004"));
}
[Fact]
public void MapsBackslashInputToo()
{
var mapper = Mapper(("//SAN/", "S:/"));
Assert.Equal(@"S:\projects\a.aep", mapper.Map(@"\\SAN\projects\a.aep"));
}
[Fact]
public void CaseInsensitiveMatch()
{
var mapper = Mapper(("//SAN/", "S:/"));
Assert.Equal(@"S:\x", mapper.Map("//san/x"));
}
[Fact]
public void FirstMatchingMappingWins()
{
var mapper = Mapper(("//SAN/renders/", "R:/"), ("//SAN/", "S:/"));
Assert.Equal(@"R:\a", mapper.Map("//SAN/renders/a"));
Assert.Equal(@"S:\projects\a", mapper.Map("//SAN/projects/a"));
}
[Fact]
public void UnmappedPathPassesThroughWithLocalSeparators()
{
var mapper = Mapper(("//SAN/", "S:/"));
Assert.Equal(@"D:\local\thing", mapper.Map("D:/local/thing"));
}
}
public class PrepareOutputDirTests
{
[Fact]
public void ClearsOnlyFilesMatchingPatternPrefix()
{
var dir = Path.Combine(Path.GetTempPath(), "vfxr-test-" + Guid.NewGuid().ToString("N"));
Directory.CreateDirectory(dir);
try
{
File.WriteAllText(Path.Combine(dir, "SHOT_cmp_TT_v004.1001.exr"), "old");
File.WriteAllText(Path.Combine(dir, "SHOT_cmp_TT_v004.1002.exr"), "old");
File.WriteAllText(Path.Combine(dir, "unrelated-notes.txt"), "keep me");
AerenderRunner.PrepareOutputDir(dir, "SHOT_cmp_TT_v004.[####].exr");
Assert.False(File.Exists(Path.Combine(dir, "SHOT_cmp_TT_v004.1001.exr")));
Assert.False(File.Exists(Path.Combine(dir, "SHOT_cmp_TT_v004.1002.exr")));
Assert.True(File.Exists(Path.Combine(dir, "unrelated-notes.txt")));
}
finally
{
Directory.Delete(dir, recursive: true);
}
}
[Fact]
public void CreatesMissingDirectory()
{
var dir = Path.Combine(Path.GetTempPath(), "vfxr-test-" + Guid.NewGuid().ToString("N"), "v001");
try
{
AerenderRunner.PrepareOutputDir(dir, "X.[####].exr");
Assert.True(Directory.Exists(dir));
}
finally
{
Directory.Delete(Path.GetDirectoryName(dir)!, recursive: true);
}
}
}
@@ -0,0 +1,120 @@
using VFXReviewWorker;
using Xunit;
namespace VFXReviewWorker.Tests;
/// <summary>
/// Recorded-transcript tests (§17.2): lines below are representative aerender
/// stdout from AE 2024/2025/2026 successes, errors, and stalls.
/// </summary>
public class ProgressParserTests
{
[Theory]
[InlineData("PROGRESS: 0:00:02:03 (51): 0 Seconds", 51)]
[InlineData("PROGRESS: 2 (2): 1 Seconds", 2)]
[InlineData("PROGRESS: 0:00:00:00 (1): 12 Seconds", 1)]
[InlineData("PROGRESS: 0:00:04:23 (120): 3 Seconds", 120)]
public void ParsesProgressFrames(string line, int expected)
{
Assert.Equal(expected, ProgressParser.ParseFrame(line));
}
[Theory]
[InlineData("PROGRESS: Rendering frame data")]
[InlineData("Starting composition \"UNG_106_010_020_cmp\".")]
[InlineData("aerender version 24.3x52")]
[InlineData("")]
public void IgnoresNonFrameLines(string line)
{
Assert.Null(ProgressParser.ParseFrame(line));
}
[Theory]
[InlineData("aerender ERROR: An existing connection was forcibly closed")]
[InlineData("aerender ERROR -1610153464: After Effects error")]
[InlineData("ERROR: Unable to open project")]
[InlineData("aerender SYNTAX ERROR: Illegal argument flag: false")]
public void DetectsErrorLines(string line)
{
Assert.True(ProgressParser.IsErrorLine(line));
}
[Fact]
public void ProgressLineIsNotAnError()
{
Assert.False(ProgressParser.IsErrorLine("PROGRESS: 0:00:02:03 (51): 0 Seconds"));
}
[Theory]
[InlineData("aerender ERROR: After Effects error: layer source file is missing or inaccessible")]
[InlineData("aerender ERROR: No comp was found with the given name.")]
[InlineData("aerender ERROR: project file could not be opened")]
[InlineData("WARNING: Missing footage in comp")]
[InlineData("aerender SYNTAX ERROR: Illegal argument flag: false")]
public void DeterministicErrorsAreNonRetryable(string line)
{
Assert.True(ProgressParser.IsNonRetryableError(line));
}
[Theory]
[InlineData("aerender ERROR: An existing connection was forcibly closed")]
[InlineData("aerender ERROR -1610153464: After Effects crashed")]
public void TransientErrorsStayRetryable(string line)
{
Assert.False(ProgressParser.IsNonRetryableError(line));
}
}
public class EtaCalculatorTests
{
[Fact]
public void NoFramesMeansNoEstimate()
{
var eta = new EtaCalculator();
Assert.Null(eta.EstimateSeconds(100));
}
[Fact]
public void EstimatesFromRollingAverage()
{
var eta = new EtaCalculator();
var t = DateTimeOffset.UtcNow;
eta.RecordFrame(t);
eta.RecordFrame(t.AddSeconds(2));
eta.RecordFrame(t.AddSeconds(4)); // 2 s/frame average
Assert.Equal(20, eta.EstimateSeconds(10));
}
[Fact]
public void ZeroRemainingMeansNoEstimate()
{
var eta = new EtaCalculator();
var t = DateTimeOffset.UtcNow;
eta.RecordFrame(t);
eta.RecordFrame(t.AddSeconds(1));
Assert.Null(eta.EstimateSeconds(0));
}
[Fact]
public void RollingWindowDropsOldFrames()
{
var eta = new EtaCalculator(windowSize: 2);
var t = DateTimeOffset.UtcNow;
eta.RecordFrame(t);
eta.RecordFrame(t.AddSeconds(100)); // old slow frame, will roll out
eta.RecordFrame(t.AddSeconds(101));
eta.RecordFrame(t.AddSeconds(102)); // window now [1, 1]
Assert.Equal(10, eta.EstimateSeconds(10));
}
}
public class LogTailTests
{
[Fact]
public void KeepsOnlyLastNLines()
{
var tail = new LogTail(3);
for (var i = 1; i <= 5; i++) tail.Add($"line {i}");
Assert.Equal("line 3\nline 4\nline 5", tail.ToString());
}
}
@@ -0,0 +1,20 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFramework>net8.0</TargetFramework>
<Nullable>enable</Nullable>
<ImplicitUsings>enable</ImplicitUsings>
<IsPackable>false</IsPackable>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="17.11.1" />
<PackageReference Include="xunit" Version="2.9.2" />
<PackageReference Include="xunit.runner.visualstudio" Version="2.8.2" />
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\VFXReviewWorker\VFXReviewWorker.csproj" />
</ItemGroup>
</Project>