fix(grpc-data): A1 review round 2 F1 + F2 — an ack-revert establishes nothing; every Good edge withdraws; Bad edge forgets unsignalable
F1: RevertNativeAlarmAck projected through WriteAlarmCondition, which re-marked a comms-withdrawn native condition known; with the Good edge's conditional withdrawal skipped (GoodSinceUtc null) it read known-inactive-Good until the replay. AlarmStateUpdate.EstablishesState (false for the revert) rides a new default sink overload WriteAlarmCondition(..., establishesState) through the deferred and SDK sinks to the node manager, and every Good edge now withdraws unconditionally. F2: the Bad edge clears the unsignalable set, so a stale report cannot arm the backstop on the next Good edge. The rig's CollectAlarmTraffic skips withdrawals (every edge now sends one).
This commit is contained in:
@@ -230,6 +230,24 @@ public sealed class ConditionStateNodeManagerTests : IDisposable
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
/// <summary>Review round 2 F1: a native projection flagged as not establishing (the #760 ack-revert) applies its state
|
||||
/// but never makes a withdrawn condition known again.</summary>
|
||||
[Fact]
|
||||
public async Task F1_A_non_establishing_native_projection_does_not_mark_known()
|
||||
{
|
||||
var (host, nm, sink) = await BootAsync();
|
||||
MaterialiseAll(nm);
|
||||
nm.WriteAlarmCondition(Native, State(true, false), DateTime.UtcNow, AddressSpaceRealm.Raw);
|
||||
nm.MarkConditionsUnknown("drv", [Native], AddressSpaceRealm.Raw).ShouldBe(1); // the Bad edge
|
||||
|
||||
nm.WriteAlarmCondition(Native, State(true, false, message: "reverted"), DateTime.UtcNow, AddressSpaceRealm.Raw, establishesState: false);
|
||||
|
||||
nm.IsConditionStateKnown(Native, AddressSpaceRealm.Raw).ShouldBeFalse();
|
||||
sink.Records.Last().ShouldSatisfyAllConditions(r => r.Message.ShouldBe("reverted"), r => r.StateKnown.ShouldBeFalse());
|
||||
AssertParity(nm, sink);
|
||||
await host.DisposeAsync();
|
||||
}
|
||||
|
||||
[Fact]
|
||||
public async Task T3_The_marker_moves_only_on_a_new_occurrence()
|
||||
{
|
||||
|
||||
+55
@@ -157,6 +157,61 @@ public sealed class NativeAlarmInitialStateSignalTests : NativeAlarmSignalTestBa
|
||||
.ConditionIds.ShouldBe([A, B], ignoreOrder: true);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Review round 2 F1 — the exact scenario: comms lost (Bad edge withdraws), an operator acks while the driver is
|
||||
/// Reconnecting, so the ack fails and the host reverts the condition. That revert is the projector's cached state,
|
||||
/// not a driver transition: it must not establish the condition (EstablishesState false). And the reconnect's Good
|
||||
/// edge withdraws again, unconditionally, ahead of the Good quality annotation — so an alarm that re-raised
|
||||
/// upstream during the outage cannot read known-inactive, Good until the replay.
|
||||
/// </summary>
|
||||
[Fact]
|
||||
public void An_ack_revert_during_an_outage_does_not_establish_and_the_Good_edge_withdraws_again()
|
||||
{
|
||||
var rig = StartRig(DriverTypeNames.Galaxy, ["hi"]);
|
||||
rig.Driver.Raise(A).ShouldBeTrue();
|
||||
rig.Driver.Signal([A]).ShouldBeTrue();
|
||||
rig.Publish.FishForMessage<OpcUaPublishActor.MarkConditionsKnown>(m => m.Known, TimeSpan.FromSeconds(5), cancellationToken: Ct);
|
||||
|
||||
rig.Host.Tell(new ReconnectDriver("c1", DriverId, "test", Guid.NewGuid()), TestActor);
|
||||
rig.Publish.FishForMessage<OpcUaPublishActor.MarkConditionsKnown>(m => !m.Known, TimeSpan.FromSeconds(5), cancellationToken: Ct);
|
||||
|
||||
rig.Host.Tell(new DriverHostActor.RouteNativeAlarmAck(A, null, "operator"), TestActor);
|
||||
var revert = rig.Publish.FishForMessage<OpcUaPublishActor.AlarmStateUpdate>(u => u.AlarmNodeId == A && !u.State.Acknowledged,
|
||||
TimeSpan.FromSeconds(5), cancellationToken: Ct);
|
||||
revert.EstablishesState.ShouldBeFalse("an ack-revert re-projects cached state; it establishes nothing");
|
||||
|
||||
// The reconnect: a withdrawal must precede the Good quality annotation.
|
||||
var withdrawnAgain = false;
|
||||
var deadline = DateTime.UtcNow + TimeSpan.FromSeconds(30);
|
||||
while (true)
|
||||
{
|
||||
var m = rig.Publish.ReceiveOne(deadline - DateTime.UtcNow, Ct);
|
||||
m.ShouldNotBeNull("the reconnect's Good quality annotation never arrived");
|
||||
if (m is OpcUaPublishActor.MarkConditionsKnown { Known: false } w && w.ConditionIds.Contains(A)) withdrawnAgain = true;
|
||||
if (m is OpcUaPublishActor.MarkConditionsKnown { Known: true }) throw new ShouldAssertException("marked known before the driver signalled");
|
||||
if (m is OpcUaPublishActor.AlarmQualityUpdate { StatusCode: OpcUaStatus.Good }) break;
|
||||
}
|
||||
|
||||
withdrawnAgain.ShouldBeTrue("the Good edge withdraws unconditionally");
|
||||
}
|
||||
|
||||
/// <summary>Review round 2 F2: an unsignalable report belongs to the subscription that made it. After a Bad edge the
|
||||
/// reconnected subscription has not reported, so the backstop must not arm from the stale set — a refresh that then
|
||||
/// fails leaves the conditions unknown (F5), never known-by-timer.</summary>
|
||||
[Fact]
|
||||
public void An_unsignalable_report_does_not_survive_a_Bad_edge()
|
||||
{
|
||||
// The settle outlasts the window before the Bad edge, so the report is still pending (an elapsed backstop clears it).
|
||||
var rig = StartRig(DriverTypeNames.OpcUaClient, ["hi"], o => o.WithOpcUaClientSettle(TimeSpan.FromSeconds(3)));
|
||||
rig.Driver.Signal([A], unsignalable: true).ShouldBeTrue();
|
||||
|
||||
rig.Host.Tell(new ReconnectDriver("c1", DriverId, "test", Guid.NewGuid()), TestActor);
|
||||
rig.Publish.FishForMessage<OpcUaPublishActor.AlarmQualityUpdate>(q => q.StatusCode != OpcUaStatus.Good, TimeSpan.FromSeconds(5), cancellationToken: Ct);
|
||||
// The reconnect's Good edge (the child retries on its reconnect interval).
|
||||
rig.Publish.FishForMessage<OpcUaPublishActor.AlarmQualityUpdate>(q => q.StatusCode == OpcUaStatus.Good, TimeSpan.FromSeconds(30), cancellationToken: Ct);
|
||||
AssertNoMark(rig.Publish, TimeSpan.FromSeconds(4.5)); // a stale set would arm the 3 s backstop from this Good edge
|
||||
}
|
||||
|
||||
/// <summary>Open question answered — re-arm F5 for refs a deploy adds while the driver is connected. Today every such
|
||||
/// deploy changes the driver's config (its authored RawTags are folded into it), so the driver is respawned: the
|
||||
/// stopped incarnation's conditions are withdrawn, and the new incarnation's Good edge puts EVERY ref — the added one
|
||||
|
||||
@@ -141,7 +141,7 @@ public abstract class NativeAlarmSignalTestBase : RuntimeActorTestBase
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>The publish-actor messages that are alarm-state updates or marks, in arrival order, until
|
||||
/// <summary>The publish-actor messages that are alarm-state updates or KNOWN marks (withdrawals skipped), in arrival order, until
|
||||
/// <paramref name="until"/> matches (inclusive).</summary>
|
||||
/// <param name="publish">The probe.</param>
|
||||
/// <param name="until">Stop condition.</param>
|
||||
@@ -156,6 +156,8 @@ public abstract class NativeAlarmSignalTestBase : RuntimeActorTestBase
|
||||
var m = publish.ReceiveOne(deadline - DateTime.UtcNow);
|
||||
if (m is null) break;
|
||||
if (m is not (OpcUaPublishActor.AlarmStateUpdate or OpcUaPublishActor.MarkConditionsKnown)) continue;
|
||||
// Withdrawals (every connectivity edge sends one, review round 2 F1) are not marks.
|
||||
if (m is OpcUaPublishActor.MarkConditionsKnown { Known: false }) continue;
|
||||
seen.Add(m);
|
||||
if (until(m)) return seen;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user