# 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). - **In progress:** `OpcUaPublishActor.MarkConditionsKnown` (deferral, F2, G3). - **Next:** driver actors (signal, backstop, F5) + fake-driver helper; scripted `OnInputsEstablished`; manifest `A1`; gates. ## 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`. ## Open questions (none yet)