server: Phase7Composer accepts DI-registered IAlarmHistorianWriter (PR B.4) #412

Merged
dohertj2 merged 1 commits from track-b4-sidecar-alarm-historian-writer into master 2026-04-30 16:33:29 -04:00
Owner

Summary

Sixth PR of the alarms-over-gateway epic (docs/plans/alarms-over-gateway.md). Depends on PR C.2 (#411, merged).

Today Phase7Composer.ResolveHistorianSink only scans drivers for an IAlarmHistorianWriter — no Galaxy driver provides one since PR 7.2, so the resolution falls through to NullAlarmHistorianSink and scripted-alarm transitions are silently discarded.

WonderwareHistorianClient already implements IAlarmHistorianWriter and Program.cs:178 already registers it as a singleton when Historian:Wonderware:Enabled=true. The gap was that Phase7Composer ignored DI: this PR adds an optional injectedWriter constructor parameter, and ASP.NET Core DI resolves it from the same registration when present.

  • Phase7Composer constructor: new optional IAlarmHistorianWriter? injectedWriter parameter (default null). Backward-compatible — existing callers don't need to change; DI populates it automatically when the singleton is registered.
  • New static SelectAlarmHistorianWriter helper — resolution order is driver → DI → null. Drivers win when both are present so a future GalaxyDriver-as-IAlarmHistorianWriter takes the write path directly, preserving the v1 invariant where a driver that natively owns the historian client doesn't bounce through the sidecar IPC.
  • ResolveHistorianSink uses the helper + emits a structured log line identifying which source provided the writer.

Test plan

  • 4 new SelectAlarmHistorianWriter precedence tests — no source / DI only / driver wins over DI / first-driver-with-writer wins.
  • Server build clean (net10.0).
  • Phase7 + alarm + bootstrap tests all pass.
  • Pre-existing 4 HostStatusPublisherTests SQL failures unrelated to this change (require the docker-host SQL Server at 10.100.0.35,14330 per CLAUDE.md).

Follow-up

  • PR D.1 — pins the live aahClientManaged write entry point in SdkAlarmHistorianWriteBackend against the dev rig and refreshes C:\publish services.
  • PR B.2 — GalaxyDriver implements IAlarmSource (depends on Track A.3 which depends on A.2's worker subscription).
## Summary Sixth PR of the **alarms-over-gateway** epic (docs/plans/alarms-over-gateway.md). Depends on PR C.2 (#411, merged). Today `Phase7Composer.ResolveHistorianSink` only scans drivers for an `IAlarmHistorianWriter` — no Galaxy driver provides one since PR 7.2, so the resolution falls through to `NullAlarmHistorianSink` and scripted-alarm transitions are silently discarded. `WonderwareHistorianClient` already implements `IAlarmHistorianWriter` and Program.cs:178 already registers it as a singleton when `Historian:Wonderware:Enabled=true`. The gap was that Phase7Composer ignored DI: this PR adds an optional `injectedWriter` constructor parameter, and ASP.NET Core DI resolves it from the same registration when present. - Phase7Composer constructor: new optional `IAlarmHistorianWriter? injectedWriter` parameter (default null). Backward-compatible — existing callers don't need to change; DI populates it automatically when the singleton is registered. - New static `SelectAlarmHistorianWriter` helper — resolution order is driver → DI → null. Drivers win when both are present so a future GalaxyDriver-as-IAlarmHistorianWriter takes the write path directly, preserving the v1 invariant where a driver that natively owns the historian client doesn't bounce through the sidecar IPC. - `ResolveHistorianSink` uses the helper + emits a structured log line identifying which source provided the writer. ## Test plan - [x] 4 new `SelectAlarmHistorianWriter` precedence tests — no source / DI only / driver wins over DI / first-driver-with-writer wins. - [x] Server build clean (net10.0). - [x] Phase7 + alarm + bootstrap tests all pass. - [ ] Pre-existing 4 `HostStatusPublisherTests` SQL failures unrelated to this change (require the docker-host SQL Server at `10.100.0.35,14330` per CLAUDE.md). ## Follow-up - **PR D.1** — pins the live aahClientManaged write entry point in `SdkAlarmHistorianWriteBackend` against the dev rig and refreshes `C:\publish` services. - **PR B.2** — GalaxyDriver implements `IAlarmSource` (depends on Track A.3 which depends on A.2's worker subscription).
dohertj2 added 1 commit 2026-04-30 16:33:25 -04:00
Sixth PR of the alarms-over-gateway epic
(docs/plans/alarms-over-gateway.md). Depends on PR C.2 (sidecar
serves IAlarmEventWriter when enabled), already merged.

Today Phase7Composer.ResolveHistorianSink only scans drivers for an
IAlarmHistorianWriter — no Galaxy driver provides one since PR 7.2,
so the resolution falls through to NullAlarmHistorianSink and
scripted-alarm transitions are silently discarded.

WonderwareHistorianClient already implements IAlarmHistorianWriter
and Program.cs:178 already registers it as a singleton when
Historian:Wonderware:Enabled=true. The gap was that Phase7Composer
ignored DI: this PR adds an optional injectedWriter constructor
parameter, and ASP.NET Core DI resolves it from the same
registration when present.

- Phase7Composer constructor: new optional IAlarmHistorianWriter?
  injectedWriter parameter (default null). Backward-compatible —
  existing callers don't need to change; DI populates it
  automatically when the singleton is registered.
- New static SelectAlarmHistorianWriter helper — resolution order
  is driver → DI → null. Drivers win when both are present so a
  future GalaxyDriver-as-IAlarmHistorianWriter takes the write
  path directly, preserving the v1 invariant where a driver that
  natively owns the historian client doesn't bounce through the
  sidecar IPC.
- ResolveHistorianSink uses the helper + emits a structured log
  line identifying which source provided the writer.

Tests:
- 4 SelectAlarmHistorianWriter precedence tests — no source / DI
  only / driver wins over DI / first-driver-with-writer wins.
- Pre-existing 4 HostStatusPublisherTests SQL failures unrelated
  to this change (require the docker-host SQL Server at
  10.100.0.35,14330 per CLAUDE.md). Phase7 + alarm tests all
  green.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
dohertj2 merged commit 95422995c0 into master 2026-04-30 16:33:29 -04:00
dohertj2 deleted branch track-b4-sidecar-alarm-historian-writer 2026-04-30 16:33:29 -04:00
Sign in to join this conversation.