fix(grpc-data): #916/#917 review r1 — mapper never encodes/decodes stable_source_id (proto field deprecated); browse skip does not consume the scan bound (no empty incomplete pages); unsupported nodes never writable; comment fixes

This commit is contained in:
Joseph Doherty
2026-11-28 10:43:32 -05:00
parent 4a481cca1c
commit 053c69f1c8
10 changed files with 173 additions and 17 deletions
@@ -258,8 +258,8 @@ public static class DataProtoMapper
v.Dimensions.AddRange(x.Dimensions);
if (x.ArrayElementKind is { } elementKind)
v.ArrayElementKind = (W.ValueKind)elementKind;
if (x.StableSourceId is not null)
v.StableSourceId = x.StableSourceId;
// #916: field 10 (stable_source_id) is never encoded, whatever the caller set. It carried the origin's internal
// acquisition key (driver instance id + RawPath), and no consumer needs it.
if (x.EngineeringUnits is not null)
v.EngineeringUnits = x.EngineeringUnits;
// H2: the service strips this (and the HistoryRead bit) from every response of a call that did not negotiate history.
@@ -288,7 +288,8 @@ public static class DataProtoMapper
// A2b method bits are condition grants, never node operations, so a metadata item carrying them is masked too.
(DataOperations)(x.AllowedOperations & (uint)DataOperationSets.Understood & ~(uint)DataOperationSets.ConditionGrants),
x.CatalogRevision,
x.HasStableSourceId ? x.StableSourceId : null,
// #916: dropped on decode too, so a consumer of a pre-fix origin never retains it in OriginMetadata.
null,
x.HasEngineeringUnits ? x.EngineeringUnits : null,
x.IsStale,
x.HasArrayElementKind ? (DataValueKind)x.ArrayElementKind : null,
@@ -161,6 +161,8 @@ message Metadata {
bool writable = 7;
uint32 allowed_operations = 8;
int64 catalog_revision = 9;
// DEPRECATED (#916): never sent and ignored on receipt. It carried the origin's internal acquisition key (driver
// instance id + RawPath). Kept so the field number is never reused.
optional string stable_source_id = 10;
optional string engineering_units = 11;
bool is_stale = 12;
@@ -394,16 +394,19 @@ public sealed partial class LocalDataServices : IDataConnectionFactory
long bytes = 256;
var maximum = Math.Min(request.Budget.MaxItems, limits.MaxPageItems);
var scanned = 0;
while (offset < children.Count && page.Count < maximum && scanned++ < maximum)
while (offset < children.Count && page.Count < maximum && scanned < maximum)
{
cancellationToken.ThrowIfCancellationRequested();
if (Expired(start, request.Budget)) return Task.FromResult(Empty(DataItemStatus.Unavailable));
var child = children[offset++];
// #917: an unsupported value node (an alarm-bearing tag, or a data type v1 cannot carry) is never listed. Every
// consumer build applies a browse page all-or-nothing and cannot materialise one, so listing it made the whole
// folder unbrowsable on the consumer (BadNoCommunication). It stays addressable: GetMetadata/Read/Subscribe on
// it answer Unsupported, and an export may still be rooted at it.
// folder unbrowsable on the consumer (BadNoCommunication). It stays addressable (GetMetadata/Read/Subscribe on it
// answer Unsupported). An export rooted at it still compiles but grants nothing. A skipped node is not counted
// against the scan bound (it costs one check; the budget timeout above still bounds the call), so the skip never
// yields an empty Complete=false page.
if (child.Source is not null && !child.Supported) continue;
scanned++;
if ((request.Filter is { Length: > 0 } filter && !child.Metadata.BrowseName.Contains(filter, StringComparison.Ordinal))
|| !Allowed(catalog, context, child, DataOperations.Browse)) continue;
var metadata = Metadata(catalog, context, target, child);
@@ -92,6 +92,7 @@ public sealed partial class LocalExportCatalog
BackingSourceKey? source = null, DataValueKind valueKind = DataValueKind.Null, bool writable = false,
bool array = false, uint? length = null, bool supported = true, bool enabled = true)
{
writable &= supported; // #917 review: an unsupported value node is never writable, not even in internal metadata
var operations = source is null ? navigation : data | (writable ? DataOperations.Write : DataOperations.None);
var metadata = new DataMetadata(view, name, source is null ? "Folder" : supported ? "Variable" : "UnsupportedVariable",
array && supported ? DataValueKind.Array : valueKind, array && supported ? 1 : -1,
@@ -137,8 +138,9 @@ public sealed partial class LocalExportCatalog
var kind = ValueKind(plan.DataType);
// #917: an alarm-bearing tag never gets a value (DriverHostActor keeps it out of the value fan-out; #896 gives it
// no UNS variable), so it is an unsupported value node: Browse does not list it (LocalDataServices) and every
// value operation answers Unsupported, instead of a Variable a consumer would wait on forever. The node is KEPT
// (an export may be rooted at it); its alarm is forwarded as a condition (A1–A4), never as a value.
// value operation answers Unsupported, instead of a Variable a consumer would wait on forever. The node is KEPT so
// an export rooted at it still compiles, but such a root grants nothing: its values are unsupported and its
// condition placement sits under its folder, not under the tag. The alarm is forwarded as a condition (A1–A4).
var supported = plan.Alarm is null && kind != DataValueKind.Unspecified
&& (!plan.IsArray || DataValue.IsSupportedArrayElementKind(kind));
var rawView = View(DataRealm.Raw, plan.NodeId, scope);