feat(orchestrator): Match cards show the score line as metric chips
scores.metric_chips() reads each metric's value from an agent's free score line by emoji, label or former label from labels.json, and Match cards render them as chips under the name instead of the raw score pill. New e2e: real mouse swipes send later, reject, refuse a stale card and accept at three widths; the release e2e gains its negative control. Fix stays below 90: the swipe e2e ended in ERROR in the aborted final run of 2026-11-17 without a traceback; the master gate reruns it. 🎯 Fix: 88 % 💥 Break: 3 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 85 🚦 Gate: ⛔ fix 88 % < 90 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
b711c3b83b
commit
78d4e4a6aa
8 files changed
+302
-16
No files matched your search
@@ -10,6 +10,7 @@ from .fields import decode, expect, field
|
||||
from .payloads import denied_roots, payload_files, payload_hash
|
||||
from .records import digest, iso_epoch
|
||||
from .register import REGISTER, adder, operator_rows, read_register
|
||||
from .scores import metric_chips, score_labels
|
||||
from .signed import signing
|
||||
from .tree import inside
|
||||
|
||||
@@ -46,7 +47,8 @@ class Matching:
|
||||
claims = read_claims(self.council)
|
||||
names = self.names.listed()
|
||||
reviews = self.reviews.pending()
|
||||
cards = [{**self.commit_card(review, reviews, born_of(review.get("agent", ""), names, claims)), "to": requester_of(claims, review.get("agent", ""))[0]} for review in reviews]
|
||||
labels = score_labels(self.scripts.skills)
|
||||
cards = [{**self.commit_card(review, reviews, born_of(review.get("agent", ""), names, claims), labels), "to": requester_of(claims, review.get("agent", ""))[0]} for review in reviews]
|
||||
tasks = read_register(self.council / REGISTER)
|
||||
held = self.open_jobs()
|
||||
rows = [row for row in operator_rows(tasks) if row["check"] != "decision" and row["task"] not in held]
|
||||
@@ -61,7 +63,7 @@ class Matching:
|
||||
self.match_snapshots.remove(snapshot["id"])
|
||||
return {"now": now, "cards": cards}
|
||||
|
||||
def commit_card(self, review: dict, reviews: list[dict], born: float | None) -> dict:
|
||||
def commit_card(self, review: dict, reviews: list[dict], born: float | None, labels: dict | None) -> dict:
|
||||
newer = [other["id"] for other in reviews if other["created"] > review["created"] and (other["worktree"], other["branch"]) == (review["worktree"], review["branch"])]
|
||||
live = review.get("live_tree")
|
||||
reason = f"added again as review:{newer[-1]}" if newer else "the staged tree changed since it was added" if live not in (None, review["tree"]) else ""
|
||||
@@ -72,7 +74,8 @@ class Matching:
|
||||
place = {"repo": repository_of(review.get("repo", "")), "branch": review["branch"], "worktree": review["worktree"]}
|
||||
return {
|
||||
"id": f"review:{review['id']}", "kind": "commit", "ref": review["id"], "agent": review.get("agent", ""), "born": born, "created_ts": iso_epoch(review["created"]),
|
||||
**place, "title": review["title"], "score": review.get("score", ""), "gate": review.get("gate", ""), "hash": review["tree"], "live_hash": live or review["tree"],
|
||||
**place, "title": review["title"], "score": review.get("score", ""), "metrics": metric_chips(review.get("score", ""), labels), "gate": review.get("gate", ""),
|
||||
"hash": review["tree"], "live_hash": live or review["tree"],
|
||||
"stale": bool(reason), "stale_reason": reason, "files": files, "command": "", "directory": review["worktree"], "reason": "",
|
||||
}
|
||||
|
||||
@@ -88,7 +91,7 @@ class Matching:
|
||||
repo, branch, worktree = place_of(row["directory"], scan)
|
||||
return {
|
||||
"id": card_id, "kind": "command", "ref": row["task"], "agent": agent, "born": born, "created_ts": snapshot["taken"], "repo": repo, "branch": branch, "worktree": worktree,
|
||||
"title": row["command"], "score": "", "gate": "", "hash": snapshot["hash"], "live_hash": live, "stale": stale,
|
||||
"title": row["command"], "score": "", "metrics": [], "gate": "", "hash": snapshot["hash"], "live_hash": live, "stale": stale,
|
||||
"stale_reason": "a payload file changed since it was added" if stale else "", "files": snapshot["files"], "command": row["command"], "directory": row["directory"],
|
||||
"reason": row["why"], "sha256": digest(row["command"]),
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
from __future__ import annotations
|
||||
|
||||
import re
|
||||
from pathlib import Path
|
||||
|
||||
from .records import epoch, parse_line, read_json, read_regular
|
||||
@@ -7,6 +8,8 @@ from .records import epoch, parse_line, read_json, read_regular
|
||||
SCORES = "scores.jsonl"
|
||||
LABELS = "kvb-check-score/labels.json"
|
||||
FILE_LIMIT = 64 << 20
|
||||
VARIATION = "️"
|
||||
VALUE = r"([0-9]+(?:\.[0-9]+)?(?:\s*%)?|–|-|new)(?![0-9.])"
|
||||
|
||||
|
||||
def checked(labels: object) -> dict | None:
|
||||
@@ -51,4 +54,30 @@ def scored(council: Path, skills: Path, span: tuple[float, float]) -> dict:
|
||||
"""
|
||||
begin, end = span
|
||||
inside = [row for row in journal(council) 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"])}
|
||||
return {"since": begin, "until": end, "labels": score_labels(skills), "rows": sorted(inside, key=lambda row: row["time"])}
|
||||
|
||||
|
||||
def score_labels(skills: Path) -> dict | None:
|
||||
return checked(read_json(skills / LABELS))
|
||||
|
||||
|
||||
def metric_chips(score: str, labels: dict | None) -> list[dict]:
|
||||
"""Args:
|
||||
score: an agent's free score line, such as line 1 or the message
|
||||
block of score.py.
|
||||
labels: the label file as checked() returns it, or None.
|
||||
|
||||
Returns:
|
||||
In label order, per metric whose emoji (with or without its
|
||||
variation selector) or label or former label stands right before a
|
||||
value in score, the first such value: {"id", "emoji", "label",
|
||||
"value"}; none without labels.
|
||||
"""
|
||||
found = []
|
||||
for key, metric in (labels or {}).get("metrics", {}).items():
|
||||
emoji = re.escape(metric["emoji"].removesuffix(VARIATION)) + f"{VARIATION}?"
|
||||
names = "|".join(re.escape(name) for name in (metric["label"], *metric.get("former", [])))
|
||||
match = re.search(rf"(?:{emoji}\s*(?:(?:{names})\s*:?\s*)?|\b(?:{names})\s*:?\s*){VALUE}", score, re.IGNORECASE)
|
||||
if match:
|
||||
found.append({"id": key, "emoji": metric["emoji"], "label": metric["label"], "value": " ".join(match.group(1).split())})
|
||||
return found
|
||||
@@ -202,10 +202,13 @@
|
||||
|
||||
function matchHead(card) {
|
||||
const [kindName, kindTone, kindIcon] = MATCH_KINDS[card.kind] || [card.kind, "neutral", "bi-collection"];
|
||||
const metrics = card.metrics || [];
|
||||
return h("header", {class: "match-head"},
|
||||
h("div", {class: "match-who"}, face(card.agent || "-", true), h("strong", {class: "match-name"}, revealed(card.agent || "unknown agent")), h("span", {class: "match-age"}, ageWords(card.born))),
|
||||
metrics.length ? h("ul", {class: "match-metrics", "aria-label": "Scores"}, metrics.map((metric) => h("li", {class: "match-metric", "data-metric": metric.id, title: revealed(`${metric.label}: ${metric.value}`)},
|
||||
h("span", {"aria-hidden": "true"}, metric.emoji), h("span", {class: "match-metric-label"}, metric.label), h("strong", {}, revealed(metric.value))))) : null,
|
||||
h("div", {class: "states"}, h("span", {class: "pill", "data-tone": kindTone}, icon(kindIcon), kindName), card.gate ? pill(`gate ${card.gate}`, card.gate === "pass" ? "ok" : "bad") : null,
|
||||
card.score ? h("span", {class: "pill", "data-tone": "neutral"}, revealed(card.score)) : null, card.stale ? h("span", {class: "pill match-stale-pill", "data-tone": "bad"}, icon("bi-hourglass-split"), "stale") : null),
|
||||
card.score && !metrics.length ? h("span", {class: "pill", "data-tone": "neutral"}, revealed(card.score)) : null, card.stale ? h("span", {class: "pill match-stale-pill", "data-tone": "bad"}, icon("bi-hourglass-split"), "stale") : null),
|
||||
h("dl", {class: "meta match-place"}, [["Repository", card.repo], ["Branch", card.branch], ["Worktree", card.worktree]].map(([label, value]) => h("div", {}, h("dt", {}, label), h("dd", {}, h("code", {title: value ? revealed(value) : null}, revealed(dash(value))))))),
|
||||
h("h2", {class: "match-title"}, revealed(card.title)),
|
||||
card.stale ? h("p", {class: "match-stale"}, icon("bi-exclamation-triangle"), revealed(card.stale_reason)) : null);
|
||||
|
||||
@@ -13,6 +13,9 @@
|
||||
.match-who .avatar.big { width: 72px; height: 72px; }
|
||||
.match-name { font-size: var(--fs-lg); }
|
||||
.match-age { color: var(--muted); font-size: var(--fs-sm); }
|
||||
.match-metrics { display: flex; flex-wrap: wrap; justify-content: center; gap: 6px; margin: 0; padding: 0; list-style: none; }
|
||||
.match-metric { display: inline-flex; align-items: center; gap: 4px; padding: 2px 10px; border: 1px solid var(--line); border-radius: 999px; background: var(--sunken); font-size: var(--fs-sm); white-space: nowrap; }
|
||||
.match-metric-label { color: var(--muted); }
|
||||
.match-place { display: grid; grid-template-columns: repeat(3, minmax(0, 1fr)); gap: var(--sp-2); width: 100%; margin: 0; text-align: left; }
|
||||
.match-place code { display: block; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
|
||||
.match-title { margin: 0; font-size: var(--fs-md); overflow-wrap: anywhere; }
|
||||
|
||||
Reference in new issue
Block a user