From 53d222e0f76469c0699573fad65f02e68a41f0b1 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Thu, 16 Jul 2026 04:29:37 -0400 Subject: [PATCH] =?UTF-8?q?feat(driver-calc):=20B2-WP7=20Calculation=20dri?= =?UTF-8?q?ver=20=E2=80=94=20IDependencyConsumer=20+=20triggers=20+=20depl?= =?UTF-8?q?oy=20cycle=20gate?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds the Calculation pseudo-driver (tags computed by C# scripts over other tags' live values) plus the host seam that feeds it: - IDependencyConsumer capability interface (Core.Abstractions) + DriverTypeNames.Calculation. - CalculationDriver : IDriver, ISubscribable, IReadable, IDependencyConsumer — change-gate + dedupe (VirtualTagActor parity), timer-group scheduler, Bad-transition + script-log emission, Good recovery; reuses the T0-4 CalculationEvaluator. - DriverHostActor spawns a DependencyConsumerMuxAdapter per dependency-consuming driver, registering its refs on the per-node DependencyMuxActor and forwarding DependencyValueChanged → OnDependencyValue; re-registers on every apply, torn down with the driver. - Factory + probe registered in DriverFactoryBootstrap (keeps the T0-3 guard green); guard test csproj references the driver so the bin-scan discovers the factory. - DeploymentArtifact injects the resolved scriptSource (scriptId → SourceCode) into a calc tag's delivered TagConfig so the host-blind driver can compile it. - DraftValidator deploy gates: CalculationScriptMissing / CalculationScriptNotFound (scriptId existence) + CalculationDependencyCycle (DependencyGraph.DetectCycles over calc→calc edges). - Tests: driver units (dep-ref extraction, change-gate, dedupe, Bad+script-log+recovery, timer, read), tag-config parsing, DraftValidator gates (self/2-cycle/cross-driver-terminal), and a Runtime integration test proving values FLOW mux → adapter → driver → calc-of-calc end-to-end. Claude-Session: https://claude.ai/code/session_01LVneM3eh1UtJxEisFXgmox --- .../Validation/DraftSnapshot.cs | 4 + .../Validation/DraftSnapshotFactory.cs | 1 + .../Validation/DraftValidator.cs | 99 +++++ .../ZB.MOM.WW.OtOpcUa.Configuration.csproj | 10 +- .../DriverTypeNames.cs | 4 + .../IDependencyConsumer.cs | 44 ++ .../CalculationDriver.cs | 384 ++++++++++++++++++ .../CalculationDriverFactoryExtensions.cs | 96 +++++ .../CalculationDriverOptions.cs | 20 + .../CalculationDriverProbe.cs | 45 ++ .../CalculationTagDefinition.cs | 85 ++++ .../CalculationTimerScheduler.cs | 110 +++++ ...B.MOM.WW.OtOpcUa.Driver.Calculation.csproj | 1 + .../Drivers/DriverFactoryBootstrap.cs | 13 +- .../ZB.MOM.WW.OtOpcUa.Host.csproj | 1 + .../Drivers/DeploymentArtifact.cs | 50 +++ .../Drivers/DriverHostActor.cs | 39 ++ .../DependencyConsumerMuxAdapter.cs | 71 ++++ .../DraftValidatorCalculationTests.cs | 156 +++++++ ....WW.OtOpcUa.Core.Abstractions.Tests.csproj | 1 + .../CalculationDriverTests.cs | 187 +++++++++ .../CalculationTagDefinitionTests.cs | 55 +++ .../Drivers/CalculationDependencyFlowTests.cs | 82 ++++ .../ZB.MOM.WW.OtOpcUa.Runtime.Tests.csproj | 3 + 24 files changed, 1558 insertions(+), 3 deletions(-) create mode 100644 src/Core/ZB.MOM.WW.OtOpcUa.Core.Abstractions/IDependencyConsumer.cs create mode 100644 src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/CalculationDriver.cs create mode 100644 src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/CalculationDriverFactoryExtensions.cs create mode 100644 src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/CalculationDriverOptions.cs create mode 100644 src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/CalculationDriverProbe.cs create mode 100644 src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/CalculationTagDefinition.cs create mode 100644 src/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation/CalculationTimerScheduler.cs create mode 100644 src/Server/ZB.MOM.WW.OtOpcUa.Runtime/VirtualTags/DependencyConsumerMuxAdapter.cs create mode 100644 tests/Core/ZB.MOM.WW.OtOpcUa.Configuration.Tests/DraftValidatorCalculationTests.cs create mode 100644 tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Tests/CalculationDriverTests.cs create mode 100644 tests/Drivers/ZB.MOM.WW.OtOpcUa.Driver.Calculation.Tests/CalculationTagDefinitionTests.cs create mode 100644 tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests/Drivers/CalculationDependencyFlowTests.cs diff --git a/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DraftSnapshot.cs b/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DraftSnapshot.cs index 9fa9dad7..4bed38ba 100644 --- a/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DraftSnapshot.cs +++ b/src/Core/ZB.MOM.WW.OtOpcUa.Configuration/Validation/DraftSnapshot.cs @@ -55,6 +55,10 @@ public sealed class DraftSnapshot public IReadOnlyList VirtualTags { get; init; } = []; /// Equipment-bound scripted alarms. Part of the UNS effective-leaf uniqueness set. public IReadOnlyList ScriptedAlarms { get; init; } = []; + + /// User-authored scripts (shared by VirtualTags, ScriptedAlarms, and Calculation tags). Drives + /// the WP7 Calculation gates: scriptId existence + the calc→calc dependency-cycle check. + public IReadOnlyList