From 688cff581227b100e216a116fb43f07f45207c04 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Wed, 25 Nov 2026 02:46:06 -0500 Subject: [PATCH] =?UTF-8?q?docs(grpc-data):=20A4=20live=20scenarios=20part?= =?UTF-8?q?=202=20+=20full=20A01=E2=80=93A08=20run=20(a4s-5)=20=E2=80=94?= =?UTF-8?q?=20A06/A07=20PASS,=20A03=20plan=20path=20PASS=20with=20findings?= =?UTF-8?q?=20F1=E2=80=93F3=20(deploy-driven=20EventId=20invalidation,=20p?= =?UTF-8?q?hantom=20re-assert=20event,=20duplicate=20transition=20across?= =?UTF-8?q?=20stream=20reset),=20F4=20folder-first=20refusal;=20D6/D7=20ve?= =?UTF-8?q?rdicts;=20CLI=20EventType=20line?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/Client.CLI.md | 6 ++ docs/plans/evidence/grpc-data-ext/A4.md | 134 ++++++++++++++++++++++++ 2 files changed, 140 insertions(+) diff --git a/docs/Client.CLI.md b/docs/Client.CLI.md index dcb617749..ee488d32e 100644 --- a/docs/Client.CLI.md +++ b/docs/Client.CLI.md @@ -387,6 +387,12 @@ QualifiedName named `ActiveState/Id` (a `/`-joined string passed to `EventFilter split into a browse path), which matched nothing — so every event printed inactive and unacknowledged whatever the condition's real state. A direct Read of the condition was always correct. +Each notification also prints an `EventType:` line (the event's `EventType` NodeId). The three refresh event types are +named: `RefreshStartEventType (i=2787)`, `RefreshEndEventType (i=2788)` and `RefreshRequiredEventType (i=2789)`; any other +type prints as its NodeId (e.g. `i=2915` for `AlarmConditionType`). A client that sees `RefreshRequiredEventType` should +re-run `alarms --refresh` (a ConditionRefresh), for example after a consumer's imported conditions were resynced +([AlarmTracking](AlarmTracking.md#conditionrefresh-and-refreshrequired)). + ### ack Acknowledges an active alarm condition via the OPC UA Part 9 `Acknowledge` method. The server gates this on the **`AlarmAck`** role (fail-closed — a session whose API-key principal holds no `AlarmAck`-conferring `NodeAcl` grant gets `BadUserAccessDenied`; the data plane does not use LDAP; see [ScriptedAlarms.md](ScriptedAlarms.md) §"AlarmAck gate"). The `--event-id` is the hex-encoded `EventId` taken from a prior `alarms` subscription notification for the same condition. diff --git a/docs/plans/evidence/grpc-data-ext/A4.md b/docs/plans/evidence/grpc-data-ext/A4.md index 53899f74e..40da37ebc 100644 --- a/docs/plans/evidence/grpc-data-ext/A4.md +++ b/docs/plans/evidence/grpc-data-ext/A4.md @@ -361,3 +361,137 @@ side. before `rig.py up`. - Any `.cs` change (seed, probe, node-probe, CLI) changes `source_tree_hash` and needs a fresh `up` and run id. Python-only harness edits do not. + +## Live scenarios (part 2) — A03, A06, A07 + +Harness: `conditions_scenarios.py` `scenario_A03/A06/A07` (commits `9ea50c11`, `42e3800f`, and the A03 native-probe change +after `a4s-4`). There were debug runs on `a4s-3` (experiments X-MARK, X-RESET and X-REASSERT, described below) and `a4s-4`. +The evidence runs are on `a4s-5` (see "Full A01–A08 run"). + +**Harness and fixture additions.** +- The CLI `alarms` command prints an `EventType:` line and names RefreshStart, RefreshEnd and RefreshRequired. That change + is in `Client.Shared` `AlarmEventArgs.EventType` (select clause 1) and in `AlarmsCommand`. Unit tests: + `Execute_PrintsEventType_NamingRefreshRequired` and an assertion in `OnAlarmEvent_TruncatedFields_StillRaisesEvent`. It is + documented in `Client.CLI.md`. +- The seed adds a second granted CONSUMER principal, `fixture-cli-alt` (cluster Admin, manifest `cli_alt`). +- The seed adds a mutation `bump_mapping_revision`. It increments one mapping's `Revision`, and through the runner + signature that resets the consumer's condition stream. +- New harness helpers: + - `duplicate_transitions`: two live events with the same (condition, Time, State, Severity, Message). The EventId check + cannot see these, because each copy gets a fresh EventId. + - `log_lines`: the runner's `stream … opened (serving …)` and `snapshot barrier passed` lines, with timestamps. + - `start_watch`: retries the CLI until a starting node accepts it. + +| ID | Result (`a4s-5`) | Evidence (`evidence/A4S-.json`) | +|---|---|---| +| A03 | **FAIL** (16/19). Phase 2, the plan's failover/G4 path: **all PASS**. Phase 1 (deploy-driven stream reset) and duplicate check: 3 product findings, F1–F3 below | Phase 2 checks run in this order; each passed. **Gap:** source Primary `source-1` was `docker pause`d. ScalarHigh was cleared and re-raised at the device, then the node was unpaused and stopped at once. The consumer never saw the clear (`scripted_events_after_failover` = `[]`). **Failover:** `source-2` became Primary, and the runner logged `stream 4 … opened (serving source-2:4053)`. **RefreshRequired:** the Server-object watcher received `RefreshRequiredEventType (i=2789)`. **Old EventId:** an ack with the pre-failover ScalarHigh EventId got `BadEventIdUnknown` and was not sent; the record time changed, so it was not re-bound. **ConditionRefresh:** a new `--refresh` subscription replayed ScalarHigh with the **same ConditionId**, a **new EventId** and `Active, Unacknowledged`, and that EventId's ack was Good (origin audit: `DriverConfirmedSuccess`). The native EastTankYellow was still present with the same ConditionId, so nothing still active was retired. **Positive control:** a clear after the resync arrived **exactly once** (`Inactive, Acknowledged`). No duplicate EventIds after failover. | +| A06 | **PASS** (11/11) | Consumer Primary `consumer-1`. Before the change, four clients watched: `consumer-1` as `fixture-cli` (with `-F` → `consumer-2`), `consumer-1` as `fixture-cli-alt`, `consumer-2` as `fixture-cli`, and `consumer-2` as `fixture-cli-alt`. All four showed the **same ConditionIds** for ScalarHigh and EastTankYellow. `consumer-1` was then stopped and `consumer-2` became Primary. Its two clients each saw the clear **exactly once** and then the re-raise, with no duplicate EventIds. The `-F` client failed over and also saw the clear once. After restart, `consumer-1` (as `fixture-cli`) and `consumer-2` (as `fixture-cli-alt`) both converged: the same ConditionIds as before, `Active, Unacknowledged`, and one clear each. No duplicate transitions on any client. | +| A07 | **PASS** (8/8) | `consumer-1` (non-Primary) was restarted. The "early" client subscribed with `--refresh` as soon as the node accepted it. RefreshEnd was at `07:41:33.16` and the first barrier at `07:41:48.22`, so **the refresh preceded the snapshot**. It replayed **0** imported conditions, and **no RefreshRequired** arrived (the barrier was complete). ScalarHigh and EastTankYellow then arrived as ordinary events as their records applied. A "late" `--refresh` after the barrier replayed both, with the pre-restart ConditionIds and the origin's state. The early client's final view equalled the late client's view. Positive control: one clear on each client, and no duplicates. | + +**A03 and A07 plan-vs-code verdicts (`A4-docs.md` D6, D7).** +- **D7 (A03): the code and the docs are right.** The plan's "pre-failover EventId ⇒ `BadEventIdUnknown`" holds when the + record `time` changes. That is what happened to ScalarHigh in every run. When the time is unchanged, the old EventId + re-binds and stays usable. + - Both outcomes were seen live for the native EastTankYellow, which the scenario does not drive. + - On `a4s-4` its pre-failover EventId was **accepted** (ack Good, audited `AcceptedUnconfirmed`). + - On `a4s-3` (its time moved) it was `BadEventIdUnknown`. + - On `a4s-5` the AddComment probe was accepted. +- **D6 (A07): the code is right; the plan's wording should change.** A ConditionRefresh made before a *complete* first + barrier gets **no** RefreshRequired, and it replays nothing imported. The client is **not** left with a wrong view: each + condition arrives as an event when its record applies, so a client that keeps its subscription converges to the same + view as a post-barrier refresh (`a4s-3` and `a4s-5`). + - RefreshRequired after a refresh is only sent at an *incomplete* barrier, which this rig does not produce. + - Suggested plan wording: "ConditionRefresh before the first snapshot returns nothing imported; conditions follow as + events (RefreshRequired only if that barrier is incomplete)." + +### Findings (product, not fixed here) + +**F1 — a deploy invalidates outstanding consumer EventIds of a still-active scripted condition, with no RefreshRequired.** + +*Repro* (`a4s-3` X-RESET, and A03 phase 1 on `a4s-3`, `a4s-4` and `a4s-5`): +1. Raise ScalarHigh. +2. On the consumer, `comment` with its EventId E1. Result: Good (the control). +3. Make any fleet deploy: `bump_mapping_revision` on `map-pumpb`, or (X-REASSERT) a SOURCE-only ACL change. +4. `comment` with E1 again. Result: `BadEventIdUnknown`, refused locally with no origin audit line. The newest EventId is + still accepted. + +*What the deploy does:* +- Every deploy ends the consumer's condition stream ("stream … ended; re-snapshotting") and reopens it on the same origin + node. +- The origin's `ScriptedAlarmHost` "re-asserted 1 non-normal condition node(s) after (re)load", with a new record `time`. + +*Why this looks like a consumer-side defect:* +- The origin's activation marker does **not** change across the deploy. The X-MARK probe read `c8ef…:10` before and after, + through the `condition-records` probe. +- So the docs' "a re-assert invalidates nothing" and "a stream reset against the same incarnation keeps old EventIds + ackable" do not hold live. A03 checks `p1_pre_reset_eventid_still_accepted`. +- The consumer's `condition.Activation` must differ from E1's binding even though the origin snapshot marker is + unchanged. One suspect is a live record on the ending or opening stream that carries a different marker. This needs code + investigation. +- Impact is limited: the client receives a fresh event with a fresh, ackable EventId, so it acks with the latest one. An + operator acking an older event across a deploy gets `BadEventIdUnknown`. + +**F2 — the consumer reports the origin's post-deploy re-assert as a new event; origin clients see none.** +- On every deploy the consumer emits one extra ScalarHigh event, `Active, Unacknowledged`, with a new Time and a new + EventId. +- The origin's own OPC UA clients get **no** event for it (`origin_events_during_reset` = `[]`) on `a4s-4` and `a4s-5`. + A03 checks this as `p1_consumer_events_mirror_origin`. +- Consumer clients therefore see a transition that did not happen. + +**F3 — one origin transition can be delivered twice to consumer clients across a stream reset.** +- On `a4s-5` the origin reported EastTankYellow at `07:35:55.3554429Z` (`Active, Unacknowledged`, "The alarm is active.") + **once** (origin EventId `8D27…`). +- The consumer's Server-object client received it **twice**, with consumer EventIds `960F…` and `0702…` and an identical + Time, state, severity and message. This was during the phase-1 deploy and stream reset. +- The same pattern appeared on `a4s-3` (`07:01:36.8679509Z`, "severity has increased") and on `a4s-4` + (`07:12:00.9922332Z`, `Inactive, Acknowledged`). +- A03 checks this as `no_duplicate_transitions_whole_scenario`. +- Part-1 A04's "no duplicated `i=2253` EventId" check could not catch it, because each copy has its own EventId. The new + `duplicate_transitions` check found no duplicates in A06 or A07 (no deploy in those windows). + +**F4 — a folder event item on a consumer with no open demand is still refused `BadNotSupported`** (part-1 observation 1, +re-checked). +- On `a4s-3` and `a4s-5`, A06 put the first subscriber on a freshly restarted consumer at the `remote-opc` branch folder + (`ns=4;s=p1.…map-opc…`). It was refused `BadNotSupported` and the CLI exited. +- This contradicts A3 Deviation 3 and `OnProjectedFolderMaterialised`, which promote condition-bearing mapping folders to + `SubscribeToEvents` at materialisation. +- One suspect: the promotion predicate `IsConditionBearingMapping` requires `Authority.IsActive`. It is evaluated only at + materialisation, and nothing re-promotes a folder when the authority activates later. This is not verified. +- The workaround is documented in `AlarmTracking.md` "Imported conditions": open an `i=2253` item first. ScadaBridge does. + +### Observations + +1. **A forwarded native ack to opc-plc froze EastTankYellow at the origin** (`a4s-4`). + - A03 acked the pre-failover native EventId, which re-bound (D7), and the ack was Good (`AcceptedUnconfirmed`). + - After that, **both** source nodes showed EastTankYellow at `Active, Acknowledged` (`07:12:42`) for the rest of the run + (≥14 min, re-probed at the end), with no further transitions. A04 then failed: no late events, 6 checks. + - In part 1 an A02 ack did not stop the cycling. The cause (OpcUaClient driver dedup versus opc-plc's `--alm` + simulation) is not established. + - The harness now probes the native EventId with AddComment (the same binding check), and A04 passed on `a4s-5`. +2. The `-F` failover-capable CLI client on the stopped consumer resumed on the partner and saw the clear (A06). The + non-failover client on the stopped node stayed alive and received nothing, as expected. +3. A consumer restart's first barrier came about 15 s after the first subscription. This is the window in which a + ConditionRefresh returns nothing imported (A07). + +## Full A01–A08 run — run `a4s-5` + +`rig.py up --run-id a4s-5 --conditions` → `seed` → 85 s → `deploy --timeout 300` → `conditions_a3_smoke.py` (PASS: one +Active/Acknowledged event each side) → `conditions_scenarios.py` (all eight, one session; restore after A03/A08, A05's +experiment restart) → `rig.py down` (0 run containers left). Evidence `artifacts/grpc-data/runs/a4s-5/evidence/` +(`A4S-results.md`). + +| Scenario | Result | Checks | Notes | +|---|---|---|---| +| A01 | PASS | 13/13 | | +| A02 | PASS | 10/10 | | +| A03 | **FAIL** | 16/19 | Plan path (failover, G4) all PASS. Fails: `p1_consumer_events_mirror_origin` (F2), `p1_pre_reset_eventid_still_accepted` (F1), `no_duplicate_transitions_whole_scenario` (F3). | +| A04 | PASS | 16/16 | | +| A05 | PASS | 4/4 | | +| A06 | PASS | 11/11 | | +| A07 | PASS | 8/8 | | +| A08 | PASS | 10/10 | | + +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.