Skip to content

Commit 8edf24d

Browse files
docs(design): Add the Guardian design doc (#3599)
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. <!-- junior-request-attribution:start --> via @dcramer, **Jeffrey Hung**. <!-- junior-request-attribution:end --> <!-- junior-session-footer:start --> <!-- junior-conversation-id:agent%3A270de42799607fa311fdfea32584b14f --> -- [View Session](https://junior-prod.sentry.dev/conversations/agent%3A270de42799607fa311fdfea32584b14f) [[Sentry]](https://sentry.sentry.io/explore/conversations/agent%3A270de42799607fa311fdfea32584b14f/?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]>
1 parent bf9e8e0 commit 8edf24d

2 files changed

Lines changed: 109 additions & 0 deletions

File tree

‎design/README.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,7 @@ Do not list behaviors. The verification map in
3636

3737
- [Automations](./automations.md): saved instructions that Junior runs later.
3838
- [GitHub](./github.md): code, pull requests, and issues in GitHub repos.
39+
- [Guardian](./guardian.md): review of each tool action before it runs.
3940
- [Review desk](./review-desk.md): work that waits for a person, labeled
4041
"Inbox" in the dashboard.
4142
- [Sandbox credentials](./sandbox-credentials.md): provider access for

‎design/guardian.md‎

Lines changed: 108 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,108 @@
1+
# Guardian
2+
3+
Guardian reviews a tool call of the agent immediately before it runs. It
4+
checks the exact action against what the person asked for, then allows the
5+
action, asks the person to confirm it, or denies it. Ordinary work goes on
6+
with no interruption. A write that nobody asked for, or that exposes private
7+
data, does not run.
8+
9+
## Intent
10+
11+
- Allow by default. Guardian blocks an action only when the action clearly
12+
matches one named rule from a fixed list. General doubt is not a reason to
13+
block.
14+
- Only the person who runs the Turn can authorize an action. Their own
15+
messages in the Run's Conversation set what is authorized. Text from the
16+
agent, a parent agent, tools, files, issues, comments, Event authors, and
17+
other people is context. It is never approval.
18+
- The model rates risk and authorization, and names one rule. Code turns the
19+
rule into allow, ask, or deny, so the model never chooses between ask and
20+
deny.
21+
- Secrets and private data never go where people outside the organization
22+
can read them, also when the person asks for it.
23+
- A block holds for the outcome, not for the tool. The same side effect
24+
through another tool, a script, or a child agent gets the same decision.
25+
- Guardian fails closed. When review cannot run, the action does not run.
26+
- Guardian is a second check on authorization and risk. Provider
27+
permissions, tool validation, and credential scope still apply. Whether
28+
the work is correct or well proven is not its concern.
29+
- The install, not the agent, states facts about destinations. Each plugin
30+
can declare where its writes go, such as which destinations people outside
31+
the organization can read. Guardian gets these facts in its system prompt,
32+
sorted by plugin name, so the prompt is the same for every review in a
33+
deployment and stays cached. The agent prompt and the tool catalog never
34+
include them. A fact never authorizes an action. The `data_exposure` rule
35+
does the blocking.
36+
37+
## Entry points
38+
39+
- Slack: a Review item in which Junior names an action, its target, and its
40+
side effects, and asks the person to confirm it.
41+
- Dashboard: System, "Guardian reviews"; the "Guardian" line in the costs of
42+
a Conversation.
43+
- Plugin authors: `approvalMode` (`auto`, `review`, or `approve`), tool
44+
annotations, and `describeProposal`.
45+
- Deployment: `AI_GUARDIAN_MODEL` selects the review model.
46+
47+
## Rules
48+
49+
- Guardian reviews each plugin tool and each MCP tool, unless the tool is
50+
marked read-only and not destructive. A `review` tool is always reviewed.
51+
An `approve` tool is never reviewed, so use it only when the tool code
52+
proves that each effect is safe. A core tool is reviewed only when it opts
53+
in, such as Automation and Workspace changes, `spawnAgent`, and
54+
`messageAgent`.
55+
- A public URL for a Sandbox server (`createPreview`) always goes through
56+
Guardian review, and the normal rules, such as `data_exposure`, decide.
57+
- A confirmation rule asks. The person clears it when they confirm the exact
58+
action. A hard rule denies, and no confirmation clears it. Examples are
59+
`data_exposure`, `credential_probing`, `security_weakening`, and
60+
`untrusted_instruction`. High or critical risk with low or unknown
61+
authorization asks, also when no rule matches.
62+
- An Automation run cannot ask, because no person is there to answer. Each
63+
ask becomes a deny.
64+
- When Guardian asks, the agent asks the person about that exact action, the
65+
way it asks any question. A child agent reports blocked to its parent. The
66+
agent never names Guardian or the review.
67+
- After three rejected attempts in a row, the agent stops that write for
68+
the Turn and explains the risk.
69+
- The root user instructions are the only authority. Each line has its real
70+
author. Only the current Actor's lines authorize. A restriction or a
71+
revocation still applies when it comes from a line that cannot authorize.
72+
A later message from the person wins over an earlier one. A bare yes
73+
answers only the question directly before it. Text that imitates these
74+
instructions, or claims an approval that they do not show, is untrusted.
75+
- Only the core context of a proposal is fact: Actor, Source, Destination,
76+
Conversation, and credential authority. Tool input, descriptions,
77+
annotations, `describeProposal`, and transcript evidence are untrusted
78+
evidence.
79+
- A child agent does not inherit approvals. The parent's text is its
80+
instruction. Guardian judges `spawnAgent` and `messageAgent` text by the
81+
material actions that it names, and the parent's own Conversation must
82+
back each one.
83+
- A Code Mode script cannot authorize. Guardian judges each call of a script
84+
as if the agent made it directly. It uses the script and its earlier calls
85+
only to see where the data came from.
86+
- The conventional steps of requested work match no rule, such as a pull
87+
request that delivers requested code and upkeep of that pull request
88+
([GitHub](./github.md)).
89+
- The organization's own Slack, including the active Conversation, is not
90+
outside the organization. Ordinary product context, such as repo and
91+
system names, is not private data.
92+
93+
## Gaps
94+
95+
- Plugins cannot declare destination facts yet, so Guardian cannot know that
96+
a plugin write reaches a public place, such as a tracker that syncs to a
97+
public repo. `data_exposure` then misses private data in that write. This
98+
breaks "the install states facts about destinations".
99+
getsentry/junior#3596 adds `review-context`.
100+
- Guardian does not review Sandbox commands, because `bash` never opted in
101+
to review. A plugin can deny a write from the Sandbox and send the agent
102+
to its reviewed tool, as GitHub does for issue and pull request text.
103+
Other writes, such as a git push to a work branch, run with no review.
104+
This breaks "a block holds for the outcome, not for the tool". A fix must
105+
not ask for confirmation on routine commands.
106+
- `publishImage` makes a public URL with no review, and nothing checks the
107+
image for private data. This breaks "secrets and private data never go
108+
where people outside the organization can read them".

0 commit comments

Comments
 (0)