From 3a833f5dea28c617c2727da7eca1f34cfe4f0b52 Mon Sep 17 00:00:00 2001 From: Joseph Doherty Date: Mon, 16 Mar 2026 09:16:29 -0400 Subject: [PATCH] Persist static attribute writes to local SQLite at site clusters Static attribute SetAttribute calls now persist the override to local SQLite, surviving restart and failover. On Instance Actor startup, persisted overrides are loaded on top of the deployed configuration. Redeployment resets all persisted overrides to the new deployed values. --- Component-SiteRuntime.md | 4 ++-- HighLevelReqs.md | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Component-SiteRuntime.md b/Component-SiteRuntime.md index afb329d..c0b6177 100644 --- a/Component-SiteRuntime.md +++ b/Component-SiteRuntime.md @@ -104,7 +104,7 @@ Deployment Manager Singleton (Cluster Singleton) ### GetAttribute / SetAttribute - **GetAttribute**: Returns the current in-memory value for the requested attribute. - **SetAttribute** (for attributes with data source reference): Sends a write request to the Data Connection Layer. The DCL writes to the physical device. If the write fails (connection down, device rejection, timeout), the error is returned synchronously to the calling script for handling. On success, the existing subscription picks up the confirmed value from the device and sends it back as a value update, which then updates the in-memory value. The in-memory value is **not** optimistically updated. -- **SetAttribute** (for static attributes): Updates the in-memory value directly. This change is ephemeral — it is lost on restart and resets to the deployed configuration value. +- **SetAttribute** (for static attributes): Updates the in-memory value and **persists the override to local SQLite**. On restart (or failover), the Instance Actor loads persisted overrides on top of the deployed configuration, preserving runtime-modified values. A redeployment of the instance resets all persisted overrides to the new deployed configuration values. ### Debug View Support - On request from central (via Communication Layer), the Instance Actor provides a **snapshot** of all current attribute values and alarm states. @@ -209,7 +209,7 @@ Available to all Script Execution Actors and Alarm Execution Actors: ### Instance Attributes - `Instance.GetAttribute("name")` — Read an attribute value from the parent Instance Actor. -- `Instance.SetAttribute("name", value)` — Write an attribute value. For data-connected attributes, writes to the DCL; for static attributes, updates in-memory directly. +- `Instance.SetAttribute("name", value)` — Write an attribute value. For data-connected attributes, writes to the DCL; for static attributes, updates in-memory and persists to local SQLite (survives restart/failover, reset on redeployment). ### Other Scripts - `Instance.CallScript("scriptName", parameters)` — Send an ask message to a sibling Script Actor. The target Script Actor spawns a Script Execution Actor, executes, and returns the result. The call includes the current recursion depth. diff --git a/HighLevelReqs.md b/HighLevelReqs.md index 217b883..42f9919 100644 --- a/HighLevelReqs.md +++ b/HighLevelReqs.md @@ -218,7 +218,7 @@ Scripts have an optional **minimum time between runs** setting. If a trigger fir ### 4.4 Script Capabilities Scripts executing on a site for a given instance can: - **Read** attribute values on that instance (live data points and static config). -- **Write** attribute values on that instance. For attributes with a data source reference, the write goes to the Data Connection Layer which writes to the physical device; the in-memory value updates when the device confirms the new value via the existing subscription. For static attributes, the write updates the in-memory value directly. +- **Write** attribute values on that instance. For attributes with a data source reference, the write goes to the Data Connection Layer which writes to the physical device; the in-memory value updates when the device confirms the new value via the existing subscription. For static attributes, the write updates the in-memory value and **persists the override to local SQLite** — the value survives restart and failover. Persisted overrides are reset when the instance is redeployed. - **Call other scripts** on that instance via `Instance.CallScript("scriptName", params)`. Calls use the Akka ask pattern and return the called script's return value. Script-to-script calls support concurrent execution. - **Call shared scripts** via `Scripts.CallShared("scriptName", params)`. Shared scripts execute **inline** in the calling Script Actor's context — they are compiled code libraries, not separate actors. - **Call external system API methods** in two modes: `ExternalSystem.Call()` for synchronous request/response, or `ExternalSystem.CachedCall()` for fire-and-forget with store-and-forward on transient failure (see Section 5).