Skip to content

docs(plans): a permission model that decides on what a command does - #4050

Closed
kovtcharov wants to merge 2 commits into
amd:mainfrom
kovtcharov:claude/permission-model-design
Closed

kovtcharov wants to merge 2 commits into
amd:mainfrom
kovtcharov:claude/permission-model-design

Conversation

@kovtcharov

Copy link
Copy Markdown
Contributor

Shell permissions blocked legitimate work nine times in one benchmark campaign. Each fix (#4019, #4020, #4037, #4041, #4042, #4044, …) let through one more spelling of a command that had always been safe, so another one was always waiting. In the worst case the agent couldn't copy a project to a scratch folder. It ran the tests on the unpatched code instead and reported "still green". This design replaces text matching with facts. GAIA parses each command into what it does, decides on that against a mode the user picked and rules they wrote, then runs exactly what it parsed and reports what ran. After this, a new command pattern needs at most a config rule or a mode change, never a code change.

Design only. No code until it's signed off. Section 6 lists every place the design lets something run that doesn't today, and section 9 lists six decisions for the owner.

Test plan

  • python util/check_doc_links.py --internal-only passes
  • The page renders under Roadmap → Agent UI, next to Security Model
  • Owner review of §6 (where it widens) and §9 (decisions)

Shell permissions blocked legitimate work nine times in one benchmark
campaign, and every fix admitted one more spelling of a command that was
always safe. This design replaces text matching with facts: parse the
command into the programs it runs, the files it reads, writes and
deletes, the code it runs and the network it names; decide on those
against a mode and user-written rules; run exactly what was parsed and
report what ran and changed in the typed tool outcome.

It covers the reach x approval settings and the named presets, the rule
format, the decision order, what stays refused, network and the
credential floor, a walk-through of the nine cases, the corpus replay
test, every place the design widens what runs, and the staged PRs.
Design only; no code until the owner signs off.
@github-actions github-actions Bot added the documentation Documentation changes label Sep 21, 2026
amd#4071 showed the gap the design has to answer: write_file refused a path
outside the allowed folders and the model wrote the same file from a
run_python snippet, so whether a refusal holds is currently the model's
choice. The new section 3.11 says which writes the facts model decides by
construction (file tools, shell redirects, command operands), and what it
takes to hold the line for code: the prompt says what a snippet can reach,
an audit hook applies the roots to GAIA's own Python execution, and the
report names writes nobody predicted. It also says what the hook is not,
which is a sandbox.
@kovtcharov-amd

Copy link
Copy Markdown
Collaborator

Overturning the "large, so defer" read on this one: +748 lines of prose in two files is not a large PR, it is one plan document plus its nav entry. There is zero code risk here and the docs CI is green. Size is not what is holding it.

What is holding it is that you marked it draft and said so yourself: design only, no code until it's signed off, with §6 listing four places the model deliberately lets something run that today prompts or refuses, and §9 listing six decisions for the owner. Those are security-boundary calls — whether reads run unprompted in ask, whether the credential floor survives full access, whether /full-access confirm stops working mid-session, and which of the open shell PRs get closed. I am not going to decide any of them for you, and merging the page would publish it to amd-gaia.ai looking settled.

The diagnosis is worth saying out loud regardless of what you decide: nine blocks in one campaign, each fix admitting one more spelling of a safe command, is a pattern argument that text matching cannot win. Deciding on parsed facts is the right shape.

One collision to be aware of before this lands:

🔍 Technical details

Marking ready for review is the unblock, once §9 is answered. Nothing else is in the way.

@kovtcharov
kovtcharov marked this pull request as ready for review September 26, 2026 22:57
@github-actions

Copy link
Copy Markdown
Contributor

Verdict: Approve with suggestions

This adds a design doc proposing that GAIA parse each shell command into what it actually does (reads, writes, runs code, uses the network), decide on those facts against a user-chosen mode and user rules, and then run exactly what it parsed. It's a design only, with no code. The code it cites exists as described, the page is wired into navigation, and internal links pass.

One point to fix before sign-off: the proposed credential floor leaves out the list that stops the agent reading private keys and certificates by file extension (.pem, .key, …). Today's file-read guard already blocks those. Because the plan also lets reads run without a prompt, cat server.key would go through unasked. §6 is meant to list every widening, and it doesn't list this one. Add that list to the floor.

Real-world evidence

N/A: docs-only change (a design plan plus one docs.json entry), with no runnable surface. I ran python util/check_doc_links.py --internal-only and it passed. The rest of the verdict rests on static review.

🔍 Technical details

🟡 Important

🟡 The credential floor omits SENSITIVE_EXTENSIONS, so it's weaker than today's read guard (docs/plans/permission-model.mdx:505)
§3.10 builds the floor from SECRET_DIRECTORIES, SENSITIVE_FILE_NAMES and BLOCKED_DIRECTORIES. But the existing read check in src/gaia/security.py:675 also refuses SENSITIVE_EXTENSIONS (.pem, .key, .crt, …). Combined with §6 item 1 (reads run without a prompt in ask, with read roots defaulting to home), cat ~/proj/server.key would run unasked. §6 item 1 claims this is "the same reach read_file … already [has]", which it isn't.

- `SECRET_DIRECTORIES`
- `SENSITIVE_FILE_NAMES`
- `SENSITIVE_EXTENSIONS`
- `BLOCKED_DIRECTORIES`

(and "three lists" → "four lists" on line 505)

🟢 Minor

🟢 §3.5 doesn't say an allow rule can't cover opaque syntax (line 356). Step 6 allows when "every fact is covered by … an allow rule", and opaque is a fact, but §3.8 says no rule can allow opaque. Add "an opaque fact is never covered by a rule" to step 6 so the implementation doesn't have to reconcile two sections.

🟢 tool(<name>) scope contradicts itself (lines 307 vs 551). §3.4 says tool(...) keeps "its paths still inside the read roots", but §3.11 says tool(run_python) "allows what that code does, paths included". State which applies to code-running tools.

🟢 set isn't a program (line 512). set with no arguments is a shell builtin. Under an argv-only executor it would resolve as an unknown program (code), not an environment dump. Either drop it or say how the parser recognises it.

🟢 §6 item 1's fourth guard is about writes, not reads (line 657). ".git/ and PATH folders are never write roots" doesn't limit what can be read. Move it or reword the lead-in ("keep it from widening what can run").

Strengths

  • §6 lists what the design widens and §9 lists the owner's decisions, so a reviewer knows exactly what they're signing off on.
  • §5 has an adversarial set as well as the good-faith corpus, plus a parser-vs-bash argv differential test. The suite can't pass by allowing everything or by refusing everything.
  • It's honest about what can't be enforced: network rules are labelled advisory, the audit hook is explicitly "not a sandbox", and there's no auto mode without a sandbox.

@itomek

itomek commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Keeping this open — the problem it describes is still live on main, and bigger than when you wrote it.

I re-checked today: with full access on, rm, tar and docker are refused outright, while plain ask-mode would merely prompt for that same rm. Full access being stricter than asking is the exact inversion §1 argues against, and nothing has landed that fixes it.

The nine-case table got more load-bearing, not less. Seven of the nine still reproduce on main, and the per-spelling PRs that would have fixed four of them were closed in favour of this design — so those bugs now have no plan and no PR except this page. That's the reason to refresh it rather than close it.

Two things need a pass first:

The header and §9 item 4 are stale. Both name PRs to merge or close before this one; that queue resolved while this sat — one merged, the rest closed. Rewrite them to today's state, and drop rows 7 and 8 from the table, which are genuinely fixed.

The credential floor in §3.10 is one list short. It names three, but the read guard also refuses a category of sensitive files by extension. Since §6 lets reads run unprompted, omitting it widens something §6 doesn't declare — and declaring every widening is §6's whole job.

Decisions 1, 2, 3, 5 and 6 are mine; I'll come back with answers. §5 is the best part of this — an adversarial set plus a parser-vs-shell differential means the suite can't pass by allowing everything.

🔍 Technical details

State. claude/permission-model-design on your fork, 2 commits, 748 added lines across 2 files, 265 behind origin/main (f4924e35a). mergeable=MERGEABLE; git merge-tree --write-tree origin/main is clean (tree 0319b1d6f) and the merged docs.json parses with exactly one plans/permission-model entry. Docs and integration lanes pass; the Linux unit lane is a cancelled 30m07s timeout, and the two smoke lanes fail inside unit tests a docs-only diff cannot reach.

Why the premise still holds. #3394 merged on 2026-09-25 and is what created the developer set. #3995 was stacked on it and on #3808, and its description promised to "replace #3394's developer set with the normal checks" — but #3808 was closed, and what landed in 58e9bfa3f is the heredoc commit alone (3 files, +167/-7; its shell_tools.py diff never touches _validate_bypass_command). The restriction landed and its replacement didn't. Full access still routes through _validate_bypass_command (src/gaia/agents/tools/shell_tools.py:2778, called at :2408).

Measured against origin/main, reading the tier field: rm, tar, docker, ffmpeg, rsync, chmod → refuse under full access, confirm in default mode.

SHELL_KEYWORDS (:41), ALLOWED_COMMANDS (:94), DEVELOPER_COMMANDS (:230) and DANGEROUS_SHELL_OPERATORS (:445) are all still present, and git ls-tree -r origin/main -- src/gaia/permissions/ is empty — no stage of §8 exists.

Nine-case table, measured today. Rows 7 (#3909) and 8 (#3995) fixed. Row 2 still refuse in default mode; rows 3 and 4 still caught by DANGEROUS_SHELL_OPERATORS; rows 5 and 6 still refuse in both modes. #4019, #4020, #4037, #4041, #4042 and #4044 are all closed, so none of those six has a fix in flight.

Staleness. Line 14 "Builds on #3808" — closed; "#4043" — merged. Line 16 "Would replace #4037, #4041, #4042, #4044" — all closed. §9 item 4's triage list resolved. Line 665 describes #3995 as running "anything inside the allowed folders under full access" — narrower than that in practice.

§3.10 (line 506) lists SECRET_DIRECTORIES, SENSITIVE_FILE_NAMES, BLOCKED_DIRECTORIES. src/gaia/security.py:123 also defines SENSITIVE_EXTENSIONS, enforced at :821 and :930.

Still open: #4071 (§3.11's target). The #3812 collision stands — still open at 214 files, and docs/plans/ is live on main (86 entries, 32 nav lines).

Separately: main ships a PR titled "full access runs anything inside the workspace" whose command-set half never landed. That gap deserves its own issue regardless of this one.

@itomek

itomek commented Sep 29, 2026

Copy link
Copy Markdown
Collaborator

Closing this in favour of #4466, which carries the six open questions as a tracked decision rather than a parked branch.

The analysis is the part I want to keep — deciding on what a command does (reads, writes, runs code, reaches the network) instead of what characters it contains is the right frame, and §3.10's recommendation that the credential floor survives full access is the one call in here that already comes with a reason attached. The 1,378-session data behind the effect table is what makes the argument, not the prose.

What stopped it is that a page under docs/plans/ publishes to amd-gaia.ai, and this one ends on six questions rather than answers — so merging it would ship unsettled security boundaries as though they were settled. That's a decision problem, not a rework problem, which is why it's an issue now and not a review round.

One thing to fix whenever it comes back: §1 says "Under full access, rm ran", and that isn't true of current main — full access swaps the read-only allowlist for a developer set that deliberately excludes rm. Noted in #4466 with the specifics.

Nothing is lost. claude/permission-model-design stays on your fork exactly as it is, and this reopens in one click if you'd rather answer the six inline.

@itomek itomek closed this Sep 29, 2026
kovtcharov added a commit to kovtcharov/gaia that referenced this pull request Oct 5, 2026
… as timeouts (amd#4461)

Closes amd#4446

Running a project's tests used to raise a **DESTRUCTIVE** prompt that
printed the command twice, wrapped a temp path over three lines, offered
only "run once", and — if nobody answered in 10 minutes — told the agent
the user had refused. Now the prompt says what the command does (`RUNS
CODE`), shows it once relative to the project, offers `y` once · `a`
always · `n` deny on shell and Python prompts too, and an expired prompt
is reported as a timeout. Shift+Tab cycles ask → accept edits → full
access, with the mode on the status bar; full access still turns on only
after it has been confirmed once this session (or at launch), and
commands GAIA refuses stay refused in every mode but full access.

- **`a` covers a command family, not a spelling.** Approving `python -m
pytest` also covers `cd proj && pytest 2>&1 | tail`, so one answer ends
the stream of prompts in a bugfix turn. Deletes, lines GAIA can't read,
and file redirects never get it; interpreter grants say they cover any
script.
- **Accept edits** lets file edits inside the starting folder run
unasked — never `.git/`, a `PATH` folder, or (on Windows) a file that
would shadow a real program.
- **Docs:** terminal-hub guide, the CLI reference's full-access section
plus the TUI flags amd#3140 flagged as undocumented, the stdio contract,
and the hub agent's SPEC/SKILL/CHANGELOG.

Aligned with amd#4050 on the presets and on full access never being one
stray keypress away. Two deliberate differences, since amd#4050 isn't
signed off: `a` is offered for inline Python (the issue asks for it on
every prompt type; the label says "any inline Python"), and Shift+Tab
reaches full access once it is unlocked rather than never.

## Test plan
- [ ] `cd tui && go test ./...` — includes frame tests for the new
prompt, the Shift+Tab cycle, timeout delivery, and the status bar never
clipping `Ctrl+C quit`
- [ ] `python -m pytest tests/unit/agents/test_tool_grants.py
tests/unit/agents/test_call_risk.py
tests/unit/chat/ui/test_confirmation_summary.py
tests/unit/test_stdio_permission_control.py
hub/agents/gaia/python/tests/test_stdio_wire_contract.py`
- [ ] `python util/tui_driver.py gate` → `13/13 as expected`
- [ ] In `gaia tui`, ask the flagship to run a project's tests: the
prompt reads `RUNS CODE`, shows the command once, and offers `a always:
pytest`; after `a`, a differently spelled test run doesn't prompt
- [ ] Shift+Tab: status bar shows `⏵⏵ accept edits`; a file edit in the
project runs unasked while a shell command still asks; the next
Shift+Tab explains full access and lands on ask
- [ ] CI re-runs the `gaia_resilience` and `gaia_files` eval categories:
the agent now sees different wording after an approval prompt expires on
a write

<details>
<summary>🔍 Technical details</summary>

Live drive (flagship agent over stdio, Fireworks `deepseek-v4p1-flash`),
same request on a clean `main` build and on this branch.

Before:
```
  DESTRUCTIVE  Confirm: run_shell_command

 Run 'run_shell_command' with command="python -m pytest -q tests/",
 working_directory="C:\Users\Kalin\AppData\Local\Temp\claude\C--Users-Kalin-Work-gaia--claude-worktrees-youthful-
 pike-76967f\0b35cb91-efcd-4a06-814b-4b5da6860f61\scratchpad\proj"?

 A shell command can read, change, or delete anything you can — check the command above before approving.

 y run once · n/esc deny · auto-denies in 10 minutes if you do nothing
```

After (keys are filled keycaps; no red text on the prompt — only the
`DESTRUCTIVE` badge stays red):
```
  RUNS CODE  Run this command?

 python -m pytest -q tests/

 mode: ask · shift+tab to change · expires in 10 minutes

  y  once ·  a  always: pytest (this session) ·  n/esc  deny
─────────────────────────────────────────────────────────────────────────
  ● agent gaia waiting for your answer        ↑↓/wheel scroll · answer above · Ctrl+C quit
```

After `a`, `cd <proj> && pytest -q tests/ 2>&1 | tail -5` ran with no
prompt (trace: one `needs_confirmation` across both turns). In accept
edits, `edit_file` + `write_file` ran unasked and the test run still
prompted with `mode: accept edits`.

Wire changes (all additive): `needs_confirmation.risk`; `tool_decision`
accepts `timeout` (stdio and `POST …/tool_decision`); stdio control verb
`accept_edits` and `--accept-edits` for respawn. An older agent treats
`timeout` as `deny` and ignores `accept_edits`.

Grant safety: a line is granted only when shlex's POSIX (escape on) and
Windows (escape off) readings put the operators in the same places, so
`pytest \" ; curl x ; \"` gets no grant. Accept edits resolves
`file_path`/`project_dir` exactly as `file_io_tools._resolve_target`
(parity test). `Agent._policy_refusal` still runs before any grant or
mode check.

The eval wasn't run: no system prompt, tool schema, or docstring
changed. The only model-facing text is the denial reason on a timeout.
</details>

---------

Co-authored-by: Kalin Ovtcharov <[email protected]>
Co-authored-by: Kalin Ovtcharov <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

documentation Documentation changes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants