Compare commits

...

6 Commits

Author SHA1 Message Date
Joseph Doherty bbba911b51 chore(plan): mark F10b + Galaxy-comment phase tasks complete
v2-ci / build (push) Failing after 38s
v2-ci / unit-tests (tests/Core/ZB.MOM.WW.OtOpcUa.Cluster.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.ControlPlane.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Runtime.Tests) (push) Has been skipped
v2-ci / unit-tests (tests/Server/ZB.MOM.WW.OtOpcUa.Security.Tests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.Host.IntegrationTests) (push) Has been skipped
v2-ci / integration (tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.IntegrationTests) (push) Has been skipped
2026-06-18 13:14:50 -04:00
Joseph Doherty b05c281132 test(opcua): pin F10b boundary — vtag EquipmentId-change + multi-vtag-mixed still rebuild 2026-06-18 13:11:53 -04:00
Joseph Doherty fac4418708 docs(client): document Galaxy fallback operator-comment limitation + pin null behavior
Closes backlog #12: Galaxy's AckMsg attribute is WRITE-ONLY and the OPC UA
event SelectClause carries no comment field, making OperatorComment
unrecoverable on the sub-attribute fallback path. Documents the two concrete
reasons in-code and tightens the AlarmEventArgs XML doc; adds pinning test
OnAlarmEvent_GalaxyFallback_LeavesOperatorCommentNull.
2026-06-18 13:06:37 -04:00
Joseph Doherty 6c6a2c4203 perf(opcua): skip address-space rebuild for vtag expression/deps/historize-only edits (F10b) 2026-06-18 13:03:50 -04:00
Joseph Doherty 0226b49437 docs(plan): implementation plan + tasks for F10b vtag rebuild-skip + Galaxy comment 2026-06-18 13:00:54 -04:00
Joseph Doherty 53f1147bfc docs(plan): design for F10b vtag rebuild-skip + Client.UI Galaxy comment limitation 2026-06-18 12:59:51 -04:00
8 changed files with 702 additions and 11 deletions
@@ -0,0 +1,171 @@
# F10b vtag-node-irrelevant rebuild skip + Client.UI Galaxy operator-comment limitation — Design
**Date:** 2026-06-18
**Branch:** `feat/f10b-vtag-skip-rebuild-galaxy-comment` (off master `be703a30`)
**Backlog items:** `stillpending.md` §A #11 (F10b in-place vs full rebuild) + #12 (Client.UI Galaxy operator-comment fallback)
Two independent, low-risk backlog items. F10b is a *bounded* address-space-rebuild optimization (the narrow, provably-safe slice — NOT the broad surgical-write rewrite). The Client.UI item is an accepted-limitation close (doc/comment + a pinning test). They touch disjoint projects (OpcUaServer / Client.Shared).
---
## Standing constraints (in force)
- NO Commons/proto change · NO Core.Abstractions / breaking-interface change · NO EF migration · NO bUnit
(no Razor touched this phase).
- Stage by explicit path (never `git add .`); never stage `sql_login.txt` / `pki/` / `pending.md` /
`current.md` / `stillpending.md` / `docker-dev/docker-compose.yml`. No force-push / no `--no-verify`.
- Finish = merge to master + push. `dangerouslyDisableSandbox: true` for all build/test commands.
---
## Component A — F10b: skip the address-space rebuild for vtag-node-irrelevant edits (backlog #11)
### What "full rebuild" costs, and why H1a made it unconditional
`OpcUaPublishActor.HandleRebuild` runs: `outcome = _applier.Apply(plan)` (which calls
`_sink.RebuildAddressSpace()` — a full tear-down of every folder/variable/alarm — iff `needsRebuild`),
then **unconditionally** re-runs the idempotent `Materialise*` passes. H1a/H1b (`1e95856b`/`ada01e1a`)
made `needsRebuild` fire on **any** Changed* (not just Added/Removed) to kill a silent stale-node bug — but
that means **editing a single VirtualTag's expression tears down and rebuilds the entire server address
space**, dropping every client's live values + monitored-item subscriptions server-wide. That blast radius
is the cost F10b targets.
### The provably-safe slice (the only zero-node-mutation case)
A VirtualTag's **materialised OPC UA node** (`Phase7Applier.MaterialiseEquipmentVirtualTags`, lines 264-272)
is derived **only** from `{EquipmentId, FolderPath, Name, DataType}` →
`EnsureVariable(parent/Name, Name, DataType, writable:false)`. `Expression`, `DependencyRefs`, and
`Historize` do **not** touch the node — `Historize` is explicitly write-side only (the code comment at
lines 260-263 says so; vtags are not materialised as SDK Historizing/HistoryRead variables).
The VirtualTag **engine** picks up `Expression`/`DependencyRefs`/`Historize` changes through a **completely
independent path**: `DriverHostActor` (`:1062`) tells `VirtualTagHostActor` `ApplyVirtualTags(...)`, and
`VirtualTagHostActor.OnApply` (lines 97-109) stop+respawns any child "whose plan changed in place (edited
Expression/DependencyRefs, or a toggled flag)". This is **not** routed through `Phase7Applier`.
Therefore, when a deploy's *only* changes are vtag deltas that differ *solely* in
`Expression`/`DependencyRefs`/`Historize`:
- the materialised node is byte-identical → `RebuildAddressSpace` would tear it down and rebuild an
identical node, dropping subscriptions for nothing;
- the idempotent `Materialise*` passes already short-circuit on an existing node
(`OtOpcUaNodeManager.EnsureVariable:1324` early-returns `if (_variables.ContainsKey(...))`), so they
no-op and preserve the live value + subscriptions;
- the engine respawns regardless via `VirtualTagHostActor`.
So **skipping `RebuildAddressSpace` for this case is correct and preserves the H1a invariant** (no stale
node — because the node never needed to change).
### Approach (Phase7Applier-only; NO node-manager / SDK / interface change)
In `Phase7Applier.Apply`, refine `needsRebuild`. A vtag delta is **node-irrelevant** iff overriding the
three engine/write-side fields to the new values makes it equal to the new plan (a whitelist-of-may-differ
that **defaults to rebuild** for any other/unknown field, because `EquipmentVirtualTagPlan` has a custom
`Equals` comparing all 8 logical fields):
```csharp
static bool VtagDeltaIsNodeIrrelevant(Phase7Plan.EquipmentVirtualTagDelta d) =>
(d.Previous with
{
Expression = d.Current.Expression,
DependencyRefs = d.Current.DependencyRefs,
Historize = d.Current.Historize,
}).Equals(d.Current);
```
`needsRebuild` becomes true iff there is any structural change OR any vtag delta that is **not**
node-irrelevant:
```csharp
var needsRebuild =
plan.AddedEquipment.Count > 0 || plan.RemovedEquipment.Count > 0 || plan.ChangedEquipment.Count > 0 ||
plan.AddedAlarms.Count > 0 || plan.RemovedAlarms.Count > 0 || plan.ChangedAlarms.Count > 0 ||
plan.AddedEquipmentTags.Count > 0 || plan.RemovedEquipmentTags.Count > 0 || plan.ChangedEquipmentTags.Count > 0 ||
plan.AddedEquipmentVirtualTags.Count > 0 || plan.RemovedEquipmentVirtualTags.Count > 0 ||
plan.ChangedEquipmentVirtualTags.Any(d => !VtagDeltaIsNodeIrrelevant(d));
```
i.e. `needsRebuild` is false **only** when every effective change is a node-irrelevant vtag edit and
nothing else changed. `ChangedNodes` (the outcome count) stays as-is (it still counts the vtag change as a
change — it just doesn't force a rebuild). Update the lines 84-91 comment to document the new skip + the
safety reasoning. The downstream `Materialise*` passes and the `VirtualTagHostActor` respawn are unchanged.
### Out of scope (deferred, documented)
Surgical *in-place attribute writes* for equipment-tag property changes (`DataType`, `Writable`,
`IsHistorized`) and alarm-severity-only changes (`SetSeverity`) genuinely mutate node attributes and carry
the H1a stale-node risk + SDK handler/historian-lifecycle complexity. They are NOT in this slice — F10b here
is strictly the zero-node-mutation vtag skip. Record them as follow-ups.
### Testing (offline, no SDK)
`Phase7ApplierTests` already uses a `RecordingSink` that captures `RebuildAddressSpace` calls. Add:
- vtag delta differing **only in Expression** ⇒ `outcome.RebuildCalled == false`, `RecordingSink` saw **no**
`RebuildAddressSpace`, `outcome.ChangedNodes == 1`.
- same for a **DependencyRefs-only** and a **Historize-only** delta ⇒ no rebuild.
- vtag delta where **DataType also changed** ⇒ `RebuildCalled == true` (the safety boundary).
- vtag delta where **Name (or FolderPath) changed** ⇒ `RebuildCalled == true`.
- a node-irrelevant vtag delta **mixed with** any other change (e.g. a ChangedEquipmentTag, or an added
equipment) ⇒ `RebuildCalled == true` (the skip requires the vtag edit to be the *sole* change).
### Live `/run` (optional, confirmatory)
On docker-dev (rebuild BOTH central nodes per the `:9200` round-robin fact): subscribe a client to a vtag,
edit only its expression in `/uns`, Deploy → server log shows `rebuild=False` for that deploy and the
client subscription is NOT dropped (vs `rebuild=True` when a tag's DataType changes). This is confirmatory;
the unit tests pin the logic.
---
## Component B — Client.UI Galaxy operator-comment fallback (backlog #12)
### Verdict: accepted limitation, not a code-fixable bug
The operator comment is **genuinely unrecoverable** in the Galaxy sub-attribute fallback path
(`OpcUaClientService.cs:769-820`):
- the standard OPC UA event SelectClause (`CreateAlarmEventFilter`, ~13 fields) does **not** request an
AckComment/Comment field — Part 9 conditions don't carry the operator comment in the event payload here;
- Galaxy's sub-attribute convention (`AlarmRefBuilder.cs:15-20`) exposes `AckMsg` as **write-only** — there
is no readable attribute to recover the last operator comment;
- the comment **is** available via the gateway's **native** alarm feed
(`GatewayGalaxyAlarmFeed` → `GalaxyAlarmTransition.OperatorComment`), which the Galaxy *driver* already
uses — a different path from this OPC UA *client* fallback.
So a real fix would require a server-side change (out of scope); the backlog already labels this "accepted
limitation." `AlarmEventArgs.cs:82-87` partly documents it, but the client-side extraction omission is
unexplained, and the behavior is untested.
### Approach (doc/comment + a pinning test; NO behavioral change)
- **Inline comment** at the fallback `AlarmEvent?.Invoke(...)` site in `OpcUaClientService.cs` (~:817):
explain that `OperatorComment` is intentionally left null here — Galaxy `AckMsg` is write-only and the
OPC UA event SelectClause carries no comment field, so the comment is only available via the gateway's
native alarm feed (the driver path), not this client fallback.
- **Tighten the `AlarmEventArgs.cs:82-87` doc** to name the two concrete reasons (write-only `AckMsg` +
no event-field), so it reads as an intentional limitation, not a TODO.
- **Pinning test** in `OpcUaClientServiceTests` (mirror the existing
`OnAlarmEvent_MissingAckedActiveButHasConditionNode_FallbackReadsAndRaisesEvent` fixture): drive the
fallback path and assert the raised `AlarmEventArgs.OperatorComment` is null — converting the gap into a
tested, intentional limitation.
### Testing
Fully offline — the existing `OpcUaClientServiceTests` fakes (`FakeSessionAdapter`/`FakeSubscriptionAdapter`)
already drive the fallback path; the new test asserts the documented behavior.
---
## Task slicing (independent → parallelizable)
| Task | Component | Project | Class | Parallel with |
|---|---|---|---|---|
| T1 | F10b vtag-node-irrelevant rebuild skip + tests | OpcUaServer (+ .Tests) | small | T2 |
| T2 | Client.UI Galaxy comment: inline comment + doc + pinning test | Client.Shared (+ .Tests) | trivial→small | T1 |
| T3 | Reconcile stillpending #11/#12 + memory + finish (build, tests, merge+push) | docs (never-staged) | small | none |
T1/T2 touch disjoint projects → dispatchable concurrently (worktree isolation or serial-on-shared-tree per
the git-index-race lesson). T3 runs last.
## Done =
Build clean + `dotnet test` green (OpcUaServer.Tests + Client.Shared.Tests) + backlog/memory reconciled +
merged to master + pushed.
@@ -0,0 +1,121 @@
# F10b vtag rebuild-skip + Client.UI Galaxy comment — Implementation Plan
> **For Claude:** REQUIRED SUB-SKILL: Use superpowers-extended-cc:subagent-driven-development to implement this plan task-by-task.
**Goal:** Close backlog #11 (F10b — skip the address-space rebuild for vtag-node-irrelevant edits) and #12 (Client.UI Galaxy operator-comment accepted-limitation).
**Architecture:** A: refine `needsRebuild` in `Phase7Applier.Apply` so a deploy whose only changes are VirtualTag deltas differing solely in Expression/DependencyRefs/Historize skips `RebuildAddressSpace` (the vtag node is byte-identical; the engine respawns independently via VirtualTagHostActor). B: a clarifying comment + doc + pinning test for the Galaxy sub-attribute fallback that can't surface the operator comment.
**Tech Stack:** .NET 10, Akka.NET, OPC UA SDK, xUnit + Shouldly.
**Design:** `docs/plans/2026-06-18-f10b-vtag-skip-rebuild-galaxy-comment-design.md` (committed `53f1147b`).
**Standing constraints:** NO Commons/proto change · NO Core.Abstractions/interface change · NO EF migration · NO bUnit · stage by explicit path (never `git add .`) · never stage the never-stage files · no force-push / no `--no-verify` · `dangerouslyDisableSandbox:true` for build/test · finish = merge to master + push.
---
### Task 1: F10b — skip rebuild for vtag-node-irrelevant edits
**Classification:** small
**Estimated implement time:** ~4 min
**Parallelizable with:** Task 2
**Files:**
- Modify: `src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer/Phase7Applier.cs` (refine `needsRebuild`, lines ~84-96)
- Test: `tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests/Phase7ApplierTests.cs`
**Context (read to confirm before editing):**
- `Phase7Applier.Apply` (`:48-115`) computes `needsRebuild` (`:92-96`) and calls `_sink.RebuildAddressSpace()` iff true; returns `Phase7ApplyOutcome(RemovedNodes, AddedNodes, ChangedNodes, RebuildCalled)`.
- A vtag's materialised node (`MaterialiseEquipmentVirtualTags`, `:264-272`) depends ONLY on `{EquipmentId, FolderPath, Name, DataType}` → `EnsureVariable(parent/Name, Name, DataType, writable:false)`. `Expression`/`DependencyRefs`/`Historize` do NOT touch the node (Historize is write-side only, `:260-263`).
- `EquipmentVirtualTagPlan` (`Phase7Composer.cs:133-157`) = `(VirtualTagId, EquipmentId, FolderPath, Name, DataType, Expression, DependencyRefs, Historize)` with a CUSTOM `Equals` comparing all 8 logical fields (DependencyRefs element-wise).
- The vtag ENGINE respawns independently via `VirtualTagHostActor.OnApply` (`:97-109`), fed by `DriverHostActor:1062` `ApplyVirtualTags(...)` — NOT through Phase7Applier. So skipping the address-space rebuild leaves the engine respawn intact.
- The downstream idempotent `Materialise*` passes (`OpcUaPublishActor:326-342`) short-circuit on an existing node (`OtOpcUaNodeManager.EnsureVariable:1324` early-returns when the node already exists) → preserve live value + subscriptions when no rebuild happened.
- `Phase7ApplierTests.cs` uses a `RecordingSink` capturing sink calls (read it for the exact API — how it records `RebuildAddressSpace` and how a `Phase7Plan` with `ChangedEquipmentVirtualTags` is constructed).
**Steps:**
1. Add a private static helper to `Phase7Applier`:
```csharp
// A VirtualTag's materialised OPC UA node (MaterialiseEquipmentVirtualTags) is derived ONLY from
// {EquipmentId, FolderPath, Name, DataType}. Expression/DependencyRefs/Historize are engine/write-side
// only and are adopted by VirtualTagHostActor's independent respawn (DriverHostActor → ApplyVirtualTags),
// so a delta that changes ONLY those three leaves a byte-identical node and needs no address-space
// rebuild. Whitelist-of-may-differ via `with`+custom-Equals: any OTHER field difference (current or
// future) makes the override unequal → falls back to a full rebuild (safe default).
private static bool VtagDeltaIsNodeIrrelevant(Phase7Plan.EquipmentVirtualTagDelta d) =>
(d.Previous with
{
Expression = d.Current.Expression,
DependencyRefs = d.Current.DependencyRefs,
Historize = d.Current.Historize,
}).Equals(d.Current);
```
(Confirm the delta type's exact name/namespace — likely `Phase7Plan.EquipmentVirtualTagDelta` with `.Previous`/`.Current` — by reading `Phase7Plan`. Adjust accessors to match.)
2. Replace the `plan.AddedEquipmentVirtualTags... || plan.ChangedEquipmentVirtualTags.Count > 0` term in `needsRebuild` (`:96`) with:
```csharp
plan.AddedEquipmentVirtualTags.Count > 0 || plan.RemovedEquipmentVirtualTags.Count > 0 ||
plan.ChangedEquipmentVirtualTags.Any(VtagDeltaIsNodeIrrelevant ... )
```
— specifically: keep Added/Removed forcing rebuild, and make the Changed term `plan.ChangedEquipmentVirtualTags.Any(d => !VtagDeltaIsNodeIrrelevant(d))`. So `needsRebuild` is false only when every effective change is a node-irrelevant vtag edit and nothing else changed. Leave `ChangedNodes`/`changedCount` computation as-is (it still counts the vtag change).
3. Update the `:84-91` comment block to document the new vtag-skip + the safety reasoning (node-irrelevant ⇒ engine respawns independently ⇒ subscriptions preserved; any structural or node-affecting change still rebuilds).
4. **Tests** in `Phase7ApplierTests.cs` (mirror the existing plan-construction + RecordingSink assertions):
- Expression-only vtag delta ⇒ `outcome.RebuildCalled == false` AND the RecordingSink recorded NO `RebuildAddressSpace` AND `outcome.ChangedNodes == 1`.
- DependencyRefs-only and Historize-only vtag deltas ⇒ no rebuild (parameterize or separate facts).
- DataType-also-changed vtag delta ⇒ `RebuildCalled == true`.
- Name-changed (and FolderPath-changed) vtag delta ⇒ `RebuildCalled == true`.
- Node-irrelevant vtag delta MIXED with another change (e.g. a ChangedEquipmentTag) ⇒ `RebuildCalled == true`.
5. **Build + test:** `dotnet build src/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer` + `dotnet test tests/Server/ZB.MOM.WW.OtOpcUa.OpcUaServer.Tests --filter "FullyQualifiedName~Phase7Applier"` (dangerouslyDisableSandbox:true). All green.
6. **Commit** (explicit paths): `Phase7Applier.cs` + `Phase7ApplierTests.cs`.
**Acceptance:** vtag Expression/DependencyRefs/Historize-only edits skip `RebuildAddressSpace`; any node-affecting or structural change still rebuilds; tests green. No node-manager/SDK/interface change.
---
### Task 2: Client.UI Galaxy operator-comment — comment + doc + pinning test
**Classification:** small
**Estimated implement time:** ~3 min
**Parallelizable with:** Task 1
**Files:**
- Modify: `src/Client/ZB.MOM.WW.OtOpcUa.Client.Shared/OpcUaClientService.cs` (inline comment at the fallback `AlarmEvent?.Invoke` site, ~:817)
- Modify: `src/Client/ZB.MOM.WW.OtOpcUa.Client.Shared/Models/AlarmEventArgs.cs` (tighten the `OperatorComment` doc, ~:82-88)
- Test: `tests/Client/ZB.MOM.WW.OtOpcUa.Client.Shared.Tests/OpcUaClientServiceTests.cs` (pinning test)
**Context:** The Galaxy sub-attribute fallback (`OpcUaClientService.cs:769-820`) reads InAlarm/Acked/TimeAlarmOn/DescAttrName when standard event fields are null, then raises `AlarmEventArgs` WITHOUT `operatorComment` (the param defaults null). This is an ACCEPTED LIMITATION — not code-fixable: Galaxy `AckMsg` is write-only (`AlarmRefBuilder.cs:15-20`, no readable comment attribute) and the OPC UA event SelectClause (`CreateAlarmEventFilter`) carries no comment field. The comment is only available via the gateway native alarm feed (`GalaxyAlarmTransition.OperatorComment`), the driver path — not this client fallback.
**Steps:**
1. Read `OpcUaClientService.cs:769-826` (both the fallback and standard `AlarmEvent?.Invoke` sites) + `Models/AlarmEventArgs.cs:82-88` + the existing fallback test `OnAlarmEvent_MissingAckedActiveButHasConditionNode_FallbackReadsAndRaisesEvent` in `OpcUaClientServiceTests.cs`.
2. Add an inline comment at the **fallback** `AlarmEvent?.Invoke(...)` site explaining `OperatorComment` is intentionally null here: Galaxy `AckMsg` is write-only + the OPC UA event SelectClause carries no comment field, so the operator comment is only recoverable via the gateway's native alarm feed (the Galaxy driver path), not this client fallback. (Comment-only — do NOT change the constructor call or behavior.)
3. Tighten the `AlarmEventArgs.OperatorComment` XML doc (`:82-87`) to name the two concrete reasons (write-only `AckMsg`; no event-field) so it reads as an intentional, documented limitation rather than a TODO.
4. Add a pinning test (mirror the existing fallback-test fixture): drive the Galaxy sub-attribute fallback path and assert the raised `AlarmEventArgs.OperatorComment` is null. Name it e.g. `OnAlarmEvent_GalaxyFallback_LeavesOperatorCommentNull`. xUnit + Shouldly; match the existing test's fake-session/subscription wiring + the `Task.Delay`/await for the background fallback read.
5. **Build + test:** `dotnet build src/Client/ZB.MOM.WW.OtOpcUa.Client.Shared` + `dotnet test tests/Client/ZB.MOM.WW.OtOpcUa.Client.Shared.Tests --filter "FullyQualifiedName~OperatorComment"` (dangerouslyDisableSandbox:true). Green.
6. **Commit** (explicit paths): the two src files + the test file.
**Acceptance:** the limitation is documented at the fallback site + on `OperatorComment`, and a test pins the null-comment behavior. No behavioral change.
---
### Task 3: Reconcile backlog + memory + finish (merge + push)
**Classification:** small
**Estimated implement time:** ~4 min
**Parallelizable with:** none (last)
**Files:**
- Modify (NEVER staged): `stillpending.md` (mark #11/#12)
- Modify: memory `project_stillpending_backlog.md` + `MEMORY.md` index line
**Steps:**
1. Full solution build: `dotnet build ZB.MOM.WW.OtOpcUa.slnx` — 0 errors.
2. Targeted tests green: `OpcUaServer.Tests` (Phase7Applier) + `Client.Shared.Tests` (OperatorComment/alarm). Report counts.
3. `stillpending.md` (never staged): #11 — F10b vtag-node-irrelevant rebuild-skip shipped (Expression/DependencyRefs/Historize-only edits skip `RebuildAddressSpace`; broader surgical writes deferred); #12 — Galaxy operator-comment closed as a documented + tested accepted-limitation (not code-fixable: write-only `AckMsg` + no event-field).
4. Memory: top marker in `project_stillpending_backlog.md` + a concise `MEMORY.md` index update (keep the file under the soft cap).
5. Finish (superpowers-extended-cc:finishing-a-development-branch): verify tests → ff-merge `feat/f10b-vtag-skip-rebuild-galaxy-comment` → master → push → delete branch → confirm `local master = origin/master`.
**Acceptance:** build clean, tests green, backlog/memory reconciled, merged + pushed.
---
## Dependency graph
`{T1 ∥ T2}` → `T3`. T1/T2 touch disjoint projects (OpcUaServer / Client.Shared) → dispatch concurrently with worktree isolation or serial-on-shared-tree (one writer at a time). T3 last.
@@ -0,0 +1,15 @@
{
"planPath": "docs/plans/2026-06-18-f10b-vtag-skip-rebuild-galaxy-comment.md",
"executionState": "COMPLETE",
"tasks": [
{"id": 1, "subject": "Task 1: F10b vtag-node-irrelevant rebuild skip + tests", "classification": "small", "status": "completed", "commits": ["6c6a2c42", "b05c2811"]},
{"id": 2, "subject": "Task 2: Client.UI Galaxy operator-comment limitation + pinning test", "classification": "small", "status": "completed", "commits": ["fac44187"]},
{"id": 3, "subject": "Task 3: Reconcile backlog + memory + finish (merge + push)", "classification": "small", "status": "completed"}
],
"verification": {
"solutionBuild": "0 errors",
"tests": "OpcUaServer.Tests 245/245 (incl. new F10b boundary tests), Client.Shared.Tests 174/174 (incl. the Galaxy fallback pinning test)",
"codeReview": "F10b: all 6 safety claims verified, no H1a stale-node regression. Galaxy: comment/doc/test-only, accurate."
},
"lastUpdated": "2026-06-18"
}
@@ -81,9 +81,13 @@ public sealed class AlarmEventArgs : EventArgs
/// <summary>
/// PR E.7 — Operator-supplied comment recorded by the upstream alarm system on
/// Acknowledge transitions. Null on raise / clear, or when the upstream path
/// can't surface the comment (sub-attribute fallback path collapses comments
/// into a single string write).
/// Acknowledge transitions. Null on raise / clear events, and intentionally null
/// on the Galaxy OPC UA sub-attribute fallback path for two unrecoverable reasons:
/// (a) Galaxy's <c>AckMsg</c> attribute is WRITE-ONLY — no readable attribute
/// exposes the last operator comment — and (b) the OPC UA event SelectClause
/// carries no comment field. The operator comment is only available via the
/// gateway's native alarm feed (<c>GalaxyAlarmTransition.OperatorComment</c>
/// in the Galaxy driver path).
/// </summary>
public string? OperatorComment { get; }
@@ -814,6 +814,15 @@ public sealed class OpcUaClientService : IOpcUaClientService
// Other supplemental read failure; deliver event with defaults
}
// OperatorComment is intentionally left null (default) here.
// Two concrete reasons make it unrecoverable in this Galaxy sub-attribute fallback path:
// (a) Galaxy's AckMsg attribute is WRITE-ONLY — there is no readable attribute that
// exposes the last operator comment, so no supplemental read can recover it.
// (b) The OPC UA event SelectClause (CreateAlarmEventFilter) carries no comment field;
// the OPC UA event notification itself never delivers a comment string.
// The operator comment is only available via the gateway's native alarm feed
// (the Galaxy driver path, GalaxyAlarmTransition.OperatorComment), not this
// OpcUaClient sub-attribute fallback.
AlarmEvent?.Invoke(this, new AlarmEventArgs(
sourceName, conditionName, severity, capturedMessage, retain, activeState, ackedState, time,
eventId, capturedConditionNodeId));
@@ -84,16 +84,23 @@ public sealed class Phase7Applier
// Any add / remove / in-place CHANGE of Equipment, ScriptedAlarm, Equipment tag, or Equipment
// VirtualTag topology requires a real address-space rebuild — the materialise passes re-derive
// every node from the composition, so a changed-only deploy (e.g. a renamed equipment, a
// re-severitied alarm, a flipped tag dataType/Writable, or an edited VirtualTag expression) must
// still rebuild or the running server keeps the stale node.
// re-severitied alarm, a flipped tag dataType/Writable) must still rebuild or the running server
// keeps the stale node.
// ChangedDrivers is deliberately EXCLUDED: a driver-instance config change doesn't touch the
// address-space topology — it routes through DriverHostActor's spawn-plan in Runtime, which
// re-spawns the affected driver actor without re-materialising any nodes.
// F10b: a CHANGED VirtualTag whose ONLY differences are Expression/DependencyRefs/Historize is
// node-IRRELEVANT (see VtagDeltaIsNodeIrrelevant) — its materialised node is byte-identical and
// the vtag engine adopts those edits via VirtualTagHostActor's INDEPENDENT respawn
// (DriverHostActor → ApplyVirtualTags), so it skips the rebuild and PRESERVES every client's
// server-wide subscriptions. Any structural / node-affecting vtag change (Name/FolderPath/
// DataType) — or any non-vtag change anywhere — still forces a full rebuild (safe default).
var needsRebuild =
plan.AddedEquipment.Count > 0 || plan.RemovedEquipment.Count > 0 || plan.ChangedEquipment.Count > 0 ||
plan.AddedAlarms.Count > 0 || plan.RemovedAlarms.Count > 0 || plan.ChangedAlarms.Count > 0 ||
plan.AddedEquipmentTags.Count > 0 || plan.RemovedEquipmentTags.Count > 0 || plan.ChangedEquipmentTags.Count > 0 ||
plan.AddedEquipmentVirtualTags.Count > 0 || plan.RemovedEquipmentVirtualTags.Count > 0 || plan.ChangedEquipmentVirtualTags.Count > 0;
plan.AddedEquipmentVirtualTags.Count > 0 || plan.RemovedEquipmentVirtualTags.Count > 0 ||
plan.ChangedEquipmentVirtualTags.Any(d => !VtagDeltaIsNodeIrrelevant(d));
if (needsRebuild)
{
@@ -319,6 +326,20 @@ public sealed class Phase7Applier
catch (Exception ex) { _logger.LogWarning(ex, "Phase7Applier: EnsureVariable threw for {Node}", nodeId); }
}
// A VirtualTag's materialised OPC UA node (MaterialiseEquipmentVirtualTags) is derived ONLY from
// {EquipmentId, FolderPath, Name, DataType}. Expression/DependencyRefs/Historize are engine/write-side
// only and are adopted by VirtualTagHostActor's INDEPENDENT respawn (DriverHostActor → ApplyVirtualTags),
// so a delta changing ONLY those three leaves a byte-identical node and needs no address-space rebuild.
// Whitelist-of-may-differ via `with` + the record's custom Equals: any OTHER field difference (current
// or future) makes the override unequal → falls back to a full rebuild (safe default).
private static bool VtagDeltaIsNodeIrrelevant(Phase7Plan.EquipmentVirtualTagDelta d) =>
(d.Previous with
{
Expression = d.Current.Expression,
DependencyRefs = d.Current.DependencyRefs,
Historize = d.Current.Historize,
}).Equals(d.Current);
/// <summary>The "no-event" condition state written to a removed equipment / alarm node before the
/// rebuild tears it down: inactive, acked, confirmed, enabled, unshelved, severity 0, empty message.
/// Drives Retain to false so a removed condition stops replaying on ConditionRefresh.</summary>
@@ -1251,6 +1251,82 @@ public class OpcUaClientServiceTests : IDisposable
received.Message.ShouldBe("Fallback message"); // from DescAttrName read
}
/// <summary>
/// Pins the accepted limitation that OperatorComment is always null on the Galaxy
/// sub-attribute fallback path. Two concrete reasons make it unrecoverable:
/// (a) Galaxy's AckMsg attribute is WRITE-ONLY — no readable attribute exposes the
/// last operator comment — and (b) the OPC UA event SelectClause carries no comment
/// field. The operator comment is only available via the gateway's native alarm feed
/// (GalaxyAlarmTransition.OperatorComment in the Galaxy driver path, not here).
/// </summary>
[Fact]
public async Task OnAlarmEvent_GalaxyFallback_LeavesOperatorCommentNull()
{
var fakeSub = new FakeSubscriptionAdapter();
var session = new FakeSessionAdapter
{
NextSubscription = fakeSub,
ReadResponseFunc = nodeId =>
{
var key = nodeId.ToString();
if (key.EndsWith(".InAlarm"))
return new DataValue(new Variant(true), StatusCodes.Good);
if (key.EndsWith(".Acked"))
return new DataValue(new Variant(true), StatusCodes.Good);
if (key.EndsWith(".TimeAlarmOn"))
return new DataValue(new Variant(new DateTime(2026, 1, 1, 12, 0, 0)), StatusCodes.Good);
if (key.EndsWith(".DescAttrName"))
return new DataValue(new Variant("Ack message"), StatusCodes.Good);
return new DataValue(StatusCodes.BadNodeIdUnknown);
}
};
_sessionFactory.EnqueueSession(session);
await _service.ConnectAsync(ValidSettings());
AlarmEventArgs? received = null;
var raised = new TaskCompletionSource();
_service.AlarmEvent += (_, e) =>
{
received = e;
raised.TrySetResult();
};
await _service.SubscribeAlarmsAsync();
var handle = fakeSub.ActiveHandles.First();
// AckedState/Id (8) and ActiveState/Id (9) are null, triggering the Galaxy
// sub-attribute fallback; SourceNode (12) is set so conditionNodeId is populated.
var fields = new EventFieldList
{
EventFields =
[
new Variant(new byte[] { 4, 5, 6 }), // 0: EventId
new Variant(ObjectTypeIds.AlarmConditionType), // 1: EventType
new Variant("Source2"), // 2: SourceName
new Variant(DateTime.MinValue), // 3: Time
new Variant(new LocalizedText("Ack")), // 4: Message
new Variant((ushort)200), // 5: Severity
new Variant("CondName2"), // 6: ConditionName
new Variant(true), // 7: Retain
Variant.Null, // 8: AckedState/Id — missing
Variant.Null, // 9: ActiveState/Id — missing
new Variant(true), // 10: EnabledState/Id
new Variant(false), // 11: SuppressedOrShelved
new Variant("ns=2;s=ConditionId2") // 12: SourceNode
]
};
fakeSub.SimulateEvent(handle, fields);
// The fallback runs on a background Task.Run continuation — wait briefly for it.
await Task.WhenAny(raised.Task, Task.Delay(500));
received.ShouldNotBeNull();
// OperatorComment must be null: AckMsg is WRITE-ONLY in Galaxy and the OPC UA
// event SelectClause carries no comment field — both reasons are unrecoverable
// on this client sub-attribute fallback path.
received!.OperatorComment.ShouldBeNull();
}
// --- Failover tests ---
/// <summary>
@@ -648,11 +648,15 @@ public sealed class Phase7ApplierTests
sink.RebuildCalls.ShouldBe(1);
}
/// <summary>H1a — a deploy that ONLY edits an existing VirtualTag's expression must rebuild the
/// address space. The planner diffs it into <c>ChangedEquipmentVirtualTags</c> alone; the applier
/// must drive exactly one rebuild.</summary>
/// <summary>F10b (backlog #11) — a deploy that ONLY edits an existing VirtualTag's <c>Expression</c>
/// must SKIP the address-space rebuild. The vtag's materialised node is derived only from
/// {EquipmentId, FolderPath, Name, DataType}, so an Expression-only edit leaves a byte-identical node;
/// the vtag engine adopts the new expression via <c>VirtualTagHostActor</c>'s independent respawn, not
/// the address-space path. Skipping the rebuild preserves every client's server-wide subscriptions.
/// The edit STILL counts as a change (ChangedNodes == 1) — it just no longer forces a rebuild.
/// (Supersedes the former H1a "expression edit ⇒ rebuild" behavior.)</summary>
[Fact]
public void Changed_equipment_virtual_tags_only_trigger_rebuild()
public void Changed_virtual_tag_expression_only_skips_rebuild()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
@@ -674,11 +678,281 @@ public sealed class Phase7ApplierTests
var outcome = applier.Apply(plan);
outcome.RebuildCalled.ShouldBeTrue();
outcome.RebuildCalled.ShouldBeFalse();
sink.RebuildCalls.ShouldBe(0); // NO RebuildAddressSpace — subscriptions preserved
outcome.ChangedNodes.ShouldBe(1); // the edit is still tallied as a change
}
/// <summary>F10b — a vtag delta differing ONLY in <c>DependencyRefs</c> (e.g. a new <c>ctx.GetTag</c>
/// literal in the script) is node-irrelevant and SKIPS the rebuild; the engine respawn picks up the
/// new dependency set.</summary>
[Fact]
public void Changed_virtual_tag_dependency_refs_only_skips_rebuild()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
var previous = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }));
// Same node-relevant fields; only the dependency set differs.
// Note: DependencyRefs normally tracks the Expression (derived by the ref extractor), so a
// deps-only divergence is an edge case — e.g. the extractor logic changed between two deploys —
// but it is still correctly node-irrelevant: the materialised OPC UA node is unchanged.
var next = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a", "b" }));
var plan = Phase7Planner.Compute(previous, next);
plan.ChangedEquipmentVirtualTags.Count.ShouldBe(1);
var outcome = applier.Apply(plan);
outcome.RebuildCalled.ShouldBeFalse();
sink.RebuildCalls.ShouldBe(0);
outcome.ChangedNodes.ShouldBe(1);
}
/// <summary>F10b — a vtag delta differing ONLY in <c>Historize</c> (write-side flag, not materialised
/// on the node) is node-irrelevant and SKIPS the rebuild.</summary>
[Fact]
public void Changed_virtual_tag_historize_only_skips_rebuild()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
var previous = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }, Historize: false));
// Same node-relevant fields; only the Historize flag flips.
var next = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }, Historize: true));
var plan = Phase7Planner.Compute(previous, next);
plan.ChangedEquipmentVirtualTags.Count.ShouldBe(1);
var outcome = applier.Apply(plan);
outcome.RebuildCalled.ShouldBeFalse();
sink.RebuildCalls.ShouldBe(0);
outcome.ChangedNodes.ShouldBe(1);
}
/// <summary>F10b safe-default — a vtag delta where the node-affecting <c>DataType</c> ALSO changed is
/// NOT node-irrelevant: the materialised node would differ, so the applier must still rebuild. Pins
/// the whitelist (Expression/DependencyRefs/Historize) against accidentally swallowing a DataType
/// edit.</summary>
[Fact]
public void Changed_virtual_tag_data_type_change_still_rebuilds()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
var previous = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\") * 120", DependencyRefs: new[] { "a" }));
// DataType flips AND the expression changes — DataType is node-affecting, so this must rebuild.
var next = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Int32",
Expression: "ctx.GetTag(\"a\") * 60", DependencyRefs: new[] { "a" }));
var plan = Phase7Planner.Compute(previous, next);
plan.ChangedEquipmentVirtualTags.Count.ShouldBe(1);
var outcome = applier.Apply(plan);
outcome.RebuildCalled.ShouldBeTrue();
sink.RebuildCalls.ShouldBe(1);
}
/// <summary>F10b safe-default — a vtag delta where the node-affecting <c>Name</c> changed must
/// rebuild (the node's BrowseName/NodeId derive from Name).</summary>
[Fact]
public void Changed_virtual_tag_name_change_still_rebuilds()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
var previous = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }));
var next = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "EfficiencyPct", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }));
var plan = Phase7Planner.Compute(previous, next);
plan.ChangedEquipmentVirtualTags.Count.ShouldBe(1);
var outcome = applier.Apply(plan);
outcome.RebuildCalled.ShouldBeTrue();
sink.RebuildCalls.ShouldBe(1);
}
/// <summary>F10b safe-default — a vtag delta where the node-affecting <c>FolderPath</c> changed must
/// rebuild (the folder-scoped NodeId derives from FolderPath).</summary>
[Fact]
public void Changed_virtual_tag_folder_path_change_still_rebuilds()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
var previous = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }));
var next = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "Calc", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }));
var plan = Phase7Planner.Compute(previous, next);
plan.ChangedEquipmentVirtualTags.Count.ShouldBe(1);
var outcome = applier.Apply(plan);
outcome.RebuildCalled.ShouldBeTrue();
sink.RebuildCalls.ShouldBe(1);
}
/// <summary>F10b — the skip is ONLY for a node-irrelevant vtag edit that is the SOLE change. A
/// node-irrelevant Expression-only vtag edit MIXED with any other change (here a changed equipment
/// tag) must still rebuild — the rebuild is forced by the OTHER change, and the running server gets
/// its single rebuild as before.</summary>
[Fact]
public void Node_irrelevant_vtag_edit_mixed_with_another_change_still_rebuilds()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
var previous = new Phase7CompositionResult(
Array.Empty<EquipmentNode>(), Array.Empty<DriverInstancePlan>(), Array.Empty<ScriptedAlarmPlan>())
{
EquipmentTags = new[]
{
new EquipmentTagPlan("tag-1", "eq-1", "drv", FolderPath: "", Name: "Speed", DataType: "Float", FullName: "40001", Writable: false, Alarm: null),
},
EquipmentVirtualTags = new[]
{
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\") * 60", DependencyRefs: new[] { "a" }),
},
};
// Expression-only vtag edit (node-irrelevant) AND a node-affecting tag DataType flip.
var next = new Phase7CompositionResult(
Array.Empty<EquipmentNode>(), Array.Empty<DriverInstancePlan>(), Array.Empty<ScriptedAlarmPlan>())
{
EquipmentTags = new[]
{
new EquipmentTagPlan("tag-1", "eq-1", "drv", FolderPath: "", Name: "Speed", DataType: "Int32", FullName: "40001", Writable: false, Alarm: null),
},
EquipmentVirtualTags = new[]
{
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\") * 120", DependencyRefs: new[] { "a" }),
},
};
var plan = Phase7Planner.Compute(previous, next);
// Both a node-irrelevant vtag change AND a node-affecting tag change are present.
plan.ChangedEquipmentVirtualTags.Count.ShouldBe(1);
plan.ChangedEquipmentTags.Count.ShouldBe(1);
var outcome = applier.Apply(plan);
outcome.RebuildCalled.ShouldBeTrue();
sink.RebuildCalls.ShouldBe(1);
}
/// <summary>F10b safe-default — a vtag delta where the node-affecting <c>EquipmentId</c> changed
/// (admin reassigns the vtag to a different equipment) must rebuild. The materialised node lives
/// under the old equipment folder; moving it to another folder requires a full address-space
/// rebuild. EquipmentId is NOT in the node-irrelevant whitelist (Expression/DependencyRefs/Historize),
/// so the applier must not skip.</summary>
[Fact]
public void Changed_virtual_tag_equipment_id_triggers_rebuild()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
var previous = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-1", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }));
// Same VirtualTagId, identical Expression/DependencyRefs/DataType/Name/FolderPath —
// but reassigned to a different equipment ("eq-2" instead of "eq-1").
var next = CompositionWithVirtualTags(
new EquipmentVirtualTagPlan("vt-1", "eq-2", FolderPath: "", Name: "Efficiency", DataType: "Float64",
Expression: "ctx.GetTag(\"a\")", DependencyRefs: new[] { "a" }));
var plan = Phase7Planner.Compute(previous, next);
// Guard the arrange: the planner sees this as a changed vtag (same id, different EquipmentId).
plan.ChangedEquipmentVirtualTags.Count.ShouldBe(1);
plan.AddedEquipmentVirtualTags.ShouldBeEmpty();
plan.RemovedEquipmentVirtualTags.ShouldBeEmpty();
var outcome = applier.Apply(plan);
// EquipmentId is node-affecting — the node moves to a different folder — so rebuild is required.
outcome.RebuildCalled.ShouldBeTrue();
sink.RebuildCalls.ShouldBe(1);
outcome.ChangedNodes.ShouldBe(1);
}
/// <summary>F10b safe-default — when a plan contains TWO changed vtags and ONE is node-irrelevant
/// (Expression-only) while the OTHER is structural (DataType changed), the applier must still rebuild.
/// The <c>Any(d =&gt; !VtagDeltaIsNodeIrrelevant(d))</c> predicate must catch the structural delta
/// even though its sibling vtag would individually qualify for the skip.</summary>
[Fact]
public void Changed_virtual_tags_one_irrelevant_one_structural_triggers_rebuild()
{
var sink = new RecordingSink();
var applier = new Phase7Applier(sink, NullLogger<Phase7Applier>.Instance);
var previous = new Phase7CompositionResult(
Array.Empty<EquipmentNode>(), Array.Empty<DriverInstancePlan>(), Array.Empty<ScriptedAlarmPlan>())
{
EquipmentVirtualTags = new[]
{
// vt-A: will receive an Expression-only edit (node-irrelevant).
new EquipmentVirtualTagPlan("vt-a", "eq-1", FolderPath: "", Name: "SpeedRpm", DataType: "Float64",
Expression: "ctx.GetTag(\"speed\") * 60", DependencyRefs: new[] { "speed" }),
// vt-B: will receive a DataType change (structural / node-affecting).
new EquipmentVirtualTagPlan("vt-b", "eq-1", FolderPath: "", Name: "LoadPct", DataType: "Float64",
Expression: "ctx.GetTag(\"load\")", DependencyRefs: new[] { "load" }),
},
};
var next = new Phase7CompositionResult(
Array.Empty<EquipmentNode>(), Array.Empty<DriverInstancePlan>(), Array.Empty<ScriptedAlarmPlan>())
{
EquipmentVirtualTags = new[]
{
// vt-A: Expression-only change — individually node-irrelevant.
new EquipmentVirtualTagPlan("vt-a", "eq-1", FolderPath: "", Name: "SpeedRpm", DataType: "Float64",
Expression: "ctx.GetTag(\"speed\") * 120", DependencyRefs: new[] { "speed" }),
// vt-B: DataType flipped — structurally node-affecting.
new EquipmentVirtualTagPlan("vt-b", "eq-1", FolderPath: "", Name: "LoadPct", DataType: "Int32",
Expression: "ctx.GetTag(\"load\")", DependencyRefs: new[] { "load" }),
},
};
var plan = Phase7Planner.Compute(previous, next);
// Guard the arrange: both vtags are diffed as changed, nothing else.
plan.ChangedEquipmentVirtualTags.Count.ShouldBe(2);
plan.AddedEquipmentVirtualTags.ShouldBeEmpty();
plan.RemovedEquipmentVirtualTags.ShouldBeEmpty();
plan.ChangedEquipmentTags.ShouldBeEmpty();
plan.ChangedEquipment.ShouldBeEmpty();
var outcome = applier.Apply(plan);
// The structural delta on vt-B must force a rebuild even though vt-A is node-irrelevant.
outcome.RebuildCalled.ShouldBeTrue();
sink.RebuildCalls.ShouldBe(1);
outcome.ChangedNodes.ShouldBe(2);
}
/// <summary>H1a — a deploy that ONLY edits an existing scripted alarm (here its message template)
/// must rebuild the address space. The planner diffs the thin <c>ScriptedAlarmPlan</c> projection
/// into <c>ChangedAlarms</c> alone; the applier must drive exactly one rebuild so the condition node