prf::system::TaskHealthMonitor class final

Tracks per-task heartbeat freshness and watchdog gating eligibility.

The monitor stores only the minimum state required by the system watchdog policy: whether a task is required, whether any heartbeat was observed, when the task most recently entered required mode, and when the last heartbeat was published. The policy uses one timeout for both startup grace and ongoing freshness:

  1. when a task becomes required, it receives one startup grace window that begins at set_required(..., true, now_ms),
  2. once the first heartbeat is observed, liveness is driven by heartbeat age,
  3. optional tasks never block watchdog feeding.

Base classes

class ITaskHeartbeatSink
Narrow sink used by task runners to publish liveness heartbeats.

Public static functions

static auto decode_watchdog_marker(uint32_t marker, TaskHealthTaskId* out_task_id) -> bool
Decodes a watchdog marker written by encode_watchdog_marker().
static auto encode_watchdog_marker(TaskHealthTaskId task_id) -> uint32_t
Encodes the first unhealthy task into a compact watchdog marker value.
static auto task_name(TaskHealthTaskId task_id) -> const char*
Returns human-readable stable task name used in logs and status output.

Constructors, destructors, conversion operators

TaskHealthMonitor(uint32_t timeout_ms) explicit

Public functions

void publish_heartbeat(TaskHealthTaskId task_id, uint64_t now_ms) override
Publishes one task heartbeat sample.
void set_required(TaskHealthTaskId task_id, bool required, uint64_t now_ms)
Marks whether a task participates in watchdog gating for the scenario.
auto snapshot(uint64_t now_ms) const -> TaskHealthSnapshot
Captures current health state of all known tasks.
auto timeout_ms() const -> uint32_t
Returns watchdog timeout used for heartbeat freshness evaluation.

Function documentation

void prf::system::TaskHealthMonitor::set_required(TaskHealthTaskId task_id, bool required, uint64_t now_ms)

Marks whether a task participates in watchdog gating for the scenario.

When a task transitions into required mode, now_ms defines the start of its startup grace window. Until that window expires, the task is reported as healthy even before the first heartbeat arrives.