Files
lmxopcua/docs/plans/evidence/followups/935.md
T

5.6 KiB
Raw Blame History

#935 — scripted alarms re-activated on every deploy: review round 1

Fix under review: ec245b84a, a310ba278, f0526753a (seed previous ?? persisted ?? Fresh from the last completed load's in-memory conditions). Round 1 fixes: 02d227cc3 (engine + tests), the docs commit after it, and this file.

Findings and outcomes

# Finding Outcome Red on revert
S1 ApplyAsync looked the alarm up before _evalGate; a command racing a load saved the interim Fresh entry over the carried Active condition (or an old-generation state over the new one) Fixed. Lookup under the gate; the command applies after the load to the generation it produced (unknown alarm if the deploy removed it). A value-equal result is not saved. An_ack_racing_a_reload_applies_to_the_new_generation (load held at its value-cache seed via FakeUpstream.OnRead; pre-fix: HighTemp Inactive after the load). An_idempotent_command_does_not_write_the_store red with the equality skip removed.
S2 Load re-saved every alarm, so a node that missed a command upserted stale carried state over the LocalDb last-writer-wins row on every deploy Fixed. A held seed (carried or persisted) left value-equal is not written. Extended: the push path's ReferenceEquals skip (always false: ApplyPredicate returns a clone, so every push wrote and replicated) is now value equality. The docs bullet is corrected. A_restatement_does_not_write_the_store_but_a_real_change_does, and A_runner_unavailable… (its no-save leg). A_push_that_changes_nothing_does_not_write_the_store red with ReferenceEquals restored.
S3 A failed load kept carrying the last good snapshot across an unbounded blind window: commands applied to Fresh were lost, and a clear plus re-fire inside the window was restated as the old occurrence Decision: a failed load ends the generation. The next good load reads the store, so a still-true alarm is a new occurrence. This is the same rule as an alarm a deploy removed or disabled. While blind, commands throw ScriptedAlarmCommandRejectedException (nothing persisted), and queued re-evaluations and shelving checks are dropped. The command topic is fire-and-forget, so the caller already has Good: the host logs a distinct Warning, and the next good load re-asserts the node from the store. An_operator_command_after_a_failed_reload_is_rejected_and_persists_nothing (rejection removed). A_reevaluation_after_a_failed_reload… (guard removed). A_failed_reload_ends_the_generation… and A_store_fault_mid_seed… (stale carry restored).
S4 Missing tests: runner Unavailable at reload, store fault mid-seed then a good load, the S1 race Added (see the rows above). The runner-Unavailable test asserts the carried condition is frozen, annotated BadResourceUnavailable, not established and not saved, then that recovery establishes with no Activated. Runner test: red only through its S2 leg, since the freeze itself was already correct.
N1 "process restart" in the docs should say "engine incarnation" (a supervision restart of the host actor also builds a fresh engine) Fixed in docs/ScriptedAlarms.md, .claude/rules/alarms.md and the LoadAsync XML doc docs
N2 EfAlarmActorStateStore was named as the production store in three places Fixed: the production store is LocalDbAlarmConditionStateStore docs
N3 "the store's view is always consistent" Reworded: persist-before-update on one node, no write for a no-op, last-writer-wins lag across the pair docs
N4 A_reload_whose_input_is_bad… waited on a QualityChanged that the load's Bad annotation already satisfied It now asserts the Bad annotation at the load and waits on a Good-bucket QualityChanged Test-strength only. It was not separately reverted.
N5 A carried timed shelve that expired before the load was silently unshelved by ApplyPredicate Fixed (trivial): the load runs ApplyShelvingCheck first, giving an AutoUnshelve comment and an Unshelved emission A_timed_shelve_that_expired_before_a_reload_is_unshelved_with_audit

Accepted consequences

  • A failed deploy is followed by one new occurrence. After a failed load, the next good deploy re-activates every still-true alarm: Activated, Unacknowledged, and one alerts row. This is the restart behaviour, and it is the conservative choice because the engine was not evaluating.
  • Stale fields can still replicate on a real transition. A node that missed a command keeps its stale fields in memory until its next engine incarnation. A later real transition on that node saves its whole condition, and that write replicates. A restatement no longer does.

Gates (at 4df38b864)

Gate Result
dotnet build ZB.MOM.WW.OtOpcUa.slnx --no-incremental 0 warnings / 0 errors
Core.ScriptedAlarms.Tests (full) 145/145 (reload-restatement class 21/21 after the push-save test)
Runtime.Tests (full) 2084 passed, 3 skipped, 0 failed
OpcUaServer.Tests (full) 1458 passed, 2 skipped, 0 failed
ScriptWorker.Tests AlarmSeamTests + ShadowModeTests 6/6
run-unit-phase.py A1 passed (OpcUaServer 31, Runtime 126, Core.ScriptedAlarms 59, Commons 20, Abstractions 7, Host 40, Galaxy 5, OpcUaClient 5, FOCAS 4)
run-unit-phase.py A4 passed
Live, run fu935-2 (rig.py up --conditions → seed → 85 s → deploy --timeout 300) F935 live check PASS (origin + consumer stay Active/Acknowledged across a deploy, no new condition event, same EventId and pre-deploy Time on a fresh refresh, positive-control clear arrives once at each end); conditions_scenarios.py A01–A08 8/8 PASS; rig down