fix(grpc-data): A4 #930/#931 — in-stream condition retries (no refresh storm), ConditionCapacity recovery, reconnect backoff, ledger, single RefreshRequired, parked-runner release; condition diagnostics core

#930 N2: an Unavailable mapping (refused item, failed root, snapshot timeout) is retried on the OPEN stream by
re-adding its item (AddSubscriptionItems) on its own backoff — definitive refusals (Denied/NotFound/Unsupported)
on LongRetryDelay (5 min, doubling to 4x), transient ones on the snapshot timeout x 2^n (<= 8x) — so healthy
mappings are never re-snapshotted for it; an incomplete barrier whose incomplete set equals the previous barrier's
sends no RefreshRequired. N3: ConditionCapacity is retried in-stream on the long timer and recovers.
#931 N4 exponential reconnect backoff (MaxReconnectDelay 60 s); N5 held-but-unlisted keys charged beside known
claims (overlapping unknown ones) + SetMaterialised cap report; N6 method calls read Serving without _gate;
N7 a capacity reset that removed conditions sends no second RefreshRequired; N8 a parked runner is released once
its removal finished.
A4 diagnostics core: DataConnectionConditionDiagnostics (side-labelled items/resyncs/capacity/method metrics, new
refresh_required counter, consumer + origin evidence), Commons contracts, DI + deployment-runtime + driver-host wiring.

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-11-24 23:03:53 -05:00
parent 9143804987
commit 78eb98ea13
15 changed files with 920 additions and 105 deletions
@@ -48,7 +48,48 @@ public sealed record DataConnectionDiagnosticsSnapshot(
long? HistoryReadsGood = null,
long? HistoryReadsUncertain = null,
long? HistoryReadsBad = null,
int? OpenRemoteContinuations = null);
int? OpenRemoteContinuations = null,
// A4 consumer-side imported-condition evidence (null = no condition-bearing mapping on this connection, or an older sender).
ConsumerConditionDiagnostics? Conditions = null);
/// <summary>A4: one condition-bearing mapping of a consumer connection's condition stream.</summary>
/// <param name="MappingId">The mapping.</param>
/// <param name="Status">Pending | Snapshotting | Complete | Unavailable | ConditionCapacity.</param>
/// <param name="Observed">The last count the origin reported or listed for it (a snapshot total, or the committed set).</param>
/// <param name="Limit">The mapping's <c>MaxConditions</c>.</param>
/// <param name="Refusal">The origin's last refusal status for its item or root (null when not refused).</param>
public sealed record ConditionMappingDiagnostics(string MappingId, string Status, int Observed, int Limit, string? Refusal = null);
/// <summary>A4: consumer evidence of one connection's imported conditions (plan §6 "AdminUI").</summary>
/// <param name="StreamState">idle (no event subscriber) | connecting | snapshotting | live.</param>
/// <param name="SnapshotAtUtc">When the connection's last snapshot barrier passed (null: none since start).</param>
/// <param name="Materialised">Imported conditions this node holds for the connection.</param>
/// <param name="StateUnknown">Of those, how many carry <c>state_known = false</c> (never shown known-inactive).</param>
/// <param name="RefreshRequired">RefreshRequired requests made for the connection since start (explicit, plus each removal batch).</param>
/// <param name="Resyncs">Condition streams that ended and re-snapshotted since start.</param>
/// <param name="CapacityRejections">Mappings reset to ConditionCapacity since start.</param>
/// <param name="Mappings">Per mapping: status, observed count vs limit, refusal.</param>
/// <param name="ChargedConditions">Imported conditions charged against this node's host caps (every connection).</param>
/// <param name="HostConditionLimit">The node-wide condition cap implied by <c>MaxImportedConditionNodes</c>/<c>Bytes</c>.</param>
public sealed record ConsumerConditionDiagnostics(string StreamState, DateTime? SnapshotAtUtc, int Materialised, int StateUnknown,
long RefreshRequired, long Resyncs, long CapacityRejections, IReadOnlyList<ConditionMappingDiagnostics> Mappings,
long ChargedConditions, long HostConditionLimit, ConditionMethodCounts Methods);
/// <summary>A4: remote condition method calls by outcome class (from <c>DataWriteState</c>).</summary>
public sealed record ConditionMethodCounts(long Succeeded, long Rejected, long Failed, long Unknown);
/// <summary>A4: origin-side evidence of the root-scoped condition items this node serves to peers.</summary>
/// <param name="OpenItems">Open condition items (all peers).</param>
/// <param name="LargestListing">The largest current listing among the open items (their last snapshot's total).</param>
/// <param name="ListingLimit">That item's <c>MaxConditions</c> limit (0 when no item is open).</param>
/// <param name="LastSnapshotAtUtc">When an item last took a snapshot (null: none since start).</param>
/// <param name="Resyncs">Items re-snapshotted after a hub reader reset since start.</param>
/// <param name="CapacityRejections">Item snapshots refused as over the item's limit since start.</param>
/// <param name="UnsignalledConditions">Native conditions whose initial state was never signalled (served <c>state_known = false</c>);
/// null when the node has no condition hub.</param>
/// <param name="Methods">Remote condition method calls served, by outcome class.</param>
public sealed record OriginConditionDiagnostics(int OpenItems, int LargestListing, int ListingLimit, DateTime? LastSnapshotAtUtc,
long Resyncs, long CapacityRejections, int? UnsignalledConditions, ConditionMethodCounts Methods);
/// <summary>H4 origin-side remote-history evidence for one node (what it serves to peers over data connections).</summary>
/// <param name="Available">The node has a historian backend and can serve remote history.</param>
@@ -51,6 +51,10 @@ public sealed record DriverInstanceDiagnostics(
/// H4: remote history this node serves to data-connection peers. Null from a sender built before H4 or when the node
/// runs no data-connection services.
/// </param>
/// <param name="OriginConditions">
/// A4: root-scoped condition items this node serves to data-connection peers. Null from a sender built before A4 or when the
/// node runs no data-connection services.
/// </param>
public sealed record NodeDiagnosticsSnapshot(
NodeId NodeId,
RevisionHash? CurrentRevision,
@@ -59,4 +63,5 @@ public sealed record NodeDiagnosticsSnapshot(
bool RunningFromCache = false,
IReadOnlyList<DataConnectionDiagnosticsSnapshot>? DataConnections = null,
IReadOnlyDictionary<string, ZB.MOM.WW.OtOpcUa.Core.Abstractions.DataConnections.DataOperations>? DroppedExportOperations = null,
OriginHistoryDiagnostics? OriginHistory = null);
OriginHistoryDiagnostics? OriginHistory = null,
OriginConditionDiagnostics? OriginConditions = null);