Status: reference.
How chitragupta protects the locally managed research corpus and its derived artefacts, where its trust boundaries are, and what remains the operator's responsibility.
Written for users operating a corpus and developers changing the pipeline or its release automation.
Assumed: ARCHITECTURE.md for the four-layer design, CLI.md for commands, and CONFIG.md for settings. Not covered here: a general system overview, an organisational security policy, or a guarantee that untrusted documents and tools are safe to execute.
Chitragupta is a local-first research-corpus pipeline. It reads the
BibTeX and PDF files that you manage, writes derived artefacts below the
configured content directory, and uses locally installed tools such as
pdftotext, Pandoc, and TeX Live when a command needs them.
Its main security goals are to keep ordinary pipeline processing bounded to the configured project, preserve the provenance of citekeys, avoid shell interpolation when it invokes local tools, and limit credentials in the release path.
This project does not claim to provide:
PATH;The citation gate is deliberately narrow: it verifies that a citekey in a draft exists in the synced ledger. It does not determine whether the citation is relevant, accurate, or sufficient. The advisory review tools and, ultimately, the author remain responsible for those judgements; see ARCHITECTURE.md.
| Asset | Why it matters | Trust boundary / owner |
|---|---|---|
papers/bibliography.bib and referenced PDFs |
Source bibliography, citekeys, metadata, and source documents | User-managed local input; review imported exports and PDFs before choosing to process them |
config.toml and environment variables |
Select the project, bibliography, content directory, parser, and other runtime behaviour | Trusted operator configuration; environment variables override TOML values |
content/ledger.sqlite |
The synced set of citekeys that the gate treats as authoritative | Pipeline-managed local state under the configured content root |
| Parsed-text, Docling, Chroma, and topic caches | Derived corpus text, embeddings, passages, and topic artefacts | Local derived data; may contain information extracted from the corpus |
| Drafts, dossiers, renders, and review reports | Research drafts and their supporting records | User-reviewed work product; generated prose is not automatically authoritative |
| Local executables and libraries | pdftotext, Pandoc, LuaLaTeX, Docling, Python packages, and GPU tooling process corpus data |
Trusted local toolchain chosen and maintained by the operator |
| GitHub Actions and PyPI release artefacts | Build, documentation, release archives, wheels, and packages | Repository-maintainer and CI trust boundary |
| An agent harness session (Claude Code, Codex, OpenCode) or another external AI session | A drafting session can receive corpus-derived context or user instructions | Optional external-service boundary; not required by the corpus pipeline |
The deterministic corpus layer does not fetch papers or call an LLM API. It processes the bibliography and attachment paths you provide. The optional drafting workflow uses the skills of an agent harness (Claude Code, Codex or OpenCode; see LLM-AGENTS.md), so any information placed in that session is subject to the AI service, account, client, and network controls selected by the operator. The repository itself contains no LLM API key requirement.
python -m chitragupta.draft gate <draft> reads known citekeys from
content/ledger.sqlite and refuses citations that no corpus sync
recorded. The bibliography is the only citekey source: the pipeline does
not generate, rename, or fetch citekeys.
Before sync creates derived filenames, chitragupta/core/corpus/bib_reader.py
rejects citekeys unsafe for filesystem use. An unsafe entry is skipped
with a warning rather than silently rewritten. The same validator
(chitragupta/core/citekey_safety.py) also guards the review layer's reads:
citekeys there are extracted from a draft, not the bib file, so a draft
citing \citep{../../secret} must resolve, and does resolve, to no
source text rather than to a file outside the content tree. Every
per-citekey file name is built by citekey_safety.citekey_path(), which
refuses such a key, so a command-line citekey such as
draft tldr show ../../x is refused too, before any file is read.
The drafting skills run the gate before presenting a draft. On Claude
Code, Codex and OpenCode, a hook or plugin also runs it after writes
the agent's own file tools make under content/drafts/
(HARNESS.md). It does not see a write made through the
shell, Continue runs none of these hooks, and Codex behind llama.cpp is
never offered the hooked tool (LOCAL-MODELS.md), so
not every draft write is checked automatically. draft render runs the
gate in every case.
Because this is a post-write check, an invalid draft can exist on disk
until it is corrected. Run the gate yourself before sharing, rendering,
committing, or relying on a draft. HOOKS.md documents the
hook boundary and its launcher checks.
Commands that accept draft paths use
config.require_inside_content() before reading or writing them.
chitragupta/core/config_path.py resolves both the candidate path and
CONTENT_DIR before comparing them. This makes .. components and
existing symlinks answer for their actual destination rather than their
textual spelling.
The rendering and review paths apply additional output-directory checks so a configured or encountered symlink cannot redirect their derived output outside the resolved content root. These checks define the configured content directory as the pipeline's working boundary; they are not an access-control system, and path validation cannot eliminate a race with a process that can alter the filesystem concurrently.
The files a draft references get the same treatment. A figure or image
reference is resolved before the figure-layout aid compiles it or a
render copies it beside the output. One that lands outside the draft's
own directory is skipped, whether it is absolute, ..-escaping, or a
symlink (of the file or of a directory on the way to it). A render goes
further for the symlink case: pandoc and the TeX engine open a draft's
images and \input files by the name the draft spells, so a draft that
names one through a symlink out of its directory is refused with
[error] before either tool runs, rather than rendered without it. A
link that stays inside the draft still works. A .tex draft's preamble
file (<slug>.preamble.tex or preamble.tex beside it, which its
preview loads) is refused the same way, since pandoc reads it with no
fence.
chitragupta.core.draft.dossier exports and restores draft records as tar.gz
bundles. Restore is a dry run unless the operator supplies --force.
Before extraction, chitragupta/core/draft/dossier/_archive.py refuses the entire
archive if a member is not a regular file or directory, is absolute,
contains .., or is outside the allowlisted top-level roots:
drafts/, dossiers/, rendered/, and review/. Extraction also uses
Python's tarfile filter="data" protection. These checks resist common
traversal, link, device-node, and unexpected-root archive attacks; they
do not make restored Markdown, TeX, PDFs, or other regular files
semantically trustworthy.
The Python implementation invokes local commands through argument
vectors, including the PDF extractor and the Pandoc command built by the
render module. The repository has no subprocess call with shell=True.
This avoids passing corpus paths and tool arguments through a shell
parser. It does not protect against vulnerabilities or unsafe behaviour
in the called executable, a malicious executable earlier on PATH, or
dangerous content interpreted by the toolchain. The PDF and rendering
sections of CLI.md identify which commands require local tools.
Every program that chitragupta/ and .claude/hooks/ launch is run by
absolute path, resolved by chitragupta/core/programs.py from the absolute
entries of PATH and nothing else. OpenCode's adapter,
.opencode/chitragupta/gate.js, applies the same rule in Node before it
spawns python. A bare name handed to
subprocess.run would leave the lookup to the OS, and on Windows
CreateProcess searches the current directory before PATH, as
shutil.which does there too. On any host a relative or empty PATH
entry is the current directory under another name. The current
directory is often a cloned or shared project, so a pdftotext.exe or
python.exe planted in it would otherwise run with the user's
privileges. The same applies to the TeX engine Pandoc starts, whose
--pdf-engine is passed as an absolute path; what Pandoc or TeX start
in turn (rsvg-convert for an SVG figure, say) is their own lookup and
outside this. On Windows a name gets .exe, as CreateProcess would
give it, so a .bat or .cmd earlier on PATH is never chosen: a
batch file runs through cmd.exe, which re-parses its arguments. An
absolute PATH entry
inside the project, such as an activated .venv/bin, is still
searched: that entry is the operator's choice, not the directory's.
tests/test_bare_launch_scan.py scans every launch in both directories and
fails on one whose program is not resolved this way, and fails on any
child_process launch in the repository's JavaScript whose program is
a string literal.
Every TeX engine this codebase starts (LuaLaTeX, for a pdf render
through Pandoc and for the figure-layout aid's probe) runs with
-no-shell-escape and behind a read fence, both set in one place,
chitragupta/core/tex_engine.py. The first turns off \write18 entirely,
including TeX Live's default restricted allow-list. The second is a
LuaTeX find_read_file callback, assets/latex/chitragupta-read-fence.lua,
loaded with --lua: after the main file, TeX may not \input or
\openin a name with a .. component or a component starting with a
dot, nor an absolute name outside the directory the main file is in
(pandoc's own temp directory, where it copies a draft's images); a
relative name found on the search paths (TEXINPUTS, the TeX
installation) is still allowed. A refusal is written to the log as
chitragupta: refused TeX read of <name>. A draft whose raw LaTeX says
\input{/home/alice/.netrc} therefore fails to render and names the
file instead of printing it. Underneath it, kpathsea's openin_any=r
refuses dot files too.
Why a callback and not kpathsea's openin_any=p. Since TeX Live
2024, p restricts absolute paths to TEXMFOUTPUT, and luaotfload
opens ScriptExtensions.txt by absolute path from texmf-dist on every
LuaLaTeX run, so under p every render fails on a current distribution
before TeX prints a line; pandoc sets TEXMFOUTPUT itself, so no variable
can widen it. TeX Live 2026's kpathsea drops the read check entirely,
so there p would fence nothing while appearing set. The callback is in
the engine, so it behaves the same on every TeX Live, and Lua's own
io.open, which the font loader uses, does not pass through it. Pandoc's own
--sandbox is deliberately not used: it confines Pandoc's reads, not
the engine's, and it drops a docx render's images.
Not measured: MiKTeX. MiKTeX, the TeX distribution
docs/WINDOWS.md installs, does not use kpathsea, so
openin_any means nothing there. The fence is a LuaTeX callback and
recognises a C:\ name as absolute, so it should hold there too, but
whether MiKTeX's lualatex honours --lua has not been measured. The
.bib path stays closed regardless, because the Lua filter below does
not depend on the engine. A Windows host that renders drafts someone
else can write should use TeX Live until it has been.
A .bib field's TeX does not reach the engine as code. pandoc's
BibTeX reader turns a command it does not understand into raw LaTeX, and
keeps $...$ as a math node whose source it prints verbatim; citeproc
carries both into the reference list. Every render that runs citeproc
(all but --fragment) therefore runs
assets/pandoc/bib_raw_tex_as_text.lua just before it, which rewrites
every bibliography entry citeproc is about to read so that its raw TeX
prints as literal text, and does the same for a math node that contains
one of the few primitives that run code or reach a file (\directlua,
\csname, \input, \write and the like). A shared .bib whose title
says \input{/home/alice/.netrc} or \directlua{...}, in text or
inside $...$, renders with that text visible and nothing read or run.
Ordinary content is untouched: accents, \emph, \textsubscript and
plain mathematics such as $\alpha \leq \beta$ are left exactly as the
reader produced them.
Accepted residual: Lua in the author's own TeX. A pdf render runs
LuaLaTeX, which embeds a Lua interpreter, and the read fence and
-no-shell-escape fence TeX's own file access, not Lua's. (That Lua
could also unregister the fence's callback.) TeX in a
draft body or in a figures/*.tex file can run Lua with \directlua,
or with an equivalent built through \csname, so a blocklist on the
text cannot catch it. That Lua can read any file the user can read,
write anywhere the user can write, and read environment variables
(measured on TeX Live 2023: plans/996-unicode-pdf-engine.md, Q2).
The project accepts this: a draft and its figures are the author's own
text, and rendering one is running it. Only the .bib path, which
carries a collaborator's text, is closed. In a shared tree where
someone else can write your drafts or figures, treat a pdf render as
running their code. Two possible follow-ups are recorded and not
implemented: confining Lua inside LuaTeX, and running the engine under
a Landlock ruleset (available on this host: Linux 5.15, Landlock ABI 1).
The fence judges a name as TeX spells it and follows symlinks, which is why the render refuses a draft's own symlinked references itself (above). Five limits follow:
LaTeX's \IfFileExists tests whether a file exists through Lua's
file system library, not the callback, so a draft can still learn
whether a file outside it exists, though not what it says.
A name that is not in the draft's text (one in a bibliography field, say) that points at a symlink someone planted in the draft's directory is still followed.
A tex output and a --fragment unit carry the same raw LaTeX to
whoever compiles them later, with their own engine and their own
settings, which this project does not control.
An .eps figure does not convert, because graphicx converts one
through repstopdf over shell escape; use a PDF or PNG figure instead.
Pandoc compiles in the system temp directory, so a pdf render needs
a TMPDIR with no dot-directory in its path (not ~/.cache/tmp). One
that has one is reported before Pandoc runs.
chitragupta corpus sync reads a user-supplied BibTeX export and its
referenced local PDFs. It writes the ledger and parsed text locally. It
does not download papers, crawl a source, or call an LLM API.
The optional enrichment layer also processes the same corpus locally, but some optional model dependencies may download models on first use. Review the model and package source before enabling that layer. See CONFIG.md and CONFIG.md.
corpus discover --html FILE and --app DIR write pages a reader opens
from file:// and may pass on. Topic labels, titles and citekeys in them
are corpus-derived, and a label can come from a PDF's extracted keywords.
So every string that is built into markup goes through a five-character
escape (&, <, >, " and ') in both pages, and the --app
directory's index.html also declares a Content-Security-Policy
(default-src 'none'; script-src 'self'; style-src 'self' 'unsafe-inline'; img-src data:; base-uri 'none'; form-action 'none').
Under that policy, markup that gets past the escaping still cannot run an
inline handler, re-point the page's relative URLs with a <base>, or
submit a form. The single-file --html page carries no policy: its
script is inline by design, so script-src 'self' would block the page
itself.
chitragupta webapp (#1262, from the optional webapp extra) serves the
webapp, a page built from frontend/ into assets/webapp/app/, and
runs the project's coding agent, one Claude Code process, one
codex app-server or one opencode serve per browser tab
(WA-1, #1261). Anyone who can send it an authenticated request could
prompt that agent, so the server is built to be reachable only from
the author's own browser, on the author's own machine, with a secret it
printed for them:
chitragupta/webapp/_server.py
binds the constant 127.0.0.1 itself and refuses to serve if the
bound address is not loopback. There is no flag, config.toml key or
environment variable for another address. To reach it from another
machine, use your own SSH tunnel:
ssh -L PORT:127.0.0.1:PORT HOST.chitragupta/webapp/_middleware.py) wraps the whole app and runs every
check before routing, in a fixed order: Host must be exactly
127.0.0.1:PORT or localhost:PORT (this closes DNS rebinding, and
runs for static files too); only GET and POST; under /api/, an
Origin of this server (required on POST), the bearer token, and a
1 MiB body limit (a POST with Transfer-Encoding is refused, since
a chunked body is not bound by Content-Length). A security header
sent twice is refused. Routes never authenticate, and a test walks
every route to prove a tokenless request cannot reach one.secrets.token_urlsafe(32), new on
every start, carried in the URL fragment (/#token=...), which a
browser never sends to a server. The page moves it to sessionStorage
and removes it from the address bar. Cookies on 127.0.0.1 are shared
by every port on the host, so none is set. The browser is opened on a
private redirect file (open.html, mode 0600), so the token is never
on a process command line that ps would show another user.open.html, server.json and
the server's lock live in a per-user folder outside the project:
$XDG_STATE_HOME/chitragupta/<hash>/ when XDG_STATE_HOME is an
absolute path, else ~/.local/state/chitragupta/<hash>/, and
%LOCALAPPDATA%\chitragupta\<hash>\ on Windows. <hash> is the
first 16 hex digits of the SHA-256 of the project's resolved root
(case-folded on Windows), so each project finds its own server. The
folder is 0700 and each file 0600; open.html is removed when the
server stops. A start deletes what an older version left in
content/.webapp/ (open.html, server.json and the lock's two
files, each only when it is a regular file, never through a symlink),
then that directory if it is empty. chitragupta webapp --json
prints the folder and each file's path, and whether a server runs,
with its port and its URL without the token. An agent's read, write
or command line naming any project's folder there is refused
(APPROVAL-MODEL.md), and a recursive search of
the project meets no token.Content-Security-Policy: default-src 'self'; script-src 'self'; style-src 'self'; connect-src 'self'; img-src 'self' data:; object-src 'none'; base-uri 'none'; form-action 'none'; frame-ancestors 'none' (the page's own adds a style nonce,
below), plus nosniff and no-referrer; a route cannot weaken them.
No response carries a CORS header. The built index.html loads one
external module script and one stylesheet, with no inline script or
style. Vue's templates set text, never markup:
ESLint refuses v-html (vue/no-v-html) and a static style
attribute, which Vue can turn into the inline style this policy
blocks.v-html, for the Help sheet's own docs. HelpArticle.vue,
the only file ESLint lets use it, shows an HTML fragment the build
converts from a page of the docs site's nav (frontend/build/, with
markdown-it), never anything from the agent, the ledger or a
request. Raw HTML in a doc keeps only its text; an outside image
becomes a link; table alignment becomes a class. The build fails on a
fragment holding a <script>, <style>, <iframe>, <object> or
<embed> element, a style or on⦠attribute, or a src that is
not relative, and when the help folder outgrows its size cap. The
page fetches the fragments and their images from this server's
static files, with no token and no change to the policy.'unsafe-inline'. The page
(/ and /index.html) is served by a route, not as a static file:
the middleware picks secrets.token_urlsafe(16) for each load, the
page's policy reads style-src 'self' 'nonce-<n>', the route writes
the same value into its <meta name="csp-nonce">, and the page is
never cached. The resizable panes' library, Reka UI, sets its drag
cursor by appending a <style> element; the page passes the nonce to
Reka's ConfigProvider, which labels that element with it. A
<style> without this load's nonce, such as one an agent's reply or a
parsed passage carried into the page, is still refused, and the
end-to-end test plants one, with no nonce and with the previous
load's, to prove it. Static files carry the policy above, with no
nonce. No path with a segment that starts with . is served, so the
build's .vite/manifest.json (read only by the build's size check)
is not, and scripts/release.py leaves it out of the release zip,
the wheel and the sdist.
api/client.ts checks every body it fetches against its
schema before a view reads it, and refuses one that does not match,
and api/agent.ts does the same for every event on the agent's
stream; the Agent pane shows the agent's words as plain text, and the
Paper pane shows each parsed passage as plain text too;
the validators are Ajv's standalone output, with no eval or
new Function, so script-src 'self' holds._middleware.py has no
development-only branch. npm run dev in frontend/ generates the
API types and validators, then runs vite build --watch, so the page
a developer works on is a build
that chitragupta webapp serves under the policy above. Vite's
development server would inject <style> tags and run without that
policy. With no build, chitragupta webapp refuses to start (exit 2)
rather than serve anything else;
PACKAGING.md has the two
forms of the message.e2e job builds
the app, starts python -m chitragupta webapp --no-browser --agent claude on it, with a stand-in claude on PATH (the fake Claude
Code of the Python tests, which runs no model), and once more with
--agent codex and a stand-in codex, and with --agent opencode
and a stand-in opencode, with CODEX_HOME and the XDG directories
in a scratch directory, and
drives it in headless Chrome and Firefox at four widths, resizing and collapsing
the panes, opening their sheets, streaming the agent's replies,
answering its approval cards and reading the sample project's
papers.
It fails on any
securitypolicyviolation event, console error, failed request or
error status. DEVELOPER-AGENTS.md's "Before claiming a task
complete" says how to run it locally./docs, /redoc and /openapi.json are off. uvicorn is
pinned to the h11 parser whatever else is installed, runs with no
WebSocket stack (and the middleware closes any handshake that reaches
the app), trusts no X-Forwarded-* header, and keeps its access log
off. A malformed request that uvicorn itself rejects gets its own
fixed-text 400, without the headers above.WebSocket API cannot
send an Authorization header, so the token would have to travel in a
query string, a cookie or a first message, and each breaks a rule
above: the token stays out of URLs, no cookie is set, and no
connection reaches the app before every check has passed. Browsers do
not apply CORS to a handshake, so any page the author visits could
open one (cross-site WebSocket hijacking), and the Origin check
would have to become mandatory for upgrades. A frame parser would also
run inside uvicorn before the middleware sees anything, and the 1 MiB
Content-Length limit does not bound its messages. Streamed replies
need none of this: they are ordinary HTTP responses read with
fetch (the agent's stream answers a POST), which carries the
bearer header and passes every check.
EventSource is not used, for the same header reason.GET /api/paper opens
the ledger read-only, so a missing ledger is refused and never
created, and a test compares the whole project tree before and after
it serves every rung of the passage ladder.GET /api/corpus/ledger writes nothing, and GET /api/draft/retrieve/search writes only the named search cache,
content/retrieval_index.json, when the corpus has changed since it
was built; it takes no --log, so it never writes a dossier. Tests
compare the whole project tree before and after.GET /api/draft/dossier/status, GET /api/draft/tldr/show and GET /api/draft/figures answer with what dossier status --json, tldr show --json and figures --json print, run under the read-only
scope, and a test compares the whole project tree before and after.GET /api/draft/dossier/status?steps=true, GET /api/draft/dossier/outline,
GET /api/draft/gate, GET /api/review/synthesis, GET /api/draft/spec/status, GET /api/draft/spec/show and GET /api/draft/unit/status answer with what those commands print under
--json, under the read-only scope. Each checks its path before the
core runs (a draft as the agent's scope does, a book under
content/drafts/ with no ..; the gate takes either, and for a book
gates the book.tex in its rendered mirror) and refuses, with 422, a query
parameter it does not declare, so write and formats never reach
review synthesis. The gate runs with no CHITRAGUPTA_GATE_CALLER,
so it records nothing, and a test compares the whole project tree
before and after every input.chitragupta/webapp/_routes/ share one
handler. It refuses, with 422, a query parameter the route does
not declare before anything else runs, so write, apply, log,
origin, formats, accept and baseline never reach a builder
that would write. It bounds every value (a string 1 to 512
characters, a list at most 64 items, a number within a ceiling) and
calls the command's builder on the one core thread, under the
read-only scope. A test fails when a route accepts a field that
selects one of the command's write rows in the tier table. The three
review aids that always file (provenance, agenda, digest) run
with filing off under that scope, and figure sync runs only as
--check. A test snapshots content/ and papers/ around every
view, cold and warm, and around the CLI's own runs, and finds nothing
changed but the search caches, content/overlap/ and
content/chroma/, which chromadb rewrites whenever a process opens
the embedding index, the CLI's included.confined() (webapp/_paths.py) joins the path to the project
root, resolves its links, and refuses with 403 one that lands
outside (.., an absolute path, a symlink out, a symlink loop, a
NUL byte). The core resolves a relative path against the working
directory, which the server never changes, so the path reaches the
builder as seen from there: a server started in another directory
reads the same files as the CLI run from the root, and a test proves
it for every route that takes a path. A draft outside content/
still reaches the core, which refuses it as the CLI does.POST under chitragupta/webapp/_routes/, with one handler. Its
body is a model that refuses, with 422 and before the core runs,
any field it does not declare, so write, accept, output_dir
and every other selector of another row never come from the
browser: the route fixes them. A test binds each route's arguments
and finds exactly its own row of the tier table selected. Every path
in a body is confined as above; an output path is confined to
content/rendered/ or content/review/ (OUTPUTS, RENDERED), so
a typed draft path can never be overwritten. The builder runs on the
one core thread as a person's click, unrestricted, and a second
request for the same output while the first runs is refused with
409 until that call ends, even after its client has gone. No module
under chitragupta/webapp/ imports argparse or the CLI, which the
import-direction test enforces. The agent reaches the same commands
only in its own shell, through decide.POST /api/corpus/sync and POST /api/enrich start python -P -m chitragupta.corpus sync --json or python -P -m chitragupta.enrich --json with the server's own interpreter, package and project, from
a list of arguments built from a validated body, never a shell and
never free text; a value is joined to its flag with =, so a path
that starts with - is never read as an option. --reparse and
--remove-stale are sent only when the body also lists them in
confirmed, which the page sets only from its confirmation dialog;
a body without it is 422 and starts nothing. One job runs at a
time (409 for a second). The child takes the writer lock itself, so
a terminal writer and a webapp job refuse each other with the CLI's
exit-2 refusal; the server never takes or probes that lock. The
child leads its own process group (a new process group on Windows):
Stop sends it what Ctrl-C sends, then terminates and then kills the
whole group after a grace, and the server's stop runs the same
escalation before uvicorn's own shutdown, so no process of a job
outlives the server. Its lines stream to the page as server-sent
events (GET /api/jobs/{id}/events), relayed as the child wrote
them and validated by the page before it shows them. The agent can
never start either: decide denies both commands in every spelling
and under every scope, before any card is drawn, and the routes need
the token, which is outside the project tree./api/, with the token.
GET /api/output serves one file a write produced: a path in
content/rendered/ or content/review/, or a dossier archive
(drafts-*.tar.gz) directly in the project root, as an attachment
with the headers every /api/ answer carries. Any other path, a
draft or config.toml included, is 403, so it is no general file
reader. The static mount holds only the built page and no route
writes there, so no output is ever served without the token. The page
saves a file from a blob URL, and opens a PDF in a new tab from one,
typed application/pdf by the page and with no opener; it embeds
none, since object-src 'none' and the default frame-src refuse an
<object>, an <embed> and an <iframe> of a blob, and the policy
is unchanged.corpus sync keeps working alongside.--permission-prompt-tool stdio and a PreToolUse hook that answers
ask for every call, so every call reaches the server as an approval
request, an auto-allowed read and a subagent's call included, and
decide answers it (APPROVAL-MODEL.md). allow
and deny are answered at once; ask waits for the person with no
timeout. An error while judging a call, a crash, an interrupt, a
closed tab and the server stopping each answer deny. Nothing passes
--dangerously-skip-permissions or --allowedTools. The residual
case: a hook that cannot start at all fails open for a call Claude
Code would allow by itself, a read inside the project (measured); the
hook's own errors and its deadline exit 2, which blocks the call.--agent codex, each tab's thread runs with approvalPolicy: "untrusted", so every command and every patch reaches the server as
an approval request, judged by the same decide as Claude Code's
calls; the server answers accept or decline, never an answer that
holds for the session or amends Codex's rules. A Codex hook's ask
and allow are ignored, so no hook carries policy. A call that runs
without a request (a tool or item type a later release adds, web
search, an MCP tool, a call that outputs before it was allowed) trips
a tripwire: its pending requests are declined and the turn is stopped.
A model Codex drives through its code-mode exec tool still asks for
every command; its collaboration, clock.sleep and asynchronous
message tools are not mapped, so a turn that uses one stops.
No Codex setting turns off its own list of commands it counts as
safe, so at every start, before any prompt, the server probes it: an
ephemeral thread under the same policy, whose model is a stand-in on
127.0.0.1 that calls ls once. Codex must ask; if it runs ls, never
asks, or does not finish within 30 seconds, the session stops with a
refusal. A command line is judged after taking off Codex's login-shell
wrapper only when the wrapper's program is literally the account's
login shell or an sh, bash or zsh on PATH, in /bin or in
/usr/bin that root owns along its whole path; any other program,
such as ./evil/bash or a link the agent made, is judged as the whole
line. Nothing is unwrapped on Windows.chitragupta-webapp/<16 hex> under the person's
Codex home ($CODEX_HOME, else ~/.codex), named for the project
root, mode 0700, and keeps it after the server stops: it holds the
conversations, which the header's resume command reopens. Its
config.toml is rewritten whole at every start from the person's
model keys only, so no command rule, hook, MCP server or profile of
the person's reaches it, plus fixed keys: approvals by the person, no
web search or image viewing, and Codex's default-on extras off (apps,
image generation, browser and computer use, plugins, a model's review
of approvals, MCP sign-ins, a background daemon, sleep, goals and
the newer subagent tools). After start, config/read and the thread's
own answer are checked against every fixed key. A wrong value, or a
missing key outside [features], stops the session before any prompt.
A [features] key Codex does not report at all, which a newer Codex
may have dropped or renamed, is a warning on the page and in the
server log, and the session runs on. Every key config/read reports must
come from the home's own config.toml: a key a project's or the
system's config sets stops the session, and so do an MCP server or a
profile from anywhere. Codex 0.173.0 trusts a project nobody decided
about at its first full-access thread and then loads the project's
.codex/ config, command rules and hooks, so the home writes a trust
decision for the root and its repository: the person's own, taken
only from an exact match of real paths, else untrusted. A project
whose .codex/rules/ holds anything, in the root or up to its
repository's root, is refused at start, since config/read does not
report rules. auth.json is a symbolic link to the
person's, so a login refreshes both; where no link can be made it is a
copy, copied back only when the person's did not change meanwhile.
The sandbox is danger-full-access: Codex's bubblewrap sandbox fails
in containers and on hosts that restrict user namespaces, and the
policy is decide and the scope guard on every harness. So there is
no kernel-level network denial, as on Claude Code. Nothing under the
person's Codex home or $CODEX_HOME may be read, named or written by
the agent by any route, which also leaves Codex's own skills in that
home unreadable to it; the project's .agents/skills/ still load.--agent opencode, each tab's session runs with a session rule of ask for
every tool, so every call reaches the server as a permission.asked
event, judged by the same decide; the server replies once or
reject, never always, which in OpenCode grants a wider pattern
and overrides a configured deny (measured). A request that arrives
before its call's input is held for up to 5 seconds, then rejected,
never decided on an empty input. OpenCode's task (subagents) and
its own customize-opencode skill are denied by rule, and questions
are rejected. A call that runs without the webapp's once (a tool a
later release adds, a part with no call id) trips a tripwire: an
error on the page and the turn is stopped. At start the server's
config is checked, every tool it lists that the webapp does not run
is denied by rule, and the session's rules are read back; a mismatch
stops the session before any prompt. OpenCode
1.19.6 or later and rg on PATH are required.chitragupta-webapp/ under the person's OpenCode data directory
($XDG_DATA_HOME/opencode, by default ~/.local/share/opencode),
mode 0700, and keeps it after the server stops: it holds the
conversations, which the header's resume command reopens, and it
grows with them. The server runs with its config, data and state
directories there and with every inherited OPENCODE_* variable
dropped, so the person's own config, inline config, plugins, MCP
servers, permission rules and instructions never reach it. Its
opencode.json is rewritten at each start from the person's model
and provider keys only, plus fixed keys: ask for every tool, web
fetch and search denied, sharing, auto-update, snapshots, formatters,
LSP and MCP off. The login is linked to, or copied from, the
person's, as for Codex. The agent may not read, name or write the
person's OpenCode data or config directories by any route, under any
harness.127.0.0.1 on a port the system picks, never with
--mdns or --cors, and requires HTTP basic auth with a password
from secrets.token_urlsafe, new for every process and passed in its
environment only. The agent's shell does not get it: the webapp's
plugin removes it from shell.env, and decide refuses any line
naming OPENCODE_SERVER_PASSWORD. A line that could print the
environment without naming it asks every time. A program running as
the same user can still read the process's environment, the same
residual case as the scope file.tool.execute.before
for every call and throws on a deny or on a tool the webapp does not
run, so a call the approval channel never carried is still refused;
it fails closed when the hook cannot run, times out or gives an
answer it cannot read. It writes a ready file
when it loads, and the server sends no prompt until it has. The
plugin and the server both refuse writes to the root's
opencode.json and opencode.jsonc, whatever is answered.rg x content, grep -r x content/drafts, find content) asks for one call only, since nothing private is under the
root. The approval policy still refuses a recursive search on a line
that changes directory, any line naming a search program it cannot
place (which rg, watch rg x content/drafts), and a shell line
naming a draft file named like one (cat content/drafts/tree.md),
under every harness. This over-denial is accepted by the owner's
decision: it fails closed, and the agent's file tools still read
those files. APPROVAL-MODEL.md lists them.tempfile.mkdtemp (mode 0700 on POSIX,
under the user's profile on Windows). Each session's scope file is
written in it with mode 0600 through a temporary file, and the
agent's environment holds only its path. The directory and
everything in it are removed when the server stops. Permissions
cannot stop an agent that runs as the same user, so decide refuses
any call that names the directory or the variable. No route lets the
agent change the file: only a person's once adds a one-shot entry,
for exactly one plain python -m chitragupta.<layer> command, and
the server removes it when the call ends.closed, denies every pending approval and stops every
process, before uvicorn waits for open connections to finish.sync and chitragupta enrich use the same SQLite-backed mutex at
content/pipeline.lock.db. The lock holds BEGIN IMMEDIATE; a
competing writer exits with code 2 rather than interleaving writes.
Read-only operations deliberately remain available while a writer runs.
A sync or enrich started from the webapp is the same command in a child
process, so it takes the same lock and meets the same refusal; the page
shows that refusal as the CLI prints it.
This prevents the pipeline's own writers from overlapping on a local
filesystem. SQLite locking is not reliable on network filesystems, so
this control assumes content/ is local storage. Treat a local
filesystem as an operational requirement for writer safety, not an
optional tuning choice.
ARCHITECTURE.md describes the
lock and its scope, and
Operational requirement: local filesystem for runlock
states the deployment requirement and mitigations.
The checkout uses uv.lock to fix resolved Python package versions
and hashes. Every locked dependency ships a wheel, so the install path
and the documentation workflow both refuse source builds (uv sync --no-build) and fail on a lock that no longer matches pyproject.toml
(--locked).
The workflows use explicit permissions, scoped per workflow or per job
depending on the file. docs.yml grants contents: read on the build
job and pages: write + id-token: write only on deploy. ci.yml
grants workflow-level contents: read. release.yml grants
workflow-level contents: write, then narrows the publish-pypi job to
id-token: write only. PyPI Trusted Publishing exchanges that OIDC token
for a short-lived token instead of storing a long-lived PyPI API token.
Every action the workflows use is commit-SHA pinned, with a # vX.Y.Z
comment naming the release the SHA was resolved from. Four of them are
third-party actions that publish releases, publish to PyPI, or upload
external analysis: softprops/action-gh-release,
pypa/gh-action-pypi-publish, codecov/codecov-action, and
SonarSource/sonarqube-scan-action. The rest are GitHub's own
actions/*, pinned the same way although Sonar's S7637 does not flag a
major tag on them: a tag can be moved to point at different code
whoever owns the action, and
actions/download-artifact is the one step between the built wheel and
the PyPI publish. So .github/dependabot.yml proposes the pin bumps as
one grouped weekly PR, and DEVELOPER-AGENTS.md's "Issues and pull
requests" says how to finish one.
The webapp's npm packages are pinned to exact versions in
frontend/package.json, with frontend/package-lock.json, and every
install runs npm ci --ignore-scripts, so no package's install script
runs. The build writes the bundled packages' licence notices into
assets/webapp/app/THIRD-PARTY-LICENSES.txt and fails on a licence
outside an allowlist, which
THIRD-PARTY-NOTICES.md
names. The check is part of the build, so CI's frontend and e2e
jobs, scripts/check_local.sh and scripts/release.py all stop on it.
It checks this repository's dependencies, never a draft.
The release workflow installs uv wheels-only
(--only-binary=:all:), like the CI and documentation workflows. A
pinned version fixes which release is installed, not whether pip builds
it, or a dependency, from source when no wheel matches.
Two of the four third-party actions consume a long-lived repository
secret rather than an OIDC token exchanged per run:
secrets.CODECOV_TOKEN and
secrets.SONAR_TOKEN, both in ci.yml. Those two are the part of this
section worth re-auditing when a maintainer leaves, when a service is
dropped, or on any schedule your organisation applies to third-party
credentials. They cannot expire on their own the way the PyPI publish
path's token does, which is why that path deliberately has no
equivalent.
A PDF is data to chitragupta, but it is input to substantial native and Python parsing stacks. Pandoc and TeX process generated rendering inputs. Keep Poppler, Pandoc, TeX Live, Python, and optional enrichment dependencies current through the package-management process appropriate to your host.
Do not process a suspicious corpus with elevated privileges. For material from an untrusted source, prefer a separate unprivileged account or an isolated disposable environment that meets your organisation's operating requirements. This project does not supply that isolation.
The pipeline runs with the permissions of the invoking account. Restrict
access to the project, bibliography, PDFs, content/, logs, backups, and
archives according to the sensitivity of the corpus. Check ownership and
permissions after running installation or scheduled jobs, especially when
using sudo.
Backups and dossier export bundles can contain drafts, review reports,
and rendered outputs. Protect them with the same care as the original
corpus.
dossier restore validates archive member type and path before
extraction. It refuses links, device nodes, traversal paths, and members
outside drafts/, dossiers/, rendered/, and review/.
Those checks reduce traversal-style risk, but the current implementation
does not enforce hard limits on member count, per-member size, or
total extracted bytes. A path-valid archive can still consume excessive
disk space, inode budget, memory, or runtime when restored with
--force.
Operator guidance: restore only trusted archives, keep the default dry run first, and preflight unusually large bundles before extraction. When possible, restore in a quota-limited workspace or disposable environment so an oversized archive cannot exhaust shared host resources.
The runlock (content/pipeline.lock.db) and the ledger depend on SQLite
locking semantics that are reliable on local filesystems. Treat local
storage for content/ as a deployment requirement for any writer
workflow (sync, enrich, and scheduled runs).
On network or synchronised filesystems (for example NFS, SMB, or cloud-sync mounts), lock visibility and ordering are not reliable. That can allow overlapping writers, partial-read races, and inconsistent pipeline state despite the lock file being present.
Mitigation options: keep the writable content/ tree on local disk; use
one designated writer host and replicate outputs afterwards; or serialize
writes through external orchestration while avoiding shared writable
network mounts for the active pipeline state.
CONFIG_PATH, CHITRAGUPTA_PROJECT, BIB_FILE, CONTENT_DIR, and the
other documented setting environment variables can alter which files are
read or written and which optional components run. Environment values
override config.toml.
Use an explicit, minimal environment for cron, systemd, CI, or other
automation. Do not run scheduled jobs from a shell profile that imports
unreviewed environment variables. Limit write access to config.toml and
avoid pointing CONTENT_DIR at a shared or unintended location.
CONFIG.md gives the precedence
rules.
The citation gate proves citekey membership in the ledger, not factual correctness, citation entailment, copyright compliance, or the absence of harmful wording. Review generated drafts, citations, quotations, references, and final rendered output before publication. The review commands are evidence for a human decision and deliberately do not block a draft.
The controls above stop other machines, other web pages and other users who cannot read your files. They do not stop:
-L, Docker -p, VS Code or
Codespaces port forwarding extend the server's reach to whoever can use
the forward. The Host check refuses forwarders that rewrite Host;
one that preserves it leaves the token as the only barrier.open.html, which holds the token while the server runs,
just as it can read the project itself (see "Local permissions
remain decisive").sessionStorage.codex.exe on PATH: npm's codex.cmd goes through
cmd.exe, which re-reads its arguments, so it is refused by name.
OpenCode on Windows is not measured either: its XDG directories, the
login link and the plugin's shell.env there are untested.Parsed PDF passages are untrusted text, and an agent drafting from them
can be told by a passage to do something the person never asked for.
In the webapp and in a terminal session of Claude Code, Codex or
OpenCode, every tool call the agent makes is checked by the same policy
in chitragupta/core/policy/ before it runs
(APPROVAL-MODEL.md): corpus sync and enrich
and the network are denied outright, and so is a file tool's write to a
.bib file, papers/, the ledger, or the hooks, skills and agent
configuration, its relative path read from the session's working
directory. A shell line that writes one of those is denied outright
only under Codex and OpenCode, and only when the line names it (see
below). Whether the rest of what lies outside the read tier asks a
person depends on where the agent runs, as below.
chitragupta init writes
denies what the policy denies, in bypass mode too. Claude Code asks
with the reason, sign-offs included. Codex cannot be made to ask, so
its hook only denies, refuses sign-offs with the command for the
person to run, and leaves everything else to Codex's own approval
mode, which asks for every command and patch only under untrusted:
under on-request a command or write inside the sandbox runs without
asking. OpenCode's plugin denies and refuses sign-offs, and every
shell call and file edit asks through OpenCode's own patterns until
the person answers "Allow always". A chitragupta command line under
Codex or OpenCode passes only as a plain command on the policy's list,
and a line the policy would ask about is refused there when one of
its words, read from the session's directory or one a plain cd
moves to, names or could glob a .bib file, papers/, the ledger,
.claude, .codex, .agents, .opencode, the root's AGENTS.md
or CLAUDE.md, its opencode.json[c], the root itself or a
directory holding one of them, holds an expansion the policy cannot
read, or when the line changes directory in a way the policy cannot
follow (cd -, git -C, env -C, ...). A plain read on the read
list is not checked. Claude Code asks about such a line instead
(APPROVAL-MODEL.md).
Static deny rules generated from the same data stand behind the hook,
for Claude Code and OpenCode.What remains, and what to do about it:
untrusted, and in OpenCode
after "Allow always", only the literal denies hold. The policy
denies what it can see in a command line. Its line rules are
best-effort checks of the text, which cannot match what a shell does
exactly: they narrow what an injected agent can do in those modes but
do not make them safe, so use Codex's untrusted approvals and
OpenCode's prompts. An injected agent can still
reach the network or record a sign-off through code it hands to an
interpreter (python -c with names built from encoded strings,
base64 -d | sh, perl -e), or by writing a script and then running
it, because what that code does is not in the line. Such a call asks a
person under Claude Code, under Codex's untrusted approvals, and in
OpenCode before any "Allow always"; anywhere else it runs. The same
holds for a protected path the line computes rather than names or
globs (code handed to an interpreter, a script that opens the file)
and for a program that changes files it was not told about
(an archive unpacked over them with tar xf or unzip -o): only
what the line names or globs is refused. Git under Codex and OpenCode
is limited to a plain git with a listed subcommand (status,
add, commit, log, diff, show, rm, mv, listing branch
and tag, and a few other reads), with no option that runs a program
or writes a file, no clean, alias or config word and no GIT_*
variable on the line, no other variable set on a line that runs git,
and the agent may not write any .git directory, a .gitattributes,
.gitmodules or .gitconfig, the person's ~/.config/git/ or
/etc/gitconfig; any other git line is refused.
Git 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. Run Codex
with untrusted approvals, and never answer "Allow always" in
OpenCode: its grant is wider than the command it was offered on
(HARNESS.md).chitragupta/ package shadows the installed one
for python -m chitragupta... run from the project root, the same
class of risk as
issue 891.
The hook that chitragupta init writes runs the installed package with
python -I, so it is not exposed. In a project unpacked from the
release zip the hook itself runs the project's own package: writes to
it are denied by the static rules and by the hook, but a Codex shell
line that writes there is not seen as a file write and remains
possible.config.toml is not a protected write. It says where the
bibliography, the ledger and the content directory are, so an agent
that edits it can move the paths the policy protects. Claude Code
asks before such an edit, and OpenCode asks until the person answers
"Allow always" on an edit; Codex's hook, which cannot ask, passes it
to Codex's own approval mode, which asks only under untrusted. Read
any change to config.toml before keeping it..codex/hooks.json on
its own, and a changed hook needs trusting again.
chitragupta doctor reports an untrusted Codex hook, a harness config
without the policy, a hook interpreter that is missing or is not the
one chitragupta runs under, and a release-zip project with no
python on PATH. A Claude Code or Codex hook whose interpreter is
gone refuses every call, since its command ends || exit 2.The corpus, gate, rendering, and review commands do not require an LLM API key. If you use the shipped skills in an agent harness, or another AI-assisted workflow, the session itself may send prompts, excerpts, paths, or other context to an external service depending on your client and settings.
Before using AI assistance with confidential, licensed, personal, or export-controlled research material, assess the service's data-handling terms and your organisation's rules. Minimise the context shared, use an approved account and client configuration, and choose a local workflow when external processing is not acceptable.
papers/, content/, config.toml, logs, and backups under
permissions appropriate for the corpus. Run the pipeline as an
unprivileged user.content/ on a local filesystem. Do not run concurrent writers
against an NFS, SMB, cloud-synchronised, or otherwise shared content
directory.sync and enrich finish; treat exit code 2 as a competing
writer rather than a reason to bypass the lock. Investigate repeated
failures and the pipeline log rather than deleting lock files.dossier restore without --force first. Review the planned new
and overwritten files before permitting the extraction.python -m chitragupta.draft gate <draft> immediately before
sharing or publishing a draft. Then perform the relevant human review
and advisory checks.Do not include credentials, private PDFs, unpublished drafts, personal data, or a working exploit in a public issue.
Check the repository's GitHub Security page and any current
project-maintainer guidance for a private reporting channel, and use that
channel when it is available. GitHub reads docs/SECURITY.md (this file) as the
repository's security policy, so the Security page shows you this text. Do not
take finding it there as evidence that a private channel exists: a policy and a
channel are separate facts. If no private channel is published, disclose only
the minimum non-sensitive information needed to request a private conversation;
do not assume an email address, response time, bounty, or coordinated-disclosure
policy that the project has not published.
A useful initial report states the affected released version or commit, operating system, command or component, expected and observed behaviour, security impact, and safe reproduction steps. Maintainers determine triage, remediation, release, and disclosure arrangements.