fix(opcuaclient): RefreshEnd signals initial alarm state only for a lossless refresh bracket (#926)

Track RefreshStart..RefreshEnd per alarm subscription. EventQueueOverflow (matched by
EventType before the source filter - it comes from the Server object), RefreshRequired,
a publish-sequence gap the SDK skipped (EventFieldList.Message.SequenceNumber; SDK 2.0.1's
Republish publish-state never fires for a gap that blocks delivery) or a missing
RefreshStart suppress the A1 signal and re-run ConditionRefresh, bounded (3, 2/4/8 s);
exhausted = conditions stay unknown (Uncertain), never Unsignalable. Alarm event queue
1000 -> 10000; new counters alarm_event_queue_overflow / alarm_refresh_lossy.
Unit + real-SDK gap tests, live overflow gate on opc-plc --alm; plan G2 text corrected.
This commit is contained in:
Joseph Doherty
2026-11-28 09:42:06 -05:00
parent 05f431f5d8
commit 99f2b9d8b7
11 changed files with 978 additions and 36 deletions
+20 -2
View File
@@ -449,8 +449,26 @@ initialise (the AdminUI form drops them on the next save). Pinned by
> `Unspecified` the host wrote as "Activated", and a retained-Active host condition stayed Active). So the host writes no
> duplicate row when its condition already shows that state (see `docs/AlarmTracking.md`). Condition **branch** events (non-null `BranchId`) are ignored.
> **`ConditionRefresh`** is called after the event item is created, after a keep-alive outage the session survived, and on a
> `RefreshRequired` event, so a condition already active upstream is reported at subscribe; `RefreshStart`/`RefreshEnd`
> markers are dropped. A server without it (`BadNotSupported`/`BadMethodInvalid`/…) is logged once and tolerated.
> `RefreshRequired` event, so a condition already active upstream is reported at subscribe. The `RefreshStart`/`RefreshEnd`
> markers are never projected as alarms. A server without ConditionRefresh (`BadNotSupported`/`BadMethodInvalid`/…) is logged once and tolerated.
>
> **A RefreshEnd signals "initial alarm state delivered" only for a lossless bracket (#926).** That signal is grpc-data
> A1's known-state signal. The driver tracks RefreshStart…RefreshEnd per alarm subscription, and the RefreshEnd does
> not signal when any of these happened:
>
> - no RefreshStart was seen;
> - the server sent an `EventQueueOverflowEventType`. That notice comes from the Server object, so it is matched before
> the source filter, and it is never projected as an alarm;
> - a `RefreshRequired` arrived;
> - a delivered publish message skipped a sequence number. This catches the gap the SDK gives up on after a failed
> republish, which the SDK reports nowhere else.
>
> A lossy bracket logs a Warning and re-runs ConditionRefresh on that subscription. At most 3 re-refreshes run per
> episode, backing off 2 s, 4 s and 8 s, and a clean RefreshEnd resets the budget. When it is spent, nothing signals:
> the conditions stay unknown (`Uncertain`) and the host's `ConditionKnownSignalTimeout` diagnostic reports them.
> An overflow outside a bracket (lost live transitions) also requests a re-refresh. The alarm event item asks for a
> queue of 10,000 (previously 1,000); the server may revise it down. Counters on `otopcua.driver.opcuaclient.events`:
> `alarm_event_queue_overflow` and `alarm_refresh_lossy`.
> Last-told state survives a re-initialise (the host re-subscribes the same set over nodes it did not rebuild) and is
> forgotten when the subscribed set changes (the host rebuilt, recreating the nodes inactive). Index keys are server-stable (`nsu=`), so a namespace reorder across a re-initialise keeps
> matching. docker-dev seeds an opc-plc driver (`MAIN-opcua`); the alarm tag is