fix(triggers): seed the trigger-expression attribute snapshot at actor startup

This commit is contained in:
Joseph Doherty
2026-05-16 05:38:50 -04:00
parent 9e21b47080
commit 41c3fa3d84
3 changed files with 22 additions and 0 deletions
@@ -72,6 +72,7 @@ public class AlarmActor : ReceiveActor
SiteRuntimeOptions options,
ILogger logger,
Script<object?>? compiledTriggerExpression = null,
IReadOnlyDictionary<string, object?>? initialAttributes = null,
ISiteHealthCollector? healthCollector = null)
{
_alarmName = alarmName;
@@ -86,6 +87,15 @@ public class AlarmActor : ReceiveActor
_onTriggerCompiledScript = onTriggerCompiledScript;
_compiledTriggerExpression = compiledTriggerExpression;
// Seed the trigger-expression attribute snapshot from the instance's
// initial attribute set so static attributes (which never re-emit an
// AttributeValueChanged after deploy) evaluate correctly at startup.
if (initialAttributes != null)
{
foreach (var kvp in initialAttributes)
_attributeSnapshot[kvp.Key] = kvp.Value;
}
// Parse trigger type
_triggerType = Enum.TryParse<AlarmTriggerType>(alarmConfig.TriggerType, true, out var tt)
? tt : AlarmTriggerType.ValueMatch;