Files
scadaproj/ZB.MOM.WW.Configuration/CLAUDE.md
T

6.0 KiB

ZB.MOM.WW.Configuration

Startup configuration-validation library for the ZB.MOM.WW SCADA family (OtOpcUa, MxAccessGateway, ScadaBridge). These are libraries, not a service — the package is linked directly into the consuming application at build time. There is no central validation process; all validation runs in-process at startup.

The library normalizes the three-project configuration-validation surface: a failure-accumulating IValidateOptions base, reusable rule primitives, a bind+validate+ValidateOnStart DI extension, and a pre-host ConfigPreflight aggregator for raw IConfiguration — so the plumbing is written once and domain rules stay per-project.

Built at 0.1.0. Adopted by OtOpcUa, MxAccessGateway, and ScadaBridge on 2026-06-01 (local default branches; not yet pushed to remotes). Adoption tracked in ~/Desktop/scadaproj/components/configuration/GAPS.md.


Package

Package Responsibilities Key Dependencies
ZB.MOM.WW.Configuration OptionsValidatorBase<TOptions> (abstract IValidateOptions base, failure-accumulating), ValidationBuilder (rule primitives: Required, Port, HostPort, PositiveTimeSpan, OneOf, MinCount, RequireThat, Add), ServiceCollectionExtensions.AddValidatedOptions (bind + validator + ValidateOnStart in one call), ConfigPreflight (fluent pre-host raw-IConfiguration checker). Microsoft.Extensions.Options, Microsoft.Extensions.Options.ConfigurationExtensions, Microsoft.Extensions.Configuration.Abstractions, Microsoft.Extensions.DependencyInjection.Abstractions

Single package; no ASP.NET Core framework reference.


Build, test, and pack commands

# From ZB.MOM.WW.Configuration/

# Build
dotnet build ZB.MOM.WW.Configuration.slnx

# Test (no external dependencies required)
dotnet test ZB.MOM.WW.Configuration.slnx

# Pack (one .nupkg lands in artifacts/)
dotnet pack ZB.MOM.WW.Configuration.slnx -c Release -o ./artifacts

Test breakdown:

Assembly Tests
ZB.MOM.WW.Configuration.Tests 27
Total 27

GeneratePackageOnBuild is off — pack explicitly with the command above.


Source layout

ZB.MOM.WW.Configuration/
├── Directory.Build.props          # version (0.1.0), TFM (net10.0), central package mgmt
├── Directory.Packages.props       # pinned package versions
├── ZB.MOM.WW.Configuration.slnx   # solution file
├── src/
│   └── ZB.MOM.WW.Configuration/   # library project
│       ├── OptionsValidatorBase.cs
│       ├── ValidationBuilder.cs
│       ├── Checks.cs                 # internal shared rule wording
│       ├── ServiceCollectionExtensions.cs
│       └── ConfigPreflight.cs
└── tests/
    └── ZB.MOM.WW.Configuration.Tests/   # xUnit test project (27 tests)

Status

Part of the scadaproj component-normalization family — this is the configuration + validation component. Built at 0.1.0. Adopted by OtOpcUa, MxAccessGateway, and ScadaBridge on 2026-06-01 (local default branches; not yet pushed to remotes) — per-app result is tracked in:

  • ~/Desktop/scadaproj/components/configuration/GAPS.md

Design documentation:

  • ~/Desktop/scadaproj/components/configuration/spec/SPEC.md — normalized validation target
  • ~/Desktop/scadaproj/components/configuration/shared-contract/ZB.MOM.WW.Configuration.md — proposed shared-library API
  • ~/Desktop/scadaproj/components/configuration/current-state/ — per-project current state (code-verified)

Index history (migrated from the scadaproj root CLAUDE.md)

Moved verbatim out of the scadaproj root CLAUDE.md on 2026-09-03 so it loads only when needed. This file is now the authoritative place for this history — append new entries here and keep the root index row short.

Narrative

The configuration component is fully populated: a normalized spec, a shared-contract, three current-state docs, and an adoption GAPS backlog. Shared = the IValidateOptions<T> failure-accumulation base (OptionsValidatorBase<T>) + reusable rule primitives (ValidationBuilder: port / host:port / required / positive-duration / one-of / min-count) + AddValidatedOptions<TOptions,TValidator>() (bind + validate + ValidateOnStart) + the pre-host ConfigPreflight aggregator (generalizes ScadaBridge's StartupValidator, byte-compatible message); left per-project = each app's options classes + domain rules, and OtOpcUa's draft/generation-content validation (DB-side sp_ValidateDraft; its C# DraftValidator is dormant).

The shared library is built and lives in this repo at ZB.MOM.WW.Configuration/ (.NET 10; single package ZB.MOM.WW.Configuration; 42 tests (verified 2026-07-18); dotnet pack → 1 nupkg @ 0.1.0). The implementation plan is at docs/plans/2026-06-01-zb-mom-ww-configuration-shared-library.md. Adopted across all three apps on 2026-06-01 (OtOpcUa, MxAccessGateway, ScadaBridge) on each repo's local default branch (main/master) — merged, not yet pushed to remotes; the package was first published to the Gitea feed. Behaviour-preserving onto OptionsValidatorBase/AddValidatedOptions for MxGateway + ScadaBridge (validator messages byte-identical), StartupValidator → ConfigPreflight for ScadaBridge, and net-new Ldap/OpcUa validators for OtOpcUa. Per-app result tracked in components/configuration/GAPS.md. Build/test from ZB.MOM.WW.Configuration/: dotnet test. Consumer matrix: all three apps consume the single package; ScadaBridge is the heaviest adopter (per-module validators + StartupValidator → ConfigPreflight); OtOpcUa adoption is additive (it has no IValidateOptions usage today).