feat(hub): radio Morse mode with WPM speed, per-agent pitch and a 0-100 % speech threshold

Morse keys every picked row whole: class prosign (SOS for MAYDAY), DE with the sender's clear name and the full text, after PARIS timing at the hub's morse.wpm (5-40, default 20) and in the sender's own 550-850 Hz tone from the same sha256 slot as its voice. A higher class cuts a keying row, which keys again whole after it. The speech threshold runs 0-100 % in steps of 10, 100 always open, 0 never. The History card moves into page-radiolog.js to keep page-radioview.js under 500 lines.

🎯 Fix: 85 %
💥 Break: 7 %
💸 Tokens: 100 %
⏱️ Velocity: 100 %
🛡️ Security: 100 %
🏆 Score: 79
🚦 Gate: ⛔ fix 85 % < 90, break 7 % > 5

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-15 09:46:05 +00:00
1 parent ded7c9a7b6
commit 86d539a95f
22 files changed
+1147 -286

No files matched your search

+28 -2
View File
@@ -44,6 +44,7 @@ HEARING_HOUR = 3600
HEARING_BUDGET = 5 * STT_SECONDS
NOISE = re.compile(r"\[[^\]\n]{0,40}\]")
PLACEHOLDERS = frozenset({0, 0xFFFFFFFF})
PITCH = (550, 850)
def voice_models(folder: Path) -> list[Path]:
@@ -92,6 +93,18 @@ def unreachable(path: Path, part: str, mode: int, ability: str) -> str:
return f"{part} {path} is missing or not {ability}"
def slot(key: str, count: int) -> int:
"""Args:
key: the speaker's session id or directory key.
count: how many slots there are, at least 1.
Returns:
The slot sha256(key) picks from count: the one mapping from a speaker
to its voice and to its Morse pitch.
"""
return int(digest(key), 16) % count
def voice_of(key: str, pool: list[str], operator: str) -> str:
"""Args:
key: the speaker's session id or directory key; HUMAN is the operator.
@@ -101,11 +114,24 @@ def voice_of(key: str, pool: list[str], operator: str) -> str:
Returns:
operator for HUMAN or when the pool is empty, otherwise the voice
sha256(key) picks from the pool.
the speaker's slot picks from the pool.
"""
if key == HUMAN or not pool:
return operator
return pool[int(digest(key), 16) % len(pool)]
return pool[slot(key, len(pool))]
def pitch_of(key: str) -> int:
"""Args:
key: the speaker's session id or directory key, as voice_of takes it.
Returns:
The speaker's Morse tone in Hz from PITCH[0] to PITCH[1], picked by
the same slot as its voice, so the same speaker always keys the same
tone, installed voices or not.
"""
low, high = PITCH
return low + slot(key, high - low + 1)
def wav_seconds(body: bytes, seconds: int) -> float:
+19 -4
View File
@@ -11,12 +11,15 @@ from .errors import ToolError
from .fields import FIELDS, NAME_LIMIT, expect
from .rates import METRICS, PERIOD_NAMES
from .records import read_json, write_atomic
from .speechgate import ALWAYS
THEMES = ("sky", "light", "dark", "custom")
ESTIMATIONS = ("none", "points")
TRENDS = ("off", "regression", "velocity")
TREND_DAYS = (1, 365)
THRESHOLDS = tuple(range(30, 91, 10))
THRESHOLDS = tuple(range(0, ALWAYS + 1, 10))
WPM = (5, 40)
LATE = ("rates", "morse")
RADIO_MOVED = ("sounds", "squelch")
SPEECH_MOVED = ("on", "classes", "muted")
COLOR = re.compile(r"#[0-9a-f]{6}")
@@ -37,6 +40,7 @@ SETTINGS = {
"channels": {"browser": True, "sounds": True, "aloud": True, "title": True},
"streams": [],
"speech": {"threshold": 50},
"morse": {"wpm": 20},
"space": {
"graph": {"axis": "none", "yaw": 30.0, "pitch": 20.0, "zoom": 1.0, "pan_x": 0.0, "pan_y": 0.0},
"sky": {"azimuth": 180.0, "altitude": 0.0, "fov": 180.0},
@@ -154,6 +158,15 @@ def speech_setting(raw: object) -> dict:
return {"threshold": threshold}
def morse_setting(raw: object) -> dict:
entry = section(raw, "morse", tuple(SETTINGS["morse"]))
low, high = WPM
wpm = entry["wpm"]
if isinstance(wpm, bool) or not isinstance(wpm, int) or not low <= wpm <= high:
raise ToolError(f"morse.wpm must be a whole number from {low} to {high} words per minute")
return {"wpm": wpm}
def space_setting(raw: object) -> dict:
entry = section(raw, "space", tuple(SETTINGS["space"]))
graph = section(entry["graph"], "space.graph", tuple(SETTINGS["space"]["graph"]))
@@ -205,6 +218,7 @@ def valid_settings(raw: object) -> dict:
"channels": channels_setting(data["channels"]),
"streams": [stream_entry(entry, index) for index, entry in enumerate(data["streams"])],
"speech": speech_setting(data["speech"]),
"morse": morse_setting(data["morse"]),
"space": space_setting(data["space"]),
"estimation": data["estimation"],
"trend": trend_setting(data["trend"]),
@@ -215,10 +229,11 @@ def valid_settings(raw: object) -> dict:
def completed(raw: object, saved: dict) -> object:
"""Returns:
raw with the saved rates when it names none, as a page loaded before
the rates chip existed sends it; anything else unchanged.
raw with the saved value of each LATE section it names none of, as a
page loaded before the rates chip or the Morse speed existed sends
it; anything else unchanged.
"""
return {**raw, "rates": saved["rates"]} if isinstance(raw, dict) and "rates" not in raw else raw
return {**{key: saved[key] for key in LATE if key not in raw}, **raw} if isinstance(raw, dict) else raw
def radio_moved(stored: object) -> object:
+10 -9
View File
@@ -12,6 +12,7 @@ from .records import READ_FLAGS, epoch, parse_line
FRESH = 120
TAIL = 1 << 16
ALWAYS = 100
def tail_lines(path: Path, size: int) -> list[str]:
@@ -65,12 +66,14 @@ class CpuGate:
def state(self) -> dict:
"""Returns:
{"threshold", "cpu", "open"}: open only while the latest fresh
sample lies below the threshold; cpu None without one.
{"threshold", "cpu", "open"}: open while the latest fresh sample
lies below the threshold, and at a threshold of ALWAYS even
without one, so a threshold of 0 never opens; cpu None without a
fresh sample.
"""
cpu = latest_cpu(self.samples, self.clock())
limit = self.threshold()
return {"threshold": limit, "cpu": cpu, "open": cpu is not None and cpu < limit}
return {"threshold": limit, "cpu": cpu, "open": limit >= ALWAYS or (cpu is not None and cpu < limit)}
def admit(self, line: str) -> None:
"""Args:
@@ -79,14 +82,12 @@ class CpuGate:
same few lines per voice and outlives the cache trim.
Returns:
None when the line may render; otherwise it raises Held busy
while the latest fresh sample is at or above the threshold and
Held unknown without a fresh sample.
None when the line may render; otherwise, while the gate is shut,
it raises Held unknown without a fresh sample and Held busy with
one.
"""
if line in PROCEDURE_LINES:
return
gate = self.state()
if gate["cpu"] is None:
raise Held("unknown")
if not gate["open"]:
raise Held("busy")
raise Held("unknown" if gate["cpu"] is None else "busy")
+4 -2
View File
@@ -15,6 +15,7 @@ from .council import (
silence_of,
)
from .crons import queue_entries
from .engines import pitch_of
from .errors import ToolError
from .events import KINDS, VIEWS
from .fields import decode, instant, single
@@ -107,8 +108,9 @@ class View:
source = directory.key(row["from"], row["ts"])
targets = [directory.key(name, row["ts"]) for name in row["to"]]
called = [directory.at(key, row["ts"]) or name for key, name in zip(targets, row["to"], strict=True)]
word, rest = phrase_parts(row["class"], directory.at(source, row["ts"]) or row["from"], called, row["text"])
spoken = {"speech": joined((word, rest)), "word": word, "rest": rest, "voice": self.speech.voice_of(source)}
speaker = directory.at(source, row["ts"]) or row["from"]
word, rest = phrase_parts(row["class"], speaker, called, row["text"])
spoken = {"speech": joined((word, rest)), "word": word, "rest": rest, "voice": self.speech.voice_of(source), "pitch": pitch_of(source), "speaker": speaker, "called": called}
read = read_of(inlined, row["ts"])
radio.append({**row, "source": source, "targets": targets, "now": directory.now(source), **spoken, **read})
grant_rows = [{**grant, "target": directory.key(grant["to"], grant["ts"])} for grant in grants(history, (begin, end), claims, tasks)]