Skip to main content

Module check_eval

Module check_eval 

Source
Expand description

Derive a Check from a check: job’s run output — the single source of truth shared by the agent’s Health-tab cache (kanade-agent::check_cache) and the backend’s fleet-wide check_status projector, so the end user’s Client App and the operator SPA can never disagree about the same run (#908).

Pure functions (no I/O) on purpose: both consumers feed them the already-captured stdout/stderr of an ExecResult.

Functions§

build_check
Map a check job’s stdout JSON object + its CheckHint into a KLP Check. Pure (no I/O) so it’s unit-testable. Non-JSON / non-object stdout, or a missing / unrecognised status_field, degrades to CheckStatus::Unknown with a diagnostic detail — everything else is up to the operator’s PowerShell.
build_check_failed
Build the Check for a check: job that exited non-zero. The script crashed before it could report a status, so we surface Unknown with the exit code + a stderr snippet rather than leaving a stale Ok on the Health tab (a persistently-crashing check must not read as healthy).
json_to_detail
Render a detail field value as a string: pass non-empty strings through, stringify scalars, and compact-JSON-encode arrays / objects (so an operator who puts structured data in detail sees something on the row instead of a silently-blank column). Only null / empty-string yield None.