00002 — Tool Call Flow

By Engineering Team•November 29, 2026•5 min read

This page follows the blue path of 00001 — Workspace Topology step by step. It is the design chosen in ADR-AI-003. Requirement IDs refer to SR-AI-001.

Every check below comes from the managed policy in /etc/claude-code/, which is root-owned. Inside the dev container, hooks and permission rules from any other settings file are ignored, so the assistant cannot skip, remove or weaken a step (SR-F-09).

Tool call flow: prompt submitted; started at workspace root, otherwise refused by start-guard; the assistant plans a tool call; a managed deny rule refuses it; env-guard blocks a secret, environment dump or op misuse; a call reaching outside the workspace asks the person, and runs only if approved; graphify hook-guard nudges to the graph; the tool runs and the result returns


1. Prompt submitted → start-guard

Hook: start-guard.js on UserPromptSubmit, before Claude Code processes any prompt (SR-F-02).

Check: was the session started at the workspace root? It compares the session’s project folder with the root recorded at build time in /etc/claude-code/workspace.

Result What happens
Started at the root The prompt goes on. The session has the workspace rules, skills and hooks
Started anywhere else Prompt refused. The person sees why, and is told to run claude again, which starts at the root
No root recorded (a host, or a broken install) The prompt goes on, so this guard can never lock every session out

2. The assistant plans a tool call

Claude Code proposes a tool call: Read, Grep, Glob, Bash, Edit and so on. From here, every tool call takes the same path, including calls made by subagents.

3. Managed deny rule → refused

Check: permissions.deny in the managed policy (SR-F-06). The 52 rules cover environment files and key material, environment dumps, keychain reads, every op subcommand except run, and docker exec, inspect and top.

On a match: the call is refused before any hook runs. Deny rules from other settings files are ignored, so none can be removed or added in a running container.

4. env-guard → blocked, reason returned

Hook: protect-env.js on PreToolUse for Read, Grep, Glob and Bash (SR-F-07).

Check: the path, search pattern and full command text. It looks for secret files and key material, a path or command naming secret, token or credential, environment dumps, reads of sensitive variables, and any op use other than op run ... -- tofu|wrangler <allowed subcommand>.

On a match: the call is blocked (exit code 2). The reason and the allowed form go back to the assistant, which changes its approach. A block is final. There is no approval step, because a leaked secret cannot be taken back.

5. Reaches outside the workspace → person approves?

Hook: scope-guard.js on PreToolUse for Bash (SR-F-08).

Check: clone, push, ssh/scp/rsync, curl/wget, GitHub CLI commands that are not read-only, and fetch or pull on a repository outside the workspace. A command it cannot follow also counts.

Result What happens
Stays inside the workspace Goes on, no question
Reaches outside Claude Code asks the person, showing the reason
Person approves Goes on to step 6
Person declines Not run. The assistant is told and continues without it

This guard asks rather than blocks, because a push or a clone is sometimes exactly the task. Bypass mode, which would skip every question, cannot be entered (disableBypassPermissionsMode).

6. graphify hook-guard → nudge to the graph

Hook: graphify hook-guard search on Bash/Grep, and graphify hook-guard read on Read/Glob (SR-F-12).

Check: whether the call is a broad search or read that the knowledge graph could answer more cheaply. This is a cost control, not a security control: it reminds the assistant to use graphify query, path or explain first. The call still goes on.

7. Tool runs, result returned

The tool runs as vscode, with no sudo and no secret in its environment. The result goes back to the assistant. When a commit is made, the gitleaks pre-commit scan runs as well (SR-F-16).


Outcomes at a glance

Step Mechanism On a match Who decides
1 start-guard Prompt refused The policy
3 Managed deny list Refused The policy
4 env-guard Blocked, reason returned The policy
5 scope-guard Asks The person
6 graphify hook-guard Nudge only The assistant