Merge #916/#917: stop sending stable_source_id (field 10 deprecated, never encoded/decoded); alarm-bearing raw tags are unsupported value nodes hidden from browse; review fixes

This commit is contained in:
Joseph Doherty
2026-11-28 10:43:51 -05:00
16 changed files with 548 additions and 21 deletions
+28 -4
View File
@@ -170,11 +170,35 @@ 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: one drops an optional field, the other drops a page item. 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 not exported as values (#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.
- The origin compiles it as an unsupported value node. GetMetadata, Read, Subscribe and HistoryRead on it answer
`Unsupported`, and writes are refused.
- **Browse does not list it**, and the same holds for any unsupported value node, such as a data type v1 cannot carry.
Every consumer build applies a browse page all or nothing and cannot materialise an `UnsupportedVariable`. Listing one
made the whole folder unbrowsable on the consumer (`BadNoCommunication`); the live gate found this.
- The node stays in the catalog, so an export rooted at it still compiles. Such a root grants nothing: the values are unsupported, and the condition sits under the tag's folder, not under the tag.
- The alarm itself is forwarded as a **condition** (A1–A4, see "Condition forwarding end to end"). Condition placements
do not depend on the value node.
G0, the v1 deploy and soak (#915), is still open; see the plan's §1.1.
## Remote history (runtime consumers)
@@ -647,7 +647,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 no longer value nodes (not listed by Browse, `Unsupported` on every value operation). 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,180 @@
# 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: compile the tag as an unsupported value node, and do not list it in Browse.** The rule is
`supported = plan.Alarm is null && …` in `Compile`. In `LocalDataServices.BrowseAsync`, a child with a `Source` and
`!Supported` is skipped.
- **Value operations.** Every value gate already keys on `LocalDataNode.Supported`: GetMetadata, Read and Subscribe
answer `Unsupported`, history requires `Supported`, and `DataWriteDispatchGate` refuses writes.
- **The node stays in the catalog.** Removing it 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.
- **Browse hides it. The live gate forced this.** The first attempt listed the tag as the existing v1
`UnsupportedVariable` kind, on the assumption that consumers skip that kind. They do not. `ProjectedNamespaceApplier`
hands a whole page to `IProjectedNamespacePageSink.TryApply`, and `OtOpcUaNodeManager.TryEnsureProjectedVariable`
rejects anything that is not a Folder, Variable or Tag (`OtOpcUaNodeManager.cs:4988`). So **one** `UnsupportedVariable`
child failed the whole page.
- On run `fu916-1`, browsing the consumer's `remote-opc` branch (the A4 Raw mapping of the opc-plc device, which holds
the alarm tag `EastTankYellow`) answered `BadNoCommunication`.
- The rig's `resolve` walk hit the same status, and `deploy` timed out on "deployed catalog and OPC UA namespace
identity".
- Every consumer build behaves this way, including the merged v1 consumers. Listing the node would therefore break any
mixed-version consumer. Not listing it works for all of them, because a page simply has one item fewer.
- **The same holds for any unsupported value node**, for example a data type v1 cannot carry. A pre-existing v1 origin
already broke consumer browse of a folder holding one, and the browse filter fixes that too.
Condition placements are independent of the value node. They need only their parent folder or equipment, so condition
forwarding is unchanged. The live gate below re-proves it on the alarm tag itself.
## 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 removes HighTemp from the device Browse page, and makes its GetMetadata item `status = Unsupported` with no value
and no lease.
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, and the only item dropped from the recorded device page.
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 its alarm config, stay supported `Variable`s; 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 |
Control run: with master's `src` restored over this branch's tests, the full Runtime.Tests `Feature=GrpcData` run failed
exactly the two new tests (#916, #917). All other tests passed (1021/1023).
The browse filter has its own red/green. With the `LocalDataServices` skip commented out, the real-origin Browse scenario
fails, both header-less and with the feature header (2 failures). With the skip restored, it passes.
## Gate runs (Release, on `70539999` + docs)
- Runtime.Tests `Feature=GrpcData`: **1023/1023 passed in 3 of 3 consecutive full runs.**
- Two earlier full runs each failed one test,
`GrpcDataConfiguredDiscoveryWireTests.Bad_null_sdk_notification_cannot_borrow_unproven_sample_evidence(different_timestamp)`:
it expected `BadUserAccessDenied` and got `BadNoCommunication`.
- This is the pre-existing intermittent **#920**, which reproduces on master and is being fixed separately. It passed
40/40 in isolation here.
- It is not touched by this change. Its fixture's nodes are all `Supported`, so the browse skip is a no-op there, and
the test exercises SDK notification queueing, not catalog metadata.
- The new 60-seed property test takes about 125 ms, the same order as the existing 60-seed UNS-only property test, so
it is not a load source.
- Host.Tests `Feature=GrpcData`: 210/210 passed. This includes `GrpcDataV1CompatibilityTests` (fake origin, untouched),
`GrpcDataV1RealOriginCompatibilityTests` and `GrpcDataHistoryWireTests`.
- `dotnet build -c Release` (whole solution): 0 warnings, 0 errors.
## Live gate (local grpc-data rig, `--conditions` profile, under the shared rig lock)
| Run | Build | Result |
|---|---|---|
| `fu916-1` | `b7ca71f1`: alarm tag listed as `UnsupportedVariable` | **Failed**, which is how the browse defect above was found. `deploy` timed out on "deployed catalog and OPC UA namespace identity". The seeder `resolve` got `BadNoCommunication`. The consumer's `remote-opc` folder answered `BadNoCommunication` to a Client.CLI browse, while the SOURCE leaves read Good on both pair members |
| `fu916-2` | interim | Discarded. The image was built while the source tree was being edited, so `verify_candidate` refused it ("running manifest does not match current image build inputs") |
| `fu916-3` | `70539999`: Browse skips unsupported value nodes | **PASS**, details below |
`fu916-3` ran `up --conditions` → `seed` → 85 s → `deploy --timeout 300` (ready) → `conditions_a3_smoke.py` → `conditions_scenarios.py` → `down`:
- `deploy --timeout 300` reached ready;
- `conditions_a3_smoke.py` reported `passed: true` (origin and consumer subscribers each saw Active/Unacknowledged → Active/Acknowledged);
- `conditions_scenarios.py` passed **A01–A08, 8/8**, `source_revision` `70539999`. A04 is the three placements of the alarm tag `EastTankYellow` (Raw `map-opc`, UNS `map-pumpa`/`map-pumpb`) and the UNS-only principal's records;
- `down` left 0 run containers.
A Client.CLI browse of consumer-1 then showed `remote-opc` → `FastUInt1` only, with the alarm tag not listed. Evidence is in
`artifacts/grpc-data/runs/fu916-3/evidence/` (`A4S-results.{json,md}`).
The live run does not separately probe `stable_source_id` over gRPC. #916 is pinned by the wire-level real-origin gate and
the 60-seed property test above.
## Review round 1 (2026-11-28)
| Finding | Fix | Red/green |
|---|---|---|
| #916 defence in depth: the mapper still encoded field 10 if anything set it | `DataProtoMapper.EncodeMetadata` never writes field 10. `DecodeMetadata` drops it, so a consumer of a pre-fix origin never retains it in `OriginMetadata`. The proto marks field 10 deprecated in a comment (not renumbered or removed) | `GrpcDataCodecTests.Stable_source_id_is_never_encoded_and_is_dropped_on_decode_916`: red with master's mapper, green with the fix. Engineering units (field 11) are the positive control |
| The fake-origin gate's goldens carry field 10 from its fake metadata, so the mapper change moves them | `GrpcDataV1Corrections.Expected` clears field 10 on the parsed Browse/GetMetadata goldens. That is the only edit, and the goldens are not re-recorded | `V1_correction_916_clears_only_stable_source_id`: the recording really carried field 10, an unedited golden re-serialises identically, and the other RPCs compare raw |
| Browse page boundaries | A skipped unsupported node no longer counts against the page's scan bound. The budget timeout still bounds the call. The skip therefore never yields an empty `Complete=false` page | `GrpcDataLocalConnectionTests.Browse_skips_unsupported_value_nodes_across_page_boundaries_917`, page size 2 over `[Speed, u, u, u, v, u, v]`. Red before the fix (an empty first-continuation page). Green after: `Speed, c3, c5` each exactly once, 2 non-empty pages, completes. Positive control: the skipped nodes are addressable (`Unsupported`) |
| Internal metadata still said an unsupported node was writable | `Add` compiles `writable &= supported` (raw tags, UNS references, virtual tags) | The #917 test fixture's alarm tag is now `ReadWrite`. `alarm.Metadata.Writable.ShouldBeFalse()` was red before the change and green after. Positive control: the same tag without its alarm is writable |
| Stale "browsable" test doc; "an export may still be rooted at it" | Both reworded. Such a root compiles, but grants nothing: the values are unsupported, and the condition placement sits under the tag's folder, not under the tag | — |
A consumer receiving an empty `Complete=false` page is no longer produced by this change. It can still come from the
pre-existing name filter. Whether the consumer resolver tolerates one was not tested end to end; it is suggested as a
follow-up.
Gates after the review, Release:
- Commons.Tests: 513/513.
- Runtime.Tests `Feature=GrpcData`: 1024/1024.
- Host.Tests `Feature=GrpcData`: 211/211. This includes both v1 gates.
- `dotnet build -c Release`: 0 warnings, 0 errors.
+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`, drops the alarm-bearing HighTemp from the device Browse page, and makes its GetMetadata
item `Unsupported`. A test pins that the edits are the only difference. See `V1-916-917.md`.
## 3. Gate runs