feat(hub): the permission hook asks for every tool and signs its whole input

The PermissionRequest hook now registers for every tool (matcher *); make orchestrator-check reports an entry that matches less. What the hub shows and the passkey signs is a Bash call's command when it sets nothing beyond command, description, timeout and run_in_background, else the whole tool input as sorted JSON, so an allow never covers a value the operator did not see (before, an Edit was signed by its file_path alone). The inbox, the stream and Match show an ask like Claude Code's dialog: 1 Yes, 2 No and 'Tell Claude what to do instead', whose text denies with it as the reason. README describes it.

Stacked on dialog (88e53ac); applied cleanly. ruff, node --check and bash -n pass.

Break: an auto-approval rule that matched a non-Bash tool by its path alone no longer matches the JSON summary, so that call asks instead of passing (fails closed). The matcher change takes effect with make orchestrator-hook.

Tests: test_hub_asks, test_hub_decision_rows, test_hub_grant_mode, test_hub_inbox_gone, test_hub_operator_tasks and the Match waiting 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, all 12 files covered.

🎯 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:
Kevin Veen-BirkenbachandClaude Opus 5.5 committed 2026-11-22 15:20:11 +00:00
1 parent 88e53ac51f
commit aa4a337c9a
12 files changed
+119 -38

No files matched your search

