fix(hub): decision answers wake their agent as a radio call
🧪 Test / 🧪 Lock + lint (push) Canceled after 0s
🧪 Test / 🧪 Lock + lint (push) Canceled after 0s
Answers to decision rows and to MCP choice cards went to the agent as a post, which it reads only when its turn ends, so the operator got no direct feedback. They now go as a passkey-signed call that wakes the agent at once; the card, the Match note, the decision_wait description and the operator checks say so. Four passkey hint texts are reworded so MEDUSA's excessive-agency rules no longer read them as agents handing out keys. 🎯 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:
1 parent
a667ac485a
commit
ad03188335
11 files changed
+26
-25
No files matched your search
@@ -150,7 +150,7 @@ flowchart TD
|
||||
- [ ] Every ask, choice, decision row and rule request under Waits on
|
||||
Operator is a card of its kind; a decision row answered through Match
|
||||
leaves the stack until its question changes, and its agent receives the
|
||||
pick as a post.
|
||||
pick as a call.
|
||||
- [ ] A decision card's option buttons record the pick; a choice's reject is
|
||||
refused; a rule card's accept opens its row and its reject carries the
|
||||
feedback.
|
||||
|
||||
@@ -30,7 +30,7 @@ TASK = re.compile(r"[a-z0-9][a-z0-9._-]{0,99}(?:/[a-z0-9][a-z0-9._-]{0,99}){0,7}
|
||||
PRIO = re.compile(r"[1-9][0-9]{0,2}")
|
||||
FIBONACCI = ("1", "2", "3", "5", "8", "13", "21", "34", "55", "89")
|
||||
ESTIMATOR = "Operator"
|
||||
CHOICE_CLASS = "post"
|
||||
CHOICE_CLASS = "call"
|
||||
QUESTION_SHOWN = 200
|
||||
PICKED = "\n"
|
||||
COMMANDS = "operator/"
|
||||
|
||||
@@ -82,7 +82,7 @@ class Mcp:
|
||||
"decision_wait",
|
||||
"Wait until the operator picks an option or the timeout passes, then return the status "
|
||||
"(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) "
|
||||
"passkey-signed answer, a radio call 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},
|
||||
),
|
||||
|
||||
@@ -132,7 +132,7 @@
|
||||
}
|
||||
}
|
||||
|
||||
const signsFor = (item) => `your passkey signs this answer, a post to ${item.agent}`;
|
||||
const signsFor = (item) => `${item.agent} gets this answer as a call once your passkey signs it`;
|
||||
|
||||
/**
|
||||
* @param {Object} item a permission ask.
|
||||
@@ -151,7 +151,7 @@
|
||||
return choiceDialog(item, {pick: (label) => { after(); chooseOne(item, label); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? grantLabel(item) : "", locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT});
|
||||
}
|
||||
if (item.kind === "ask") {
|
||||
return choiceDialog(askDialog(item.id), {pick: (answer, typed) => { after(); answerAsk(item, answer, typed); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? ALLOW : "", locked: item.held, hint: `your passkey signs it, the answer goes to ${item.to || "its session"}`, group: "", other: TELL});
|
||||
return choiceDialog(askDialog(item.id), {pick: (answer, typed) => { after(); answerAsk(item, answer, typed); }, toggled: new Set(), chosen: ui.selected.has(keyOf(item)) ? ALLOW : "", locked: item.held, hint: `the answer goes to ${item.to || "its session"} once your passkey signs it`, group: "", other: TELL});
|
||||
}
|
||||
const shown = ui.selected.has(keyOf(item)) ? grantLabel(item) : "";
|
||||
return asked(item) ? [answerTo(item), choiceDialog(item, {pick: (label) => { after(); answerPick(item, label); }, toggled: new Set(), chosen: shown, locked: item.held, hint: signsFor(item), group: "", other: OTHER_PROMPT})] : null;
|
||||
@@ -161,7 +161,8 @@
|
||||
* @param {Object} item a decision row of the register.
|
||||
* @returns {HTMLElement} who receives the answer: the row's first agent with role A, which any agent can set, so the operator sees it before signing.
|
||||
*/
|
||||
const answerTo = (item) => h("p", {class: "muted answer-to"}, item.agent ? ["Your answer goes to ", h("strong", {}, revealed(item.agent)), " as a passkey-signed post, with the row id and your answer only."] : "No agent holds role A on this row: answer in its session.");
|
||||
const UNASSIGNED = "No agent holds role A on this row: answer in its session.";
|
||||
const answerTo = (item) => h("p", {class: "muted answer-to"}, item.agent ? ["Your answer goes to ", h("strong", {}, revealed(item.agent)), " as a passkey-signed call that wakes it at once, with the row id and your answer only."] : UNASSIGNED);
|
||||
|
||||
const deniable = (item) => item.deniable || item.kind === "review";
|
||||
const denialOf = (item, reason) => ({...entryOf(item, "reject", ""), channel: "post", reason, to: item.to});
|
||||
@@ -179,7 +180,7 @@
|
||||
return [...state.inbox.filter((entry) => entry.kind === "review" && linked.has(entry.id) && !entry.held && !keys.has(keyOf(entry))), ...items];
|
||||
}
|
||||
|
||||
const DENY_NOTE = "Every entry and every full command that gets denied; each requester gets its denial and the reason by post. After the click the passkey signs the whole selection once; then 3 s remain to undo.";
|
||||
const DENY_NOTE = "Every entry and every full command that gets denied; each requester gets its denial and the reason by post. After the click 3 s remain for undo, and one passkey signature covers the whole selection.";
|
||||
|
||||
function grantNote(alone, batched) {
|
||||
const solos = alone ? ` Each rule and each red-gate review first asks its own signature, one after the other (${alone}).` : "";
|
||||
@@ -230,7 +231,7 @@
|
||||
return {
|
||||
chosen,
|
||||
grant: h("button", {type: "button", class: "btn small primary", ...named(`Grant selection (${grantable.length})`), disabled: !grantable.length || ui.busy, on: {click: () => bulk(withReviews(chosen), "Grant selection", false)}}, icon("bi-check2-square"), `Grant ${grantable.length}`),
|
||||
deny: h("button", {type: "button", class: "menu-item danger", ...named(`Deny selection (${denials.length})`, `Deny selection (${denials.length}): each requester gets its denial and an optional reason by post, one passkey signature, 3 s to undo`), disabled: !denials.length || ui.busy, on: {click: () => bulk(chosen, "Deny selection", true)}}, icon("bi-x-square"), `Deny ${denials.length}`),
|
||||
deny: h("button", {type: "button", class: "menu-item danger", ...named(`Deny selection (${denials.length})`, `Deny selection (${denials.length}): each requester gets its denial and an optional reason by post, 3 s to undo, one passkey signature`), disabled: !denials.length || ui.busy, on: {click: () => bulk(chosen, "Deny selection", true)}}, icon("bi-x-square"), `Deny ${denials.length}`),
|
||||
green: h("button", {type: "button", class: "menu-item", ...named(`Grant all green (${green.length})`), disabled: !green.length || ui.busy, on: {click: () => bulk(green, "Grant all green", false)}}, icon("bi-check2-all"), `Grant all green ${green.length}`),
|
||||
};
|
||||
}
|
||||
@@ -322,7 +323,7 @@
|
||||
function waitOf(item) {
|
||||
const to = item.agent ? ` to ${item.agent}` : "";
|
||||
if (sending.has(keyOf(item))) {
|
||||
return `Clicked: waits for your passkey, then the hub stores the answer and sends it${to}`;
|
||||
return `Clicked: the hub stores the answer and sends it${to} once your passkey signs it`;
|
||||
}
|
||||
if (item.held) {
|
||||
return `Signed: waits out the undo window of a few seconds, then the hub delivers it${to} and the card closes`;
|
||||
|
||||
@@ -608,7 +608,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, accepted asks are granted, every picked option goes to its agent as a post, 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 and 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));
|
||||
|
||||
@@ -25,5 +25,5 @@ A `decision` row carries two to four answers, as an `AskUserQuestion`
|
||||
offers, each as `--option "<label>=<what it means>"`, and your pick as
|
||||
`--recommended`; an instruction step offers `Done=` and `Blocked=`. The hub
|
||||
shows them as a numbered dialog with a one-line Other answer, and the answer
|
||||
reaches the row's A as a passkey-signed post `Decision <task>` /
|
||||
reaches the row's A as a passkey-signed call `Decision <task>` /
|
||||
`Answer: <answer>` to check with `operator_message` before acting.
|
||||
@@ -212,7 +212,7 @@ class TestHubInbox(base.OrchestratorE2ECase):
|
||||
|
||||
def answered(self, result: dict, signs: bool) -> None:
|
||||
self.assertNotIn("error", result)
|
||||
self.assertEqual((result["title"], result["asked"], result["closed"], result["tall"], result["wide"]), ("Wait: your passkey signs this answer, a post to Stage", 1, [False, 0], False, False))
|
||||
self.assertEqual((result["title"], result["asked"], result["closed"], result["tall"], result["wide"]), ("Wait: Stage gets this answer as a call once your passkey signs it", 1, [False, 0], False, False))
|
||||
signed = [["/api/sign", ["items"], None, None]]
|
||||
self.assertEqual(result["posted"], [*signed, ["/api/inbox/approve", ["items", "proof"], None, None]] if signs else signed)
|
||||
self.assertTrue((result["toast"] or "").startswith("Choice: Wait" + ("" if signs else ": not signed")), result)
|
||||
@@ -268,8 +268,8 @@ class TestHubInbox(base.OrchestratorE2ECase):
|
||||
state = self.tool("decision_wait", {"id": decision, "timeout_seconds": 0})["structuredContent"]
|
||||
self.assertEqual((state["status"], state["choice"], state["answer"]), ("decided", "Wait", f"Choice for decision {decision} ({questions[width]}): Wait"))
|
||||
found = self.tool("operator_message", {"id": state["message"], "text": state["answer"], "to": "Stage"})["structuredContent"]
|
||||
self.assertEqual((found["match"], found["class"], found["to"]), (True, "post", "Stage"))
|
||||
self.assertIn(["post", "--to", "Stage", "--session", "Operator", f"[kvb-orchestrator msg {state['message']}] {state['answer']}"], radio)
|
||||
self.assertEqual((found["match"], found["class"], found["to"]), (True, "call", "Stage"))
|
||||
self.assertIn(["send", "call", "--to", "Stage", "--session", "Operator", f"[kvb-orchestrator msg {state['message']}] {state['answer']}"], radio)
|
||||
|
||||
def test_chromium_requests_choices_on_every_channel_and_signs_a_choice_at_three_widths(self):
|
||||
self.check_choices("chromium", "cdp.mjs", os.environ.get("CHROMIUM", "chromium"), signs=True)
|
||||
|
||||
@@ -113,7 +113,7 @@ class TestHubChoices(HubCase):
|
||||
result = self.tool("decision_request", {"question": question, "options": OPTIONS, "agent": "Stage", "recommended": ""})
|
||||
self.assertFalse(result["isError"], result)
|
||||
decision_id = result["structuredContent"]["id"]
|
||||
answer = signing.message_item("Stage", "post", f"Choice for decision {decision_id} ({' '.join(question.split())}): Wait", "", "", "")
|
||||
answer = signing.message_item("Stage", "call", f"Choice for decision {decision_id} ({' '.join(question.split())}): Wait", "", "", "")
|
||||
return decision_id, answer
|
||||
|
||||
def test_a_click_on_a_choice_option_sends_a_signed_answer_operator_message_verifies(self):
|
||||
@@ -131,13 +131,13 @@ class TestHubChoices(HubCase):
|
||||
state = self.tool("decision_wait", {"id": decision_id, "timeout_seconds": 0})["structuredContent"]
|
||||
self.assertEqual((state["status"], state["answer"]), ("decided", answer["text"]))
|
||||
found = self.check(state["message"], state["answer"], "Stage")["structuredContent"]
|
||||
self.assertEqual((found["match"], found["to"], found["class"], found["text"]), (True, "Stage", "post", answer["text"]))
|
||||
self.assertEqual((found["match"], found["to"], found["class"], found["text"]), (True, "Stage", "call", answer["text"]))
|
||||
self.assertTrue(self.check(state["message"], state["answer"], "Skills")["isError"])
|
||||
self.assertTrue(self.check(state["message"], f"Choice for decision {decision_id} (Pick a name?): Merge now", "Stage")["isError"])
|
||||
self.assertEqual(self.scripts.calls, [(skill_scripts.RADIO, ["post", "--to", "Stage", "--session", "Operator", f"[kvb-orchestrator msg {state['message']}] {answer['text']}"])])
|
||||
self.assertEqual(self.scripts.calls, [(skill_scripts.RADIO, ["send", "call", "--to", "Stage", "--session", "Operator", f"[kvb-orchestrator msg {state['message']}] {answer['text']}"])])
|
||||
self.assertEqual(self.approve([entry], proof)[0], 409)
|
||||
titles = [row["text"] for row in self.events("kinds=approval")["events"]]
|
||||
self.assertIn("decided · post to Stage (operator)", titles)
|
||||
self.assertIn("decided · call to Stage (operator)", titles)
|
||||
|
||||
def test_an_answer_signed_by_no_pinned_key_decides_nothing_and_sends_nothing(self):
|
||||
self.pin()
|
||||
|
||||
@@ -168,7 +168,7 @@ class TestDecisionRows(unittest.TestCase):
|
||||
self.assertNotIn("Operator", row["pills"])
|
||||
self.assertEqual(row["options"], [["Keep", False], ["Remove", False]])
|
||||
self.assertEqual(row["other"], 1)
|
||||
self.assertEqual(row["to"], ["Your answer goes to Stage 2.0 as a passkey-signed post, with the row id and your answer only."])
|
||||
self.assertEqual(row["to"], ["Your answer goes to Stage 2.0 as a passkey-signed call that wakes it at once, with the row id and your answer only."])
|
||||
|
||||
def test_a_picked_option_is_one_signed_grant_of_the_row_with_its_label_and_no_plain_post(self):
|
||||
picked = self.data["picked"]
|
||||
@@ -183,7 +183,7 @@ class TestDecisionRows(unittest.TestCase):
|
||||
def test_a_clicked_row_greys_out_spins_and_names_what_it_waits_for(self):
|
||||
waits = self.data["waits"]
|
||||
self.assertEqual(waits["idle"], ["", False, 0, ""])
|
||||
for state, words in (("sending", "Clicked: waits for your passkey, then the hub stores the answer and sends it to Stage 2.0"), ("held", "Signed: waits out the undo window of a few seconds, then the hub delivers it to Stage 2.0 and the card closes"), ("picked", 'Picked "Keep": Select mode collects it until you press Grant selection at the top; pick it again to take it back')):
|
||||
for state, words in (("sending", "Clicked: the hub stores the answer and sends it to Stage 2.0 once your passkey signs it"), ("held", "Signed: waits out the undo window of a few seconds, then the hub delivers it to Stage 2.0 and the card closes"), ("picked", 'Picked "Keep": Select mode collects it until you press Grant selection at the top; pick it again to take it back')):
|
||||
with self.subTest(state=state):
|
||||
self.assertEqual(waits[state], [words, True, 1, words])
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ class TestHubInbox(HubCase):
|
||||
self.assertEqual(self.approve([self.entry("review", "0123456789abcdef", "", "")], None)[0], 404)
|
||||
self.assertEqual(self.post_json("/api/inbox/approve", {"items": batch, "proof": None}, self.client())[0], 403)
|
||||
prepared = self.prepare(batch)
|
||||
answer = signing.message_item("Skills", "post", f"Choice for decision {decision_id} (Merge the hub?): Merge now", "", "", "")
|
||||
answer = signing.message_item("Skills", "call", f"Choice for decision {decision_id} (Merge the hub?): Merge now", "", "", "")
|
||||
listed = [signing.item_hash(signing.review_item(green, "/repo/.git", "/repo/.worktrees/feature/x", "feature/x", TREE)), signing.item_hash(signing.ask_item(ask_id, "Bash", "make deploy", "/repo", "s1")), signing.item_hash(answer)]
|
||||
self.assertEqual((prepared["payload"]["items"], prepared["challenge"]), (sorted(listed), signing.challenge(prepared["payload"])))
|
||||
unsigned = [{**self.entry("review", red, "", ""), "verb": "reject"}]
|
||||
|
||||
@@ -445,7 +445,7 @@ class TestWaitingCards(MatchCase):
|
||||
{"kind": "decision", "id": ids["decision"], "verb": "approve", "label": "Merge now", "sha256": ""},
|
||||
{"kind": "ask", "id": ids["ask"], "verb": "approve", "label": "", "sha256": ""},
|
||||
]
|
||||
answer = signing.message_item("Skills", "post", "Decision operator/pick\nAnswer: Wait", "", "", "")
|
||||
answer = signing.message_item("Skills", "call", "Decision operator/pick\nAnswer: Wait", "", "", "")
|
||||
self.assertIn(signing.item_hash(answer), self.prepare(entries)["payload"]["items"])
|
||||
for bad, code in (({**entries[0], "label": "Wait\nAnswer: Merge now"}, 400), ({**entries[0], "payload": "0" * 64}, 400), ({**entries[0], "sha256": "0" * 64}, 409)):
|
||||
with self.subTest(bad=bad):
|
||||
@@ -454,9 +454,9 @@ class TestWaitingCards(MatchCase):
|
||||
self.assertEqual(self.approve(entries, self.signed(entries, self.pin()))[0], 202)
|
||||
self.assertNotIn("operator:operator/pick", [card["id"] for card in self.cards()])
|
||||
self.settle(lambda: self.choice(ids["decision"]) == "Merge now" and self.ask_status(ids["ask"], "0") == "allowed")
|
||||
self.settle(lambda: any(sent[0] == "post" and sent[-1].endswith("Decision operator/pick Answer: Wait") for sent in self.radio()))
|
||||
self.settle(lambda: any(sent[:2] == ["send", "call"] and sent[-1].endswith("Decision operator/pick Answer: Wait") for sent in self.radio()))
|
||||
sent = next(sent for sent in self.radio() if sent[-1].endswith("Answer: Wait"))
|
||||
self.assertEqual(sent[:5], ["post", "--to", "Skills session", "--session", "Operator"])
|
||||
self.assertEqual(sent[:6], ["send", "call", "--to", "Skills session", "--session", "Operator"])
|
||||
self.assertNotIn((skill_scripts.RASCI, ["set", "operator/pick", "--status", "stopped"]), self.scripts.calls)
|
||||
self.assertEqual({card["kind"] for card in self.cards()}, {"commit", "command", "rule"})
|
||||
self.assertEqual(self.post_json("/api/sign", {"items": [entries[0]]}, self.guard(self.host))[0], 409)
|
||||
@@ -471,7 +471,7 @@ class TestWaitingCards(MatchCase):
|
||||
for label in (" padded", "Wait\nAnswer: Merge now", "tab\there", "x" * 1001):
|
||||
with self.subTest(label=label[:20]):
|
||||
self.assertEqual(self.post_json("/api/sign", {"items": [{**entry, "label": label}]}, self.guard(self.host))[0], 400)
|
||||
answer = signing.message_item("Skills", "post", "Decision operator/pick\nAnswer: Ask Main first", "", "", "")
|
||||
answer = signing.message_item("Skills", "call", "Decision operator/pick\nAnswer: Ask Main first", "", "", "")
|
||||
self.assertIn(signing.item_hash(answer), self.prepare([entry])["payload"]["items"])
|
||||
with mock.patch.object(batches, "UNDO", 0.4):
|
||||
self.assertEqual(self.approve([entry], self.signed([entry], self.pin()))[0], 202)
|
||||
|
||||
Reference in new issue
Block a user