61 lines
3.9 KiB
Markdown
61 lines
3.9 KiB
Markdown
# 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.
|
|
- `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.
|
|
|
|
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 has two ways to reach Claude. They differ in what orch can enforce:
|
|
|
|
| mode | who runs the tools | `allow` | `max_turns` |
|
|
|---|---|---|---|
|
|
| `direct` (API provider) | hx | enforced (guard + stream check) | counts model turns |
|
|
| `claude_cli` (hx starts the `claude` binary; auto-on when `claude` is in PATH and `HX_BASE_URL` is unset) | the `claude` binary; hx emits no `tool_call` events and its permission bridge skips reads | cannot be enforced | meaningless: 1 hx request per run |
|
|
|
|
A profile with `allow` in `claude_cli` mode is **refused** before hx starts: the run ends `needs-human` with
|
|
`policy: allow cannot be enforced ...`. orch never runs "guarded" without a guard and never switches providers
|
|
silently (the direct Claude provider is not usable on every subscription). Options for such a profile:
|
|
no `allow` plus `sandbox = true`, `home`, the cleared environment; or `claude_cli = false` in the profile's hx config
|
|
if the direct provider works for you. Planned: make the claude_cli provider guardable in hx (permission bridge on
|
|
the event bus, tool events), see the linked hx issue.
|
|
|
|
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.
|
|
Limit: 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.
|
|
|
|
## Audit log
|
|
|
|
`<state>/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.
|