Skip to content

feat(agent-isolation): hint when gh ran inside the sandbox and catalogue the TLS -26276 shape - #1289

Merged
potiuk merged 1 commit into
mainfrom
fix/sandbox-hint-gh-tls
Sep 19, 2026
Merged

potiuk merged 1 commit into
mainfrom
fix/sandbox-hint-gh-tls

Conversation

@potiuk

@potiuk potiuk commented Sep 19, 2026

Copy link
Copy Markdown
Member

Summary

  • A gh call that does not get excluded from the sandbox fails on macOS with x509: OSStatus -26276 (or HTTP 401): Go verifies TLS through Security.framework and the Seatbelt profile blocks the trustd / keychain mach services. This cannot be fixed in-sandbox (no fallback roots in the Homebrew gh, SSL_CERT_FILE ignored on darwin, no mach-service setting in Claude Code), so the gh * exclusion is the only remedy — and it applies only when every part of the Bash invocation is cd … or gh …. A pipe, $(…), a loop, or any file redirection (even > /dev/null) puts gh back in the sandbox. The redirection case is a Claude Code regression, reported as anthropics/claude-code#95532.
  • This PR makes that failure self-explaining at the moment it happens: a new catalog entry in docs/setup/sandbox-troubleshooting.md (measured shape table, root cause, the gh tofile alias workaround), a matching [sandbox-hint] signature in sandbox-error-hint.sh, a sixth doctor probe with an eval fixture, an eleventh verify check, and a new spec tools/spec-loop/specs/sandbox-diagnostics.md that describes the catalog / hook / doctor / verify surface as one contract.
  • Drive-by: the hint hook had no tests (14 added, covering all five signatures and the fail-open paths); the hint-signature table in secure-agent-setup.md was missing the /tmp row.

Type of change

  • Skill change (.claude/skills/<name>/) — eval fixtures updated below
  • Tool / bridge contract (tools/<system>/*.md)
  • Python package (tools/*/ with pyproject.toml)
  • Groovy reference impl
  • Cross-cutting (RFC, AGENTS.md, sandbox, privacy-LLM)
  • Documentation (docs/, README.md, CONTRIBUTING.md)
  • Project template (projects/_template/)
  • CI / dev loop (prek, workflows, validators)
  • Other:

