005 · Approvals
Approvals and user questions (spec_005_approvals)
| Status | Implemented. Reverse-engineered from 53f8c53 (2026-09-24) and kept with the code since; its paths checked 2026-09-27 (//tools/specs). |
| Source | pkg/engine/tools/hooks.go, approval_store.go, ask_user.go; approver UI in apps/cli/internal/tui |
| Tests | pkg/engine/tools/approval_test.go, approvals_checkpoints_test.go |
| Depends on | spec_002_config, spec_003_observability (audit) |
| Used by | spec_006_filetools, spec_007_shell, spec_008_web, spec_009_mcp, spec_013_skills, spec_014_agents, spec_023_workers |
Sensitive tool actions (edits, deletions, commands, network, MCP tools, forged tools, skill installs) pass one gate, Hooks.Approve, which fails closed. Front ends supply the interactive approver; remembered and saved rules skip it; unattended runs (jobs) replace it with a permission check.
- APR-01
ApprovalRequest{Tool, Kind, Detail, Diff, Key, KeyLabel, Targets}. Kinds:run_command,write_file,delete_file,network,mcp_tool. - APR-02
Keynames what a remembered decision covers; empty means it can only be approved once.Targetsare what policies match (workspace-relative paths, the command, the URL host or search provider,server:tool); empty targets can’t be matched by permission policies. - APR-03 Decisions:
deny,once,session(same key until the process exits),always(same key, persisted).
| Action | Key | Label |
|---|---|---|
| File edit | write:<workspace> |
file edits in the workspace |
| File delete | delete:<workspace> |
file deletions in the workspace |
| Shell command | cmd:<workspace>\x00<exact command> |
this exact command in this workspace |
| Web fetch | web:<host> (per host) |
|
| Web search | per provider | |
| MCP tool | mcp:<server>:<tool> |
|
| Forged tool run | uc-run:<name>\x00<script sha256>\x00<args> |
this forged tool, as it is now, with these arguments |
| Tier-3 skill script | none (never rememberable) |
- APR-10 Unattended context (
tools.Unattended(ctx, decide)): onlydecideis consulted — auto-approval, session/saved rules and the interactive approver are bypassed and nothing is remembered. Allowed → auditapprovalunattended-permitted; refused → auditdenialunattended-refusedand error “isn’t among this unattended run’s permissions”. - APR-11 Otherwise, in order: permission mode
bypass→ allowed, auditmode-bypass;tools.auto_approve_commands(commands only) →auto-policy; a session rule for the key →session-rule; a saved rule →saved-rule; modeaccept-editsand a write or delete (paths were already resolved as writable) →mode-accept-edits; modedont-ask→ denied,mode-dont-ask; no approver → denied, auditno-approver, error suggesting a rule or a permission mode. - APR-11a 2026-11-05 (scan N26-engine-tools-1#4: refusals were logged as approvals). Every refusing decision is an audit
denial(and a denial in a workflow run’s receipt):deny,no-approver,error,mode-dont-ask,hook-denyandbackground-refused, as well asrule-deny,unattended-refusedandauto-deny. - APR-15 Permission rules (
[permissions] allow/ask/deny,kind(pattern)or a bare tool name;tools.PermissionRules, live): the gate evaluates them first by the request’s kind and targets — deny if any target matches a deny rule (in every mode, auditedrule-deny, also for unattended runs), else ask if any matches an ask rule (MustAsk: straight to the approver, skipping modes, allow rules and remembered approvals; refused indont-ask, without an approver, and in unattended runs), else allow if every target matches an allow rule (rule-allow; never for unattended runs, which keep exactly their permissions).shellrules are applied by the command policy on every sub-command (deny joins deny, allow joins auto-approve, ask setsMustAsk; an unverifiable command setsMustAskwhen ask rules exist).webdeny/ask are also applied beforeallow_domainsand fetch grants;mcpdeny/ask apply toauto_approveservers; bare tool names,skillandagentdeny rules refuse the call before it runs (enginebeforeTool).readrules are deny-only and become blocked paths at start. Rules can be added and removed during a session (readrules only by saving; they apply from the next start); saving edits[permissions]in place, in the global settings or the workspace’s own (api.Scope), whose rules add to the global ones; a saved rule applies as the file’s, not also the session’s. Rules are checked before they’re saved (config.ValidatePermissionRule, set by the parser), also in the settings-file editor.[permissions] read_only_defaults(default on; a workspace may set it either way) adds built-in rules (sourcebuilt-in): allowconfig.ReadOnlyCommands(ls,pwd,cat,head,tail,wc,stat,du,df,which,grep,rg,diff,git status,git log,git show,git diff,git blame,git rev-parse), and ask forconfig.ReadOnlyGuards(git … --output,git … --ext-diff,rg … --pre); a redirection to a file still asks (SH-11a). Sources as listed:global,workspace,built-in,flag,session. When the settings change, open workspaces replace their configured and built-in rules (PermissionRules.ReplaceConfigured,Workspace.ReloadPermissions).tools.CheckPermissionRulechecks a rule without adding it and says how it matches (prefix,glob,regex,path,name) and whether it applies to a sample (an allow rule to every command in it, ask or deny to any), noting a redirection. - APR-15b 2026-11-05 (scan N26-engine-tools-2#4: a patch’s
*** Delete Fileand a writes_workspace script’s removed files were approved as plain writes, sodeny delete(…)andask delete(…)never saw them). A write that deletes files names them in the request (ApprovalRequest.Deletes: apply_patch’s deleted files and moved-away sources, a script’s removed files), anddeleterules govern them as well aswriterules over all its targets: deny from either wins, then ask from either, and it’s allowed by rules only when both allow. - APR-15c 2026-11-05 (scan N26-engine-tools-2#5:
deny write(*.pem)matched only top-level files, anddeny write(~/proj/secrets/**)never matched, since targets are workspace-relative).read,writeanddeletepatterns take the blocked paths’ forms (spec_006 FS-10): a name without a slash (*.pem,secrets) at any depth; an absolute or~location matched against the target’s absolute path (the workspace’s path joined to it; also the location’s link-resolved spelling); a relative path with a slash from the workspace root. A relative pattern doesn’t cover the other allowed roots: name them absolutely. - APR-15a Rules follow their files, whoever edits them (the desktop app,
/permissions --save, an editor, another process): the engine looks at the global settings, the workspace’s own, the project’s files (.blitz/settings.toml,.blitz/settings.local.toml) and the approvals file every 2 s (settingswatch.go), and applies a change to the live rules (ReplaceConfigured,ReplaceProject,ApprovalStore.Reload). Every tool call reads them, so a turn already running obeys an added or removed rule from its next action; background tasks share them. A project’s loosening settings still wait for trust (spec_031_project_config); jobs keep their own permissions. Watching clients hear of it:WatchTaskssendssettings_changed, and the desktop app’s Run settings and Settings › Permissions reload. - APR-14a The
automode (PAR-PERM-20, -21): after deny rules, the automatic allows (allow rules, remembered approvals, auto-approved commands) andpermission_requesthooks, what would ask the user goes to the reviewer (Hooks.SetReviewer,Engine.review):[permissions.auto] model(else the session’s model) with the request (tool, kind, detail, targets, diff up to 8,000 characters), the last six messages, the workspace and[permissions.auto] environment, asked for{"decision": "allow"|"deny", "reason": …}(parseVerdictreads it in a code fence too). Allow proceeds (auto-allow: <reason>in the audit log), deny returns the reason to the agent (auto-deny); a failure, an answer that isn’t a verdict, or no answer within 2 minutes (reviewTimeout) asks the user (auto-error). An ask rule still asks the user. Its tokens count in the session’s usage.[permissions.auto]comes from the user’s settings only (a project may not set it); it follows accept-edits in Shift+Tab’s cycle. - APR-14b 2026-11-07 (the owner: “I checked the boxes, clicked approve, but was then blocked. That shouldn’t happen”). The reviewer reads what the user said in every form, not only their messages: the recent conversation it’s given (
recentConversationN,answeredLineinpkg/engine/runtime/review.go) has the agent’sask_user_questionquestions (“agent asked the user: …”), the user’s answers (“user answered: …”, several questions’ answers each after its question) and their answer to a plan (“user approved the agent’s plan”, or their feedback). Other tools’ results stay out: they aren’t the user’s words. Before, an answer reached the agent as a tool’s result, which the reviewer skipped, so after “Can you display these as options?” and the user ticking two and approving them, the first edit was denied as “they asked to see options, not changes”. - APR-14c 2026-11-08 (the owner, with qwen2.5-coder:7b on Ollama: the agent called
create_filefor.agents/scratch/recipebook_database.md, auto mode’s reviewer, the same model, denied it as “outside the workspace”, and the model pasted Markdown for the rest of the conversation). Facts before the reviewer: for a write or delete whose targets are all workspace-relative paths that don’t climb out (inWorkspaceinpkg/engine/runtime/review.go), the reviewer’s prompt says so, with each full path, and a denial whose reason says the action is outside the workspace or project is no verdict: the user decides, as when the reviewer fails. A local model doesn’t review its own actions: with no reviewer model of its own ([permissions.auto] model, built as the workspace opens) and the workspace’s model on Ollama (localReviewinpkg/engine/localmode.go), auto mode is default (ask) instead, when the workspace opens, when its model changes, and when auto is chosen;Settings.mode_notesays why, and the desktop’s status bar shows the mode with a warning and says it once in a snackbar, the CLI on start,/mode,/modeland/status. A model that doesn’t run here gives auto back, if it was held for this reason; ask chosen by the person stays. - APR-14d 2026-11-08 (the owner: “They should be presented with a clickable choice in chat without needing to type anything”). When the reviewer denies an action and someone is there to answer (the chat’s approver, or a background task’s people), they’re asked instead of the agent being refused: the request carries the reviewer’s reason (
ApprovalRequest.reviewer_denied), the desktop’s card shows it with Allow anyway and Deny (Deny focused, so a stray Enter doesn’t allow it), and the terminal’s picker shows it with “Yes, allow it anyway” (the cursor on No). The audit log hasauto-denyand then the person’s decision. With nobody to ask (a background run, a script without an approver), the denial goes back to the agent as before. - APR-14e 2026-11-21 (the owner: “one more mode … for running outside the sandbox, or ‘Unsafe’, or ‘FFAFO’ mode”).
unsafe(alsofafo,no-sandbox): bypass with the shell’s commands, foreground and background, run outside the OS sandbox (the guard and the scrubbed environment stay); nothing is asked (mode-unsafein the audit log). Deny rules, guardrails and the file tools’ blocked paths still apply; skill scripts, MCP servers, hooks and language servers run as before. Only the person chooses it, each time:/mode unsafe,--permission-mode unsafe, or the status bar’s menu, which asks first. It’s never kept or restored: a settings file naming it (one the agent’s command could have written) opens the workspace in default withErrUnsafeChosenEachTime, and the window doesn’t save it. It’s refused while the agent is at work in the workspace (ErrUnsafeWhileAgentWorks: a turn, a background task, or a background process it started), so a command of the agent’s reaching the service can’t switch it; and ablitzthe agent’s command started (BLITZ_AGENTset) refuses it for--permission-mode,/modeand/set mode. An agent’spermission_modeof it isn’t applied, the agent’ssettings set moderefuses it (only stricter modes, DRV-71), and Shift+Tab never reaches it (from it, Shift+Tab goes to default). While connected to an organization it’s refused (ErrUnsafeNotHere), and a setting asking for it opens in default with the reason. It ranks loosest (above bypass) forLooser. The CLI shows it red and warns on switching; the window marks it red. - APR-14 Permission modes (per workspace, shared by every session and client of it):
default,accept-edits,auto(APR-14a),plan(every prompt ofWorkspace.Runis planned —PlanPromptandWithPlanOnly— while the transcript keeps the text as typed; job runs and read-only/aside turns are unaffected),dont-ask,bypass. The starting mode is[blitz] permission_mode(a workspace’s own settings may set it: the user restricts a workspace there, and the desktop app’s workspace settings keep the mode chosen), elsebypassforauto_approve = true, elseauto(since 2026-10-18;tools.StartingMode). A project’s files may not set it. A workflow runs in its own mode within the workspace’s (spec_043_workflows WF-21).bypassrequires the OS sandbox to be active, at start (otherwisedefaultwith a warning,Registry.ModeNote) and when switching (ErrBypassNeedsSandbox).ParsePermissionModeaccepts Claude Code’s spellings (acceptEdits,dontAsk,bypassPermissions). - APR-14c 2026-11-05 (scan N26-desktop-2#17: the status bar’s mode menu changed the mode for the running workspace only, while Settings › Workspaces kept it, so the workspace reopened in the old mode). A mode picked in the desktop’s status bar is kept as the workspace’s mode (
blitz.permission_modein its own settings), as Settings › Workspaces keeps it (keepPermissionMode): new chats and the workspace after a restart start in it. It’s applied first, so what the service refuses (bypass without the OS sandbox) is neither applied nor kept; a project’s files still can’t set the mode./modeand Shift+Tab stay for the running workspace only. - APR-14b 2026-11-05 (scan N26-engine-tools-1#6:
auto_approve = trueturned a workspace’s explicitpermission_mode = "default"intobypass).auto_approve = trueapplies only whilepermission_modeis unset: a mode that is set,defaultincluded, is the starting mode. - APR-12 Otherwise the approver is asked inside an
approvalspan (time waiting for the user is isolated from tool time; attributes tool, kind, decision). An approver error denies (error).session/alwayswith a key add a session rule;alwaysalso saves it (a save failure is reported as “approved, but saving the rule failed”). Deny returns “the user declined this”. - APR-12a 2026-11-05 (scan N26-engine-tools-1#5: the save failure went only to the log). When an
alwaysrule can’t be saved, the person is told in the turn’s notices (approvals.save_failed: “Approved, but saving the rule failed, so it lasts only this session: …”) as well as the log. - APR-13 Auto-approval and rules never override hard policy: deny rules, the file sandbox and the OS sandbox are checked before approval.
- APR-20
~/.blitz/approvals.json(tools.approvals_file):{"version":1,"rules":[{key,label,added}]}sorted by key, written atomically (temp + rename) in a 0700 directory. A missing file is empty; a corrupt file is a startup error. - APR-21 Rules can be listed, revoked individually, or cleared (
/approvals, spec_018_workspace WS-62).
- APR-30 Shows the detail and (for edits) a coloured diff truncated to
ui.diff_lines(120); answersyonce,ssession,aalways,nno. Ctrl+C at an approval prompt cancels the whole turn. With no terminal to ask, the request is denied unless covered by config.
-
APR-41
exit_plan_mode(plan): only while the turn is planning (else an error). Unattended,dont-askor no prompter →approved: falseand “end your turn with the plan as your answer”. Otherwise the plan goes to the user through the question prompter, with options Yes, carry it out / Yes, and accept its file edits without asking / No, keep planning (localized); any other answer is feedback (approved: false, feedback), and the agent revises. On approval the plan is saved to.blitz/plans/<session>-<n>.md(session ID made file-safe;nthe first free number), the gate records the mode (defaultoraccept-edits) and planning ends. -
APR-42
enter_plan_mode(reason?)(registered only withplan_review = agent-decides): refused when no one can review (unattended,dont-ask, no prompter); otherwise the rest of the turn plans. -
APR-43
todo(items): the whole list, each{content, status}with statuspending|in_progress|done(todo,in-progress,completedand the like are normalized); at most 50 items; empty content or an unknown status is an error; more than onein_progressadds a note. The result carries the normalized items,doneandtotal; front ends show it as a checklist (api.Event.Tasks). A foreground sub-agent’s list shows while it runs, then the caller’s again (spec_014_agents AG-31a). The built-inproject-setupandproject-specsend the list again each time a step starts and ends, and after another agent returns (2026-10-29: a model that only made the list left the checklist on its first step), and ask only withask_user_question, with options whenever answers are likely, never as a question in their text. -
APR-40 Args
question,options?. Empty question → error. Unattended → error “this run is unattended: no one can answer; decide yourself and say what you assumed”. No prompter → “interactive input is not available; proceed with your best judgement”. Otherwise returns the user’s answer. The prompter shares the front end’s input reader (no competing stdin readers). -
APR-40a Several questions and multi-select (PAR-TOOL-05):
multi_select: true(it needsoptions) lets the user choose several;questions: [{question, options?, multi_select?}](at most 8) asks them in turn, instead ofquestion. A multi-select question is marked on the prompter’s context (api.WithMultiSelect,Question.multi_select,TaskRequest.MultiSelect); its answer is the options chosen, one per line, returned asselectedand joined inanswer(", “). Withquestions, the result isanswers: [{question, answer, selected?}]; an error stops at the question it happened on, with the answers so far. The REPL reads a multi-select answer as numbers or text separated by commas; the desktop app shows checkboxes and Send; stream-json input sendsmulti_selectwith the question. -
APR-40b 2026-11-07 (the owner’s request: “not everyone using this tool is technical”). Explained choices: when the options name technical things (frameworks, libraries, services, architectures), the agent gives
choicesinstead ofoptions, each{label, summary, details, why}: a short plain label for the button, one sentence for its tooltip, a few sentences on what choosing it means for someone non-technical, and why it’s ranked there. They come best first, andordersays in a sentence what the ranking rests on (easiest to maintain with AI, the largest community, the project’s ADRs). The tool’s description asks for them. The labels are the question’s options, so a front end that doesn’t know choices still offers them; a blank label is refused. They travel on the prompter’s context (api.WithChoices,api.ChoicesOf),Question.choicesandQuestion.order, andTaskRequest.Choicesfor a background task’s question. The app shows each as its button (the summary its tooltip, at once on hover), Recommended on the first, and an info button that opens the details and why; a multi-select question’s choices get the same tooltip and details. The terminal prints the order’s reason above the options, and each option’s summary and why under it.