Merge branch 'feature/score-metric-overlays' into unify/skills-20261112-night

This commit is contained in:
Kevin Veen-Birkenbach committed 2026-11-13 12:33:10 +00:00
commit 7d9f25e289
30 files changed
+1806 -142

No files matched your search

+3
View File
@@ -11,6 +11,7 @@ from .diffs import DIFF_BODY_LIMIT
from .engines import STT_LIMIT
from .exchange import PLAIN_CSP, Exchange
from .resources import RESOURCES, sampled
from .scores import scored
BODY_LIMIT = 1 << 20
UPLOAD_LIMIT = 50 << 20
@@ -119,6 +120,8 @@ class Handler(Exchange):
self.answer(hub.repositories, HTTPStatus.OK)
elif path == "/api/resources":
self.answer(lambda: sampled(hub.kept / RESOURCES, hub.span(self.query(), time.time())), HTTPStatus.OK)
elif path == "/api/scores":
self.answer(lambda: scored(hub.council, hub.scripts.skills, hub.span(self.query(), time.time())), HTTPStatus.OK)
elif path == "/api/subagents":
self.answer(lambda: hub.subagents(self.query()), HTTPStatus.OK)
elif path == "/api/runner/jobs":
+44
View File
@@ -0,0 +1,44 @@
from __future__ import annotations
from pathlib import Path
from .records import epoch, parse_line, read_json, read_regular
SCORES = "scores.jsonl"
LABELS = "kvb-check-score/labels.json"
FILE_LIMIT = 64 << 20
def checked(labels: object) -> dict | None:
"""Args:
labels: the parsed label file, or None.
Returns:
labels when its "metrics" is a non-empty object of entries with a string
emoji and label, else None.
"""
metrics = labels.get("metrics") if isinstance(labels, dict) else None
valid = isinstance(metrics, dict) and metrics and all(isinstance(metric, dict) and isinstance(metric.get("emoji"), str) and isinstance(metric.get("label"), str) for metric in metrics.values())
return labels if valid else None
def scored(council: Path, skills: Path, span: tuple[float, float]) -> dict:
"""Args:
council: the council directory holding scores.jsonl, which score.py
and backfill.py of kvb-check-score append to.
skills: the skills directory holding kvb-check-score/labels.json.
span: (begin, end) of the burndown's time range in epoch seconds.
Returns:
{"since", "until", "labels", "rows"}: the label file, None when
unreadable or not as checked() wants it, and the journal rows whose time lies within the span, in
time order.
"""
begin, end = span
try:
lines = read_regular(council / SCORES, FILE_LIMIT).splitlines()
except (OSError, ValueError):
lines = []
rows = [row for row in map(parse_line, lines) if row is not None and isinstance(row.get("values"), dict)]
inside = [row for row in rows if (moment := epoch(row.get("time"))) is not None and begin <= moment <= end]
return {"since": begin, "until": end, "labels": checked(read_json(skills / LABELS)), "rows": sorted(inside, key=lambda row: row["time"])}