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

+23 -6
View File
@@ -88,7 +88,7 @@ mode = path.stat().st_mode & 0o777 if path.exists() else 0o600
entries = settings.setdefault("hooks", {}).setdefault("PermissionRequest", [])
entries[:] = [entry for entry in entries if not any(marker in hook.get("command", "") for hook in entry.get("hooks", []))]
if added:
entries.append({"matcher": "Bash|AskUserQuestion", "hooks":[{"type": "command", "command": added[0], "timeout": int(added[1])}]})
entries.append({"matcher": "*", "hooks":[{"type": "command", "command": added[0], "timeout": int(added[1])}]})
temporary = path.with_name(f"{path.name}.{os.getpid()}")
temporary.write_text(json.dumps(settings, indent=2, ensure_ascii=False) + "\n", encoding="utf-8")
temporary.chmod(mode)
@@ -96,6 +96,22 @@ temporary.replace(path)
PY
}
# Args: settings files. Prints the matcher of every PermissionRequest entry
# whose hook runs this hub's client, one per line.
hook_matchers() {
python3 - "${NAME}/client/permission_hook.py" "$@" <<'PY'
import json, sys
from pathlib import Path
marker, *paths = sys.argv[1:]
for path in (Path(name) for name in paths):
if path.is_file():
for entry in json.loads(path.read_text(encoding="utf-8")).get("hooks", {}).get("PermissionRequest", []):
if any(marker in hook.get("command", "") for hook in entry.get("hooks", [])):
print(entry.get("matcher", ""))
PY
}
move_once() {
local from="$1" to="$2"
[[ -e "${from}" ]] || return 0
@@ -389,12 +405,13 @@ check() {
code="$(curl -s -o /dev/null -w '%{http_code}' "http://localhost:${port}/" || true)"
if [[ "${code}" == "200" ]]; then ok "http://localhost:${port}/ answers 200"; else fail "http://localhost:${port}/ answers ${code}"; fi
check_keys
if grep -qs "${NAME}/client/permission_hook.py" "${SETTINGS}" "${LOCAL_SETTINGS}" && ! grep -qs '"Bash|AskUserQuestion"' "${SETTINGS}" "${LOCAL_SETTINGS}"; then
todo "PermissionRequest hook misses AskUserQuestion: make orchestrator-hook"
elif grep -qs "${NAME}/client/permission_hook.py" "${SETTINGS}" "${LOCAL_SETTINGS}"; then
ok "PermissionRequest hook registered"
else
matchers="$(hook_matchers "${SETTINGS}" "${LOCAL_SETTINGS}")"
if [[ -z "${matchers}" ]]; then
todo "PermissionRequest hook missing: make orchestrator-hook"
elif grep -qvx '\*' <<<"${matchers}"; then
todo "PermissionRequest hook matches only ${matchers//$'\n'/, }, not every tool: make orchestrator-hook"
else
ok "PermissionRequest hook registered for every tool"
fi
if [[ "$(systemctl --user is-active "${RUNNER}" 2>/dev/null || true)" == "active" ]]; then
ok "runner active; last lines:"