fix(render-node): a restarted node frees its job; downloads resume; batches split on arrival

A node registering again gives back the job its previous run abandoned, so
a restart within the heartbeat timeout no longer leaves it running forever.
Frame downloads retry dropped connections from the partial file; a 404 at
registration waits for the next poll; render remarks reach the job log; a
render the server engine started stays with it. POST /jobs splits a batch
into one job per preset, and a node fails a batch it cannot send back
instead of reporting it done. Renders honour Settings > Rendering: hardware
encoders only where the preference allows them, also for what a node offers.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_012iLMBNwBE2GnphAsu4cjaC
This commit is contained in:
Claude committed 2026-10-02 23:16:23 +00:00
1 parent 04a40ea22a
commit 23c40ece6f
14 files changed
+512 -82

No files matched your search

@@ -15,12 +15,31 @@ namespace Titano.Data.Processing;
/// </summary>
public sealed record ProcessingOptions
{
/// <summary><see cref="SequenceChanged"/> after a render was recorded.</summary>
public const string RenderedChange = "renders";
/// <summary><see cref="SequenceChanged"/> after the advisor changed the project.</summary>
public const string SettingsChange = "settings";
/// <summary>Decoders, lease owner and lease timing for the sidecar and project writes.</summary>
public ArchiveServiceOptions Archive { get; init; } = new();
/// <summary>Encoder providers in priority order.</summary>
public IReadOnlyList<IVideoEncoderProvider> Encoders { get; init; } = [new ManagedEncoderProvider()];
/// <summary>
/// Whether a render of the given preset (its base preset id) may use hardware encoders (Settings › Rendering); when
/// not, it gets only the software ones. Asked at every render, so a changed preference applies to the next one.
/// </summary>
public Func<string, bool> AllowsHardware { get; init; } = _ => true;
/// <summary>
/// Told after a job changed a sequence: <see cref="RenderedChange"/> (a render was recorded) or
/// <see cref="SettingsChange"/> (the advisor changed Auto values). A server tells its connected clients (BRIEF §14.3).
/// A failure is logged and never fails the job.
/// </summary>
public Func<Guid, string, CancellationToken, Task>? SequenceChanged { get; init; }
/// <summary>The server delegates platform codecs to render nodes and never runs them itself.</summary>
public EncoderHost Host { get; init; } = EncoderHost.Client;
@@ -34,6 +53,24 @@ public sealed record ProcessingOptions
public RenderOptions Render { get; init; } = RenderOptions.Default;
/// <summary>Tells <see cref="SequenceChanged"/>; a failure is logged, never passed on to the job.</summary>
internal async Task NotifyAsync(Guid sequenceId, string change, CancellationToken cancellationToken)
{
if (SequenceChanged is null) return;
try
{
await SequenceChanged(sequenceId, change, cancellationToken).ConfigureAwait(false);
}
catch (Exception ex) when (ex is not OperationCanceledException)
{
Core.Diagnostics.Log.Warning("processing", $"The {change} change of sequence {sequenceId} could not be announced", ex);
}
}
/// <summary><see cref="Encoders"/> without their hardware encoders, for renders <see cref="AllowsHardware"/> keeps off them.</summary>
internal IReadOnlyList<IVideoEncoderProvider> SoftwareEncoders =>
[.. Encoders.Select(e => e.Capabilities.Any(c => c.Hardware) ? new SoftwareEncoderProvider(e) : e)];
/// <summary>
/// Encoders the advisor may count on: this machine's on a client; none listed on the server (render nodes can
/// produce any codec, so the advisor rules none out).