cb672ea060
The X0 node-only harness used a GC.GetTotalMemory(true) delta, which on .NET 10 counts committed-but-free GC regions. Switched it to the L2 Measure() method (full blocking GC, HeapSizeBytes - FragmentedBytes, settled working set): 79,085 B heap / ~90 KB WS per OffNormal condition (GetTotalMemory still reads 158,169 B, reproducing the old 160,997). Plan 5.5, X0/A3/A4-docs evidence and the BytesPerCondition comment corrected; the default (160,000 B from the L2 in-server worst case) is unchanged.
752 lines
76 KiB
Markdown
752 lines
76 KiB
Markdown
# A3 evidence — consumer condition registry, visibility, event delivery (A3a) and remote methods (A3b)
|
||
|
||
Phase A3 (first half) of `docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md`, 2026-11-24, branch
|
||
`a3-consumer` (from master `83c7e586`). A3b (§5.6 remote methods: `ICallAsyncNodeManager`, claim / `base.Call` / await,
|
||
lock-freedom, `BadEventIdUnknown`, native Confirm) is a separate agent's work on top of this.
|
||
|
||
## Progress log
|
||
|
||
1. Contracts (`e15bd7c9`): `OpcUaServer/IProjectedConditionAccess.cs` — `IProjectedConditionAccess` (gate, generation,
|
||
demand), `IProjectedConditionSink` (apply / remove / stale / RefreshRequired), `ImportedConditionPlacement`,
|
||
`ImportedConditionUpdate`. SDK-free except the identity type (as `IProjectedHistoryAccess`).
|
||
2. Shared helpers (`a75ea95e`, §5.3 "one refactored helper"): `CreateConditionNode` (type, optional children before
|
||
`Create()`, child ids via `New`, initial fields) is now the body of `MaterialiseAlarmCondition` AND the imported factory;
|
||
`ApplyConditionState` (state projection + the T20/#656 delta gate) is now the body of `WriteAlarmCondition` AND the
|
||
imported apply. `ApplicationAlarmConditions.Create` accepts a null parent (an imported condition has no folder parent).
|
||
3. Registry (`1ff18caa`): `OpcUaServer/ProjectedConditionRegistry.cs` (registry class + NM partial implementing
|
||
`IProjectedConditionSink`).
|
||
4. Runtime (`4f6e26dd`): `Runtime/DataConnections/ProjectedConditionAccess.cs`.
|
||
5. Host wiring (`8d6c94a3`): DI singleton + `IProjectedConditionAccess`; `OtOpcUaServerHostedService` sets
|
||
`NodeManager.ProjectedConditionAccess` and binds the node manager as the runtime's sink; host caps
|
||
`DataConnections:MaxImportedConditionNodes` (122,500) / `MaxImportedConditionBytes` (400 MiB).
|
||
6. Tests (`de381157`, `4b74ac9c`, `855f7256`, `bdc29ac2`) and the `A3` manifest entry (`762b0fa1`).
|
||
|
||
## What is implemented (A3a)
|
||
|
||
- **Namespace + classification (§5.2 N4).** `https://zb.com/otopcua/mapped/conditions` is the node manager's FIFTH
|
||
registered namespace. `IsImportedConditionId` is asked before `RealmOf` by `Permits` (read / browse / subscribe) and by
|
||
`DataPlaneAuthorizer.TryAuthorizeMapped`, which every authorizer entry point (`Authorize`, `AuthorizeIfRequired`,
|
||
`IsAllowedCached`, the alarm-command gate, history) reaches first — so the realm a caller computed with `RealmOf` (which
|
||
folds the index into Uns) is never consulted. Imported ids: Browse / Read / CreateMonitoredItems via the condition's
|
||
mapping gate; HistoryRead, writes, Call and the alarm operations refused (Call = A3b). ⚠️ **Defect found while testing:**
|
||
`OwnsNamespace` listed only indexes 0–3, so condition children kept their ns=0 TYPE ids AND `Permits` treated an
|
||
imported id as "not ours to gate" (ungated Read). Fixed; pinned by the child-Read wire test.
|
||
- **Registry (§5.3).** Keyed by full NodeId (`c1.` + base64url JSON{ConnectionId, ConditionKey}); never `_alarmConditions` /
|
||
`_eventNotifierSources` / `_nativeAlarmNodeIds`. Conditions are parentless predefined nodes with instance-scoped children
|
||
(#629). SourceNode = ConditionId = the imported id; SourceName = primary placement path; Severity verbatim (1..1000);
|
||
ConditionName / Message / Comment / ClientUserId / ConditionClass / Quality from the record. All Part 9 methods on an
|
||
imported condition answer `BadNotSupported` before the SDK touches state (no local apply; A3b replaces this).
|
||
- **Notifier wiring (N7).** Lazy and symmetric: a placement's folder (projected folder or mapping anchor, matched on
|
||
`(mappingId, local subject)`) is wired when it is materialised — at apply time, or later from `TryEnsureProjectedVariable`
|
||
/ `TryEnsureProjectedAnchor` — with `AddNotifier` both ways + `EventNotifier |= SubscribeToEvents` + `AddRootNotifier`;
|
||
unwired (`RemoveNotifier(bidirectional)`, root notifier removed, `SubscribeToEvents` cleared when the last condition
|
||
leaves) at every projected removal site (anchor removal, capacity eviction, page removal, page rollback). A folder holding
|
||
an admitted event item is **pinned**: eviction and page removal skip it; a mapping (anchor) removal still removes it,
|
||
unwiring first. The Server object is always the delivery point (`OnConditionReportEvent`).
|
||
- **Delivery + gate (§5.4).** Delivery reuses the node manager's report walk (`ReportConditionEvent` → condition's
|
||
`OnReportEvent` → Server-object items; inverse notifiers → wired folder items), so exactly-once, the #838 deferral queue
|
||
and the #854 cuts apply unchanged. The imported branch: the mapping gate per item **regardless of `AclEnforced`**
|
||
(Server object, folder hop, refresh), cached per (identity, condition, authority generation, placement version); the
|
||
folder hop also requires the folder to be currently wired. `RaiseConditionRecord` is a no-op for imported conditions
|
||
(they are not in `_alarmConditions`), so an imported condition never re-enters the origin hub.
|
||
- **`ProjectedEventFieldList : EventFieldList` + rewriter (§5.4).** Imported events ALWAYS take the marked projected path
|
||
(`EventDeliveryCache.QueueMarked`), whatever `UseProjectedEventDelivery` says; an item the projected path cannot serve
|
||
gets nothing (fail closed, counted). The marker carries identity, condition id, generation and a re-check (live condition
|
||
∧ gate). `ProjectedNotificationRewriter.Project` now also walks `EventNotificationList`: a marked list whose re-check
|
||
fails is dropped (counted); an UNMARKED list whose `Handle` is an imported-condition snapshot (a select-clause modify
|
||
rebuilt it) is re-gated for the publishing session (identity from the Publish/Republish request header's session) and
|
||
dropped only on deny (counted); anything else passes as before (v1 messages return the same instance).
|
||
- **Event items on projected notifiers.** Admitted (instead of the mapped blanket deny, which still applies to data items)
|
||
when the caller passes the gate of at least one condition wired at that folder; delivery and publish re-check per event.
|
||
- **Demand / barrier / budget (§5.5)** in `ProjectedConditionAccess`: the first admitted Server-object or projected-notifier
|
||
event item opens, per condition-bearing connection (mapping enabled ∧ Subscribe ∧ AlarmSubscribe), ONE stream under the
|
||
connection's service principal with one root-scoped item per mapping (Raw first, then mapping id ordinal); all close
|
||
together after the last item plus a 30 s linger (and the linger removes what they materialised). Snapshot begin
|
||
`total > MaxConditions` ⇒ `ConditionCapacity`, the item is REMOVED (`RemoveSubscriptionItems`), counted
|
||
(`otopcua.dataconn.conditions.capacity_rejections`); host caps (`total × 49` nodes, `total × 160,997` bytes) reject the
|
||
mappings that would cross them, in deployed order; 80% warning. Nothing is materialised until every mapping completed or
|
||
`ConditionSnapshotTimeoutMilliseconds` expired (incomplete ⇒ `Unavailable`, the rest proceed, then `RefreshRequired`).
|
||
Conditions never consume `MaxProjectionNodes`.
|
||
- **Version rule (A2 N2).** Per key per epoch; `removed` and snapshot begin bypass; a removal is applied unconditionally and
|
||
forgets the key's version.
|
||
- **Lifetime rule (A2 S1).** A stream end is re-snapshot, never removal; staleness after `ConditionStaleTimeoutMilliseconds`
|
||
⇒ `MarkConnectionStale` (Quality `BadNoCommunication` through the shared delta gate: one event each, Active/Acked
|
||
unchanged). Only a COMPLETE re-snapshot that no longer lists a key removes it (an incomplete mapping removes nothing).
|
||
T2: a `state_known = false` record never changes state; a never-known condition is `UncertainInitialValue`.
|
||
- **Primary placement / SourceName (§5.2).** From deployed config only: Raw mappings before UNS, mapping id ordinal,
|
||
placement address ordinal. SourceName = `<anchor local subject>/<placement address relative to the remote root>` (root
|
||
subject learned once per stream with `GetMetadataAsync`). ConditionId depends on (connection, key) only (N4): disabling
|
||
the primary mapping moves notifiers and SourceName, nothing else.
|
||
- **EventId re-binding seam (N6) for A3b.** `ReportImported` records each consumer-minted EventId with the activation marker
|
||
it described (32 per condition); `OtOpcUaNodeManager.TryResolveImportedEvent(conditionId, eventId, out
|
||
ImportedConditionBinding)` returns connection, condition_key, primary placement, all placements, activation marker,
|
||
native flag — everything §5.6 dispatch needs.
|
||
- **RefreshRequired.** `IProjectedConditionSink.RequireRefresh` queues `RefreshRequiredEventType` to every Server-object and
|
||
wired-folder item that may see a condition of the connection.
|
||
- **ConditionRefresh.** Imported conditions are excluded from the local replay paths (plain + cut, Server object + direct)
|
||
and replayed once by `ReplayImportedConditions` through the gated marked path, ACLs on or off.
|
||
- **§5.7.** No `alerts` publication / no consumer alarm history (imported conditions are not in `_alarmConditions`, the
|
||
condition-state sink never sees them, they are not fed to `NativeAlarmProjector`), no local shelving timers
|
||
(`OnTimedUnshelve` no-op, shelve refused).
|
||
|
||
## Tests
|
||
|
||
| Project | Class | What |
|
||
|---|---|---|
|
||
| OI | `ImportedConditionEventWireTests` (7, Phase=A3) | real SDK server + real client sessions: exactly one event per transition at a projected device folder, the mapping anchor (second placement) and `i=2253`, after a sentinel; §5.2 identity fields (SourceNode = ConditionId = `c1.` id in mapped/conditions, SourceName, Severity 777 verbatim, ConditionName); **A3-SEC** with ACLs off (no grant ⇒ folder item refused, zero events live and on ConditionRefresh, positive control + RefreshEnd sentinel; a revocation drops a queued event at publish); child Read authorized through the condition (granted Good / ungranted `BadUserAccessDenied`), Acknowledge refused and unapplied; disabling the primary mapping keeps the ConditionId and the instance (notifiers + SourceName move), a later mapping changes no NodeId; folder with an event item not retired, retirement unwires; resync of unchanged state reports nothing, then a must-arrive transition exactly once; staleness = one `BadNoCommunication` event per condition, still Active, unknown records change nothing, never-known = Uncertain |
|
||
| Runtime | `GrpcDataProjectedConditionAccessTests` (8, Phase=A3) | scripted origin stream: `total > MaxConditions` ⇒ `ConditionCapacity` + item removed before anything materialises, other mapping unaffected; 2,000 conditions with `MaxProjectionNodes = 10`; host node cap rejects at begin; version gate, removal bypass + forgotten version; stream end ⇒ no removal, staleness, complete re-snapshot removes only the missing key, incomplete removes nothing; snapshot timeout ⇒ Unavailable + RefreshRequired; primary placement Raw-first/ordinal independent of stream order + SourceName + folder subject; the gate with a REAL `DataOperationPolicy` (Subscribe grant on the folder scope; not AlarmRead; mapping needs AlarmSubscribe); demand opens, linger closes and removes |
|
||
| OpcUaServer | `ImportedConditionClassifierTests` (4, Phase=A3) | **guard test**: a condition-namespace id fed to `Authorize` / `AuthorizeIfRequired` / `IsAllowedCached` / `TryAuthorizeMapped` × {Raw, Uns} × {Read, Browse, HistoryRead, Call, CreateMonitoredItems, AlarmAcknowledge}, ACL on and off, under a Cluster-wide grant — the classifier is asked every time (48), never the realm walk; positive control on a Raw id; the node manager's classifier: Read/Subscribe through the condition, HistoryRead/Call/Ack refused, invisible ⇒ denied despite the Cluster grant; rewriter drops failed / throwing markers, re-gates unmarked, empties payloads, passes v1 messages through as the same instance |
|
||
| Host | `GrpcDataV1CompatibilityTests.A3_consumer_condition_shapes_…` (Phase=A3) | recorded-v1-client gate: the fake origin now also emits begin+`total`, an info/placement record + `snapshot_complete`, a `removed` delta; header-less (scoped or not) still the golden bytes; negotiated decodes all three. `git diff master -- '*Goldens.cs'` empty |
|
||
|
||
**Mutation record (A3-SEC, OI).** Removing only the Server-object delivery gate leaves A3-SEC green: the publish-time
|
||
marker re-check drops the event (the second layer works). Removing the delivery gate AND making the marker re-check
|
||
`true` turns it red (`deniedEvents … Count` 1). Both layers are real; no single-layer test isolates the delivery gate.
|
||
|
||
## Deviations / decisions (no questions asked; reasoning recorded)
|
||
|
||
1. **Delivery reuses the node manager's report walk** instead of a separate fan-out: imported conditions are not in the
|
||
realm-keyed maps (as the plan requires), but `ReportConditionEvent`/`DeliverConditionEventAsync`/`OnConditionReportEvent`/
|
||
`DeliverToNotifierItems`/`QueueToItem` gained an imported branch. This keeps exactly-once, #838/#854/#855 semantics
|
||
without a second implementation.
|
||
2. **Demand is global, not "per connection the caller could see"**: the first admitted event item opens every
|
||
condition-bearing connection. The per-event gate still decides visibility; the cost is opening streams a caller might not
|
||
see. Simpler and fail-safe; A4 diagnostics can reconsider.
|
||
3. **Folder event-item admission** uses the imported gate of a condition wired at that folder (not the folder's mapped
|
||
Browse proof). A folder is a notifier only while a condition is wired there (N7), so a folder-only client cannot open
|
||
demand by itself — a Server-object item (or an already-wired folder) is needed. Recorded for A4.
|
||
4. **RefreshRequired** is sent on an INCOMPLETE barrier (snapshot timeout); "a ConditionRefresh before the barrier ⇒
|
||
RefreshRequired when it completes" is not tracked separately (the timeout path covers incomplete resyncs). An UNMARKED
|
||
list dropped by the rewriter is counted but the item does NOT get a RefreshRequired (the rewriter has no item handle) —
|
||
follow-up for A3b/A4.
|
||
5. **Verdict cache** keys on `AuthorityGeneration` = (mapping-set version ≪ 32) ⊕ the policy's authority epoch, plus the
|
||
condition's placement version; the policy's own decision cache sits under it. Bounded (65,536 entries, then cleared).
|
||
6. **Removal of an imported condition emits no event** (no NodeDeleted model change for the condition namespace); clients
|
||
key on ConditionId and see it no longer refreshed. The linger close removes materialised conditions (no stale state left
|
||
when no one watches).
|
||
7. **Root-leaf replacement** of a mapping anchor (`TryApplyRootLeaf`) does not unwire an imported condition wired at that
|
||
anchor (a root-leaf mapping is a variable root; conditions there have a folder parent elsewhere). Edge case, recorded.
|
||
8. **ConditionRefresh replay of imported conditions** runs under one `Lock` hold (consistent with the synchronous events it
|
||
races); at the host cap (2,500 conditions) × items this is the longest hold A3a adds — L2/L3 live measurements should
|
||
include it. Apply is chunked at 128 updates per hold; the folder index is one scan of projected nodes per apply batch.
|
||
9. **Primary endpoint** for condition items (A2 N7: a Secondary advertises but refuses) is left to the connection source's
|
||
existing endpoint selection; a Secondary answers the item `Unavailable`, the mapping is `Unavailable` and retried on the
|
||
next stream. A3b/A4 should prefer the Primary explicitly.
|
||
10. **A3 OI tests** run outside the unit-phase runner (it accepts unit projects only), as for H1/H3.
|
||
|
||
## Gates
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A3` (Runtime + OpcUaServer + Host) | passed (`20261124T214213…`) |
|
||
| `run-unit-phase.py A2` | passed |
|
||
| `run-unit-phase.py A1`, `X0` | passed, passed |
|
||
| Host.Tests DataConnections (both v1 gates) | 207 passed |
|
||
| OI `ImportedConditionEventWireTests` | 7 passed |
|
||
| OpcUaServer.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 1455 passed, 1 skipped |
|
||
| Runtime.Tests full (same filter) | 2030 passed, 3 skipped (no #920 rerun needed) |
|
||
| OI `Feature=GrpcData` + ConditionMethodEvent / NativeAlarmEventIdentityFieldDelivery / FolderConditionRefresh / ConditionRefreshDeferral | 116 passed |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
Live rig: not run for A3a (no consumer-side condition demand exists until a client subscribes, and A3b + the exit gate
|
||
own the live leg); the unit + OI wire tests above use a real SDK server and real client sessions.
|
||
|
||
## Left for A3b
|
||
|
||
- §5.6: `ICallAsyncNodeManager` on the node manager (claim / `base.Call` / await, never under `Lock`), dispatch through
|
||
`TryResolveImportedEvent` → `IDataConditionMethodService` on the connection, no local apply before the origin record,
|
||
unknown EventId ⇒ `BadEventIdUnknown` unsent, native Confirm ⇒ `BadNotSupported` unsent, lock-freedom (L3), binding the
|
||
mapping's `ConditionMethodTimeoutMilliseconds`. Today every Part 9 method on an imported condition is refused
|
||
(`BadNotSupported` handlers; the classifier also refuses `Call` / alarm operations).
|
||
- RefreshRequired to an item whose UNMARKED list the rewriter dropped (deviation 4); explicit Primary endpoint for
|
||
condition items (deviation 9); the mapping-change runner hand-over (an old runner's in-flight batch can still reach the
|
||
sink until its cancellation is observed — bounded by one frame).
|
||
|
||
---
|
||
|
||
# A3 — PART 2 (A3b): methods on imported conditions, no `Lock` waits; A3 exit (L2, L3, live)
|
||
|
||
2026-11-24, branch `a3-consumer`, on top of A3a (`b5ab6e7c`). Not merged, not pushed.
|
||
|
||
## Progress log
|
||
|
||
1. `c1be5725` NM: `ICallAsyncNodeManager` (`OpcUaServer/ImportedConditionMethods.cs`), EventId registry gate, N6 re-binding.
|
||
2. `28098a8d` Runtime/Host: `ProjectedConditionAccess : IProjectedConditionMethods` (`ProjectedConditionAccess.Methods.cs`), the
|
||
runner's stream serving identity, `DataConnectionDeploymentLease : IDataConditionMethodService`, host wiring.
|
||
3. `de51886d` OI wire tests; `2d0147f9` Runtime tests + `A3` manifest; `fecb178e` L2 harness + byte cap.
|
||
4. `4e6535ee` live smoke (`conditions_a3_smoke.py`, seeder conditions profile makes the CONSUMER condition-bearing).
|
||
5. Live `a3b-cond-1` / `-2` FAILED and found two A3a integration defects, fixed in `404a664c` (logger) and `82ecc116` (root view);
|
||
live `a3b-cond-3` PASS.
|
||
|
||
## What is implemented (A3b, plan §5.6)
|
||
|
||
- **Interception (step 1).** Verified against the pinned SDK 2.0.1 (ilspy): `CustomNodeManager2` has a public virtual
|
||
`CallAsync(OperationContext, ArrayOf<CallMethodRequest>, IList<CallMethodResult>, IList<ServiceResult>, CancellationToken)` but
|
||
does NOT declare `ICallAsyncNodeManager`, so `AsyncNodeManagerAdapter.CallAsync` ran the synchronous `Call`. NM now declares
|
||
`ICallAsyncNodeManager` and overrides `CallAsync`: (a) claims every unprocessed request whose ObjectId is in the
|
||
`mapped/conditions` namespace — a namespace-index test, **no lock at all** — and marks it `Processed`; (b) calls
|
||
`base.Call(...)` unchanged (it skips the claimed ones; local behaviour incl. `ReportAfterMethod` under `Lock` is unchanged),
|
||
completed before any remote await; (c) runs the claimed calls concurrently and awaits them. No `Lock` is held at any point;
|
||
the SDK pre-validation `FindMethodState` takes `Lock` only for its lookup (plan's residual).
|
||
- **Local checks (step 2), no I/O, no NM `Lock`:** condition resolved from the ObjectId (`TryParse`, lock-free registry
|
||
`Find`) else `BadNodeIdUnknown`; method from the MethodId — the type declarations (`AcknowledgeableConditionType_Acknowledge`
|
||
/ `_Confirm`, `ConditionType_AddComment`) or this condition's instance child (`c1.…/Acknowledge` etc.); anything else
|
||
(shelve, enable/disable) `BadNotSupported`; no port ⇒ `BadNotSupported`; **per-caller mapping gate**
|
||
`IProjectedConditionMethods.AuthorizeMethod(local caller, placements, method)` ⇒ `BadUserAccessDenied` unsent; native
|
||
Confirm ⇒ `BadNotSupported`; the origin's `supported_methods` (kept from the listing) lacks the method ⇒ `BadNotSupported`;
|
||
Warm Standby ⇒ the standby refusal; argument shape (`BadArgumentsMissing` / `BadTooManyArguments` / `BadTypeMismatch`);
|
||
**EventId**: must be one this consumer minted for that condition AND bound to the CURRENT marker, else `BadEventIdUnknown`
|
||
unsent. The EventId registry (`RecentEvents`, 32 per condition) and `Activation` are now read/written under a per-condition
|
||
`MethodGate` (the plan's "small registry with its own lock"); `TryResolveImportedEvent` also uses it instead of `Lock`.
|
||
- **The gate** (`ProjectedConditionAccess.AuthorizeMethod`, real `DataOperationPolicy`): for a placement in primary order whose
|
||
mapping is current, condition-bearing, of the placement's realm and itself grants the method's bit (AlarmAcknowledge for
|
||
Acknowledge/AddComment, AlarmConfirm for Confirm): `AuthorizeLocal(caller, AlarmAcknowledge|AlarmConfirm, folder scope)`,
|
||
which re-checks the caller's key (#563); regardless of `Security:Acl:Enabled` (as the A3a visibility gate). Returns the
|
||
placement to dispatch through and that mapping's `ConditionMethodTimeoutMilliseconds`.
|
||
- **Dispatch (steps 4–5).** Bounded by a per-node semaphore (8; waiting counts against the budget, exhausted ⇒
|
||
`BadTooManyOperations` unsent). Budget = min(request `OperationDeadline`, the mapping's method timeout). A fresh operation id
|
||
(`a3-<guid>`) per dispatch; **an identical call already in flight** (same caller, condition, EventId, method, comment) **joins**
|
||
it — one dispatch, the same answer. The port call is bounded by budget + 250 ms (`WaitAsync` + `CancelAfter`). The Runtime
|
||
addresses the origin with the placement, `expected_activation` = the latest applied marker, `expected_serving_incarnation` =
|
||
the serving identity of the CURRENT condition stream (`IDataSubscriptionProvenance`), `on_behalf_of` = the local principal,
|
||
through the deployed lease (`DataConnectionDeploymentLease` now implements `IDataConditionMethodService`: the row's
|
||
AlarmAcknowledge/AlarmConfirm bit else `UnauthorizedAccessException` ⇒ `BadUserAccessDenied`, unsent). No open condition stream
|
||
(connection down / never opened) ⇒ `BadNoCommunication`, nothing leased or sent.
|
||
- **No local apply.** Imported conditions keep their A3a `BadNotSupported` SDK handlers; nothing in the claimed path touches
|
||
node state. The node changes only when the origin's record arrives on the condition stream.
|
||
- **Outcome mapping (documented choice).** `DriverConfirmedSuccess` (scripted) / `AcceptedUnconfirmed` (native) ⇒ `Good` (the
|
||
client may see Good before the confirming event); `RejectedBeforeDispatch` ⇒ the origin's status (+ its diagnostic);
|
||
**`OutcomeUnknown` ⇒ `BadTimeout` when the budget elapsed, otherwise `BadCommunicationError`**, always with
|
||
"OutcomeUnknown: …" in the diagnostic and a Warning log. Chosen over an Uncertain code: Part 4 gives a Call result no
|
||
"maybe applied" Uncertain meaning, and an Uncertain-family status reads as success to most clients; a Bad status plus the
|
||
confirming (or absent) condition event is the honest answer. Never retried.
|
||
- **N6 re-binding** (`RebindImportedEventIds`). After a record that changed no state: a moved marker re-binds retained EventIds
|
||
only when the record's `time` equals the time they were bound under (F6); otherwise a fresh EventId bound to the new marker is
|
||
stamped on the node (what a ConditionRefresh now returns) and `RequireRefresh(connection)` is queued after the apply
|
||
(outside `Lock`). A condition whose first record reported no event gets one bound EventId.
|
||
|
||
## A3a defects found by the live gate (fixed)
|
||
|
||
1. **`ProjectedConditionAccess` logged to `NullLogger` in production** (DI passed no logger): the first live failure
|
||
(`a3b-cond-1`, nothing imported) left no trace. Now the host logger; plus Information logs for stream open (serving), a
|
||
refused item (Warning, status + diagnostic) and each snapshot barrier (statuses, record count, timeout).
|
||
2. **The UNS root item was refused `Denied`** (`a3b-cond-2`: `map-uns item refused by the origin (Denied)`, `map-raw` Complete,
|
||
0 records). The item view was built from the anchor address with subject = the address identifier (an opaque EquipmentId);
|
||
the origin requires its own subject (`area/line/plc`). Now metadata is asked exactly as `RemoteNamespaceResolver` asks it
|
||
(subject = `RemoteRootEntityId`) and the item carries the origin's canonical view from the metadata answer. Pinned by
|
||
`The_condition_item_carries_the_origins_canonical_root_view_learned_from_metadata` (red with the item view reverted).
|
||
The A3a unit tests could not see either: their fake origin accepted any view.
|
||
|
||
## Tests (A3b)
|
||
|
||
| Project | Class | What |
|
||
|---|---|---|
|
||
| OI | `ImportedConditionMethodWireTests` (7, Phase=A3) | real SDK server + client sessions; the port fakes the origin: **once + join** (duplicate in-flight call joins, one dispatch, both Good; still unacked until the origin record; record ⇒ acked; a later call = new dispatch, fresh op id); **child Call** via the instance method id, denied caller `BadUserAccessDenied` unsent, re-gated per local caller, Acknowledge grant ≠ Confirm; **unknown / superseded EventId** `BadEventIdUnknown`, native Confirm + OneShotShelve `BadNotSupported`, all unsent, positive control carries the current marker; **N6** same-time resync re-binds, other-time resync ⇒ old EventId unknown + fresh ackable EventId; **L3 lock-freedom**; **mixed batch** (local native Ack through `base.Call` = Good + routed once + one local ack event, imported Ack dispatched, imported unchanged); **timeout** (300 ms mapping timeout ⇒ `BadTimeout` < 3 s, port cancelled, one dispatch), OutcomeUnknown ⇒ `BadCommunicationError`, refusal statuses passed through (`BadInvalidState`, `BadNoCommunication`), nothing applied |
|
||
| Runtime | `GrpcDataProjectedConditionMethodTests` (5, Phase=A3, manifest `A3`) | gate with a real `DataOperationPolicy` (AlarmAcknowledge ⇒ Ack/AddComment not Confirm; Subscribe-only ⇒ denied; mapping lacking the bit ⇒ denied; mapping timeout 4321 ms carried; unknown mapping/caller/null denied); no open stream ⇒ `BadNoCommunication`, never leased, nothing sent; call carries the stream's serving incarnation, placement, marker, op id, budget, on-behalf-of; OutcomeUnknown passed through; connection down after a stream end ⇒ `BadNoCommunication`, nothing sent; lease refusal ⇒ `BadUserAccessDenied` unsent; canonical root view |
|
||
| OI | `ImportedConditionMemoryMeasurementTests` (opt-in `OTOPCUA_A3_L2=1`, Category=Perf) | L2 harness |
|
||
|
||
OI suites run outside the unit-phase runner (it accepts unit projects only), as for A3a.
|
||
|
||
**Red-on-revert (each mutation built, run, restored; `git status` clean after):**
|
||
|
||
| Mutation | Test | Result |
|
||
|---|---|---|
|
||
| M1: port call waited synchronously under `lock (Lock)` | L3 lock-freedom | **red** (the first Read/Browse waited out the 5 s stall: `ack.IsCompleted` already true) |
|
||
| M2: in-flight join disabled | once + join | **red** (joined count never 1) |
|
||
| M3: `AuthorizeMethod` verdict ignored | child Call gate | **red** (denied caller got Good) |
|
||
| M4: EventId marker check ignored | unknown/superseded EventId | **red** (superseded EventId accepted) |
|
||
| M5: mapping timeout ignored (30 s budget) | timeout | **red** (elapsed > 3 s) |
|
||
| M6: N6 re-bind disabled | re-binding | **red** (same-time resync EventId refused) |
|
||
| M7: `base.Call` skipped when anything is claimed | mixed batch | **red** (local Ack not Good) |
|
||
| R1: no-stream check removed (Runtime) | connection down | **red** |
|
||
| R2: mapping-bit check removed (Runtime) | gate | **red** |
|
||
| R3: item view reverted to the address-only view | canonical root view | **red** |
|
||
| native-Confirm check removed (not run) | — | expected **masked**: `supported_methods` of a native condition (Native = 3) lacks Confirm, a second layer refusing the same call `BadNotSupported` unsent |
|
||
|
||
## L3 — lock-freedom (§9.3, hard gate) — PASS
|
||
|
||
Measured by the OI wire test (in-process, real SDK server; the origin's method handler is stalled 5 s at the consumer's
|
||
`IProjectedConditionMethods` port — the consumer-side boundary, below which everything is the remote origin). 10 rounds of
|
||
concurrent Read (raw variable), Browse (Plant folder) and a data Publish (value write → client notification, publishing interval
|
||
20 ms) while the call is in flight, plus `Monitor.TryEnter(Lock)` from the test thread; `AckedState` asserted false after every
|
||
round; the origin record applied after release flips it (positive control). Three runs:
|
||
|
||
| Run | Stall | Read max | Browse max | Data Publish max | `Lock` acquire max | Baseline (no stall) read / browse / publish |
|
||
|---|---|---|---|---|---|---|
|
||
| 1 | 5003 ms | 1.8 ms | 1.2 ms | 99.7 ms | 0.01 ms | 1.3 / 5.0 / 105.8 ms |
|
||
| 2 | 5003 ms | 1.9 ms | 6.3 ms | 98.6 ms | 0.01 ms | 1.3 / 4.6 / 107.7 ms |
|
||
| 3 | 5002 ms | 2.6 ms | 1.1 ms | 99.7 ms | 0.01 ms | 1.2 / 5.4 / 105.9 ms |
|
||
|
||
All < 200 ms. The ~100 ms publish figure is the server's minimum publishing interval (identical without a stall), not a delay.
|
||
Deviation: the plan lists L3 as a docker-dev measurement; the live rig has no hook to stall the origin's handler, so the gate is
|
||
this deterministic in-process measurement (its mutation M1 proves it detects a `Lock` wait).
|
||
|
||
## L2 — consumer memory, 1,000 imported conditions in one mapping (§9.3) — PASS
|
||
|
||
In-process harness (`ImportedConditionMemoryMeasurementTests`, opt-in): a running SDK server, 1,000 conditions materialised through
|
||
the real `IProjectedConditionSink` (nodes + instance-scoped children, ids, registry + folder/notifier indexes, one more transition
|
||
each so every N6 EventId slot is used, the verdict cache exercised once per condition) plus the update records the runtime keeps per
|
||
key. Forced compacting GCs before/after. Three runs:
|
||
|
||
| Run | Working-set growth | Managed heap growth | per condition (heap) | materialise / transition |
|
||
|---|---|---|---|---|
|
||
| 1 | +107.1 MiB | +197.4 MiB | 207,036 B | 605 / 80 ms |
|
||
| 2 | +106.2 MiB | +197.4 MiB | 207,029 B | 704 / 91 ms |
|
||
| 3 | +112.2 MiB | +197.4 MiB | 207,029 B | 747 / 77 ms |
|
||
| 4 (after-materialise split) | +106.8 MiB | +196.1 MiB | 205,665 B (204,612 after materialise alone) | 602 / 83 ms |
|
||
|
||
Working-set growth ≤ 200 MiB: **PASS** (the heap grows more than the working set because the process had already committed GC
|
||
regions at baseline). Per the plan, `MaxImportedConditionBytes` is now set from the measurement: `BytesPerCondition` 160,997 →
|
||
**205,665** (the managed-heap figure, the larger of the two) and the default `DataConnections:MaxImportedConditionBytes` =
|
||
205,665 × 2,500 = **514,162,500 B (≈ 490 MiB)** (was 400 MiB). `MaxConditions` (1,000 per mapping) needs no lowering.
|
||
Nearly all of it is the SDK condition node + children (X0's node-only figure was 160,997); the A3b EventId registry adds ~1 KB.
|
||
(Superseded: these figures and X0's were `GC.GetTotalMemory` deltas — see round 2's L2 below and #929, which re-measured the
|
||
node-only retained heap at 79,085 B.)
|
||
|
||
## Live — run `a3b-cond-3` (build `82ecc116`, clean tree) — PASS
|
||
|
||
```bash
|
||
python3 scripts/validation/grpc-data/rig.py up --run-id a3b-cond-3 --conditions --timeout 1200
|
||
python3 scripts/validation/grpc-data/rig.py seed --run-id a3b-cond-3
|
||
# ~90 s for CONTROL's ClusterNode contact refresh
|
||
python3 scripts/validation/grpc-data/rig.py deploy --run-id a3b-cond-3 --timeout 300
|
||
python3 scripts/validation/grpc-data/conditions_a3_smoke.py --run-id a3b-cond-3
|
||
python3 scripts/validation/grpc-data/rig.py down --run-id a3b-cond-3
|
||
```
|
||
|
||
The conditions profile now also makes the CONSUMER condition-bearing (connection + both mappings carry 64|128|256; ConfigDb
|
||
showed 479 on both). `conditions_a3_smoke.py` raises ScalarHigh, runs CLI `alarms --refresh` on the SOURCE Primary (origin's own
|
||
subscriber) and the CONSUMER Primary, acks through the consumer with CLI `ack`, then clears.
|
||
|
||
| Item | Observed | Result |
|
||
|---|---|---|
|
||
| Consumer import | `stream 1 … opened (2 mapping(s), serving source-1:4053)`; barrier `map-raw=Complete, map-uns=Complete; 1 record(s)`; consumer CLI shows ScalarHigh Active/Unacknowledged with ConditionNodeId `ns=6;s=c1.…` (mapped/conditions) and a consumer EventId | PASS |
|
||
| Bogus EventId via the consumer | `Acknowledge failed: BadEventIdUnknown [0x809A0000]`; origin shows no ack | PASS |
|
||
| Ack via the consumer (CLI `ack`) | `Acknowledge successful` in 580 ms | PASS |
|
||
| Origin audit (source-1) | `Data-connection condition method Acknowledge by fixture-consumer (key …) on Uns:…:source-scalar-high op a3-1eabf280…: DriverConfirmedSuccess 0x00000000; on behalf of fixture-cli` — the service principal, the consumer's fresh op id, the local caller as on-behalf-of | PASS |
|
||
| Origin's own subscriber | ScalarHigh: Active/Unacknowledged, **exactly one Active/Acknowledged** | PASS |
|
||
| Consumer subscriber | Active/Unacknowledged, **exactly one Active/Acknowledged** (the origin's record re-imported) | PASS |
|
||
| Teardown | no run-labelled containers / networks left | — |
|
||
|
||
Failed attempts (history): `a3b-cond-1` — nothing imported, no log (A3a defect 1); `a3b-cond-2` — map-uns Denied (A3a defect 2).
|
||
Each fix changed the image inputs, so each run was torn down and a fresh run id brought up.
|
||
|
||
## Deviations / decisions (A3b)
|
||
|
||
1. **EventIds retained: 32** (A3a's `RecentEventIds`), not the plan's "last N (default 8)"; validity is "minted for this condition
|
||
under the current marker", as §5.6 step 3 specifies.
|
||
2. **Consumer-side join of identical in-flight calls** (the brief's "duplicate call joins"): each dispatch has a fresh operation id
|
||
(the origin's own registry joins duplicates of an id); two identical local calls in flight share one dispatch. A repeat after
|
||
completion is a new dispatch (no retry, no stale join).
|
||
3. **Dispatch placement** = the first placement (primary order) the CALLER passes the method gate on, not unconditionally the
|
||
primary placement: a caller authorized only via a second mapping is addressed through that mapping's placement.
|
||
4. **`expected_serving_incarnation`** = the serving identity of the condition stream the records arrived on (no stream ⇒
|
||
`BadNoCommunication`, unsent). A stream that does not expose provenance cannot be called through (production streams do).
|
||
5. **OutcomeUnknown ⇒ Bad** (`BadTimeout` / `BadCommunicationError`), see "Outcome mapping".
|
||
6. **The node manager enforces the mapping timeout itself** (budget + 250 ms grace around the port), so a port that never answers
|
||
cannot hold a request past it; the Runtime passes the budget to `GrpcDataConnection`, whose own ceiling still applies.
|
||
7. **L3 measured in-process** (see L3). **L2 measured in-process** (allowed by the brief).
|
||
8. Defaults changed at the A3 exit: `BytesPerCondition` 205,665, `MaxImportedConditionBytes` ≈ 490 MiB (L2).
|
||
9. Two A3a files were edited beyond A3b's seams because the live gate required it: the ProjectedConditionAccess DI logger and the
|
||
condition item root view (defects above); plus the per-condition `MethodGate` and N6 re-binding hook in `ApplyImported` /
|
||
`ReportImported` / `TryResolveImportedEvent`.
|
||
|
||
## Open / follow-ups
|
||
|
||
- RefreshRequired after an un-re-bindable resync goes to every item that may see the connection's conditions (A3a's
|
||
`RequireRefresh`), not only the affected mapping's notifiers.
|
||
- The A3a deviation 9 (explicit Primary endpoint for condition items) is still open; the live run happened to stream from the
|
||
Primary (source-1).
|
||
|
||
## Gates (A3b, at `82ecc116`)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A3` (Runtime + OpcUaServer + Host) | passed (`20261124T225624…`) |
|
||
| `run-unit-phase.py A2` | passed (`20261124T225724…`) |
|
||
| `run-unit-phase.py A1` | passed (`20261124T225845…`) |
|
||
| `run-unit-phase.py X0` | passed (`20261124T230234…`) |
|
||
| Host.Tests `.DataConnections.` (both v1 gates) | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2035 passed, 3 skipped (no #920 rerun needed) |
|
||
| OpcUaServer.Tests full (same filter) | 1455 passed, 1 skipped |
|
||
| OI `Feature=GrpcData` + ConditionMethodEvent / NativeAlarmEventIdentityFieldDelivery / FolderConditionRefresh / ConditionRefreshDeferral | 123 passed, 1 skipped (the opt-in L2 harness) |
|
||
| OI `ImportedConditionMethodWireTests` ×3 | 7/7 each |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
| Live `a3b-cond-3` | PASS (above) |
|
||
|
||
---
|
||
|
||
# A3 — Review round 1 (A3a adversarial review, `a3a-review-round1.md`, written against `b5ab6e7c`)
|
||
|
||
2026-11-24, branch `a3-consumer`, on top of A3b (`3c941458`). Not merged, not pushed. Commits: `69aeeb77` (runner + NM fixes,
|
||
Runtime tests), `14343bf0` (folder promotion for folder-only demand, NM tests).
|
||
|
||
"Red on revert": the test was run with the fix removed (Runtime: the whole HEAD runner restored with interface stubs; NM: the
|
||
single fix line(s) removed by a scripted mutation) and failed; the fix was then restored and the test passed.
|
||
|
||
| Finding | Resolution | Test(s) | Red on revert |
|
||
|---|---|---|---|
|
||
| **B1** in-stream re-snapshot removes conditions | `ProjectedConditionAccess.Runner.cs`: a begin opens a per-mapping `Buffer`; snapshot records fill it; the committed `Live` set (and every node) is untouched until `snapshot_complete`, which swaps and re-merges old ∪ new keys — only a key the complete set no longer lists (and no other mapping lists) is removed. Deltas apply to `Live` and the buffer. An in-stream capacity refusal removes the mapping's keys once (keys another mapping lists survive) and requires refresh | `B1_an_in_stream_multi_frame_re_snapshot…` (begin + 2 record frames + positive control on map-b, then complete); `B1_an_in_stream_re_snapshot_over_capacity…` | yes / yes (refresh assertion; the removal shape itself was already right) |
|
||
| **B2** timed-out / non-Good mapping frozen Good | frames of a timed-out mapping keep being processed: a late `snapshot_complete` swaps in and re-runs the merge (full re-diff); at an incomplete barrier the keys no contributing mapping lists are `MarkConditionsStale` (new sink method, `BadNoCommunication`, one event each, never removed); after the barrier a still-`Unavailable` mapping ends the stream after a bounded wait (`ConditionSnapshotTimeout` × 1,2,4,8 backoff), cancelled by a late completion | `B2_a_snapshot_completing_after_the_timeout…`; `B2_an_incomplete_barrier_marks…`; `B2_S7_a_refused_item…` (new stream within 5 s) | yes / yes / yes |
|
||
| **Deviation 9** Primary endpoint | new `IDataPrimarySubscriptionSource.SubscribePrimaryAsync` (Abstractions) on `GrpcDataConnection` (skips a non-Primary endpoint; a role-only miss is not a discovery failure, no probe backoff) and the deployment lease; the runner uses it and also drops any stream whose provenance role is not Primary | `Deviation9_a_condition_stream_served_by_a_Secondary…` | yes (hangs: the old runner keeps the Secondary stream) |
|
||
| **B3** revalidation stands down folder items; demand leak | `RevalidateEventItems` asks `ImportedNotifierAdmits` for a projected notifier; the unsubscribe arm releases demand before both early returns; `_authorizer?.LogFiltered` (a rig without an authorizer NRE'd once an item was stood down) | `B3_revalidation_keeps_an_admitted_folder_item_and_deleting_a_stood_down_item_releases_its_demand` (real `RevalidateMonitoredItems()`, lease counter) | yes (revalidation mutation) / yes (demand-order mutation) |
|
||
| **B4** host caps per connection / order / trust `total` | one node-wide `ConditionLedger`: connection charge = max(materialised keys, Σ mapping claims); a claim is the admitted `total` while snapshotting, the record count after (growth is charged); admission is against everything charged or claimed, order-independent. Records past `total`, `Live` past `MaxConditions`, or growth past the node caps ⇒ `ConditionCapacity` (item removed, keys removed, refresh). `ChargedConditions` observation | `B4_the_host_caps_are_node_wide_across_connections`; `B4_admission_is_order_independent…`; `B4_records_past_the_snapshot_total…`; `B4_post_snapshot_delta_growth…` | yes ×4 |
|
||
| **S1** rebuild leaves stale wiring | `RebuildAddressSpace` calls `UnwireAllImportedFolders()` before clearing; `WiredByFolder` keeps the promoted folder INSTANCE — a re-created folder with the same NodeId unwires the dead instance and is promoted afresh | `S1_a_full_rebuild_unwires_and_the_re_created_folder_is_promoted_and_delivers_again` | yes (rebuild-unwire removed), yes (both removed) |
|
||
| **S2** verdict cache outlives expiry / IsActive | `Verdict` stores `ValidUntil` = min(credential expiry, now + 5 s) for a positive verdict; `AuthorityGeneration` folds every current mapping's `Authority.IsActive` | `S2_a_cached_positive_verdict_is_re_proved…` (OpcUaServer.Tests); `S2_an_authority_deactivation_moves_the_authority_generation…` (Runtime) | yes / yes (by construction: the old formula ignores IsActive) |
|
||
| **S3** removal races a new runner | a new runner of a connection awaits its predecessor's `Stopped` (loop end + removal) before opening a stream; stopped runners are kept per connection in `_stopping` | `S3_a_new_runner_waits_for_the_old_runners_removal…` (the sink holds the old removal open 400 ms) | yes |
|
||
| **S4** `TakeMaterialised` cross-thread | the materialised set is handed over inside the new runner's loop after the predecessor stopped (no concurrent mutation, no orphaned key) | `S4_a_mapping_change_hands_the_materialised_set_over…` | **no** — the race window is one in-flight frame; the test pins the hand-over, it cannot force the interleaving |
|
||
| **S5** Lock-hold bounds | `ProjectedFolderIndex()` scan replaced by the incremental `FolderIds`/`FolderKeys` index (maintained in `OnProjectedFolderMaterialised`/`Removing`, cleared on rebuild, resolved against the live projected maps); refresh targets gathered 128 conditions per hold, visibility decided off Lock | covered by every OI wiring test (index correctness); no timing test | n/a (not behaviour-observable) |
|
||
| **S6** metadata failure swallowed | a root whose metadata is not Good (or a failed call) is `Unavailable` (logged), its item is not opened; all roots failing ends the stream | `S6_a_root_whose_metadata_fails…` | yes |
|
||
| **S7** RefreshRequired only on timeout | any incomplete barrier (a mapping not `Known`: timed out, refused, metadata) requires refresh | `B2_S7_a_refused_item…` (`RefreshRequired == 1`) | yes |
|
||
| **Deviation 3** folder-only demand | event items on any projected folder are admitted through `ImportedNotifierAdmits` = a wired condition the caller sees, OR the mapping gate on the folder's own (mapping, subject) key (`IProjectedConditionAccess.CanSubscribeFolder`); projected folders of a condition-bearing mapping (`IsConditionBearingMapping`) are `SubscribeToEvents` from materialisation (the SDK answers `BadNotSupported` before `SubscribeToEvents` otherwise) and never demoted by an unwire | `Deviation3_a_folder_only_client_opens_demand…` (granted Good + demand + the condition then delivered; anonymous denied) | yes (promotion removed ⇒ `BadNotSupported`) |
|
||
| **Deviation 6** removal tells nobody | `RemoveConditions` captures the items that may see the conditions BEFORE unwiring, removes, then queues `RefreshRequired` (off Lock) to those passing the gate. `RequireRefresh`'s early return on a connection with no conditions stays: nothing of it can be held any more — the removal itself now notifies | `Deviation6_removing_an_imported_condition_sends_RefreshRequired_only_to_the_items_that_could_see_it` (Server + folder get it; a map-b folder item does not, after a must-arrive control) | yes |
|
||
| **Deviation 8** one-hold replay | `ReplayImportedConditions` runs 128 conditions per Lock hold; each condition's snapshot and its queueing share a hold (ordering vs. live events kept) and one `EventDeliveryCache` per snapshot is shared across items | `Deviation8_ConditionRefresh_replays_hundreds…` (300 conditions inside RefreshStart/End) | **no** — chunking is not observable; the test guards correctness of the chunked replay |
|
||
| **A3b open item** RefreshRequired scope after an EventId-invalidating resync | `ApplyConditions` collects the un-re-bindable CONDITIONS and refreshes only the items that may see one of them (shared `QueueImportedRefresh`) | via the shared targeting in `Deviation6_…` (a folder item of another mapping is not refreshed); the A3b re-binding test still passes | not separately reverted |
|
||
| NIT `IsWiredTo` reads `Folders` off Lock | `ImportedCondition.WiredFolders` immutable array, replaced under Lock on wire/unwire | — | n/a |
|
||
| NIT `Infos` never pruned | `ConditionSet.Apply` drops the info with a removed key; a swap discards the old set | — | n/a |
|
||
| NIT stale callback after a fresh barrier | stale mark and barrier serialize on the runner's stale gate + generation | — | n/a (race) |
|
||
| Test adequacy: vacuous absence assertions | `Applied.ShouldBeEmpty` / `Removed.ShouldBeEmpty` now follow a must-arrive control (a later frame's item removal; the barrier) | the three original tests rewritten | — |
|
||
| Test adequacy: delivery gate not isolated | `ImportedConditionDeliveryGateTests` (non-parallel collection): the denied Server-object session gets nothing AND `ProjectedEventFieldList.DroppedOnPublish` does not move | `A3_SEC_the_delivery_gate_alone_withholds…` | yes — removing only the Server-object delivery gate turns it red while the original A3-SEC test stays green |
|
||
|
||
Residual / recorded:
|
||
- A projected folder materialised while its mapping was NOT condition-bearing (or before `ProjectedConditionAccess` is bound) is
|
||
not promoted until it re-materialises; the host binds access before any projection deploys.
|
||
- The B2 retry ends the whole stream (complete mappings re-snapshot too), bounded by the backoff; a per-item re-add is A4 material.
|
||
- In-stream capacity refusal removes the mapping's keys (all-or-nothing, §5.5) rather than keeping them stale.
|
||
|
||
## Gates (review round 1, at `14343bf0`)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A3` | passed (`20261124T234716…`) |
|
||
| `run-unit-phase.py A2` | passed (`20261124T234814…`) |
|
||
| `run-unit-phase.py A1` | passed (`20261124T234927…`) |
|
||
| `run-unit-phase.py X0` | passed (`20261124T235258…`) |
|
||
| Host.Tests `.DataConnections.` (both v1 gates) | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2049 passed, 3 skipped (no #920 rerun needed) |
|
||
| OpcUaServer.Tests full (same filter) | 1456 passed, 1 skipped |
|
||
| OI `Feature=GrpcData` + ConditionMethodEvent / NativeAlarmEventIdentityFieldDelivery / FolderConditionRefresh / ConditionRefreshDeferral | 129 passed, 1 skipped in 2 of 4 runs; the other 2 runs failed 2 and 6 of the #854 deferral stress tests (`ConditionRefreshDeferralWireTests` / `FolderConditionRefreshWireTests` `Deferred_events_older_than_a_refresh…`, `A_condition_removed_during_a_plain_refresh…`) — **pre-existing**: the same suite at the unchanged base `3c941458` failed 2 of them in 1 of 3 runs; the classes pass 3/3 in isolation on this branch; no imported-condition code is reached in those rigs (no `ProjectedConditionAccess`). Root cause not established (load-sensitive local-condition deferral) — to be filed as an issue, not closed as a flake |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
## Live — run `a3r1-cond-1` (build `14343bf0` + docs) — PASS
|
||
|
||
Same procedure as `a3b-cond-3` (`rig.py up --conditions`, seed, ~88 s, deploy, `conditions_a3_smoke.py`, `rig.py down`).
|
||
Consumer: `stream 1 for connection consumer-source opened (2 mapping(s), serving source-1:4053)` (the Primary, now via
|
||
`SubscribePrimaryAsync`); barrier `map-raw=Complete, map-uns=Complete; 1 record(s)`. Bogus EventId ⇒ `BadEventIdUnknown`; ack
|
||
through the consumer `Acknowledge successful` (608 ms); origin subscriber and consumer subscriber each saw exactly one
|
||
Active/Acknowledged. Teardown: no run-labelled containers or networks left.
|
||
|
||
---
|
||
|
||
# A3 — Review round 1 (A3b adversarial review, `a3b-review-round1.md`, written against `3c941458`)
|
||
|
||
2026-11-25, branch `a3-consumer`, on top of the A3a fix round (`01a4e8db`). Not merged, not pushed. Commits: `72dece7f` (fixes +
|
||
tests), `perf(grpc-data): … BytesPerCondition` (L2 re-derivation), this docs commit.
|
||
|
||
"Red on revert": the single fix was removed by a scripted mutation (`mut.py`, one mutation per build), the named test run and seen
|
||
red, the file restored (`git status` clean after the 19 mutations).
|
||
|
||
| Finding | Resolution | Test(s) | Red on revert |
|
||
|---|---|---|---|
|
||
| **S1** a throw after `base.Call` faults the batch | `CallAsync` runs each claimed item through `CallImportedGuardedAsync` (never faults, a synchronous throw included) and collects per-item results; a fault before the port is called ⇒ that item's `BadInternalError`, unsent (logged); `DispatchImportedAsync` answers every post-dispatch failure itself | `A_fault_before_dispatch_is_a_per_item_BadInternalError…` (gate throws: imported-first batch ⇒ `[BadInternalError, Good]`, local ack routed once, nothing sent; a pre-validation failure (`MethodId` null) answered per item beside a dispatched call; a port THROWING after dispatch ⇒ `BadCommunicationError`, one dispatch) | yes (both catch-alls removed ⇒ ServiceFault) |
|
||
| **S2** mapping timeout capped at 5 s; BadTimeout inferred | the mapping's `ConditionMethodTimeoutMilliseconds` is honoured (up to the validator's 3,600,000 ms): it rides `RemainingBudget`, and `GrpcDataConnection.ConditionMethodTimeout` defaults to that validator ceiling (`MaxConditionMethodTimeout`) instead of 5 s. The client maps gRPC `DeadlineExceeded` ⇒ `OutcomeUnknown` + `BadTimeout`; `MapOutcome` takes the transport's status (BadTimeout stays BadTimeout, anything else unknown ⇒ BadCommunicationError) — no clock comparison | Runtime `Without_a_connection_ceiling_the_deadline_is_the_requests_budget_not_a_hidden_5s` (8 s budget ⇒ grpc-timeout > 6 s); `A_deadline_passing_after_send_is_OutcomeUnknown_with_BadTimeout_known_not_inferred`; OI timeout test: port answers `OutcomeUnknown/BadTimeout` at once ⇒ `BadTimeout` | yes / yes / yes |
|
||
| **S3** unsent / definite failures labelled unknown | cancel while waiting for a slot ⇒ `BadRequestCancelledByClient` unsent; an invalid request is `RejectedBeforeDispatch` `BadInvalidArgument` in `ProjectedConditionAccess.CallAsync` (before the lease) and in the client (never thrown); `DriverConfirmedFailure` ⇒ the origin's status (+ diagnostic) | Runtime `An_invalid_request_is_refused_unsent_before_the_lease` (not even leased); client `An_invalid_request_is_RejectedBeforeDispatch_never_thrown`; OI timeout test (`DriverConfirmedFailure`/`BadConditionAlreadyEnabled` passes through) | yes / yes / yes. Slot-wait cancellation: **not tested** — the SDK 2.0.1 server gives no client-driven way to cancel an in-flight Call (no Cancel wiring into `OperationContext.CancellationToken` found); by inspection only |
|
||
| **S4** no fairness; dispatch with a few ms left | per-connection sub-limit `DefaultImportedMethodConcurrencyPerConnection = 4` inside the node-wide 8 (connection slot first, then node slot, both released in `finally`); a dispatch with < `ImportedMethodMinimumDispatchBudget` (250 ms) left is `BadTimeout` UNSENT (checked before the waits and again after them). Per-principal fairness not added (a principal is bounded by the per-connection limit; documented) | `One_stalled_connection_cannot_starve_another_and_its_excess_calls_are_BadTooManyOperations_unsent` (8 stalled calls on conn-a: 4 dispatched, 4 `BadTooManyOperations` unsent, a conn-b call Good < 1.5 s — slot exhaustion included); `A_request_deadline_below_the_dispatch_floor_is_BadTimeout_unsent` (TimeoutHint 450 ms ⇒ unsent; 2,000 ms ⇒ dispatched with budget ≤ 1,750 ms) | yes / yes |
|
||
| **S5 L3** stall below the port only | the L3 test is now a Theory: `realPath: true` puts a REAL `ProjectedConditionAccess` (runner, serving incarnation, lease) and a REAL `GrpcDataConnection` (capabilities, eligibility, deadline, HTTP/2 gRPC framing) between the node manager and an in-process origin whose `CallConditionMethod` handler stalls 5 s (`RealConditionMethodPath`); only the condition stream is a quiet stand-in carrying Primary provenance. The per-caller gate stays the fake (pinned by the Runtime gate tests) | L3 numbers below | yes (M1 on the real path: port awaited under `Lock` ⇒ both cases red) |
|
||
| **S5 L2** not worst case | harness now: two placements per condition (two mappings, both folders wired), all 32 EventId slots filled (asserted), three event items (Server object + both folders, publishing off, queue 1000), runner Live + Buffer record copies; max of three runs, rounded up: `BytesPerCondition` 205,665 → **230,000**, `MaxImportedConditionBytes` default = 230,000 × 2,500 = **575,000,000 B (≈ 548 MiB)** | L2 numbers below | n/a (measurement) |
|
||
| **S6** test gaps | RefreshRequired after an un-re-bindable resync asserted over the wire (Server-object item receives `RefreshRequiredEventType`); native Confirm with a listing that HAS Confirm (still refused) and scripted lacking it (refused) / having it (dispatched); real gate: first authorized placement of several, realm mismatch, unknown mapping, ungranted folder; Warm standby refusal; different principals never join; imported-first mixed batch; batch with a pre-validation failure; throwing port; slot exhaustion; the `cancelled` flag is written/read with `Volatile` | `A_resync_that_cannot_re_bind_sends_RefreshRequired…`; `Native_Confirm_is_refused_even_when_listed…`; Runtime `The_gate_routes_through_the_first_authorized_placement_and_refuses_a_realm_mismatch`; `A_warm_standby_refuses_an_imported_method_unsent`; `Identical_calls_from_different_principals_do_not_join`; S1/S4 tests above | native guard yes; supported-methods guard yes; gate (stop at first refusal) yes; standby yes; principal dropped from the join key yes. **ACL-on gate variant: not added** — `AuthorizeMethod` has no `Security:Acl:Enabled` input at all (`DataOperationPolicy.AuthorizeLocal` regardless of the flag, by design §5.6); the mixed/fault batches run with enforcement on. **Mid-call cancel: not tested** (see S3) |
|
||
| **N1** `bounded` not cancelled on TimeoutException | `bounded.Cancel()` in the `TimeoutException` catch | timeout test (`cancelled` observed) | **no** — the CancelAfter timer usually still fires first; the race the fix closes is not forceable |
|
||
| **N2** re-bind on any marker move | F6 re-binding only when the INCARNATION changed at an unchanged time; a same-incarnation sequence bump mints + RefreshRequired | `A_resync_that_cannot_re_bind…` | yes |
|
||
| **N3** null-marker transition | a marker appearing or disappearing is a marker change: mint + RefreshRequired | `A_marker_appearing_on_an_unchanged_state_mints_an_ackable_EventId` | yes |
|
||
| **N4** joiner inherits the first caller's cancel/deadline | kept (documented in code): a joiner asked for the same thing at the same moment and never dispatches twice; the key includes the principal | — | n/a |
|
||
| **N5** existence answers before the gate | kept; the comment corrected — `BadNodeIdUnknown`/`BadNotSupported` are what SDK pre-validation reveals anyway | — | n/a |
|
||
| **N6** "OutcomeUnknown" text only with diagnostics | kept: the status is always Bad (never read as done); the text reaches a client requesting diagnostics and the Warning log | — | n/a |
|
||
| **N7** grace past TimeoutHint; elapsed subtracted twice | one end instant = min(start + mapping timeout, request deadline − grace); waits and the port budget derive from it, so the answer lands inside the client's TimeoutHint | floor test positive control (budget ≤ hint − grace) | not separately reverted |
|
||
| **N8** unsynchronised reads | `ImportedCondition.Placements` volatile publication; `SupportedMethods` an atomic 64-bit word | — | n/a (memory model) |
|
||
| **N9** method gate does not require visibility | documented: Ack on placement B suffices without seeing it via A; the EventId (128-bit, minted per consumer, only delivered to items that see the condition) is the practical visibility requirement | — | n/a |
|
||
|
||
## L3 — real dispatch path (review S5)
|
||
|
||
The A3b measurement repeated with the stall behind a real `ProjectedConditionAccess` + `GrpcDataConnection` (in-process origin
|
||
handler stalling 5 s), and with the original port-level stall, 10 rounds each:
|
||
|
||
| Run | Path | Stall | Read max | Browse max | Data Publish max | `Lock` acquire max |
|
||
|---|---|---|---|---|---|---|
|
||
| 1 | port | 5002 ms | 0.4 ms | 0.3 ms | 100.0 ms | 0.01 ms |
|
||
| 1 | **real** | 5044 ms | 0.5 ms | 0.3 ms | 101.6 ms | 0.01 ms |
|
||
| 2 | port | 5003 ms | 1.5 ms | 2.2 ms | 102.1 ms | 0.01 ms |
|
||
| 2 | **real** | 5051 ms | 2.3 ms | 0.3 ms | 100.8 ms | 0.01 ms |
|
||
| 3 | port | 5002 ms | 0.7 ms | 0.3 ms | 94.6 ms | 0.00 ms |
|
||
| 3 | **real** | 5040 ms | 0.4 ms | 0.3 ms | 102.6 ms | 0.00 ms |
|
||
| 4 | port | 5002 ms | 0.5 ms | 0.3 ms | 96.7 ms | 0.01 ms |
|
||
| 4 | **real** | 5042 ms | 0.4 ms | 0.3 ms | 109.1 ms | 0.01 ms |
|
||
|
||
(Measured inside the 4 combined OI gate runs, i.e. under the whole suite's parallel load.) All < 200 ms; the ~100 ms publish
|
||
figure is the minimum publishing interval, as before. The real-path stall is ~40 ms longer (capabilities probe + channel set-up
|
||
of the first call). **L3: PASS on the real dispatch path.**
|
||
|
||
## L2 — worst case (review S5) — **FAILS the 200 MiB gate**
|
||
|
||
Two placements per condition, every EventId slot (32) filled, three event items holding up to 1,000 events each (publishing off),
|
||
Live + Buffer record copies; forced compacting GCs; three runs:
|
||
|
||
| Run | Managed heap growth | Working-set growth | heap B/condition | after materialise (heap) |
|
||
|---|---|---|---|---|
|
||
| 1 | +92.3 MiB (GC noise: below the after-materialise figure) | +125.7 MiB | 96,770 | 217,948 |
|
||
| 2 | **+217.8 MiB** | **+210.0 MiB** | 228,353 | 217,979 |
|
||
| 3 | **+217.7 MiB** | **+206.1 MiB** | 228,299 | 217,931 |
|
||
|
||
At this worst case BOTH the managed heap (≈ 218 MiB) and the working set (206–210 MiB in 2 of 3 runs) exceed the 200 MiB gate;
|
||
the A3b single-placement figure (heap 197.4 MiB, WS ≈ 107 MiB) passed it only because it was not worst case. Recorded, not
|
||
adjusted: the harness keeps asserting ≤ 200 MiB and fails when opted in. The byte cap is now derived from the worst case
|
||
(230,000 B × 2,500 ≈ 548 MiB), so admission accounting is honest; whether the §9.3 L2 gate (200 MiB for 1,000 conditions) is
|
||
re-scoped to the single-placement case or the per-condition cost is reduced (≈ 210 KB is the SDK condition node + children —
|
||
X0's node-only figure was 161 KB — plus the second wiring) is an owner decision.
|
||
|
||
## Task: the OI condition-refresh failures (`ConditionRefreshDeferralWireTests` / `FolderConditionRefreshWireTests`)
|
||
|
||
**Conclusion: reproduces only with the A3 test classes in the run; NOT reproduced on master; root cause NOT established.
|
||
Not marked flaky.** No A3 production path is reached in the failing rigs (no imported condition exists in them;
|
||
`ReplayImportedConditions` returns at `Count == 0`; every other A3 hunk on the delivery/refresh path is a namespace-index test or a
|
||
`Find` returning null).
|
||
|
||
Evidence (combined filter `Feature=GrpcData|…ConditionMethodEvent|…NativeAlarmEventIdentityFieldDelivery|…FolderConditionRefresh|
|
||
…ConditionRefreshDeferral`, `--blame-hang-timeout 120s`, one run at a time):
|
||
|
||
| Build | Runs | Failed runs | Failures |
|
||
|---|---|---|---|
|
||
| master `83c7e586` (109 tests) | 4 | **0** | — |
|
||
| master `83c7e586`, only the two deferral classes, 14 busy-loop CPU burners | 2 | 0 | — |
|
||
| A3a r1 `01a4e8db` (130 tests) | 4 | 2 | gate test `A_refresh_waits_for_a_deferred_delivery…` (`window.Count` 4, expected 2); folder `Deferred_events_older…(enforced: False, …, modify: True)` (RefreshEnd not seen in 10 s, line 93) |
|
||
| `01a4e8db` + diagnostics (window dump on failure) | 6 | 0 | — (the failure did not recur, so no window dump was captured) |
|
||
| this round `72dece7f`+ (139 tests) | 4 | 3 | folder `Deferred_events_older…(enforced: True…)` ×2 (RefreshEnd not seen, line 93); folder `A_condition_removed_during_a_plain_refresh_is_not_replayed(serverObject: False)` (RefreshEnd not seen, line 527 — **no stall, no deferral involved**) |
|
||
| same + thread-pool latency sampler (50 ms probe) | 4 | 1 | folder `Deferred_events_older…` ×2; pool dispatch latency max **11 ms** in the failing run (≤ 21 ms in all), ≤ 21 pool threads |
|
||
| same + `DOTNET_ThreadPool_ForceMinWorkerThreads=64` | 1 | 1 | `ConditionRefreshDeferralWireTests.Deferred_events_older…(enforced: True…)`; pool max 15 ms |
|
||
|
||
Ruled out:
|
||
- **A3 production code in those rigs** — not reached (above); the shared helpers (`ApplyConditionState`, `CreateConditionNode`) are
|
||
pure extractions.
|
||
- **Thread-pool starvation** (the SDK's ConditionRefresh worker blocks a pool thread in `WaitOne` per server, which made it the
|
||
first suspect) — dispatch latency stayed ≤ 21 ms in failing runs and forcing 64 minimum workers did not prevent a failure.
|
||
- **Plain CPU load** — 14 burners on master's two classes: 0 failures.
|
||
|
||
What it is: mostly **a RefreshEnd that never reaches a folder (direct) event item** within 10 s — once in the plain
|
||
(non-deferring) refresh path with no stall at all — plus, once, two extra deferred events inside a Server-object refresh window.
|
||
It needs other tests running in the same process at the same time (it scales with the size of the parallel suite: 0/4 at 109
|
||
tests, 2/4 at 130, 3/4 at 139). Process-wide shared state is the remaining lead — e.g. `ProjectedEventDelivery`'s static
|
||
`FilterGroup` registry keyed by filter text, which every rig's server shares — but no mechanism was demonstrated. Pre-existing
|
||
code (#854/#855), exposed by suite composition rather than introduced by A3 behaviour as far as the evidence goes; to be filed.
|
||
|
||
## Gates (review round 1 A3b)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A3` | passed (`20261125T010625…`) |
|
||
| `run-unit-phase.py A2` | passed (`20261125T010724…`) |
|
||
| `run-unit-phase.py A1` | passed (`20261125T010836…`) |
|
||
| `run-unit-phase.py X0` | passed (`20261125T011156…`) |
|
||
| Host.Tests `.DataConnections.` (both v1 gates) | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2054 passed, 3 skipped |
|
||
| OpcUaServer.Tests full (same filter) | 1456 passed, 1 skipped |
|
||
| OI combined (139) | **not 3 clean**: 1 of 4 clean; every failure is in `FolderConditionRefreshWireTests` / `ConditionRefreshDeferralWireTests` (see the investigation above); every A3/GrpcData test passed in every run |
|
||
| OI `ImportedConditionMethodWireTests` (16) | 16/16 (and in each combined run) |
|
||
| L2 worst case (opt-in) | **FAIL** 2 of 3 runs (above) |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
## Live — run `a3br1-cond-1` (build `c82ea04e`, clean tree) — PASS
|
||
|
||
Same procedure as `a3b-cond-3` (`rig.py up --conditions`, seed, 90 s, deploy, `conditions_a3_smoke.py`, `rig.py down`). Imported
|
||
ScalarHigh at the consumer (`ns=6;s=c1.…`, 32-char EventId); bogus EventId ⇒ `BadEventIdUnknown [809A0000]`; ack through the
|
||
consumer `Acknowledge successful` (596 ms, through the new per-connection slot + dispatch floor + mapping-timeout path); origin
|
||
subscriber and consumer subscriber each saw exactly one Active/Acknowledged; `passed: true`. Teardown: no run-labelled containers
|
||
or networks left.
|
||
|
||
# A3 — Round 2 (merge blocker: the OI condition-refresh failures; L2 worst-case memory)
|
||
|
||
2026-11-25, branch `a3-consumer`. Not merged, not pushed. Commits: `6be0b8dc` (fix + red/green test), `b884db5f` (L2), this docs
|
||
commit.
|
||
|
||
## Root cause of the OI condition-refresh failures — an A3 defect, now fixed
|
||
|
||
**SDK 2.0.1 pools `EventFieldList` process-wide, and `ProjectedEventFieldList` (A3a, §5.4) went back into that pool.**
|
||
`EventFieldListActivator : PooledEncodeableType<EventFieldList>` (bounded, process-global, 1,024); `MonitoredItem.GetEventFields`
|
||
rents every event's list from it; `SentMessageQueue.ReuseNotificationPayloads` calls `Reuse()` on every list of an acknowledged /
|
||
evicted message, and the base `ReuseCore` resets the instance and returns it — **whatever its runtime type** — to the stock pool.
|
||
A released `ProjectedEventFieldList` was therefore rented by ANY server's next `GetEventFields` — an unrelated session's
|
||
`RefreshStart`/`RefreshEnd` or local condition event — still carrying the imported condition's `ProjectedEventMarker`, and
|
||
`ProjectedNotificationRewriter` judged that unrelated event by the stale marker: when its gate denied (a revoked caller, a removed
|
||
condition), the event was **dropped**. The data path already knew this trap (`ProjectedSdkNotification` overrides `ReuseCore` and
|
||
"stays out of the shared stock pool"; `OrdinaryTagMarker` validates itself against its notification); the A3a event subclass did
|
||
not follow it.
|
||
|
||
This is a production defect, not a test artifact: in one server process, any session's events (refresh markers, local alarms,
|
||
acks) could be dropped by another session's imported-condition gate, and every recycled list pinned a marker closure (condition +
|
||
identity) for as long as it sat in the pool.
|
||
|
||
How it was found (one test run at a time, `--blame-hang-timeout 120s`):
|
||
|
||
| Step | Set | Runs | Failed runs |
|
||
|---|---|---|---|
|
||
| A3 build, full combined filter (139) | — | 1 | 1 |
|
||
| A3 build, master's 109 only (`FullyQualifiedName!~ImportedCondition`) | **A3 production code alone** | 4 | **0** ⇒ the A3 tests trigger it |
|
||
| without `ImportedConditionMethodWireTests` (123) | event wire tests in | 4 | 2 |
|
||
| deferral + folder classes + event wire tests only (52) | — | 4 | **4** |
|
||
| … + half A (6 tests) | — | 3 | 2 |
|
||
| … + `Exactly_one…`, `A3_SEC_with_ACLs_off…`, `A_condition_child_Read…` | — | 3 | 3 |
|
||
| … + `A_condition_child_Read…` only (no event subscription) | — | 3 | 0 |
|
||
| … + `Exactly_one…` only (no revocation) | — | 3 | 0 |
|
||
| … + `A3_SEC_with_ACLs_off…` only (**revokes** a marked event's caller) | — | 3 | 2 |
|
||
|
||
Then a temporary publish-path trace (server: the SDK's message before and after the rewriter; client: RefreshStart/End received;
|
||
reverted, never committed) on a failing run showed it directly:
|
||
|
||
```
|
||
PUBraw app=urn:OtOpcUa.Refresh855.… sub=3999762809 seq=2 h=19 START EventFieldList
|
||
PUBraw app=urn:OtOpcUa.Refresh855.… sub=3999762809 seq=2 h=19 END ProjectedEventFieldList ← a non-imported rig's RefreshEnd
|
||
PUB app=urn:OtOpcUa.Refresh855.… sub=3999762809 seq=2 h=19 START EventFieldList ← END dropped by the rewriter
|
||
RCV sub=3999762809 h=19 START
|
||
PUBraw app=urn:OtOpcUa.Refresh854Gate.… sub=990727810 seq=3 h=30 END ProjectedEventFieldList (never published)
|
||
```
|
||
|
||
That explains every symptom: "RefreshEnd never arrives" (the recycled list was the RefreshEnd), "RefreshStart missing but
|
||
RefreshEnd present" (the recycled list was the RefreshStart), "no stall/deferral at all" (plain refresh, same pool), extra events
|
||
inside a window (a recycled list whose stale marker PERMITTED), the scaling with suite size and the need for other tests in the
|
||
process (more marked lists in the pool), and master never reproducing (no marked lists). The earlier leads (thread-pool
|
||
starvation, CPU load, the static `FilterGroup` registry) were not it.
|
||
|
||
**Fix** (`ProjectedEventDelivery.cs`): `ProjectedEventFieldList` overrides `ReuseCore` — clears its marker, `ResetForReuse()`,
|
||
never returns to the stock pool (the GC takes it), exactly like `ProjectedSdkNotification`. `Marker` is nullable; the rewriter
|
||
treats a released (marker-less) list as denied (fail closed; it is never published again anyway). No `Lock` involvement.
|
||
|
||
**Red/green** (`ImportedConditionClassifierTests.A_released_marked_event_list_never_returns_to_the_SDK_pool_so_no_other_session_rents_its_marker`,
|
||
OpcUaServer.Tests, deterministic): `Reuse()` a marked list as `SentMessageQueue` does, drain `DefaultMaximumRetained + 64` lists
|
||
from `EventFieldListActivator.Instance`, assert none is a `ProjectedEventFieldList`, the marker is gone, and a released list
|
||
through the rewriter is dropped. Red on revert, both ways: override body → `base.ReuseCore()` ⇒ `marked.Marker should be null`;
|
||
`Marker = null; base.ReuseCore()` ⇒ `rented should not contain an element satisfying the condition`.
|
||
|
||
After the fix: the 52-test reproducer 0/3 (was 4/4); the combined OI filter — see gates.
|
||
|
||
## L2 worst-case memory — PASS (the round-1 "FAIL" was a measurement artifact)
|
||
|
||
1. **EventId window → 8** (`ProjectedConditionRegistry.RecentEventIds`), the plan's §5.6 step 3 "within its last N (default 8)".
|
||
A3a's 32 had no recorded need (deviation 1 only stated it); validity is "minted under the current marker", which only the
|
||
newest few EventIds can meet. No test depended on 32 (only the L2 harness reads the constant).
|
||
2. **`GC.GetTotalMemory` is not the retained heap on .NET 10 regions.** In the same process state it reported **+92 or +218 MiB**
|
||
run to run (bimodal; it is the source of round 1's "+217.8 MiB" and run 1's "GC noise"). In those very runs
|
||
`GC.GetGCMemoryInfo().HeapSizeBytes` was 135.5 MB both times, and a heap dump of a "+218" run (`dotnet-dump`, taken while
|
||
paused after the measurement) held **136 MB of objects in total** (`eeheap -gc`: allocated 136,318,696 B, committed
|
||
236,208,128 B): the extra ~125 MiB was committed-but-free region space, and the working set measured the instant after the
|
||
forced GCs counted it too (+214 MiB; +133 MiB two seconds later in the same run). The harness now takes
|
||
`HeapSizeBytes − FragmentedBytes` after a full blocking GC, samples the working set until the GC has decommitted (two samples
|
||
500 ms apart within 1 MiB, ≤ 10 s), still logs the `GetTotalMemory` delta for comparison, and asserts **both** heap and working
|
||
set ≤ 200 MiB (stricter than before, not looser).
|
||
3. **What dominates** (end-of-run dump, 32-slot build): of 136 MB live, our own types are 6.4 MB — 3.1 MB of it the 32-slot
|
||
EventId window (32,000 `LinkedListNode` + 33,000 `DataActivationMarker`, now ÷4), the rest registry entries, placements,
|
||
1,000 `ImportedCondition`, 3,000 marked lists/markers (queues capped at 1,000 per item), the harness's Live + Buffer records
|
||
(~0.6 MB). ~86 MB is SDK `Opc.Ua.*` node state (property/variable/method states, `ReferenceDictionary`, 158 `Lock`s and 400
|
||
`object`s per condition), not ours to cut without touching the SDK node model.
|
||
|
||
Worst case (2 placements per condition, all 8 EventId slots filled, 3 event items with publishing off, Live + Buffer records):
|
||
|
||
| Run | Managed heap growth | Working-set growth (settled) | heap B/condition | WS B/condition | `GetTotalMemory` delta (not used) |
|
||
|---|---|---|---|---|---|
|
||
| 1 | +106.5 MiB | +151.3 MiB | 111,715 | 158,629 | +211.6 MiB |
|
||
| 2 | +106.5 MiB | +149.2 MiB | 111,682 | 156,434 | +211.5 MiB |
|
||
| 3 | +106.5 MiB | +149.4 MiB | 111,654 | 156,663 | +211.5 MiB |
|
||
|
||
**L2: PASS** (both ≤ 200 MiB in every run). `BytesPerCondition` = the larger of the two per-condition figures, max of three runs,
|
||
rounded up: 158,629 → **160,000** (was 230,000); `MaxImportedConditionBytes` default = 160,000 × 2,500 = **400,000,000 B
|
||
(≈ 381 MiB)** (was ≈ 548 MiB). The X0 node-only figure (160,997) and A3b's 197.4 MiB were taken with `GetTotalMemory` too and are
|
||
likely inflated the same way (not re-measured here; #929 re-measured X0: 79,085 B node-only heap, X0 evidence).
|
||
|
||
## Gates (round 2, at `b884db5f`)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A3` | passed (`20261125T024649…`) |
|
||
| `run-unit-phase.py A2` | passed (`20261125T024744…`) |
|
||
| `run-unit-phase.py A1` | passed (`20261125T024855…`) |
|
||
| `run-unit-phase.py X0` | passed (`20261125T025234…`) |
|
||
| Host.Tests `.DataConnections.` (both v1 gates) | 207 passed |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2054 passed, 3 skipped (see note) |
|
||
| OpcUaServer.Tests full (same filter) | 1457 passed, 1 skipped |
|
||
| OI combined (139) | **3 consecutive clean runs**: 138 passed, 1 skipped (the opt-in L2 harness) each |
|
||
| L2 worst case (opt-in) | PASS 3/3 (above) |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
Note (Runtime): the first full run, made while the live rig's images were building (heavy CPU), failed one test,
|
||
`GrpcDataConditionStreamTests.Overflow_before_the_snapshot_is_drained_resets_the_stream` (A2, unchanged by A3 — it races 6 raises
|
||
against the condition item's read position to force a hub eviction). Not touched by round 2 (no Runtime behaviour changed; only the
|
||
`BytesPerCondition` constant). The class passed 5/5 alone and the full suite passed on the re-run without load. Not root-caused
|
||
here and not called a flake: to be filed as a load-sensitivity follow-up.
|
||
|
||
## Live — run `a3r2-cond-1` (build `b884db5f`, clean tree) — PASS
|
||
|
||
Same procedure as `a3b-cond-3` (`rig.py up --conditions`, seed, 90 s, deploy, `conditions_a3_smoke.py`, `rig.py down`). Imported
|
||
ScalarHigh at the consumer (`ns=6;s=c1.…`, 32-char EventId); bogus EventId ⇒ `BadEventIdUnknown [809A0000]`; ack through the
|
||
consumer `Acknowledge successful` (1,990 ms); origin subscriber and consumer subscriber each saw exactly one
|
||
Active/Acknowledged; `passed: true`. Teardown: no run-labelled containers or networks left.
|
||
|
||
## Left over
|
||
|
||
- File: the `GrpcDataConditionStreamTests.Overflow_before_the_snapshot_is_drained_resets_the_stream` load sensitivity (above).
|
||
- The plan's L2 / X0 figures (≈ 157–161 KiB per condition node, §5.5 table) came from `GC.GetTotalMemory` and are likely
|
||
inflated by the same region accounting; the plan's §5.5 table was not edited (evidence only). Done in #929: the X0 harness
|
||
now uses the L2 method (79,085 B node-only heap vs 158,169 B by `GetTotalMemory`), and §5.5 cites L2's 160,000 B.
|
||
|
||
# A3 — Verification review round 2
|
||
|
||
2026-11-25, branch `a3-consumer`. Not merged, not pushed. **Verdict: approve-with-changes** — one must-fix (N1) and one
|
||
comment/test fix; both done in `c8b35d49`. N2/N3 filed as #930; N4–N8 filed as #931.
|
||
|
||
## N1 — the runner predecessor chain leaked one runner per demand cycle — fixed
|
||
|
||
`ConnectionRunner._predecessor` was `readonly` and never cleared, and every runner kept `_states` (its last stream's Live/Buffer
|
||
record sets). Each linger expiry + re-subscribe, or mapping change, added a link R3 → R2 → R1, so memory grew without bound.
|
||
Fix (`ProjectedConditionAccess.Runner.cs`): the hand-over moved into `HandOverAsync` (its own state machine, so no hoisted
|
||
`previous` local outlives it), which awaits the old runner's `Stopped` (loop end + removal), takes its materialised set, and only
|
||
then sets `_predecessor = null` — the S3/S4 ordering is unchanged. A stopping runner's continuation now resets `_states = []`
|
||
before (optionally) removing its conditions, so a runner parked in `_stopping` until the next demand holds no record sets.
|
||
New test observation `ProjectedConditionAccess.RunnerReference(connectionId)` (a `WeakReference`, never a strong one).
|
||
|
||
**Red/green** — `GrpcDataProjectedConditionAccessTests.N1_demand_cycles_and_mapping_changes_do_not_chain_runners_so_an_old_runner_is_collectable`
|
||
(Runtime.Tests): first runner completes a snapshot, then 3 linger-expiry + re-demand cycles and 2 mapping changes, each with a
|
||
complete snapshot; asserts the hand-over still holds (`Sink.Live == [x]`) and, after forced GCs, that the first runner's weak
|
||
reference is dead. Red with the original `Runner.cs` restored (`first.IsAlive should be False`); green with the fix, 5/5 repeats.
|
||
S3/S4 hand-over tests still pass.
|
||
|
||
## Pool-fix comment corrected + clone dependency pinned
|
||
|
||
The `ProjectedEventFieldList` summary claimed the SDK never clones a queued list. Wrong: SDK 2.0.1 `SentMessageQueue` returns
|
||
`CoreUtils.Clone` of the stored message on Publish and Republish, so the rewriter never sees the queued instance. The gate works
|
||
because `EventFieldList.Clone()` is `MemberwiseClone`, which keeps the subclass, the marker and the handle. The comment now says
|
||
that. New test `ImportedConditionClassifierTests.Cloning_a_marked_event_list_the_way_the_SDK_does_keeps_the_subclass_and_the_marker`
|
||
(OpcUaServer.Tests): `Clone()` and `CoreUtils.Clone(NotificationMessage)` both yield a `ProjectedEventFieldList` with the same
|
||
marker and handle, and the rewriter still drops the copy when its re-check fails. Shown to discriminate: a temporary
|
||
`Clone()` override returning a stock `EventFieldList` (what an activator-based clone would do) turns it red
|
||
(`marked.Clone() should be of type ProjectedEventFieldList`); reverted.
|
||
|
||
## Gates (verification round 2, at `c8b35d49`)
|
||
|
||
| Gate | Result |
|
||
|---|---|
|
||
| `dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental` | 0 warnings, 0 errors |
|
||
| `run-unit-phase.py A3` | passed (`20261125T032703…`) |
|
||
| `run-unit-phase.py A2` | passed (`20261125T032802…`) |
|
||
| Runtime.Tests full (`Category!=E2E&Category!=LiveIntegration`) | 2055 passed, 3 skipped |
|
||
| OpcUaServer.Tests full (same filter) | 1458 passed, 1 skipped |
|
||
| Host.Tests `.DataConnections.` | 207 passed |
|
||
| OI combined (139) | clean: 138 passed, 1 skipped (the opt-in L2 harness) |
|
||
| `git diff master -- '*Goldens.cs'` | empty |
|
||
|
||
## Live — run `a3v2-cond-1` (build `c8b35d49`) — PASS
|
||
|
||
Same procedure as `a3b-cond-3` (`rig.py up --conditions`, seed, 90 s, deploy, `conditions_a3_smoke.py`, `rig.py down`). Imported
|
||
ScalarHigh at the consumer (`ns=6;s=c1.…`, 32-char EventId); bogus EventId ⇒ `BadEventIdUnknown [809A0000]`; ack through the
|
||
consumer `Acknowledge successful` (540 ms); origin subscriber and consumer subscriber each saw exactly one Active/Acknowledged;
|
||
`passed: true`. Teardown: no run-labelled containers or networks left.
|