# Safety hx in `-p` mode never prompts: with no permission hook every tool call is allowed. orch therefore enforces its own policy and keeps credentials of different profiles apart. ## Profile keys ```toml home = "/work/hxhome" # own HOME => own ~/.hx/auth.json; HX_HOME of orch is NOT passed on allow = ["read", "write", "edit", "bash:cargo *", "bash:git status"] read_roots = ["/work/shared-docs"] # extra readable dirs besides the worktree env = ["GITEA_*"] # orch env vars hx may see (default: PATH HOME USER LOGNAME SHELL TERM LANG LC_* # TMPDIR CARGO_* RUST* NIX_*, plus HX_HOME only when `home` is unset) sandbox = true # hx --sandbox (bwrap); required for yolo = true ``` ## Allowlist (`allow`) - Absent: no policy, hx may use every tool (orch prints a warning unless `sandbox = true`). - `TOOL` allows every call of that tool (`read`, `write`, `edit`, `bash`, `lsp`, ...), `*` allows all. - `readonly`: bash commands that only look, one simple command each: `ls cat head tail wc grep rg fd find pwd echo stat file du df which tree diff sort cut nl tr jq basename dirname` and `git status|diff|log|show|blame|ls-files|rev-parse`. Flags that run or write are refused per command (`find -exec/-delete/-fprint*`, `fd -x/--exec`, `rg --pre`, `sort -o/--output`, `tree -o`, `git --output/--ext-diff/--textconv`), and so are `git -C`, other git subcommands and anything outside the worktree. Typical profile: `allow = ["read", "write", "edit", "readonly", "Grep", "Glob", "LS", "bash:cargo *"]`. In `claude_cli` mode Claude's other tools arrive under Claude's own names and need their own entry. - `bash:PATTERN`: `*` glob over the whole command. Only simple commands match (no `; & | < > $ ( ) { } \` or newline); path-like words must resolve inside the worktree or `read_roots`. - Always denied, even with `*`: `git push` (publishing is the sink's job), credential-looking paths (`.env*`, `.ssh`, `.aws`, `auth.json`, `*.pem`, `*.key`, ...), file tools outside the worktree (reads may also use `read_roots`), writes to `.git` and `.hx`. - A denied call ends the run as `needs-human` with `reason = "policy: ..."`; the branch keeps what was done so far. - `on_deny = "continue"` (default `"stop"`): a call that is merely **not in the allowlist** is answered to the agent (`orch-guard-soft: ... Use another way`), the tool does not run and the run goes on; the gate decides in the end. **Hard** denies always stop the run: credential-looking paths, paths outside the worktree, `git push`, writes to `.git`/`.hx`. Every deny is audited (`decision: deny`, `hard: true|false`) and counted (`denies` in the run state, telemetry and the `denies` column of `orch report`). Enforced twice: `orch guard` runs inside hx as an extension (installed as the worktree's `.hx/config.toml`, removed after each attempt, rewritten before the next) and blocks the call before it executes. orch also checks every `tool_call` event in the stream and kills the run, because hx treats a dead or slow extension as "continue". Limit: plain `bash` (no pattern) is not confined; a shell cannot be parsed reliably. Use `sandbox = true` for that. A repo that already has its own `.hx/config.toml` is refused (`setup:` failure) so the guard is never silently skipped. ## Provider modes hx reaches Claude in two ways: | mode | who runs the tools | how `allow` is enforced | |---|---|---| | `direct` (API provider) | hx | `orch guard` blocks the `tool_call` before the tool runs; orch re-checks the event stream | | `claude_cli` (hx starts the `claude` binary; auto-on when `claude` is in PATH and `HX_BASE_URL` is unset) | the `claude` binary | requires hx with johannes/hx#182: claude asks `mcp__hx__approve` first, hx puts the question on the event bus as `tool_call` (`bash{command}`, `write|edit|read{path}`), `orch guard` blocks it before the tool runs | For `claude_cli` orch writes `permissions = "extensions-only"` into the generated worktree config. Then a question is allowed only while a live `tool_call` extension guards it: if the guard dies or never starts, hx denies (a dead extension otherwise counts as "continue"). Reads and Bash are asked too (hx passes `--settings permissions.ask`). Checks that do not depend on trusting hx or claude: - Stream check: orch sees `tool_call` events from claude's tools too and kills the run on a denied one. - Count check: orch counts the `[claude TOOL: ...]` lines hx prints for every tool claude ran and the `tool_call` events. Fewer events than lines (hx without #182, or a claude that skips the permission prompt) ends the run `needs-human`: `policy: claude used N tool(s) but hx reported M tool_call event(s) ...`. This check is after the fact (the tool already ran); the bridge is what prevents the call. `max_turns` counts model turns; in claude_cli mode there is one hx request per run, so it is not a useful limit. Telemetry records the mode (`provider_mode`: `claude_cli`, `direct`, `codex`; old lines `unknown`). `orch report` shows it as a column and `orch eval` refuses to compare files with different (or mixed) modes ("NOT COMPARABLE", exit 1): tokens, turns and tool behaviour differ by an order of magnitude between the modes. Limits: the mode is derived from config and the `claude` binary, not from hx itself (hx' remembered last provider `last.json` is not read, so set `provider` in profiles you compare). hx#182's `--settings` flag is untested against a real `claude` binary (upstream says so too); tests use a fake claude that asks the bridge like the real one. ## Audit log `/audit.log`, append-only JSONL: `run_start` (profile, allowlist, sandbox, yolo), one `tool` line per call (`allow`/`deny`, rule, arguments), `run_end`. `orch audit [RUN_ID]` prints it.