Status: decided 2026-12-01; implemented for the webapp's Claude Code,
Codex and OpenCode sessions, and for terminal sessions of all three.
decide, the scope file, the scope guard and the terminal's answer
(terminal.py) are in chitragupta/core/policy/; the three adapters, Claude
Code's ask hook, OpenCode's gate plugin and the webapp's agent session,
which writes the scope file and answers every call with decide, are
in chitragupta/webapp/agent/, with the for this draft answer, the
draft selector's binding, the bind snapshot, the gate after every edit
and the rollback.
The terminal's hook, OpenCode plugin and static rules
(issue 1332)
are written by chitragupta init and shipped in the release zip; the
section In the terminal describes them.
The tier table it reads is plans/1269-tier-table.md, the canonical
table for
issue 1269.
Written for anyone building or changing the webapp's agent session,
a harness adapter, the scope guard, or the policy in
chitragupta/core/. Assumed: HARNESS.md for how each
harness is driven, including its section "Approval channels and per-call
checks", which holds the measured facts this page relies on.
Not covered here: the citation gate, which checks what a draft
says. This page is about what the agent may do.
The drafting skills read parsed PDF passages (draft retrieve, picks in
outline.md). That text is untrusted. A passage can tell the agent to
run a command, send data out, edit files, or record a sign-off. A person
picking a passage for its claim may never read all of it. The agent
cannot tell an instruction it was given from one it read.
Three layers, one policy. A scope file the server owns says
what the agent may currently change: read, or draft:<path>. Before a
tool call runs, one function in chitragupta/core/,
decide(action, scope) → allow | deny | ask, matches the call against
the tier table's list for that scope. Inside every chitragupta command,
a scope guard refuses any write the scope does not cover, so a flag
that selects a write mode cannot slip past the list. Ask reaches a
person as a card in the webapp's Agent pane, or as the harness's own
prompt in a terminal. One agent session survives every change of scope,
because the scope is a file that is re-read on every call, not a
setting fixed when the agent starts.
CHITRAGUPTA_WRITE_SCOPE_FILE. The file it names is owned and
rewritten by the webapp server. It holds read, or draft:<path> for
the one draft the agent may write.content/), in a private per-user runtime directory the server makes
in the operating system's temporary directory (0700, each file
0600). The webapp's other runtime files, server.json, its lock and
the launch file open.html, which holds the bearer token, live in a
per-user folder outside the project,
$XDG_STATE_HOME/chitragupta/<hash>/ or
~/.local/state/chitragupta/<hash>/ (%LOCALAPPDATA%\chitragupta\<hash>\
on Windows; 0700, each file 0600), so nothing private is in the
project tree. chitragupta webapp --json prints its paths. A missing,
unreadable or unparseable file means read, never "anything".One check, which every command's builder passes through before it runs,
re-reads the scope file on every command; init, install and
webapp, which have no builder, refuse whenever the variable is set:
read, every write mode in the tier table refuses with a
typed refusal before it writes. The three always-filing aids
(review provenance, review agenda, review digest) print their
payload and file nothing.draft:<path>, the draft scope's rows may write, and only
to the bound draft's paths (its draft, dossier, sections, references
and figures/). Everything else refuses. A table in
core/policy/binding.py names, for each of those rows, the arguments
that say where it writes: each must resolve (symbolic links followed,
from the working directory) to the bound draft or its dossier
directory, its figures directory or a file directly in it, or, for
--output-dir, the draft's rendered mirror. A refusal names the
argument. figure sync with no path would walk every draft's figures,
so under draft: it is refused until it names the draft's own. An
always-filing aid run on another draft prints its payload and files
nothing, as under read.The guard is what makes one list entry per command safe. argparse
accepts any unambiguous abbreviation of a flag: --basel ran
review agenda --baseline, and --wri ran --write (measured). So no
list entry can tell a read from a write that a flag selects. The guard
can, because it runs after argparse.
decide, and the tier tabledecide takes the command line the harness is about to run, plus the
current scope. It answers:
python -m chitragupta.<layer> <verb> [<mode>]:
read, the plan's 43 read entries, plus reads under the read
rule (below);draft:<path>, those plus the draft scope's write rows for
the bound draft (below).$(...), a redirect, an environment assignment such as
CHITRAGUPTA_WRITE_SCOPE_FILE=... python -m ..., or another
program), except a plain read line under the read rule and a
sequence of allowed reads (below);Write flags turn allow into ask. When a line matches an entry
the scope allows, and a word in it selects a write mode whose row the
scope does not list (the option itself, any abbreviation of it from
-- and one letter up, or either with =), decide answers ask
instead of allow. That is how review agenda --accept, draft dossier acronyms-suggest --apply and review union --write reach a
card although each shares its entry with an allowed mode; under
read, every flag-selected write asks the same way. The rule only
ever asks more: it never turns anything into allow. The guard stays
the last line, after argparse, and refuses any write the scope and the
one-shot entries do not cover.
The tier table (plans/1269-tier-table.md) puts 103 rows (72 commands
and 31 flag-selected modes) in five classes: 43 read, 27 regenerable
output, 4 pipeline writers, 25 authored content, 4 excluded. A write
whose only effect is a rebuildable cache (retrieval_index.json,
retrieval_passage_index.json, content/overlap/) counts as a read,
and so does chromadb's rewrite of content/chroma/ whenever a read
opens the embedding index.
A rewrite of a generated region of an authored file (draft references, figure sync) counts as authored content.
One rule, in decide, for every harness. A read is allow when every
path it names resolves inside:
content/;.claude/skills/, .agents/skills/
and .opencode/skills/;AGENTS.md at the project root.Nothing the webapp keeps private is inside those roots. Reads of its runtime folder, of the scope file and its directory, and of the webapp's own harness homes (Codex's and OpenCode's) are deny. Any other read asks.
| Harness | What counts as a read |
|---|---|
| Claude Code | the Read and NotebookRead tools. Glob and Grep always ask, for one call only: a pattern can reach past the root it names, and Grep reads hidden files |
| Codex | it has no read tool: a plain read command line whose paths all fall inside the roots (below) |
| OpenCode | the read, glob and grep tools |
A plain read line is one plain command (no pipe, redirect, substitution or assignment) whose program and options are in this table, with the options first, each its own word, and at least one path after them:
| Program | Options |
|---|---|
cat |
none |
head, tail |
-n <number> |
ls |
-l, -a, -1 |
sed |
-n, then one script <n>p or <n>,<m>p |
grep |
-n, -i, -l, -c, -w, -F, -e <pattern>, -C, -A, -B and -m with a number; the pattern first unless -e gives it; files only |
Every word is spelled so that a POSIX shell, zsh and PowerShell read it
alike: bare, from letters, digits, ., _, / and -, or wholly in
single or double quotes holding printable ASCII with no quote,
backslash, backtick or $. A path holds no glob character, comma,
tilde or non-ASCII letter, quoted or not; an absolute Windows path
never counts. Anything else (sed -i, ls -R, wc, an option after a
path, a combined -in, no path) is another program's line and asks.
A search never reads as a read. Every rg, rgrep, a grep with
a recursive option (-r, -R, -d, --recursive and their
spellings), and a grep naming a directory ask for one call only, once
or deny, like a read outside the roots: a recursive search can follow
a link planted under content/ to files outside it. Nothing private
is under content/ (the webapp's runtime files are in its per-user
folder), so a search there meets nothing of the webapp's.
The same plain read line run through Claude Code's Bash or
OpenCode's bash is a read too, since decide sees only the line.
Under draft:<path> the agent may also, for the bound draft only:
draft dossier init (with or without
--outline), mark-revision, snapshot, stamp, sections --citekeys --write, draft retrieve search --log and
evidence --log, draft render, and figure new;draft evidence, both
draft diff modes, the seven aids' --write, the three
always-filing aids, agenda --baseline and digest --baseline, and
figure look;draft dossier prune --apply and apply-renames;draft references and figure sync, bound to the draft.The rest stays outside the draft scope:
agenda --accept, set-language, acronyms-suggest --apply,
restore and export;draft spec init and seed, draft registry build and index, review union --write).Each of these asks, every time. The three that share an entry with
an allowed mode (--accept, --apply, union --write) ask through
decide's write-flag rule above.
The bound draft's paths. draft:<path> names one .md or .tex
file under content/drafts/, outside every figures/ directory;
anything else in the scope file is unparseable, so read. Its paths
follow the core's own rules: the dossier is
content/dossiers/<path below drafts, minus suffix>/, the figures
directory is figures/ beside the draft (shared by every draft in that
directory), and the rendered and review mirrors are the draft's
directory under content/rendered/ and content/review/. A draft row
is allow when the first word after its entry is the bound draft, or,
for figure new and figure look, the figures directory or a file in
it. A write row whose draft is a flag's value (retrieve --log) is left
to the guard.
A file tool may write less than a command:
evidence.md,
rejected.md, sections.md, steering.md, revisions.md,
retrieval.md, paper.md and math.md;.tex or .txt directly in figures/.scope.md asks, because set-language, which asks every time, and
stamp write it; outline.md (the person's picks) and versions/
(what a rollback trusts) are written by commands only. Any other write
asks as before.
Moving to a draft. A file write to another draft, or a draft row
naming one, asks with the reason first_write under read and
other_draft under draft:, and offers for this draft for that
draft. A draft row's card offers no for this conversation: a grant
keyed on the entry's words would cover every draft. For this draft is
offered only where decide would allow the call under that draft.
The first change to a draft scope takes a dossier snapshot, and
draft gate runs after every edit to the draft. So a bad session can
be rolled back, and a fabricated citekey fails where it can be seen.
These are refused whatever is clicked or granted:
corpus sync, enrich;init, install, webapp;outline.md generator, draft dossier skeleton (tier-table
row 98);<state>/chitragupta/
(matched like the Codex home below), the scope file's directory or the
webapp's harness homes;XDG_STATE_HOME or
LOCALAPPDATA in any spelling, or a path that is, or could glob to,
state/chitragupta or AppData/Local/chitragupta (case-folded,
through quotes and escapes), wherever the line runs from. Another
application's folder beside it, such as ~/.local/state/<other>,
stays an ordinary read;*, ?, [,
{) unless every glob word is relative, with no .., $, ~,
backslash, brace or drive letter, the line changes no directory
(cd, pushd, popd, -C, -D, --chdir, --directory, a
subshell, exec) and
names no variable, and each glob, expanded from the root when the
call is decided with every match resolved through its links, reaches
nothing in the webapp's homes, its scope directory, its runtime
folders, the person's Codex home and OpenCode directories or any .codex
directory (at most 10,000 matches). A glob that passes keeps its
usual rule. This over-denies (a quoted grep pattern with * and a
$ is a glob to it), and fails closed;cd
or pushd with no target, -, a variable, a glob, ~ or a path
outside the project root; popd; exec; a subshell; -C or
--directory for env, git, make or tar; any ..) and names a
relative path with a separator, or a word that is the last part of a
private or person directory (opencode, .codex,
chitragupta-webapp, the runtime folder's chitragupta and its
hash);grep -r, rg, find, fd, ag, ack, tree,
du, git grep, ls -R) one of whose starts is at, above or inside a
private directory (the webapp's homes, scope directory and runtime
folder, the folder holding every project's runtime folder, the person's
Codex home and OpenCode directories), still holds a $, backtick, brace
or ~ once a leading home is replaced, or whose tree reaches one
through a link or holds more than 10,000 entries. Every word that is not
an option counts as a start, the pattern included, and so does the
working directory for every search but ls -R naming a path: which word
is the pattern, and whether one is a path, depends on options the rule
does not parse (grep -r -e x searches .). Nothing private is under
the project root, so a search whose starts are all inside it (rg x content, grep -r x content/drafts, find content -name '*.md', rg x from the root) asks for one call only, once or deny, like a read
outside the roots, but only when every option on it is on its program's
list of read-only options (core/policy/search_options.py). An option
that runs a program, writes a file or is not listed (find -delete,
-exec, -execdir, -ok, -okdir, -fprint, -fprintf, -fls; fd -x, -X, --exec-batch; rg --pre, --pre-glob, -z; ag and
ack --pager; tree -o; git grep -O) asks as another program's
line, with no answer for the conversation, and is refused with the
reason search_action when a word of that search, or an option's value,
names a path outside the project (find content -fprint ~/x). A long
option counts only when named in full, so an abbreviation such as grep --rec asks the same way. git grep and ack always ask that way,
since a repository's .git/config, git's own options and an .ackrc
can set a pager or options the line does not show; so does a search on a
line with an environment assignment (X=y rg, env X=y rg) or naming a
variable a search program reads its options or a pager from
(RIPGREP_CONFIG_PATH, ACK_OPTIONS, ACKRC, GREP_OPTIONS,
GREP_COLORS, FD_*, GIT_*, PAGER, LESSOPEN), which is refused
as search_action when a value names a path outside the project. A
recursive search on a line that changes directory in any way (cd,
pushd, popd, exec, a subshell, any .., any -C, -D, --chdir
or --directory, attached or separate and in any case, or any option to
env, sudo, doas, nice, timeout, nohup, stdbuf, xargs,
busybox, command or builtin) is refused. Every path rule reads its
private directories from one list (core/policy/private.py);ionice, setsid, watch, strace, flock, parallel, su -c,
script -c, xargs -P 4, env -S, sudo -p p), inside a quoted
string, or in a git alias. Each such word (rg, find, fd,
ag, ack, tree, du, rgrep, git before a search program,
and grep, egrep, fgrep or ls with a recursive option among
the words after it) is read as a recursive search over every word
after it and the working directory, and the search rule above is
applied to it. A line naming such a search more often than it runs
one is refused wherever the search would start (watch rg x content/drafts included). The name is matched in any case,
with its path and extension and a leading !, quote or backslash
dropped (/usr/bin/RG.exe is rg). This fails closed, by the
owner's decision: which rg, echo find and cat content/drafts/tree.md are refused too, with a message naming the
reason. grep without a recursive option on named files is still a
read;CODEX_HOME, in any spelling ($CODEX_HOME,
${CODEX_HOME}, quoted or escaped, printenv, env -u, unset,
export, an assignment, PowerShell's $env: and cmd's %...%), as
for the scope variable;too_long, before any other rule
reads it. No ordinary command comes near either bound; past them the
line is refused unread, so no rule's work grows with what the agent
sends;OPENCODE_SERVER_PASSWORD, in any quoting,
escape or case. A line that could print the environment without
naming it (env alone, printenv, set, export -p, declare -x,
compgen, ps e, /proc/<pid>/environ, os.environ,
process.env, PowerShell's env:) asks every time, with no answer
for the conversation;~/.codex, and $CODEX_HOME where the server's environment sets
it), whichever project's webapp home it holds: matched by resolved,
case-folded path through .., a link, ~, $HOME and the expanded
home directory, and a glob that could match inside it;$XDG_DATA_HOME/opencode, $XDG_CONFIG_HOME/opencode, by default
~/.local/share/opencode and ~/.config/opencode), whatever the
harness, and also any line with a path segment that is, or could
glob to, opencode, and any line naming XDG_DATA_HOME or
XDG_CONFIG_HOME; and a read or write by the agent's file tools of
any path with an opencode segment and an auth.json after it,
wherever it is;~, $HOME,
~/.local/share, ~/.config, /, the directory holding the scope
directory, or .. from the root. An option's value counts as a
word (--directory=~, and what follows each letter of a
short-option cluster, so -C~, -b~ and -xzvC~/.local/share),
and a word that cannot
be resolved, or that still holds a
$, backtick, brace or ~ once a leading home is replaced
($XDG_DATA_HOME, ${HOME:-x}, $(echo ~), ~name), counts as
one. What the
program does with the word (copies, archives, lists or walks it) is
not parsed, so tar czf x ~/.local/share, cp -r ~/.config x, zip -r x ~ and du -a ~ are refused alike. The project root and its
read roots (content/ and the skills directories) keep their own
rules, so ls content is still a read;glob or grep call whose search root is at, above or
inside a private location (the webapp's homes, the scope directory,
the runtime folders, the person's Codex home and OpenCode directories,
any .codex directory), so ~ and / among them, or whose tree,
walked with hidden names and links, reaches one (or holds more than
10,000 entries); and a glob pattern, or a grep include, with
braces, $, ~, a backslash, a drive or absolute start, or a ..
segment, or whose expansion reaches one;.bib, papers/, the ledger, the scope file, .claude/,
.codex/, .agents/, .opencode/, the root's AGENTS.md and
CLAUDE.md (resolved and case-folded, so through a link too; reads of
AGENTS.md stay allowed), and the root's opencode.json and
opencode.jsonc. These hold the hooks, plugins, skills, instructions
and agent configuration, and an edit there would make an attack
persist.A person runs these themselves, in a terminal or through a webapp button.
Some of the rules above refuse lines that would have done no harm. This is accepted by the owner's decision: each rule fails closed, and the agent has another way to do the same work.
cd content && rg x,
and any -C, -D, --chdir or --directory on a line with a
recursive search (grep -d recurse x content among them, as -d
reads like sudo's -D), are refused, since the rule does not follow
the working directory. Without the move the same search asks once.which rg,
echo find, man rg, watch rg x content/drafts and rg find content (the pattern names find) are refused, with the reason
unplaced_search.cat content/drafts/tree.md or sed -n 1p content/drafts/find.md is
refused. The agent's own file tools (Claude Code's Read and
Edit, OpenCode's read, edit and write, Codex's patches) still
read and change such a file.grep pattern holding * and a
$ or a parenthesis, ls ~/*.txt and ls /*, as above.echo $HOME, ls ~,
ls /, ls ~/.local/state and a listing of the temporary directory
that holds the scope directory are refused, since each is above the
person's Codex home, their OpenCode directories, the runtime folders
or the scope directory, whatever the program does with the
word. So is any line with a variable other than a leading $HOME, a
command substitution or ANSI-C quoting in a word (echo $PATH,
python -m chitragupta.draft gate $(ls), cat $'content/a.md'), or
a ~ inside a quoted path (cat 'content/~/a.md').The webapp's runtime files moved out of the project with the for this
draft answer (#1339), so nothing private is left under the root, and a
recursive search of the project returned to the once-only card (owner,
2026-12-03). The unplaced_search rule, the glob rule and the move rule
did not change with that move.
draft:<path>.A card offers for this conversation only when decide gives its ask
a grant: another program's exact line, a chitragupta command, or a
write to a path. These ask for one call only, once or deny:
Glob and Grep included;A request that makes several calls, such as a Codex patch over several
files, gets one answer from decide_all: any deny denies, every
allow allows, and otherwise its card lists each path with its
verdict, and offers for this conversation only when every asking call
has a grant. The card's reason is the strongest asking one, whatever
the order of the calls: a mode that asks every time, then an unknown
tool, a read outside the read roots and a line that is not plain, then
the rest. A sign-off is never joined: a request of several calls that
holds one is refused, and the model is told to make the sign-off call
on its own.
A sequence of reads is judged as its commands. A line of two or
more plain commands joined by ; or &&, and by no other operator,
gets the answer decide_all gives those commands as calls of one
request, when every command but the last is a plain read line the read
rule allows: ls content/drafts; ls content/dossiers is allowed, and
ls content; make test offers for this conversation with the grant
for make test. Each command is judged as if it ran alone, and that
holds only while the commands before it change nothing: cd, a
symbolic link or a written file would move what a later read reaches.
So any other sequence stays one line that is not plain, asking once,
and so does one whose last command is a chitragupta command that asks:
its once is a one-shot scope-file entry, and the guard matches that
against the one command it was written for.
Every grant ends with the conversation. A new conversation starts at
read.
draft spec sign and draft unit accept record that a person
approved an outline or accepted a chapter. There are two ways to record
one:
<slug> at
digest <d>, signed as <name>. Approve only if you have read it."
No grant covers a sign-off, and the card's once is the only answer
that runs it.The webapp drives the harness, and answers every approval request itself
by calling decide:
How each harness is made to send every call to the webapp:
| Every call reaches the webapp through | The webapp answers | |
|---|---|---|
| Claude Code | --permission-prompt-tool stdio, plus a PreToolUse hook that answers ask for every call, so that auto-allowed reads and saved allow rules are covered too |
can_use_tool: allow or deny |
| Codex | codex app-server with approvalPolicy: "untrusted", which asks for every command and patch, and a Codex home of the webapp's own with web search, image viewing and MCP servers off, since their calls never ask |
accept or decline |
| OpenCode | opencode serve with "permission": "ask", behind a password of its own that every shell the agent runs sees empty, and a webapp plugin whose tool.execute.before refuses every call decide denies, even one that never asks |
once or reject, never always: OpenCode's always grants chitragupta * and overrides a configured deny |
A terminal session has no server, so nothing rewrites a scope file and
there is no card. The terminal's scope is fixed, terminal: the draft
scope's rows for any draft under content/drafts/ and its dossier under
content/dossiers/. decide reads it as it reads draft:<path>, with
the path left free: a call's draft is the one the call names. No scope
file parses to terminal, and it never binds a draft. One function in
core/policy/terminal.py turns decide_all's verdict into each
harness's answer; the hook and the plugin convert the harness's call
into actions, refuse a write into the chitragupta package the hook runs
from when that package lies inside the project, and print the answer.
OpenCode's task call, which starts a subagent, is judged as Claude
Code's Agent tool outside a webapp session.
| Adapter | deny | ask | Sign-offs | |
|---|---|---|---|---|
| Claude Code | PreToolUse hook, matcher *, in .claude/settings.json |
the hook's deny, with the reason; it blocks in bypass mode too |
the hook's ask, with the reason, for every call decide asks about, pytest and git included; it still asks in bypass mode |
ask, with the sign-off text when the line spells the command python -m chitragupta.draft ...; another spelling (chitragupta draft ..., cg draft ...) asks with the generic reason |
| Codex | PreToolUse hook on Bash, apply_patch, Edit and Write in .codex/hooks.json, once the person has trusted it |
exit 2, with the reason on stderr and a deny on stdout; it blocks with approvals off too |
none: the call falls to Codex's own approval mode | refused, with "Sign-offs are yours to run: <command>" |
| OpenCode | tool.execute.before in .opencode/plugins/chitragupta-policy.js, which runs the Python hook that .opencode/chitragupta/policy.json names |
the plugin throws | "*": "ask" under bash and under edit in .opencode/opencode.json: every shell call and file edit asks until the person answers "Allow always", and the prompt shows no reason |
refused by the plugin, with the same message |
Codex has no ask and no command rules (owner, 1a). A Codex
hook's ask is ignored (HARNESS.md).
Command rules could ask, but the webapp refuses Codex in a project
that holds any, and rules in ~/.codex/rules/ would apply to every
project the person opens. So a call decide would ask about goes to
Codex's approval mode: under untrusted Codex asks, without the
reason; under on-request a command or write inside the sandbox runs
without asking; with approvals off it runs. Since nothing can
make Codex ask with the sign-off text, the hook refuses both sign-offs
(draft spec sign, draft unit accept) with the exact command for
the person to run. Codex trusts each hook on its own, by a key naming
the file, the event and the hook's place
(<root>/.codex/hooks.json:pre_tool_use:0:0) and a hash of the hook,
so trusting the gate's PostToolUse hook does not trust this one.
Until the person trusts the PreToolUse hook it does not run, and
chitragupta doctor reports it.
Chitragupta's own commands under Codex and OpenCode. Neither can
ask with a reason, and one OpenCode "Allow always" on a chitragupta
line grants chitragupta *. So a line that may run chitragupta,
however it is spelled (cg, a path ending in chitragupta,
python -m chitragupta..., or a glob or variable that could expand
to one of them), passes the hook only when it is a plain command on
the tier table's list with no sign-off and no always-denied mode.
Any other such line is refused: "Chitragupta commands this harness
cannot ask about are yours to run: <line>". Other lines that
decide asks about go to the harness's own approval, except those
the line rule refuses. The protected paths are a .bib file,
anything under papers/, the ledger and its -wal, -shm and
-journal files, .claude, .codex, .agents and .opencode
under the root, the root's AGENTS.md and CLAUDE.md, and its
opencode.json and opencode.jsonc. Each command of the line
(split at ;, &, |, &&, || and newlines) is read in turn,
and a line is refused when:
git or
git-*) in any but the listed form. Git passes only as the plain
word git at the start of a command, with no global option but
--no-pager, -P or --paginate, and a subcommand from status,
add, commit, log, diff, show, rev-parse, ls-files,
blame, mv, rm, branch, tag, describe and shortlog;
branch and tag only in a listing form (no name, and no option
but -l, --list, -a, --all, -r, --remotes, -v, -vv,
--verbose or --show-current). No option that runs a program or
writes a file may follow the subcommand: -O..., and
--open-files-in-pager, --output, --ext-diff, --textconv,
--exec, --upload-pack, --receive-pack or --config-env in
any abbreviation or with =. A command holds one git word only,
and a line with process substitution (<( or >() is refused. A
line with a word holding alias, GIT_CONFIG, include.path or
includeIf (any case) is refused whatever the subcommand, since
each can rename one, and so is any line, git or not, with a word
starting GIT_ (GIT_PAGER=, export GIT_EXTERNAL_DIFF,
env GIT_SSH_COMMAND=), since git runs the programs they name. A
line that runs git and sets any variable (a command starting
NAME=, or export, declare, typeset, local, readonly,
setenv, set or env) is refused too, since git also reads
PAGER, EDITOR, HOME, PATH and others. So git grep,
git -C, git -c, git reset, git stash,
git checkout, git restore, a git behind xargs, find -exec,
parallel or watch, and /usr/bin/git are refused: "Refused: this line runs
git in a form the policy cannot read (only a plain git with a
listed subcommand passes), which this harness cannot ask about.";--, other than a commit message's value
(after -m, --message, -F or --file, and only for commit
and tag; for any other subcommand the next word is read and
checked for the options above), is clean, dry runs
included, since git clean deletes untracked files and the ledger,
drafts and papers/ are git-ignored: "Refused: git clean deletes
untracked files, the ledger and drafts among them; run it
yourself." Quotes are not read, so git commit -m "tidy and clean"
is refused too;.git (the root's, a nested repository's), a .gitattributes,
.gitmodules or .gitconfig in any directory, the person's
~/.gitconfig, ~/.config/git/ or $XDG_CONFIG_HOME/git/, or
/etc/gitconfig, since git runs the pagers, diff drivers and
filters they name (the line gets the protected-path message below).
A file tool's write there is refused too: "Refused: git runs
programs that its config names (a .git directory,
.gitattributes, .gitmodules, .gitconfig or the person's git
config), so the agent may not write them under this harness."
Claude Code asks about both, and the webapp keeps its own rules;cd <path> or
pushd <path> with a literal path: cd alone, cd -, cd --,
a cd to a glob or variable, popd, builtin cd, command cd,
any -C option, --chdir or --directory (git -C, env -C,
make --directory), or an option to a program that runs another
(env, sudo, timeout, ...): "Refused: this line changes
directory in a way the policy cannot follow, which this harness
cannot ask about: <command>";=, read from the session's
directory and from every directory a plain cd moved to, names a
protected path, a path inside one, the root, or any directory that
holds a protected path (content when the ledger is in it, .,
..);*, ?, [...]) that, component by
component, could match a protected path or a directory holding one
(.claud*, papers*, content/ledger.sqlit?), whose last
component could match a name ending .bib (refs.*, refs.bi?,
*), or that now expands to one of those, or to more names than
the rule reads;$, a backtick or a ~ the rule cannot
expand.That bullet and the last three say "Refused: this line names a protected path
(<word>), which this harness cannot ask about." A command that is a
plain read on the read list (cat, ls, head, tail, sed -n,
grep with listed options, globs included) writes nothing and is
not checked. These rules are best-effort checks of a line's text,
which cannot match what a shell does exactly: under Codex with
approvals off and OpenCode after "Allow always" they narrow what an
injected agent can do but do not make those modes safe, so use
Codex's untrusted approvals and OpenCode's prompts. The rule
over-refuses: a commit message that mentions
papers is refused too. What stays possible is a protected path the
line computes rather than names or globs (code handed to an
interpreter, a script written and then run) and a program that
changes files it was not told about (an archive unpacked over them
with tar xf or unzip -o). Git also still honours the person's own
global and system git config and any GIT_* variable set outside
the session, so a pager, diff driver or alias configured there runs.
A session inside a nested project is refused. A directory under
the root that holds its own config.toml (a copy of the project, or
a sample project such as docs/examples/* kept inside it) is another
project, so a
session whose directory is inside it gets every call refused by the
hook, which names chitragupta init. Start the session in that
project's own directory instead, and run chitragupta init there if
its harness config does not carry the policy yet.
Relative paths are the session's, not the root's. A file tool's
relative path is read from the working directory the harness reports
with the call (cwd in a Claude Code or Codex hook's input; the
OpenCode plugin sends OpenCode's directory, and a bash call's
workdir is read from it), or the hook's own when none is given. A
command line's text is judged as the agent wrote it, with its
relative words read from that directory, so
python -m chitragupta.draft gate drafts/x.md from content/ is
judged like python -m chitragupta.draft gate content/drafts/x.md
from the root. The webapp's sessions run at the root and are judged
as before.
A hook judges only its own project. When chitragupta init's
--root is given and the hook runs outside that directory (or, for
Claude Code, CLAUDE_PROJECT_DIR lies outside it), the hook refuses
every call and names chitragupta init: a copied project still names
the original's root until init runs in the copy. A directory under
the root that holds its own config.toml, as a copy nested in the
root does, counts as outside it. chitragupta doctor reports a recorded --root that is not the project it checks.
No scope guard in the terminal (owner, 2026-12-04, option i). The
terminal sets no CHITRAGUPTA_WRITE_SCOPE_FILE, no harness config
names it, and the guard stays unrestricted there. decide's
write-flag rule already turns a write mode's flag, any abbreviation of
it, or either with =, into ask (see
decide, and the tier table).
Where that ask reaches a person, a guard would add nothing. Where it
does not (Codex under on-request or with approvals off, OpenCode
after "Allow always"), a guard that admits what the person approved
would admit the same line.
The adapters step aside inside a webapp session. A webapp session
loads the project's harness config, so the terminal's hook and plugin
run there too. When CHITRAGUPTA_WRITE_SCOPE_FILE names a webapp
scope file (a regular file named scope-<16 hex digits> in a
directory whose name starts chitragupta-webapp-), each adapter
checks the call against that scope file and only denies: it never
asks, never allows and never refuses a sign-off, since the webapp's
own channel asks and its card takes sign-offs. A variable that names
anything else is treated as absent, so a stray export in a
person's shell does not switch the terminal policy off. In a project
unpacked from the release zip, the static rules' denies on
chitragupta/**, pyproject.toml and scripts/** and the hook's
refusal of a write into the package hold inside a webapp session too,
so such a write is refused there instead of asked.
A project's own copy of chitragupta is not the agent's to write.
When the package the hook loaded lies inside the project, as in a
project unpacked from the release zip or one whose chitragupta is
installed in an in-project .venv, the hook refuses any file write
into it, in a webapp session too.
Generated static deny rules are a second line, there because a
harness can skip or lose its hook. They are made from the always-denied
list only: a webapp session loads them too and keeps every configured
deny, so a static rule broader than what decide denies under every
scope would change a webapp outcome. Each command rule matches whole
words: Claude Code's permissions.deny holds Bash(<cmd>) and
Bash(<cmd> *), and the always-denied paths as Edit(...) and
Write(...), plus WebFetch and WebSearch; OpenCode's permission
holds <cmd> and <cmd> * as deny under bash, beside "*": "ask",
the same paths under edit, also beside "*": "ask", and webfetch: deny. OpenCode never gets a top-level permission["*"] nor an allow,
since patterns cannot express a draft's paths. Codex gets none (1a). A
release-zip project's rules also deny writes to chitragupta/**,
pyproject.toml and scripts/**.
Where they come from. chitragupta init writes every harness's
tree (.claude/, .codex/, .agents/, .opencode/) with the hook,
the plugin and the static rules; it has no --agent option. Each
hook runs the absolute path of the interpreter that ran init, with
-I, so neither the project directory nor the environment can put a
planted chitragupta/ ahead of the installed package, and passes
--root with the project's path. On an existing config, init adds
the policy only after the person confirms, and never loosens a rule the
person set (it may tighten one: a bash or edit * allow becomes
ask, and a hook entry carrying the policy marker is replaced). When the
person declines it for an existing .opencode/opencode.json, init
writes neither the OpenCode plugin nor a new policy.json.
scripts/release.py writes the same into the release zip, which has no
recorded interpreter and so runs python with the zip's own package.
chitragupta doctor reports a harness config without the policy, a
recorded interpreter that cannot run or is not the one doctor runs
under (compared by path, and through links only within one directory,
so python and python3 in one virtual environment are the same
interpreter while two environments' python, which can link to one
base interpreter, are not; it never runs that interpreter), a running
chitragupta with no terminal_hook.py, a recorded --root naming
another project, and a Codex PreToolUse hook that is not trusted. A
Codex trust record is
reported as existing, not as current: Codex keys it to a hash of the
hook that doctor cannot recompute, so a record made before the hook
last changed reads the same, and Codex skips the hook until the person
trusts it again after chitragupta init. In chitragupta's own source
checkout, whose configs carry no policy, it says nothing about it. The
hook's 5-second deadline starts once its own code runs, under the
harness's 10-second timeout; it answers deny on that deadline, on any
error, and when chitragupta cannot be imported at all. A stall before
the deadline starts (the interpreter starting, loading the hook's entry
module) falls to the
harness's timeout, which Claude Code and Codex treat as non-blocking
and the OpenCode plugin treats as a refusal.
The Claude Code and Codex hook command ends || exit 2, so a recorded
interpreter that is gone (the shell's exit 127, which both harnesses
would let through) refuses too; doctor reports a release-zip project
with no python on PATH.
running
part brings no input or the input has not come within 5 seconds.opencode serve as soon as it is spawned, so the webapp's
last-resort kill at server stop ends one that has not yet said its
port.read, and so does anything but a regular file (a
FIFO, a directory or a device), which is never opened for a blocking
read.chitragupta.core.config, and about four
times that for a whole layer. The policy module imports neither a
layer nor the ledger.| It can | Because |
|---|---|
| Make the agent ask for something harmful | Asking is free; the person must read the card |
| Get a tired "yes" | Approval fatigue. Grants are narrow, and the always-denied list holds whatever is clicked |
| Write misleading prose into the bound draft | Only a person reading the draft catches it; the gate catches only a fabricated citekey |
| Read anything in the read tier | Reads are allowed by design |
In the webapp, it cannot (the terminal's limits are in SECURITY.md):
corpus sync or enrich, or reach the network from the agent's
shell;.bib, papers/, the scope file, or the hooks, skills and
agent configuration;The next step, with
issue 901's
MCP server, is an agent with no shell and no file tools, only
chitragupta's own: run(verb, args), write_draft(path, text). Its
arguments arrive structured, so nothing has to be parsed. Three rules
keep that move to one new adapter, with core/ unchanged:
decide and the guard work on chitragupta's own command and scope,
not on a harness's payload.core/.--allowedTools). It
cannot follow a session that reads, then initialises a dossier, then
drafts, then reviews. Each widening would mean a restart.= form, and they cannot express
figure sync --check.