Capability report: PUT /devices/{id}/report, a Capabilities section, offline devices degraded

A device reports its board, screen, camera and ports from its own
credential (16 KB, schema 1, replacing the last report), and the flows
are validated against it again. The node panel turns a reported port's
config schema into a form, a reported screen is a canvas preset and a
touch screen's first report turns Touch friendly on. An offline device
node is degraded: amber on the canvas, a warning on Home, never a fault.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_0138N7k5PT4dcR1iEqXaaQ9k
This commit is contained in:
Melvin Strobl
2026-10-16 17:37:49 +02:00
co-authored by Claude Opus 5.5
parent a9d453c9d9
commit ad76200d3d
28 changed files with 820 additions and 129 deletions
+36 -4
View File
@@ -1363,9 +1363,14 @@ class FlowController:
}
)
def unhealthy_nodes(self, flow: str | None = None) -> list[LoadedNode]:
def unhealthy_nodes(
self, flow: str | None = None, health: Health = "down"
) -> list[LoadedNode]:
"""Nodes that have been down long enough to be worth telling anyone.
Or degraded, with ``health``: working, but not as well as they should,
which is a warning rather than a fault.
The floor is on the surfacing, not on the transition: `entry.health` is
the truth the moment the node reports it, so a flow reading a node's
health is never told a stale story — only the screens wait. And only
@@ -1376,7 +1381,7 @@ class FlowController:
return [
entry
for entry in self.loaded.values()
if entry.health == "down"
if entry.health == health
and now - entry.health_since >= HEALTH_FLOOR
and (flow is None or entry.flow == flow)
]
@@ -1384,6 +1389,9 @@ class FlowController:
def _health_issues(self, flow: str | None = None) -> list[ValidationIssue]:
"""Nodes that are running but not working, as issues on their flow.
A degraded node is an advisory one: it works, if not as it should, such
as a device node whose device is switched off.
Not part of `self.issues`: that list is what a build found, and this is
what is happening now. Derived on read, so a node reporting itself well
again clears it with nothing to remember.
@@ -1399,6 +1407,17 @@ class FlowController:
node=entry.id,
)
for entry in self.unhealthy_nodes(flow)
] + [
ValidationIssue(
code="node_degraded",
message=(
f"Node '{entry.id.rpartition('.')[2]}' is degraded: "
f"{entry.health_detail or 'no detail given'}"
),
flow=entry.flow,
node=entry.id,
)
for entry in self.unhealthy_nodes(flow, "degraded")
]
def flow_issues(self, flow: str) -> list[ValidationIssue]:
@@ -2101,6 +2120,10 @@ def _collect_issues(
return issues
#: The dtypes a device port reads as a plain number.
_NUMBERS = frozenset({"int", "float"})
def _device_issues(
loaded: dict[str, LoadedNode], devices: Any
) -> list[ValidationIssue]:
@@ -2111,6 +2134,10 @@ def _device_issues(
direction or of another dtype is an error too, and one the device does not
list is a warning: the device may know it all the same. Without a report
a port is the device's business and nothing is said about it.
A port reporting ``modes`` may be wired in any of them, as a GPIO pin is
either way. ``int`` and ``float`` pass for each other: the device reads a
number either way.
"""
if devices is None:
return []
@@ -2163,12 +2190,17 @@ def _device_issues(
elif said is None:
problem = f"'{device}' does not report a port '{spec.port}'."
advisory = True
elif said.get("direction") and said["direction"] != direction:
elif said.get("direction") and direction not in (
said.get("modes") or [said["direction"]]
):
problem = (
f"'{spec.port}' of '{device}' is an {said['direction']} "
f"port, wired here as {direction}."
)
elif said.get("dtype") and said["dtype"] != spec.dtype.value:
elif said.get("dtype") and not (
said["dtype"] == spec.dtype.value
or {said["dtype"], spec.dtype.value} <= _NUMBERS
):
problem = (
f"'{spec.port}' of '{device}' carries {said['dtype']}, "
f"wired here to a {spec.dtype.value} message."