Convert the gateway-visualisation TODO item into phases 28 (gateway_agent_proxy: agent sections for haproxy/nginx configs + live sockets, 1.2.0, capture, rollout) and 29 (gateway_dashboard_page: source, wiring, API, animated-pipe page, nav, docs). Clear TODO.md. LLM-Generated: true
4.5 KiB
Task 02 — The gateway job: poller, health, alerts, summary, config
Phase: 29_gateway_dashboard_page · Source: TODO.md:3 — the source is a job of its own (the disks:<host> precedent): its own interval, timeout, health record, and events, so a wedged config read ages the pipes instead of blinking /system
Story: n/a
Objective
The gateway source runs as its own poller job (the disks: shape — one job dials the same /snapshot the host: job of the gateway host reads, with the gateway's own interval/timeout), so the page ages on its own cadence and a failed poll keeps the last good pipes dimmed instead of zeroing them (invariant 4). The alerts rules keep an unconfigured source silent (invariant 3) and a dead source to exactly one line (the disks echo rule — the gateway job dials the same agent, so its failure carries no new information while the host: job is the voice; a gateway job failing while its host answers — the sections wedged — is the only voice that fault has). /api/summary gains the additive gateway block, /api/config gains the gateway row.
- ASSUMPTION: the job is
gateway(one job, thenutshape — a single source, not per-host: the page is about the one gateway host),DISKS-interval defaults from task 01 (30 s / 10 s), events under the dashboard namegateway. - ASSUMPTION: the no-verdict alert rule: the source's payload carries no
severity, soalerts.pygains no threshold forgateway— the only alerts agatewayjob raises are reachability (stale > 3× its 30 s interval →warn, stopped answering →fail, thedisks-echo suppression applied: a dead gateway job while itshost:job is also dead adds no line).
Work
src/dashboards/app.py—build_hub: thegatewayjob (one, not per host) wired thedisks:job is wired — the sameAgentTlsentry the gateway host'shost:/disks:jobs use (so a revocation fails all three with one sentence, the task-03agent_tls_mapshape), itsparsethesources.gateway.parse+samplespass-through, noRateEstimator(the source takes none — task 01). The job exists only whensettings.gateway_enabled(thedisksjob's configured gate: no job at all when the source is unconfigured, invariant 3).src/dashboards/alerts.py— thegatewayblock: the reachability rules per the assumption above; theHREFtable gains/gateway; no verdict rule (asserted: agatewaypayload with a fabricatedseveritydict still produces no verdict alert — the module may not have a threshold of its own, the phase-09 disk rule's shape).src/dashboards/api.py—/api/summary: the additivegatewayblock ({configured, supported, host, inbound: int (Σ connections), outbound: int, map_targets: int, unmatched: int, states: {gateway: str}}— a configured job with no payload yet is a stub, thesystem.hostsstub shape);/api/config: the gateway row (GATEWAY_HOST's name + theTarget.display_urlof the entry it names, redacted — invariant 6's boundary).tests/test_api.py— thebuild_hubwiring pins (the job present iffgateway_enabled; the sharedAgentTlsentry — a revocation written intometafails thegatewayjob before any dial, thetest_a_revoked_agent_fails_both_of_its_sources_without_a_dialshape extended to three sources); the/api/summarygatewayblock pin (with and without the source configured — unconfigured: the block isconfigured: falseand absent no dial happens, the spy-pinned shape); the alerts pins (unconfigured → nogatewayalert; dead job + dead host → one line, not two; a wedged-sections failure while the host answers → one line naminggateway).
Testing & Quality
- Unit: the wiring/alerts/summary pins above
- Coverage: >90% on the modified
app.py/alerts.py/api.pybranches
Completion Criteria
- a configured build carries exactly one
gatewayjob on the gateway host's shared TLS entry; an unconfigured build carries none (pinned) - a revocation in
metafails thegatewayjob before any dial (spy-pinned, thehost:/disks:pair's shape) /api/summary'sgatewayblock is pinned with and without configuration; the pre-existing blocks are unchanged- the alerts pins hold: unconfigured silent, dead-source one line, no verdict rule
uv run pytestgreen,uv run ruff check src testsanduv run pyrightclean- no behavior change in completed work: the pre-existing jobs, alerts, and summary blocks behave exactly as before