Files
skills/orchestrator/kvb_orchestrator/livestate.py
T
Kevin Veen-BirkenbachandClaude Opus 5.5 0fad1bfae3 feat: hub and skills requirements 032 to 063
Hub: send in the field (032), coherent speak box (033), stream head band (034), Match at full width with its pile (035, 036), Home without the outer box (037), badge to Match (038), rejects that survive a changed or withdrawn card (039), the release card (040), code marks in the review diff (041), why Deny is off (042), the undo window clock (043), widgets without inner boxes (044), the Artifacts head on one line (045), accepting a red gate's risk (046), one code box (047), done rows greyed and folded (048), one control height (049), menus that stay open (050), radio settings in the Device card (051), bubbles beside the modes (052), agent settings on every face and name (053), pin only by menu (054), WASD in Match (055), the flowing card edge (056), Schedules in Controls (057) and the hub poll cost (059).

Skills: the coach leaves for its own repository kevinveenbirkenbach/coach (058; test_install pins its four skills in skills-lock.json and stays red until that repository is published and pinned), hooks and timers start fewer processes (060), council files on hot paths stay bounded and mirror by marker instead of mtime (061), scripts and hooks hand agents less output (062), and block.py builds the commit table and message block in one run (063). Requirement documents 032 to 063 with their implementation amendments.

MEDUSA false positives accepted after kvb-think-criticize (36 lines): MM-SCAN-058 (pla inside replace or plan), JB-SCAN-616/641 (the local clip helper), CODEGEN-SCAN-001 (drop-in paths), CGS-SCAN-029 (systemctl argv from constants), CGS-SCAN-040 (runner poll loop), FLA-SCAN-055 (feedback), WM-SCAN-354, AI-BACKDOOR-006, GENAI-SCAN-1270, B604 (runner shell path for passkey-verified commands), TC004, EXA002, EXA006, EXA010 and WEB-SSRF.

🎯 Fix: 92 %
💥 Break: 8 %
💸 Tokens: 89 %
⏱️ Velocity: –
🛡️ Security: ~100 %
🏆 Score: 95
🚦 Gate: ⛔ break 8 % > 5

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-26 08:44:15 +00:00

65 lines
2.3 KiB
Python

from __future__ import annotations
import json
import threading
import time
from collections.abc import Callable
LIVE_TTL = 2.0
class LiveState:
def __init__(self, ttl: float) -> None:
"""Args:
ttl: seconds a finished build serves later callers of the same
key; 0 rebuilds every time but still one build at a time.
"""
self.ttl = ttl
self.guard = threading.Lock()
self.locks: dict[object, threading.Lock] = {}
self.built: dict[object, tuple[int, float, dict, bytes]] = {}
self.generation = 0
def invalidate(self) -> None:
with self.guard:
self.generation += 1
def slot(self, moment: float) -> float:
"""Returns:
moment rounded down to a multiple of ttl, so polls whose window
starts within one ttl share a key; moment itself for a zero ttl.
"""
return moment - moment % self.ttl if self.ttl > 0 else moment
def shared(self, key: object, build: Callable[[], dict]) -> dict:
"""Returns:
build()'s result; callers arriving while it runs wait for it and
share it, and so do callers within ttl after it, until
invalidate() is called.
"""
return self.entry(key, build)[0]
def encoded(self, key: object, build: Callable[[], dict]) -> bytes:
"""Returns:
The JSON bytes of shared(key, build), encoded once per build.
"""
return self.entry(key, build)[1]
def entry(self, key: object, build: Callable[[], dict]) -> tuple[dict, bytes]:
with self.guard:
lock = self.locks.setdefault(key, threading.Lock())
with lock:
with self.guard:
generation = self.generation
hit = self.built.get(key)
if hit is not None and hit[0] == generation and time.monotonic() - hit[1] < self.ttl:
return hit[2], hit[3]
value = build()
body = json.dumps(value).encode()
with self.guard:
at = time.monotonic()
self.built = {old: found for old, found in self.built.items() if at - found[1] < self.ttl}
self.built[key] = (generation, at, value, body)
self.locks = {old: held for old, held in self.locks.items() if old in self.built}
return value, body