# Tiers
Every file under `src/` has a tier, recorded in `ci/tiers.tsv`; `test/pic/tiers.sh` enforces it.
The principle, the tiers and the ladder are in [the keel note](../design/keel.md). This page is the
manifest and the checks.
## Columns
| Column | Values |
|---|---|
| Tier | `core`, `bundled`, `client` (`src/tui/`), `root` (`main.c`, which may name everything), `data` |
| Seam | the published seam a bundled file reaches core through, or `-` |
| Clock | whose change forces the file to change: `durability`, `os`, `vendor`, `pi`, `taste` |
| Why | one line |
Generated `.inc` files (`changelog.inc`, `manual.inc`) are not listed. Committed `.inc` files are
data. An `#include` of a `.inc` is never a tier crossing.
## Checks
`sh test/pic/tiers.sh` runs them; `make test-docs` runs the script and `--selftest`, which plants
a violation for each check in a temporary copy and requires the check to fail.
| # | Fails when |
|---|---|
| 1 | a file under `src/` has no row, a row names no file, or a row has a bad tier or clock |
| 2 | a core file includes a header whose tier is not core and `ci/tiers.allow` does not excuse it |
| 3 | a `src/tui/` file includes a header outside `src/tui/` other than `pic.h`, `platform.h`, `input.h` and `image.h`, unexcused |
| 4 | a core file names a vendor or model (`claude-`, `gpt-`, `gemini`, `deepseek`, `openrouter`, `anthropic`, `openai`, `sonnet`, `haiku`, `opus`, `grok`, `mistral`, `llama`, `qwen`), unexcused |
| 5 | the core `.c` files, as one unit, linked with the vendored libraries and an empty `main` alone, leave a symbol undefined that `ci/tiers.stubs` does not list, or a listed one is defined or unused |
| 6 | `ci/tiers.allow` has more lines than `# allowance:` in the header of `ci/tiers.tsv`, or a line excuses nothing; `ci/tiers.stubs` has more than `# stubs:` |
| 7 | the table below differs from `ci/tiers.tsv` |
| 8 | the core and client files, as one unit, linked the same way, leave a symbol undefined that `ci/tiers.stubs` does not list: the client called a component instead of asking a command |
`ci/tiers.allow` lists today's leaks, one per line with a reason. It only shrinks: when a seam
lands, delete its lines and lower `# allowance:`.
The client's short list holds core headers with no state of their own to share: `pic.h`'s types,
the operating-system seam, input helpers and the image limits. Everything else the terminal
interface needs, a component's answer or the user's state, it asks as a command
(`pic_tui_options.ask`, answered in its process by the same registry `pic --mode rpc` uses), and
check 8 proves it: linked without the bundled files, the interface needs nothing core does not.
`ci/tiers.stubs` lists the symbols core still takes from bundled files, found by linking: many are
declared in `pic.h`, so no include shows them to check 2. It shrinks the same way, under
`# stubs:`. Checks 5 and 8 run when `TIERS_CORE_LINK` names the vendored objects and libraries to
link with; `make test-docs` sets it. They take a few seconds; the planted cases in `--selftest`
take longer, since each compiles core again.
## Adding a file
Add a row to `ci/tiers.tsv` in the same change, then regenerate the table below with
`sh test/pic/tiers.sh --table`. Choose `core` only for a file that answers question 1 or 2 of the
sorting test in the keel note; the default is not core.
## The audit
`sh test/pic/tiers.sh --report [CHECKIN]` prints the lines of core, the allowance, the check-ins
that touched core files since CHECKIN (landing merges are not counted twice), and how many of those
had a comment naming a vendor, model, price or catalog. Each of those is a misclassified file or a
missing seam.
## The table
Generated; do not edit between the markers.
<!-- tiers:begin -->
| Tier | Files |
|---|---|
| core | 61 |
| bundled | 91 |
| client | 40 |
| root | 1 |
| data | 6 |
| File | Tier | Seam | Clock | Why |
|---|---|---|---|---|
| `src/anthropic.c` | bundled | provider | vendor | Anthropic stream decoding, its neutral form and cache_control; pure over a provider interface |
| `src/anthropic.h` | bundled | provider | vendor | Anthropic adapter interface |
| `src/ask.c` | core | - | durability | asks: a question a conversation puts to a person, kept in pic_ask, answered once by any client; a wake's OK is one |
| `src/ask.h` | core | - | durability | ask interface: open, answer once, wait, the list and its commands |
| `src/attach.c` | bundled | inbox | pi | pic attach: a read-only view of a conversation rebuilt from committed rows, and its stdin to the inbox |
| `src/attach.h` | bundled | inbox | pi | pic attach interface |
| `src/bash.c` | core | - | os | the bash tool: launches and supervises a command, records it |
| `src/ca_bundle.inc` | data | - | os | compiled-in CA roots; expires, so refreshed by re-vendoring |
| `src/catalog.c` | data | - | vendor | reads model-catalog rows from the user database; the facts are data |
| `src/catalog.h` | data | - | vendor | catalog row interface |
| `src/catalog_fetch.c` | bundled | - | vendor | fetches a third party's catalog from inside pic; should become an explicit command |
| `src/codemode.c` | bundled | tool | pi | the codemode tool: Pi's scripts on QuickJS in a worker process of their own, calling the other tools through the nested-call seam; an effect per script and a nested effect per inner call, off by default |
| `src/codemode.h` | bundled | tool | pi | codemode interface; the root registers the tool and runs the worker |
| `src/codemode_js.inc` | bundled | tool | pi | the JavaScript the codemode worker runs: Pi's prelude and source format, ported |
| `src/commands.c` | core | - | pi | the RPC command table |
| `src/commands.h` | core | - | pi | RPC command table interface |
| `src/compact.c` | bundled | context-policy | pi | the context policy: when to compact (threshold, lapse and its holdout), the cut and the summary prompts |
| `src/compact.h` | bundled | context-policy | pi | compaction interface; the composition root registers its policy |
| `src/context.c` | bundled | prompt-assembly | taste | system prompt wording and the instruction-file convention |
| `src/cred.c` | core | - | os | sealed credential storage and unlocking |
| `src/cred.h` | core | - | os | credential store interface |
| `src/doctor.c` | bundled | - | durability | pic doctor: names a journal's holders, stops the older pics that keep it, and migrates it |
| `src/doctor.h` | bundled | - | durability | pic doctor interface |
| `src/stripctl.h` | bundled | tool | vendor | control characters out of JSON text from a provider's web search, header-only so each stream decoder carries it |
| `src/update.c` | bundled | - | os | pic update: pulls trunk, builds and tests it in a source checkout, installs it over the running pic when green |
| `src/update.h` | bundled | - | os | pic update interface |
| `src/endpoints.c` | bundled | model | vendor | saved model endpoints: their rows and the checks on a name and a URL; models.c resolves NAME/MODEL through them |
| `src/endpoints.h` | bundled | model | vendor | saved endpoints interface |
| `src/endpoints_fetch.c` | bundled | rpc-command | vendor | fetches an endpoint's OpenAI-shaped model list when asked, and the endpoint RPC commands |
| `src/events.c` | core | - | pi | the JSON event protocol |
| `src/events.h` | core | - | pi | event protocol interface |
| `src/export_html.c` | bundled | - | taste | HTML view of a conversation; a converter over a read view |
| `src/export_pi.c` | bundled | - | pi | Pi session lines; hooks and ctx read them, so it may become core |
| `src/filelog.c` | core | - | durability | file history: pre- and post-images of write and edit, journaled restores finished after a crash |
| `src/folder.c` | bundled | - | vendor | the workspace's .pic folder: its own .gitignore, and its line in a zit or fossil checkout's ignore file |
| `src/folder.h` | bundled | - | vendor | workspace folder interface |
| `src/gemini.c` | bundled | provider | vendor | Gemini request shape and stream decoding |
| `src/gemini.h` | bundled | provider | vendor | Gemini adapter interface |
| `src/goal.c` | bundled | stop-policy | taste | goals: the stop policy that says whether a goal is met, and the wake tool the model starts monitors, loops and goals with |
| `src/goal.h` | bundled | stop-policy | taste | goal interface; the root registers its policy and its tool |
| `src/help.c` | bundled | rpc-command | taste | pic help over the compiled-in manual; get_help and get_changelog |
| `src/help.h` | bundled | - | taste | help interface |
| `src/hooks.c` | core | - | pi | the component host: journaled hook runs with safe defaults |
| `src/hooks.h` | core | - | pi | hook host interface |
| `src/htmltext.c` | bundled | tool | taste | HTML to markdown-ish text for web_fetch: one forgiving pass, entities decoded, links made absolute |
| `src/htmltext.h` | bundled | tool | taste | HTML to text interface |
| `src/http.c` | core | - | os | HTTP over the transport |
| `src/http.h` | core | - | os | HTTP interface |
| `src/ignore.c` | bundled | - | taste | ignore-file matching and the ignore-aware walk, for discovery, search and @file |
| `src/ignore.h` | bundled | - | taste | ignore interface |
| `src/image.c` | core | - | durability | content-addressed image storage |
| `src/image.h` | core | - | durability | image storage interface |
| `src/import_claude.c` | bundled | - | vendor | reads another product's private transcript format; should move out |
| `src/import_pi.c` | bundled | - | pi | reads Pi sessions into conversations |
| `src/inbox.c` | core | - | durability | the inbox: accepting a message from another process, delivering it under the lease, its watch and retention |
| `src/inbox.h` | core | - | durability | inbox interface |
| `src/input.c` | core | - | os | input and path helpers over the OS seam |
| `src/input.h` | core | - | os | input helpers interface |
| `src/jsengine.h` | bundled | tool | pi | the JavaScript engine seam codemode runs scripts with: make, evaluate, pump jobs, an interrupt and one host function |
| `src/jsengine_quickjs.c` | bundled | tool | vendor | the engine seam on Bellard's QuickJS, for hosted builds, run in codemode's worker process |
| `src/keyhealth.c` | bundled | credential | vendor | what a provider's refusal means for a key (vendor wording as data rows), and the words and swap choices for a key's state |
| `src/keyhealth.h` | bundled | credential | vendor | key health interface; the root registers its classifier |
| `src/keyprobe.c` | bundled | credential | vendor | free checks of a key: asks each provider's probe at once in worker threads and records the answers; what to ask is the adapters' |
| `src/keyprobe.h` | bundled | credential | vendor | free key check interface; pic auth status and the terminal interface call it |
| `src/listings.c` | bundled | rpc-command | pi | listings as commands: models, providers, templates and skills, instruction files, a folder's files |
| `src/listings.h` | bundled | rpc-command | pi | listings interface |
| `src/loop.c` | core | - | durability | admission, effects, recovery, generations; runs the compaction it is told to; asks the model source for prices; still holds error wording |
| `src/main.c` | root | - | durability | composition root: the one place allowed to name everything |
| `src/mcp.c` | bundled | tool | vendor | the MCP client: servers as rows with sealed values, their tools in the registry, pic mcp |
| `src/mcp.h` | bundled | tool | vendor | MCP client interface |
| `src/mcp_stdio.c` | bundled | tool | os | the MCP stdio transport on a host: a server program in its own process group, lines on its pipes |
| `src/mcp_stdio.h` | bundled | tool | os | MCP stdio transport interface |
| `src/mcp_wire.c` | bundled | tool | vendor | the MCP protocol: the 2026-07-28 revision, the 2025 handshake, streamable HTTP, the stdio seam |
| `src/mcp_wire.h` | bundled | tool | vendor | MCP protocol interface |
| `src/model.c` | core | model | pi | the model seam: asks the registered model source what a name means and its price; Pi's thinking-level rules |
| `src/model.h` | core | model | pi | model seam interface: the model core uses and the source a component registers |
| `src/model_catalog.inc` | data | - | vendor | dated snapshot of the model catalog |
| `src/models.c` | bundled | model | vendor | the model source: built-in providers, the catalog and models file, compat switches, the cost formula; registered by the root |
| `src/models.h` | bundled | model | vendor | model source interface |
| `src/monitor.c` | bundled | wake | os | the monitor runner: a monitor's command detached with its spool, pid and exit files; its liveness and output for core |
| `src/monitor.h` | bundled | wake | os | monitor runner interface; the root registers it |
| `src/net.c` | core | - | os | TLS transport |
| `src/net.h` | core | - | os | transport interface |
| `src/noise.c` | bundled | - | vendor | remote control's cryptography on BearSSL: Noise IK and IKpsk1 over P-256, records, the explicit counter, VAPID and RFC 8291 |
| `src/noise.h` | bundled | - | vendor | remote control's cryptography interface |
| `src/oauth.c` | bundled | credential | os | subscription sign-in machinery: PKCE, the loopback redirect, the device-code poll, token requests; registered by the root |
| `src/oauth.h` | bundled | credential | os | sign-in flow interface and the shared helpers |
| `src/oauth_openai.c` | bundled | credential | vendor | OpenAI's Sign in with ChatGPT: endpoints, scopes, the token contract |
| `src/oauth_openrouter.c` | bundled | credential | vendor | OpenRouter's PKCE sign-in, which hands back an API key |
| `src/openai_chat.c` | bundled | provider | vendor | OpenAI-compatible chat request shape and stream decoding |
| `src/openai_chat.h` | bundled | provider | vendor | chat adapter interface |
| `src/openai_responses.c` | bundled | provider | vendor | OpenAI responses request shape and stream decoding |
| `src/openai_responses.h` | bundled | provider | vendor | responses adapter interface |
| `src/peer.c` | bundled | tool | taste | the send_message tool, the frame a peer's message arrives in, and the wake component (grapevine stage 4) |
| `src/peer.h` | bundled | - | taste | peer interface: the send_message tool, pic sessions --all |
| `src/perm.c` | core | - | durability | permission modes: a conversation's mode in pic_permission, and the gate that makes a call wait on an ask for a person's yes |
| `src/perm.h` | core | - | durability | permission mode interface: the mode, the admission's default, the gate and its commands |
| `src/pic.h` | core | - | durability | the shared header: store, entries, generations |
| `src/platform.c` | core | - | os | the OS seam |
| `src/platform.h` | core | - | os | OS seam interface |
| `src/policy.h` | core | context-policy | durability | the context-policy seam: the question asked before a request and the plan core enforces |
| `src/procs.c` | core | - | os | process supervision and process records |
| `src/procs.h` | core | - | os | process supervision interface |
| `src/prompts.c` | bundled | - | taste | prompt template discovery and expansion |
| `src/prompts.h` | bundled | - | taste | prompt template interface |
| `src/provider_anthropic.c` | bundled | provider | vendor | the Anthropic adapter: request building, cache policy and content shapes, registered by the root |
| `src/provider_chat.c` | bundled | provider | vendor | the chat adapter: request building, id rules, cache policy and content shapes, registered by the root |
| `src/provider_fake.c` | core | provider | durability | the scripted provider that lets core run with no component; replies in the neutral form |
| `src/provider_gemini.c` | bundled | provider | vendor | the Gemini adapter: request building, registered by the root |
| `src/provider_http.c` | core | provider | durability | shared POST, retries before first byte, key attachment; the table of registered adapters |
| `src/provider_http.h` | core | provider | durability | provider seam interface: the shared POST and the adapter a component registers |
| `src/provider_responses.c` | bundled | provider | vendor | the responses adapter: request building, id rules, cache policy and content shapes, registered by the root |
| `src/prune.c` | core | - | durability | retention of stored images and entries |
| `src/remote.c` | bundled | inbox | pi | pic remote: pairing, the relay's API and stream, Noise sessions per phone, commands as inbox rows or keyed admissions, following by the attach pass |
| `src/remote.h` | bundled | inbox | pi | pic remote interface |
| `src/rewind.c` | bundled | rpc-command | taste | rewind: which files go back to what, refusals, the conversation fork; over the file history |
| `src/rewind.h` | bundled | rpc-command | taste | rewind interface |
| `src/rpc.c` | core | - | pi | the RPC server; dispatches components' commands through its registry |
| `src/rpc.h` | core | - | pi | RPC server interface and the RPC command registry |
| `src/search.c` | bundled | tool | pi | the grep, find and ls tools |
| `src/search.h` | bundled | tool | pi | the grep, find and ls registrations |
| `src/settings.c` | core | - | pi | the settings list: what each setting is and allows |
| `src/settings.h` | core | - | pi | the settings list: what each setting is and allows |
| `src/skills.c` | bundled | - | pi | skill discovery and expansion |
| `src/skills.h` | bundled | - | pi | skill interface |
| `src/rpc_core.c` | core | rpc-command | pi | core's own commands for a client: settings, trust, the model scope, recent models, bug reports, phones, hooks, process records |
| `src/sqlar.c` | core | - | durability | SQLite archive storage for blobs |
| `src/sqlar.h` | core | - | durability | archive storage interface |
| `src/sse.c` | core | - | os | server-sent-event framing |
| `src/sse.h` | core | - | os | SSE framing interface |
| `src/store.c` | core | - | durability | journal, schema, leases, migrations |
| `src/toolpar.c` | core | - | durability | parallel tool-call execution |
| `src/toolpar.h` | core | - | durability | parallel tool interface |
| `src/toolreg.c` | core | - | durability | the tool registry: each tool's schema, replay safety, tier and executor, and the tools in play |
| `src/toolreg.h` | core | - | durability | tool registry interface |
| `src/tools.c` | core | - | pi | the executor and core's tools: read, bash, edit and write |
| `src/toolsearch.c` | bundled | tool | pi | tool_search: BM25 over deferred MCP tools, declaring the matches for later requests |
| `src/toolsearch.h` | bundled | tool | pi | tool_search interface |
| `src/transform.c` | core | - | durability | neutral content form: id rewriting and content shapes, by the registered adapter's rules |
| `src/trash.c` | core | - | durability | deleted conversations: hidden by a row, restored, and purged keeping the journal's invariants |
| `src/tree.c` | core | - | durability | the conversation tree over entries |
| `src/tui/app.c` | client | rpc-command | taste | the terminal interface's application; asks components and core state through the command registry |
| `src/tui/atfile.c` | client | - | taste | @file completion |
| `src/tui/atfile.h` | client | - | taste | @file completion interface |
| `src/tui/clipboard.c` | client | - | os | clipboard access |
| `src/tui/clipboard.h` | client | - | os | clipboard interface |
| `src/tui/editor.c` | client | - | taste | the input editor |
| `src/tui/editor.h` | client | - | taste | editor interface |
| `src/tui/fuzzy.c` | client | - | taste | fuzzy matching |
| `src/tui/fuzzy.h` | client | - | taste | fuzzy matching interface |
| `src/tui/highlight.c` | client | - | taste | syntax highlighting |
| `src/tui/highlight.h` | client | - | taste | highlighting interface |
| `src/tui/keymap.c` | client | - | pi | key actions and defaults |
| `src/tui/keymap.h` | client | - | pi | keymap interface |
| `src/tui/markdown.c` | client | - | taste | markdown rendering |
| `src/tui/markdown.h` | client | - | taste | markdown interface |
| `src/tui/mjson.c` | client | - | taste | JSON reader for themes and keybindings |
| `src/tui/mjson.h` | client | - | taste | JSON reader interface |
| `src/tui/modelpanel.c` | client | - | taste | the model picker's lines, in the settings panel's frame, and which models it suggests |
| `src/tui/modelpanel.h` | client | - | taste | the model picker's lines |
| `src/tui/panel.c` | client | - | taste | the settings panel's lines and the frame it shares with the model picker |
| `src/tui/panel.h` | client | - | taste | the settings panel's lines |
| `src/tui/remote.c` | client | - | os | /remote-control: the ssh command, host lookups, port 22 and the QR code |
| `src/tui/remote.h` | client | - | os | remote-control interface |
| `src/tui/render.c` | client | - | taste | screen rendering |
| `src/tui/render.h` | client | - | taste | rendering interface |
| `src/tui/term.c` | client | - | os | terminal control |
| `src/tui/term.h` | client | - | os | terminal interface |
| `src/tui/theme.c` | client | - | taste | themes |
| `src/tui/theme.h` | client | - | taste | theme interface |
| `src/tui/theme_dark.inc` | data | - | taste | the dark theme |
| `src/tui/theme_light.inc` | data | - | taste | the light theme |
| `src/tui/themes.c` | client | - | taste | theme discovery |
| `src/tui/themes.h` | client | - | taste | theme discovery interface |
| `src/tui/transcript.c` | client | - | taste | transcript layout |
| `src/tui/transcript.h` | client | - | taste | transcript interface |
| `src/tui/tui.h` | client | - | taste | entry point of the terminal interface |
| `src/tui/view.c` | client | - | taste | view model |
| `src/tui/view.h` | client | - | taste | view interface |
| `src/tui/viewport.c` | client | - | taste | scrolling viewport |
| `src/tui/viewport.h` | client | - | taste | viewport interface |
| `src/tui/width.c` | client | - | os | character widths |
| `src/tui/width.h` | client | - | os | width interface |
| `src/userdb.c` | core | - | durability | the user database |
| `src/userdb.h` | core | - | durability | user database interface |
| `src/verify.c` | bundled | - | taste | the workspace's verify command: reads .pic/verify.json in a trusted workspace; core runs it and records the verdict |
| `src/verify.h` | bundled | - | taste | verify command interface |
| `src/wake.c` | core | - | durability | loops, monitors and goals: the pic_wake record, the fire through the inbox in one transaction, the due check |
| `src/wake.h` | core | - | durability | wake interface: the record, the fire, the due check and its RPC commands |
| `src/webfetch.c` | bundled | tool | taste | the web_fetch tool: a GET of a public URL with redirects, size and time caps and binary refusal; the address check is net.c's web mode |
| `src/webfetch.h` | bundled | tool | taste | web_fetch registration |
| `src/websearch_native.c` | bundled | tool | vendor | the provider's own web search: when a request declares its server tool in place of web_search, and the control-character filter for what comes back |
| `src/websearch_native.h` | bundled | tool | vendor | provider-native search interface |
| `src/websearch.c` | bundled | tool | vendor | the web_search tool: Brave's Search API as title, URL and snippet text, the key from the credential store, reply and time caps; with no key, Stack Exchange's keyless search of Stack Overflow (gzip, backoff kept) |
| `src/websearch.h` | bundled | tool | vendor | web_search registration |
| `src/webpush.c` | bundled | - | vendor | Web Push to a phone: the VAPID token and the request on noise.c's cryptography, and its outcome (pic remote) |
| `src/webpush.h` | bundled | - | vendor | Web Push interface |
| `src/xfer.c` | core | - | os | transfer of the store between machines |
| `src/xfer.h` | core | - | os | transfer interface |
<!-- tiers:end -->