Make documentation standalone and generalize examples

This commit is contained in:
Melvin Strobl
2026-10-25 14:43:20 +01:00
parent 13bf0f76d7
commit bdb18b99da
57 changed files with 553 additions and 481 deletions
+2 -5
View File
@@ -205,11 +205,8 @@ class ExecutionService:
def _sleep_until_due(self) -> bool:
"""Wait for the soonest deadline, the housekeeping cap, or a new one.
A fixed poll here made every delayed item late by 0-1000ms whatever the
load — on a rollershutter driven for a measured 26 seconds, 2-4% of its
travel every time, accumulating in the position its node believes it is
at. Sleeping to the deadline instead leaves a wake-up and a promotion,
which is milliseconds.
Sleeping until the deadline avoids adding a fixed polling delay to
timed work. New deadlines wake the timer so earlier work is not missed.
"""
self._timer_wake.clear()
try:
+1 -1
View File
@@ -150,7 +150,7 @@ class WebSocketNode(Node):
"A WebSocket node needs either inputs (to send) or outputs (to listen)"
)
# ponytail: one direction per node, as mqtt and http. Inputs and
# outputs over one socket is the NOTEPAD follow-up.
# outputs over one socket is not supported yet.
self.mode = (
WebSocketNode.Mode.SENDER if requires else WebSocketNode.Mode.LISTENER
)
+5 -11
View File
@@ -79,17 +79,12 @@ _NUMBERS = {w: n for n, w in enumerate(_ONES)} | {
def _plain(command: str) -> str:
"""The command as the model was trained on it: lower case, no sentence marks.
A transcript's "Turn on the kitchen light." reads less sure than the same
words plain, 0.80 against 0.99 with every area shown.
"""
"""Normalize case and sentence punctuation to match the training format."""
return re.sub(r"[.,!?;:]+(?=\s|$)", "", command).strip().lower()
def _aliased(prompt: str, aliases: dict[str, str]) -> str:
"""``prompt`` with the house's words in wren's, whole words in any case:
"the traverse" as "the living room light", "page too" as "patio"."""
"""Replace whole-word aliases with target names, ignoring case."""
if not aliases:
return prompt
words = {k.lower(): v for k, v in aliases.items()}
@@ -103,8 +98,7 @@ def _aliased(prompt: str, aliases: dict[str, str]) -> str:
def _digits(command: str) -> str:
"""Number words as digits: "in five minutes" kept its delay only as "in 5
minutes", and "twenty two degrees" read as 21."""
"""Convert number words to digits, as expected by the model."""
tens, ones = "|".join(_TENS), "|".join(_ONES[1:10])
command = re.sub(
rf"\b({tens})[ -]({ones})\b",
@@ -266,8 +260,8 @@ class WrenNode(Node):
)
aliases: dict[str, str] = Field(
default_factory=dict,
description="Your own words, and words heard wrong, in the model's: "
'{"traverse": "living room light", "page too": "patio"}.',
description="Map your own names to the model's target names: "
'{"desk lamp": "office light"}.',
)
examples: list[dict[str, Any]] = Field(
default_factory=list,
+3 -7
View File
@@ -6,11 +6,8 @@ listens any more. The supervisor restarts those tasks with a growing delay and
stands a flow down when one keeps failing, because a flow crash-looping every
second is worse than a flow that is visibly stopped.
Standing down is a rest, not a verdict. It used to be the end of the task: the
flow stayed dead until somebody published it or the engine restarted. On a
house that runs unattended that turns a broker rebooting at four in the morning
into a hole in the record until someone notices — so the rest expires, the
budget comes back, and the task tries again on a much longer clock.
Quarantined tasks retry after a longer cooldown with a fresh restart budget.
This lets unattended flows recover from extended connection failures.
Deliberately a plain task registry rather than a `TaskGroup`: a group cancels
its siblings when one member fails, which is the opposite of what supervision
@@ -38,8 +35,7 @@ BACKOFF = settings.FLOW_RESTART_BACKOFF
# Per task rather than per flow: a flow whose subscriber and its keepalive
# publisher both go down with the same broker spends one shared budget twice as
# fast as it was sized for, and gives up before the backoff above has reached
# its longest step. That is what took the house's inverter readings out for
# nearly five hours — six crashes across two tasks inside 41 seconds.
# its longest step.
FAILURE_BUDGET = 5
FAILURE_WINDOW = 300.0
# How long a task sits out before its budget is handed back. Minutes rather