feat(orchestrator): every entry that waits on the operator is a Match card

Match now builds asks, choices, decision rows and rule requests from the inbox items, beside commits and commands, so its card count follows the Tasks badge. A decision card shows its options with the recommended one marked; a pick is released with the same single passkey, and the hub posts the answer of a decision row to the row's agent itself and keeps the row off the stack until its question changes. A choice cannot be rejected; a rule card's accept opens its row, its reject carries the feedback. Every card shows the scores its text carries as labels, value included; outside a commit's score line only an emoji-led score counts. Answered decision rows leave the badge and show as answered in the inbox. Requirement 012 records the operator's amendment of 2026-11-19 and decision 11.

🎯 Fix: 92 %
💥 Break: 4 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 88
🚦 Gate: ✅ 90/5, tokens and velocity <= 100, security 100 %

Created-with: https://s.veen.world/skills
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-19 10:14:39 +00:00
1 parent 67cbe0ddd3
commit c3dc1b8c58
13 files changed
+489 -55

No files matched your search

+18 -1
View File
@@ -4,7 +4,7 @@ import secrets
import time
from .asking import ask_state
from .choosing import answer_signed
from .choosing import answer_signed, answered, row_answer_signed
from .cleanup import cleanup_request
from .denying import (
DENIABLE,
@@ -179,6 +179,8 @@ class Approving:
if item["note"] is not None:
return self.deny(item, proof)
if item["kind"] == "operator":
if item["label"]:
return self.answer_row(item, proof)
if not all(self.payload_holds(bound) for bound in item.get("bound", [])):
return "refused: a payload file changed since the release"
return self.queue_job(item, proof)
@@ -225,6 +227,8 @@ class Approving:
if row is None:
raise Missing(str(raw["id"]))
visible({name: row[name] for name in ("task", "command", "directory")})
if row["check"] == "decision" and raw["verb"] == "approve":
return self.row_answer_entry(raw, row, tasks)
if raw["verb"] == "approve" and not runnable(row):
raise ToolError("an operator row is approved only when it holds a directory and a command")
if digest(row["command"]) != raw["sha256"]:
@@ -234,6 +238,19 @@ class Approving:
bound = self.payload_bound(row, raw["payload"]) if "payload" in raw else []
return {**inbox_item(raw, "", row["command"], "", operator_signed(row), self.requester(raw, adder(tasks[row["task"]]))), "bound": bound}
def row_answer_entry(self, raw: dict, row: dict, tasks: dict[str, dict]) -> dict:
"""Returns:
The signed item of a decision row answered with one of its option
labels: the post row_answer_signed() builds to the row's agent.
"""
if raw["label"] not in [option["label"] for option in row["options"]] or "payload" in raw:
raise ToolError("a decision row is approved with one of its option labels and no payload")
if digest(row["command"]) != raw["sha256"]:
raise Conflict({"id": row["task"], "status": "changed"})
if answered(self.answers.get(row["task"]), row):
raise Conflict({"id": row["task"], "status": "answered"})
return inbox_item(raw, raw["label"], row["command"], "", row_answer_signed(row, adder(tasks[row["task"]]), raw["label"]), "")
def item_of(self, raw: object, tasks: dict[str, dict]) -> dict:
if not isinstance(raw, dict):
raise ToolError("every item must be an object with kind, id, verb, label and sha256, and a denial also channel, reason and to")
+46
View File
@@ -4,6 +4,8 @@ from .council import agent
from .errors import ToolError
from .fields import decode, expect, field
from .messaging import DIRECT, EVERYONE, TO_ALL
from .records import digest
from .register import REGISTER, adder, operator_rows, read_register
from .signed import signing
CHOICE_REQUEST = "send me your open decisions as choices"
@@ -29,6 +31,25 @@ def answer_signed(decision: dict, label: str) -> dict:
return signing.message_item(agent(decision["agent"]), ANSWER_CLASS, answer_text(decision, label), "", "", "")
def row_answer_signed(row: dict, to: str, label: str) -> dict:
"""Args:
row: an open decision row of the register.
to: the row's adding agent.
label: one of the row's option labels.
Returns:
The post to that agent that a Match pick signs, in the words the
inbox's own answer sends.
"""
if not to or EVERYONE in to:
raise ToolError(f"a decision row is answered only when an agent other than {EVERYONE} holds role A on it")
return signing.message_item(agent(to), ANSWER_CLASS, f"Decision {row['task']}\nAnswer: {label}", "", "", "")
def answered(record: dict | None, row: dict) -> bool:
return record is not None and record["sha256"] == digest(row["command"])
def recipients(payload: dict) -> list[str]:
"""Args:
payload: the page's class and to: 1 to RECIPIENT_LIMIT distinct
@@ -98,3 +119,28 @@ class Choosing:
run = self.radioed(message, CHANNELS[ANSWER_CLASS])
where = f"{ANSWER_CLASS} to {message['address']}"
return f"decided · {where}" if run["code"] == 0 else f"decided · {where} failed ({run['code']})"
def answer_row(self, item: dict, proof: dict) -> str:
"""Args:
item: a checked operator item of a decision row whose label is
the picked option and whose signed is row_answer_signed().
proof: the relayed signature, verified here once, as the hub
sends the answer itself.
Returns:
The outcome words for the stream; the row stays open until its
agent closes it, while answers keeps it off the Match stack.
"""
tasks = read_register(self.council / REGISTER)
row = next((row for row in operator_rows(tasks) if row["task"] == item["id"]), None)
if row is None or item["label"] not in [option["label"] for option in row["options"]] or row_answer_signed(row, adder(tasks[item["id"]]), item["label"]) != item["signed"]:
return "refused: the row changed since the release"
self.operator_proven(proof, item["signed"])
with self.answers.changed:
if answered(self.answers.get(item["id"]), row):
return "already answered"
message = self.stored_message(item["signed"], proof, None)
self.answers.insert(item["id"], {"sha256": digest(row["command"]), "label": item["label"], "message": message["id"]})
run = self.radioed(message, CHANNELS[ANSWER_CLASS])
where = f"{ANSWER_CLASS} to {message['address']}"
return f"answered · {where}" if run["code"] == 0 else f"answered · {where} failed ({run['code']})"
+2 -1
View File
@@ -84,7 +84,8 @@ class Denying:
if run["code"] != 0:
return f"failed: {run['command']} → {run['code']}"
command, directory = row["command"][:200], row["directory"]
return f"stopped · {self.tell(item, proof, adder(tasks[item['id']]), f'operator command {command} in {directory}')}"
what = f"decision {item['id']}: {command}" if row["check"] == "decision" else f"operator command {command} in {directory}"
return f"stopped · {self.tell(item, proof, adder(tasks[item['id']]), what)}"
if item["kind"] == "review":
record, changed = self.reviews.decide(item["id"], {"status": "rejected", "proof": proof, **note})
if record is None:
+2
View File
@@ -96,6 +96,7 @@ class Hub(Mcp, Reviewing, Revealing, Asking, Messaging, Choosing, Approving, Den
reviews: Reviews
asks: Ledger
decisions: Ledger
answers: Ledger
messages: Ledger
rule_requests: Ledger
uploads: Path
@@ -235,6 +236,7 @@ def open_hub(council: Path, pages: Path, public_port: int, state: Path, host_sta
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"),
uploads=uploads,
+4 -2
View File
@@ -3,6 +3,7 @@ from __future__ import annotations
import time
from .approving import INBOX_KINDS
from .choosing import answered
from .council import read_claims
from .denying import requester_of
from .errors import ToolError
@@ -20,7 +21,7 @@ SNOOZE_LIMIT = 8 * 86400
class Inbox:
def inbox(self, now: float, tasks: dict[str, dict], directory: Directory) -> list[dict]:
claims = read_claims(self.council)
base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "check": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None, "settled": False}
base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "check": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None, "settled": False, "answered": ""}
items = []
for review in self.reviews.pending():
created = iso_epoch(review["created"]) or now
@@ -42,7 +43,8 @@ class Inbox:
rows = [row for row in operator_rows(tasks) if pattern is not None and pattern.fullmatch(row["task"])]
for row in rows:
busy = row["task"] in held
fields = {"title": row["command"], "detail": row["why"], "agent": adder(tasks[row["task"]]), "to": requester_of(claims, adder(tasks[row["task"]]))[0], "command": row["command"], "directory": row["directory"], "sha256": digest(row["command"]), "check": row["check"], "options": row["options"], "recommended": row["recommended"]}
answer = self.answers.get(row["task"])
fields = {"answered": answer["label"] if answered(answer, row) else "", "title": row["command"], "detail": row["why"], "agent": adder(tasks[row["task"]]), "to": requester_of(claims, adder(tasks[row["task"]]))[0], "command": row["command"], "directory": row["directory"], "sha256": digest(row["command"]), "check": row["check"], "options": row["options"], "recommended": row["recommended"]}
state = {"runnable": runnable(row) and not busy, "deniable": not busy, "job": console_of(consoles.get(row["task"]))}
items.append({**base, "kind": "operator", "id": row["task"], "ts": self.watch.first(row["task"], now), **fields, **state})
listed = {row["task"] for row in rows}
+55 -6
View File
@@ -1,21 +1,23 @@
from __future__ import annotations
import json
import time
from .council import read_claims
from .council import NEWS, read_claims
from .denying import requester_of
from .diffs import stored_diff
from .errors import Conflict, Missing, ToolError
from .fields import decode, expect, field
from .payloads import denied_roots, payload_files, payload_hash
from .previewing import merge_hash
from .records import digest, iso_epoch
from .records import digest, iso_epoch, read_jsonl
from .register import REGISTER, adder, operator_rows, read_register
from .scores import metric_chips, score_labels
from .signed import signing
from .tree import inside
OPERATOR = "operator/"
WAITING = ("ask", "decision", "rule")
def repository_of(common_dir: str) -> str:
@@ -57,7 +59,13 @@ class Matching:
scan = self.tree.get()
for row in rows:
agent = adder(tasks[row["task"]])
cards.append({**self.command_card(row, agent, born_of(agent, names, claims), roots, scan), "to": requester_of(claims, agent)[0]})
cards.append({**self.command_card(row, agent, born_of(agent, names, claims), roots, scan, labels), "to": requester_of(claims, agent)[0]})
items = self.inbox(now, tasks, self.directory(claims, read_jsonl(self.council / NEWS), now))
cards += [self.waiting_card(item, born_of(item["agent"], names, claims), scan, labels) for item in items if self.waits(item)]
asked = {row["task"] for row in operator_rows(tasks) if row["check"] == "decision"}
for answer in self.answers.listed():
if answer["id"] not in asked:
self.answers.remove(answer["id"])
listed = {card["id"] for card in cards}
for store in (self.match_snapshots, self.merge_previews):
for snapshot in store.listed():
@@ -76,7 +84,7 @@ 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", ""), "metrics": metric_chips(review.get("score", ""), labels), "gate": review.get("gate", ""),
**place, "title": review["title"], "score": review.get("score", ""), "metrics": metric_chips(review.get("score", ""), labels, True), "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": "",
}
@@ -93,7 +101,48 @@ class Matching:
files = payload_files(row["command"], row["directory"], roots)
return files, payload_hash(row["command"], row["directory"], files), None
def command_card(self, row: dict, agent: str, born: float | None, roots: list[str] | None, scan: dict) -> dict:
def waits(self, item: dict) -> bool:
"""Returns:
Whether an inbox item is a Match card of its own: an ask, a
choice, a rule request, or a decision row not yet answered with
its current question, none held by a release in its undo window;
commits and commands have their own cards.
"""
if item["held"]:
return False
if item["kind"] == "operator":
return item["check"] == "decision" and not item["settled"] and item["job"] is None and not item["answered"]
return item["kind"] in WAITING
def waiting_card(self, item: dict, born: float | None, scan: dict, labels: dict | None) -> dict:
"""Args:
item: an inbox item waits() keeps.
born: when its agent was first seen.
scan: the branch tree.
labels: the score labels.
Returns:
Its card: kind ask, decision (a choice or a decision row) or rule;
entry names the inbox kind a release signs, metrics the scores
its question, command or reason carries.
"""
files = []
if item["kind"] == "ask" and item["diff"]:
try:
files = stored_diff(self.reviews.pages, "ask", item["id"])["diff"]
except Missing:
files = None
repo, branch, worktree = place_of(item["directory"], scan) if item["directory"] else ("", "", "")
shown = digest(json.dumps([item["title"], item["command"], item["detail"], item["options"], item["rule"]], sort_keys=True))
return {
"id": f"{item['kind']}:{item['id']}", "kind": "decision" if item["kind"] == "operator" else item["kind"], "entry": item["kind"], "ref": item["id"], "agent": item["agent"], "to": item["to"],
"born": born, "created_ts": item["ts"], "repo": repo, "branch": branch, "worktree": worktree, "title": item["title"], "score": "",
"metrics": metric_chips("\n".join((item["title"], item["command"], item["detail"])), labels, False), "gate": "", "hash": shown, "live_hash": shown, "stale": False, "stale_reason": "",
"files": files, "command": item["command"], "directory": item["directory"], "reason": item["detail"], "sha256": item["sha256"], "options": item["options"],
"recommended": item["recommended"], "warnings": item["warnings"], "rule": item["rule"], "dry_run": item["dry_run"],
}
def command_card(self, row: dict, agent: str, born: float | None, roots: list[str] | None, scan: dict, labels: dict | None) -> dict:
card_id = f"operator:{row['task']}"
files, live, preview = self.card_payload(row, roots)
snapshot = self.match_snapshots.get(card_id)
@@ -106,7 +155,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": "", "metrics": [], "gate": "", "hash": snapshot["hash"], "live_hash": live, "stale": stale,
"title": row["command"], "score": "", "metrics": metric_chips(f"{row['command']}\n{row['why']}", labels, False), "gate": "", "hash": snapshot["hash"], "live_hash": live, "stale": stale,
"stale_reason": moved if stale else "", "files": snapshot["files"], "command": row["command"], "directory": row["directory"],
"reason": row["why"], "sha256": digest(row["command"]), "merge": merge,
}
+16 -9
View File
@@ -9,7 +9,8 @@ SCORES = "scores.jsonl"
LABELS = "kvb-check-score/labels.json"
FILE_LIMIT = 64 << 20
VARIATION = "️"
VALUE = r"([0-9]+(?:\.[0-9]+)?(?:\s*%)?|–|-|new)(?![0-9.])"
VALUE = r"([0-9]+(?:\.[0-9]+)?(?:\s*%|:[0-9]+(?:\.[0-9]+)?)?|–|-|new)(?![0-9.])"
CHIP_EXTRAS = ("value",)
def checked(labels: object) -> dict | None:
@@ -61,23 +62,29 @@ def score_labels(skills: Path) -> dict | None:
return checked(read_json(skills / LABELS))
def metric_chips(score: str, labels: dict | None) -> list[dict]:
def metric_chips(score: str, labels: dict | None, bare: bool) -> list[dict]:
"""Args:
score: an agent's free score line, such as line 1 or the message
block of score.py.
block of score.py, or a free text that may carry one.
labels: the label file as checked() returns it, or None.
bare: whether a label without its emoji counts; False for a free
text, where "fix 2 tests" is no score.
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.
In label order, then the CHIP_EXTRAS, per metric whose emoji (with or
without its variation selector) or label or former label stands
right before a value in score (the label alone only when bare), the
first such value: {"id", "emoji", "label", "value"}; none without
labels.
"""
found = []
for key, metric in (labels or {}).get("metrics", {}).items():
extras = (labels or {}).get("extras")
shown = [(key, extras[key]) for key in CHIP_EXTRAS if isinstance(extras, dict) and checked({"metrics": {key: extras.get(key)}})]
for key, metric in [*(labels or {}).get("metrics", {}).items(), *shown]:
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)
alone = rf"|\b(?:{names})\s*:?\s*" if bare else ""
match = re.search(rf"(?:{emoji}\s*(?:(?:{names})\s*:?\s*)?{alone}){VALUE}", score, re.IGNORECASE)
if match:
found.append({"id": key, "emoji": metric["emoji"], "label": metric["label"], "value": " ".join(match.group(1).split())})
return found