perf(site-runtime): deserialize a deploy's flattened config once and hand the parsed object down (review 2026-10-21 01/SR-P5)

The deploy compile warm parses once off-thread; the parsed FlattenedConfiguration
rides DeployCompileWarmed to the gate (new Validate(FlattenedConfiguration)
overload), the redeploy buffer, CreateInstanceActor's DCL ensure and a new
InstanceActor constructor overload. Stored-row paths parse once inside
CreateInstanceActor; an unparseable stored row still fails init via S6.
This commit is contained in:
Joseph Doherty
2026-10-22 06:47:18 -04:00
parent 960c35060c
commit dde22a3dd1
5 changed files with 296 additions and 40 deletions
@@ -58,19 +58,54 @@ public sealed class DeployCompileValidator
/// <returns>A list of compile-error messages; empty if the configuration is clean.</returns>
public IReadOnlyList<string> Validate(string configJson, string? instanceName = null)
{
FlattenedConfiguration? config;
if (!TryParse(configJson, out var config, out var parseError))
return [parseError!];
return Validate(config!, instanceName);
}
/// <summary>
/// Deserializes a flattened-configuration JSON exactly as <see cref="Validate(string, string?)"/>
/// does, so a caller that needs the parsed object as well (the Deployment Manager, which hands
/// it on to the Instance Actor — review 2026-10-21 01/SR-P5) parses once instead of once per
/// consumer. The error text is the one <see cref="Validate(string, string?)"/> reports.
/// </summary>
/// <param name="configJson">The flattened-configuration JSON.</param>
/// <param name="config">The parsed configuration, or <see langword="null"/> on failure.</param>
/// <param name="error">The deserialization error, or <see langword="null"/> on success.</param>
/// <returns><see langword="true"/> when the JSON produced a configuration.</returns>
public static bool TryParse(string configJson, out FlattenedConfiguration? config, out string? error)
{
try
{
config = JsonSerializer.Deserialize<FlattenedConfiguration>(configJson);
}
catch (JsonException ex)
{
return [$"Configuration JSON failed to deserialize: {ex.Message}"];
config = null;
error = $"Configuration JSON failed to deserialize: {ex.Message}";
return false;
}
if (config == null)
return ["Configuration JSON failed to deserialize: result was null."];
{
error = "Configuration JSON failed to deserialize: result was null.";
return false;
}
error = null;
return true;
}
/// <summary>
/// Validates an already-parsed flattened configuration — the same checks as
/// <see cref="Validate(string, string?)"/> without a second deserialization (01/SR-P5).
/// </summary>
/// <param name="config">The parsed flattened configuration.</param>
/// <param name="instanceName">See <see cref="Validate(string, string?)"/>.</param>
/// <returns>A list of error messages; empty if the configuration is clean.</returns>
public IReadOnlyList<string> Validate(FlattenedConfiguration config, string? instanceName = null)
{
var errors = new List<string>();
// Runtime names first: they are cheap, and a name Akka refuses would otherwise surface