914 lines
84 KiB
Markdown
914 lines
84 KiB
Markdown
# A4 evidence — code part (diagnostics, #930, #931, L1, L5)
|
||
|
||
Phase A4 of `docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md`, 2026-11-24/25, branch `a4-code` (from master
|
||
`91438049`). Not merged, not pushed. The docs part (`DataConnections.md`, `AlarmTracking.md`, `ScriptedAlarms.md`, `security.md`)
|
||
is a separate worktree; the A01–A08 fleet scenarios are not part of this code pass.
|
||
|
||
## #930 — a permanently refused mapping no longer storms (N2), ConditionCapacity recovers (N3)
|
||
|
||
`ProjectedConditionAccess.Runner.cs`:
|
||
|
||
- **In-stream retry.** A mapping that is Unavailable (item refused, root metadata failed, snapshot timed out) or ConditionCapacity is
|
||
retried ON THE OPEN STREAM: its root is re-resolved if it never resolved, any still-open item is removed, and its item is re-added
|
||
(`AddSubscriptionItems`, a fresh command id; acks are matched on `(mapping, command id)`). The stream is no longer ended for it, so
|
||
the healthy mappings are never re-snapshotted and methods are not answered `BadNoCommunication` in a reconnect gap.
|
||
- **Backoff per mapping.** Definitive refusals (`Denied`, `NotFound`, `Unsupported`, item or root) and ConditionCapacity:
|
||
`ProjectedConditionOptions.LongRetryDelay` (new, default **5 min**) × 2ⁿ, ≤ 4×. Transient: the snapshot timeout × 2ⁿ, ≤ 8× (the old
|
||
B2 schedule). A retry whose snapshot has not completed by its deadline goes back to Unavailable (claim released); a late completion
|
||
of that item is still taken. A completed snapshot resets the retry count.
|
||
- **RefreshRequired only on a changed incomplete set.** Each barrier records the set of mappings not known; an incomplete barrier
|
||
whose set equals the previous barrier's (e.g. a stream that ended for another reason with the same mapping still refused) sends no
|
||
RefreshRequired. A mapping that completes in-stream leaves the recorded set, so a later relapse is told again.
|
||
- **T2 holds:** a retried mapping is `Pending` (unknown) while its retry runs, so nothing it might list is removed or marked
|
||
known-inactive meanwhile; a capacity mapping's retry likewise blocks removals until it is known again.
|
||
|
||
Decision: a ConditionCapacity mapping is "known-empty" while parked but "unknown" during its retry window. Conservative (removals by
|
||
other mappings in that window are held as `BadNoCommunication` instead of removed) — never the T2-unsafe direction.
|
||
|
||
## #931 — nits N4–N8
|
||
|
||
| Nit | Fix |
|
||
|---|---|
|
||
| N4 | A stream that ended before its barrier (every root failing, no Primary) backs off `ReconnectDelay × 2^(n−1)` up to the new `MaxReconnectDelay` (60 s); reset when a barrier passes. The repeated end logs at Debug after the first. |
|
||
| N5 | The ledger charges `max(Materialised, Σ known claims + max(Unlisted, Σ unknown claims))`: held-but-unlisted keys (an Unavailable mapping's stale keys) are charged beside a **known** mapping's new claim (the under-count), but overlap an **unknown** mapping's claim (it may be re-listing those very keys — no false capacity rejection of a retry). The swap commits its count via `Commit` (never refused). `SetMaterialised` now reports when the node is over a cap (logged; materialising is never refused — bounded by Σ MaxConditions). |
|
||
| N6 | `_runners` is a `ConcurrentDictionary` (mutated under `_gate` only); `CallAsync` and the diagnostics poll read a runner's `Serving` without `_gate`. No test (a lock-ordering change with no observable seam; reviewed by reading). |
|
||
| N7 | A capacity reset whose reconcile removed conditions sends no second RefreshRequired — the removal already carried one to every item that held them (the sink's §5.2 "removal + RefreshRequired"); it still asks when nothing was removed. |
|
||
| N8 | A parked (`_stopping`) runner is dropped once its removal finished (it hands over an empty set); new test observation `IsParked`. |
|
||
|
||
### Red/green (each reverted alone, the named test re-run, then restored)
|
||
|
||
| Fix | Revert | Test | Red |
|
||
|---|---|---|---|
|
||
| N2 in-stream | end the stream when a retry is due | `B2_S7_a_refused_item…` (rewritten: Add arrives, no new stream, map-b not re-applied) and `N3_a_ConditionCapacity_mapping_is_re_added_in_stream…` | both red |
|
||
| N2 unchanged set | `alreadyTold = false` | `N2_an_unchanged_incomplete_set_on_a_new_stream…` | red |
|
||
| N2 definitive | `Definitive` ignores the refusal status | `N2_a_definitive_refusal_waits_the_long_backoff…` | red |
|
||
| N4 | fixed `ReconnectDelay` | `N4_streams_that_never_reach_a_barrier_back_off_exponentially` (< 12 metadata calls in 2 s; ~40 without) | red |
|
||
| N5 | `known + unknown` (old under-count) | `N5_held_stale_keys_are_charged_beside_a_known_mappings_new_claim…` | red |
|
||
| N7 | `if (outcome.Refresh) RequireRefresh()` | `B1_an_in_stream_re_snapshot_over_capacity…` (now asserts one RefreshRequired per reset: the removal's) | red |
|
||
| N8 | continuation never removes the parked entry | `N8_a_stopped_runner_is_not_kept_parked…` | red |
|
||
|
||
Also new: `N3_a_retry_still_over_capacity_stays_ConditionCapacity…` (backoff doubles, map-b's key never removed).
|
||
|
||
Test-only fix found on the way: the condition-access tests waited for `BarriersCompleted` and then asserted RefreshRequired, but the
|
||
barrier count moves before the barrier's refresh (the A4 manifest's first run caught it in `N2_an_unchanged…`); they now wait for
|
||
the refresh itself, with the third stream's refresh as the positive control for the second stream's absence.
|
||
|
||
## Diagnostics and metrics (plan §6)
|
||
|
||
- **`Runtime/DataConnections/DataConnectionConditionDiagnostics.cs`** (new DI singleton, no dependencies — the H4 shape): shared by
|
||
the origin condition items (`ConditionItemStream`, via `LocalDataServices.ConditionDiagnostics`), the consumer runtime
|
||
(`ProjectedConditionAccess.Diagnostics`) and the readers (`DataConnectionDeploymentRuntime.ConditionDiagnostics`, `DriverHostActor`).
|
||
The condition hub's unsignalled count is attached at DI time (no lazy-composition gap like H4 review 2).
|
||
- **Metrics** (OtOpcUa meter, every one with `side` = origin | consumer, no ids): `otopcua.dataconn.conditions.items{side}`
|
||
(consumer side new: one per acked mapping item), `…conditions.resyncs{side}`, `…conditions.capacity_rejections{side}`,
|
||
`…condition_methods{method,outcome,side}` (consumer side new: every forwarded call), and the new
|
||
`otopcua.dataconn.conditions.refresh_required{side=consumer}`. The A2 instruments were **reused** (only `side` added).
|
||
- **Contracts** (Commons, additive optional members; older senders ⇒ null = "unavailable"): `DataConnectionDiagnosticsSnapshot.Conditions`
|
||
(`ConsumerConditionDiagnostics`: stream state idle|connecting|snapshotting|live, last snapshot, materialised, `state_known=false`
|
||
count, RefreshRequired, resyncs, capacity rejections, per mapping status / observed / MaxConditions / refusal, node budget vs host
|
||
cap, method outcome classes), `NodeDiagnosticsSnapshot.OriginConditions` (`OriginConditionDiagnostics`: open items, the item
|
||
nearest its limit, last snapshot, resyncs, capacity rejections, unsignalled, methods served). Arrays in production (H4 Akka JSON
|
||
note); no bool flag was added.
|
||
- **AdminUI** `ClusterDataConnections.razor` (already in `<PageErrorBoundary>`) + `DataConnectionDiagnostics` helpers: an
|
||
"Imported conditions" line per connection (notice style when a mapping is Unavailable/ConditionCapacity or any count ≥ 80 % of its
|
||
limit) and a served-conditions segment in the origin panel.
|
||
|
||
Decisions: the consumer RefreshRequired count is requests made by the runtime (explicit + each removal batch), not per client item;
|
||
method outcome classes: DriverConfirmedSuccess = succeeded, RejectedBeforeDispatch = rejected, DriverConfirmedFailure = failed, the
|
||
rest (AcceptedUnconfirmed, OutcomeUnknown) = unknown. A method the node manager refuses before forwarding (no local grant) is not
|
||
counted on the consumer side.
|
||
|
||
Tests: Runtime `GrpcDataConditionDiagnosticsTests` (3), `GrpcDataConditionDiagnosticsSerializationTests` (2: cluster-serializer
|
||
round trip; an older payload decodes `Conditions`/`OriginConditions` null), `GrpcDataProjectedConditionAccessTests.A4_consumer_diagnostics…`;
|
||
AdminUI `GrpcDataConditionDiagnosticsDisplayTests` (4). Manifest key `A4` in `unit-phases.json`.
|
||
|
||
## AdminUI live — run `a4c-cond-1` (prerendered HTML from control-1's admin, login disabled)
|
||
|
||
`/clusters/CONSUMER/data-connections` after the smoke:
|
||
- consumer-1: "Imported conditions: stream live · last snapshot 2026-11-25 04:44:51Z · conditions 1 (state unknown 0) · node budget
|
||
1/2500 · RefreshRequired 0 · resyncs 0 · capacity rejections 0 · methods succeeded 1 · … · mappings map-raw Complete 0/1000;
|
||
map-uns Complete 1/1000".
|
||
- consumer-2 (no event subscriber): "stream idle · … · mappings map-raw Pending 0/1000; map-uns Pending 0/1000".
|
||
- origin panel for consumer-1/2: "condition items open 0 · last snapshot none since start · … · state unknown (unsignalled) 0".
|
||
|
||
`/clusters/SOURCE/data-connections` origin panel: source-1 "condition items open 2 · largest listing 1/1000 · last snapshot
|
||
2026-11-25 04:44:51Z · resyncs 0 · capacity rejections 0 · state unknown (unsignalled) 0 · methods served succeeded 1"; source-2
|
||
(Secondary) zeros. `/metrics`: consumer-1 `conditions_items{side="consumer"} 2`, `condition_methods_total{method="Acknowledge",
|
||
outcome="DriverConfirmedSuccess",side="consumer"} 1`; source-1 `conditions_items{side="origin"} 2`, the same method series with
|
||
`side="origin"` 1 — page and metrics agree. Not driven in a browser (Chrome tools not used); prerender runs the same render.
|
||
|
||
## L1 — origin `SnapshotConditions` Lock hold (§9.3) — PASS (A1 had not measured it)
|
||
|
||
`A1-core.md`/`A1-L4.md` record only L4 (X0 measured a field copy outside the server). Measured now with the opt-in harness
|
||
`OpcUaServer.Tests/ConditionSnapshotLockHoldMeasurementTests` (`OTOPCUA_L1=1`): a running SDK server, 1,000 native conditions +
|
||
500 variables, two publisher threads (`WriteValue`, `WriteAlarmCondition`, both under `Lock`), 500 snapshots after 20 warm-up. The
|
||
hold is an upper bound (keys-enumerated hook → post-hold hook; 1,000 = one hold at `DefaultMaxConditionsPerHold`). macOS (developer Mac),
|
||
Debug build:
|
||
|
||
| Run | hold p50 / p99 / max (ms) | WriteValue p99 / max (ms) | WriteAlarmCondition p99 / max (ms) |
|
||
|---|---|---|---|
|
||
| 1 | 1.61 / 4.65 / 5.89 | 1.93 / 6.39 | 1.94 / 6.42 |
|
||
| 2 | 1.44 / 4.32 / 5.00 | 1.71 / 6.34 | 1.71 / 6.38 |
|
||
| 3 | 1.45 / 4.53 / 5.90 | 1.65 / 6.81 | 1.66 / 6.76 |
|
||
|
||
p99 ≤ 10 ms and no publish delayed > 50 ms: **pass**. In-process, not on docker-dev (deviation: the brief allowed in-process).
|
||
|
||
## L5 — condition counts vs defaults
|
||
|
||
- **docker-dev export** (run `a4c-cond-1`, from the new diagnostics): map-raw 0/1000, map-uns 1/1000 (0.1 %); consumer node
|
||
1/2500 conditions (host caps 122,500 nodes / 400 MiB ⇒ 2,500); origin largest listing 1/1000. All ≤ 80 %: **pass**, defaults unchanged.
|
||
- **Production export: BLOCKED.** No production ConfigDb is reachable read-only from configuration in the repo (production
|
||
ConfigDbs are on the wonder boxes, which this brief forbids touching), and the data-connections feature is not deployed in
|
||
production (v1 merged, undeployed), so no production export exists to count yet. To be filed.
|
||
|
||
## Gates (at `a4-code` HEAD)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A4` (new) | passed (`20261125T040920…`) |
|
||
| `run-unit-phase.py A3` / `A1` / `H4` / `X0` | passed |
|
||
| `run-unit-phase.py A2` | first run failed `Overflow_before_the_snapshot_is_drained_resets_the_stream` (below); re-run passed (`20261125T042208…`) |
|
||
| Host.Tests `.DataConnections.` | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2066 passed, 3 skipped, 2 failed: `GrpcDataConfiguredDiscoveryWireTests` (#920) and `Overflow_before_…` (below) |
|
||
| OpcUaServer.Tests full | 1458 passed, 2 skipped (the L1 harness is one) |
|
||
| AdminUI.Tests full | 2707 passed |
|
||
| OI combined (139) | 138 passed, 1 skipped |
|
||
| Live `conditions_a3_smoke.py`, run `a4c-cond-1` | `passed: true` (imported ScalarHigh `ns=6;s=c1.…`, 32-char EventId; bogus EventId ⇒ BadEventIdUnknown; ack via consumer 635 ms; exactly one Active/Acknowledged on origin and consumer); `rig.py down` ⇒ 0 run containers / networks |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
| Configuration.Tests | not touched |
|
||
|
||
## #928 — `Overflow_before_the_snapshot_is_drained_resets_the_stream`: a test asserting one of two legal outcomes (b)
|
||
|
||
**Classification (b): test defect, no product change.** The origin item notices a hub eviction only when it next reads the hub,
|
||
which it does not do while it is producing snapshot chunks. At that read it takes one of two paths
|
||
(`ConditionItemStream.ReadDeltas`):
|
||
|
||
- the previous snapshot's last chunk is still undelivered (`_deliveredSnapshot < Snapshots`) ⇒ `Overflowed` ⇒ the session sends a
|
||
stream `Reset` ("Condition stream overflow; retry later.");
|
||
- otherwise ⇒ `ResetSnapshot`: a fresh snapshot (new begin) on the same stream, counted as a resync.
|
||
|
||
Both are what A2 specified (A2.md "Overflow" item 3: "a hub reader reset ⇒ the item re-snapshots … a reset while the item's previous
|
||
snapshot is still undelivered ⇒ stream `Reset`"). Which one an eviction **during** a long delivery gets depends on whether the pump
|
||
reads the hub before the session commits the last chunk (`DirectReader.MoveNextAsync` commits before returning the frame, so a
|
||
consumer that has caught up commits it first). Neither loses a change. The Reset path makes the consumer reconnect and take a
|
||
complete snapshot. The silent path's new snapshot is taken from the source, so it includes every evicted change. The A3 consumer
|
||
(`ProjectedConditionAccess.Runner.cs`, the `IsSnapshot && Total` branch and the `SnapshotComplete` swap) buffers any snapshot begin into
|
||
a new `ConditionSet`, keeps applying live deltas to both, and at `snapshot_complete` swaps it in as a **full replacement**: old ∪ new
|
||
keys are re-merged and a key only the old set listed is removed. So a silent re-snapshot is safe, and the Overflowed rule protects the
|
||
snapshot memory lease and back-pressure (no snapshot is taken behind an undelivered one). It is not a correctness signal the consumer
|
||
depends on.
|
||
|
||
**Evidence (instrumented copy of the test, alone, a4-code):** 3,000 records came in chunks of **51** records, not the 24 × ~125 the
|
||
test comment assumed: since A2 review S5 (`20bf9372`) the chunk budget is min(256 KiB, `MaxPendingBytes` = 200,000 in the fixture,
|
||
`MaxMessageBytes`), and a record with info estimates ≈ 3.9 KB. Frames #1–#59 were snapshot 1 (`complete` on #59). #60 was a new
|
||
begin (`total=3000`), then snapshot 2 was complete at #120, with `Snapshots=2, Resets=1, Overflowed=false` and no Reset control. So the
|
||
test waited for a Reset that the legal silent path never sends. The original contract test, with its outcome instrumented, took the
|
||
silent path **10/10** alone.
|
||
|
||
**Why it "started" failing:** it did not. Neither `ConditionItemStream.cs`, `DataSubscriptionSession.Conditions.cs` nor the test changed
|
||
between the A2 merge (`83c7e586`) and master `91438049` (A3 touched only consumer files). At `83c7e586` (detached worktree, built
|
||
clean) the test **fails 3/3 alone** but its class (22 tests) passes. It has been order- and JIT-warmth-dependent since S5 made
|
||
the snapshot 59 chunks. A2 gated it only inside the class or suite. A3 and A4 add tests and change the scheduling of suite runs, so
|
||
full-suite failures became more frequent.
|
||
|
||
**Fix (tests only, `GrpcDataConditionStreamTests.cs`):**
|
||
|
||
1. `Overflow_before_the_snapshot_is_drained_resets_the_stream` is now **deterministic**. 300 records (begin + 6 chunks) fit the
|
||
16-frame condition queue. The consumer reads nothing after the ack. The test waits until the snapshot is taken and charged
|
||
(`ChargedBytes > 0`, so the start cursor precedes the raises), raises 6 times (capacity 2 ⇒ eviction above the cursor), ticks
|
||
until `Overflowed`, and then asserts the `Reset` ("overflow") and `Snapshots == 1`.
|
||
2. New `An_eviction_during_a_long_snapshot_delivery_resets_or_resnapshots_without_losing_a_change` keeps the 3,000-record race and
|
||
asserts the contract for **either** outcome. On Reset ⇒ `Overflowed`, and a reconnected stream's complete snapshot (3,000) holds the
|
||
source's final state for the raised condition. On re-snapshot ⇒ begin `total=3000`, only snapshot chunks until `snapshot_complete`,
|
||
3,000 records with the final state, `Resets == 1`, `Snapshots == 2`, `Overflowed == false`, and the stream not ended. Any other
|
||
outcome fails.
|
||
|
||
**Red/green (mutations of `ConditionItemStream.ReadDeltas`, each restored):**
|
||
|
||
| Mutation | Deterministic Overflow test | Contract test |
|
||
|---|---|---|
|
||
| none | green 10/10 alone | green 10/10 alone (silent path 10/10) |
|
||
| M1: Overflowed rule disabled (`false && …`) | **red** (`Condition not reached` — no Reset) | green (silent path, which is legal) |
|
||
| M2: eviction swallowed (`_cursors[p] = read.Floor; continue`), Overflowed kept | green (Overflowed still set) | green (took the Reset path) |
|
||
| M3: eviction swallowed **and** no Overflowed (a lost change) | **red** | **red** ("Neither a Reset nor a fresh snapshot.") |
|
||
|
||
**Gates after the #928 fix + docs reconcile** (tests + docs, and one XML doc comment in `RemoteNamespaceMapping.cs`; no
|
||
behaviour change, so OpcUaServer.Tests full and the live smoke were not re-run):
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| The two #928 tests alone, 10× | 10/10 green |
|
||
| `run-unit-phase.py A2` / `A3` / `A4` | passed (`20261125T050036…`, `20261125T050157…`, `20261125T050252…`) |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2068 passed, 3 skipped, 1 failed: `GrpcDataConfiguredDiscoveryWireTests.Two_sdk_cadences_…` (#920), which passed when re-run alone |
|
||
| Host.Tests `.DataConnections.` | 207 passed |
|
||
|
||
## Left over
|
||
|
||
- File: production L5 count (blocked, above). #928 resolved above (test defect, tests fixed).
|
||
- Not done here: A01–A08, reviewer approval, the ScadaBridge consumer-impact record, docs (other worktree).
|
||
|
||
## Review round 1
|
||
|
||
Review written at `3be51e3b` (approve-with-changes: 1 blocker, 4 should-fix, NITs). Fixed on `a4-code` after `b2fab8b07`.
|
||
"Red" = the fix reverted alone (scratch copy, file restored afterwards), the named test re-run alone.
|
||
|
||
| Finding | Outcome | Test | Red when reverted |
|
||
|---|---|---|---|
|
||
| **B1** second capacity reset reused `"remove-{mapping}"` ⇒ transport refuses it, stream ends | Fixed: `"remove-{mapping}-{guid}"`. Every command id the runner builds was checked: `open` (once per stream), `retry-{mapping}-{guid}`, `remove-retry-{guid}`, and the new `remove-late-{guid}` (S2) are unique. The test fake (`FakeStream.SendAsync`) now **refuses any command id already used on the stream**, as `GrpcDataConnection` does (`_usedCommands`) — this is what hid the defect. | `N3_a_retry_still_over_capacity…` (+ asserts no new stream and two removes) | **red** (the strict fake alone, before the fix, and the fix reverted) |
|
||
| **S1** retry timeout dropped buffer + claim, so a retry snapshot slower than the timeout never completed | Fixed: a retry deadline keeps the buffer and claim, like the initial barrier timeout; the late completion swaps in. The buffer (and its claim) are dropped only when the next retry removes the item and re-adds it. Comment, `RetryDueAsync` doc and `DataConnections.md` now say so. | `R1_S1_a_retry_snapshot_slower_than_the_timeout_still_completes_late…` | **red** |
|
||
| **S2** a late ack after the retry was replaced left an orphaned origin item; re-adds refused `InvalidArgument` forever | Fixed both ways: (1) a command replaced before its ack is remembered (`Superseded`, ≤ 8 per mapping); a late Good ack of it sends `RemoveSubscriptionItems` for that handle at once; (2) backstop: 3 consecutive `InvalidArgument` refusals of a mapping's in-stream re-adds end the stream (`MaxInvalidArgumentRefusals`). | `R1_S2_a_late_ack_of_a_superseded_retry_removes_the_orphaned_origin_item…` (fake origin acks retry #1 after #2 was sent); `R1_S2_consecutive_InvalidArgument_refusals…backstop` | **red** / **red** |
|
||
| **S3** N5 overlap allowance let another mapping's held stale keys count as overlap, exceeding the host caps | Fixed: an unknown mapping's claim is reduced only by the held-unlisted keys **it** listed when last known on this runner (`_lastListed`, kept only while it has no committed set; `HeldOverlap`). Charge = `max(Materialised, known + Unlisted + Σunknown − min(Unlisted, Σ min(claim, overlap)))`. `Unlisted` is now reset to everything held at each stream start (nothing contributes yet) — before, it carried the last barrier's value (0 after a complete one), which is how the review's counter-example got in on a new stream. Residual (documented in `DataConnections.md`): a mapping whose origin retired its old keys and lists new ones, while another mapping is unknown, can exceed by at most its own previous count until known; logged and on the AdminUI budget line. | `R1_S3_another_mappings_held_stale_keys_are_not_overlap…` (the review's counter-example at 3-condition scale); `N5_…` still green | **red** (old formula) |
|
||
| **S4** SourceName depended on runtime mapping status | **Decision: keep SourceName stable.** `Merge` remembers per key the mapping that chose its SourceName; while that mapping is deployed, higher in the deployed order, and merely not contributing (refused / Unavailable / retrying / ConditionCapacity / Pending on a new stream), the held SourceName is kept. Placements and notifiers still follow the contributing mappings (visibility unchanged: SourceName is a display field, no access decision reads it); no removal or known-inactive decision involved (T2 unaffected). It moves when that mapping is known again and no longer lists the key, when it is no longer deployed (new runner ⇒ recomputed: the A3 "disabling the primary mapping moves SourceName" behaviour holds), or when a higher-priority mapping lists the key. Residual: a key first seen while the Raw mapping is unavailable starts with the UNS SourceName. `AlarmTracking.md` and `A4-docs.md` ScadaBridge item 1 updated (add both cases to ScadaBridge#147). | `R1_S4_SourceName_stays_on_the_deployed_primary…` (with a positive control: Raw known again without the key ⇒ moves) | **red** |
|
||
| Docs: DataConnections step 5 / follow-ups / metrics `side` + `refresh_required` | Already fixed by `b2fab8b07`; verified. Line on retry timeout corrected (S1), S2/S3 behaviour and the resync definition added. | — | — |
|
||
| Docs: AlarmTracking RefreshRequired "every incomplete barrier" | Fixed: only when the incomplete set changed (#930). | — | — |
|
||
| Docs: ScriptedAlarms "accepted and routed" vs DataConnections "applied" | Code (`LocalDataServices.ConditionMethods.cs`): scripted ⇒ `DriverConfirmedSuccess` when the origin's handler applied it; native ⇒ `AcceptedUnconfirmed`. `ScriptedAlarms.md` now says "applied" (DataConnections.md table was already right). | — | — |
|
||
| Docs: A4-docs.md stale `Runner.cs` citations | Updated to current lines (`:703`, `:521`, `:951`, `:955-962`, `:966-974`). | — | — |
|
||
| Metric descriptions said "on this origin" | `OtOpcUaTelemetry.cs` descriptions for items / resyncs / capacity_rejections / condition_methods name both sides. | — | — |
|
||
| NIT `resyncs{side=consumer}` over-count | Fixed: counted only for a stream that opened. | `R1_NIT_consumer_resyncs_count_streams_that_opened…` (+ positive control) | **red** |
|
||
| NIT AdminUI null-safety | `ConditionsNeedAttention` uses `Mappings?.`; `MethodCounts` takes null ⇒ "unavailable". | AdminUI `A_partial_payload_without_mappings_or_methods_renders…` | **red** (HEAD file) |
|
||
| NIT misplaced doc comments | `NearLimit` has one summary; `HasDrops` has its `#919` summary back. | — | — |
|
||
| NIT in-loop `ResolveRootsAsync` stall (≤ 10 s) | **Not fixed — recorded, #934.** Moving it off the loop changes the loop's concurrency shape (a second wake source, results applied on the loop); frames are delayed, not lost. | — | — |
|
||
| NIT unpruned `_consumer` map | Fixed: `RetainConsumers` on every mapping change drops connections no deployed mapping references. | `R1_NIT_consumer_counters_of_a_removed_connection_are_pruned` | **red** |
|
||
| NIT permanent removal block | Filed as #933 (not fixed here, per brief). | — | — |
|
||
| NIT L1 measured on macOS Debug | Accepted as recorded. | — | — |
|
||
|
||
Commits: `c93290d0` (runner fixes + tests), `0cac09ce` (AdminUI, metric descriptions, docs), this evidence commit. Follow-up filed:
|
||
#934 (in-loop root re-resolve).
|
||
|
||
### Gates after review round 1
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A4` / `A3` / `A2` / `A1` / `X0` | passed (`20261125T052352…`, `…052438…`, `…052546…`, `…052655…`, `…053025…`) |
|
||
| Host.Tests `.DataConnections.` | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2076 passed, 3 skipped, 0 failed (#920 did not fire) |
|
||
| OpcUaServer.Tests full | 1458 passed, 2 skipped |
|
||
| AdminUI.Tests full | 2708 passed |
|
||
| OI combined (`Feature=GrpcData` + ConditionMethodEvent / NativeAlarmEventIdentityFieldDelivery / FolderConditionRefresh / ConditionRefreshDeferral), once | 138 passed, 1 skipped (opt-in L2 harness) |
|
||
| Live `conditions_a3_smoke.py`, run `a4r1-cond-1` | `passed: true` (all 7 checks; imported `ns=6;s=c1.…`, 32-char EventId; bogus EventId ⇒ BadEventIdUnknown; ack 597 ms; exactly one Active/Acknowledged on origin and consumer) |
|
||
| AdminUI `/clusters/{CONSUMER,SOURCE}/data-connections` (curl, control-1 admin) | 200 both; consumer-1 "Imported conditions: stream live · … · resyncs 0 · … · methods succeeded 1 · … · mappings map-raw Complete 0/1000; map-uns Complete 1/1000"; source-1 "condition items open 2 · largest listing 1/1000 · … · methods served succeeded 1" |
|
||
| `rig.py down` | 0 run containers / networks |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
## Live scenarios (part 1) — A01, A02, A04, A05, A08: all PASS (run `a4s-2`)
|
||
|
||
Harness: `scripts/validation/grpc-data/conditions_scenarios.py` (commits `304e8b1b`, `6bf7dc89`) on `rig.py up --conditions`
|
||
at `6bf7dc89` (seed → 85 s → `deploy --timeout 300` → `conditions_a3_smoke.py` → scenarios → `rig.py down`, 0 run containers
|
||
left). It reuses `scenarios.ScenarioRunner` (publish, `mutate`+deploy, `restore`+deploy, configuration experiments, redacted
|
||
evidence). Ids are resolved, never built: projected folders by `browse -r` of the consumer from `i=85`, imported
|
||
ConditionIds/EventIds from the `ConditionNodeId`/`EventId` lines the CLI `alarms` prints. Every absence check has a positive
|
||
control in the same window. Each scenario is restored before the next one runs. A08 runs `restore` + deploy, A05 restarts
|
||
the consumer pair back onto compose.yml, and every scenario ends with scalar := 0.
|
||
|
||
**Fixture additions (conditions profile only; v1 rig unchanged).**
|
||
- A run-owned `opcplc` container (`opc-plc:2.14.10 --alm`), the image the OpcUaClient integration fixture pins.
|
||
- A SOURCE `OpcUaClient` driver `opcua` with device `opcplc`.
|
||
- A native alarm tag `EastTankYellow`, whose `nodeId` is the upstream **condition** node `ns=6;s=1:Colours/EastTank?Yellow`.
|
||
- Equipment `pumpa`/`pumpb`, both referencing that tag.
|
||
- Raw mapping `map-opc` and UNS mappings `map-pumpa`/`map-pumpb`, with matching exports.
|
||
- An origin principal `fixture-unsonly` that holds only the `pumpa` UNS export.
|
||
- A CONSUMER principal `fixture-cli-nogrant` with no NodeAcl.
|
||
|
||
**Deviation from the brief: no shared `10.100.0.35:50000` fixture.** The rig's endpoint guard (`validate_fixture_endpoints`,
|
||
implementation plan "validate resolved compose/seed has no shared-host endpoints") admits run-owned DNS only. The scenarios
|
||
also ack and comment upstream conditions, which must not leak into a shared simulator.
|
||
|
||
| ID | Result | Evidence (run `a4s-2`, `evidence/A4S-<id>.json`) |
|
||
|---|---|---|
|
||
| A01 | **PASS** (13 checks) | Scripted `ScalarHigh` raised (scalar 150), imported Active/Unacked with an opaque `ns=6;s=c1.…` id. The consumer `ack` succeeds, then `confirm` with the acked EventId succeeds. Origin and consumer each show exactly one Active/Acknowledged ack event and exactly one confirm event (`Active, Acknowledged`, "scalar high"). `ConfirmedState` was resolved by browsing each condition node and read `Confirmed` on both the origin (`ns=3;s=source-scalar-high`) and the consumer. Both clear to `Inactive, Acknowledged`. Same sequence on both sides: Unacked → Acked → Acked(confirm) → Inactive. |
|
||
| A02 | **PASS** (10 checks) | Native `EastTankYellow` (driver → opc-plc) is imported. A bogus EventId gets `BadEventIdUnknown`. The consumer `ack` and `comment` (CLI "Comment added") both succeed, and the origin audits both: `Acknowledge … AcceptedUnconfirmed 0x00000000` and `AddComment … AcceptedUnconfirmed`, each on `Raw:…:opcua/opcplc/EastTankYellow` on behalf of `fixture-cli`. `confirm` gets `BadNotSupported [0x803D0000]`, and the origin audit has **no** Confirm line, so it was unsent; the two audited calls are the positive control. |
|
||
| A04 | **PASS** (16 checks) | See the A04 notes below. |
|
||
| A05 | **PASS** (4 checks) | The consumer pair was restarted with `Security__Acl__Enabled=false` (rig configuration experiment). In the same window the granted `fixture-cli` session saw 3 ScalarHigh and 6 EastTankYellow events. `fixture-cli-nogrant` at `i=2253` (two sessions, each with ConditionRefresh) saw **0** imported events. Its RefreshStart/End markers (2) arrived, which shows the session and subscription were alive. |
|
||
| A08 | **PASS** (10 checks) | See the A08 notes below. |
|
||
|
||
**A04 notes.**
|
||
- The three branch folders were resolved by browsing: `OtOpcUa/remote-opc`, `/remote-pumpa` and `/remote-pumpb`.
|
||
- Two rounds ran with different folder-subscription orders, (pumpa, raw, pumpb) then (raw, pumpb, pumpa), and the 30 s
|
||
demand linger was allowed to expire between them.
|
||
- In each round the Server object showed exactly **one** consumer ConditionId, and that id was the same in both rounds.
|
||
- No `i=2253` EventId was duplicated after all subscribers were up.
|
||
- All three folders were live notifiers: each carried the same single ConditionId, with no duplicates.
|
||
- Every live Server-object event after the window reached every folder, and no folder carried an event the Server object
|
||
lacked.
|
||
- `fixture-unsonly` records (probe `condition-records`, UNS `pumpa` item) are UNS-only. The placement is
|
||
`area/line/pumpa/EastTankYellow`, and `opcua/opcplc` appears nowhere in them.
|
||
- Positive control: the full principal's Raw item names `opcua/opcplc/EastTankYellow`.
|
||
|
||
**A08 notes.**
|
||
- The setup was `acl_permissions` `source-peer` := Admin without `AlarmAcknowledge` (3839), then deploy.
|
||
- ScalarHigh still streams: it was imported Active and cleared Inactive on the consumer.
|
||
- The consumer `ack` returned `BadUserAccessDenied [0x801F0000]`. The origin audit records
|
||
`Acknowledge … RejectedBeforeDispatch 0x801F0000`, so the denial came from the origin, not the consumer gate. The origin
|
||
never showed Acknowledged.
|
||
- The `alert-transitions` node probe listened on each Primary's own authenticated telemetry stream (the `/alerts` +
|
||
alarm-history feed) for 110 s:
|
||
- SOURCE: 71 envelopes, 15 transitions (ScalarHigh Activated/Cleared plus native ones). This is the positive control.
|
||
- CONSUMER: **0** transitions.
|
||
- Restoring 4095 and deploying makes the same consumer ack Good. This is the positive control for the denial.
|
||
|
||
**Also re-run on `a4s-2`:** `conditions_a3_smoke.py` passed, all 7 checks; exactly one Active/Acknowledged event on each
|
||
side.
|
||
|
||
### Observations (no product defect found in part 1)
|
||
|
||
1. **A folder event item created before demand is open is refused `BadNotSupported`.** The CLI exits with an error. This
|
||
is A3 deviation 3 ("a folder is a notifier only while a condition is wired there") and was observed live on the debug
|
||
run `a4s-1`. The consequence is that a client that subscribes only at an equipment or device folder, with no Server-object
|
||
item anywhere on that consumer node, never gets imported conditions, and the CLI cannot retry. A04 therefore opens demand
|
||
at `i=2253` first.
|
||
- Worth a ScadaBridge note: its DCL subscribes at the Server object, so it is unaffected.
|
||
- Worth a docs line in `AlarmTracking.md` "Imported conditions".
|
||
2. **Native ack against opc-plc is never confirmed upstream.** opc-plc's `--alm` conditions return Good to Acknowledge, but
|
||
they keep reporting `AckedState=false`, with all-zero EventIds (`EastTank?Red`).
|
||
- The origin's driver dedups on the last-told state, so after a consumer ack the origin and consumer show `Active, Acknowledged` and then stay silent. For `Red`, which never leaves Active, nothing more ever arrives.
|
||
- This is the `AcceptedUnconfirmed` contract working as specified: the consumer doesn't claim the upstream applied it. It is also a simulator limitation.
|
||
- That is why the alarm tag binds `Yellow`, which cycles. The first run (`a4s-1`, a debug run with a hand-written `fixture.json`, not evidence) used `Red`.
|
||
3. **A native AddComment produces no event.** It is forwarded and audited `AcceptedUnconfirmed`, but opc-plc emits no
|
||
comment event, so neither side re-reports anything. This is expected for `AcceptedUnconfirmed`.
|
||
4. **The origin `/alerts` writes `Activated` rows for opc-plc's repeated "severity has increased" events on an
|
||
already-Active condition.** That is one row every ~8 s, seen in the A08 SOURCE stream. The cause is the OpcUaClient
|
||
restatement rule (#656): only the same message *and* the same severity is suppressed. This is pre-existing origin-side
|
||
behaviour, unrelated to forwarding, and is recorded only.
|
||
5. **A08's consumer telemetry stream carried 0 envelopes.** The consumer has no drivers, so there is no driver-health
|
||
priming. The "stream open" check therefore proves an authenticated subscribe that ran to its deadline without error, not
|
||
that traffic was received. The SOURCE stream from the same probe code is the positive control. The rig runs no alarm
|
||
historian, so the "no alarm-history rows" leg is asserted at the feed the historian adapter consumes (the `alerts`
|
||
transitions), not at a historian table.
|
||
6. **Harness defect found and fixed during the run.** With `Write` in their operations, condition mappings need
|
||
`WriteThrough=true` (`DataMappingOperationsInvalid`). The first seed (`a4s-1`) was rejected; that run id is poisoned.
|
||
|
||
### Harness notes for part 2 (A03, A06, A07)
|
||
|
||
- Add `scenario_A03`/`A06`/`A07` methods to `ConditionScenarios` and their ids to `SCENARIOS`/`TIMEOUTS`. `run()` already
|
||
handles per-scenario restore and result rows. Add the id to the `baseline()` set in `run()` if the scenario mutates.
|
||
- Building blocks:
|
||
- `Watch` (a CLI `alarms` subscription per node/notifier/key, with parsed blocks);
|
||
- `projected_folders` (resolved by browse);
|
||
- `condition_child` (browse a condition, then read a child);
|
||
- `audit(node, since)` (origin method audit lines);
|
||
- `node_probe_async(node, op, seconds)` (a non-blocking node-file probe);
|
||
- `probe_records(...)` (origin condition snapshot under any `data_key_files` principal);
|
||
- `self.r.stopped(...)` / `self.r.paused(...)` / `self.r.wait_primary(...)` from `ScenarioRunner` for failover and restarts.
|
||
- A03 should use a failover in which the record `time` changes (D7), i.e. raise/clear across the gap. The scripted
|
||
`ScalarHigh` is the controllable alarm. `EastTankYellow` cycles every ~48 s by itself, which is useful as a
|
||
"standing active" native alarm.
|
||
- A06/A07: watch both `consumer-1` and `consumer-2` (each with `Watch(..., node)`) and compare the printed ConditionIds. For
|
||
RefreshRequired, the CLI prints every event, so look for the RefreshRequired event type in the block's `Message`/`Source`.
|
||
The CLI does not print EventType; add it to `AlarmsCommand` if A07 needs it, which is a CLI `.cs` change and so must land
|
||
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-<id>.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.
|
||
|
||
## 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 |
|
||
|
||
### Gates after the F1–F4 fixes (`a4-code` at `0c253b66`)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A4` / `A3` / `A2` / `A1` / `X0` | all exit 0 (`20261125T080929…`, `…081015…`, `…081134…`, `…081248…`, `…081627…`) |
|
||
| Host.Tests `DataConnections` | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2076 passed, 3 skipped, 1 failed: `GrpcDataConfiguredDiscoveryWireTests.Two_sdk_cadences_…` (the known #920 flake), which passed when re-run alone |
|
||
| OpcUaServer.Tests full | 1458 passed, 2 skipped |
|
||
| OI combined (`Feature=GrpcData` + ConditionMethodEvent / NativeAlarmEventIdentityFieldDelivery / FolderConditionRefresh / ConditionRefreshDeferral / ImportedConditionEventWireTests), once | 139 passed, 1 skipped (opt-in L2 harness) |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
## Full A01–A08 run (2) — run `a4s-6`
|
||
|
||
The sequence was `rig.py up --run-id a4s-6 --conditions` → `seed` → 85 s → `deploy --timeout 300` → `conditions_a3_smoke.py`
|
||
(`passed: true`) → `conditions_scenarios.py` (all eight in one session) → `rig.py down` (0 run containers left). Evidence is
|
||
in `artifacts/grpc-data/runs/a4s-6/evidence/` (`A4S-results.md`). **A4 exit gate: 8/8 PASS.**
|
||
|
||
| Scenario | Result | Checks | Notes |
|
||
|---|---|---|---|
|
||
| A01 | PASS | 13/13 | |
|
||
| A02 | PASS | 10/10 | |
|
||
| A03 | **PASS** | 19/19 | Phase 1 (deploy-driven stream reset): consumer `events_during_reset` = `[]` and origin = `[]` (F2 gone); the pre-reset EventId comment is Good (F1 gone); `duplicate_transitions` = `[]` (F3 gone); the latest-EventId positive control is Good. The phase 2 failover/G4 path is unchanged and passes. |
|
||
| A04 | PASS | 16/16 | |
|
||
| A05 | PASS | 4/4 | |
|
||
| A06 | PASS | 11/11 | |
|
||
| A07 | PASS | 8/8 | |
|
||
| A08 | PASS | 10/10 | |
|
||
|
||
Remaining open items, each filed: **#935**, a reload re-activates still-active scripted alarms (the origin un-acks an acked
|
||
alarm and writes a duplicate `alerts` row on every deploy); **#936**, the removal RefreshRequired is gated by the current
|
||
mapping set.
|
||
|
||
## Review round 2
|
||
|
||
The review is `a4-review-round2.md` at `57522437`. Its verdict was approve-with-changes, with no blocker. Commits:
|
||
`d72f2d96` (S1–S4 and the runtime NITs), `6bdca132` (the F4 and EventId NITs) and `dc5ed011` (the A03 phase-1 check and
|
||
the docs). Each "red" below means the named test was re-run with that one change reverted, failed at the stated assertion,
|
||
and passed again once the change was restored and rebuilt.
|
||
|
||
| Finding | Outcome | Test | Red on revert |
|
||
|---|---|---|---|
|
||
| **S1** `Suspended` read live next to an older `Current` copy | Fixed. `ProjectedMappingDeploymentRuntime` publishes `ProjectedMappingSet(Placements, Suspended, Sequence)`, captured under `_gate` in each transition and raised as `SetChanged` after every transition. `DeployedConditionMappings` keeps it as one volatile reference (the highest `Sequence` wins, so out-of-order notifications cannot regress it), and `ReconcileRunners` reads `IProjectedConditionMappings.Snapshot` as one pair. | Runtime `R2_S1_a_demand_acquired_between_the_settle_and_its_notification_keeps_the_held_set`: a real coordinator and runtime. A `Changed` handler registered **before** the adapter calls `AcquireEventDemand` inside the window (after `_gate` is released and before the adapter has seen the transition). | **red**. With the old adapter (live flag plus a copied list) it fails at `f.Sink.Removed should be empty` |
|
||
| **S2** a non-success deploy leaves the hold unbounded | Fixed (the decision is below). A separate `_undecided` flag is set by `AttemptBegan` and cleared by **any** `AttemptCompleted`, so a failed, degraded or throwing build settles the set as empty and the held runner is released. Browse-anchor `Suspended` is unchanged: it still clears only on success, so anchors stay retained. A hold is bounded: the held conditions go `BadNoCommunication` on the connection's stale timeout, chained after the runner's stop and disarmed under `_staleGate` before any takeover. Past `ProjectedConditionOptions.MaxHold` (default 5 min) the held set is released. Diagnostics report `held` (from a concurrent `_held`, without `_gate`), keep its counters (`RetainConsumers` includes held ids), and the set stays charged until release. | Runtime `R2_S2_an_unsuccessful_deploy_completion_releases_the_held_conditions` (real coordinator, `Complete(attempt, false)`), `R2_S2_a_hold_that_never_settles_goes_stale_then_is_released_past_MaxHold`, `R2_S4_…` | **red** for each part, reverted separately. `_undecided = !success`: the unsuccessful-completion test (no removal) and R2_S4. `MaxHold` timer infinite: the never-settles test (no removal). Hold stale mark removed: the never-settles test and F1 (its positive control). `held` diagnostics branch removed: both S2 tests (null diagnostics) |
|
||
| **S3** no resync signal after a hold | Fixed. A runner constructed with `tookOverHeld` (only when the predecessor came from `_held`) and handed a **non-empty** set sends `RequireRefresh(ConnectionId)` once at its first barrier, after the re-snapshot's `Reconcile`. It is visibility-gated in the registry, keeps EventIds, and is not a condition event. | Runtime `R2_S3_a_runner_taking_over_a_held_set_sends_RefreshRequired_once_at_its_first_barrier` (none before the barrier, exactly one after, none at a later complete resync of the same runner); `R2_S1_…` asserts 1 | **red** (`tookOverHeld: false`): both tests time out waiting for the RefreshRequired |
|
||
| **S4** the production switch was untested | Added. `GrpcDataCatalogStagingTests.R2_S4_the_published_set_is_undecided_only_between_AttemptBegan_and_any_completion` covers Began, success, Began, a failed or degraded completion (`Complete(attempt, false)`), a throwing build (invalid parent), and a never-completing Began. It checks `runtime.Set`, `runtime.Suspended` (browse retention: still true after a failure) and `DeployedConditionMappings.Snapshot`, with one notification per transition. The S1 interleave is the S1 test above. | — | **red** (`_undecided = !success`) at `runtime.Set.Suspended should be false` |
|
||
| NIT F1 second-phase absence check | Fixed: a must-arrive control. The hold's stale mark is chained after the held runner's stop, and any removal would run in that stop's continuation, so the test waits for `Sink.Stale` before `Removed.ShouldBeEmpty()`. | `F1_…` | **red** when the hold stale mark is removed (the control never arrives) |
|
||
| NIT linger expiry while held | Test added. | `R2_NIT_linger_expiry_while_held_releases_the_held_conditions` | **red** (`ReleaseHeld(_ => true)` dropped from `OnLingerExpired`) |
|
||
| NIT EventId retention across the takeover | Test added at the node-manager level. A takeover re-snapshot (versions restart, same marker, a restated newer record time, then `RequireRefresh`) keeps the condition instance, the current EventId and an older retained one (both acks Good, sent with the same marker), and reports no event. | OI `ImportedConditionMethodWireTests.R2_a_takeover_re_snapshot_with_the_same_marker_keeps_the_instance_and_every_retained_EventId` | Control, not a product revert: modelling the pre-F1 behaviour (`RemoveConditions` before the re-apply) fails at the `ReferenceEquals` instance check. The runtime half (no removal across the hold) is pinned by F1 and R2_S1 |
|
||
| NIT F4 negative case | Test extended. After `ConditionBearing = true`, an anonymous (ungranted) caller's folder item gets `BadUserAccessDenied`, the folder's `EventNotifier` is unchanged (read through a new `ProjectedFolderEventNotifier` test observation) and no demand opens. Then the granted item promotes it (positive control). | OI `F4_…` | **red**: swapping admission and promotion fails at `EventNotifier … should be` (unchanged) |
|
||
| NIT fake `CanSubscribeFolder` ignores `ConditionBearing` | Fixed. The fake now returns false while the mapping is not condition-bearing, as the real gate does, and the F4 control asserts `BadUserAccessDenied` (it was `BadNotSupported`). | OI `F4_…` | — |
|
||
| NIT `Dispose` ignores `_held` | Fixed: `Dispose` ends each held runner's hold (disposing its timers) and clears `_held`. | — | — |
|
||
| NIT promotion is never demoted | Recorded, not changed. It matches materialisation-time promotion, and removal or a rebuild clears it. A folder that stays a notifier after its mapping stops being condition-bearing admits nobody: the mapping gate refuses the item. | — | — |
|
||
| Round-1 leftover `unknown = states.Any(x => !x.Known)` | Already filed as **#933** in round 1 (the "NIT permanent removal block" row above). | — | — |
|
||
|
||
**Degraded-apply decision: settled (with the empty set), not "settled with the new set" and not held.** `FinishRebuild`
|
||
calls `LocalCatalogCoordinator.Complete(attempt, topologySucceeded: !outcome.Degraded)`. A degraded apply makes `valid`
|
||
false, so `_published` goes null, `CatalogActivation.Complete` reports not completed, and `AttemptCompleted(attempt,
|
||
completed: false)` publishes **no placements**.
|
||
- The published mapping set after a degraded apply really is empty. No `CanSee` can pass, projected browse has no current
|
||
placement, and the new set never became the deployed one.
|
||
- Treating it as "settled with the new set" would claim mappings the node is not serving.
|
||
- Holding until the next deploy is the unbounded case the review describes. Holding with a timeout keeps invisible state
|
||
for no reader.
|
||
- So any completion settles. The empty set releases the held conditions (a removal, the same class as a mapping removal or
|
||
a linger expiry, never "known inactive"). The retry deploy that follows re-creates them.
|
||
- The cost is one remove and re-create per failed or degraded deploy (new EventIds). That is accepted: a failed deploy has
|
||
already withdrawn every projection on that node.
|
||
- Browse anchors keep their old retention (`Suspended` stays set after an unsuccessful attempt). That is a separate flag
|
||
with separate semantics, deliberately unchanged.
|
||
|
||
**A03 phase-1 check and the RefreshRequired (S3).** Phase 1 bumps a mapping revision, which deploys the consumer, so the
|
||
connection is held and then taken over. The consumer's Server-object watcher now receives **one** `RefreshRequiredEventType`
|
||
at the takeover barrier. The rig has one condition-bearing connection (`consumer-source`).
|
||
- `p1_consumer_events_mirror_origin` (unchanged) still requires the consumer's ScalarHigh events during the reset to equal
|
||
the origin's, so any extra **condition** event fails it. That is F2's check.
|
||
- The new `p1_exactly_one_refresh_required_after_held_takeover` counts RefreshRequired across all of the watcher's blocks
|
||
since the mutation and requires exactly one.
|
||
- This is safe for F1–F3 for three reasons:
|
||
- RefreshRequired carries no condition and no EventId.
|
||
- A client that refreshes gets the same EventIds (the takeover re-bound nothing).
|
||
- `duplicate_transitions` ignores non-condition events.
|
||
- Phase 2 marks its own window (`mark_all`) after phase 1, so the phase-1 RefreshRequired cannot satisfy
|
||
`p2_refresh_required_received`.
|
||
|
||
### Gates after review round 2 (`a4-code` at `dc5ed011`)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A4` / `A3` / `A2` / `A1` / `X0` | all exit 0 (`20261125T090847…`, `…090936…`, `…091038…`, `…091149…`, `…091516…`) |
|
||
| Host.Tests `DataConnections` | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2083 passed, 3 skipped, 0 failed (#920 did not fire) |
|
||
| OpcUaServer.Tests full | 1458 passed, 2 skipped |
|
||
| OI combined (`Feature=GrpcData` + ConditionMethodEvent / NativeAlarmEventIdentityFieldDelivery / FolderConditionRefresh / ConditionRefreshDeferral / ImportedConditionEventWireTests), once | 140 passed, 1 skipped (opt-in L2 harness) |
|
||
| `git diff master -- '*Goldens.cs'` | empty (no proto, mapper or golden touched) |
|
||
|
||
### Full A01–A08 run (3) — run `a4s-7` (after review round 2)
|
||
|
||
The sequence was `rig.py up --run-id a4s-7 --conditions` → `seed` → 85 s → `deploy --timeout 300` → `conditions_a3_smoke.py`
|
||
(`passed: true`) → `conditions_scenarios.py` (all eight in one session) → `rig.py down` (0 run containers left). Evidence is
|
||
in `artifacts/grpc-data/runs/a4s-7/evidence/` (`A4S-results.md`). **A4 exit gate: 8/8 PASS.**
|
||
|
||
| Scenario | Result | Checks | Notes |
|
||
|---|---|---|---|
|
||
| A01 | PASS | 13/13 | |
|
||
| A02 | PASS | 10/10 | |
|
||
| A03 | **PASS** | 20/20 | Phase 1: consumer `events_during_reset` = `[]` and origin = `[]` (still no extra condition event); the pre-reset EventId comment is Good. The new `p1_exactly_one_refresh_required_after_held_takeover` passed: one `RefreshRequiredEventType` (Source `Server`, 09:35:12.267) right after the takeover barrier (09:35:12.265). A second barrier at 09:35:15 (the source-side deploy reset the stream) sent none, so the signal is one-shot. Phase 2 (failover/G4) unchanged and passing; `duplicate_transitions` = `[]`. |
|
||
| A04 | PASS | 16/16 | |
|
||
| A05 | PASS | 4/4 | The denied session still saw zero imported events (RefreshRequired is visibility-gated). |
|
||
| A06 | PASS | 11/11 | |
|
||
| A07 | PASS | 8/8 | |
|
||
| A08 | PASS | 10/10 | |
|
||
|
||
## Follow-ups #933/#934/#936 (consumer side, branch `fu-consumer-933`)
|
||
|
||
"Red" = that one change reverted in place (file restored afterwards), the named test re-run alone; it failed at the stated
|
||
assertion and passed again once restored.
|
||
|
||
### #933 — a durably unknown mapping no longer blocks removals forever
|
||
|
||
**Decision: a bounded per-key hold, not scoping.** Scoping the unknown check to "mappings whose placements could list the
|
||
key" would need a proof that the unknown mapping cannot list it. The consumer has none: a mapping lists a key when the
|
||
origin's *current* catalog places the condition under that mapping's root in its realm
|
||
(`LocalExportCatalog.Compilation.cs` builds condition placements at origin deploy time; raw placements by device scope, UNS
|
||
placements by `UnsTagReference` / equipment). An origin deploy can add a UNS reference or move a tag, so the very drop that
|
||
made a known mapping stop listing a key may be a move into the unknown mapping's root. Neither a disjoint root nor a
|
||
different realm is provable from the consumer's last-known placements.
|
||
|
||
- `ProjectedConditionOptions.MaxUnknownHold` (default **20 min**, fixed like `LongRetryDelay`). A materialised key that no
|
||
known mapping lists, held `BadNoCommunication` because another mapping is unknown, records when the hold began
|
||
(`_heldSince`, loop-owned, kept across stream ends and hand-overs so a flapping stream cannot restart it). Past the bound
|
||
`Reconcile` removes it: a removal with RefreshRequired (the sink's §5.2 path), never "known inactive". A later listing
|
||
re-creates it (new EventIds). Logged Warning "held past MaxUnknownHold" with the unknown mappings and their status.
|
||
- Why 20 min: about 4× the longest transient retry cycle at the default 30 s snapshot timeout (× 8 = 4 min, plus the
|
||
retry's own timeout), and it spans the first two in-stream re-checks of a definitive refusal (`LongRetryDelay` 5 min,
|
||
then 10 min). A transient outage or a grant corrected within that window removes nothing; only a durable one does.
|
||
- The earliest expiry shares the loop's retry timer (`HeldExpiry` in the wanted deadline), and `ExpireHeld` runs on the
|
||
loop when it fires, so no frame is needed to settle it. An expiry entry for a key no longer materialised is dropped,
|
||
so the timer cannot re-arm at zero.
|
||
- Docs: `DataConnections.md` lifetime rule (step 6) and a troubleshooting row.
|
||
|
||
| Test | Red on revert |
|
||
|---|---|
|
||
| Runtime `Issue933_a_key_held_for_a_durably_denied_mapping_is_removed_past_MaxUnknownHold_not_kept_forever`: map-b `Denied`, map-a retires x ⇒ stale mark arrives (must-arrive control), nothing removed; past 1.5 s x is removed once, with no frame, stream kept, map-b still Unavailable; a later listing re-creates x | **red** with the bound disabled (`< TimeSpan.MaxValue`): fails at the removal wait. Also **red** with only the timer-driven `ExpireHeld` removed (the expiry then waits for a frame that never comes) |
|
||
|
||
### #934 — the in-stream root re-resolve no longer runs on the frame loop
|
||
|
||
- `ResolveRootsAsync` was split. `FetchRootsAsync` (static, reads only the immutable `MappingState.Root` views, never
|
||
throws except cancellation) issues the metadata request. `ApplyRoots` sets `RootView` or calls `MarkRefused`, on the loop.
|
||
- `RetryDueAsync` starts the fetch for due mappings whose root never resolved, marks them `Resolving`, and records it in
|
||
the stream's `Resolves` list. The loop's wake set is `WhenAny(retry timer, pending fetches)` after the barrier.
|
||
`ApplyResolvedAsync` (on the loop, each iteration) applies every finished fetch and re-adds the resolved mappings
|
||
(`ReAddAsync`, the old re-add body unchanged).
|
||
- While resolving, the mapping stays `Unavailable` (unknown, T2: nothing it may list is removed or marked inactive), and
|
||
`ScheduleRetry` skips it, so it is not retried twice. A failed answer re-schedules it on its backoff. A fetch outliving
|
||
its stream is abandoned (cancelled with the stream's token; the next stream has fresh states).
|
||
- The stream-open resolve still awaits (no frames exist yet). All runner state stays loop-owned.
|
||
|
||
| Test | Red on revert |
|
||
|---|---|
|
||
| Runtime `Issue934_a_slow_in_stream_root_re_resolve_does_not_stall_frames_of_the_other_mappings`: map-a's root fails at open; its in-stream re-resolve (2nd metadata call) hangs; map-b's delta y is applied meanwhile, map-a not re-added and Unavailable; released ⇒ re-added exactly once and Complete (positive control), 2 metadata calls | **red** with the fetch awaited inline in `RetryDueAsync` (the old shape): fails at the y wait (10 s) |
|
||
|
||
### #936 — the removal RefreshRequired reaches holders after their mapping left the deployed set
|
||
|
||
**Decision: visibility for a removal is "this identity was admitted to this condition instance", recorded at admission.**
|
||
Not "send to every collected target without a check": the targets include every Server-object item of every session, so an
|
||
ungranted session would learn that an imported condition it never saw was removed (and A05's "denied session sees nothing"
|
||
would no longer hold).
|
||
|
||
- `ImportedCondition` keeps a `ConditionalWeakTable` of admitted identities (weak keys: a closed session's identity is
|
||
collected). `ImportedVisibleTo` records the caller inside the verdict-cache compute when `CanSee` is true. That compute
|
||
is the only place a positive verdict is made, and every delivery (publish-time marker), refresh replay and Read/Browse
|
||
of an imported condition goes through it. Cached positives were recorded when computed; `Remove` clears the NodeId's
|
||
verdicts, so a re-created instance (same NodeId) is admitted afresh.
|
||
- `RemoveConditions` → `QueueRefreshRequired(…, removal: true)`: a collected target (Server-object item, or direct item at
|
||
a folder the condition was wired to) is sent one RefreshRequired when its identity was admitted to a removed instance.
|
||
The non-removal paths (incomplete barrier, un-re-bindable resync, takeover) keep the current gate.
|
||
- **What the event carries:** `RefreshRequiredEventState` with `SourceNode = Server`, `SourceName = "Server"`,
|
||
`Message = "RefreshRequired"`, Severity Low, a fresh EventId and times. It has no ConditionId, ConditionName,
|
||
Active/Acked state or any origin data (asserted on the wire). It goes only to identities that could see the condition.
|
||
Residual: an identity admitted earlier and revoked by an ACL edit since is still told (content-free, about a condition it
|
||
saw).
|
||
- Docs: `AlarmTracking.md` §ConditionRefresh and RefreshRequired.
|
||
|
||
| Test | Red on revert |
|
||
|---|---|
|
||
| OI `Issue936_a_removal_after_the_mapping_left_the_deployed_set_still_tells_its_holders_and_only_them`: the granted session holds the condition (server + device items); then the gate admits nobody (`Allowed.Clear()`, generation bumped — what `CanSee` does with the mapping gone) and the condition is removed ⇒ both items get RefreshRequired (count 2), with no condition fields; the anonymous session's Server item gets none, after a must-arrive control (its own ConditionRefresh's RefreshEnd) | **red** with `removal: false` (the old current-gate check): fails at the RefreshRequired wait. **Red** the other way too: an unconditional send fails at the count (3, the ungranted session was told). `Deviation6_…` still green |
|
||
|
||
Commits: `2eb31f62` (#933), `5d946fde` (#934), `18154eef` (#936), plus this evidence commit.
|
||
|
||
### Gates (`fu-consumer-933` at `18154eef`)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A4` / `A3` / `A2` | all exit 0 (`20261125T160154…`, `…160249…`, `…160447…`) |
|
||
| Host.Tests `DataConnections` | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2085 passed, 3 skipped, 0 failed (#920 did not fire) |
|
||
| OpcUaServer.Tests full | 1458 passed, 2 skipped |
|
||
| OI combined (`Feature=GrpcData` + ConditionMethodEvent / NativeAlarmEventIdentityFieldDelivery / FolderConditionRefresh / ConditionRefreshDeferral / ImportedConditionEventWireTests), once | 141 passed, 1 skipped (opt-in L2 harness) |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
### Full A01–A08 run — run `fu933-1` (after #933/#934/#936)
|
||
|
||
The sequence was `rig.py up --run-id fu933-1 --conditions` → `seed` → 85 s → `deploy --timeout 300` →
|
||
`conditions_a3_smoke.py` (`passed: true`) → `conditions_scenarios.py` (all eight, one session) → `rig.py down` (exit 0,
|
||
0 run containers left). Evidence is in `artifacts/grpc-data/runs/fu933-1/evidence/`. **8/8 PASS.**
|
||
|
||
| Scenario | Result | Checks | Notes |
|
||
|---|---|---|---|
|
||
| A01 | PASS | 13/13 | |
|
||
| A02 | PASS | 10/10 | |
|
||
| A03 | PASS | 20/20 | `p1_exactly_one_refresh_required_after_held_takeover` still exactly one; phase 2 RefreshRequired + new-EventId ack Good |
|
||
| A04 | PASS | 16/16 | |
|
||
| A05 | PASS | 4/4 | The denied session still saw zero imported events (the #936 removal path sends only to admitted identities) |
|
||
| A06 | PASS | 11/11 | |
|
||
| A07 | PASS | 8/8 | |
|
||
| A08 | PASS | 10/10 | |
|
||
|
||
The live scenarios do not exercise a 20 min unknown hold, a slow origin metadata answer, or a mapping removal while a
|
||
client holds a condition. Those three behaviours are pinned by the unit/OI tests above; the live run shows no regression.
|
||
|
||
## Follow-ups review round 1 (#933/#934/#936)
|
||
|
||
The review (approve-with-changes) found two gaps in #933, two in #936 and five NITs. Every fix below has a test that was
|
||
run red with the fix reverted and green with it restored.
|
||
|
||
### S1 (#933) — the bound removed the unknown mapping's own conditions
|
||
|
||
A key held because ANOTHER mapping is unknown is still bounded by `MaxUnknownHold`. A key the unknown mapping listed
|
||
itself the last time it was known (`_lastListed`: its previous stream, or before a capacity reset) is held with no bound
|
||
while that mapping is only transiently unknown (`Pending`, `Unavailable`, retrying). Its clock starts only when the
|
||
mapping's refusal is definitive (`Denied` / `NotFound` / `Unsupported` / `ConditionCapacity`).
|
||
|
||
- The definitive verdict is kept in a runner set (`_definitiveRefused`). It survives in-stream retries (a retry resets
|
||
`Refusal` to null), stream ends and hand-overs, and is cleared when the mapping completes a snapshot. Without it, each
|
||
long retry of a durably denied mapping would make it transient again, restart its keys' clocks, and they would never
|
||
expire, because the retry backoff tops out at 20 min.
|
||
- When the set of transient mappings changes, the loop re-decides the held keys (`ReconcileUnlisted`). Exempt keys drop
|
||
their clock; the others start it.
|
||
- **The single-mapping and never-opening-stream cases are now consistent.** A connection whose stream never opens holds
|
||
its keys stale indefinitely. A mapping that is only transiently unknown now does the same with its own keys. Only a
|
||
definitive refusal leads to the bounded removal.
|
||
|
||
### S2 (#933) — the hold clock counted time when no stream was open
|
||
|
||
The clock now runs only while a stream is past its barrier. The stream's `finally` records `_heldPausedAt` if that stream
|
||
passed its barrier. The next barrier shifts every `_heldSince` forward by the paused time before its full re-diff.
|
||
`_heldPausedAt` is handed over with `_heldSince`.
|
||
|
||
### S3 (#936) — admission was keyed on the identity object
|
||
|
||
SDK evidence comes from `Opc.Ua.Server` 2.0.1 `lib/net9.0`, decompiled with ilspycmd:
|
||
|
||
- `Session.UpdateUserIdentity`, which runs on every ActivateSession, assigns `Identity` and `EffectiveIdentity` the new
|
||
objects.
|
||
- `MonitoredItem.EffectiveIdentity` returns `m_subscription?.EffectiveIdentity`.
|
||
- `Subscription.EffectiveIdentity` returns `Session.EffectiveIdentity`, or the saved owner identity when it has no session.
|
||
|
||
So a re-activated session, or a subscription transferred to another session, presents a new `RoleCarryingUserIdentity`
|
||
object. `OpcUaApplicationHost` builds that object per activation. The OI test also asserts directly that
|
||
`EffectiveIdentity` is a different object after `ReconnectAsync`.
|
||
|
||
- **Decision:** admission is keyed on `RoleCarryingUserIdentity.AdmissionKey` = principal + `\0` + API key id. It is
|
||
computed once per identity object, and the set references the identity's string.
|
||
- The session id was rejected because it does not survive a subscription transfer to a new session.
|
||
- Sessions sharing one key share its grants, so they also share the record. A sibling session of an admitted key may
|
||
receive a content-free RefreshRequired. That is the same audience the old current-gate check had.
|
||
- A removal now sends RefreshRequired when `WasAdmitted(identity) || ImportedVisibleNow(identity, c)`. `ImportedVisibleNow`
|
||
is the current gate, uncached, so nothing is cached for the removed instance.
|
||
|
||
### S4 (#936) — one ConditionalWeakTable per condition
|
||
|
||
`ImportedCondition` now holds a `HashSet<string>?`.
|
||
|
||
- It is allocated by CAS on the first admission and locked on itself. A condition nobody was admitted to allocates
|
||
nothing. There are no finalizable containers and no dependent handles.
|
||
- **Bound:** one entry per distinct credential admitted, capped at `MaxAdmittedCredentials` = 1024 per condition. Past the
|
||
cap, a holder falls back to the current gate at removal. A Server-object ConditionRefresh by S sessions of K keys adds at
|
||
most C × K entries, where K ≤ deployed API keys + anonymous. The old structure grew S × C.
|
||
- The record is dropped (`ForgetAdmitted`) once the removal's RefreshRequired has been decided. Other removal paths drop
|
||
the instance itself.
|
||
|
||
### NITs
|
||
|
||
- **N1 (#934):** in-stream root re-resolves run under a per-stream `fetches` source. It is linked to the stream token and
|
||
cancelled in the stream's `finally` however the stream ends. Cancelling the stream token itself was rejected: it would
|
||
also abort the subscription's graceful dispose.
|
||
- **N2 (#933):** no held-key expiry is armed when there is no sink.
|
||
- **N3 (#933):** a `MaxUnknownHold` of zero or less makes the `ProjectedConditionAccess` constructor throw
|
||
`ArgumentOutOfRangeException`.
|
||
- **N4 (#936):** `Verdict` writes back only while `_byInstance` still holds that instance. `Remove` drops the instance from
|
||
`_byInstance` before purging under the same gate.
|
||
- The existing S2 TTL unit test now `Add`s its condition first. Verdicts are only cached for live instances.
|
||
- **N5:** the #933 test's lower bound is taken BEFORE the record that starts the hold. It is asserted `≥ hold` with no
|
||
tolerance.
|
||
|
||
### Tests (red on revert → green)
|
||
|
||
| Test | Revert used | Red |
|
||
|---|---|---|
|
||
| `Issue933_r1_S1_…held_past_the_bound_until_that_mapping_is_definitively_refused` (map-b listed x, then transiently refused on the next stream ⇒ x not removed after 2.5 × hold; positive control: a Denied re-add ack ⇒ removed ≥ hold after it) | exemption disabled | **red** (x removed while map-b transient) |
|
||
| `Issue933_r1_S2_time_with_no_stream_past_its_barrier_does_not_count…` (held, stream ends, next stream sits 2 × hold before its barrier ⇒ not removed at the barrier; removed later on the live stream) | gap shift disabled | **red** ("Removed should be empty") |
|
||
| `Issue933_r1_N2_with_no_sink_an_expired_hold_does_not_spin_the_loop` (sink lookups in 500 ms after expiry < 50) | `HeldExpiry()` armed without a sink | **red** |
|
||
| `Issue933_r1_N3_a_non_positive_MaxUnknownHold_is_refused` | guard removed | **red** |
|
||
| `Issue934_r1_N1_a_root_re_resolve_in_flight_is_cancelled_when_the_stream_ends` (natural end ⇒ the blocked metadata call observes cancellation; next stream resolves; the abandoned answer is never applied) | `fetches.Cancel()` removed | **red** (10 s wait) |
|
||
| `Issue934_r1_a_second_failed_in_stream_re_resolve_is_rescheduled…` | — (new coverage, no fix) | green |
|
||
| OI `Issue936_r1_S3_a_session_re_activated_on_a_new_channel_is_still_told_of_the_removal` | `AdmissionKey` = a per-object GUID (object keying) | **red** |
|
||
| unit `Issue936_r1_S3_S4_admission_is_recorded_lazily_per_credential…` | GUID key / eager allocation | **red** for each |
|
||
| unit `Issue936_r1_N4_a_verdict_computed_while_its_condition_was_removed…` | write-back guard removed | **red** |
|
||
|
||
The `|| ImportedVisibleNow` removal fallback has no test of its own. Once admission is keyed on the credential, the
|
||
fallback is reachable only past the 1024-credential cap, or for an identity the gate admits now but never admitted
|
||
before.
|
||
|
||
Commits: `9d969c47` (#933 S1/S2/N2/N3/N5, #934 N1), `e61db016` (#936 S3/S4/N4 + docs), plus this evidence commit.
|
||
|
||
### Gates (`fu-consumer-933` at `e61db016`)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A4` / `A3` / `A2` | all `passed`: A4 Runtime 90 + AdminUI 14; A3 Runtime 90 + OpcUaServer 33 + Host 82; A2 157 + 83 + 32 + 30 + 12 + 12 + 5 (`20261125T170708…`, `…170812…`, `…170934…`) |
|
||
| Host.Tests `DataConnections` | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2091 passed, 3 skipped, 0 failed (#920 did not fire) |
|
||
| OpcUaServer.Tests full | 1460 passed, 2 skipped |
|
||
| OI combined (`Feature=GrpcData` + ConditionMethodEvent / NativeAlarmEventIdentityFieldDelivery / FolderConditionRefresh / ConditionRefreshDeferral / ImportedConditionEventWireTests), once | 142 passed, 1 skipped (opt-in L2 harness) |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
### Full A01–A08 run — run `fu933-2` (after review round 1)
|
||
|
||
The run was taken under the shared rig lock. The sequence was `rig.py up --run-id fu933-2 --conditions` → `seed` → 85 s →
|
||
`deploy --timeout 300` → `conditions_a3_smoke.py` (`passed: true`) → `conditions_scenarios.py` (all eight, one session)
|
||
→ `rig.py down` (exit 0, 0 run containers left, lock released). Evidence is in `artifacts/grpc-data/runs/fu933-2/evidence/`.
|
||
**8/8 PASS.**
|
||
|
||
| Scenario | Result | Checks | Notes |
|
||
|---|---|---|---|
|
||
| A01 | PASS | 13/13 | |
|
||
| A02 | PASS | 10/10 | |
|
||
| A03 | PASS | 20/20 | `p1_exactly_one_refresh_required_after_held_takeover` and `p2_refresh_required_received` pass |
|
||
| A04 | PASS | 16/16 | |
|
||
| A05 | PASS | 4/4 | The denied session still sees no imported event (removal now = admitted credential OR the current gate) |
|
||
| A06 | PASS | 11/11 | |
|
||
| A07 | PASS | 8/8 | |
|
||
| A08 | PASS | 10/10 | |
|
||
|
||
As in `fu933-1`, the live scenarios do not exercise a 20 min hold, a stream outage during a hold, a session re-activation
|
||
before a removal, or a slow metadata answer. The unit and OI tests above pin those.
|