Health: count only flows the engine acts on, format durations with their unit

The "running" tile counted paused and invalid flows as running, so it read
"5/5" beside "1 flow(s) cannot run". Its note is now additive rather than a
precedence chain, so a quarantine no longer hides the invalid count.

Adds dur() beside si(): a ms reading picks its own unit, so a slow run reads
"1.24 s" instead of "1.2k ms".

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01HTsT1isxUjw5gtkJk8WhuA
This commit is contained in:
2026-08-20 08:24:57 +02:00
co-authored by Claude Opus 5
parent 0e7c0038c0
commit 6be718f672
6 changed files with 93 additions and 20 deletions
+11 -1
View File
@@ -157,8 +157,18 @@ async def read_summary(
problems=problems,
flows={
"total": len(names),
# What the engine will actually act on. Enabled is not enough:
# validation stops a flow as surely as quarantine does, and a
# paused one is holding its messages rather than running them.
"running": len(
[n for n in names if controller.is_enabled(n) and n not in quarantined]
[
n
for n in names
if controller.is_enabled(n)
and n not in quarantined
and n not in paused
and n not in invalid
]
),
"paused": len(paused),
"quarantined": len(quarantined),
@@ -91,6 +91,10 @@ def test_a_flow_that_cannot_run_makes_the_summary_degraded(
controller = client.app.state.flow_controller
before = controller.issues
before_flows = controller.store.list_flows
# The looping flow has to be one the store lists, otherwise "running"
# counts nothing either way and the assertion below proves nothing.
controller.store.list_flows = lambda: ["looping"]
controller.issues = [
ValidationIssue(
code="cycle",
@@ -110,9 +114,11 @@ def test_a_flow_that_cannot_run_makes_the_summary_degraded(
body = client.get(f"{PREFIX}/summary", headers=superuser_token_headers).json()
finally:
controller.issues = before
controller.store.list_flows = before_flows
assert body["status"] == "degraded"
assert body["flows"]["invalid"] == 1
assert body["flows"]["running"] == 0
assert any("looping" in problem for problem in body["problems"])
assert not any("broken" in problem for problem in body["problems"])
assert not any("hooky" in problem for problem in body["problems"])