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
+1 -1
View File
@@ -54,7 +54,7 @@
const alarmRows = () => state.radio.filter((row) => (row.class === "mayday" || row.class === "pan-pan") && row.ts >= state.alarm_since).reverse();
const keyOf = (item) => `${item.kind}:${item.id}`;
const visibleInbox = () => state.inbox.filter((item) => ui.snoozed || !item.until);
const waitingCount = () => state.inbox.filter((item) => !item.until).length;
const waitingCount = () => state.inbox.filter((item) => !item.until && !item.answered).length;
const isGreen = (item) => item.green && !item.held && !item.until && item.kind !== "operator";
const selectable = (item) => !item.held && item.kind !== "rule" && !(item.kind === "review" && item.gate !== "pass") && !(item.kind === "operator" && !item.runnable) && !(item.kind === "decision" && !item.recommended);
const entryOf = (item, verb, label) => ({kind: item.kind, id: item.id, verb, label, sha256: item.sha256 || ""});
+3 -2
View File
@@ -107,6 +107,7 @@
const chooseOne = (item, label) => submit([entryOf(item, "approve", label)], `Choice: ${label}`);
const asked = (item) => item.kind === "operator" && item.check === "decision";
const answers = new Map();
const answerOf = (item) => answers.get(keyOf(item)) || item.answered || "";
async function answerRow(item, answer) {
if (!item.agent) {
@@ -133,7 +134,7 @@
}
function choicePanel(item, pick, other) {
const done = answers.has(keyOf(item));
const done = Boolean(answerOf(item));
const pane = item.options.some((option) => option.preview) ? h("pre", {class: "choice-preview", "aria-label": "Preview"}) : null;
const show = (option) => {
if (pane) {
@@ -280,7 +281,7 @@
h("div", {class: "msg-meta"},
when(item.ts),
asked(item) ? pill("Decision", KIND_TONES.decision) : pill(ITEM_LABELS[item.kind], KIND_TONES[item.kind]),
answers.has(keyOf(item)) ? pill(revealed(`answered: ${answers.get(keyOf(item))}`), "ok") : null,
answerOf(item) ? pill(revealed(`answered: ${answerOf(item)}`), "ok") : null,
item.kind === "review" ? pill(item.gate === "pass" ? "Gate green" : "Gate red", item.gate === "pass" ? "ok" : "bad") : null,
item.warnings.map((warning) => pill(warning, "bad")),
item.pinned ? pill("pinned", "violet") : null,
+68 -23
View File
@@ -2,7 +2,7 @@
const MATCH_PEEKS = 2;
const LONG_PRESS = 550;
const PRESS_SLOP = 10;
const MATCH_KINDS = {commit: ["Commit", "info", "bi-git"], command: ["Command", "warn", "bi-terminal"]};
const MATCH_KINDS = {commit: ["Commit", "info", "bi-git"], command: ["Command", "warn", "bi-terminal"], ask: ["Ask", "warn", "bi-shield-lock"], decision: ["Decision", "info", "bi-signpost-split"], rule: ["Rule", "neutral", "bi-shield-check"]};
const MATCH_VERDICTS = {accept: ["Accept", "ok", "bi-check-lg"], reject: ["Reject", "bad", "bi-x-lg"]};
const SWIPE_SHARE = 0.25;
const SWIPE_UP = 80;
@@ -70,7 +70,9 @@
return h("tr", {class: "match-mark", "data-line": mark.line}, h("td", {colspan: columns}, icon("bi-chat-square-text"), h("span", {class: "match-mark-text"}, revealed(mark.comment))));
}
const patched = (card) => card.kind === "commit" || Boolean(card.merge);
const patched = (card) => card.kind === "commit" || card.kind === "ask" || Boolean(card.merge);
const pickOnly = (card) => card.kind === "decision" && card.entry === "decision";
const flies = (card) => !card.stale && card.kind !== "rule" && (card.kind !== "decision" || Boolean(card.recommended));
function matchFileRows(card, file) {
const diffed = patched(card);
@@ -202,7 +204,25 @@
card.stale ? h("p", {class: "match-stale"}, icon("bi-exclamation-triangle"), revealed(card.stale_reason)) : null);
}
function matchCommand(card) {
function matchOptions(card) {
const kept = matchView.decisions.get(cardKey(card));
return h("div", {class: "options match-options", role: "group", "aria-label": "Options"}, card.options.map((option) => h("button", {
type: "button", class: `option${option.label === card.recommended ? " recommended" : ""}`, "aria-pressed": String(Boolean(kept && kept.label === option.label)),
title: revealed(`${option.label}: picked now, sent to ${card.agent || "its agent"} as a post at the release`), on: {click: () => decide(card, "accept", "", option.label)},
}, h("strong", {}, revealed(option.label)), option.description ? h("span", {}, revealed(option.description)) : null)));
}
function matchPayload(card) {
if (card.kind === "decision") {
return h("section", {class: "match-payload"}, card.reason && card.reason !== "-" ? h("p", {class: "match-reason"}, revealed(card.reason)) : null, matchOptions(card));
}
if (card.kind === "rule") {
return h("section", {class: "match-payload"}, ruleRequestBody({...card, detail: card.reason}));
}
if (card.kind === "ask") {
return h("section", {class: "match-payload"}, h("pre", {class: "match-command"}, h("code", {}, revealed(card.command))), h("p", {class: "match-directory"}, revealed(card.directory)),
card.warnings.length ? h("p", {class: "match-warnings"}, card.warnings.map((warning) => pill(warning, "bad"))) : null);
}
if (card.kind !== "command") {
return null;
}
@@ -218,9 +238,9 @@
function matchCard(card) {
const files = card.files || [];
const none = card.kind === "commit" ? "No diff shipped with this stage." : card.merge ? (card.merge.error ? "No diff to show." : "The merge brings no change.") : "Its command names no file.";
const list = files.length ? h("ol", {class: "match-files", "aria-label": `Files: ${files.length}`}, files.map((file, index) => fileBlock(card, file, index))) : h("p", {class: "muted"}, none);
const body = h("div", {class: "match-body"}, matchCommand(card), list);
const none = card.kind === "commit" ? "No diff shipped with this stage." : card.kind === "ask" ? "Its tool call changes no file." : card.merge ? (card.merge.error ? "No diff to show." : "The merge brings no change.") : "Its command names no file.";
const list = files.length ? h("ol", {class: "match-files", "aria-label": `Files: ${files.length}`}, files.map((file, index) => fileBlock(card, file, index))) : card.kind === "decision" || card.kind === "rule" ? null : h("p", {class: "muted"}, none);
const body = h("div", {class: "match-body"}, matchPayload(card), list);
body.addEventListener("scroll", () => openOnScroll(body, ".match-file"), {passive: true});
const article = h("article", {class: "card match-card front", "data-card": card.id, "data-kind": card.kind, "data-stale": String(Boolean(card.stale)), "aria-label": `${card.kind} card of ${card.agent || "an agent"}`},
matchHead(card), body);
@@ -275,9 +295,15 @@
window.setTimeout(land, FLY_MS);
}
function decide(card, verdict, feedback) {
/**
* @param {object} card the card decided.
* @param {string} verdict accept or reject.
* @param {string} feedback the rejection text, else empty.
* @param {string} label the picked option of a decision card, else empty.
*/
function decide(card, verdict, feedback, label) {
flyOff(verdict, () => {
matchView.decisions.set(cardKey(card), {verdict, feedback});
matchView.decisions.set(cardKey(card), {verdict, feedback, label});
drawMatch(true);
});
}
@@ -298,17 +324,34 @@
toast("Accept: refused", [`The card is stale: ${card.stale_reason}. Add it again to decide it.`], false);
return;
}
decide(card, "accept", "");
if (card.kind === "rule") {
const item = state.inbox.find((entry) => keyOf(entry) === card.id);
if (item) {
openItem(item);
} else {
toast("Accept: the rule request is gone", [], false);
}
return;
}
if (card.kind === "decision" && !card.recommended) {
toast("Accept: pick one of its options", ["The decision recommends none, so the card waits for your pick."], false);
return;
}
decide(card, "accept", "", card.kind === "decision" ? card.recommended : "");
}
function rejectCard(card) {
if (pickOnly(card)) {
toast("Reject: not possible", ["A choice is answered with one of its options."], false);
return;
}
const kept = matchView.decisions.get(cardKey(card));
const words = h("textarea", {class: "field match-feedback", rows: 6, maxlength: FEEDBACK_LIMIT, "aria-label": "Feedback"});
words.value = (kept && kept.verdict === "reject" ? kept.feedback : feedbackOf(card)).slice(0, FEEDBACK_LIMIT);
const confirm = h("button", {type: "button", class: "btn danger match-feedback-reject"}, icon("bi-x-lg"), "Reject");
confirm.addEventListener("click", () => {
closeSheet();
decide(card, "reject", words.value.trim());
decide(card, "reject", words.value.trim(), "");
});
const note = `${card.agent || "The agent"} gets this text by radio call at the release; nothing is sent before.`;
openSheet(`Reject: ${card.title}`, [h("p", {class: "muted"}, note), words, h("div", {class: "actions"}, h("span", {class: "spacer"}), btn("Cancel", "btn ghost", closeSheet), confirm)], false);
@@ -361,7 +404,7 @@
const far = SWIPE_SHARE * article.getBoundingClientRect().width;
const swiped = event.type === "pointercancel" ? "" : Math.abs(dx) >= far && Math.abs(dx) > Math.abs(dy) ? (dx > 0 ? "accept" : "reject") : -dy >= SWIPE_UP && -dy > Math.abs(dx) ? "later" : "";
article.style.removeProperty("--lean");
if (!((swiped === "accept" && !card.stale) || swiped === "later")) {
if (!((swiped === "accept" && flies(card)) || swiped === "later")) {
article.style.removeProperty("transform");
delete article.dataset.leaning;
}
@@ -389,17 +432,18 @@
/**
* @param {object} card a decided match card.
* @param {object} decision its {verdict, feedback}.
* @returns {object} the inbox entry the release signs: an approval of the review, or of the operator row bound to
* the payload hash the card showed, or its rejection carrying the feedback as a radio call to the card's agent.
* @param {object} decision its {verdict, feedback, label}.
* @returns {object} the inbox entry the release signs: an approval of the review or the ask, the picked option of a
* decision, the operator row bound to the payload hash the card showed, or a rejection carrying the feedback as a
* radio call to the card's agent.
*/
function matchEntry(card, decision) {
const kind = card.kind === "commit" ? "review" : "operator";
const entry = {kind, id: card.ref, verb: decision.verdict === "accept" ? "approve" : "reject", label: "", sha256: kind === "operator" ? card.sha256 || "" : ""};
const kind = card.entry || (card.kind === "commit" ? "review" : "operator");
const entry = {kind, id: card.ref, verb: decision.verdict === "accept" ? "approve" : "reject", label: decision.verdict === "accept" ? decision.label || "" : "", sha256: kind === "operator" ? card.sha256 || "" : ""};
if (decision.verdict === "reject") {
return {...entry, channel: "call", reason: decision.feedback, to: card.to || ""};
}
return kind === "operator" ? {...entry, payload: card.hash} : entry;
return card.kind === "command" ? {...entry, payload: card.hash} : entry;
}
function decided(cards) {
@@ -420,7 +464,7 @@
const [kindName, kindTone, kindIcon] = MATCH_KINDS[card.kind] || [card.kind, "neutral", "bi-collection"];
const [word, tone, mark] = MATCH_VERDICTS[decision.verdict];
const other = decision.verdict === "accept" ? "reject" : "accept";
const flip = iconBtn(MATCH_VERDICTS[other][2], MATCH_VERDICTS[other][0], "btn small ghost match-flip", () => (other === "accept" ? acceptCard(card) : rejectCard(card)), `${MATCH_VERDICTS[other][0]} instead`);
const flip = (other === "reject" && pickOnly(card)) || (other === "accept" && !flies(card)) ? null : iconBtn(MATCH_VERDICTS[other][2], MATCH_VERDICTS[other][0], "btn small ghost match-flip", () => (other === "accept" ? acceptCard(card) : rejectCard(card)), `${MATCH_VERDICTS[other][0]} instead`);
const back = iconBtn("bi-arrow-counterclockwise", "Back to the stack", "btn small ghost match-undecide", () => {
matchView.decisions.delete(cardKey(card));
matchView.overview = false;
@@ -428,7 +472,7 @@
});
return h("li", {class: "match-decision", "data-card": card.id, "data-verdict": decision.verdict},
h("div", {class: "row"}, face(card.agent || "-", false), h("span", {class: "pill", "data-tone": kindTone}, icon(kindIcon), kindName), h("strong", {class: "match-decision-title"}, revealed(card.title)), h("span", {class: "spacer"}),
h("span", {class: "pill match-verdict", "data-tone": tone}, icon(mark), word), decision.verdict === "reject" ? iconBtn("bi-pencil", "Edit feedback", "btn small ghost match-edit", () => rejectCard(card)) : null, flip, back),
h("span", {class: "pill match-verdict", "data-tone": tone}, icon(mark), decision.label ? revealed(`${word}: ${decision.label}`) : word), decision.verdict === "reject" ? iconBtn("bi-pencil", "Edit feedback", "btn small ghost match-edit", () => rejectCard(card)) : null, flip, back),
decision.verdict === "reject" ? h("pre", {class: "match-decision-feedback"}, revealedLines(decision.feedback === "" ? "no feedback text" : decision.feedback)) : null);
}
@@ -458,7 +502,7 @@
}) : null;
return h("section", {class: "card match-overview", "aria-label": "Decisions"},
h("h2", {class: "panel-title"}, "Decisions"),
h("p", {class: "muted"}, "Nothing has run yet. Accepted commits get the operator's signature for their exact tree, accepted commands run once as jobs under Waits on Operator, every rejection goes to its agent by radio call."),
h("p", {class: "muted"}, "Nothing has run yet. Accepted commits get the operator's signature for their exact tree, accepted commands run once as jobs under Waits on Operator, accepted asks are granted, every picked option goes to its agent as a post, every rejection goes to its agent by radio call."),
picked.length ? h("ol", {class: "match-decisions"}, picked.map(([card, decision]) => overviewRow(card, decision))) : h("p", {class: "muted"}, "No decision yet."),
block && picked.length ? h("p", {class: "match-release-block"}, icon("bi-exclamation-triangle"), block) : null,
h("div", {class: "actions"}, back, h("span", {class: "spacer"}), release));
@@ -534,7 +578,7 @@
dom.decisions.hidden = !matchView.decisions.size || shownOverview;
if (!cards.length) {
matchView.front = null;
dom.stack.replaceChildren(emptyState("No card waits", "No staged commit and no operator command waits for a decision."));
dom.stack.replaceChildren(emptyState("No card waits", "Nothing waits on the operator."));
return;
}
if (shownOverview) {
@@ -550,8 +594,9 @@
matchView.front = front;
const act = (cls, iconName, word, hint, disabled, run) => h("button", {type: "button", class: `match-act ${cls}`, disabled, ...named(word, hint), on: {click: run}},
h("span", {class: "match-act-face", "aria-hidden": "true"}, icon(iconName)), h("span", {class: "match-act-label"}, word));
const accept = act("match-accept", "bi-check-lg", "Accept", front.stale ? `Accept: refused while the card is stale (${front.stale_reason})` : "Accept (right arrow, swipe right)", Boolean(front.stale), () => acceptCard(front));
const reject = act("match-reject", "bi-x-lg", "Reject", "Reject with feedback (left arrow, swipe left)", false, () => rejectCard(front));
const hint = front.stale ? `Accept: refused while the card is stale (${front.stale_reason})` : front.kind === "rule" ? "Accept: opens its row, where the passkey signs exactly this rule" : front.kind === "decision" ? (front.recommended ? `Accept: ${front.recommended} (right arrow, swipe right)` : "Accept: pick one of its options") : "Accept (right arrow, swipe right)";
const accept = act("match-accept", "bi-check-lg", "Accept", revealed(hint), Boolean(front.stale) || (front.kind === "decision" && !front.recommended), () => acceptCard(front));
const reject = act("match-reject", "bi-x-lg", "Reject", pickOnly(front) ? "Reject: a choice is answered with one of its options" : "Reject with feedback (left arrow, swipe left)", pickOnly(front), () => rejectCard(front));
const later = act("match-later", "bi-arrow-up", "Later", "Later: to the back of the stack (up arrow, swipe up)", !rest.length, () => laterCard(front));
const peeks = rest.length ? h("div", {class: "match-peeks", role: "group", "aria-label": `${rest.length} more cards`}, rest.map(peekTab)) : null;
const behind = rest.slice(0, MATCH_PEEKS).map((card, index) => {