fix(commons): flow fold ranks lifecycle before time, schema required/legacy-type checks, CSV trailing comma, case-insensitive audit enum parse (CMN-6,7,8,9,12, WP7 task 7.5)

This commit is contained in:
Joseph Doherty
2026-12-03 09:48:24 -05:00
parent 517f093ce9
commit 76c50a29c2
13 changed files with 214 additions and 12 deletions
@@ -655,6 +655,27 @@ public class FlowGraphBuilderTests
Assert.Equal(sa.Lifecycle!.Select(r => r.Kind), sb.Lifecycle!.Select(r => r.Kind));
}
/// <summary>
/// CMN-6: the resolve row is written centrally and the submit row at the site; with the site clock
/// ahead, the submit row's timestamp is LATER than the delivery's. The fold must still treat the
/// resolve as terminal, not render the completed operation as Pending.
/// </summary>
[Fact]
public void Fold_WithCrossNodeClockSkew_StillTreatsResolveAsTerminal()
{
var corr = Guid.NewGuid();
var submit = Outbound(AuditChannel.ApiOutbound, AuditKind.CachedSubmit, AuditStatus.Submitted, 2000, corr, "Delmia.Ack", node: "node-a", request: "req");
var resolve = Outbound(AuditChannel.ApiOutbound, AuditKind.CachedResolve, AuditStatus.Delivered, 1000, corr, "Delmia.Ack", node: "central-a", response: "res");
var graph = FlowGraphBuilder.Build([SiteRunRow(20), submit, resolve]);
var step = Assert.Single(graph.Steps, s => s.Kind == FlowStepKind.ApiCall);
Assert.Equal(FlowStepOutcome.Ok, step.Outcome);
Assert.Equal("res", step.OutputJson);
Assert.Equal(["CachedSubmit", "CachedResolve"], step.Lifecycle!.Select(r => r.Kind));
Assert.True(step.DurationMs >= 0);
}
/// <summary>Verifies that a cached step whose submit row is missing is still treated as asynchronous.</summary>
[Fact]
public void CachedStep_WhoseSubmitRowIsMissing_IsStillAsync()