Skip to content

ui: decide tool calls by permission rules, with command patterns and folders - #101

Draft
allozaur wants to merge 1 commit into
allozaur/feat/harness-seamsfrom
allozaur/feat/permission-rules
Draft

allozaur wants to merge 1 commit into
allozaur/feat/harness-seamsfrom
allozaur/feat/permission-rules

Conversation

@allozaur

@allozaur allozaur commented Nov 20, 2026 •

Copy link
Copy Markdown
Owner

Overview

Tool permissions become rules: allow a shell command by its pattern, for this chat, in this folder or everywhere, and pick a permission mode for what no rule decides. Commands that could destroy the system are refused in every mode.

Additional information

Layer 3 of the planned stack, on #100 (harness hooks). Like #100, it goes between #55 and #61; inserting both into the stack and restacking #61 and above is still to do. The permission card was checked in Storybook; the settings list and the flow in the running app were not checked by hand.

What changed
  • Rules. { tool, pattern?, effect: allow | ask | deny, cwd? }, kept in localStorage. Deny beats ask beats allow, whatever their order. A rule without a pattern covers every call of its tool; a pattern (npm run test *) covers shell commands; a folder limits a rule to calls made there and in folders inside it. The old "always allowed" tools turn into tool-wide allow rules on first load.
  • Shell commands. exec_shell_command calls are split on &&, ||, ;, |, & and newlines (quotes respected, 2>&1 kept as a redirection), and harmless wrappers (timeout, time, nice, nohup, command) are stripped. A command runs without asking only when every part is allowed; a deny or ask rule fires on any part. Substitution, subshells, open quotes and over-long commands are never allowed by a pattern. A trailing * also matches the bare command, as in Claude Code.
  • Built in. A short read-only allowlist runs without a rule (ls, cat, grep, find without -exec/-delete, git status/log/diff/show, …, without output redirection). A hard floor refuses rm -r of / or ~, fork bombs, mkfs and raw disk writes in every mode, even with an allow-all rule.
  • Permission mode (Settings › Tools): Ask (default); Accept edits (also write_file / edit_file inside the working folder); Read-only (refuses tools that can write, per /tools permissions.write, except read-only shell commands); Auto-approve (everything no rule denies).
  • The prompt. Shows the command and the proposed pattern for each part that needs approval, editable. Choices: Allow once, Allow for this chat, Always allow in <folder>, Always allow everywhere, Always allow all tools from the server (non-shell tools), Deny. A denial by a rule tells the model which rule.
  • Settings › Tools lists the kept rules with their folder, and removes them. A tool that a rule denies outright is no longer offered to the model.
  • It all runs in authorize from ui: give Llama Harness hooks to authorize tool calls and prepare each turn #100: the rules and the mode decide first, and the prompt only shows for what they leave open.
Testing
  • Storybook, ChatMessageActionCard › States: the shell-command card shows the command, the two editable patterns and the folder choice in its menu; the action cards' icon now sits on the first line.
  • ui/apps/chat: npm run check, npm run lint and the 887 unit tests pass, including the new permission-rules.test.ts (shell splitting, patterns, precedence, folders, modes, the floor) and permissions-store.test.ts (migration, rules for one chat, remembering edited patterns in a folder, a stopped run), and agentic-flow.test.ts with its denied-permission case.

Requirements

allozaur added a commit that referenced this pull request Nov 20, 2026
@allozaur
allozaur added this pull request to stack #110 November 21, 2026 13:48
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch from 842dfe1 to ea34ae3 Compare November 21, 2026 14:38
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch 2 times, most recently from 7426943 to e6cb5a4 Compare November 24, 2026 06:56
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch from e6cb5a4 to 4780626 Compare November 24, 2026 08:28
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch from 4780626 to 41d998e Compare November 24, 2026 09:40
@allozaur
allozaur removed this pull request from stack #110 November 24, 2026 09:41
@allozaur
allozaur added this pull request to stack #114 November 24, 2026 09:41
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch from 41d998e to da1c665 Compare November 24, 2026 12:18
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch from da1c665 to 1fd5997 Compare November 24, 2026 13:57
@allozaur
allozaur removed this pull request from stack #114 November 24, 2026 13:58
@allozaur
allozaur added this pull request to stack #126 November 24, 2026 13:58
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch from 1fd5997 to eb010f9 Compare November 24, 2026 14:10
@allozaur
allozaur removed this pull request from stack #126 November 24, 2026 14:10
@allozaur
allozaur added this pull request to stack #127 November 24, 2026 14:10
@allozaur
allozaur removed this pull request from stack #127 November 24, 2026 14:45
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch from eb010f9 to 6461a83 Compare November 24, 2026 14:45
@allozaur
allozaur added this pull request to stack #129 November 24, 2026 14:46
…folders

Tool permissions become rules kept in localStorage: allow, ask or deny,
for a tool or a shell command pattern such as `npm run test *`,
everywhere or in one working folder and the folders inside it. Deny
beats ask beats allow. The tools allowed for good before turn into
tool-wide allow rules on first load.

exec_shell_command calls are split on && || ; | & and newlines, with
quotes respected and harmless wrappers (timeout, time, nice, nohup,
command) stripped. A command runs without asking only when every part
is allowed; a deny or ask rule fires on any part. Substitution,
subshells, open quotes and over-long commands are never allowed by a
pattern. A short read-only allowlist needs no rule, and a hard floor
(rm -r of / or ~, fork bombs, mkfs, raw disk writes) is refused in
every mode.

A permission mode in Settings > Tools decides what no rule does: ask,
accept edits inside the working folder, read-only (tools llama-server
marks as writing are refused, read-only shell commands still run), or
auto-approve. It all runs in the harness's authorize: the prompt only
shows for what the rules and the mode leave open.

The prompt shows the command and an editable pattern for each part that
needs approval, and can allow once, for this chat, always in the
folder, always everywhere, or every tool of the server. Settings lists
the kept rules and removes them; a tool a rule denies outright is no
longer offered to the model.

Assisted-by: Claude (Opus 5.5 Medium)
@allozaur
allozaur force-pushed the allozaur/feat/permission-rules branch from 6461a83 to 55a54ca Compare November 24, 2026 16:43

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant