feat(orchestrator): hub requirements 066 to 082 and 084

Radio footer, rules page, schedules editor (System timers and Claude
tasks through signed runner jobs), account usage bar, usage explorer
with a streamed usage.jsonl, queue Controls tab and override, running
tasks on the board, stale task prune with the generic dial, greyed card
stamps, commit-tree diffs from the runner preview, VS Code path links,
expired asks and decisions that stay as EXPIRED cards (asks keyed by a
call digest; an async PostToolUse hook closes those answered in the
terminal), the Match refresh hourglass, attachments by paste, drop and
paperclip in every text field (page CSP gains img-src blob: for the
thumbnails) and the limits board with profiles and a passkey to loosen.
Fixes: one red accept on a red-gate commit and no release while a risk
is open, the send bar footer segments share one height, the mic button
survives a redraw, new Match cards queue before the release card.

E2E specs were still running at commit time (operator order); their
failures follow as separate fixes.

🎯 Fix: 88 %
💥 Break: 8 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 81
🚦 Gate: ⛔ fix 88 % < 90, break 8 % > 5 (committed on the operator's word)

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-27 19:05:38 +00:00
1 parent dc0d578eca
commit f356083a24
149 files changed
+10646 -963

No files matched your search

+142
View File
@@ -0,0 +1,142 @@
"""Returns:
LIMITS_SCRIPT: the installed limits.py the hub reads, checks and writes
<council>/limits.json with (requirement 084), so it refuses exactly
what queue.py and watch.py refuse.
TARGET_SCRIPT: the installed aimd.py naming the live target file.
PROFILE_TABLE: the profiles of decision 3, per metric (lower, upper,
stop, mayday); cpu and ram hold the profile's band (Calm 50 to 70,
Balanced 70 to 90, Max 80 to 95), and every value grows from Calm
over Balanced to Max, so a calmer profile is never looser. Balanced
keeps the limits.py example but for the ram band.
"""
from __future__ import annotations
import json
import threading
from pathlib import Path
from types import ModuleType
from .errors import ToolError
from .fields import decode, expect
from .records import read_json
from .signed import signing
from .skill_scripts import script_module
LIMITS_SCRIPT = "kvb-org-organize/scripts/limits.py"
TARGET_SCRIPT = "kvb-org-queue/scripts/aimd.py"
PROFILE_TABLE = {
"calm": {"cpu": (50, 70, 85, 95), "ram": (50, 70, 85, 95), "swap": (10, 40, 75, 90), "disk": (60, 75, 90, 95), "psi": (1, 5, 20, 40)},
"balanced": {"cpu": (70, 90, 95, 99), "ram": (70, 90, 94, 97), "swap": (20, 60, 90, 97), "disk": (70, 85, 95, 98), "psi": (1, 10, 30, 60)},
"max": {"cpu": (80, 95, 98, 99), "ram": (80, 95, 97, 99), "swap": (30, 70, 93, 98), "disk": (75, 90, 96, 99), "psi": (2, 15, 40, 70)},
}
FILE_MODE = 0o600
SAVING = threading.Lock()
def limits_module(skills: Path) -> ModuleType:
"""Returns:
The installed limits.py; ToolError while it is missing or lacks the
reader and the check, so the hub never writes a file it cannot check.
"""
module = script_module(skills / LIMITS_SCRIPT)
if module is None or not all(callable(getattr(module, name, None)) for name in ("problem", "read")):
raise ToolError(f"{LIMITS_SCRIPT} is not installed: the hub checks the limits with it")
return module
def profiles(module: ModuleType) -> dict[str, dict[str, dict[str, float]]]:
return {name: {metric: dict(zip(module.LEVELS, row[metric], strict=True)) for metric in module.METRICS} for name, row in PROFILE_TABLE.items()}
def checked(module: ModuleType, value: object) -> dict:
"""Returns:
value, once limits.py problem() finds no fault in it; ToolError
naming the fault otherwise.
"""
why = module.problem(value)
if why is not None:
raise ToolError(why)
return value
def loosened(module: ModuleType, value: dict, held: dict | None) -> list[str]:
"""Args:
value: checked limits.
held: the limits in force (limits.py read()), None while the config
applies, which the hub cannot compare against.
Returns:
`<metric>.<level>` of every value above the one in force: a higher
lower or upper admits more load, a higher stop or mayday raises an
alarm threshold; every value while none is in force.
"""
pairs = [(metric, level) for metric in module.METRICS for level in module.LEVELS]
return [f"{metric}.{level}" for metric, level in pairs if held is None or value[metric][level] > held[metric][level]]
def live_target(skills: Path, council: Path) -> dict[str, float] | None:
"""Returns:
{cpu, ram}: the AIMD target queue.py last stored, each a finite
number or None; None while aimd.py is missing or no target is stored.
"""
aimd = script_module(skills / TARGET_SCRIPT)
if aimd is None or not isinstance(getattr(aimd, "NAME", None), str) or not callable(getattr(aimd, "number", None)):
return None
stored = read_json(council / aimd.NAME)
if not isinstance(stored, dict):
return None
return {resource: stored[resource] if aimd.number(stored.get(resource)) else None for resource in aimd.RESOURCES}
class Limiting:
def limits_view(self) -> dict:
"""Returns:
{limits, why, target, profiles, metrics, levels}: the limits in
force (None while the config applies), why limits.json was
refused (None when it was not), the live target (live_target()),
the profiles of PROFILE_TABLE and the metric and level names.
"""
module = limits_module(self.scripts.skills)
held, why = module.read(self.council)
return {"limits": held, "why": why, "target": live_target(self.scripts.skills, self.council), "profiles": profiles(module),
"metrics": list(module.METRICS), "levels": list(module.LEVELS)}
def limits_items(self, module: ModuleType, value: dict) -> list[dict]:
held, _ = module.read(self.council)
return [signing.limits_item(value)] if loosened(module, value, held) else []
def sign_limits(self, body: bytes) -> dict:
"""Args:
body: {limits}: the whole limits object the page wants to save.
Returns:
challenge_for() over the limits item when a value loosens, with
payload None when every value stays or tightens.
"""
payload = decode(body)
expect(payload, ("limits",))
module = limits_module(self.scripts.skills)
return self.challenge_for(self.limits_items(module, checked(module, payload["limits"])))
def save_limits(self, body: bytes) -> dict:
"""Args:
body: {limits, proof}: the whole limits object and, when a value
loosens against the limits in force at this save, the
passkey proof over signing.limits_item() of exactly it.
Returns:
limits_view() after the write; ToolError (400) for limits
limits.py refuses or a looser save without a valid proof, which
writes nothing.
"""
payload = decode(body)
expect(payload, ("limits", "proof"))
module = limits_module(self.scripts.skills)
value = checked(module, payload["limits"])
with SAVING:
for item in self.limits_items(module, value):
self.operator_proven(payload["proof"], item)
self.council.mkdir(parents=True, exist_ok=True)
module.nofollow.replace(self.council, self.council / module.NAME, json.dumps(value, indent=1, sort_keys=True) + "\n", FILE_MODE)
return self.limits_view()