Phase 6.3 Stream A - RedundancyTopology + ClusterTopologyLoader + RedundancyCoordinator #98

Merged
dohertj2 merged 1 commits from phase-6-3-stream-a-topology-loader into v2 2026-04-19 11:26:13 -04:00
Owner

Data path that feeds the Phase 6.3 ServiceLevelCalculator (PR #89). Stream C OPC UA node wiring still deferred to task #147.

Summary

  • RedundancyTopology immutable snapshot + ServerUriArray() per OPC UA Part 4 §6.6.2.2 (self first, peers lexicographic).
  • ClusterTopologyLoader pure fn enforcing Stream A.1 invariants: 1-2 nodes per cluster (decision #83); unique ApplicationUri (#86); ≤ 1 Primary in Warm/Hot (#84); self is a cluster member; every node belongs to target cluster. Violations throw InvalidTopologyException.
  • RedundancyCoordinator singleton: InitializeAsync throws on invariant violation (startup fails fast); RefreshAsync logs + flips IsTopologyValid=false (runtime falls to ServiceLevelBand.InvalidTopology=2 instead of tearing down). Volatile CAS-style swap for readers.

Test plan

  • 10 new loader tests: standalone + 2-node happy paths, ServerUriArray ordering, empty/self-missing/3-node/duplicate-URI/two-primary/cross-cluster rejections + None-mode permissive.
  • Full solution dotnet test: 1178 passing (was 1168, +10).

🤖 Generated with Claude Code

Data path that feeds the Phase 6.3 ServiceLevelCalculator (PR #89). Stream C OPC UA node wiring still deferred to task #147. ## Summary - `RedundancyTopology` immutable snapshot + `ServerUriArray()` per OPC UA Part 4 §6.6.2.2 (self first, peers lexicographic). - `ClusterTopologyLoader` pure fn enforcing Stream A.1 invariants: 1-2 nodes per cluster (decision #83); unique ApplicationUri (#86); ≤ 1 Primary in Warm/Hot (#84); self is a cluster member; every node belongs to target cluster. Violations throw `InvalidTopologyException`. - `RedundancyCoordinator` singleton: `InitializeAsync` throws on invariant violation (startup fails fast); `RefreshAsync` logs + flips `IsTopologyValid=false` (runtime falls to `ServiceLevelBand.InvalidTopology=2` instead of tearing down). Volatile CAS-style swap for readers. ## Test plan - [x] 10 new loader tests: standalone + 2-node happy paths, ServerUriArray ordering, empty/self-missing/3-node/duplicate-URI/two-primary/cross-cluster rejections + None-mode permissive. - [x] Full solution `dotnet test`: 1178 passing (was 1168, +10). 🤖 Generated with [Claude Code](https://claude.com/claude-code)
dohertj2 added 1 commit 2026-04-19 11:26:03 -04:00
Lands the data path that feeds the Phase 6.3 ServiceLevelCalculator shipped in
PR #89. OPC UA node wiring (ServiceLevel variable + ServerUriArray +
RedundancySupport) still deferred to task #147; peer-probe loops (Stream B.1/B.2
runtime layer beyond the calculator logic) deferred.

Server.Redundancy additions:
- RedundancyTopology record — immutable snapshot (ClusterId, SelfNodeId,
  SelfRole, Mode, Peers[], SelfApplicationUri). ServerUriArray() emits the
  OPC UA Part 4 §6.6.2.2 shape (self first, peers lexicographically by
  NodeId). RedundancyPeer record with per-peer Host/OpcUaPort/DashboardPort/
  ApplicationUri so the follow-up peer-probe loops know where to probe.
- ClusterTopologyLoader — pure fn from ServerCluster + ClusterNode[] to
  RedundancyTopology. Enforces Phase 6.3 Stream A.1 invariants:
    * At least one node per cluster.
    * At most 2 nodes (decision #83, v2.0 cap).
    * Every node belongs to the target cluster.
    * Unique ApplicationUri across the cluster (OPC UA Part 4 trust pin,
      decision #86).
    * At most 1 Primary per cluster in Warm/Hot modes (decision #84).
    * Self NodeId must be a member of the cluster.
  Violations throw InvalidTopologyException with a decision-ID-tagged message
  so operators know which invariant + what to fix.
- RedundancyCoordinator singleton — holds the current topology + IsTopologyValid
  flag. InitializeAsync throws on invariant violation (startup fails fast).
  RefreshAsync logs + flips IsTopologyValid=false (runtime won't tear down a
  running server; ServiceLevelCalculator falls to InvalidTopology band = 2
  which surfaces the problem to clients without crashing). CAS-style swap
  via Volatile.Write so readers always see a coherent snapshot.

Tests (10 new ClusterTopologyLoaderTests):
- Single-node standalone loads + empty peer list.
- Two-node cluster loads self + peer.
- ServerUriArray puts self first + peers sort lexicographically.
- Empty-nodes throws.
- Self-not-in-cluster throws.
- Three-node cluster rejected with decision #83 message.
- Duplicate ApplicationUri rejected with decision #86 shape reference.
- Two Primaries in Warm mode rejected (decision #84 + runtime-band reference).
- Cross-cluster node rejected.
- None-mode allows any role mix (standalone clusters don't enforce Primary count).

Full solution dotnet test: 1178 passing (was 1168, +10). Pre-existing
Client.CLI Subscribe flake unchanged.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dohertj2 merged commit e588c4f980 into v2 2026-04-19 11:26:13 -04:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: dohertj2/lmxopcua#98