Files
lmxopcua/docs/plans/evidence/grpc-data-ext/A1-core.md
T

5.2 KiB
Raw Blame History

A1 (core condition state) — progress log and evidence

Phase A1 of docs/plans/2026-11-23-grpc-data-connections-history-alarms-plan.md (revision 7), core condition-state part only (placements / condition_key / c1. ids are a parallel agent's; the six real native drivers are a later agent's). Branch worktree-agent-ad44f71fa7ab46039, based on master cbb5b396.

Progress log (resume from here)

  • Done: IAlarmInitialStateSignal (Abstractions); NM condition state in the partial OtOpcUaNodeManager.ConditionState.cs + record types ConditionStateRecords.cs (6836efae, tests ConditionStateNodeManagerTests 12/12 incl. parity (a)–(g), T1, T3, MaxConditions); ConditionStateHub + DI + hosted-service wiring (923c2511, ConditionStateHubTests 5/5 incl. falsely-empty). OpcUaPublishActor.MarkConditionsKnown + G3 (d64578b1, OpcUaPublishActorConditionKnownTests 5/5); driver actors: signal forward, routing, OpcUaClient backstop, F5 timeout (DriverHostActor.ConditionSignals.cs, ConditionSignalOptions), tests + reusable rig NativeAlarmSignalTestBase/FakeSignallingAlarmDriver (47bf3a1c, NativeAlarmInitialStateSignalTests 6/6).
  • In progress: scripted OnInputsEstablished (engine → ScriptedAlarmHostActor).
  • Next: manifest A1; gates; evidence tables.

Decisions and deviations (each with a reason)

  • MarkConditionsKnown takes a realm ((source, conditionIds, realm)): NM keys are realm-qualified; native = Raw/RawPath, scripted = Uns/ScriptedAlarmId. A sibling MarkConditionsUnknown exists because the plan's test "an input reverting to never-pushed makes the scripted condition unknown again" needs a way back to unknown.

  • The sink members are default interface methods (like CompleteAddressSpaceApply) so the ~20 test fakes compile; DeferredAddressSpaceSink/SdkAddressSpaceSink/NullOpcUaAddressSpaceSink implement them (the reflection forwarding guard covers the deferred one automatically).

  • Hub types live in OpcUaServer (IConditionStateSink, ConditionStateRecord, ConditionSnapshotSlice) because Runtime references OpcUaServer, not the reverse; the hub implementation is Runtime/DataConnections/ConditionStateHub.cs.

  • Overflow = per-reader reset, not a whole-partition epoch bump. A full partition evicts its oldest record and raises its floor; only a reader whose cursor is below the floor gets ResetRequired. Same guarantee as the plan's epoch invalidation, without resetting caught-up readers. Versions are global (one counter), so a slice watermark orders deltas for every condition in it.

  • Snapshot slices by key order, not by hub partition: keys are enumerated + filtered OFF Lock, then copied in ≤ MaxConditions slices, each with its own watermark under the same hold. Consumers must register for deltas BEFORE snapshotting (A2) so a condition created after enumeration arrives as its materialise delta.

  • A rebuild does not emit removal records for conditions that come back. Removal records for conditions the rebuild dropped for good are emitted at CompleteAddressSpaceApply (otherwise a consumer would retire an active alarm mid-rebuild — a T2 violation).

  • Carry-over carries the known flag, not "known = true": a native condition that was unknown before the rebuild stays unknown after it (no falsely-normal known). Plan text says "carried-over state is known".

  • Activation marker: incarnation = a GUID per node-manager lifetime (ConditionIncarnation); the materialise record does not advance the basis, and scripted conditions keep their basis across a rebuild (_rebuildScriptedActivation) so the engine's re-assert of a still-active alarm is not a new occurrence; native ones ride NativeConditionCarryOver (+ActivationSequence/Active/Acked, StateKnown) per the plan.

  • snapshot_complete readiness = ConditionStateHub.IsSnapshotComplete = NM apply complete (false at boot and from RebuildAddressSpace until CompleteAddressSpaceApply) AND IDriverPrimaryRoleSource.ShouldActAsPrimary.

  • AlarmStateUpdate gained an optional Source (driver id / OpcUaPublishActor.ScriptedSource) so G3 can discard exactly the source that lost a projection. An unattributed loss (null source, e.g. the #760 ack-revert write) discards every deferred mark — conservative. A deferred QUALITY drop does not discard marks.

  • Live + deferred: like AlarmStateUpdate, a mark received during a plan is applied live (to the old nodes) AND deferred; the deferred copy replays after every deferred alarm/quality.

  • F5 window starts at each ConnectivityChanged(Connected) edge and covers every alarm ref the driver owns at that instant (_alarmRefsByDriver); a Bad edge cancels the F5 and backstop timers. Conditions added by a later deploy while connected are not covered by F5 until the next Good edge (they still become known on the next signal). Diagnostic cleared when a signal empties the pending set, or the driver is removed.

  • Backstop applies only to driver type OpcUaClient (ConditionKnownSettle:OpcUaClient, default 60 s); an Unsignalable report from any other type is logged and ignored (the conditions stay unknown).

Open questions

(none yet)