fix(template-engine): resolve alarm on-trigger scripts by name per composition chain (TPL-1, TPL-2, TPL-5, WP2 tasks 2.2+2.3)
Alarm -> on-trigger script links went through one flatten-wide 'TemplateScript.Id -> canonical name' map. Slot-derived templates hold only IsInherited placeholders, so every slot of a module composed twice resolved to the base script row id and the LAST slot's canonical name won: pump 1's alarm ran pump 2's script in pump 2's scope (TPL-1). A derived script override has a different row id, so the base alarm's link resolved to null (TPL-2). And the base pass over a nested slot overwrote a slot-level on-trigger override (TPL-5). ResolveInheritedAlarms now looks the id up among the script rows of the alarm's own chain, takes the row's NAME and path-qualifies it with the alarm's prefix, carrying it on the ResolvedAlarm, so only the pass that actually adds the alarm decides it. An id outside the alarm's chain keeps the old flatten-wide fallback; a name with no resolved script is still nulled. BY DESIGN this changes the revision hash of multi-slot compositions (and of derived templates that override an alarm's on-trigger script, and nested slot overrides): affected instances read Out of date once and redeploy with the corrected on-trigger script.
This commit is contained in:
@@ -156,6 +156,8 @@ When an instance is deployed, the Template Engine resolves the full configuratio
|
||||
5. Resolve data connection bindings — replace connection name references with concrete connection details from the site.
|
||||
6. Output a flat structure: list of attributes with resolved values and data source addresses, list of alarms with resolved trigger definitions, list of scripts with resolved code and triggers.
|
||||
|
||||
**Alarm on-trigger script resolution (2026-12-03, TPL-1/TPL-2/TPL-5).** An alarm's `OnTriggerScriptId` is resolved **by name within the alarm's own chain**: the id is looked up among the script rows of every template in that alarm's inheritance chain (base rows, derived overrides and `IsInherited` placeholders), and the row's *name* is path-qualified with the alarm's composition prefix (`Pump1.HighTemp` → `Pump1.OnHigh`). It used to go through one flatten-wide `script id → canonical name` map, which (a) made every slot of a module composed twice run the **last** slot's script, since all slots share the base script row id; (b) dropped the link (null on-trigger script) when a derived template overrode the script, since the override row has a different id; and (c) let the second visit of a nested slot overwrite a slot-level on-trigger override. The value is decided by the pass that actually adds the alarm (first wins, same as the alarm itself). An id that is not a script row of the alarm's own chain keeps the old flatten-wide fallback, and a reference that names no resolved script is still left null. **This changes the revision hash** of any instance whose flattened alarms were affected — such instances read *Out of date* once and redeploy with the corrected script link.
|
||||
|
||||
### Flatten-session caching and the graph watermark (WP2.5)
|
||||
|
||||
The flatten above is driven per instance, so an unmemoised implementation re-walks
|
||||
|
||||
Reference in New Issue
Block a user