feat(hub): every choice is one numbered dialog with an Other answer
Decisions, decision rows and hook questions render through one page-dialog.js: numbered options, check boxes for multi picks, the recommended option tagged, and a one-line Other answer; page-inbox.js and page-match.js drop their own option code. choosing.picks accepts one line of other text for every decision and decision row, not only hook questions, and approving checks a decision row's label through it and visible(). operator.py add --check decision now needs 2 to 4 --option values, as an AskUserQuestion offers (OPTION_FLOOR 2, OPTION_LIMIT 4 instead of 12), and refuses --option or --recommended on any other check; kvb-agent-optimize's graph.py passes two answers for each row it adds, and checks.md names the instruction-step answers Done= and Blocked=.
Stacked on questions (a6eee78); applied cleanly. ruff and node --check pass.
Tests: test_hub_decision_rows, test_hub_questions, test_operator, test_code_graph, test_hub_match and the Match waiting and question e2e updated. Written, not run: the full suite runs once on master after all bundles (operator order).
Security: MEDUSA over the staged tree on master: 100, no findings over 21 files; index.html.j2 is not covered and was read by hand (dialog style rules and the page-dialog.js include).
🎯 Fix: 90 %
💥 Break: 5 %
💸 Tokens: –
⏱️ Velocity: –
🛡️ Security: 100 %
🏆 Score: 86
🚦 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:
1 parent
a6eee78165
commit
88e53ac51f
22 files changed
+212
-181
No files matched your search
@@ -248,10 +248,12 @@ class Approving:
|
||||
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.
|
||||
labels or one line of other text: 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 not picks(row, raw["label"]) or "payload" in raw:
|
||||
raise ToolError("a decision row is approved with one of its option labels or one line of other text, and no payload")
|
||||
visible({"label": raw["label"]})
|
||||
if digest(row["command"]) != raw["sha256"]:
|
||||
raise Conflict({"id": row["task"], "status": "changed"})
|
||||
if answered(self.answers.get(row["task"]), row):
|
||||
@@ -281,7 +283,7 @@ class Approving:
|
||||
label = ""
|
||||
if kind_name == "decision":
|
||||
if verb != "approve" or not picks(record, raw["label"]):
|
||||
raise ToolError("a decision is approved with one of its option labels, a multi decision with one or more of them in option order, a hook question also with one line of other text")
|
||||
raise ToolError("a decision is approved with one of its option labels, a multi decision with one or more of them in option order, or with one line of other text")
|
||||
visible([{"label": part} for part in raw["label"].split(PICKED)])
|
||||
label = raw["label"]
|
||||
if kind_name == "rule":
|
||||
|
||||
@@ -21,17 +21,17 @@ OTHER_LIMIT = 1000
|
||||
|
||||
def picks(decision: dict, label: str) -> bool:
|
||||
"""Args:
|
||||
label: the answer to a decision: one option label, or for a multi
|
||||
decision one or more labels in option order, joined by PICKED,
|
||||
which no label holds; for a decision the permission hook asked
|
||||
also one line of free text up to OTHER_LIMIT characters, trimmed
|
||||
and no option label.
|
||||
decision: a decision or a decision row, with its options.
|
||||
label: the answer to it: one option label, or for a multi decision
|
||||
one or more labels in option order, joined by PICKED, which no
|
||||
label holds; or one line of free text up to OTHER_LIMIT
|
||||
characters, trimmed and no option label.
|
||||
|
||||
Returns:
|
||||
Whether label is a valid answer to the decision.
|
||||
"""
|
||||
labels = [option["label"] for option in decision["options"]]
|
||||
if decision.get("hooked") and PICKED not in label and label not in labels:
|
||||
if PICKED not in label and label not in labels:
|
||||
return 0 < len(label) <= OTHER_LIMIT and label == label.strip()
|
||||
if not decision.get("multi"):
|
||||
return label in labels
|
||||
@@ -66,7 +66,7 @@ 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.
|
||||
label: the answer picks() accepts for the row.
|
||||
|
||||
Returns:
|
||||
The post to that agent that a Match pick signs, in the words the
|
||||
|
||||
@@ -21,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": "", "multi": False, "other": False, "check": "", "command": "", "directory": "", "sha256": "", "runnable": False, "deniable": False, "job": None, "rule": None, "dry_run": None, "diff": None, "settled": False, "answered": ""}
|
||||
base = {"agent": "", "to": "", "detail": "", "green": False, "gate": "", "score": "", "warnings": [], "options": [], "recommended": "", "multi": False, "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
|
||||
@@ -35,7 +35,7 @@ class Inbox:
|
||||
items.append({**base, "kind": "ask", "id": ask["id"], "ts": ask["created_ts"], **fields, "command": ask["command"], "directory": ask["cwd"]})
|
||||
for decision in (decision for decision in self.decisions.pending() if decision_status(decision, now) == "pending"):
|
||||
recommended = decision.get("recommended", "")
|
||||
fields = {"title": decision["question"][:300], "agent": decision["agent"], "green": recommended != "", "options": decision["options"], "recommended": recommended, "multi": bool(decision.get("multi")), "other": bool(decision.get("hooked"))}
|
||||
fields = {"title": decision["question"][:300], "agent": decision["agent"], "green": recommended != "", "options": decision["options"], "recommended": recommended, "multi": bool(decision.get("multi"))}
|
||||
items.append({**base, "kind": "decision", "id": decision["id"], "ts": decision["created_ts"], **fields})
|
||||
held = self.open_jobs()
|
||||
consoles = self.consoles()
|
||||
|
||||
@@ -147,7 +147,7 @@ class Matching:
|
||||
"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"], "multi": item["multi"], "other": item["other"], "warnings": item["warnings"], "rule": item["rule"], "dry_run": item["dry_run"],
|
||||
"recommended": item["recommended"], "multi": item["multi"], "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:
|
||||
|
||||
@@ -69,7 +69,7 @@ class Mcp:
|
||||
tool(
|
||||
"decision_request",
|
||||
"Ask the operator to pick one of several options in the Agent Orchestrator; the question shows as a choice card "
|
||||
"under Waits on Operator in the Tasks tab and each option becomes a button. When an operator message asks "
|
||||
"under Waits on Operator in the Tasks tab, each option becomes a numbered row beside a free-text Other answer. When an operator message asks "
|
||||
f'"{CHOICE_REQUEST}", send each open decision of kvb-think-choice through this tool. Returns the decision id and the hub URL.',
|
||||
{
|
||||
"question": text_property("The question, plain text."),
|
||||
@@ -81,7 +81,7 @@ class Mcp:
|
||||
tool(
|
||||
"decision_wait",
|
||||
"Wait until the operator picks an option or the timeout passes, then return the status "
|
||||
"(pending, decided), the chosen label and, for a click, message and answer: the id and text of the operator's "
|
||||
"(pending, decided), the chosen label or the operator's own one-line Other answer and, for a click, message and answer: the id and text of the operator's "
|
||||
"passkey-signed answer, a post to the asking agent; check it with operator_message(message, answer, your name) "
|
||||
f"before acting on the choice. Waits at most {WAIT_CAP} seconds.",
|
||||
{"id": text_property("Decision id that decision_request returned."), "timeout_seconds": wait},
|
||||
|
||||
Reference in new issue
Block a user