Note: HC3 REST parity for flua

Status: design + implementations (2026-10-16/17). Implemented: real /debugMessages (console buffer) + DELETE + /tags; /flua/systemLog (structured system/crash log) + DELETE.

Context

The HC3's REST API manages QAs (upload/restart/delete), the house resources (devices, scenes, globals, alarms, …), the event log (/refreshStates), and the QA console (/debugMessages). flua's sim implements 77 of those routes in HC3 shapes (the live compat suite pins them), but several were shape-only stubs — most notably /debugMessages, which returned an empty buffer while the real QA logs went to stdout/stderr only.

The gap that matters: agents and tools want the logs over REST, the same surface the real HC3 offers — one interface for both, no console parsing.

Decision: parity is selective

Rule for adding/upgrading a route: implement it for real when (a) a QA calls it, (b) a tool/agent reads it, or (c) the compat suite shows shape drift that hurts. Everything else stays a shape-pinned stub. Full parity is a treadmill (359 endpoints in the spec, shapes drift per firmware).

Implemented: real /debugMessages

HC3 semantics (fibaro_api_docs/debugMessages.json, schema DebugMessageDto):

Where the lines come from:

State: SimState.debug_messages (deque, append is thread-safe — the pump and worker threads both log). Pins: tests/test_api.py::test_debug_messages, tests/test_qa.py::test_debug_messages_record_qa_logs.

Implemented: /flua/systemLog (structured system/crash log)

The thing the real HC3 lacks: machine-readable engine lifecycle. flua-only route (the /flua/* namespace), same polling contract as /debugMessages (last/offset, DELETE):

{"id": 1, "time": "2026-10-17T08:09:26+02:00", "event": "qa_load",
 "qa": 5000, "tag": "name5000", "code": 0, "detail": ""}

Events: run_start/run_stop (engine start/stop), qa_load, qa_restart, qa_exit (with code), qa_error (boot failures, from Lua), crash (callback errors, from Lua), error (pump handler / dispatch failures). Emit points: engine lifecycle methods + resumeQa/startQaInEnv on the Lua side (_PY.system_event). Pins: tests/test_api.py::test_flua_system_log, tests/test_qa.py::test_system_log_records_lifecycle_and_crashes, test_system_log_records_boot_failures.

Real vs stub — the inventory

The canonical table lives in ../rest-endpoints.md (contributor reference); update it when routes/__init__.py changes.

Open questions

  1. ~~Text-mode untagged runtime lines in /debugMessages~~ — done: engine.post_log records flua notices under the flua tag, and the Lua-side postLog/runtime print taps record untagged lines; the buffer is complete in both log modes (single record per line).
  2. ~~System-log file copy~~ — done: --syslog FILE appends every system event as one JSON line (the complete history, complementing the bounded /flua/systemLog buffer).
  3. Buffer bounds (10 000 / 2 000) — enough for agent probing sessions, or should they be configurable?
  4. Should offset's HC3 quirk ("number of returned messages") be documented in USAGE.md alongside the endpoint, or is the pin enough?