fix(grpc-data): stop sending stable_source_id (#916); export alarm-bearing raw tags as UnsupportedVariable (#917)

#916: Metadata.stable_source_id carried the internal acquisition key
(<len>:<driverInstanceId><RawPath>) on every export, so a UNS-only peer learned
driver ids and RawPaths. No consumer uses the field beyond byte accounting; it is
optional on the wire and absent decodes as null. It is now never sent; the
internal BackingSourceKey is unchanged.

#917: alarm-bearing raw tags never get a value but were exported as Variables.
They are now the existing explicit UnsupportedVariable kind (browsable,
Unsupported on every value op). The node is kept so exports rooted at it still
compile and A1 condition placements are unaffected.

The real-origin v1 goldens are not re-recorded: GrpcDataV1RealOriginCorrections
applies exactly these two edits to the parsed goldens, pinned by a test.
Evidence: docs/plans/evidence/grpc-data-ext/V1-916-917.md
This commit is contained in:
Joseph Doherty
2026-11-28 09:23:34 -05:00
parent 05f431f5d8
commit b7ca71f188
10 changed files with 325 additions and 12 deletions
+25 -4
View File
@@ -170,11 +170,32 @@ advertisement and a per-call request header, `x-otopcua-data-features`, whose va
- The new RPCs (`HistoryRead`, `CallConditionMethod`) answer `FailedPrecondition("feature not negotiated")`. A
history-only call is also refused `CallConditionMethod`.
- Header-less goldens (`*Goldens.cs`) and the recorded-v1-client gates (`GrpcDataV1CompatibilityTests`,
`GrpcDataV1RealOriginCompatibilityTests`) pin the v1 bytes. Every phase ran them with an empty goldens diff.
`GrpcDataV1RealOriginCompatibilityTests`) pin the v1 bytes. Every phase ran them with an empty goldens diff. The two
pre-deploy corrections below are the only deliberate differences. The real-origin gate applies them to the recorded
goldens in `GrpcDataV1RealOriginCorrections`; the goldens are never re-recorded.
Fix two v1 defects before any v1 deploy. #916: `stable_source_id` leaks the driver id and RawPath to UNS-only peers.
#917: v1 exports alarm-bearing raw tags as variables that never get a value. G0, the v1 deploy and soak (#915), is still
open; see the plan's §1.1.
### What an origin exports (v1 corrections #916, #917)
v1 was merged but not deployed (#915), so two defects were fixed in v1 itself. Header-less callers get the fix too.
Neither change alters the wire shape. Evidence: `docs/plans/evidence/grpc-data-ext/V1-916-917.md`.
- **No `Metadata.stable_source_id` (#916).** The origin never sends field 10. It used to carry the internal acquisition key,
which for a driver tag is `<len>:<driverInstanceId><RawPath>`. That disclosed driver ids and RawPaths to peers holding
only a UNS export.
- No consumer used the field except for byte accounting, so it was dropped rather than replaced by an opaque id. A
stable opaque id would only let a peer correlate Raw and UNS nodes.
- The field is `optional`. Old consumers decode its absence as null, so every version mix works.
- Conditions dedupe on the keyed `condition_key` instead.
- Internally the origin still keys acquisition on the unchanged `BackingSourceKey`.
- **Alarm-bearing raw tags are `UnsupportedVariable` (#917).** A tag with an alarm config never gets a value: the driver
host keeps it out of the value fan-out, and #896 gives it no UNS variable.
- It is still browsable, so exports rooted at it and its folder's condition placement still work.
- Its node kind is `UnsupportedVariable` and its value kind `NULL`, with Browse as the only operation. Read, Subscribe,
GetMetadata and HistoryRead answer `Unsupported`, and writes are refused.
- Consumers already skip that kind, so nothing waits on a value that never comes.
- The alarm itself is forwarded as a **condition** (A1–A4, see "Condition forwarding end to end").
G0, the v1 deploy and soak (#915), is still open; see the plan's §1.1.
## Remote history (runtime consumers)
@@ -614,7 +614,9 @@ per-origin-cluster `${secret:}` of at least 32 UTF-8 bytes, identical on both pa
- It cannot be dictionary-reversed from guessable paths. An unkeyed hash was rejected for that reason.
- If the secret is absent, the origin advertises no `conditions` capability (fail closed, with a diagnostic).
> **Pre-existing v1 findings (not fixed here; filed as #916 and #917):**
> **Pre-existing v1 findings (not fixed here; filed as #916 and #917).** *Update 2026-11-28: both are fixed in v1 before
> deploy. `stable_source_id` is no longer sent, and alarm-bearing raw tags are exported as `UnsupportedVariable`. See
> `docs/plans/evidence/grpc-data-ext/V1-916-917.md`.*
> 1. #916 — `type:review-finding`, security: v1 already sends `stable_source_id` = driver id + RawPath on **UNS reference variables**
> to UNS-only principals (same code path).
> 2. #917 — `type:bug`: v1 exports alarm-bearing raw tags as `Variable` (`LocalExportCatalog.Compilation.cs:120-130` has no Alarm
@@ -0,0 +1,111 @@
# v1 pre-deploy corrections: #916 and #917
Two defects in gRPC data connections v1 (merged `95c5e484`, never deployed, #915), found while planning remote history and
alarm forwarding (plan §5.2, "Pre-existing v1 findings"; N3). Both are fixed in the v1 origin catalog
(`LocalExportCatalog.Compilation.cs`), so header-less v1 callers get the fix too. Neither changes the wire shape.
## #916: `Metadata.stable_source_id` disclosed driver ids and RawPaths
**Defect.** `Compile` put `BackingSourceKey.StableSourceId` into `Metadata.stable_source_id` (proto field 10) on every value
node, in every realm. For a driver source that key is `SourceKey.ForDriver`'s `<len>:<driverInstanceId><driver reference>`,
and the reference is the RawPath. So a peer holding only a UNS export learned the origin's driver instance ids and RawPaths.
The recorded real-origin golden shows the leak: `Browse/uns` carries `8:driver-1Plant/Modbus/dev1/Speed` on the UNS Speed
reference.
**Consumer-side uses of the field (all of them).** Every read of `DataMetadata.StableSourceId` / `Metadata.stable_source_id`
in `src/`:
| Site | Use |
|---|---|
| `DataProtoMapper.EncodeMetadata` / `DecodeMetadata` | Copies it when present. Decodes absence as `null` (`HasStableSourceId`). |
| `ProjectedProofSize.cs:21` | Byte accounting of a proof. |
| `OtOpcUaNodeManager.cs:4439` | Byte accounting of a projected definition. |
Nothing dedupes on it, compares it, keys on it, or exposes it to the consumer's own OPC UA clients. It is not an OPC UA
property, not shown in the AdminUI and not logged. `DataSourceIdentity.StableSourceId` (Core.Abstractions) has no users.
A1–A4 dedupe conditions by the keyed `condition_key` (`ConditionKeys`), never by this field.
**Decision: omit the field on every export, in every realm.** We considered two alternatives:
- *A keyed opaque id* (HMAC like `condition_key`). Rejected. No consumer uses the field, so an opaque value would only be a
stable cross-realm correlator: it would tell a peer holding both a Raw and a UNS export that two nodes share a source.
It would also depend on `DataConnections:ConditionKeySecret`, which is optional, so the field would come and go with an
unrelated setting.
- *Omit only where the realm differs.* Rejected. A Raw export also does not need the internal key, and keeping one rule
is simpler to audit.
**Mixed versions.** Field 10 is `optional`. An old consumer decodes its absence as `null` and uses it for nothing but size
accounting, so an upgraded origin works with old consumers, and a new consumer works with an old origin (it ignores
the value).
One effect to know about: consumers compare whole `DataMetadata` records, field 10 included, when they renew a
projection (`ProjectedCatalogCache.SameMetadata`, `OtOpcUaNodeManager` projected-variable reuse). An origin pair running a
pre-fix build on one member and this build on the other would therefore look like a metadata change at failover, and the
node would be re-projected once. No pre-fix build was ever deployed (#915), so this cannot happen in the field.
The internal `BackingSourceKey` (on `LocalDataNode.Source`) is unchanged: acquisition, sample routing,
partitioning, write routes and `SourceKey.TryDriver` still use it.
## #917: alarm-bearing raw tags were exported as Variables that never get a value
**Defect.** `Compile` added every raw tag plan as a `Variable` with Read/Subscribe/HistoryRead. An alarm-bearing tag
(`RawTagPlan.Alarm != null`) never receives a value, because `DriverHostActor` keeps it out of the value fan-out and #896
gives it no UNS variable. So a consumer that imported one read `BadWaitingForInitialData` forever.
**Are these tags now forwarded as conditions?** Yes. Since A1–A4, every alarm-bearing raw tag gets a native condition
placement at its RawPath in Raw (parented at its device or group folder). Every UNS reference to one gets a placement at
the reserved `Area/Line/Equipment/EffectiveName` id, parented at the equipment. Both are listed through root-scoped
condition items and keyed by `condition_key`, and the consumer materialises them in its `mapped/conditions` namespace.
The alarm is therefore served as a condition, never as a value.
**Decision: export the tag as the existing explicit `UnsupportedVariable` kind** (`supported = plan.Alarm is null && …`).
We did not remove the node, for three reasons:
- `UnsupportedVariable` is already a v1 kind (used for unmapped data types). Old consumers already treat it as "not a
value node" (`ProjectedCatalogCache.IsValueNode`, `OtOpcUaNodeManager.cs:4988`), so no consumer materialises or waits on
it.
- Every value gate already keys on `LocalDataNode.Supported`. Read, Subscribe and GetMetadata answer `Unsupported`.
History requires `Supported`. Writes are refused by `DataWriteDispatchGate`. Browse masks the operations to Browse.
- Removing the node would turn a deployable `DataExport` rooted at that tag (`RootKind = RawTag` is valid) into a catalog
compile failure ("Export has no valid origin root") for the whole cluster.
Condition placements are independent of the value node. They need only their parent folder or equipment, so condition
forwarding is unchanged.
## The v1 gate: goldens not re-recorded
`GrpcDataV1RealOriginGoldens` (recorded on `1086593a`) captured both defects. The goldens stay as recorded. The new
`GrpcDataV1RealOriginCorrections.Expected(scenario)` applies exactly two edits to the parsed golden message and
re-serialises it:
- it clears `stable_source_id` on every Metadata;
- it makes HighTemp `UnsupportedVariable` / `VALUE_KIND_NULL` / `allowed_operations = 1` in Browse pages, and
`status = Unsupported` with no value and no lease in GetMetadata.
The test then compares the real origin's header-less bytes with the result. Only Browse, Browse/uns and GetMetadata are
corrected. GetCapabilities, Read, Write, Write/no-write-grant and Subscribe are compared with the raw goldens, unchanged.
`V1_corrections_916_917_are_exact_and_the_recorded_leak_was_real` pins the method:
- an unedited golden re-serialises byte-identically, so an edit is the only possible difference;
- the corrected scenarios really differ from the goldens, and the others really do not;
- the recorded UNS browse really contains the leaked `driver-1Plant/Modbus/dev1/`, and no corrected scenario does;
- HighTemp is the single Unsupported item in GetMetadata.
The fake-origin gate `GrpcDataV1CompatibilityTests` is untouched and green.
Before the fix, the decoded diff of real-origin output against the goldens was exactly these edits: field 10 on every
value node of Browse, Browse/uns and GetMetadata, plus the HighTemp entries.
## Red/green
| Test | Before the fix (master behaviour) | After |
|---|---|---|
| `GrpcDataConditionPlacementTests.No_exported_metadata_carries_the_internal_source_key_916` (60 generated topologies; encoded metadata of every node; UNS bytes searched for every driver id and RawPath; positive control: the internal key still contains them) | **Failed**: `node.Metadata.StableSourceId should be null` | Pass |
| `GrpcDataConditionPlacementTests.An_alarm_bearing_raw_tag_is_an_UnsupportedVariable_and_keeps_its_condition_placements_917` (positive controls: a plain tag and the same tag without alarm config stay `Variable`; 3 placements and the Raw listing intact; an export rooted at the alarm tag compiles) | **Failed**: alarm tag `Supported` was true | Pass |
| `GrpcDataV1RealOriginCompatibilityTests` header-less + feature-header Browse, Browse/uns, GetMetadata vs the raw goldens | Pass on master; fail with the fix | Compared with `Expected(...)`: pass |
## Gate runs (Release)
- Runtime.Tests `Feature=GrpcData`: 1023/1023 passed.
- Host.Tests `Feature=GrpcData`: 210/210 passed. This includes `GrpcDataV1CompatibilityTests`,
`GrpcDataV1RealOriginCompatibilityTests` and `GrpcDataHistoryWireTests`.
+4
View File
@@ -220,6 +220,10 @@ pre-H2 master `1086593a`.
2. Still expect these exact bytes **without** the header.
3. Expect them **with** the header too, until the server advertises the feature in `SupportedFeatures`.
4. Never re-record.
- **Pre-deploy corrections (#916, #917; 2026-11-28).** Two deliberate v1 fixes change real-origin Browse, Browse/uns and
GetMetadata. `GrpcDataV1RealOriginCorrections.Expected` applies exactly those edits to the parsed, unre-recorded golden:
it clears `stable_source_id` and makes the alarm-bearing HighTemp `UnsupportedVariable` / `Unsupported`. A test pins that
the edits are the only difference. See `V1-916-917.md`.
## 3. Gate runs