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:
1 parent
dc0d578eca
commit
f356083a24
149 files changed
+10646
-963
No files matched your search
@@ -1,12 +1,13 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import json
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from .errors import ToolError
|
||||
from .fields import decode
|
||||
from .errors import ToolError, Unsigned
|
||||
from .records import read_json, write_atomic
|
||||
from .settings import CLOCK, flag, section
|
||||
from .signed import signing
|
||||
|
||||
SCHEDULES = "schedules.json"
|
||||
SCHEDULES_VIEW = "schedules-view.json"
|
||||
@@ -17,41 +18,110 @@ ROWS = {
|
||||
"queue-cleanup": {"on": True, "at": ["00:00", "12:00"]},
|
||||
"code-graph": {"on": True},
|
||||
}
|
||||
UNITS_KEY = "units"
|
||||
HUB_UNIT = re.compile(r"kvb-orchestrator-[a-z0-9-]{1,64}\.timer")
|
||||
HOURS = (1, 24)
|
||||
TIMES_LIMIT = 6
|
||||
VIEW_LIMIT = 200
|
||||
VIEW_LIMIT = 500
|
||||
VIEW_TEXT = 2000
|
||||
VIEW_KEYS = ("name", "kind", "owner", "unit", "file", "schedule", "next", "last", "event", "command", "off")
|
||||
VIEW_KEYS = ("name", "source", "kind", "unit", "file", "task", "schedule", "next", "last", "on", "dropin", "error", "command")
|
||||
CRON_FIELDS = (("minute", 0, 59), ("hour", 0, 23), ("day of month", 1, 31), ("month", 1, 12), ("day of week", 0, 6))
|
||||
CRON_PART = re.compile(r"(?:\*|([0-9]{1,2})(?:-([0-9]{1,2}))?)(?:/([0-9]{1,2}))?")
|
||||
|
||||
|
||||
def timing(name: str, row: dict) -> dict:
|
||||
"""Args:
|
||||
name: the row or unit, for the errors.
|
||||
row: a timer row with at (1 to TIMES_LIMIT distinct HH:MM) or
|
||||
calendar (an OnCalendar expression signing.SCHEDULE_CALENDAR
|
||||
matches), not both.
|
||||
|
||||
Returns:
|
||||
{at} with the times sorted, or {calendar}.
|
||||
"""
|
||||
if "at" in row and "calendar" in row:
|
||||
raise ToolError(f"{name} takes at or calendar, not both")
|
||||
if "calendar" in row:
|
||||
calendar = row["calendar"]
|
||||
if not isinstance(calendar, str) or not signing.SCHEDULE_CALENDAR.fullmatch(calendar):
|
||||
raise ToolError(f"{name}.calendar must be an OnCalendar expression of letters, digits, spaces and * : , . / ~ _ + -")
|
||||
return {"calendar": calendar}
|
||||
times = row["at"]
|
||||
if not isinstance(times, list) or not 1 <= len(times) <= TIMES_LIMIT or not all(isinstance(time, str) and CLOCK.fullmatch(time) for time in times):
|
||||
raise ToolError(f"{name}.at must hold 1 to {TIMES_LIMIT} times like 17:00")
|
||||
if len(set(times)) != len(times):
|
||||
raise ToolError(f"{name}.at names a time twice")
|
||||
return {"at": sorted(times)}
|
||||
|
||||
|
||||
def valid_row(name: object, value: object) -> dict:
|
||||
"""Args:
|
||||
name: one of ROWS.
|
||||
value: the row: on, plus every (hours from 1 to 24) for a reminder
|
||||
hook or at (1 to TIMES_LIMIT distinct HH:MM) for a timer.
|
||||
hook, or at or calendar (timing()) for a timer.
|
||||
|
||||
Returns:
|
||||
The row, times sorted.
|
||||
"""
|
||||
if not isinstance(name, str) or name not in ROWS:
|
||||
raise ToolError(f"no such schedule: {name}")
|
||||
row = section(value, str(name), tuple(ROWS[name]))
|
||||
default = ROWS[name]
|
||||
calendar = "at" in default and isinstance(value, dict) and "calendar" in value
|
||||
row = section(value, name, ("on", "calendar") if calendar else tuple(default))
|
||||
found = {"on": flag(row["on"], f"{name}.on")}
|
||||
if "every" in row:
|
||||
every = row["every"]
|
||||
if isinstance(every, bool) or not isinstance(every, int) or not HOURS[0] <= every <= HOURS[1]:
|
||||
raise ToolError(f"{name}.every must be a whole number of hours from {HOURS[0]} to {HOURS[1]}")
|
||||
found["every"] = every
|
||||
if "at" in row:
|
||||
times = row["at"]
|
||||
if not isinstance(times, list) or not 1 <= len(times) <= TIMES_LIMIT or not all(isinstance(time, str) and CLOCK.fullmatch(time) for time in times):
|
||||
raise ToolError(f"{name}.at must hold 1 to {TIMES_LIMIT} times like 17:00")
|
||||
if len(set(times)) != len(times):
|
||||
raise ToolError(f"{name}.at names a time twice")
|
||||
found["at"] = sorted(times)
|
||||
if "at" in default:
|
||||
found.update(timing(name, row))
|
||||
return found
|
||||
|
||||
|
||||
def valid_unit(unit: object, value: object) -> dict:
|
||||
"""Args:
|
||||
unit: a hub timer HUB_UNIT matches; any other text is a System timer
|
||||
or a Claude task, which takes the signed route.
|
||||
value: on, plus at or calendar (timing()) for a retime; without
|
||||
them the reconciler removes the unit's drop-in.
|
||||
|
||||
Returns:
|
||||
The override, times sorted.
|
||||
"""
|
||||
if not isinstance(unit, str):
|
||||
raise ToolError("unit must be a text")
|
||||
if not HUB_UNIT.fullmatch(unit):
|
||||
raise Unsigned(f"{unit} is no kvb-orchestrator- timer: a System timer or a Claude task needs the passkey")
|
||||
keys = ("on", *(key for key in ("at", "calendar") if isinstance(value, dict) and key in value))
|
||||
row = section(value, unit, keys)
|
||||
found = {"on": flag(row["on"], f"{unit}.on")}
|
||||
return {**found, **timing(unit, row)} if len(keys) > 1 else found
|
||||
|
||||
|
||||
def cron_part(part: str, low: int, high: int) -> bool:
|
||||
found = CRON_PART.fullmatch(part)
|
||||
if found is None:
|
||||
return False
|
||||
start, end, step = (None if group is None else int(group) for group in found.groups())
|
||||
first = low if start is None else start
|
||||
last = high if start is None or (end is None and step is not None) else start if end is None else end
|
||||
return low <= first <= last <= high and step != 0
|
||||
|
||||
|
||||
def valid_cron(cron: object) -> str:
|
||||
"""Returns:
|
||||
cron, five fields of `*`, numbers, ranges, lists and steps within
|
||||
CRON_FIELDS; ToolError naming the first field out of range.
|
||||
"""
|
||||
if not isinstance(cron, str) or not signing.CRON.fullmatch(cron):
|
||||
raise ToolError("cron must be 5 fields of digits and * , / -, like 0 9 * * 1-5")
|
||||
for text, (field, low, high) in zip(cron.split(" "), CRON_FIELDS, strict=True):
|
||||
if not all(cron_part(part, low, high) for part in text.split(",")):
|
||||
raise ToolError(f"cron {field} field {text} must stay within {low} to {high}")
|
||||
return cron
|
||||
|
||||
|
||||
def stored_rows(council: Path) -> dict:
|
||||
"""Returns:
|
||||
Every row of ROWS from schedules.json; a missing, linked or malformed
|
||||
@@ -67,11 +137,27 @@ def stored_rows(council: Path) -> dict:
|
||||
return rows
|
||||
|
||||
|
||||
def stored_units(council: Path) -> dict:
|
||||
"""Returns:
|
||||
The hub timer overrides of schedules.json; a malformed one is left
|
||||
out, as the reconciler leaves it alone.
|
||||
"""
|
||||
data = read_json(council / SCHEDULES)
|
||||
units = data.get(UNITS_KEY) if isinstance(data, dict) else None
|
||||
kept = {}
|
||||
for unit, value in units.items() if isinstance(units, dict) else ():
|
||||
try:
|
||||
kept[unit] = valid_unit(unit, value)
|
||||
except (ToolError, Unsigned):
|
||||
continue
|
||||
return kept
|
||||
|
||||
|
||||
def view_rows(council: Path) -> dict:
|
||||
"""Returns:
|
||||
{at, rows}: what the host reconciler last saw, each row with the
|
||||
VIEW_KEYS as strings or numbers; {at: None, rows: []} before its first
|
||||
run or for a malformed file.
|
||||
VIEW_KEYS as texts, numbers or true/false; {at: None, rows: []}
|
||||
before its first run or for a malformed file.
|
||||
"""
|
||||
data = read_json(council / SCHEDULES_VIEW)
|
||||
rows = data.get("rows") if isinstance(data, dict) else None
|
||||
@@ -85,10 +171,10 @@ def view_rows(council: Path) -> dict:
|
||||
return {"at": at, "rows": kept}
|
||||
|
||||
|
||||
def shown(value: object) -> str | float | None:
|
||||
def shown(value: object) -> str | float | bool | None:
|
||||
if isinstance(value, str):
|
||||
return value[:VIEW_TEXT]
|
||||
if isinstance(value, int | float) and not isinstance(value, bool):
|
||||
if isinstance(value, bool | int | float):
|
||||
return value
|
||||
return None
|
||||
|
||||
@@ -98,15 +184,21 @@ class Schedules:
|
||||
self.council = council
|
||||
|
||||
def view(self) -> dict:
|
||||
return {"rows": stored_rows(self.council), "host": view_rows(self.council)}
|
||||
return {"rows": stored_rows(self.council), "units": stored_units(self.council), "host": view_rows(self.council)}
|
||||
|
||||
def save(self, body: bytes) -> dict:
|
||||
def save(self, payload: object) -> dict:
|
||||
"""Args:
|
||||
body: {row, value}: one row of ROWS and its new value; every
|
||||
other row keeps its stored value.
|
||||
payload: {row, value}: one row of ROWS and its new value, or
|
||||
{unit, value}: one hub timer and its override (valid_unit());
|
||||
every other row and override keeps its stored value.
|
||||
"""
|
||||
data = section(decode(body), "body", ("row", "value"))
|
||||
rows = {**stored_rows(self.council), data["row"]: valid_row(data["row"], data["value"])}
|
||||
if isinstance(payload, dict) and "unit" in payload:
|
||||
data = section(payload, "body", ("unit", "value"))
|
||||
changed = {UNITS_KEY: {**stored_units(self.council), data["unit"]: valid_unit(data["unit"], data["value"])}}
|
||||
else:
|
||||
data = section(payload, "body", ("row", "value"))
|
||||
changed = {data["row"]: valid_row(data["row"], data["value"])}
|
||||
stored = {**stored_rows(self.council), UNITS_KEY: stored_units(self.council), **changed}
|
||||
self.council.mkdir(parents=True, exist_ok=True)
|
||||
write_atomic(self.council / SCHEDULES, json.dumps(rows, sort_keys=True).encode())
|
||||
write_atomic(self.council / SCHEDULES, json.dumps(stored, sort_keys=True).encode())
|
||||
return self.view()
|
||||
Reference in new issue
Block a user