From 0c253b66df95521255b52b6b29d794d90992228c Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 25 Nov 2026 03:10:38 -0500 Subject: [PATCH] =?UTF-8?q?docs(grpc-data):=20A4=20F1=E2=80=93F4=20root=20?= =?UTF-8?q?causes,=20design=20decision=20(consumer=20holds=20imported=20co?= =?UTF-8?q?nditions=20across=20its=20own=20deploy;=20promote-on-admission)?= =?UTF-8?q?,=20native=20ack=20freeze=20=3D=20opc-plc=20behaviour;=20#935?= =?UTF-8?q?=20#936=20filed?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/AlarmTracking.md | 17 ++++--- docs/DataConnections.md | 3 ++ docs/plans/evidence/grpc-data-ext/A4.md | 65 +++++++++++++++++++++++++ 3 files changed, 79 insertions(+), 6 deletions(-) diff --git a/docs/AlarmTracking.md b/docs/AlarmTracking.md index 15d8a11b2..a26360dc0 100644 --- a/docs/AlarmTracking.md +++ b/docs/AlarmTracking.md @@ -831,12 +831,17 @@ This section is what an OPC UA client of the **consumer** sees. Code: `OpcUaServ Wiring is lazy, in both directions, and also adds a root notifier. It is unwired at every projected-removal site. Projected folders of a condition-bearing mapping are meant to have `SubscribeToEvents` from materialisation, so that a client can subscribe at a folder before any condition is wired there and open demand. - - ⚠️ **Live behaviour (A4 gate, runs `a4s-1` and `a4s-3`): that does not hold.** On a consumer node where no `i=2253` event - item has opened demand yet (including a freshly restarted node), an event item on a mapping's branch folder (e.g. - `remote-opc`) is refused `BadNotSupported` and the CLI `alarms -n ` exits. Once demand is open and the - conditions are wired, the same folder accepts items and delivers every event. - - **Workaround:** open demand with a Server-object (`i=2253`) event item first (ScadaBridge's DCL already does), then - subscribe at folders. A folder-only client never receives imported conditions. Tracked as an A4 finding. + - A projected folder that materialised **before** its mapping was condition-bearing (a freshly restarted consumer serves + its projected pages before the mapping's authority activates at the first barrier) is promoted when an event item on it + is **admitted** (the mapping gate passes): `SubscribeToEvents` re-checks the mapping and sets `SubscribeToEvents` before + the SDK attach. (A4 finding F4, fixed on `a4-code`: such a folder-first item used to be refused `BadNotSupported` until an + `i=2253` item had opened demand and a condition was wired there.) +- **A consumer's own deploy is not a removal.** Every deploy begins with an empty, undecided mapping set (the catalog + attempt is suspended until it completes). Imported conditions are **held** across it — the connection's next runner takes + them over and re-snapshots onto the same nodes, so an unchanged condition reports no event and keeps its EventIds. Only a + settled set without the mapping's connection (or the demand linger) removes them. (A4 findings F1–F3, fixed on `a4-code`: + each deploy used to remove and re-create every imported condition — a phantom event per active condition, an origin + transition delivered twice, every older EventId `BadEventIdUnknown` with no RefreshRequired.) - **One event per origin transition.** It is delivered to every wired folder item and to the Server object (`i=2253`), however many placements the condition has (one `ReportEvent`, through the shared report walk). - A folder holding an admitted event item is pinned: projection eviction and paging skip it. Removing the mapping still diff --git a/docs/DataConnections.md b/docs/DataConnections.md index e6fb105d9..9a11c02d2 100644 --- a/docs/DataConnections.md +++ b/docs/DataConnections.md @@ -358,6 +358,9 @@ An origin streams its alarm condition state to a peer that negotiated `condition condition item cannot outlive the identity it was admitted under. Conditions that a deploy adds or removes therefore never arrive as delta records. The consumer reconnects and takes a complete snapshot of the new catalog. (Corrected in the A2 review, S1. Earlier text here said a deploy's adds/removes arrive as deltas; only a fixture could do that.) +- **A consumer deploy holds its imported conditions.** The consumer's own deploy publishes an empty mapping set while its + catalog attempt is in progress; that set is undecided, not a removal. Conditions are held and handed to the next runner + (same nodes, same EventIds); only the settled set decides a removal (A4 F1–F3). - **Priority and overflow.** A control or ack at the head of the stream goes first, then condition frames, then queued values. Condition production is pull-based: a slow consumer leaves records in the bounded condition-state hub. The item notices an eviction of records it has not read the next time it reads the hub. If its previous snapshot's last chunk is diff --git a/docs/plans/evidence/grpc-data-ext/A4.md b/docs/plans/evidence/grpc-data-ext/A4.md index 40da37ebc..3271df926 100644 --- a/docs/plans/evidence/grpc-data-ext/A4.md +++ b/docs/plans/evidence/grpc-data-ext/A4.md @@ -495,3 +495,68 @@ Earlier full run, `a4s-4`: - A04 also failed, because of observation 1. - A03 failed with the same three checks as `a4s-5`. - Every other scenario passed. + +## Findings F1–F4 fixes + +**Debug run `a4dbg-1`** (instrumented build, never committed): the consumer logged every imported-condition apply (fire / +no-fire, marker before→after, node state before) and the origin logged every condition record. A03 alone reproduced the +same three failures as `a4s-5`. + +**Root cause of F1, F2 and F3 (one consumer defect).** +- The consumer's own deploy (every fleet deploy, including a SOURCE-only ACL change) begins a catalog attempt. + `ProjectedMappingDeploymentRuntime.AttemptBegan` publishes an **empty** mapping set (`Notify([])`) until `AttemptCompleted`. +- `ProjectedConditionAccess.ReconcileRunners` read that as "connection removed": `Stop(removeConditions: true)` removed every + imported condition. The runner after the deploy re-created them on **fresh nodes**. Live evidence at the deploy instant: + `marker null->M5 before={Active=False, Acknowledged=True, …, Message=EastTankYellow, Quality=BadWaitingForInitialData}` + (a fresh node) for both conditions, then stream 2's records applied as genuine deltas. + - **F2:** the fresh node makes the re-snapshotted ScalarHigh a delta, so one event per active condition. + - **F3:** EastTankYellow's last transition (delivered just before the deploy) is applied again to a fresh node. The result + is a second event with the same Time and state. + - **F1:** the condition object, and with it the EventId registry, is new, so every older EventId is `BadEventIdUnknown`. + The removal's RefreshRequired was queued but gated away: visibility is decided against the current mapping set, which + was empty (filed **#936** for genuine removals). +- **The origin side is a contributing factor, not the cause.** The origin record across the deploy had the **same marker and + state, with a new time**. `ScriptedAlarmEngine.LoadAsync` restores `Active=Inactive` (the LocalDb store does not persist it) + and re-activates a still-true alarm, so `LastTransitionUtc` moves. The origin node stays the same state, so the origin + reports no event. That is what the brief's hypothesis saw. With the consumer holding its nodes, the consumer mirrors this + silently: there is no delta, the marker is unchanged, and old EventIds stay bound. The same reload also **un-acks an acked + active alarm** and writes a duplicate `alerts` row on every deploy. That is an origin engine defect outside condition + forwarding, filed as **#935** (not fixed here). + +**Design decision (consumer side).** The plan's T2/G4 contract holds unchanged: a resync against the same incarnation keeps +EventIds, an unchanged occurrence reports nothing, and an un-re-bindable change sends RefreshRequired. The defect was the +consumer treating an *undecided* mapping set as a *removal*. That also violated T2: an active condition was removed while it +was still active at the origin. +- `IProjectedConditionMappings.Suspended` (`DeployedConditionMappings` reads the runtime's `Suspended`): while it is set, a + connection that drops out is stopped **without** removal and **held**. +- The connection's next runner takes the held materialised set over, through the existing S3/S4 hand-over, and re-snapshots + onto the same nodes. +- Only a **settled** set without the connection (or the demand linger) releases the held runner, which then removes its + conditions. +- The origin is not changed. A restatement keeps its marker, so comparing the marker (not the time) is already how the + consumer re-binds. Time-only differences fire nothing, because the delta gate excludes Time. +- Docs: `AlarmTracking.md` §Notifiers and delivery and `DataConnections.md` §condition stream lifetime. + +**F4 root cause.** On a restarted consumer the projected pages, including the `remote-opc` anchor, materialise before the +mapping's authority activates. `IsConditionBearingMapping` needs `Authority.IsActive`, so `OnProjectedFolderMaterialised` +did not promote the folder, and nothing re-promoted it later. The SDK's `MonitoredNodeMonitoredItemManager` then refused the +item `BadNotSupported` (it checks `EventNotifier & SubscribeToEvents`). Our `CreateMonitoredItems` override is too late for +event items, because the master has already processed them. **Fix:** in the `SubscribeToEvents` override, once the +projected-notifier admission (the mapping gate) passes, `PromoteProjectedEventFolder` re-checks the mapping and promotes the +folder before the SDK attach. Callers who are not authorized are refused before this step. The `i=2253`-first workaround +text in `AlarmTracking.md` is replaced. + +**Native ack freeze (`a4s-4` observation 1): opc-plc's own behaviour, not ours.** A standalone `opc-plc:2.14.10 --alm` +container was run with no OtOpcUa. The CLI `alarms` watched `127.0.0.1:50999`, and `ack -n "ns=6;s=1:Colours/EastTank?Yellow" +-e 00…00` was sent at 07:58:19. +- Before the ack, EastTank/Yellow transitioned every 8 s (severity 300 → 500 → 700). +- After the ack it emitted one `Active, Acknowledged` event (07:58:20.40), then **nothing** for the rest of the watch + (≥ 10 min). +- Over the same window NorthMotor/Yellow, which was never acked, kept cycling (61 events). +- opc-plc's alarm simulation stops driving a condition once it has been acknowledged. Our forwarding and the OpcUaClient + driver relay that faithfully. Recorded; the harness keeps its AddComment probe for the native EventId. + +| Fix | Commit | Test (red on revert → green) | +|---|---|---| +| F1–F3 hold across a deploy | `1b7c69c6` | Runtime `F1_a_deploys_empty_suspended_mapping_set_holds_the_conditions_and_only_a_settled_set_without_the_connection_removes_them`: with `suspended` forced false it fails at "a deploy's undecided empty set is not a removal" (`Removed` had `x`); restored, it passes | +| F4 promote on admission | `e4b9998c` | OI `F4_a_folder_materialised_before_its_mapping_was_condition_bearing_still_admits_a_folder_first_event_item`. Its control asserts `BadNotSupported` while the mapping is not condition-bearing. With the promotion call removed it fails at "folder-first item admitted" (`0x803D0000`); restored, it passes |