docs(plans): history+alarms plan rev 5 (T1-T3, m-T4..m-T7); Fable fourth pass
v2-ci / unit-tests (push) Has been cancelled

MarkConditionsKnown delta, input/driver-signal-based known state with
per-driver timer backstop, origin activation marker, cluster-wide condition
key. Fourth Fable pass: X0 + H approved; A approved with changes (F1-F2 Major,
F3-F6) — small A1 edits.
This commit is contained in:
Joseph Doherty
2026-11-23 16:50:22 -05:00
parent 310b42e3fc
commit 9a977a74fa
2 changed files with 299 additions and 55 deletions
@@ -1,6 +1,6 @@
# gRPC data connections: remote history and alarm/event forwarding
Date: 2026-11-23 (revision 4: open items settled from code and the pinned SDK; revision 3 folded in the review's two passes and the owner decisions of 2026-11-23)
Date: 2026-11-23 (revision 5: review third pass folded in; revision 4 settled open items from code and the pinned SDK; revision 3 folded in the first two passes and the owner decisions of 2026-11-23)
Status: **Design + phased plan, not approved, not implemented.** No code, schema or issue changes accompany this
document. It extends the merged v1 feature (`95c5e484`), whose design is
[`2026-11-15-grpc-data-connections-design.md`](2026-11-15-grpc-data-connections-design.md) ("v1 design") and whose
@@ -45,7 +45,7 @@ found while verifying M1 (row M1).
| m2 two release mechanisms | Accepted | §4.2: `release_continuations` flag only |
| m3 `HistoryEventRow` fields | Accepted (verified `HistoryReadContracts.cs:194-204`) | §7 deferred event history defines the row from `HistoricalEvent` |
| m4 `SubscriptionFrame` field 8 taken | Accepted | §4.2: new arm = 9 |
| m5 origin EventId round-trip unnecessary | Accepted | §5.6: consumer validates its own EventIds; origin precondition = `expected_activation_time` |
| m5 origin EventId round-trip unnecessary | Accepted | §5.6: consumer validates its own EventIds; origin precondition = activation marker (revision 5, T3) |
| m6 Galaxy ack-identity lookup unverified | Accepted; settled in revision 4 | §6 Galaxy: keyed on the service key's `ApiKeyId`; provisioning step named |
| m7 assembly budget per node | Accepted | §3.2: per-request budget |
| m8 aggregate configuration judged by consumer | Accepted | §4.2: configuration fields sent; origin `IsServable` decides |
@@ -60,15 +60,24 @@ found while verifying M1 (row M1).
| N3 cross-realm home leaks RawPath | Accepted (verified `LocalExportCatalog.cs:42-48`, `NM:4885`, `DataPlaneAuthorizer.cs:182`); **refinement:** `stable_source_id` cannot be the dedupe key — it embeds driver id + RawPath (`SourceSamplePublisher.cs:32-33`, `LocalExportCatalog.Compilation.cs:92,123`) | §5.2 realm-local placement addresses + keyed `condition_key`; pre-existing v1 disclosure filed as #916 |
| N4 ConditionId depends on stream order / home | Accepted | §5.2: NodeId = (connection, `condition_key`) in a new `mapped/conditions` namespace; mapping changes never change it; primary placement (SourceName only) from deployed config |
| N5 default budgets | Accepted (verified `RemoteNamespaceMapping.cs:29` = 10,000); recomputed in revision 4 | §5.5: counted 49 nodes ⇒ 10,000 / 49 ≈ 204; own budget, `MaxConditions` 1,000, host caps 122,500 nodes / 400 MiB, admission at snapshot begin, 80% warning |
| N6 `occurrence` across failover | Accepted | §5.6 step 3: `expected_activation_time` + EventId re-binding on unchanged resync; gated in A03 |
| N6 `occurrence` across failover | Accepted; mechanism replaced in revision 5 (T3) | §5.6 step 3: origin-owned activation marker + EventId re-binding on unchanged resync; gated in A03 |
| N7 notifier wiring vs lazy folders | Accepted (verified projected folders created `EventNotifier = None`, `NM:4919`) | §5.3 lazy, symmetric wiring; folders with event items pinned |
| N8 G0 deferral consequences | Accepted | Recorded-v1-client gate repeated at H2, A2 and A3 exits; §1.1: #915's soak should run on an X0-or-later build |
| **Revision 4 (settled offline)** | | |
| B5 interception point | Settled: works | §5.6 step 1 — NM implements `ICallAsyncNodeManager`; SDK 2.0.1 dispatch traced (validation's `FindMethodState` holds `Lock` only for the lookup; per-manager `CallAsync` awaited with `ConfigureAwait(false)`); A3 not blocked |
| N5 node count | Settled: 48–49 nodes, ≈ 157 KiB each (was "~21") | §5.5 recomputed: 10,000 / 49 ≈ 204; `MaxConditions` 1,000; host caps 122,500 nodes / 400 MiB |
| `state_known` field | Settled: does not exist; named additions | §5.1: `_conditionStateKnown`, quality-settle timestamp, `MarkScriptedConditionsKnown` |
| `state_known` field | Settled: does not exist; named additions (revised in revision 5 by T1/T2) | §5.1: `_conditionStateKnown`, `MarkConditionsKnown`, driver signal / per-driver timer, scripted inputs-established |
| Event re-gating, Galaxy keying, build reporting, opc-plc alarms, alarm-tag export | Settled from code/SDK | §5.4, §6, §4.3, A02, §5.2 (+ second pre-existing v1 defect) |
| Remaining live items | Listed | §9.3 L1–L5 with pass criteria |
| **Third pass (revision 5)** | | |
| T1 no delta when a condition becomes known | Accepted (verified: neither tap fires when only a timer or load signal changes; no snapshot-time recheck) | §5.1: `MarkConditionsKnown(scope)` actor message raises state-only records; A1 T1 test |
| T2 known-inactive declared too early | Accepted (verified `ScriptedAlarmEngine.cs:58-67,440-461,1325`; one global window) | §5.1: scripted known on inputs established (`OnInputsEstablished`); native via a new `IAlarmInitialStateSignal` (Galaxy `IGalaxyAlarmFeed.cs:38`, OpcUaClient `OpcUaClientDriver.cs:2552`), else a per-driver-type timer (60 s default); invariant stated and tested; L4 per driver; residual for timer drivers stated |
| T3 `expected_activation_time` moves on every projection | Accepted (verified: decompiled SDK `AlarmConditionState.SetActiveState` sets `TransitionTime = DateTimeUtc.Now` unconditionally; `NM:1364`) | §4.2 `ActivationMarker`; §5.6 step 3: origin-owned `(incarnation, sequence)` bumped on Active false→true **and** on Acked true→false while Active (extension: a #647 re-raise needs a new ack); N6 re-checked; A2 test |
| B5 notes (operation scope, sequential dispatch) | Accepted; dispatch-order point settled (NM is the last registered manager, `OtOpcUaSdkServer.cs:883` + decompiled `MasterNodeManager` ctor) | §5.6 step 1 notes |
| m-T4 fail-closed drop loses authorised events | Accepted | §5.4: rewriter re-evaluates the gate for the publishing session, drops only on deny / not evaluable with `RefreshRequired`; imported events always use the marked path regardless of `UseProjectedEventDelivery` (`NM:1915,1930`) |
| m-T5 L4/L2 gate placement | Accepted | L4 → A1 exit; L2 at A3 exit with A2 defaults provisional; A1–A3 not fleet-deployable before A4 (§9.1) |
| m-T6 ConditionId depends on principal | Accepted, **alternative fix** | §5.2: `condition_key` derived with a cluster-wide key (not per principal), because the validator cannot see per-node credentials; A06 asserts equal ConditionIds |
| m-T7 what 157 KiB excludes | Accepted | §5.5: exclusions listed; L2 is the authority for `MaxImportedConditionBytes` |
| Owner decisions 2026-11-23 | Applied | Q1 → §5.5 (service principal upstream, per-caller re-gating); Q2 → §5.2 (NodeIds stable across mapping disable; residual change accepted) |
---
@@ -169,7 +178,7 @@ has accepted the call.
| SDK Call dispatch (B5) | Decompiled SDK 2.0.1: `StandardServer.CallAsync` → `MasterNodeManager.CallAsync` → `NodeManagerServiceDispatcher.CallAsync` (validation via `FindMethodState`, short `lock (Lock)`, then per-manager `IAsyncNodeManager.CallAsync`); `AsyncNodeManagerAdapter.CallAsync` forwards to `ICallAsyncNodeManager` when the wrapped manager implements it; `CustomNodeManager2` (NM's base) implements `INodeManager3` only and its sync `Call`/`GetMethodCalls` skip `Processed` items | NM implements `ICallAsyncNodeManager`; imported-condition calls are claimed and awaited with no `Lock` held (§5.6) |
| Condition subtree (N5) | `NM:2461-2475` (optional `ConfirmedState`/`Confirm`/`ShelvingState`/`MaxTimeShelved` before `Create`), `ApplicationAlarmConditions.cs:7-11` (Alarm / OffNormal / Discrete) | Counted with SDK 2.0.1: 48 / 49 / 48 nodes, ≈ 157 KiB retained each (§5.5) |
| Event delivery path (§5.4) | Decompiled SDK 2.0.1 `MonitoredItem.QueueEvent(EventFieldList)` enqueues by reference; `Subscription.ConstructMessage` moves queued lists into `EventNotificationList` by reference; a select-clause modify rebuilds queued lists via `GetEventFields` with `Handle` = the original event; `OtOpcUaSdkServer.cs:746,768` already rewrites every Publish/Republish via `ProjectedNotificationRewriter` (`WarmStandby.cs:917`), which today passes event payloads through untouched | A marked `EventFieldList` subclass survives to Publish/Republish; the rewriter is extended to events |
| Native/scripted state signals (N1) | Native `Quality = BadWaitingForInitialData` at materialise (`NM:2527`), driven Good via `WriteAlarmQuality` (`NM:1480`); `RestoreCarryOver` (`NM:2727`); scripted re-assert only for non-normal conditions (`ScriptedAlarmHostActor.cs:491`) | `_conditionStateKnown` + settle timestamp + `MarkScriptedConditionsKnown` (§5.1) |
| Native/scripted state signals (N1) | Native `Quality = BadWaitingForInitialData` at materialise (`NM:2527`), driven Good via `WriteAlarmQuality` (`NM:1480`); `RestoreCarryOver` (`NM:2727`); scripted re-assert only for non-normal conditions (`ScriptedAlarmHostActor.cs:491`); scripted cold start re-derives Active from a `ReadTag`-seeded cache (`ScriptedAlarmEngine.cs:440-461`, `StatusNeverPushed` `:58-67`, `WorstInputStatus` `:1325`); existing driver signals: Galaxy `IGalaxyAlarmFeed.InitialSnapshotCompleted` (`:38`), OpcUaClient ConditionRefresh sweep (`OpcUaClientDriver.cs:2552`); `IAlarmSource` implementers: Galaxy, OpcUaClient, MTConnect, FOCAS, AbCip, Heidenhain; SDK `SetActiveState` stamps `TransitionTime = Now` on every call (`NM:1364` calls it per projection) | `_conditionStateKnown` + `MarkConditionsKnown` deltas + driver signal / per-driver timer + inputs-established; origin-owned activation marker (§5.1, §5.6) |
| Alarm-bearing tags (N3, §5.2) | `AddressSpaceComposer.cs:978-985` (#896: no UNS value Variable for an alarm-bearing backing tag); `AddressSpaceComposer.cs:835-850` (alarm tags are in `RawTags`); `LocalExportCatalog.Compilation.cs:120-130` (no Alarm filter) | UNS placement address is a reserved reference id with no node; v1 exports alarm-bearing raw tags as dead Variables (pre-existing defect) |
| Galaxy ack identity (m6) | `DataConnectionAuthInterceptor.cs:19,24` (data-connection bearer = data-plane API key, `FindUsableKey` → `ApiKeyId`); `GalaxyAckIdentitySecrets.cs:30,35` (`otopcua/apikeys/<keyId>/galaxy-ack-user|password`); `GalaxyAckCredentialResolver.cs:75` | Remote Galaxy acks work iff those secrets exist for the service key on the origin (§6) |
| Node build reporting (M1) | `ClusterNode.cs` has no version/build column (only `LastSeenAt`); the model snapshot has none | The M1 "all nodes upgraded" check is procedural (§4.3) |
@@ -293,8 +302,9 @@ message ConditionState {
bool active = 6; bool acknowledged = 7; bool confirmed = 8; bool enabled = 9; int32 shelving = 10;
uint32 severity = 11; string message = 12; uint32 quality = 13; google.protobuf.Timestamp unshelve_at = 14;
int32 condition_class = 15; google.protobuf.Timestamp time = 16; bool retain = 17;
google.protobuf.Timestamp activation_time = 18; // ActiveState transition time (method precondition, N6)
ActivationMarker activation = 18; // origin-owned; changes only on a new occurrence (T3)
optional string comment = 19; optional string client_user_id = 20; }
message ActivationMarker { string incarnation = 1; uint64 sequence = 2; } // (serving incarnation, per-condition sequence)
message ConditionStates { // SubscriptionFrame oneof arm 9
Handle handle = 1; // the root-scoped item's handle
bool is_snapshot = 2; optional int32 total = 3; // total on the first snapshot chunk (admission before materialising, N5)
@@ -302,7 +312,7 @@ message ConditionStates { // SubscriptionFrame oneof
rpc CallConditionMethod(ConditionMethodRequest) returns (ConditionMethodResponse);
message ConditionMethodRequest { string operation_id = 1; View placement = 2; int32 method = 3;
google.protobuf.Timestamp expected_activation_time = 4; optional string comment = 5;
ActivationMarker expected_activation = 4; optional string comment = 5;
string expected_serving_incarnation = 6; int64 remaining_budget_ticks = 7;
optional string on_behalf_of = 8; } // untrusted audit text; capped, sanitised, audit-log only (§6)
message ConditionMethodResponse { int32 state = 1; uint32 status_code = 2; optional string diagnostic = 3; Serving serving = 4; }
@@ -390,23 +400,53 @@ conditions re-report (`NM:5639-5651`). Some state changes never produce an event
record.
- **Never a falsely empty or falsely normal snapshot.** Each record carries `state_known`. **No such field exists today**:
`_alarmConditions` maps keys to `AlarmConditionState` only. A1 adds `HashSet<RealmKey> _conditionStateKnown` in NM,
maintained under `Lock`:
- **cleared** when a condition is (re)materialised (`MaterialiseAlarmCondition`, registration at `NM:2636`) and on removal;
- **set** when `WriteAlarmCondition` applies a snapshot (`NM:1323`), whether or not the delta gate fires an event — every
native driver transition and every scripted engine projection arrives here;
- **set** by `RestoreCarryOver` (`NM:2727`): #641 carried-over state is known;
- **native, normal-state conditions:** a transition-only source (MTConnect, FOCAS) never projects a condition that stays
normal. Such a condition becomes known once its native `Quality` has been Good for `ConditionKnownSettleMilliseconds`
(default 10 s). Quality starts `BadWaitingForInitialData` at materialise (`NM:2527`) and is driven Good by the driver
connectivity path through `WriteAlarmQuality` (`NM:1480`). This only needs a timestamp beside the set, recorded when
`WriteAlarmQuality` first observes Good. The settle default is calibrated by live measurement L4 (§9.3).
- **scripted, normal-state conditions:** `ScriptedAlarmHostActor` re-asserts only **non-normal** conditions after (re)load
(`ScriptedAlarmHostActor.cs:491`), so a normal scripted condition never reaches `WriteAlarmCondition`. A1 adds a sink call,
`IOpcUaAddressSpaceSink.MarkScriptedConditionsKnown(generation)` (`Commons/OpcUa/IOpcUaAddressSpaceSink.cs`). The host
sends it, through the existing `OpcUaPublishActor` path, right after the re-assert pass completes, and it marks every
scripted condition of that generation known.
- On a Warm standby native drivers do not run, so native conditions stay unknown until promotion. That is correct, and the
stream is Primary-only by default.
maintained under `Lock`.
**Invariant (T2), stated and tested:** *the consumer never retires or clears an alarm that is active at the origin.* A
condition may be declared known only once its state is actually established; "loaded", "connected" or "a window elapsed"
is not enough where a real signal exists.
- **Cleared** when a condition is (re)materialised (`MaterialiseAlarmCondition`, registration at `NM:2636`) and on removal.
- **Set when a state is applied.** `WriteAlarmCondition` applies a snapshot (`NM:1323`) for every native driver transition
and every scripted projection. A projection *is* an established state.
- **Set when carried over.** `RestoreCarryOver` (`NM:2727`): #641 carried-over state is known.
- **Scripted, normal-state conditions (T2).** `Active` is not persisted. The engine re-derives it at load from a value cache
seeded by `ReadTag` before any driver has published (`ScriptedAlarmEngine.cs:440-461`), and the engine already tells a
never-pushed input apart (`StatusNeverPushed`, `ScriptedAlarmEngine.cs:58-67`; `WorstInputStatus`, `:1325`). So a
scripted condition is known only when **none of its inputs is still `StatusNeverPushed`** — not when load completes.
- A1 adds an engine callback, `OnInputsEstablished(alarmId)`, raised from the evaluation path the first time after load
that an alarm's read cache holds no never-pushed input, and re-raised if an input reverts to never-pushed (a tag
re-created by a deploy). `ScriptedAlarmHostActor` turns it into the sink call below.
- A scripted condition whose inputs never arrive stays unknown: Uncertain on the consumer, which is honest. The origin
cannot know its state either.
- **Native, normal-state conditions (T2).** A transition-only source never projects a condition that stays normal. In
order of preference:
1. **A real driver signal, where one exists.** A new optional capability
`IAlarmInitialStateSignal { Task InitialAlarmStateDelivered { get; } }` (`Abstractions/`), completed when the driver
has delivered its standing alarms after a (re)connect. Two drivers already have the event to wire it to: Galaxy's
`IGalaxyAlarmFeed.InitialSnapshotCompleted` (`Drivers/…Galaxy/Runtime/IGalaxyAlarmFeed.cs:38`), and OpcUaClient's
ConditionRefresh sweep after subscribing (`OpcUaClientDriver.cs:2552`, `TryConditionRefreshAsync`).
2. **A per-driver-type settle timer as the fallback,** for MTConnect, FOCAS, AbCip ALMD and Heidenhain: the remaining
`IAlarmSource` implementers. It starts when native `Quality` turns Good (materialise sets `BadWaitingForInitialData`,
`NM:2527`; `WriteAlarmQuality`, `NM:1480`).
- Configured as `DataConnections:ConditionKnownSettle:<DriverType>`.
- **Default 60 s** for any driver type not calibrated by L4 (§9.3); a calibrated type uses ≥ 2× its measured p99.
- **Residual, stated:** for a fallback-timer driver whose initial replay exceeds its configured window, a false clear
remains possible. L4 must measure each shipped fallback driver. The invariant test (A1) covers the signal-bearing
drivers and scripted conditions exactly, and the timer drivers at their calibrated window.
- **Every unknown → known transition is a hub delta (T1).** Neither the signal nor the timer changes node state, so neither
existing tap would fire. Both paths therefore end in one sink call that raises the deltas itself:
- `IOpcUaAddressSpaceSink.MarkConditionsKnown(scope)` (`Commons/OpcUa/IOpcUaAddressSpaceSink.cs`), where scope is
`(driverInstanceId)` for native or `(alarmIds)` for scripted.
- It is sent as an actor message through `OpcUaPublishActor`. Native sends come from `DriverHostActor`, which owns the
driver-signal continuation and the per-driver one-shot settle timer (an Akka scheduled message, started on the
connectivity edge and cancelled on disconnect). Scripted sends come from `ScriptedAlarmHostActor` on
`OnInputsEstablished`.
- NM sets the flags under `Lock` and raises one **state-only hub record per newly-known condition**. There is no
snapshot-time evaluation: a consumer whose snapshot was cut before the transition receives the known record as an
ordinary delta.
- On a Warm standby native drivers do not run, so native conditions stay unknown until promotion. The standby's scripted
engine is warm, so its scripted conditions are already known. The stream is Primary-only by default.
`snapshot_complete` is withheld until the origin's current address-space apply has completed (`CompleteAddressSpaceApply`
ran for the active generation) and the serving node holds its Primary verdict. Until then the stream sends a Control `NotReady`.
- **Consumer rule:** a condition is retired only when it is absent from a complete snapshot, or a removal record arrives. A
@@ -445,13 +485,19 @@ addressed in that realm:
it is `"<len>:<driverInstanceId><RawPath>"` (`SourceSamplePublisher.cs:32-33`, emitted at
`LocalExportCatalog.Compilation.cs:92,123`), so it would disclose the RawPath.
`condition_key = base64url(HMAC-SHA256(K_p, originClusterId ‖ 0x00 ‖ ConditionId))`, where
K_p = HKDF(`DataConnections:ConditionKeySecret`, info = authenticated principal id). The secret is a per-origin-cluster
`condition_key = base64url(HMAC-SHA256(K, originClusterId ‖ 0x00 ‖ ConditionId))`, where
K = HKDF(`DataConnections:ConditionKeySecret`, info = `"otopcua/condition-key/v1"`). The secret is a per-origin-cluster
`${secret:}`, identical on both pair members.
- It is stable across restarts, failover and re-deploys.
- It is identical across a principal's Raw and UNS listings, so the consumer dedupes.
- It differs per principal, so two principals cannot correlate.
- It is identical across all of the origin's listings and principals, so the consumer dedupes Raw and UNS placements.
- **m-T6, revision 5:** the key is no longer per principal. Two consumer pair members that authenticate as different
principals (two exports) still mint the **same** `ConditionId`, so a client failing over between them sees no change.
Keying per principal would instead require a "one principal per connection across `ConsumerNodeIds`" rule, which the
validator cannot check: credentials are provisioned per node and never appear in the artifact.
- The cost is cross-principal unlinkability, which is weak here: both principals are authorized for the same origin
conditions.
- A06 asserts equal ConditionIds on both consumer nodes.
- It cannot be dictionary-reversed from guessable paths. An unkeyed hash was rejected for that reason.
- If the secret is absent, the origin advertises no `conditions` capability (fail closed, with a diagnostic).
@@ -539,9 +585,15 @@ Imported conditions do **not** use `MaterialiseAlarmCondition` or the `RealmKey`
(`OtOpcUaSdkServer.cs:746,768`), is extended from `DataChangeNotification` to `EventNotificationList`:
- a marked list whose check fails is **dropped**. Events have no Bad-value form, and the drop is counted.
- The one path that rebuilds queued lists is a `ModifyMonitoredItems` that changes select clauses: `GetEventFields`
creates a plain `EventFieldList` but keeps `Handle` = the original event instance. The rewriter therefore treats an
**unmarked** list whose `Handle` is an imported-condition snapshot (its `ConditionId` is in the `mapped/conditions`
namespace) as unauthorised and drops it — fail closed, counted.
creates a plain `EventFieldList` but keeps `Handle` = the original event instance. For an **unmarked** list whose
`Handle` is an imported-condition snapshot (its `ConditionId` is in the `mapped/conditions` namespace), the rewriter is
given the publishing session's identity (from the Publish/Republish request context at `OtOpcUaSdkServer.cs:746,768`).
- It **re-evaluates** the §5.4 gate for that session and condition, and keeps the list when allowed.
- It drops the list only when the gate denies or cannot be evaluated. Such a drop is counted, and that item receives a
`RefreshRequiredEventType`, so an authorised client is told to refresh rather than silently losing a transition.
- **Imported-condition events always use the marked path,** independent of the `UseProjectedEventDelivery` switch
(`NM:1915`; when it is off the SDK's own `QueueEvent(IFilterTarget)` is used, `NM:1930`). The registry delivers imported
conditions through `ProjectedEventFieldList` unconditionally; the switch governs local conditions only.
- **Gate A3-SEC:** with `Security:Acl:Enabled=false`, a session without the mapping grant at `i=2253` and on a projected folder
receives zero imported events and zero on refresh. A positive-control session with the grant receives them, and the absence
assertion follows a must-arrive sentinel.
@@ -613,6 +665,14 @@ Defaults (conditions get their **own** budget; worst case is 49 nodes):
node's mappings exceeds `MaxImportedConditionNodes`.
- Whether 1,000 per mapping / 2,500 per node covers real exports is live measurement L5 (§9.3). The defaults are tunable and
sized from the measured memory cost, not from a guessed plant size.
- **What the 157 KiB excludes (m-T7):**
- NM's indexes;
- the `c1.<base64url JSON>/<browse path>` identifier strings on 48–49 nodes;
- the per-condition EventId registry;
- placement sets.
**L2 is the authority:** `MaxImportedConditionBytes` is set from the L2 measurement (per-condition in-server bytes × 2,500),
and the 400 MiB above is a provisional default until L2 passes.
**Stream mechanics.**
@@ -670,6 +730,13 @@ Defaults (conditions get their **own** budget; worst case is 49 nodes):
Residual: master-level `ValidatePermissionsAsync` still checks `RolePermissions` on the object and method nodes. Imported
nodes set none, so they pass; the mapped gate in step 2 is the authority.
Third-pass notes:
- `base.Call` runs inside the SDK's `BeginNodeManagerOperation()` scope. It is called and **completed before** any remote
await, so no remote wait sits inside that scope.
- The dispatcher awaits node managers sequentially, but the SDK registers the configuration and core managers first and
the `MasterNodeManager` constructor's additional managers last (decompiled ctor), and `OtOpcUaSdkServer.cs:883` passes NM
as the only additional manager. So no later-registered manager waits behind an imported-condition call.
Imported conditions get no state-applying SDK handlers and are never wrapped by `ReportAfterMethod`.
2. **Local checks** (no I/O, no `Lock`):
- mapping gate `AlarmOperationFor(method)` on any current placement;
@@ -678,13 +745,37 @@ Defaults (conditions get their **own** budget; worst case is 49 nodes):
- Warm Standby refusal (`NM:3122-3124` rule);
- **EventId:** must be one this consumer minted for that condition within its last N (default 8) events — a small registry
with its own lock. Unknown ⇒ `BadEventIdUnknown`.
3. **Precondition and re-binding (N6).** Each minted EventId is bound to the record it was reported with; the record carries
the origin's `activation_time`, its ActiveState transition time. That value is sent as `expected_activation_time`.
- When a resync (new epoch, including origin failover or restart) delivers a record whose state is unchanged under the
shared delta gate, the consumer **re-binds** that condition's retained EventIds to the new record. Pre-failover EventIds
stay ackable without a ConditionRefresh even if the promoted node reports a different transition time.
- A changed state (a new activation) does not re-bind: the old EventIds answer `BadEventIdUnknown`.
- Gated in A03.
3. **Precondition and re-binding (N6, T3).** The SDK field cannot be used:
`AlarmConditionState.SetActiveState` stamps `ActiveState.TransitionTime = DateTimeUtc.Now` on every call, changed or
not (decompiled SDK 2.0.1 `Opc.Ua.Core.Types`, `AlarmConditionState.SetActiveState`). `WriteAlarmCondition` calls it on
every projection (`NM:1364`).
Instead the origin keeps an **activation marker** per condition in NM: `(serving incarnation, sequence)`, under `Lock`.
- **Bumped only on a new occurrence:**
- an Active false→true edge;
- an Acked true→false edge while Active. This is #647's changed-message re-raise, which un-acks and so needs a new
acknowledgement; this extends the review's inactive→active rule, because otherwise an old EventId could acknowledge
the new statement.
- **Never bumped** by a re-projection that leaves Active/Acked unchanged: severity or message updates, same-message
re-raises, re-asserts, method echoes.
- `RestoreCarryOver` carries the marker through a rebuild; `NativeConditionCarryOver` already carries
`ActiveTransitionTime`, `NM:2670-2747`, and gains the marker.
The consumer:
- binds each minted EventId to the marker of the record it was reported with;
- always sends the marker of the **latest applied record** as `expected_activation`;
- decides EventId validity locally by "minted under the same marker as the latest record". A state-only record with an
unchanged marker invalidates nothing.
The origin rejects a mismatch with `BadEventIdUnknown`, which covers a new occurrence not yet streamed.
- **N6 re-checked:** a resync (origin failover or restart) yields a new incarnation and therefore a new marker. When the
resynced record's state is unchanged under the shared delta gate, the consumer **re-binds** that condition's retained
EventIds to the new marker, so pre-failover EventIds stay ackable without a ConditionRefresh. A changed state does not
re-bind. Gated in A03.
- **A2 test (T3):** re-project an unchanged active alarm at the origin (message-only change, then a scripted re-assert),
then ack with the pre-re-projection EventId ⇒ Good. A changed-message re-raise ⇒ the old EventId answers
`BadEventIdUnknown`.
4. **Remote call.** One bounded remote `CallConditionMethod`. Timeout = min(request deadline, `ConditionMethodTimeout`,
default 5 s).
5. **Result.** The consumer returns the origin's status and does **not** touch local condition state. The origin applies and
@@ -706,7 +797,7 @@ around the other. It:
- takes `Lock`;
- runs the gate: origin ACL on the **placement's** subject for the service principal, Primary gate, Warm Standby refusal,
native preflight;
- checks `expected_activation_time` (mismatch ⇒ `BadEventIdUnknown`);
- checks `expected_activation` against the condition's current activation marker (mismatch ⇒ `BadEventIdUnknown`);
- native: applies Ack + the Confirmed/Retain re-assert + the comment, reports once, invokes the non-blocking
`NativeAlarmAckRouter` (the `DriverHostActor.cs:2612-2637` contract holds);
- scripted: publishes `AlarmCommand` unchanged (§6 audit);
@@ -767,7 +858,7 @@ NodeId: accepted under owner decision Q2, as removal + addition + RefreshRequire
|---|---|---|
| H2 | `AddDataConnectionHistory` | `DataConnection.HistoryTimeoutMilliseconds` (30000); `DataExport.MaxConcurrentHistoryReads` (4), `MaxHistoryValuesPerPage` (10000), `MaxHistoryResponseBytes` (4 MiB); `RemoteNamespaceMapping.MaxHistoryAssemblyBytesPerRequest` (16 MiB) |
| A2 | `AddDataConnectionConditions` | `DataExport.MaxConditions` (1000), `AllowGalaxyServiceAck` (false); `RemoteNamespaceMapping.MaxConditions` (1000), `ConditionStaleTimeoutMilliseconds` (30000), `ConditionMethodTimeoutMilliseconds` (5000), `ConditionSnapshotTimeoutMilliseconds` (30000) |
| A2 (host options, not ConfigDb) | — | `DataConnections:MaxImportedConditionNodes` (122500), `DataConnections:MaxImportedConditionBytes` (400 MiB), `DataConnections:ConditionKnownSettleMilliseconds` (10000, origin), `DataConnections:ConditionKeySecret` (secret) |
| A2 (host options, not ConfigDb) | — | `DataConnections:MaxImportedConditionNodes` (122500), `DataConnections:MaxImportedConditionBytes` (400 MiB), `DataConnections:ConditionKnownSettle:<DriverType>` (origin; 60 s default for uncalibrated fallback drivers, L4-calibrated otherwise), `DataConnections:ConditionKeySecret` (secret) |
Each migration phase also adds the bits to `KnownOperations`, extends `DeploymentArtifact.DataConnections.cs`, and includes the
new fields in `DataConnectionScopeRevision` (so DB-less nodes and the LocalDb artifact cache receive them). It also adds
@@ -843,7 +934,9 @@ Project keys are the v1 plan's (A, C, F, K, R, O, H, P, U, L), plus `OpcUaServer
Deployability: X0 is a release of its own. H2, H3 and H4 each deploy and are usable alone: H2 gives runtime consumers direct
history, H3 OPC UA clients, H4 the Gateway sign-off. A1 is invisible until A2/A3 negotiate it. A2 alone gives runtime consumers
condition state and methods; A3 OPC UA clients.
condition state and methods; A3 OPC UA clients. **m-T5:** A1–A3 are not deployable to a fleet until A4 passes. The A2 migration's
condition defaults (`MaxConditions` 1,000, byte cap 400 MiB) are provisional until L2 (A3 exit) and L5 (A4) confirm them. The
settle windows are calibrated at the A1 exit (L4), before `state_known` ships.
### X0 — Tolerant readers and contract reservation (release before any new bit)
@@ -964,8 +1057,10 @@ Expected: identical rows/status/timestamps to the origin; continuation followed
- Tasks:
- `SnapshotConditions(scope)` under a short `Lock` hold with watermark;
- the delta callback in `ReportConditionEvent` (before the standby return) and in `WriteAlarmCondition` for silent applies;
- `state_known`: `_conditionStateKnown` + Good-quality settle timestamp in NM, and
`IOpcUaAddressSpaceSink.MarkScriptedConditionsKnown(generation)` sent by `ScriptedAlarmHostActor` after re-assert;
- `state_known`: `_conditionStateKnown` in NM; `IOpcUaAddressSpaceSink.MarkConditionsKnown(scope)` raising state-only
deltas; `IAlarmInitialStateSignal` (Abstractions) wired for Galaxy and OpcUaClient; per-driver-type settle timer in
`DriverHostActor`; `ScriptedAlarmEngine.OnInputsEstablished` → `ScriptedAlarmHostActor`;
- the per-condition activation marker in NM, carried by `RestoreCarryOver` (T3);
- the `ConditionStateHub`;
- realm-local placement enumeration per export: Raw = RawPath; UNS = reference variable ids and ScriptedAlarmId;
- the `condition_key` derivation and its secret;
@@ -973,7 +1068,9 @@ Expected: identical rows/status/timestamps to the origin; continuation followed
- `ProjectedDataIds`-style `c1.` identifier, child id helpers and the condition-namespace constant.
- Files: NM (snapshot + callback + `state_known` only), `Commons/OpcUa/IOpcUaAddressSpaceSink.cs` (+ `DeferredAddressSpaceSink`,
`SdkAddressSpaceSink`, the no-op sink), `Runtime/OpcUa/OpcUaPublishActor.cs` (forwarding),
`Runtime/ScriptedAlarms/ScriptedAlarmHostActor.cs` (send after re-assert), new `Runtime/DataConnections/ConditionStateHub.cs`,
`Runtime/ScriptedAlarms/ScriptedAlarmHostActor.cs`, `src/Core/ZB.MOM.WW.OtOpcUa.Core.ScriptedAlarms/ScriptedAlarmEngine.cs`
(`OnInputsEstablished`), `Runtime/Drivers/DriverHostActor.cs` (signal/timer), new `Abstractions/IAlarmInitialStateSignal.cs`,
`Drivers/…Galaxy/GalaxyDriver.cs`, `Drivers/…OpcUaClient/OpcUaClientDriver.cs`, new `Runtime/DataConnections/ConditionStateHub.cs`,
`LocalExportCatalog*.cs` (placement enumeration; the catalog stays v1-shaped), `LocalCatalogCoordinator.cs`,
`Abstractions/DataConnections/ProjectedDataIds.cs` (or a sibling `ImportedConditionIds.cs`).
- Tests:
@@ -981,18 +1078,27 @@ Expected: identical rows/status/timestamps to the origin; continuation followed
- a **falsely-empty** negative test: an origin restart with standing alarms ⇒ `snapshot_complete` is not sent until apply
completes, and no record claims "inactive" with `state_known = true` before its source projected;
- a snapshot never covers more than `MaxConditions` under one `Lock` hold (structural test); the in-server hold time is L1 (§9.3);
- a normal-state scripted condition becomes known only after `MarkScriptedConditionsKnown`; a normal-state native
condition only after the quality settle window; a carried-over condition at once;
- **T1:** snapshot cut inside the window, then the driver signal or timer fires ⇒ the consumer receives a state-only known
record and its condition quality returns Good with no further origin activity (positive control: the record arrives;
negative: no record before the signal);
- **T2 invariant:** across origin restart, rebuild and failover, the consumer never emits Active=false/Retain=false for a
condition that is active at the origin, checked against origin node state after settling. Cases:
- (i) a standing scripted alarm whose input arrives 30 s late ⇒ no `known, inactive` record before the first real
evaluation;
- (ii) a Galaxy/OpcUaClient-style driver whose initial replay arrives after quality Good ⇒ known only on
`InitialAlarmStateDelivered`;
- (iii) a fallback-timer driver ⇒ known only after its configured window;
- a carried-over condition is known at once; an input reverting to never-pushed makes the scripted condition unknown again;
- a UNS-only export lists no RawPath anywhere in the record (property test over generated topologies);
- `condition_key` stable across restart and pair members, equal across a principal's Raw/UNS listings, different across
principals;
- `condition_key` stable across restart and pair members, and equal across listings and principals (m-T6);
- A: id and child round-trip.
- Exit gate: A1 manifest; reviewer sign-off on the state-source inventory.
- Exit gate: A1 manifest; reviewer sign-off on the state-source inventory; **L4 passed** (settle windows calibrated per
shipped fallback driver, signal latency recorded for Galaxy/OpcUaClient), moved here from A4 (m-T5).
**A2 — Wire and origin execution.**
- Tasks: condition items on Subscribe (arm 9, non-coalescing class, `snapshot_complete`); `CallConditionMethod`;
root-scoped `condition_scope` items with `total`, `removed`, `snapshot_complete` (§5.5); `TryExecuteConditionMethod` (§5.6
origin, placement-resolved, `expected_activation_time`); Primary/standby; operation registry; audit-log sanitising;
origin, placement-resolved, `expected_activation` marker); Primary/standby; operation registry; audit-log sanitising;
`AllowGalaxyServiceAck`; **validator bits + `Implemented(target)` + `AddDataConnectionConditions` + artifact + AdminUI
checkboxes**.
- Files: proto/mapper, `Runtime/DataConnections/{DataSubscriptionSession,DeliveryScheduler,LocalSubscriptionService,LocalDataServices,WriteOperationRegistry,DataCapabilitiesProvider}.cs`,
@@ -1005,7 +1111,8 @@ Expected: identical rows/status/timestamps to the origin; continuation followed
- native AddComment stored;
- off-Primary / Warm Standby ⇒ `RejectedBeforeDispatch`;
- Galaxy without opt-in ⇒ `BadUserAccessDenied`, no state change;
- `expected_activation_time` mismatch ⇒ `BadEventIdUnknown`;
- activation-marker mismatch ⇒ `BadEventIdUnknown`; an unchanged re-projection keeps old EventIds ackable (T3 test,
§5.6 step 3);
- a method through a UNS placement resolves to the condition and is authorized on the equipment subject;
- duplicate operation id joins;
- transport drop ⇒ `OutcomeUnknown`, no retry;
@@ -1054,7 +1161,7 @@ Expected: identical rows/status/timestamps to the origin; continuation followed
| A03 | Origin failover mid-stream with standing active alarms ⇒ resync retires nothing still active, no duplicate events, positive control; an ack with a **pre-failover** EventId succeeds after the unchanged resync (N6) |
| A04 | One native alarm referenced by two equipment + a Raw mapping ⇒ one consumer condition (same `ConditionId` regardless of which mapping's subscriber came first), three notifiers, one `i=2253` event; a UNS-only principal's records carry no RawPath |
| A05 | ACLs off, session without mapping grant at `i=2253` ⇒ zero imported events (with positive control) |
| A06 | Consumer Primary change with clients connected to both consumer nodes ⇒ both converge, no duplicates |
| A06 | Consumer Primary change with clients connected to both consumer nodes ⇒ both converge, no duplicates; the same alarm has the **same `ConditionId` on both consumer nodes**, including when they authenticate as different principals (m-T6) |
| A07 | Consumer node restart ⇒ ConditionRefresh correct after snapshot; RefreshRequired observed if refresh preceded snapshot |
| A08 | Revoke `AlarmAcknowledge` at origin ⇒ method denied, state still streams; no consumer `alerts`/alarm-history rows |
@@ -1095,7 +1202,9 @@ Use two-state id selection via `SimpleAttributeOperand(type, [X, Id])`, as the C
| Remote wait freezes the address space | A3 | Interception before `Lock`, semaphore, lock-freedom gate |
| Remote ack is a no-op at origin | A2 | Session-less entry factored from the SDK path; origin-subscriber assertion |
| Partial condition sets make ConditionRefresh lie | A3 | Per-mapping all-or-nothing decided at snapshot begin from `total`; own budget sized ≈ 4× expected counts |
| Failover/restart clears live alarms on the consumer | A1/A3 | Snapshot from node state, `state_known`, withheld `snapshot_complete`, retire-only-on-complete; A1 (a)–(c), A03 |
| Failover/restart clears live alarms on the consumer | A1/A3 | Snapshot from node state; `state_known` only on established state (driver signal, inputs established, per-driver window); withheld `snapshot_complete`; retire-only-on-complete; T2 invariant test, A03 |
| A fallback-timer driver replays slower than its window | A1 | Per-driver window, L4 per driver, 60 s default for unmeasured types; residual documented (§5.1) |
| Acks fail on busy alarms because the precondition moves | A2 | Origin-owned activation marker, bumped only on a new occurrence (T3) |
| RawPath disclosure to UNS-only principals | A1 | Realm-local placements; keyed `condition_key`; property test; pre-existing `stable_source_id` disclosure is #916 |
| Imported-condition method path regresses local methods | A3 | Claimed items only (`Processed`), `base.Call` unchanged for the rest; lock-freedom gate; existing `ConditionMethodEventTests` stay green |
| Imported-condition memory (≈ 157 KiB each) | A3 | Own budget sized from the counted cost; byte cap 400 MiB per consumer node; L2 confirms in-server |
@@ -1122,9 +1231,9 @@ delta over 2,000 instances, and times the snapshot field copy. It is not in the
| ID | Phase | Measurement | Pass criterion |
|---|---|---|---|
| L1 | A1 | `SnapshotConditions` `Lock` hold inside a running origin with 1,000 conditions in scope while drivers publish | p99 ≤ 10 ms; no data Publish on the origin delayed > 50 ms during a snapshot |
| L2 | A3 | Consumer memory with 1,000 imported conditions (one mapping) | Working-set growth ≤ 200 MiB (≈ 1,000 × 157 KiB + indexes); if exceeded, lower the defaults before A4 |
| L2 | A3 exit | Consumer memory with 1,000 imported conditions (one mapping), including ids, registries and indexes (m-T7) | Working-set growth ≤ 200 MiB; set `MaxImportedConditionBytes` = measured per-condition bytes × 2,500 and lower `MaxConditions` if needed, before A4 freezes defaults |
| L3 | A3 | Lock-freedom: origin method handler stalled 5 s | Concurrent consumer Read/Browse/Publish < 200 ms; no local ack state before the origin record (§5.6 step 6) |
| L4 | A4 | `ConditionKnownSettleMilliseconds`: time from driver connected (quality Good) to initial alarm snapshot delivered, for the docker-dev native source (OpcUaClient → opc-plc `--alm`); Galaxy reconnect snapshot latency on the AVEVA rig when available | Default (10 s) ≥ 2× the observed p99; else raise it |
| L4 | **A1 exit** (m-T5) | Per native alarm source shipped: time from quality Good to the driver's standing alarms all projected. Galaxy and OpcUaClient (→ opc-plc `--alm`): signal latency. MTConnect, FOCAS, AbCip ALMD, Heidenhain: settle window, on their software fixtures or the hardware rigs recorded in memory | Each fallback driver's `ConditionKnownSettle:<DriverType>` ≥ 2× its observed p99; an unmeasured driver type keeps the conservative 60 s default and is listed as unmeasured; the T2 invariant test passes for every measured source |
| L5 | A4 | Condition counts of the docker-dev export and of one real production export (read-only count via the origin's existing AdminUI `/alerts` or ConfigDb authoring counts) | Each mapping ≤ 80% of `MaxConditions` and each consumer node ≤ 80% of the host caps; else adjust the defaults and record why |
---
@@ -694,3 +694,138 @@ overhead; keep L2 as the authority and size `MaxImportedConditionBytes` from it,
No Blocker. Majors: **T1** (no delta when a condition becomes known), **T2** (known-inactive declared too early for
scripted cold start and slow native replay), **T3** (`expected_activation_time` moves on every projection). All three are
Phase A only.
---
## Fourth pass (2026-11-23)
Reviewed: revision 5 of [`2026-11-23-grpc-data-connections-history-alarms-plan.md`](2026-11-23-grpc-data-connections-history-alarms-plan.md).
Baseline `649f2ecd2`; SDK references are to the same `ilspycmd` decompiles of the pinned 2.0.1 packages as the third pass.
Nothing was run; findings are from reading code.
### Final verdict per phase
- **X0 — approve.**
- **Phase H — approve.**
- **Phase A — approve with changes.** The design is now sound and T1/T3 are closed. Two Majors remain, both about *where*
the new "known" signal is taken and ordered (F1, F2). They are plan edits of a few lines each, not a redesign, and both
belong to A1. No Blocker.
### Third-pass items
| Item | Status | Evidence |
|---|---|---|
| **T1** no delta on unknown→known | **Closed.** One sink call (`MarkConditionsKnown(scope)`) sets the flags under `Lock` and raises a state-only record per newly-known condition; no snapshot-time evaluation. The remaining requirement is ordering — F2. |
| **T2** known-inactive too early | **Partially closed.** Scripted: closed in design (see below). Native: the Galaxy signal is real; the OpcUaClient one is taken at the wrong point (F1); the four timer drivers have a better signal available (F3). |
| **T3** activation precondition | **Closed.** Origin-owned `(incarnation, sequence)` marker, not the SDK field (SDK: `AlarmConditionState.SetActiveState` ≈912-919; `NM:1364`); consumer sends the latest applied record's marker and validates EventIds locally; carried through `RestoreCarryOver` (`NM:2670-2747`). One edge missing from the bump rule — F4. |
| B5 notes | **Closed.** |
| **m-T4** | **Closed.** Rewriter re-evaluates the gate for the publishing session, drops only on deny/not-evaluable with `RefreshRequired`; imported events always use the marked path. |
| **m-T5** | **Closed** (L4 at A1 exit; L2 at A3 exit with A2 defaults provisional; A1–A3 not fleet-deployable before A4). |
| **m-T6** | **Closed** by the alternative (cluster-wide key). Agreed: the validator cannot see per-node credentials, and the unlinkability lost is between principals already authorised for the same conditions. The key is still secret-derived, so guessable paths cannot be reversed. |
| **m-T7** | **Closed** (L2 is the authority). |
### Checks requested
**Galaxy signal — exists, with two properties the plan should state.**
`IGalaxyAlarmFeed.InitialSnapshotCompleted` (`src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Galaxy/Runtime/IGalaxyAlarmFeed.cs:30-38`):
"every snapshot entry has been raised on `OnAlarmTransition`, then the gateway's `snapshot_complete` sentinel arrived".
That is the right meaning. But:
- it is **one-shot per feed instance**: a readonly `TaskCompletionSource` set by `TrySetResult` on the first sentinel
(`Runtime/GatewayGalaxyAlarmFeed.cs:69,168`); the feed's reopen loop (`:140-152`) does not reset it. The plan's "after a
(re)connect" is true only for a driver restart, not a gateway stream reopen. That is harmless for `state_known`
(known is not cleared on disconnect) but the wording should match.
- it **never completes** if the gateway sends no sentinel (interface doc: "stays incomplete while … the gateway has not
answered"). With a signal-only rule, every normal-state Galaxy condition then stays `Uncertain` on the consumer
indefinitely — see F5.
**OpcUaClient signal — does not mean what the plan says (F1).**
**`OnInputsEstablished` — implementable.** The read cache is in hand on both evaluation paths
(`ScriptedAlarmEngine.cs:903`, `:1055`), and never-pushed inputs are identifiable by `StatusNeverPushed` (`:67`).
Note `WorstInputStatus` (`:1325-1330`) *filters those out*, so the check is a new predicate over `scratch.ReadCache`, not
a reuse of that function. Subject to F2 for ordering.
**Un-ack-while-active trigger — right, but one edge short (F4).** It correctly covers the changed-message re-raise and
the #760 ack-revert (the revert reports a new event, so the client holds an EventId bound to the new marker).
**Residual risk — not acceptable as stated for the shipped drivers; a stronger mitigation is cheap (F3).**
### New findings
#### F1 (Major) — OpcUaClient: `TryConditionRefreshAsync` returning is not "standing alarms delivered"
`TryConditionRefreshAsync` (`src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.OpcUaClient/OpcUaClientDriver.cs:2881-2900`) awaits the
ConditionRefresh **method call**. The refreshed condition events arrive afterwards on the subscription, bracketed by
`RefreshStartEventType`/`RefreshEndEventType`, which the driver currently discards as markers (`:2863-2864`, `:3066-3067`).
Completing `InitialAlarmStateDelivered` at `:2552` therefore marks every condition known **before** the standing alarms
have been projected: the consumer receives `known, inactive`, clears, then receives the raise. That breaks the plan's own
invariant on the one driver A02 uses.
Two further cases at the same site: the upstream server may not support ConditionRefresh (caught and logged, `:2887-2893`:
"conditions already active are reported only on their next transition") and the call may fail (`:2894-2900`). Neither has
a signal at all.
**Fix.** Complete the signal on receipt of `RefreshEndEventType` for the alarm subscription (stop discarding it at
`:3066`), in the same handler that projects the refreshed events. When refresh is unsupported or fails, do not signal:
fall back to the driver-type timer and say so. A1 test: an upstream with a standing active alarm ⇒ no `known, inactive`
record precedes its raise.
#### F2 (Major) — the "known" signal must travel the same ordered path as the projections it follows
The plan has `DriverHostActor` own "the driver-signal continuation" and `ScriptedAlarmHostActor` send on
`OnInputsEstablished`. Neither says how the signal is ordered against the alarm projections that precede it:
- Galaxy raises snapshot entries on `OnAlarmTransition` and then completes a `TaskCompletionSource` created with
`RunContinuationsAsynchronously` (`GatewayGalaxyAlarmFeed.cs:69`). Transitions reach the node through
`DriverInstanceActor` → `DriverHostActor` → `OpcUaPublishActor`. A continuation piped straight to `DriverHostActor` can
overtake transitions still queued in `DriverInstanceActor`.
- Scripted: an evaluation that turns an alarm Active queues its emission into `pending`, fired after the gate is released
(`ScriptedAlarmEngine.cs:447-449`). A callback raised "from the evaluation path" can reach the host before that emission.
Either way `MarkConditionsKnown` lands before the Active projection ⇒ a `known, inactive` record ⇒ a false clear followed
by the raise.
**Fix.** State the rule: the signal is enqueued **behind** the projections it summarises, on the same mailbox chain
(driver signal sent by `DriverInstanceActor` to itself and forwarded like an alarm event; scripted callback raised after
the evaluation's pending emissions are dispatched). Add the ordering to the A1 invariant test for both kinds, with the
projection path artificially delayed.
#### F3 (Minor, but changes the stated residual) — the four "timer" drivers poll; use the first poll as the signal
The residual ("a fallback-timer driver whose initial replay exceeds its window can false-clear") is presented as
unavoidable for MTConnect, FOCAS, AbCip ALMD and Heidenhain. Three of them poll their alarm state and already know when
a poll completed: FOCAS records it (`src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.FOCAS/FocasDriver.cs:2023-2027`
`NoteAlarmReadSucceeded`), AbCip ALMD polls on an interval (`…Driver.AbCip/AbCipAlarmProjection.cs:36`), Heidenhain on
`Polling.AlarmMs` (`…Driver.Heidenhain/HeidenhainAlarmProjection.cs:145`). MTConnect starts from an agent `current`
document. "First complete alarm poll (all devices) after connect" is a real `IAlarmInitialStateSignal` for each.
**Recommendation.** Implement the signal for these in A1 and keep the timer only for a driver type with no signal. The
residual then applies to no shipped driver, L4 shrinks to recording signal latency, and the 60 s default becomes a
backstop rather than the mechanism. If that is not done, the residual is acceptable only with the per-driver L4 already
planned **and** a consumer-visible diagnostic counting `known, inactive` records that cleared a locally active condition.
#### F4 (Minor) — bump the marker on any Acked true→false edge, not only while Active
`NativeAlarmProjector` has a transition that projects **inactive + unacked in one update** for an occurrence that came and
went (`src/Server/ZB.MOM.WW.OtOpcUa.Runtime/Drivers/NativeAlarmProjector.cs:63-65,116-119`: "a condition can only have
become unacked through a new occurrence"). Active never goes false→true and Acked goes true→false while inactive, so
neither bump rule fires and an EventId from the previous occurrence can acknowledge the new one — the case the un-ack
rule was added to prevent. Rule: bump on Active false→true **or** any Acked true→false.
#### F5 (Minor) — a signal that never completes needs a bound
For a signal-bearing driver (Galaxy with a gateway that sends no sentinel; OpcUaClient without ConditionRefresh), "known"
never arrives and normal-state conditions stay `Uncertain` on the consumer with no operator-visible cause. Apply the
driver-type timer as an upper bound when the signal has not completed, and surface "initial alarm state not signalled"
in data-connection diagnostics.
#### F6 (Minor) — EventId re-binding on "unchanged" resync
Re-binding is decided by the shared delta gate, which does not include `Time` (`NM:2329-2339`). An alarm that cleared and
re-raised with the same message and severity during the gap, unacked both times, compares unchanged, so pre-gap EventIds
are re-bound to a different occurrence. Require the record's `time` (or the origin's activation timestamp carried beside
the marker) to match as well before re-binding.
### Open Major items at close
**F1** (OpcUaClient signal point) and **F2** (signal ordering), both Phase A1. Everything else is closed or Minor.