Test plan

  • prek run --files <all changed files> passes every hook (rebased on fix(agent-isolation): show the touch overlay on macOS and for ssh-signed commits #1288, which fixed the pre-existing test_gpg_touch_overlay failure that blocked the earlier commit)
  • uv run --project tools/agent-isolation --group dev python -m pytest tools/agent-isolation/tests/test_sandbox_error_hint.py — 14 passed (written red first: the four gh cases failed before the hook change)
  • Invocation-shape table measured on Claude Code 2.1.278 / macOS 26, one Bash tool call per row, sandbox on
  • gh tofile alias verified from a sandboxed call: writes to the scratch tree, refuses a path outside $PWD / the scratch tree with exit 2
  • Skill evals: print-mode extraction confirmed for setup-isolated-setup-doctor (interpret-probes, after-report) and setup-isolated-setup-verify (step-1-classify) — the renamed sections extract and include the new probe / check
  • For skill behaviour changes: interpret-probes gains a gh_sandbox_status field (schema extended the same way fix(agent-isolation): show the touch overlay on macOS and for ssh-signed commits #1288 added signing_key_status), the eight existing fixtures carry "skip" for it, and case-9-gh-sandbox-fail covers the ✗ shape
  • Spec: spec-validate and check-doc-sync pass; the spec's own validation block cross-checks every hook anchor against the catalog headings
  • Token table regenerated (skill-token-count --write)

RFC-AI-0004 compliance

  • HITL — the new probe and check are read-only; the gh tofile alias is documented as an operator-installed convenience and refuses paths outside the working directory / scratch tree
  • Sandbox — no new host access; the change documents an existing exclusion and when it does not apply
  • Vendor neutrality — no project-specific values introduced
  • Conversational + correctable — n/a
  • Write-access discipline — n/a
  • Privacy LLM — n/a

Linked issues

Refs anthropics/claude-code#95532 (the upstream redirection regression), anthropics/claude-code#85857 (trustd mach-lookup root cause). Follows #1288 (Probe 5 / check 10 there; this PR adds Probe 6 / check 11).

Notes for reviewers (optional)

  • Spec-sync pre-check: no spec under tools/spec-loop/specs/ named the hint hook, the doctor probes, or the verify checks, so this PR adds sandbox-diagnostics.md for that surface (catalog as source of truth; hook, doctor and verify as discoverability layers; the gh exclusion shape rule as contract), cross-links it from agent-isolation-sandbox.md, lists it in both spec indexes, and bumps .last-sync to the base main tip.
  • The invocation-shape rule is measured behaviour on 2.1.278 and will change when #95532 is fixed; the catalog entry, the probe text and the verify check name the issue so they can be edited together on that day.

🤖 Generated with Claude Code

…gue the TLS -26276 shape

A `gh` call that is not excluded from the sandbox fails on macOS with
`tls: failed to verify certificate: x509: OSStatus -26276` (or an
`HTTP 401`), because Go verifies TLS through Security.framework and the
Seatbelt profile blocks the trustd / keychain mach services. Nothing on
the Go side can route around that, so the `gh *` exclusion in
`sandbox.excludedCommands` is the only remedy — and it applies only
when every part of the Bash invocation is `cd …` or `gh …`. A pipe, a
`$(…)` substitution, a loop, or any file redirection (even `> /dev/null`)
puts `gh` back in the sandbox. The redirection case is a Claude Code
regression reported as anthropics/claude-code#95532.

- sandbox-troubleshooting.md: new catalog entry with the measured
  invocation-shape table, the reason it cannot be fixed in-sandbox,
  and the `gh tofile` alias that moves a redirection inside `gh`.
- sandbox-error-hint.sh: recognise the two signatures and point at the
  entry; first test file for the hook (14 cases).
- isolated-setup-doctor: Probe 6 runs `gh` through `sh -c` so the
  exclusion cannot apply, then checks the exclusion is configured;
  the interpret-probes eval gains a `gh_sandbox_status` field and a
  case-9 fixture for the ✗ shape.
- isolated-setup-verify: check 11 requires `"gh *"` in
  `excludedCommands`; the canonical prompt in secure-agent-setup.md
  gains the same item.
- secure-agent-setup.md: hint-signature table gains the missing /tmp
  row and the new gh row; the annotated settings comment explains the
  shape rule.
- spec: new tools/spec-loop/specs/sandbox-diagnostics.md covering the
  catalog, the hint hook, the doctor probes and the verify checks as one
  contract (catalog is the source of truth; the other three are
  discoverability layers); cross-linked from agent-isolation-sandbox.md.

Generated-by: Claude Opus 5
@potiuk

potiuk commented Sep 19, 2026

Copy link
Copy Markdown
Member Author

Hopefully one of the last to avoid unnecessary prompts and bypassing sandbox.

@potiuk
potiuk merged commit b7b27ca into main Sep 19, 2026
10 checks passed
@potiuk
potiuk deleted the fix/sandbox-hint-gh-tls branch September 19, 2026 11:24
@potiuk
potiuk restored the fix/sandbox-hint-gh-tls branch September 19, 2026 11:27
@potiuk potiuk added substrate:framework-dev Tool substrate: build / validate / eval the framework itself substrate:sandbox Tool substrate: agent isolation, egress control, settings audit labels Sep 25, 2026
@potiuk potiuk added capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) capability:reassess Re-run historical issues against current code family:docs Docs, MISSION.md, READMEs family:setup setup-* skills family:tools tools/* labels Nov 1, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

capability:platform Framework / agent substrate skills (install, verify, doctor, override, status, setup bootstrap) capability:reassess Re-run historical issues against current code family:docs Docs, MISSION.md, READMEs family:setup setup-* skills family:tools tools/* substrate:framework-dev Tool substrate: build / validate / eval the framework itself substrate:sandbox Tool substrate: agent isolation, egress control, settings audit

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant