claude_cli: guard denies before the tool runs (hx#182) #19

Merged
hermes merged 1 commits from claude-cli-guard into main 2026-11-14 11:19:52 +00:00
Collaborator

Closes #17

hx#182 is merged (bridge on the event bus, permissions = "extensions-only", claude tool events). This PR switches orch from "fail closed after the fact" to the real guard and proves it against the real hx binary.

  • orch guard config for every guarded run now also sets permissions = "extensions-only": in claude_cli mode a question is allowed only while a live tool_call extension answers it, so a dead guard denies instead of "continue".
  • The count check from #18 stays as an independent second line (claude lines vs tool_call events), now for the case that claude skips the permission prompt or an hx without #182 is used.
  • tests/fake_claude.py behaves like claude with --permission-prompt-tool: it asks mcp__hx__approve first and runs the tool only when allowed.

Verification (real hx binary at hx main f1b3ee0, fake claude):

  • control: profile without allow -> the fake claude really reads the secret (test is sensitive), mode claude_cli.
  • profile with allow: the Read is put on the bus, orch guard denies it BEFORE the tool runs; claude-read.txt does not exist, run needs-human policy:, audit has the deny written by the guard.
  • claude that never asks (flags ignored): the read goes through (control), orch notices after the fact: needs-human policy:.
  • dead guard (tests/dying_guard.py, starts, dies on the first event): without extensions-only the secret is read (control), with it nothing is read. Checked by hand first.
  • sh tests/all.sh exit 0, flake loop 5/5 under load.

Not verified: a real claude binary. hx#182's --settings permissions.ask flag is untested against it (the hx PR says the same); if real claude does not ask for reads, the count check still catches it after the fact, and the next step is --tools/--disallowedTools in claude_cli = [...] (claude 2.1.318 has them). The first real-claude run decides; orch audit shows what was asked.

Closes #17 hx#182 is merged (bridge on the event bus, `permissions = "extensions-only"`, claude tool events). This PR switches orch from "fail closed after the fact" to the real guard and proves it against the real hx binary. - `orch guard` config for every guarded run now also sets `permissions = "extensions-only"`: in claude_cli mode a question is allowed only while a live `tool_call` extension answers it, so a dead guard denies instead of "continue". - The count check from #18 stays as an independent second line (claude lines vs `tool_call` events), now for the case that claude skips the permission prompt or an hx without #182 is used. - `tests/fake_claude.py` behaves like claude with `--permission-prompt-tool`: it asks `mcp__hx__approve` first and runs the tool only when allowed. Verification (real hx binary at hx main f1b3ee0, fake claude): - control: profile without `allow` -> the fake claude really reads the secret (test is sensitive), mode `claude_cli`. - profile with `allow`: the Read is put on the bus, `orch guard` denies it BEFORE the tool runs; `claude-read.txt` does not exist, run `needs-human policy:`, audit has the deny written by the guard. - claude that never asks (flags ignored): the read goes through (control), orch notices after the fact: `needs-human policy:`. - dead guard (`tests/dying_guard.py`, starts, dies on the first event): without `extensions-only` the secret is read (control), with it nothing is read. Checked by hand first. - `sh tests/all.sh` exit 0, flake loop 5/5 under load. Not verified: a real `claude` binary. hx#182's `--settings permissions.ask` flag is untested against it (the hx PR says the same); if real claude does not ask for reads, the count check still catches it after the fact, and the next step is `--tools`/`--disallowedTools` in `claude_cli = [...]` (claude 2.1.318 has them). The first real-claude run decides; `orch audit` shows what was asked.
hermes added 1 commit 2026-11-14 10:52:08 +00:00
hermes merged commit 9ce4756fad into main 2026-11-14 11:19:52 +00:00
hermes deleted branch claude-cli-guard 2026-11-14 11:19:53 +00:00
Sign in to join this conversation.
No Reviewers
No labels
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/orch#19