Commit Graph

3199 Commits

Author SHA1 Message Date
Joseph Doherty 9ea50c11b2 test(grpc-data): A4 live scenarios part 2 harness — A03 origin failover (same-incarnation stream reset via mapping revision bump, clear-and-re-raise in the gap, RefreshRequired, BadEventIdUnknown, refreshed EventId acks), A06 consumer Primary change across both nodes + second CONSUMER principal fixture-cli-alt, A07 consumer restart refresh-vs-barrier; CLI alarms prints EventType (names RefreshStart/End/Required) 2026-11-25 01:44:58 -05:00
Joseph Doherty 0cac09cee3 fix(grpc-data): A4 review r1 — AdminUI helpers null-safe + doc comments restored; metric descriptions name both sides; docs: S1/S2/S3 behaviour, RefreshRequired only on a changed incomplete set, SourceName vs runtime status (S4), scripted Good = applied, A4-docs citations 2026-11-25 00:22:54 -05:00
Joseph Doherty c93290d0a0 fix(grpc-data): A4 review r1 — B1 unique capacity-reset command id (fake now rejects reused ids); S1 retry timeout keeps buffer+claim; S2 late ack of a superseded re-add removes the orphan + InvalidArgument backstop; S3 overlap only for keys the mapping itself held; S4 SourceName independent of runtime status; NITs resyncs count opened streams, prune removed connections' counters 2026-11-25 00:20:26 -05:00
Joseph Doherty b2fab8b075 test(grpc-data): #928 — overflow test asserted one of two legal outcomes; deterministic Reset test + either-outcome contract test; DataConnections.md A4 reconcile (#930 retries, condition metrics, AdminUI fields)
The origin item sees a hub eviction only at its next hub read: Reset if the last snapshot chunk is
still undelivered, otherwise a silent fresh snapshot on the same stream (both per A2, both loss-free
since the A3 consumer swaps a buffered re-snapshot in as a full replacement). Since A2 review S5 the
3,000-record snapshot is 59 chunks and the silent path wins when run alone (fails 3/3 alone at the A2
merge too; passes in its class). No product change. Also fixes the stale ack/confirm/shelve comment on
ConditionMethodTimeoutMilliseconds.
2026-11-25 00:08:06 -05:00
Joseph Doherty f1f9f49813 feat(adminui): A4 imported/served condition diagnostics on the data-connections page
Per connection: stream state, last snapshot, conditions and state-unknown count, node budget vs host caps, RefreshRequired,
resyncs, capacity rejections, method outcomes, per-mapping status / observed vs MaxConditions (80% warning) / refusal.
Per node (origin panel): open condition items, largest listing vs its limit, last snapshot, resyncs, capacity
rejections, unsignalled (state unknown), methods served.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-24 23:06:51 -05:00
Joseph Doherty 78eb98ea13 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>
2026-11-24 23:03:53 -05:00
Joseph Doherty c8b35d494f fix(grpc-data): A3 verification r2 — N1 runner predecessor chain dropped after hand-over + stopped runner clears its record sets; correct the SentMessageQueue clone comment and pin the EventFieldList MemberwiseClone dependency 2026-11-24 22:26:09 -05:00
Joseph Doherty b884db5fb1 perf(grpc-data): A3 r2 L2 — EventId window back to the plan's 8; measure the retained heap, not GC.GetTotalMemory
GC.GetTotalMemory on .NET 10 regions reported +92 or +218 MiB (bimodal) for the same
state; GCMemoryInfo heap size and a heap dump (136 MB of objects, eeheap allocated
136,318,696 / committed 236,208,128) show the extra was committed-but-free regions.
The harness now takes HeapSizeBytes-FragmentedBytes after a full blocking GC and the
settled working set, and asserts BOTH <= 200 MiB. Worst case (2 placements, 8 slots,
3 event items, Live+Buffer): heap +106.5 MiB, WS +151.3 MiB max of 3 runs.
BytesPerCondition 230,000 -> 160,000 (max WS/condition 158,629, rounded up);
MaxImportedConditionBytes default 160,000 x 2,500 = 400,000,000 B (~381 MiB).
2026-11-24 21:46:21 -05:00
Joseph Doherty 6be0b8dc4b fix(grpc-data): A3 r2 — a released marked EventFieldList never re-enters the SDK's process-wide pool
SDK 2.0.1 pools EventFieldList (PooledEncodeableType); SentMessageQueue Reuse()s every
list of an acknowledged message and the base ReuseCore returns it, whatever its runtime
type, to the shared stock pool. A recycled ProjectedEventFieldList was then rented by any
server's GetEventFields (an unrelated session's RefreshStart/RefreshEnd or local event)
still carrying an imported condition's marker, and ProjectedNotificationRewriter dropped it
when that marker's gate denied. Root cause of the intermittent OI ConditionRefresh failures
(#854/#855 classes). Mirrors ProjectedSdkNotification on the data path: override ReuseCore,
clear the marker, never return to the pool; a released (marker-less) list fails closed.
2026-11-24 21:36:47 -05:00
Joseph Doherty e5e0780f5e perf(grpc-data): A3b review S5 — BytesPerCondition from the worst-case L2 harness (max 228,353 B ⇒ 230,000; cap ≈ 548 MiB) 2026-11-24 20:05:26 -05:00
Joseph Doherty 72dece7f45 fix(grpc-data): A3b review r1 — per-item results after base.Call (S1), mapping timeout honoured + transport-known BadTimeout (S2), unsent vs OutcomeUnknown + origin failure status (S3), per-connection sub-limit + dispatch floor (S4), N1/N2/N3/N7/N8; tests: real-path L3, worst-case L2 harness, RefreshRequired over the wire, Confirm guards isolated, gate placements/realm, slots, standby, faults, principals 2026-11-24 19:59:21 -05:00
Joseph Doherty 14343bf086 fix(grpc-data): A3a review r1 — condition-bearing projected folders are event notifiers from materialisation (folder-only demand), null-safe revalidation log; NM tests: B3 revalidation + demand release, S1 rebuild, deviation 3/6/8, S2 verdict TTL, A3-SEC delivery gate isolated (DroppedOnPublish 0) 2026-11-24 18:46:11 -05:00
Joseph Doherty 69aeeb770b fix(grpc-data): A3a review r1 — buffered in-stream re-snapshots, late completion + stale-on-incomplete + bounded retry, Primary-pinned condition streams, node-wide host-cap ledger, runner hand-over after stop, metadata failure Unavailable; NM: revalidation through the imported gate, demand released first, rebuild unwires, instance-keyed promotion, incremental folder index, verdict TTL + expiry, removal RefreshRequired, chunked refresh/replay, folder-only demand
Runtime tests: B1 multi-frame + capacity re-snapshot, B2 late completion / stale-on-incomplete / refused retry, B4 cross-connection / reverse order / records>total / delta growth, S3/S4 hand-over, S6, deviation 9, S2 IsActive generation; absence assertions now follow must-arrive controls.
2026-11-24 18:38:07 -05:00
Joseph Doherty 82ecc1164c fix(grpc-data): A3 condition items carry the origin's canonical root view (metadata asked like the browse resolver) — live a3b-cond-2 found map-uns refused Denied 2026-11-24 17:48:16 -05:00
Joseph Doherty 404a664ca3 fix(grpc-data): A3 ProjectedConditionAccess logs through the host logger (was NullLogger in production) + stream/item/barrier diagnostics 2026-11-24 17:37:23 -05:00
Joseph Doherty fecb178efa perf(grpc-data): A3 L2 in-process memory harness (1,000 imported conditions, one mapping) + MaxImportedConditionBytes from the measurement (205,665 B × 2,500) 2026-11-24 17:23:40 -05:00
Joseph Doherty 28098a8d32 feat(grpc-data): A3b consumer method port — per-caller AlarmAcknowledge/AlarmConfirm gate, mapping timeout, stream serving incarnation, lease condition methods, host wiring 2026-11-24 17:11:05 -05:00
Joseph Doherty c1be5725b9 feat(grpc-data): A3b ICallAsyncNodeManager — claim imported-condition calls, base.Call unchanged for the rest, lock-free remote dispatch, EventId registry gate + N6 re-binding 2026-11-24 17:11:05 -05:00
Joseph Doherty de381157cf test(grpc-data): A3a over-the-wire imported-condition events (exactly-once, identity, A3-SEC, child Read, N4, N7, resync, T2) + OwnsNamespace covers mapped/conditions 2026-11-24 16:35:01 -05:00
Joseph Doherty 8d6c94a3b3 feat(host): wire A3 ProjectedConditionAccess (DI, node-manager sink, host condition caps) 2026-11-24 16:30:03 -05:00
Joseph Doherty 4f6e26dd4e feat(grpc-data): A3 ProjectedConditionAccess — per-connection demand, snapshot barrier, condition budget, version rule, re-snapshot lifetime, mapping gate 2026-11-24 16:28:45 -05:00
Joseph Doherty 1ff18caa79 feat(opcua): A3 ProjectedConditionRegistry — mapped/conditions namespace, lazy symmetric notifier wiring, gated marked delivery, publish-time re-gating, refresh replay 2026-11-24 16:25:17 -05:00
Joseph Doherty a75ea95e25 refactor(opcua): share condition node factory + state-apply/delta gate (A3 §5.3 prerequisites) 2026-11-24 16:19:24 -05:00
Joseph Doherty e15bd7c9f9 feat(grpc-data): A3 IProjectedConditionAccess / IProjectedConditionSink contracts 2026-11-24 16:18:25 -05:00
Joseph Doherty 91f1f72971 fix(grpc-data): A2b security review — outcome-unknown after dispatch, per-principal registry cap, audit category + sanitising, monotonic activation sequence, bounded Lock wait, consumer cancel = OutcomeUnknown 2026-11-24 15:41:24 -05:00
Joseph Doherty c709fbc1c4 test(grpc-data): A2 review N5 — the waiter test counts condition-queue waits only (red on revert: 19 vs ≤ 1) 2026-11-24 14:59:01 -05:00
Joseph Doherty 20bf937259 fix(grpc-data): A2 review S2/S3/S4/S5/N1/N2/N4/N5/N6 — bounded, effective-named, fair condition streams
S2: one condition item per (stream, root) (InvalidArgument + diagnostic), SubscriptionSessionLimits
    .MaxConditionItems (32) per stream (LimitExceeded), each snapshot's estimated bytes charged against
    the principal's snapshot memory budget until its last chunk is delivered (refused ⇒ retried).
S3: a native condition in a UNS listing is named by its placement's browse name (effective name);
    a raw-derived message (raw name, raw leaf, RawPath) is replaced by it.
S4: the item limit rides ConditionItemScope and is re-read with every listing.
S5: chunk budget = min(256 KiB, MaxPendingBytes, MaxMessageBytes) − frame overhead; an oversized
    record's free text is truncated (no split surrogate); one that cannot fit resets with a diagnostic.
N1: one queued v1 frame after every 8 condition frames.  N2: removal/snapshot-begin bypass rule documented.
N4: min(limit, DefaultMaxConditionsPerHold) per Lock hold.  N5: losing channel waits are reused.
N6: ConditionTestAssertions deleted; probe seams reduced to three primitives; class doc moved back.
S1 (tests): the fixture 'deploy' test renamed to what it is (a listing swap without an attempt);
    a real LocalCatalogCoordinator republish ends the stream.
2026-11-24 14:56:49 -05:00
Joseph Doherty 7694eb67b2 perf(grpc-data): A2 review N3 — a caught-up hub reader skips the partition scan
ConditionStateHub.Read scanned the whole partition under its gate on every tick even when the cursor
was at the tail. The partition now records its tail version; a reader at or past it returns empty.
2026-11-24 14:56:49 -05:00
Joseph Doherty 69014cc4f8 fix(grpc-data): A2 review B1 — a full condition queue back-pressures instead of resetting the stream
budget = Max(1, …) pulled a chunk on a full queue every 100 ms tick, TryWrite failed and the stream was
reset, so a backlog above MaxPendingFrames chunks never completed its snapshot. Max(0, …) produces
nothing until the consumer drains. Test: 25-chunk backlog, stalled sink, 20 ticks ⇒ no reset, snapshot
completes (red before).
2026-11-24 14:48:28 -05:00
Joseph Doherty fbf9f7b898 fix(grpc-data): a raised F5 diagnostic follows the pending set down after a late native transition
The A1 phase-run failure of A_native_transition_leaves_the_F5_pending_set was a real defect: when the
600 ms F5 window closed before the transition was processed (a loaded run), the diagnostic kept the
count from when it was raised (2) although the node manager held the condition established (1).
New deterministic test closes the window first; red before, green after.
2026-11-24 14:47:36 -05:00
Joseph Doherty f6c9c9d7fe feat(grpc-data): A2b — consumer CallConditionMethodAsync (no retry, OutcomeUnknown after send), validator + AdminUI method bits, Galaxy opt-in checkbox, capacity warnings at the deploy gate 2026-11-24 13:33:36 -05:00
Joseph Doherty 1e78c64b92 feat(grpc-data): A2b — CallConditionMethod RPC, origin TryExecuteConditionMethod through the wrapped SDK handler, bits 128/256 understood, Galaxy service-ack rule, operation registry + audit log 2026-11-24 13:31:03 -05:00
Joseph Doherty 1977d8ce84 feat(grpc-data): A2a — byte-bounded condition chunks (256 KiB estimate); DataConnections.md condition streams 2026-11-24 12:30:28 -05:00
Joseph Doherty 06c8740f94 test(grpc-data): A2a — unit-phase manifest key A2; probe carries history,conditions; metadata never carries AlarmSubscribe 2026-11-24 12:21:18 -05:00
Joseph Doherty 14ab6be37f test(grpc-data): A2a — condition stream R tests (priority, overflow reset, hub reset, revocation, deploy deltas, total first, slice cut, UNS no RawPath); delivered-snapshot overflow rule 2026-11-24 12:15:02 -05:00
Joseph Doherty ee1556ac5e feat(grpc-data): A2a AdminUI AlarmSubscribe checkbox, condition limit fields, capacity warning
Connection/export/mapping editors offer AlarmSubscribe (DataOperationAuthoring; method bits stay unauthorable until A2b);
export MaxConditions and mapping MaxConditions / ConditionStale / ConditionMethod / ConditionSnapshot timeouts with the
validator's min/max; the X0 banner already shows for any post-v1 bit. The Mappings panel lists the validator's
non-blocking ConditionCapacityWarnings for this cluster's consumer nodes. AllowGalaxyServiceAck is not in the UI (A2b).
2026-11-24 12:11:18 -05:00
Joseph Doherty 5b03c8a26e feat(grpc-data): A2a — origin condition streaming: root-scoped items over the A1 hub, priority queue, host negotiation, consumer decode 2026-11-24 12:08:08 -05:00
Joseph Doherty 73142e52d4 feat(grpc-data): A2a — condition contract: ConditionCapabilities (17), condition_scope (4), ConditionStates arm 9, codecs 2026-11-24 12:08:07 -05:00
Joseph Doherty ac9455634d feat(grpc-data): A2a AddDataConnectionConditions schema; authoring accepts AlarmSubscribe
Migration per plan 6: DataExport.MaxConditions (1000), AllowGalaxyServiceAck (false); RemoteNamespaceMapping.MaxConditions
(1000), ConditionStaleTimeoutMilliseconds (30000), ConditionMethodTimeoutMilliseconds (5000),
ConditionSnapshotTimeoutMilliseconds (30000); NOT NULL with SQL defaults, check constraints widened. Validator known set
grows by AlarmSubscribe (method bits stay rejected); condition limits bounded (MaxConditions <= 5000 = the node manager's
per-hold clamp, timeouts <= 1 h); AllowGalaxyServiceAck only with AlarmAcknowledge; non-blocking
ConditionCapacityWarnings when a consumer node's alarm mappings' MaxConditions x 49 exceed MaxImportedConditionNodes.
2026-11-24 12:05:09 -05:00
Joseph Doherty a74a1aeef9 feat(grpc-data): A2a — AlarmSubscribe joins DataOperationSets.Understood; A2 progress log 2026-11-24 11:59:20 -05:00
Joseph Doherty d377e3775a fix(grpc-data): A1 review round 2 N3 — FOCAS does not signal a condition a truncated alarm list shows inactive
A list cut off at the per-read cap may hide the alarm a selector matches; a condition that matched nothing on such a
read stays unknown instead of being signalled known-inactive.
2026-11-24 11:35:01 -05:00
Joseph Doherty 4a6c894268 fix(grpc-data): A1 review round 2 N1 + N2 — withdrawals are never dropped; a discarded mark re-arms F5
N1: the deferral keeps every withdrawal (Known: false) regardless of capacity; a known mark beyond capacity is
dropped (unknown is safe) and its source remembered.
N2: a G3-discarded (or overflowed) deferred mark is reported to its sender as OpcUaPublishActor.ConditionMarksDiscarded
(the scripted host is skipped); DriverHostActor puts those conditions back in the F5 window from now, so a driver
that does not re-signal gets the diagnostic.
2026-11-24 11:34:12 -05:00
Joseph Doherty 4c8539b897 fix(grpc-data): A1 review round 2 F4 — a Galaxy sentinel signals only a stream opened under the live subscription
The feed raises a new IGalaxyAlarmFeed.StreamOpened (default no-op accessors) before each stream's first message;
GalaxyDriver records the live subscription then, and its sentinel signals only if that is still the live one —
so refs whose snapshot entries arrived before (or without) the subscription are never signalled. The handle is
now added before the feed starts, so the first stream opens under it.
2026-11-24 11:30:30 -05:00
Joseph Doherty ea19c3ed4f fix(grpc-data): A1 review round 2 F3 — an MTConnect delta signals the conditions it touched
A condition Unavailable at baseline never became known: its later Normal is a quality-only emission and only full
emissions signalled. A delta emission now signals its touched conditions whose level is not Unavailable, after the
events and under the same lock (tracker baseline required). Sample_delta_does_not_signal… (which pinned the old
behaviour) is now Sample_delta_signals_its_touched_conditions_and_a_rebaseline_signals_all.
2026-11-24 11:28:14 -05:00
Joseph Doherty 4d21ccafa1 fix(grpc-data): A1 review round 2 F1 + F2 — an ack-revert establishes nothing; every Good edge withdraws; Bad edge forgets unsignalable
F1: RevertNativeAlarmAck projected through WriteAlarmCondition, which re-marked a comms-withdrawn native condition
known; with the Good edge's conditional withdrawal skipped (GoodSinceUtc null) it read known-inactive-Good until the
replay. AlarmStateUpdate.EstablishesState (false for the revert) rides a new default sink overload
WriteAlarmCondition(..., establishesState) through the deferred and SDK sinks to the node manager, and every Good
edge now withdraws unconditionally.
F2: the Bad edge clears the unsignalable set, so a stale report cannot arm the backstop on the next Good edge.
The rig's CollectAlarmTraffic skips withdrawals (every edge now sends one).
2026-11-24 11:26:56 -05:00
Joseph Doherty 27a59716aa Merge A1 review round 1 fixes 2026-11-24 11:03:44 -05:00
Joseph Doherty 795ad6ccc7 fix(grpc-data): A1 review S2 — only a retired child's Bad edge withdraws known; a stray sender changes nothing 2026-11-24 10:47:49 -05:00
Joseph Doherty 2fdf9d87c2 fix(grpc-data): A1 review nit — colliding condition placements are logged at Warning (locally)
DistinctPlacements still drops every placement of an address claimed twice (fail closed); Compile takes an
optional logger (the coordinator passes its own) and the drop is reported in the local log only.
2026-11-24 10:44:00 -05:00
Joseph Doherty 16166c21e5 fix(grpc-data): A1 review S3 + S4 + nits — snapshot start cursor, readiness cut with the snapshot, failed applies
- S3a: SnapshotConditions reads a start cursor under Lock before enumerating keys; every slice carries it, so a
  condition materialised and activated between the enumeration and slice 1's hold is covered by deltas after it.
- S3b: each hold captures the apply generation (bumped when a rebuild begins) and the complete flag; slices carry
  them and ConditionSnapshotSlice.IsCompleteSnapshot / ConditionStateHub.IsSnapshotCompleteFor detect a rebuild
  that straddles a multi-slice snapshot. An empty scope still takes one hold.
- S3c: maxConditionsPerHold is clamped to MaxConditionsPerHoldLimit (5,000).
- S4: CompleteAddressSpaceApply(bool succeeded) (new default sink member, forwarded by the deferred and SDK sinks);
  the publish actor passes !Degraded. A failed/degraded rebuild keeps readiness false and its pending removals,
  emitting no removal records; the next successful apply completes it.
- Nits: ConditionStateRecord.UnshelveTimeUtc (timed-shelve expiry); ConditionStateHub.Read has a bounded default.
2026-11-24 10:43:04 -05:00
Joseph Doherty f08ca7d9e3 fix(grpc-data): A1 review S2 + F5 re-arm + nits — native known is withdrawn on comms loss
- The Bad connectivity edge (and a Good edge with no Bad edge since the last Good one, or from a new child
  incarnation) sends MarkConditionsKnown(Known: false) for the driver's condition nodes, ahead of the quality
  annotation, so an alarm raised during an outage never reads known-inactive, Good after the reconnect. Stopping a
  child (a respawn) withdraws too.
- DriverInstanceActor stamps a connection epoch (bumped on every Connected entry) on the initial-state signal and
  on ConnectivityChanged(Connected); a signal raised under an earlier connection is dropped by the child and the host.
- G3 never discards a deferred withdrawal.
- F5 'still unknown' follows the node manager: a native transition takes its ref out of Pending.
- Re-arm F5 at the alarm-ref reindex for refs a deploy adds while connected (defensive: today such a deploy
  respawns the driver because its RawTags are folded into its config).
- Nits: signals/edges from a retired or non-current child never (re)create a tracker; the injected clock replaces
  DateTime.UtcNow.
- Primary demote/re-promote: checked, not a stale-known window — drivers and their condition writes run ungated on
  both pair members.
2026-11-24 10:37:02 -05:00