fix: orchestrated runs honour yolo/auto and work inside the sandbox #194

Merged
johannes merged 1 commits from fix/acp-sandbox-permissions into main 2026-11-17 15:48:38 +00:00
Owner
  • serve --acp applies --yolo / --auto (or permissions in config.toml)
    like the TUI; before, every edit and command went to the orchestrator.
  • claude no longer asks to run outside the sandbox. With the sandbox on it
    stays confined; only a stored claude:unsandboxed rule or
    --no-claude-sandbox lets it out, and yolo never does.
  • The sandbox reads the files the global git config includes and may stat
    $HOME and the directories above allowed paths and includeIf gitdir
    paths (metadata only). git died on both before.
  • hx mcp-serve logs a failed start to $TMPDIR/hx-mcp-serve.log; claude
    hides its stderr and only reports "mcp__hx__approve not found".

Co-Authored-By: Claude Opus 5.5 noreply@anthropic.com

- serve --acp applies --yolo / --auto (or `permissions` in config.toml) like the TUI; before, every edit and command went to the orchestrator. - claude no longer asks to run outside the sandbox. With the sandbox on it stays confined; only a stored `claude:unsandboxed` rule or --no-claude-sandbox lets it out, and yolo never does. - The sandbox reads the files the global git config includes and may stat $HOME and the directories above allowed paths and includeIf gitdir paths (metadata only). git died on both before. - hx mcp-serve logs a failed start to $TMPDIR/hx-mcp-serve.log; claude hides its stderr and only reports "mcp__hx__approve not found". Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
johannes added 1 commit 2026-11-17 15:48:31 +00:00
- serve --acp applies --yolo / --auto (or `permissions` in config.toml)
  like the TUI; before, every edit and command went to the orchestrator.
- claude no longer asks to run outside the sandbox. With the sandbox on it
  stays confined; only a stored `claude:unsandboxed` rule or
  --no-claude-sandbox lets it out, and yolo never does.
- The sandbox reads the files the global git config includes and may stat
  $HOME and the directories above allowed paths and includeIf gitdir
  paths (metadata only). git died on both before.
- hx mcp-serve logs a failed start to $TMPDIR/hx-mcp-serve.log; claude
  hides its stderr and only reports "mcp__hx__approve not found".

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
johannes merged commit 437f8ec501 into main 2026-11-17 15:48:38 +00:00
johannes deleted branch fix/acp-sandbox-permissions 2026-11-17 15:48:39 +00:00

Preparing review...

Preparing review...

PR Reviewer Guide 🔍

Here are some key observations to aid the review process:

⏱️ Estimated effort to review: 3 🔵🔵🔵⚪⚪
🧪 PR contains tests
🔒 Security concerns

Sandbox scope widening:
the sandbox now grants file-read-metadata on $HOME, parent dirs of allowed paths, and includeIf gitdir paths. It also grants read on files included by the global git config. Metadata exposure is low risk, but included git-config files can hold credentials or tokens, so confirm only the exact included files are readable and that symlinks are not followed outside the intended set. Also check config trust: if yolo can be enabled from repo-local config, untrusted repos can disable permission prompts in ACP mode.

⚡ Recommended focus areas for review

Unattended Auto-Approve

ACP mode now sets yolo/auto from cfg.permissions. Check where cfg is loaded from. If a project-local config.toml can set permissions = "yolo", a cloned repo could silently turn off all prompts for an orchestrated run. Also check that --yolo and --auto are mutually exclusive in the CLI definition, since auto && !yolo quietly resolves the conflict.

// no TUI, no prompts: every permission question goes to the orchestrator, except what
// --yolo / --auto (or `permissions` in config.toml) settle here, the same as in the TUI
{
    let yolo = cli.yolo || cfg.permissions.as_deref() == Some("yolo");
    let auto = cli.auto || cfg.permissions.as_deref() == Some("auto");
    let mut a = agent
        .cx
        .state
        .allow
        .lock()
        .unwrap_or_else(|e| e.into_inner());
    a.set_yolo(yolo);
    a.set_auto(auto && !yolo);
}
Exact-Match Rule Lookup

has_rule uses self.rules.contains(rule), which is an exact match. If stored rules can be globs or prefixes (the glob helper above suggests so), a pattern like claude:* will not count as claude:unsandboxed. Confirm the intent. Also confirm rules is a set of String so contains(&str) compiles and behaves as expected. The "yolo never unsandboxes" guarantee depends entirely on callers using has_rule instead of the general permission check, so add a test that pins it.

/// A stored rule (`.hx/allow.json` or "always" this session), ignoring yolo and edit grants.
pub fn has_rule(&self, rule: &str) -> bool {
    self.rules.contains(rule)
}
Brittle Test

