Merge #926: OpcUaClient RefreshEnd signals initial alarm state only for a lossless bracket; post-signal loss withdraws known; deferred alarm/mark replay in arrival order; 2 review rounds

This commit is contained in:
Joseph Doherty
2026-11-28 10:26:58 -05:00
18 changed files with 1689 additions and 101 deletions
+27 -2
View File
@@ -449,8 +449,33 @@ 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 RefreshStart that arrives while a bracket is still open is a loss too.
>
> Any loss logs a Warning and re-runs ConditionRefresh on that subscription. That includes an overflow or sequence gap
> outside a bracket, which can hold a lost live transition, and a failed ConditionRefresh call.
>
> - **Withdraw on a later loss:** a loss after the subscription signalled also **withdraws "known"**
> (`AlarmInitialStateEventArgs.Withdrawn`). The host takes known back for those conditions (`Uncertain` on a
> consumer), keeps them out of the backstop, and diagnoses them if no signal follows.
> - **Retry bounds:** at most 3 re-refreshes run per episode, backing off 2 s, 4 s and 8 s. A clean RefreshEnd resets
> the budget. Once the budget is spent, a further loss gets a new budget only after a 5-minute cool-down.
> - **RefreshRequired:** its sweeps are coalesced while one is queued. 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