Skip to content
pi-c Artifact [f8900aad9f]
Login

Artifact [f8900aad9f]

Artifact f8900aad9f602e52d1ea6102f8344300eaed4cad96e092823daf4e4f36a2c721:


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:

  1. An ask under the key perm:EFFECT (perm:n:ROW for a call a tool made, pic_nested_effect) already exists: wait on it. A replay never decides again.
  2. The tool is not registered or not in play: run it (it answers "Tool X not found").
  3. read-only and the tool is not read_only (pic_tool_def.read_only): skip it with a refusal for the model. A hook's allow does not lift this.
  4. A hook asked: ask. A hook allowed: run.
  5. By mode: ask-all asks for a tool that is not read_only, ask-edits for write and edit, allow never; a tool in the conversation's allowed runs without asking.

read_only is set for read, grep, find, ls and tool_search. An MCP tool is never read-only by its server's readOnlyHint; the setting readOnlyTools (pic_store.read_only_tools, resolved in main.c: names, or prefixes ending in *) makes any tool count as read-only. codemode is not read-only: it asks itself, and each call it makes goes through the gate again.

The gate reads the call's input from the journal (pic_effect.input, or pic_nested_effect's), so a PreToolUse rewrite (updatedInput) is what the person is asked about and what runs. After an Allow, the mode is read again: a conversation made read-only while the call waited refuses it. A call a tool made whose wait Ctrl-C cut short is skipped with a result, since its caller reads one.

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.

A fork (fork_session in loop.c: /fork, /tree, a rewind into a branch) copies the row (pic_perm_copy) in the fork's transaction.

pic_permission_key(key, session_id, answer, created_ms), made with the table, keeps a phone's set_permission_mode under its rc:DEVICE:KEY: the first command with the key sets the mode and keeps its answer in one transaction, and a resend gets that answer and changes nothing, even after the mode was changed elsewhere.

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.