Artifact e6dde41da522a4027f87db0f5892cbd413c1d58f8a56cb21ab0edd403f75e31d:
- File docs/dev/permissions.md — part of check-in [895c2ed663] at 2026-11-27 14:08:14 on branch perm-modes — Permission modes: terminal, phone, docs (user: dmestas, size: 4558) [annotate] [blame] [check-ins using]
Permissions
A conversation's permission mode says which tool calls wait for a person's yes, and the gate that makes them wait. The user's view is permissions; the decision is the design note; the question itself is an ask.
Tier: core (src/perm.c). Clock: durability. Record: pic_permission, and a pic_ask per call
that asks. Default: allow, which asks nothing.
The table
pic_permission, a table of its own made IF NOT EXISTS by every full open and by
pic_perm_set, so no schema version (durability). Readers take a
missing table or row as allow.
| Column | Meaning |
|---|---|
session_id |
the conversation, primary key |
mode |
allow, ask-edits, ask-all or read-only |
allowed |
a JSON array of tool names answered "Allow for this conversation" |
updated_ms |
when the mode or the allowances last changed |
A conversation takes its mode in the transaction that admits a request into it
(pic_perm_admit): --permission-mode (pic_store.permission_set) is written over whatever it
had; otherwise the setting permissionMode (permission_default, resolved in main.c, which
refuses a bad value at startup) is written only when the conversation has no request yet and the
mode is not allow. A conversation that has run with no row stays allow whatever the setting
says later.
The gate
tool_gate in loop.c runs a call's PreToolUse hooks as before and reads their decision from
pic_hook_run: a deny skips the call. Otherwise it hands pic_perm_gate the call, whether a hook
asked (with the asking hooks' permissionDecisionReason, now kept in the run's reason) and
whether one allowed with none asking. The gate decides, in order:
- An ask under the key
perm:EFFECT(perm:n:ROWfor a call a tool made,pic_nested_effect) already exists: wait on it. A replay never decides again. - The tool is not registered or not in play: run it (it answers "Tool X not found").
read-onlyand the tool is notread_only(pic_tool_def.read_only): skip it with a refusal for the model. A hook's allow does not lift this.- A hook asked: ask. A hook allowed: run.
- By mode:
ask-allasks for a tool that is notread_only,ask-editsforwriteandedit,allownever; a tool in the conversation'sallowedruns without asking.
read_only is set for read, grep, find, ls and tool_search, and for an MCP tool whose server marks
it readOnlyHint. codemode is not read-only: it asks itself, and each call it makes goes through
the gate again.
The ask is a select (a confirm carries only true or false) with the options Allow,
Allow for this conversation and Deny, no default; the title "Allow TOOL: KEY?" with the
command, path or first text argument, cut at its first line; the body the command, the path and up
to 20 lines of a write's content, or the path and each edit's old and new lines (10 each), or the
input's JSON, after "A hook asks: REASON" when a hook asked. It is opened with the call's
submission and expires as every ask does (7 days; PIC_TEST_PERM_EXPIRY_MS in dev builds).
The answer: "Allow" runs; "Allow for this conversation" adds the tool to allowed (its own
transaction, idempotent, so a replay after a crash adds it once) and runs; "Deny" or a dismissal
skips with "The person denied this TOOL call"; an expired ask skips with "Nobody answered…" and a
line on stderr; a withdrawn one skips. Ctrl-C while waiting withdraws the ask and cancels the
request. The call stays an intent effect the whole time: nothing outside the journal is touched
before the answer.
Clients
| Client | Shows | Changes |
|---|---|---|
| terminal | the footer's mode (read with the asks, every 2 s); the call's ask as OV_ASK |
/permissions MODE; before a conversation exists, the next request's --permission-mode |
| RPC | get_permission_mode |
set_permission_mode |
pic remote |
permissionMode in get_state, and in a sessions row when not allow; permissions in features |
set_permission_mode, a job on the conversation's lane |
| hooks | permission_mode in Claude Code's names (bypassPermissions, default, plan) |
Fault points
perm_ask, reached twice per call that asks: arrival 1 once the ask is open (or found), arrival 2
once its answer is read, before it acts. test/pic/permissions.sh crashes at both and kills a
waiting run: the call has not run, and the next owner runs it once on the answer.