Allowlist: readonly entry, on_deny = continue, tokens of stopped runs #20

Merged
hermes merged 2 commits from readonly-allow into main 2026-11-14 12:54:16 +00:00
Collaborator

Your second bench run (readonly in place): 3 of 12 done. The 9 needs-human all came from Python test/inspect commands, and each denied bash call ended the whole run, so every gap in the allowlist killed the run instead of letting Claude pick another way. Also tok/run was 9711 while tok/done was 38845 (runs stopped by the guard reported 0 tokens).

1. readonly allowlist entry (unchanged from the first commit of this PR): bash commands that only look, flags that run or write refused.

2. on_deny = "continue" (profile key, default "stop" = old behaviour)

  • Soft deny (not in the allowlist): the guard answers the call with orch-guard-soft: <reason>. Use another way ..., the tool does not run, the run goes on, the gate decides in the end.
  • Hard deny always stops the run, also under continue: credential-looking paths, paths outside the worktree, git push, writes to .git/.hx. (Decision::Hard vs Decision::Deny in policy.rs.)
  • Every deny is audited (decision: deny, new hard: true|false) and counted: denies in the run state, in telemetry and as a denies column in orch report.

3. Tokens of stopped runs. Per attempt orch sums the stream/done usage events and uses that as a lower bound when the final done line never comes (guard, budget or timeout kill). needs-human runs no longer show 0 tokens; tok/run becomes comparable. (A killed run's last request may still be missing, so it is a lower bound, never an overcount.)

Also: a guard-blocked claude tool shows up in hx' stream only as a tool_result (the bus tool_call is internal), so the soft/hard deny is counted from that result; the count check from #19 keeps working.

Verification: sh tests/all.sh exit 0 (24 unit tests, e2e, real-hx e2e), flake loop 5/5 under load.

  • Unit: hard vs soft table (credentials, outside worktree, push, metadata hard; not-in-allowlist soft). Mutation: a decide that always allows turns 5 tests red.
  • e2e (real orch guard process): under continue the agent tries python3 -c, gets the reason, then runs ls and writes; denied call never ran, denies = 1, audit deny, allow, allow. Hard denies (auth.json, git push, .hx/config.toml, ls /etc) still end needs-human. Default stop ends at the first soft deny. Mutation 1 (soft deny always stops) and mutation 2 (no token fallback) each turn the e2e red.
  • Real hx binary + fake claude: on_deny = continue with a denied ls ends done with denies = 1; the same profile with readonly has denies = 0; default stop ends needs-human.

Not verified with real claude: how it reacts to a denied call (it reads the reason and may retry the same command or give up with a text answer; the retry then counts as another deny). A run that loops on denies is limited only by max_turns / max_tokens / wall_secs, so set one of them when you use continue.

Your second bench run (`readonly` in place): 3 of 12 done. The 9 `needs-human` all came from Python test/inspect commands, and each denied bash call ended the whole run, so every gap in the allowlist killed the run instead of letting Claude pick another way. Also `tok/run` was 9711 while `tok/done` was 38845 (runs stopped by the guard reported 0 tokens). **1. `readonly` allowlist entry** (unchanged from the first commit of this PR): bash commands that only look, flags that run or write refused. **2. `on_deny = "continue"`** (profile key, default `"stop"` = old behaviour) - Soft deny (not in the allowlist): the guard answers the call with `orch-guard-soft: <reason>. Use another way ...`, the tool does not run, the run goes on, the gate decides in the end. - Hard deny always stops the run, also under `continue`: credential-looking paths, paths outside the worktree, `git push`, writes to `.git`/`.hx`. (`Decision::Hard` vs `Decision::Deny` in policy.rs.) - Every deny is audited (`decision: deny`, new `hard: true|false`) and counted: `denies` in the run state, in telemetry and as a `denies` column in `orch report`. **3. Tokens of stopped runs.** Per attempt orch sums the `stream/done` usage events and uses that as a lower bound when the final `done` line never comes (guard, budget or timeout kill). `needs-human` runs no longer show 0 tokens; `tok/run` becomes comparable. (A killed run's last request may still be missing, so it is a lower bound, never an overcount.) Also: a guard-blocked claude tool shows up in hx' stream only as a `tool_result` (the bus `tool_call` is internal), so the soft/hard deny is counted from that result; the count check from #19 keeps working. Verification: `sh tests/all.sh` exit 0 (24 unit tests, e2e, real-hx e2e), flake loop 5/5 under load. - Unit: hard vs soft table (credentials, outside worktree, push, metadata hard; not-in-allowlist soft). Mutation: a `decide` that always allows turns 5 tests red. - e2e (real `orch guard` process): under `continue` the agent tries `python3 -c`, gets the reason, then runs `ls` and writes; denied call never ran, `denies = 1`, audit `deny, allow, allow`. Hard denies (`auth.json`, `git push`, `.hx/config.toml`, `ls /etc`) still end `needs-human`. Default `stop` ends at the first soft deny. Mutation 1 (soft deny always stops) and mutation 2 (no token fallback) each turn the e2e red. - Real hx binary + fake claude: `on_deny = continue` with a denied `ls` ends `done` with `denies = 1`; the same profile with `readonly` has `denies = 0`; default `stop` ends `needs-human`. Not verified with real claude: how it reacts to a denied call (it reads the reason and may retry the same command or give up with a text answer; the retry then counts as another deny). A run that loops on denies is limited only by `max_turns` / `max_tokens` / `wall_secs`, so set one of them when you use `continue`.
hermes added 1 commit 2026-11-14 11:29:05 +00:00
hermes changed title from Allowlist entry readonly to Allowlist: readonly entry, on_deny = continue, tokens of stopped runs 2026-11-14 12:18:54 +00:00
hermes added 1 commit 2026-11-14 12:18:57 +00:00
hermes merged commit 39a2e74742 into main 2026-11-14 12:54:16 +00:00
hermes deleted branch readonly-allow 2026-11-14 12:54:16 +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#20