fix(site-runtime): script Asks honour the run deadline, Notify.Status checks the buffer first, routed calls wait for the script's own timeout (SRT-8, SRT-9, SRT-13, WP3 task 3.9)

This commit is contained in:
Joseph Doherty
2026-12-03 10:15:23 -05:00
parent bc7fae2652
commit b0c40deefb
8 changed files with 201 additions and 45 deletions
@@ -109,7 +109,7 @@ NotificationStatus status = Notify.Status(id);
- Available to instance scripts (via Script Execution Actors), alarm on-trigger scripts (via Alarm Execution Actors), and shared scripts (executing inline).
- `Notify.To("listName").Send(...)` is **asynchronous**: it generates a `NotificationId` (GUID) locally, hands the notification to the site Store-and-Forward Engine for forwarding to central, and returns the `NotificationId` to the script **immediately**. The script does not block waiting for delivery.
- The message body is **plain text** only. No HTML content.
- `Notify.Status(notificationId)` returns a small **status record** — the current status, retry count, last error, and key timestamps (enqueued, delivered). While the notification is still in the site Store-and-Forward buffer, the site answers the query **locally** with status `Forwarding`; once forwarded to central, the query round-trips to central and reads the `Notifications` table.
- `Notify.Status(notificationId)` returns a small **status record** — the current status, retry count, last error, and key timestamps (enqueued, delivered). While the notification is still in the site Store-and-Forward buffer, the site answers the query **locally** with status `Forwarding` — the buffer is checked **first**, without contacting central (2026-12-02 review SRT-8; it used to ask central first with the script's whole execution timeout, exactly when central was unreachable); once forwarded to central, the query round-trips to central and reads the `Notifications` table. That central query is bounded by 10 s (or the script's ask timeout if shorter) and by the run's deadline.
- The returned `NotificationId` is a `TrackedOperationId` — the shared Commons tracking-handle type used by all store-and-forward producers; `NotificationId` is simply the notification-domain name for it. Likewise, `Notify.Status` is a thin alias of the unified `Tracking.Status` accessor, retained for backward compatibility. This is a naming/type clarification only — notification delivery behavior is unchanged.
## Notification Delivery Behavior
+1 -1
View File
@@ -644,7 +644,7 @@ Per Akka.NET best practices, internal actor communication uses **Tell** (fire-an
**Ask** is reserved for system boundaries where a synchronous response is needed:
- **`Instance.CallScript()`**: Ask pattern from the running script (via `ScriptRuntimeContext.CallScript`) to sibling Script Actor. The caller needs the return value. Acceptable because script calls are infrequent relative to tag updates.
- **`Route.To().Call()`**: Ask from Inbound API to site Instance Actor via Communication Layer. External caller needs a response.
- **`Route.To().Call()`**: Ask from Inbound API to site Instance Actor via Communication Layer. External caller needs a response. On the site, the Deployment Manager's Ask to the Instance Actor waits as long as the **target script** may run — its resolved execution timeout (per-script override, else the site default) plus the stuck-script grace and 5 s — instead of a hard-coded 30 s (2026-12-02 review SRT-13: a 120 s handshake script used to fail its caller at 30 s while it ran on, so a retrying caller ran it twice). Script-facing Asks (`GetAttribute`, `SetAttribute`, `CallScript`) are cancelled by the run's own deadline token (SRT-9), so a run parked in one takes the timeout path at its deadline instead of sailing past it.
- **Debug view snapshot**: Ask from Communication Layer to Instance Actor for initial state.
## Concurrency & Serialization