Files
Joseph Doherty 2ee84af1c0 feat(grpc): PSK-authenticate the site gRPC control plane; drop the vestigial management receptionist registration
Phase 0 of the ClusterClient→gRPC migration
(docs/plans/2026-07-22-clusterclient-to-grpc-plan.md). Standalone hardening: it
closes a gap that exists today and is a precondition for moving command/control
onto gRPC in later phases.

T0.1 — delete the ManagementActor ClusterClientReceptionist registration.
It was built for an out-of-cluster CLI that was never written: the shipped CLI
speaks HTTP Basic to /management, which asks the actor in-process through
ManagementActorHolder. Nothing in the repo ever sent to /user/management. The
actor still runs there; only the cross-boundary advertisement is gone. Six
documents claimed the CLI used ClusterClient — including the CLI's own README
"Architecture Notes" — and are corrected here rather than left to rot.

T0.2 — record, do not port, the dead integration-routing path.
IntegrationCallRequest is unwired at BOTH ends: RouteIntegrationCallAsync has
zero callers anywhere, and RegisterLocalHandler(Integration, …) appears only in
a test, so production always answers "Integration handler not available". It is
excluded from the gRPC contract (28 of 29 commands migrate) rather than
enshrined on an additive-only wire format, and deleting it during a
transport migration would mix a behavioural change into a change whose whole
value is that behaviour is identical. See
docs/known-issues/2026-07-22-integration-call-routing-is-dead-code.md.

T0.3 — preshared-key authentication on SiteStreamService.
The service shipped with no auth at all: plaintext h2c, no interceptor, so
anything that could reach a site node's :8083 could open a live data stream or
read audit rows back via PullAuditEvents/PullSiteCalls. ControlPlaneAuthInterceptor
now gates /sitestream.SiteStreamService/ — modeled on LocalDbSyncAuthInterceptor
(constant-time compare, fail-closed, PermissionDenied) but gating a SET of
service prefixes so phases 1A/1B add services rather than interceptors. LocalDb
sync keeps its own separate key: it authenticates the pair partner, not central,
and collapsing the two would make a site's central-facing key also admit writes
into its database.

Keys are per site (SB-GRPC-PSK-<siteId>), never fleet-wide, so a compromised
site yields only its own. Central attaches them through ControlPlaneCredentials,
which binds CallCredentials to the channel — covering unary and streaming
uniformly, and letting the key resolve asynchronously, which a client
interceptor could not do without blocking. All three central→site channel
creation sites go through it (SiteStreamGrpcClient and both audit pull invokers);
the pull invokers' channel caches are re-keyed by (site, endpoint) because
credentials are per-site and bound to the channel.

Two decisions beyond the plan:

  * StartupValidator now requires GrpcPsk on Site nodes. The plan specified only
    the runtime gate, but fail-closed with no boot check produces a node that
    joins, answers heartbeats and reports healthy while refusing every stream,
    audit pull and telemetry ingest — silent and total. Same reasoning as the
    existing inbound API-key pepper rule.

  * Added Communication:SitePsks as a central-side key map. The plan assumed
    central would read the store, seeded via a dev KEK; the docker rig
    deliberately boots with no master key, so store-only resolution would leave
    it unable to dial its own sites. The store stays primary — it is the only
    source that can serve a site added at runtime — with the map covering
    key-less hosts and one-off pins. Neither source falling back to
    "unauthenticated" is the invariant.

T0.4 — dev keys on both rigs and tests.
34 tests. The seven that matter most exercise a real in-process gRPC stack over
TestServer: the unit tests on either side of the wire would both stay green if
the halves disagreed, and gRPC refuses call credentials on a plaintext channel
by default — the UnsafeUseInsecureChannelCallCredentials opt-in is only provable
by making a real call. They confirm correct key passes on unary AND streaming,
wrong key and no-credentials both get PermissionDenied, and an unresolvable key
fails the call with nothing reaching the service.

