fix(commons): FlowGraphBuilder review fixes — leading async steps link from the spawner, robust async rule, lifecycle tie-break, total DbSubtitle

Review of Task 2 (2026-09-06 outbound-calls plan): (1) an outbound step that
precedes the first chain step of its execution — the default Replay shape when
a run's ScriptTrace rows are absent — was orphaned or given a solid spawner
edge; leading async steps now hang off the spawner on Async edges and the
first non-async step gets the normal link. (2) IsAsync keyed on the first row
being CachedSubmit; it now mirrors the projector's sync rule (first row not
ApiCall/DbWrite) so a group missing its submit row still branches. (3) Same-
tick rows tie-broke by GUID; new LifecycleRank (submit < attempt < resolve,
non-terminal < terminal) makes first/latest attribution order-independent.
(4) DbSubtitle used GetInt32 (FormatException on out-of-range/fractional) —
now TryGetInt32, never throws. Also: External-lane edges never count as
central↔site crossings; DurationMs clamped; FlowStep doc updated.

Claude-Session: https://claude.ai/code/session_01NcMG6xXdsJbmD2wYAgkK29
This commit is contained in:
Joseph Doherty
2026-09-06 01:49:40 -04:00
parent 30faee0d0e
commit 865c4be651
5 changed files with 183 additions and 19 deletions
@@ -148,4 +148,17 @@ public class FlowStepProjectorTests
Assert.Equal(FlowStepOutcome.Ok, FlowStepProjector.Project(ok).Outcome);
Assert.Equal(FlowStepOutcome.Failed, FlowStepProjector.Project(failed).Outcome);
}
[Theory]
[InlineData("{\"op\":\"write\",\"rowsAffected\":2147483648}", "write")]
[InlineData("{\"op\":\"write\",\"rowsAffected\":1.5}", "write")]
[InlineData("{\"op\":\"write\",\"rowsAffected\":-1}", "write")]
[InlineData("{\"op\":7}", "Delivered")]
[InlineData("not json", "Delivered")]
public void DbSubtitle_NeverThrows_OnOddExtra(string extra, string expected)
{
var evt = ScadaBridgeAuditEventFactory.Create(AuditChannel.DbOutbound, AuditKind.DbWrite, AuditStatus.Delivered,
occurredAtUtc: T0.UtcDateTime, target: "MesDb", extra: extra);
Assert.Equal(expected, FlowStepProjector.Project(evt).Subtitle);
}
}