O5: safety - allowlist guard, credential separation, audit log #13

Merged
hermes merged 1 commits from o5-safety into main 2026-11-13 00:09:31 +00:00
Collaborator

Closes #6

hx in -p mode never prompts (no permission hook = every call allowed), so orch enforces the policy itself. Details in docs/safety.md.

  • allow list per profile: TOOL, *, or bash:GLOB (simple commands only, path-like words must stay in the worktree or read_roots). Hard rules even for *: no git push, no credential-looking paths, file tools stay in the worktree, no writes to .git / .hx. A denied call ends the run as needs-human (policy: ...), the branch keeps the work so far.
  • Enforced twice: orch guard runs inside hx as an extension (generated .hx/config.toml, removed after each attempt, never committed, rewritten before the next attempt) and orch re-checks every tool_call event and kills the run, because hx treats a dead or slow extension as "continue". A repo with its own .hx/config.toml is refused instead of silently running unguarded.
  • Credential separation: hx gets a cleared environment (PATH, HOME, USER, LANG, LC_, TMPDIR, CARGO_, RUST*, NIX_* plus the profile's env patterns). HX_HOME of orch is dropped when the profile sets its own home, so the work profile never inherits the private auth file.
  • Audit: append-only <state>/audit.log (run_start, one tool line per allow/deny with rule and args, run_end), orch audit [ID]. Warning on stderr for profiles with neither allow nor sandbox.
  • yolo without sandbox was already refused at profile load (O1).

Verification: sh tests/all.sh exit 0 (fmt, clippy -D warnings, 15 unit tests, e2e, spike check, real-hx e2e). The acceptance test: a work-profile run asking hx to read the private profile's auth.json is blocked (fake hx speaking the real extension protocol AND with the guard disabled, via the stream check), the token never appears in the repo or log, env dump shows no HX_HOME/AWS_*/GITEA_*. tests/real_hx.py drives the REAL hx binary (/opt/data/hx debug build) against its fake Anthropic API: hx starts orch guard itself and the Read of the secret is denied by the guard (audit by: ['guard']). e2e flake loop 8/8 idle, 6/6 under 6 CPU hogs.

Deviations from the issue text: "block pushes to protected branches" is implemented as "agents never push" (stricter; the sink pushes). Not done: confining plain bash (needs sandbox = true; bwrap is not installed on this box, so sandbox mode is untested here), network policy, per-command timeouts.

Closes #6 hx in `-p` mode never prompts (no permission hook = every call allowed), so orch enforces the policy itself. Details in `docs/safety.md`. - `allow` list per profile: `TOOL`, `*`, or `bash:GLOB` (simple commands only, path-like words must stay in the worktree or `read_roots`). Hard rules even for `*`: no `git push`, no credential-looking paths, file tools stay in the worktree, no writes to `.git` / `.hx`. A denied call ends the run as `needs-human` (`policy: ...`), the branch keeps the work so far. - Enforced twice: `orch guard` runs inside hx as an extension (generated `.hx/config.toml`, removed after each attempt, never committed, rewritten before the next attempt) and orch re-checks every `tool_call` event and kills the run, because hx treats a dead or slow extension as "continue". A repo with its own `.hx/config.toml` is refused instead of silently running unguarded. - Credential separation: hx gets a cleared environment (PATH, HOME, USER, LANG, LC_*, TMPDIR, CARGO_*, RUST*, NIX_* plus the profile's `env` patterns). `HX_HOME` of orch is dropped when the profile sets its own `home`, so the work profile never inherits the private auth file. - Audit: append-only `<state>/audit.log` (`run_start`, one `tool` line per allow/deny with rule and args, `run_end`), `orch audit [ID]`. Warning on stderr for profiles with neither `allow` nor `sandbox`. - `yolo` without `sandbox` was already refused at profile load (O1). Verification: `sh tests/all.sh` exit 0 (fmt, clippy -D warnings, 15 unit tests, e2e, spike check, real-hx e2e). The acceptance test: a work-profile run asking hx to read the private profile's `auth.json` is blocked (fake hx speaking the real extension protocol AND with the guard disabled, via the stream check), the token never appears in the repo or log, env dump shows no `HX_HOME`/`AWS_*`/`GITEA_*`. `tests/real_hx.py` drives the REAL hx binary (/opt/data/hx debug build) against its fake Anthropic API: hx starts `orch guard` itself and the Read of the secret is denied by the guard (`audit by: ['guard']`). e2e flake loop 8/8 idle, 6/6 under 6 CPU hogs. Deviations from the issue text: "block pushes to protected branches" is implemented as "agents never push" (stricter; the sink pushes). Not done: confining plain `bash` (needs `sandbox = true`; bwrap is not installed on this box, so sandbox mode is untested here), network policy, per-command timeouts.
hermes added 1 commit 2026-11-13 00:09:28 +00:00
hermes merged commit bea07e82bb into main 2026-11-13 00:09:31 +00:00
hermes deleted branch o5-safety 2026-11-13 00:09:32 +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#13