+1 -1
View File
@@ -158,7 +158,7 @@ class TestMatchWaiting(HubCase):
self.assertEqual(sorted(seen), sorted([PICK, ask, choice, rule]), found)
self.assertEqual({card_id: entry["kind"] for card_id, entry in seen.items()}, {PICK: "decision", ask: "ask", choice: "decision", rule: "rule"})
self.assertEqual(seen[ask]["chips"], ["fix=95 %", "break=2 %", "score=93", "value=1:4"], found)
self.assertEqual(seen[ask]["command"], SCORED)
self.assertEqual((seen[ask]["command"], seen[ask]["options"]), (SCORED, ["Yes", "No"]), found)
self.assertEqual((seen[PICK]["options"], seen[PICK]["acts"]["Accept"], seen[PICK]["acts"]["Reject"]), (["Merge now", "Wait"], False, False), found)
self.assertEqual((seen[choice]["acts"]["Accept"], seen[choice]["acts"]["Reject"], seen[choice]["refused"]), (True, True, True), found)
self.assertEqual((seen[rule]["rule"], seen[rule]["sheet"], seen[rule]["stayed"]), (True, True, True), found)
+15
View File
@@ -148,6 +148,21 @@ class TestHubAsks(HubCase):
self.assertEqual(self.call("POST", f"/api/asks/{ask['id']}/deny", b"", self.guard(self.host))[0], 200)
self.assertEqual(json.loads(self.finish(process)[1])["hookSpecificOutput"]["decision"]["behavior"], "deny")
def test_every_tool_but_a_plain_bash_call_shows_and_signs_its_whole_input(self):
edit = {"file_path": "/repo/a.py", "old_string": "x = 1", "new_string": "x = 2\n"}
unsandboxed = {"command": "ls", "dangerouslyDisableSandbox": True}
for tool, tool_input, shown in (
("Edit", edit, '{\n "file_path": "/repo/a.py",\n "new_string": "x = 2\\n",\n "old_string": "x = 1"\n}'),
("Bash", unsandboxed, '{\n "command": "ls",\n "dangerouslyDisableSandbox": true\n}'),
("Bash", {"command": "ls", "description": "list", "timeout": 5, "run_in_background": False}, "ls"),
):
with self.subTest(tool=tool, keys=sorted(tool_input)):
process = self.hook(self.port, "20", {**HOOK, "tool_name": tool, "tool_input": tool_input})
ask = self.first_ask()
self.assertEqual((ask["tool"], ask["command"]), (tool, shown))
self.assertEqual(self.call("POST", f"/api/asks/{ask['id']}/deny", b"", self.guard(self.host))[0], 200)
self.finish(process)
def test_a_bad_timeout_names_the_field_the_caller_sent(self):
status, _, body = self.post_json("/api/asks", {**ASK, "timeout": -1}, self.local())
self.assertEqual((status, body), (400, b"timeout must be a finite number of seconds, 0 or more\n"))
+18
View File
@@ -43,6 +43,7 @@ const items = {
bare: {...base, kind: "operator", id: "operator/bare", title: "decide: rename it", command: "decide: rename it", check: "decision"},
orphan: {...base, kind: "operator", id: "operator/orphan", title: question, command: question, check: "decision", options, agent: ""},
run: {...base, kind: "operator", id: "operator/run", title: "make install", command: "make install", check: "manual", runnable: true},
ask: {...base, kind: "ask", id: "a-1", title: "Bash: rm -rf build", command: "rm -rf build"},
pick: {...base, kind: "decision", id: "d-1", title: "Layout?", deniable: false, recommended: "B", options: [{label: "A", description: "tabs", preview: "[A]\nline"}, {label: "B", description: "card", preview: "[B]"}, {label: "C", description: "none"}]},
};
const context = {
@@ -109,6 +110,17 @@ const results = {};
results.keys = {submits: submits.splice(0), stopped, focused: document.activeElement === null ? "" : document.activeElement.tag};
press("4");
results.keys.other = document.activeElement.tag;
const denials = [];
denyNow = (item, channel, reason) => { denials.push([item.id, channel, reason]); };
const asking = inboxItem(items.ask, 6);
results.ask = {options: shape(asking).options, other: shape(asking).other};
await optionNamed(asking, "No").fire("click");
const tell = classed(asking, "other")[0];
all(tell).find((el) => el.tag === "input").value = " Yes ";
await tell.fire("submit");
await optionNamed(asking, "Yes").fire("click");
results.ask.denials = denials.splice(0);
results.ask.grants = submits.splice(0).map((label) => label.split(":")[0]);
console.log(JSON.stringify(results));
})().catch((error) => { console.error(error && error.stack || error); process.exit(1); });
`;
@@ -173,6 +185,12 @@ class TestDecisionRows(unittest.TestCase):
self.assertEqual((keys["submits"], keys["stopped"], keys["focused"]), (["Choice: B"], 1, ""))
self.assertEqual(keys["other"], "input")
def test_a_permission_ask_offers_yes_and_no_and_typed_text_always_denies_with_it_as_the_reason(self):
ask = self.data["ask"]
self.assertEqual((ask["options"], ask["other"]), ([["Yes", False], ["No", False]], 1))
self.assertEqual(ask["denials"], [["a-1", "post", ""], ["a-1", "post", "Yes"]])
self.assertEqual(ask["grants"], ["Grant"])
class TestDecisionFeed(HubCase):
def test_the_inbox_carries_a_decision_rows_options_and_drops_malformed_ones(self):
+3 -3
View File
@@ -7,7 +7,7 @@ import unittest
from hub_support import HUB
TEMPLATES = HUB / "templates"
MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-inbox.js", "page-grant.js"]
MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-dialog.js", "page-inbox.js", "page-grant.js"]
PROBE = r"""
const fs = require("fs");
const vm = require("vm");
@@ -110,8 +110,8 @@ const byName = (node, label) => buttons(node).find((button) => button.getAttribu
results.direct_press = press(of("green"));
await approveOne(of("green"));
results.direct = take();
ui.selected.add(keyOf(of("ask")));
results.direct_picked = press(of("ask"));
ui.selected.add(keyOf(of("run")));
results.direct_picked = press(of("run"));
drawGrant();
results.direct_selection = {main: buttons(bar)[0].getAttribute("aria-label"), labels: labels(bar)};
ui.selected.clear();
+1 -1
View File
@@ -7,7 +7,7 @@ import unittest
from hub_support import HUB
TEMPLATES = HUB / "templates"
MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-api.js", "page-passkey.js", "page-inbox.js", "page-grant.js", "page-console.js", "page-rule-request.js", "page-load.js"]
MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-dialog.js", "page-api.js", "page-passkey.js", "page-inbox.js", "page-grant.js", "page-console.js", "page-rule-request.js", "page-load.js"]
GONE = "operator/gui-agentbox-merge-push"
NOTICE = "already done or removed elsewhere"
PROBE = r"""
+1 -1
View File
@@ -24,7 +24,7 @@ hub_limits = importlib.import_module("hub_limits")
approval = importlib.import_module("approval")
TEMPLATES = HUB / "templates"
DIFFS = TEMPLATES / "diffs.js"
PAGE_MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-diff.js", "page-inbox.js", "page-grant.js", "page-stream.js", "page-screens.js", "page-keyboard.js"]
PAGE_MODULES = ["page-constants.js", "page-reveal.js", "page-dom.js", "page-dialog.js", "page-diff.js", "page-inbox.js", "page-grant.js", "page-stream.js", "page-screens.js", "page-keyboard.js"]
SECRET = 'api_key = "plain-example-words"'
ARMOURED = "before\n-----BEGIN EXAMPLE-----\nplain words only\n-----END EXAMPLE-----\nafter\n"
WITHHELD = "content withheld"