093: triage.py classifies every request as open, failed, expired or stale; POST /api/requests/dismiss hides many requests hub-wide under one passkey signature with the usual undo window, ledger dismissals.json. 094: an ask or hooked decision lives as long as its Claude dialog: the hook waits the hub Settings' hook wait (1-60 min, default 60), PostToolUse, Stop, UserPromptSubmit and SessionEnd hooks close the session's cards, and a card whose hook stopped waiting reads open in Claude. Closes are bound to a per-session closer token whose sha256 the hub stores, so a local process cannot close another session's cards or forge a choice. GET /api/match/closed lets the page drop closed cards within 5 s. 096: the release signs dismissals of dropped expired cards together with the inbox entries; no radio reaches the agent. 088: the prune list is no longer capped at 50 tasks. 091: nvidia-smi's error line reaches the GPU row as its cause; limits take a batch of staged values under one proof. MEDUSA: 57 findings accepted as false positives after an independent skeptic review and the operator's word (MM-SCAN-058 regex PLA matching replay/place/replace, CODEGEN-SCAN-001 on Map.delete and labels, fixed nvidia-smi argv, localhost-only hook URLs, passkey in tooltips). Gate missed on the operator's word: break 8 %, the E2E runs after the page bundle; operator must run make orchestrator-hook and restart every Claude Code session after the install. 🎯 Fix: 92 % 💥 Break: 8 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 85 🚦 Gate: ⛔ break 8 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
264 lines
8.5 KiB
Python
264 lines
8.5 KiB
Python
from __future__ import annotations
|
|
|
|
import functools
|
|
import sys
|
|
import threading
|
|
import time
|
|
from dataclasses import dataclass
|
|
from pathlib import Path
|
|
|
|
import jinja2
|
|
from markupsafe import Markup
|
|
|
|
from .accounts import Accounts
|
|
from .approving import Approving
|
|
from .artifacts import Touched
|
|
from .asking import Asking
|
|
from .batches import Pending
|
|
from .choosing import Choosing
|
|
from .cleanup import Cleaning, Spool
|
|
from .crons import History, queue_live
|
|
from .denying import Denying
|
|
from .diffs import SEALED_SUFFIX
|
|
from .engines import Engines, Speech
|
|
from .events import Log, Watch
|
|
from .firewall import Firewall
|
|
from .gating import Gating
|
|
from .icons import sheet
|
|
from .inbox import Inbox
|
|
from .jobs import Jobs
|
|
from .language import Language, Model
|
|
from .ledger import Ledger, Marks, Reviews, Sealed
|
|
from .limiting import Limiting
|
|
from .livestate import LiveState
|
|
from .matching import Matching
|
|
from .mcp import Mcp
|
|
from .messaging import Messaging
|
|
from .names import Names
|
|
from .offices import Offices
|
|
from .presence import SNAPSHOT
|
|
from .previewing import Previewing
|
|
from .prunes import Prunes
|
|
from .queue_order import QUEUE_SCRIPT, QueueOrder
|
|
from .queueing import Queueing
|
|
from .receipts import (
|
|
NAMES,
|
|
READS,
|
|
SIGHTING,
|
|
ReceiptNames,
|
|
ReceiptReads,
|
|
sight,
|
|
sighting_pass,
|
|
)
|
|
from .redirects import RETRY_SECONDS, Redirects
|
|
from .requesting import Requesting
|
|
from .resources import RESOURCES, SAMPLES
|
|
from .revealing import Revealing
|
|
from .reviewing import Reviewing
|
|
from .rules import Offers, Rules
|
|
from .running import RUNNER_JOB
|
|
from .schedules import Schedules
|
|
from .scheduling import Scheduling
|
|
from .settings import Settings
|
|
from .signed import signing
|
|
from .skill_scripts import Runner
|
|
from .sources import Sources
|
|
from .speechgate import CpuGate
|
|
from .tasking import Tasking
|
|
from .timeline import Timeline
|
|
from .transcripts import Transcripts
|
|
from .tree import TREE_HEARTBEAT, Tree
|
|
from .triage import Triage
|
|
from .view import RADIO_WINDOW, View
|
|
from .viewstore import ViewStore
|
|
from .voicenotes import VoiceNotes
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Places:
|
|
tree_file: Path
|
|
timers: Path
|
|
vendor: Path
|
|
cleanup: Path
|
|
offices: Path
|
|
kept: Path
|
|
|
|
|
|
def environment(templates: Path) -> jinja2.Environment:
|
|
env = jinja2.Environment(
|
|
loader=jinja2.FileSystemLoader(templates),
|
|
autoescape=True,
|
|
undefined=jinja2.StrictUndefined,
|
|
trim_blocks=True,
|
|
lstrip_blocks=True,
|
|
)
|
|
env.policies["json.dumps_kwargs"] = {"sort_keys": False}
|
|
return env
|
|
|
|
|
|
@dataclass(frozen=True)
|
|
class Hub(Mcp, Reviewing, Revealing, Asking, Messaging, Choosing, Approving, Denying, Requesting, Cleaning, Offices, Tasking, Gating, Queueing, Scheduling, Limiting, Prunes, Firewall, Triage, Inbox, Matching, Previewing, Rules, Jobs, Sources, Timeline, View, Language):
|
|
council: Path
|
|
pages: Path
|
|
public_port: int
|
|
reviews: Reviews
|
|
asks: Ledger
|
|
decisions: Ledger
|
|
answers: Ledger
|
|
messages: Ledger
|
|
rule_requests: Ledger
|
|
uploads: Path
|
|
host_state: Path
|
|
transcripts: Transcripts
|
|
scripts: Runner
|
|
templates: jinja2.Environment
|
|
rules: Ledger
|
|
offers: Offers
|
|
jobs: Ledger
|
|
marks: Marks
|
|
log: Log
|
|
batches: Pending
|
|
names: Names
|
|
receipt_names: ReceiptNames
|
|
receipt_reads: ReceiptReads
|
|
watch: Watch
|
|
tree: Tree
|
|
agent_sessions: Path
|
|
runner_marker: Path
|
|
model: Model
|
|
timers: Path
|
|
kept: Path
|
|
settings: Settings
|
|
redirects: Redirects
|
|
speech: Speech
|
|
speech_gate: CpuGate
|
|
approvers: Path
|
|
vendor: Path
|
|
icons: Markup
|
|
spool: Spool
|
|
office_spool: Spool
|
|
firewall_spool: Spool
|
|
groups: Ledger
|
|
rule_sets: Ledger
|
|
touched: Touched
|
|
voice_notes: VoiceNotes
|
|
replay: Path
|
|
history: History
|
|
queue_order: QueueOrder
|
|
view_store: ViewStore
|
|
match_snapshots: Ledger
|
|
merge_previews: Ledger
|
|
live_state: LiveState
|
|
accounts: Accounts
|
|
schedule_settings: Schedules
|
|
dismissals: Ledger
|
|
|
|
def hosts(self) -> tuple[str, str]:
|
|
return f"127.0.0.1:{self.public_port}", f"localhost:{self.public_port}"
|
|
|
|
def url(self) -> str:
|
|
return f"{signing.origin_of(self.public_port)}/"
|
|
|
|
|
|
def sighting(hub: Hub, stop: threading.Event) -> threading.Thread:
|
|
"""Args:
|
|
hub: the hub whose receipt stores record the host snapshot's names
|
|
and the first sighting of each read row.
|
|
stop: ends the thread once set.
|
|
|
|
Returns:
|
|
The started daemon thread that runs sighting_pass() every SIGHTING
|
|
seconds, whether or not a page builds the state.
|
|
"""
|
|
step = functools.partial(sighting_pass, hub.scripts.skills, hub.council, hub.receipt_names, hub.receipt_reads, hub.agent_sessions, RADIO_WINDOW)
|
|
thread = threading.Thread(target=sight, args=(step, hub.receipt_reads, stop, SIGHTING), name="receipt names", daemon=True)
|
|
thread.start()
|
|
return thread
|
|
|
|
|
|
def stations(hub: Hub, stop: threading.Event) -> threading.Thread:
|
|
"""Args:
|
|
hub: the hub whose unresolved stations are retried.
|
|
stop: ends the thread once set.
|
|
|
|
Returns:
|
|
The started daemon thread that runs retry_stations() at the start and
|
|
every RETRY_SECONDS, printing why a station still does not resolve.
|
|
"""
|
|
|
|
def run() -> None:
|
|
while True:
|
|
for problem in hub.retry_stations():
|
|
print(f"station redirect: {problem}", file=sys.stderr, flush=True)
|
|
if stop.wait(RETRY_SECONDS):
|
|
return
|
|
|
|
thread = threading.Thread(target=run, name="station redirects", daemon=True)
|
|
thread.start()
|
|
return thread
|
|
|
|
|
|
def open_hub(council: Path, pages: Path, public_port: int, state: Path, host_state: Path, transcripts: Path, scripts: Runner, templates: Path, places: Places, model: Model, engines: Engines, approvers: Path, redirects: Redirects, live_ttl: float) -> Hub:
|
|
uploads = state / "uploads"
|
|
uploads.mkdir(exist_ok=True)
|
|
reviews = Reviews(state)
|
|
speech = Speech(engines, state / "tts")
|
|
messages = Ledger(state / "messages.json")
|
|
settings = Settings(state / "settings.json")
|
|
return Hub(
|
|
speech_gate=CpuGate(samples=places.kept / RESOURCES / SAMPLES, threshold=lambda: settings.get()["speech"]["threshold"], clock=time.time),
|
|
vendor=places.vendor,
|
|
icons=sheet(places.vendor, templates),
|
|
spool=Spool(places.cleanup).ready(),
|
|
office_spool=Spool(places.offices).ready(),
|
|
firewall_spool=Spool(state / "firewall").ready(),
|
|
groups=Ledger(state / "groups.json"),
|
|
rule_sets=Ledger(state / "rule-sets.json"),
|
|
touched=Touched(reviews.stored),
|
|
approvers=approvers,
|
|
speech=speech,
|
|
voice_notes=VoiceNotes(state / "voice", host_state / "voice", speech, lambda: {message["voice"] for message in messages.listed() if message.get("voice")}),
|
|
replay=state / "replay" / "messages.json",
|
|
view_store=ViewStore(state / "view.json"),
|
|
accounts=Accounts(state, places.kept, council),
|
|
schedule_settings=Schedules(council),
|
|
match_snapshots=Ledger(state / "match.json"),
|
|
merge_previews=Ledger(state / "previews.json"),
|
|
live_state=LiveState(live_ttl),
|
|
rules=Ledger(state / "rules.json"),
|
|
offers=Offers(),
|
|
jobs=Ledger(state / "jobs.json"),
|
|
marks=Marks(state / "marks.json"),
|
|
log=Log(state / "log.jsonl"),
|
|
batches=Pending(lambda: settings.undo()),
|
|
names=Names(state / "names.json"),
|
|
receipt_names=ReceiptNames(state / NAMES),
|
|
receipt_reads=ReceiptReads(state / READS),
|
|
settings=settings,
|
|
redirects=redirects,
|
|
watch=Watch(),
|
|
tree=Tree(file=places.tree_file, heartbeat=state / TREE_HEARTBEAT, lock=threading.Lock(), cached=None, stamp=None),
|
|
agent_sessions=state / SNAPSHOT,
|
|
runner_marker=state / RUNNER_JOB,
|
|
model=model,
|
|
timers=places.timers,
|
|
kept=places.kept,
|
|
council=council,
|
|
history=History(council / queue_live.HISTORY),
|
|
queue_order=QueueOrder(script=scripts.skills / QUEUE_SCRIPT, council=council, home=state),
|
|
pages=pages,
|
|
public_port=public_port,
|
|
reviews=reviews,
|
|
asks=Sealed(state / "asks.json", reviews.pages, SEALED_SUFFIX["ask"]),
|
|
decisions=Ledger(state / "decisions.json"),
|
|
answers=Ledger(state / "answers.json"),
|
|
messages=messages,
|
|
rule_requests=Ledger(state / "rule-requests.json"),
|
|
dismissals=Ledger(state / "dismissals.json"),
|
|
uploads=uploads,
|
|
host_state=host_state,
|
|
transcripts=Transcripts(transcripts),
|
|
scripts=scripts,
|
|
templates=environment(templates),
|
|
)
|