OPERATIONAL: a site node upgraded to this build without a key will not boot.
That includes the gitignored deploy/wonder-app-vd03/ overlay.
2026-07-22 17:51:09 -04:00
..

Component Reference Documentation

Developer-reference docs for each ScadaBridge component, describing how the shipped code in src/ actually works — with real code examples. These complement the design specs in docs/requirements/: the specs say what a component should do and why; these docs say how the code does it.

Reference docs exist for 24 of the 27 components (plus the shared TreeView, listed below). ScriptAnalysis (#25), KpiHistory (#26), and DelmiaNotifier (#27) are pending — tracked in ../plans/2026-07-08-deferred-work-register.md.

# Component Description
1 Template Engine Template modeling, inheritance, composition, flattening, diffs, and semantic validation as implemented by the engine's services.
2 Deployment Manager The central deployment pipeline: deployment identity and idempotency, per-instance operation locks, state transitions, all-or-nothing site apply, and artifact deployment.
3 Site Runtime The site actor hierarchy (Deployment Manager singleton, Instance, Script, and Alarm actors), script compilation and execution, the site-wide stream, native alarms, and supervision.
4 Data Connection Layer Protocol adapters (OPC UA, MxGateway), the Become/Stash connection state machine, reconnect and re-subscribe, and the native-alarm subscription seam.
5 CentralSite Communication ClusterClient command and control plus gRPC server-streaming, the central and site communication actors, receptionist registration, and per-site contact points.
6 Store-and-Forward Engine Site-only buffering, fixed-interval retry, parking, SQLite persistence, standby replication, and the operation-tracking store.
7 External System Gateway Script-facing HTTP/REST and database access, the Call and CachedCall modes, and transient versus permanent error classification.
8 Notification Service Central notification-list and SMTP definitions, the per-type delivery adapters, and OAuth2 or Basic SMTP delivery.
9 Central UI The Blazor Server app structure, authentication, real-time updates (SignalR and gRPC), and the management pages.
10 Security & Auth LDAP bind authentication, cookie and JWT sessions, role-based and site-scoped authorization, and shared Data Protection keys.
11 Health Monitoring Site metric collection and central aggregation, report and heartbeat intervals, offline detection, and dead-letter monitoring.
12 Site Event Logging The site-local SQLite event log, retention and storage cap, daily purge, and paginated central query access.
13 Cluster Infrastructure The ClusterOptions model and validation for active/standby clustering, split-brain resolution, and failover.
14 Inbound API POST /api/{method} script invocation, API-key authentication, the extended type system, and inbound-request auditing.
15 Host The deployable binary: role-based component registration, Akka bootstrap, ASP.NET Core hosting, and the readiness and active-node health endpoints.
16 Commons Shared POCO entities, repository and service interfaces, message contracts, and the Types/Interfaces/Entities/Messages namespace layout.
17 Configuration Database The EF Core DbContext, repository implementations, the audit service, secret encryption, and migration and partition maintenance.
18 Management Service The ManagementActor admin command surface, its HTTP endpoints, and ClusterClientReceptionist registration.
19 CLI The System.CommandLine tool over the HTTP Management API — its command groups, config file, and output formats.
20 Traefik Proxy The reverse proxy fronting the central cluster, active-node routing via /health/active, and the Docker topology configuration.
21 Notification Outbox The central NotificationOutboxActor, the Notifications table, the dispatcher loop, retry and parking, and KPIs.
22 Site Call Audit The central SiteCallAuditActor, the SiteCalls mirror table, telemetry ingest, and the parked-call Retry/Discard relay.
23 Audit Log The append-only audit store: site SQLite hot-path, gRPC telemetry, central ingest and reconciliation, redaction, retention, and KPIs.
24 Transport Encrypted bundle export and import, dependency resolution, conflict detection, and BundleImportId-correlated audit.
25 Tree View The reusable Blazor tree component — parameters, selection modes, and usage in the Central UI.