feat(daemon): alarms by name + RequestControlState + WatchHealth (Phase A complete)

A2 — alarms: optional 'name:' on alarm config (a LOCAL key — SEMI only
defines numeric ALID + freetext ALTX; field appended last so existing
{id, text, category} brace-inits compile unchanged), parsed by the loader,
checked by the validator, shipped in equipment.yaml. SetAlarm/ClearAlarm
RPCs resolve config name OR stringified ALID via a constructor snapshot.

A3 — control state + health: RequestControlState fires operator events on
the io thread (read_sync) and reports what the E30 table actually did —
ACCEPT iff the equipment landed in the requested state, CANNOT_DO_NOW naming
the actual state otherwise (the shipped table has no operator path to
EquipmentOffline; the test pins that honesty). ATTEMPT_ONLINE is rejected as
transient. WatchHealth streams an immediate snapshot then pushes on link/
control-state changes via service observers (add_link_observer +
add_control_state_observer — the HandlerSlot work paying off), spool depth
sampled at the 500ms poll; ends on cancel or engine stop.

Tests: daemon suite 61 -> 101 assertions (alarm lifecycle by name/id/unknown,
WatchHealth initial + change push, all four RequestControlState semantics);
loader test for the alarm name (present + absent fallback); core 467/3055.
Interop now 15 checks incl. gRPC SetAlarm -> host receives S5F1 ALCD=0x84
ALID=1, and RequestControlState(HOST_OFFLINE) -> GetControlState confirms.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
2026-06-10 19:47:31 +02:00
parent 83593bb508
commit 1da56f973f
9 changed files with 326 additions and 15 deletions
+1
View File
@@ -206,6 +206,7 @@ EquipmentDescriptor load_equipment(const std::string& path, gem::EquipmentDataMo
static_cast<uint32_t>(a["id"].as<int>()),
a["text"].as<std::string>(),
static_cast<uint8_t>(a["category"].as<int>()),
a["name"] ? a["name"].as<std::string>() : "", // optional local key
});
}
}
+4
View File
@@ -218,6 +218,10 @@ void validate_equipment_block(YAML::Node& root, Sink& sink) {
// is the set/clear flag, set at emit time — must not be in YAML.
as_int_in_range<uint8_t>(als[i]["category"], sink,
path + ".category", 0, 127);
// Optional local key for name-based APIs (not on the wire). If
// present it must be non-empty.
if (als[i]["name"])
as_nonempty_string(als[i]["name"], sink, path + ".name");
if (id && !alarm_ids.insert(*id).second) {
sink.error(path + ".id",
"duplicate ALID " + std::to_string(*id), als[i]);