fix(galaxy): establish a changed alarm subscription by a QueryActiveAlarms re-read instead of waiting for a stream reopen (#925)

A sentinel comes only when StreamAlarms opens, so a subscription that became live
after the current stream's sentinel (or changed during its snapshot phase, F4)
stayed unknown until a reopen. The feed now re-reads the active set via the
gateway's existing QueryActiveAlarms (same monitor cache), replays entries as
restatements except where the live stream already delivered a newer message for
that alarm, and the driver then signals the still-live subscription. Coalesced
(one in flight + one follow-up), 3 bounded retries, Unimplemented not retried,
a failed re-read never signals.
This commit is contained in:
Joseph Doherty
2026-11-28 09:24:26 -05:00
parent 05f431f5d8
commit b4c27bd5b8
7 changed files with 617 additions and 10 deletions
@@ -476,7 +476,7 @@ conditions re-report (`NM:5639-5651`). Some state changes never produce an event
| Driver | Exact hook | Signal raised |
|---|---|---|
| Galaxy | `GatewayGalaxyAlarmFeed.cs:168`, where the gateway's `snapshot_complete` sentinel is handled in `Dispatch` on the feed thread after the snapshot entries (`:155-169`) | On **every** sentinel, covering every condition of the feed's current subscription. The existing `InitialSnapshotCompleted` task (`:69`) stays for its current users but is not the signal: it is one-shot per feed instance (the reopen loop `:140-152` does not reset it), and its `RunContinuationsAsynchronously` continuation could overtake queued transitions. After a gateway stream reopen, the reopened stream's sentinel signals again |
| Galaxy | `GatewayGalaxyAlarmFeed.cs:168`, where the gateway's `snapshot_complete` sentinel is handled in `Dispatch` on the feed thread after the snapshot entries (`:155-169`) | On **every** sentinel, covering every condition of the feed's current subscription. The existing `InitialSnapshotCompleted` task (`:69`) stays for its current users but is not the signal: it is one-shot per feed instance (the reopen loop `:140-152` does not reset it), and its `RunContinuationsAsynchronously` continuation could overtake queued transitions. After a gateway stream reopen, the reopened stream's sentinel signals again. **#925:** a subscription that becomes live after the current stream's sentinel (or changes during its snapshot phase) is established by a `QueryActiveAlarms` re-read instead: the entries are replayed as restatements, except where a newer live message already arrived, and then the signal is raised (`docs/drivers/Galaxy.md`) |
| OpcUaClient (**F1**, **G2**) | The per-event route that today drops `RefreshEndEventType` as a marker (`OpcUaClientDriver.cs:3066-3067`, `IsRefreshMarker` `:2860-2864`), reached from `OnEventNotification` (`:2749-2762`) | On receipt of `RefreshEndEventType`, covering every condition of that alarm subscription, after the refreshed events delivered before it were projected. **Not** when `TryConditionRefreshAsync` returns (`:2881-2900`). See G2 below for ordering across publish responses |
| FOCAS | `FocasAlarmProjection.PollOnceAsync` per-host loop (`:243-276`): after `NoteAlarmReadSucceeded(host)` (`:273`) and that host's `Tick` (`:274`). The `continue` path for a failed host (`:253-272`) raises nothing | **Per host**: the condition ids of that host's alarm tags, after its read succeeded and its transitions were emitted. Raised again on each later successful read |
| AbCip ALMD/ALMA | `AbCipAlarmProjection.Tick` (`:195`), called from `RunPollLoopAsync` (`:251`); a node whose `InAlarm` read is non-Good is skipped (`:211`) | **Per node**: at the end of each `Tick`, the condition ids of the nodes whose `InAlarm` (and, for ALMA, all plan refs) read Good in that tick. Skipped nodes are excluded |
@@ -215,6 +215,15 @@ Heidenhain legs are **blocked**: Galaxy needs the VPN and mxaccessgw, and Heiden
sentinel, which comes only on a stream reopen. Until then F5 diagnoses it.
- This is by design (vii): the snapshot that preceded the subscribe may have carried that alarm while it was unroutable.
- Open question: should the driver ask the gateway for a fresh snapshot on a changed subscription set?
**Answered by #925 (2026-11-28):** yes. mxaccessgw already serves `QueryActiveAlarms` from the same monitor cache as the
stream snapshot, so no gateway change was needed. A subscribe on a stream that is past its sentinel, and a sentinel for
a stream opened under an earlier subscription (F4), both trigger a re-read. The re-read is replayed as restatements; an
entry is skipped when the live stream already delivered a newer message for that alarm. Then the live subscription is
signalled. Re-reads are coalesced: one in flight plus one follow-up. A failed re-read is retried 3 times and never
signals. Tests: `GalaxyAlarmSnapshotRefreshTests` (6). Each of these mutations turns a test red: no re-read on subscribe
(5 red), no supersede check, no handle check at the signal, Unimplemented retried, no re-read at a mismatched sentinel,
no coalescing. The F5 re-arm for deploy-added refs was already in place (`RearmConditionSignalsAfterReindex`, review
round 1). **Not live-gated:** no Galaxy or mxaccessgw is reachable (wonder-box hold).
- **OpcUaClient: no signal suppression on an SDK-reported sequence gap during a refresh.** Plan G2 says such a `RefreshEnd`
"does not signal".
- The SDK 2.0.1 surface the driver sees (the per-item `Notification` callback) exposes no per-message gap or republish