The assertion hardcodes the exact order of file-read-metadata literals in one long string. It passes only if the path list is deterministically sorted and deduplicated (for example a BTreeSet). If it is built from a HashSet or insertion order, the test will be flaky. Also, the sandbox logic that reads git-config includes and stats $HOME and ancestor dirs is not in this diff, so verify it separately.

assert!(p.contains(
    "(allow file-read-metadata (literal \"/home/u\") (literal \"/home/u/.cargo\") (literal \"/home/u/.cargo/registry\") (literal \"/home/u/proj\") (literal \"/home/u/w\") (literal \"/home/u/w/x\"))"
));
## PR Reviewer Guide 🔍 Here are some key observations to aid the review process: <table> <tr><td>⏱️&nbsp;<strong>Estimated effort to review</strong>: 3 🔵🔵🔵⚪⚪</td></tr> <tr><td>🧪&nbsp;<strong>PR contains tests</strong></td></tr> <tr><td>🔒&nbsp;<strong>Security concerns</strong><br><br> <strong>Sandbox scope widening:</strong><br> the sandbox now grants `file-read-metadata` on `$HOME`, parent dirs of allowed paths, and `includeIf gitdir` paths. It also grants read on files included by the global git config. Metadata exposure is low risk, but included git-config files can hold credentials or tokens, so confirm only the exact included files are readable and that symlinks are not followed outside the intended set. Also check config trust: if yolo can be enabled from repo-local config, untrusted repos can disable permission prompts in ACP mode.</td></tr> <tr><td>⚡&nbsp;<strong>Recommended focus areas for review</strong><br><br> <details><summary><a href='https://git.jokresner.de/johannes/hx/src/branch/refs/pull/194/head/crates/hx-cli/src/main.rs#L1197-L1210'><strong>Unattended Auto-Approve</strong></a> ACP mode now sets yolo/auto from `cfg.permissions`. Check where `cfg` is loaded from. If a project-local `config.toml` can set `permissions = "yolo"`, a cloned repo could silently turn off all prompts for an orchestrated run. Also check that `--yolo` and `--auto` are mutually exclusive in the CLI definition, since `auto && !yolo` quietly resolves the conflict. </summary> ```rust // no TUI, no prompts: every permission question goes to the orchestrator, except what // --yolo / --auto (or `permissions` in config.toml) settle here, the same as in the TUI { let yolo = cli.yolo || cfg.permissions.as_deref() == Some("yolo"); let auto = cli.auto || cfg.permissions.as_deref() == Some("auto"); let mut a = agent .cx .state .allow .lock() .unwrap_or_else(|e| e.into_inner()); a.set_yolo(yolo); a.set_auto(auto && !yolo); } ``` </details> <details><summary><a href='https://git.jokresner.de/johannes/hx/src/branch/refs/pull/194/head/crates/hx-core/src/permit.rs#L405-L408'><strong>Exact-Match Rule Lookup</strong></a> `has_rule` uses `self.rules.contains(rule)`, which is an exact match. If stored rules can be globs or prefixes (the `glob` helper above suggests so), a pattern like `claude:*` will not count as `claude:unsandboxed`. Confirm the intent. Also confirm `rules` is a set of `String` so `contains(&str)` compiles and behaves as expected. The "yolo never unsandboxes" guarantee depends entirely on callers using `has_rule` instead of the general permission check, so add a test that pins it. </summary> ```rust /// A stored rule (`.hx/allow.json` or "always" this session), ignoring yolo and edit grants. pub fn has_rule(&self, rule: &str) -> bool { self.rules.contains(rule) } ``` </details> <details><summary><a href='https://git.jokresner.de/johannes/hx/src/branch/refs/pull/194/head/crates/hx-core/src/sandbox.rs#L608-L610'><strong>Brittle Test</strong></a> The assertion hardcodes the exact order of `file-read-metadata` literals in one long string. It passes only if the path list is deterministically sorted and deduplicated (for example a `BTreeSet`). If it is built from a `HashSet` or insertion order, the test will be flaky. Also, the sandbox logic that reads git-config includes and stats `$HOME` and ancestor dirs is not in this diff, so verify it separately. </summary> ```rust assert!(p.contains( "(allow file-read-metadata (literal \"/home/u\") (literal \"/home/u/.cargo\") (literal \"/home/u/.cargo/registry\") (literal \"/home/u/proj\") (literal \"/home/u/w\") (literal \"/home/u/w/x\"))" )); ``` </details> </td></tr> </table>
Sign in to join this conversation.
No Reviewers
2 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: johannes/hx#194