feat(kvb-check-score): score journal, backfill and per-metric burndown overlays (006)

score.py names the Cost and Time metrics Tokens and Velocity from one label file and appends every scored block to a score journal in the council root. backfill.py rebuilds that journal from commit messages with its own label mapping, deterministic and idempotent, so another host can import its history. The hub serves the journal, and the Gantt burndown draws each metric as its own overlay on a right 0-100 % axis, every overlay off by default and switched by legend chips whose state the view store keeps.

🎯 Fix: 90 %
💥 Break: 5 %
💸 Cost: 100 %
⏱️ Time: 100 %
🛡️ Security: 100 %
🏆 Score: 86
🚦 Gate: ✅ 90/5, cost and time <= 100, security 100 %

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-13 12:32:54 +00:00
1 parent 3418738993
commit 5b55c39b64
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
@@ -118,6 +119,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"])}