2238da6504
v2-ci / unit-tests (push) Has been cancelled
The throwaway loopback spike (11/11 over the wire) shows SDK 2.0.1 clones the cached NotificationMessage on every Publish, queued send and Republish, and pools notification payloads, so design §4.6's object-keyed provenance and first-delivery ledger never match a delivered object (0 hits; Good leaks after demotion). A ledger keyed by (SubscriptionId, SequenceNumber) plus a provenance token on the clone-copied MonitoredItemNotification.Message helper passed the same matrix. Per the plan's T0 exit rule this re-opens D4's mechanism; T1+ wait for the owner's go/no-go. Claude-Session: https://claude.ai/code/session_01GT67ACmpMR7b9LGRPLijMi
137 lines
9.7 KiB
Markdown
137 lines
9.7 KiB
Markdown
# #717 T0: SDK 2.0.1 hook re-proof results (2026-11-13)
|
|
|
|
Plan task T0 of `docs/plans/2026-11-11-warm-redundancy-717-plan.md`. A throwaway loopback server
|
|
(`Warm717Sdk2Spike.cs` in this folder: a `StandardServer` with a `CustomNodeManager2`, as the product uses) was
|
|
driven over a real OPC UA session on the pinned `OPCFoundation.NetStandard.Opc.Ua.*` **2.0.1**. The client used raw
|
|
`CreateSubscription` / `Publish` / `Republish` / `SetPublishingMode` service calls, so each step is deterministic.
|
|
SDK source references are to the `2.0.1` tag of `OPCFoundation/UA-.NETStandard`.
|
|
|
|
Run: 11 of 11 passed (16 s). The (c)/(d) tests run twice: `V2=false` pins the failure of design §4.6 as written,
|
|
and `V2=true` pins the alternative described below.
|
|
|
|
## Verdict
|
|
|
|
| Fixture | Result | Gate |
|
|
|---|---|---|
|
|
| a. Metadata graph | **Pass**, through a different hook than planned | go |
|
|
| b. Read projection coverage | **Pass** | go |
|
|
| c. Provenance | **Fail as designed.** The custom item installs, but object-keyed provenance never reaches a delivered notification | **no-go on §4.6 as written** |
|
|
| d. Publish/Republish choice | **Fail as designed.** Every delivery is a fresh clone, so a choice keyed by object never matches | **no-go on §4.6 as written** |
|
|
| e. Events | Not exercised. The stamp/deliver split is product code, not an SDK hook | n/a |
|
|
|
|
The plan's T0 exit rule applies: "A 'no' on (c) or (d) re-opens D4's mechanism." Implementation (T1 onward) is
|
|
stopped pending the owner's go/no-go on the alternative mechanism below. D4 itself (strict first delivery) is unchanged.
|
|
|
|
## a. Metadata graph: pass
|
|
|
|
- `Server.ServerRedundancy` is promoted to `NonTransparentRedundancyType` (2039) by
|
|
`IPredefinedNodeSubtypeReplacer.ReplacePredefinedInstanceSubtypeAsync`. The interface is new in 2.0.1, and the
|
|
`DiagnosticsNodeManager` (an `AsyncCustomNodeManager`) implements it. The call goes in `OnNodeManagerStartedAsync`,
|
|
which the product already overrides, so no `CreateMainNodeManagerFactory` override is needed. The well-known child
|
|
NodeId `i=11314` is passed in, so the passive-predefined-node problem from the 1.5 spike (c7791) does not arise.
|
|
This is the same route the SDK's own `Opc.Ua.Redundancy.Server` package uses (`ServerRedundancyController.ApplyAsync`).
|
|
That package is not referenced, and it publishes peers only, whereas decision #155 wants self first.
|
|
- Over the wire, in Warm: `i=3709` = 2 (Warm); `HasTypeDefinition` of `i=2296` = `i=2039`; `ServerRedundancy`
|
|
`HasProperty` → `i=11314`; `TranslateBrowsePaths(Server/ServerRedundancy/ServerUriArray)` = `i=11314`;
|
|
`i=11314` = `[self, peer]`; a Write to it is refused; `Server.ServiceLevel` reads 1 at boot.
|
|
- In None: `i=3709` = 0, and the type definition stays `ServerRedundancyType` (2034).
|
|
- **Finding:** in None (and so also today's Unset), the predefined `i=11314` survives as an orphan. It is readable by
|
|
NodeId (Good, empty `String[]`), but it is not referenced from `ServerRedundancy` (browse lists only
|
|
`RedundancySupport` and `RedundantServerArray`), and TranslateBrowsePaths returns `BadNoMatch`. `docs/Redundancy.md`
|
|
says `i=11314` is "absent". That is true for browse and false for a direct Read. Spec §3 wants it absent for None.
|
|
Deleting the orphan in None is a small product step.
|
|
|
|
## b. Read projection: pass
|
|
|
|
An override of `BaseVariableState.ReadValueAttribute` (the product's `EquipmentVariableState` already has one) that
|
|
runs the base read first and then returns `BadOutOfService` with a null value covers every path:
|
|
|
|
- Read, including an IndexRange read of an array tag. The `ServerTimestamp` is set; non-Value attributes stay Good.
|
|
- The initial sample on create, with queue size 1 and with queue size 10.
|
|
- The change fan-out while projected: a new stored value produces no Good notification.
|
|
- Sampling → Reporting.
|
|
- `Server.ResendData` (`i=12873`): the resent value is projected.
|
|
- AggregateFilter (Average, 200 ms): no Good aggregate over projected input.
|
|
|
|
A non-ordinary variable in the same manager and `i=2267` stay Good. Turning the projection off and touching the node
|
|
delivers the latest stored value Good, with no new driver value. In 2.0.1, `ReadAttributeAsync` and the
|
|
`MonitoredNode2` sampling paths fall back to the synchronous `ReadAttribute` → `ReadValueAttribute` when no
|
|
`OnReadValueAsync`/`OnSimpleReadValueAsync` is set (`NodeState.cs:4556`, `BaseVariableState.cs:2063`), and the product
|
|
sets neither. A queued value with `ignoreFilters: true` reaches an item with an absolute-deadband filter in both
|
|
directions, which is the T8 demotion/promotion queue.
|
|
|
|
## c./d. Provenance and first-delivery choice: fail as designed
|
|
|
|
**The custom sampled item can be installed.** The planned 2.0.1 creation hook (`MonitoredItemFactory` /
|
|
`MonitoredItemCreateDecision`) exists only on `AsyncCustomNodeManager` (`AsyncCustomNodeManager.cs:8550`). Its
|
|
`CustomNodeManager2` counterpart (`ICustomMonitoredItemManager`) is `internal`. But `CustomNodeManager2.m_monitoredItemManager`
|
|
is protected and assignable, and `MonitoredNodeMonitoredItemManager` is public and not sealed. A subclass that
|
|
re-implements `IMonitoredItemManager.CreateMonitoredItem` creates the item, and keeps the SDK's
|
|
`is MonitoredNodeMonitoredItemManager` checks and its internal lifecycle interface intact. That is the 1.5
|
|
"manager-subclass route". The spike confirms the custom item is the one in use.
|
|
|
|
**Object identity does not survive delivery.** In 2.0.1, `SentMessageQueue` hands every delivery a deep clone of the
|
|
cached message: a new message's first send (`SentMessageQueue.cs:310`), a prebuilt queued message (`:204`) and
|
|
Republish (`:357`) all go through `CoreUtils.Clone`. Notification payloads are pooled: `ReuseNotificationPayloads`
|
|
(`:529`) returns them to `MonitoredItemNotificationActivator` on acknowledge, eviction and overflow, and
|
|
`ResetForReuse` → `Initialize()` resets only `ClientHandle` and `Value`. So:
|
|
|
|
- A provenance table keyed by the `MonitoredItemNotification` the item created **never** matches a delivered
|
|
notification. The spike recorded 0 object hits.
|
|
- A first-delivery ledger keyed by the message object never matches either, because each Publish and Republish of the
|
|
same sequence number is a different object.
|
|
- Worse, object-keyed provenance would go **stale**: a pooled object stamped for an ordinary tag can be handed back
|
|
out to any other item's notification.
|
|
|
|
With `V2=false`, the spike shows Good ordinary-tag values delivered after demotion, both for samples queued before
|
|
demotion and for messages prebuilt before it.
|
|
|
|
Two further 2.0.1 facts change the test matrix:
|
|
|
|
- A Republish of a prebuilt but not-yet-sent sequence number is refused with `BadMessageNotAvailable`. "First
|
|
delivery through Republish" (spec §4.6 item 2) cannot occur for queued messages.
|
|
- An anonymous session cannot `TransferSubscriptions` another anonymous session's subscription
|
|
(`BadUserAccessDenied`). The transfer leg was not exercised.
|
|
|
|
## Alternative mechanism proven in the spike (`V2=true`), for the owner's go/no-go
|
|
|
|
This keeps the D4 semantics and spec §4.6's structure: a custom item stamps at build time, and an override of
|
|
`PublishAsync`/`RepublishAsync` decides at first delivery. It changes the two keys.
|
|
|
|
1. **Ledger keyed by `(SubscriptionId, SequenceNumber)`, not by object.** The first delivery of a sequence number
|
|
records Active or Standby. Every later delivery of that number, including Republish, applies the recorded
|
|
decision to the fresh clone the SDK returns. A Standby decision projects the clone, which is our own object, so no
|
|
cached SDK object is touched. Entries are pruned against the `AvailableSequenceNumbers` that Publish returns. The
|
|
ledger must be bounded per subscription and for dead subscriptions.
|
|
2. **Provenance token carried on `MonitoredItemNotification.Message`.** This is a public, non-encoded helper
|
|
reference that the SDK's `MemberwiseClone` copies into every clone. The custom item sets it, after the base
|
|
per-value publish has applied the timestamp filter, to a token holding the notification's `ClientHandle` and
|
|
final `DataValue`. At delivery a notification counts as ordinary-tag only if its token matches its own
|
|
`ClientHandle` and `DataValue`. A stale token left on a pooled object (`Initialize()` does not clear the helper)
|
|
therefore fails the match.
|
|
|
|
Spike evidence with `V2=true`:
|
|
|
|
- Good samples queued while Active, a ClientHandle change, then demotion: the first Publish carries
|
|
`BadOutOfService`/null, a non-ordinary item in the same message stays Good, and Republish returns the projected payload.
|
|
- Messages prebuilt while Active (`maxNotificationsPerPublish=1`), then demotion: the next Publish is projected, and
|
|
Republish returns the recorded projected choice.
|
|
- Good delivered while Active, then demotion: Republish returns the original Good. After an acknowledge, Republish
|
|
returns `BadMessageNotAvailable`.
|
|
|
|
Limits the owner should weigh:
|
|
|
|
- The token re-purposes an SDK helper property. The SDK server never reads it (no server use in the 2.0.1 source),
|
|
and the SDK version is pinned. A contract test would pin the clone-copies-helper behaviour so an SDK bump fails loudly.
|
|
- Stale-token rejection is by fingerprint. A false match needs the same `ClientHandle` *and* an identical `DataValue`
|
|
(value, status and both timestamps) on a pooled object. That is improbable but not impossible by construction.
|
|
- A durable-subscription restore (out of scope, spec §8) and a TransferSubscriptions under one identity are still
|
|
unexercised.
|
|
|
|
Other ways to close the gap, not spiked:
|
|
|
|
- (i) Migrate `OtOpcUaNodeManager` to `AsyncCustomNodeManager` to get the supported creation hook. This is a very
|
|
large change, and it still does not fix the clone/pool problem.
|
|
- (ii) Drop D4's queued/prebuilt guarantee and rely on the item-level projection alone. That is an owner decision on
|
|
D4 itself.
|