Commit Graph

2 Commits

Author SHA1 Message Date
Joseph Doherty 6004a5a565 fix(alarms): #937 review r1 — revert a refused scripted method, broadcast to the peer only after the local verdict, settle a batch per request, in-flight cap
1. A post-dispatch refusal now puts the node back to its captured pre-call state
   with one corrective event (skipped when the node changed since) — the SDK had
   already applied and reported the change. Blank scripted AddComment is refused
   in the handler before the SDK runs.
2. ScriptedAlarmCommandDispatch: ask the local engine first, broadcast to the peer
   only on Applied/OutcomeUnknown — a refusal now reached no engine anywhere.
3. ApplyAsync no longer checks 'loaded' before _evalGate: a command racing the
   first load queues behind it; never loaded => refusal (nothing applied).
4. One Call's requests are settled sequentially (no request runs against a node
   state the engine refused); <= 64 asks in flight node-wide, else
   BadTooManyOperations before anything applies; per-request bound starts at send.
   Measured 300 acks through one host + LocalDb: 59 ms sequential, max 24 ms/ask
   with 64 outstanding.
5. Mixed-batch wire test (scripted refused + native + imported + scripted applied
   + core-manager method): per-item status in order, one scripted ask at a time.
L6: readiness from the engine's HasCompleteGeneration on a load fault.
L7: the verdict slot is closed when its SDK call returns (timer-captured
AsyncLocal can no longer park an ask). L10: remote budget never stretched.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-28 11:51:28 -05:00
Joseph Doherty d6f2a1b5e2 fix(alarms): a scripted condition's Part 9 method returns the engine's verdict (#937)
Before: the alarm-commands topic is fire-and-forget, so an OPC UA method (and a
remote gRPC-data condition method) returned Good even when the engine rejected
the command because its last load failed.

- ScriptedAlarmCommandReadinessView: the host's latest load outcome; the node
  manager's handler refuses BadInvalidState before the SDK applies anything
  while the last load failed (lock-free read).
- Bounded ask: inside CallAsync (off Lock) each local request runs base.Call
  alone; the handler only STARTS AlarmCommandAsker (broadcast for the peer +
  DriverHostActor -> ScriptedAlarmHostActor.ExecuteAlarmCommand on the local
  engine, CommandId-deduplicated) and the Call awaits the verdict: refused =>
  BadInvalidState, no answer => BadTimeout OutcomeUnknown.
- Remote CallConditionMethod: ExecuteConditionMethodAsync => DriverConfirmedFailure
  / OutcomeUnknown on the origin.
- Host ownership uses the latest plan set (stable across a load in flight and a
  failed load's half-built set).
- Docs: ScriptedAlarms.md (verdicts, residual, duplicate-activation trade-off),
  DataConnections.md, rules/alarms.md. Live leg scenario F937 + seeder
  scripted_predicate mutation.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-11-28 09:40:35 -05:00