20 lines
7.1 KiB
Markdown
20 lines
7.1 KiB
Markdown
# P07 read-only preparation — NOT implementation
|
||
|
||
P06 source and its final gate/review remain in progress. This note is a map, not approval or evidence of P07 implementation. Coordinator owns `Program.cs` and shared DI; settle packet interfaces before edits.
|
||
|
||
## Existing boundaries
|
||
|
||
- `src/Server/ZB.MOM.WW.OtOpcUa.Host/Program.cs`: pre-host `AddZbSecrets` and SQLite migration at 118–129; role-gated `AddOtOpcUaLocalDb` at 273–279; `AddOtOpcUaSecrets` at 629; one `AddGrpc` interceptor chain at 658–675; explicit Kestrel h2c takeover and existing-binding reconstruction at 679–783; auth middleware only on admin at 803–809; mesh maps at 817–822. Any added listener must join the binding reconstruction, preserve UI bindings, and check actual local port/host on each RPC: endpoint routing alone does not isolate listeners.
|
||
- `Host/Configuration/MeshGrpcEndpoints.cs` maps LocalDb sync, artifact/central command, telemetry/node command with `AllowAnonymous`; the interceptors are the fail-closed authentication boundary, and the explicit metadata bypasses admin cookie fallback. Data ingress needs its own equally explicit fail-closed auth plus listener admission; mesh services must also be barred from the data port. Disabled means unmapped. TLS HTTP/2 is dedicated; cleartext only explicit loopback development.
|
||
- `Host/Configuration/SecretsRegistration.cs` selects local SQLite or opt-in pair replication and decorates `ISecretCacheInvalidator`. `SecretChangeSignallingInvalidator.Invalidate(SecretName)` calls the inner invalidator then optional Galaxy directory; compose any data change notification, do not replace either. Existing production write pattern in `AdminUI/ApiKeyAck/ApiKeyGalaxyAckIdentityService.cs` uses `_cipher.Encrypt(name, value, SecretContentType.Text) with { Description, CreatedBy, UpdatedBy }`, `_store.UpsertAsync(row, ct)`, then `_invalidator?.Invalidate(name)`. Mint target keys with `IApiKeyAdminService.CreateAsync(string name, string principal, DateTime? expiresUtc, string? notes, CancellationToken ct)`; only the returned string contains the plaintext. Grant scoped exports separately.
|
||
- Pinned `Directory.Packages.props`: Secrets 0.6.2, Secrets.Abstractions 0.6.6, Secrets.Replicator.AkkaDotNet 0.6.2, Grpc.AspNetCore/Grpc.Net.Client 2.76.0, Google.Protobuf 3.34.1. Installed 0.6.2 and 0.6.6 packages contain DLL and README but **no XML documentation**; do not infer unverified library methods from older XML. Check the pinned package README and existing call sites for any additional operation.
|
||
- `Runtime/DataConnections/LocalDataServices.cs` exposes `IDataConnectionFactory.Create(DataAuthenticatedContext, DataTarget)`; its constructor accepts the catalog provider, hub, policy, capabilities, clock and optional caller write/subscription factories. Without a factory it does not advertise the corresponding operation. `DataWriteRuntime.ForCaller(context, Func<IActorRef?>)` is public, but `LocalSubscriptionService`, `DriverHostSubscriptionDemandSource`, its `SubscriptionAcquisitionCapacity` dependency and session limits are internal. Add a narrow **public Runtime composition seam** that owns construction/lifetime; do not use `InternalsVisibleTo` for Host. `LocalCatalogCoordinator(activation, authority, Func<ServingIdentity>)` and `SourceSamplePublisher(hub, Func<ServingIdentity?>, originClusterId)` require the same actual boot NodeId/incarnation and current role provenance as the facade. Share authority/dispatch fence, clock and process acquisition owner with write and driver-host paths. Verify Host actor construction actually receives those instances; creating disconnected singletons is insufficient. Feature remains false until fully wired.
|
||
|
||
## Packet and test-first boundaries
|
||
|
||
1. **Secret/trust lifecycle:** Host `Configuration/DataConnectionSecretProvisioner.cs`, `DataConnectionCredentialResolver.cs`, `DataConnectionSecretChangeHandler.cs`, `DataConnectionTrustPolicy.cs` and their four manifest Host tests. Define a narrow local bundle reader, current consumer scope/reference allowlist provider, durable monotonic version/tombstone store and credential/channel retirement notifications. On removal deny and drain before deleting an unshared reference; persist tombstones and current allowlist so an old mounted bundle cannot resurrect it after offline DB-less restart. Validate expected owner cluster and actual consumer NodeId per bundle, encrypt into local `ISecretStore`, never publish bearer in central deployment artifacts or offer an upload endpoint. Atomic replacement, encryption/store failure and partial updates must fail closed. Credential and independent trust versions retire matching channels/streams; retain dispatched write outcome observers without replay. Exercise existing Galaxy invalidation. Test two independently provisioned replicas and independent pairs, downgrade/wrong-scope/missing-secret, deletion and offline restart, and trust old/new/removal.
|
||
2. **Remote client:** Runtime `GrpcDataConnection.cs`, `DataConnectionManager.cs`, `ClusterEndpointSelector.cs`, `DataConnectionRoleAdapter.cs` and manifest `GrpcDataConnectionClientTests`, `GrpcDataEndpointSelectionTests`, `GrpcDataConsumerScopeTests`. Identity of a bounded cached channel includes endpoint, credential version and trust fingerprint. Node selection remains pinned; cluster selection authenticates capabilities and selects ready Primary, with unknown role/no primary unready and bounded backoff. Retry read/query within original causal budget; retry writes only individually typed `RejectedBeforeDispatch`, never unknown or a lost reply. Scope changes drain handles; stream epochs renew after channel/role changes. Construct realm roots from validated capability cluster identity. Confirm mapper and generated proto fields, version 1.1, age/readiness and decode/transport bounds before coding; no assumed field names.
|
||
3. **Coordinator-owned ingress and composition:** `Host/Grpc/DataConnectionGrpcService.cs`, `Configuration/DataConnectionOptions.cs`, `DataConnectionOptionsValidator.cs`, `DataConnectionAuthInterceptor.cs`, `DataConnectionEndpoints.cs`, plus Program/shared DI and Runtime public composition seam. Manifest `GrpcDataListenerTests`, `GrpcDataIngressAuthTests`, `GrpcDataServiceDispatchTests` should prove disabled mapping, listener and method admission, cookie behavior, key/pepper/authority failures, partial batches, final per-response publication gates and bounded parsing. Stream delivery must await real `WriteAsync` success before acknowledging baseline; expiry/revocation closes quiet streams. Separate unary and stream timeout policies, disable automatic write retries/hedges. Integration wire tests are P10, including real TLS/cert rotation and actual caller DI for the public NodeProbe fixture; no production network-control hook.
|
||
|
||
Manifest H regressions: `DriverWriteBoundsBindingTests`, `ApiKeyStoreRegistrationTests`, `ApiKeyAuthenticationTests`, `SecretsPreHostContentRootSourceTests`; R role regressions `WarmRoleAuthorityTests` and `PrimaryGatePolicyTests` if role adapter changes. P10 also runs `MeshGrpcAnonymousMetadataTests`, `MeshGrpcAuthStackTests`, `MeshGrpcBoundaryTests` and the new TLS/listener wire tests. P06 focused tests and current review remain separate gates.
|