Skip to content
pi-c Artifact [f9cfc80ff9]
Login

Artifact [f9cfc80ff9]

Artifact f9cfc80ff926eed2c894d572d0fda5b771dd34e4a17a33e385756eafbf8259ea:


# Architecture

## State

pic's state lives in SQLite: the journal per workspace (`WORKSPACE/.pic/journal.sqlite`, `pic_*`
tables) and `~/.pic/pic.sqlite` (`picu_*` tables) for settings, the model catalog, credentials,
trust decisions, process records and the conversation lines that ctx archives. One process owns a
journal at a time; [durability](durability.md) says what is committed when.

## The operating system seams

What touches the operating system sits behind two interfaces: `pic_platform` (clocks, entropy, the
lock, input files, the SQLite VFS) and `pic_executor` (file operations and running commands).
Host-only code stays behind them, which is what makes the targets in [where pic can
run](../manual/platforms.md) reachable.

## The terminal interface

The terminal interface is a module in the pic binary (`src/tui/`). It runs each request as a child
`pic --json` process and knows the run only through Pi's JSON events, so a fault in the interface
cannot touch a run.

## The credential store

Each stored key is sealed with ChaCha20-Poly1305 (the provider's name bound as associated data), so
no plaintext key reaches the database, its WAL, a backup or a log. The sealing key comes from a
passphrase, stretched with PBKDF2-HMAC-SHA256 (600,000 iterations, a random salt; both kept in
`picu_credential_key` with a verifier, so a wrong passphrase is refused cleanly). What it protects
against is in [credentials](../manual/credentials.md).

## The behavioural reference

`reference/pi.lock.json` pins the Pi revision used as the behavioural reference. Pi's source is not
part of this repository. The decisions in force are in [the implementation
plan](../design/implementation-plan.md).