fix(deploy): #977 deploy/apply bookkeeping — planner sees every composition field, degraded/restarted applies repair, failed deploys restore the last applied revision, superseded deployments close

- U-2: planner diffs the rich scripted-alarm plans; an Enabled flip is a surgical add/remove of the one
  condition, a Name/AlarmType/Severity edit on an enabled alarm rebuilds.
- U-3: planner diffs UNS Areas/Lines in full; a Line moved to another Area rebuilds, added/removed
  Areas/Lines are surgical.
- U-9: removing the last VirtualTag in a FolderPath removes the sub-folder in place.
- AddressSpacePlannerFieldCoverageTests reflects over every composition list + record field.
- R-4: while the last applied composition is degraded, a non-rebuild apply re-ensures the full composition.
- R-20: a supervision restart of OpcUaPublishActor forces its first apply to rebuild.
- R-1: Direct boot with a Failed/orphan newest row restores the newest Applied deployment, then the cache.
- R-15: the revision advances after the last throwing apply step; a throw marks it unconfirmed.
- H-4: ConfigPublishCoordinator closes a superseded in-flight deployment (TimedOut + reason).

Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
Joseph Doherty
2026-12-03 10:46:47 -05:00
parent be5641fc06
commit a0f41a30d8
14 changed files with 1215 additions and 33 deletions
+19 -1
View File
@@ -823,7 +823,25 @@ deployment green fleet-wide. Now:
missing nodes, and the ack reports the new outcome. A degraded **rebuild** is the other shape: it DOES
advance `_lastApplied`, so the identical re-deploy diffs to an empty plan — the publish actor remembers
that the last advance was degraded and, on that empty plan, re-ensures the whole composition (idempotent,
no second rebuild), reporting clean only if that pass is clean.
no second rebuild), reporting clean only if that pass is clean. **The same holds for a NON-empty plan
(#977 R-4):** while the flag is set, an unrelated surgical deploy re-ensures the whole composition rather
than only its own delta, and clears the flag only when that pass is clean — before, a one-tag add after a
degraded rebuild sealed green over the node the rebuild had failed to place.
- **A restarted publish actor rebuilds its first apply (#977 R-20).** A supervision restart resets
`_lastApplied` to empty while the node manager keeps serving; the new instance therefore forces a full
rebuild on its next apply (even of an otherwise empty plan) instead of diffing against nothing.
- **A failed apply never looks cleanly served (#977 R-15).** `DriverHostActor` advances `_currentRevision` only
after the last step that can throw, and a throw marks the current revision *unconfirmed* — a re-dispatch of
it re-applies instead of short-circuiting a clean `Applied`.
- **A restart after a FAILED deploy restores the last APPLIED one (#977 R-1).** A `Direct` node whose newest
`NodeDeploymentState` row is `Failed` (or an orphan `Applying` row whose deployment is gone) restores the
newest **Applied** deployment for the node — the revision it kept serving when the later apply failed — then
falls back to the LocalDb cache, and only then boots Steady with no revision. It used to boot straight to an
empty address space, logged at Info, with nothing to heal it.
- **A newer dispatch closes the one still in flight (#977 H-4).** If `ConfigPublishCoordinator` receives a
dispatch for deployment B while a different deployment A is still awaiting acks (two composes overlapping a
singleton hand-over), it writes A `TimedOut` with a "Superseded by deployment B" reason before adopting B.
A used to stay `AwaitingApplyAcks` forever, refusing every later deploy as `AnotherDeploymentInFlight`.
- **A node with a ConfigDb also writes the reason on its own row** (`ApplyAck.DegradedReasonPrefix`), because
central only records it when it *accepts* the ack — a timed-out deployment's late ack is discarded.
**That row stays `Applying` until the outcome is known** (lmxopcua#868): it used to be written `Applied`/clean
+5
View File
@@ -175,6 +175,11 @@ after a full rebuild, carrying the unchanged `LastTransitionUtc`. Decisions:
- **Identity is the alarm id.** An edited predicate, severity, message template or equipment placement on the same id is the
same alarm. Its condition carries over, the new predicate decides the next transition (a predicate that is now false is a real
`Cleared`), and the next projection carries the new severity and message.
- **The condition NODE follows the deploy too (#977 U-2).** Enabling a disabled alarm materialises its condition in place
(no rebuild), disabling one removes it in place (a terminal removed-state event first), and a `Name` / `AlarmType` /
`Severity` edit on an enabled alarm rebuilds the address space so the node gets its new type and name. Before #977 the
address-space planner never looked at those four fields: an enable produced an empty plan and the condition never appeared
(every engine write to it was a silent no-op), a disable left it browsable, and a type/name edit kept the old node.
- **Removed and re-added in one deploy** is the same id in both generations, so it carries over. An alarm **removed or disabled**
(the host does not load a disabled plan) by one deploy and re-added by a later one is absent from the previous generation, so it
is seeded from the store like a restart: the engine stopped evaluating it, so it is a new occurrence.