See More

--- title: "Storage: SQLite index, blob store and sinks · coding.sh" description: "By default coding.sh keeps a SQLite index and a content-addressed blob store on your machine, mirrors to sinks, and loads remote stores as plugins." canonical: https://coding.sh/docs/storage human_url: https://coding.sh/docs/storage markdown_url: https://coding.sh/docs/storage.md agents_url: https://coding.sh/agents.md llms_url: https://coding.sh/llms.txt updated: 2026-11-23 --- # Storage By default coding.sh keeps a SQLite index and a content-addressed blob store on your machine, mirrors to sinks, and loads remote stores as plugins. coding.sh keeps two stores with different shapes, plus any number of write-only mirrors. Each is an interface, and the config picks the implementation by URL scheme. ## Index Small, queryable rows: sessions, events, eval tasks, harness bundles, runs, labels, datasets and experiments. The default is one SQLite file through the built-in `node:sqlite`, in WAL mode, with an FTS5 table over prompt, reply and tool text for `coding.sh search`. Writes are idempotent on event id, so re-ingesting the same spool changes nothing. [`coding.sh sql "select …"`](https://coding.sh/docs/cli/sql) runs one read-only query against it. [`coding.sh export sessions|events|labels`](https://coding.sh/docs/cli/export) streams rows as JSONL or CSV, on every store. The tables and columns are in [Query language](https://coding.sh/docs/query#tables). ## Blobs Large, write-once content: full tool output, raw source payloads, diffs. Event payloads larger than `maxInlineBytes` (4 KB) move to a blob and the event keeps a reference. Each blob is keyed by the sha256 of its uncompressed bytes, so the same `AGENTS.md` read in a thousand sessions is stored once. Blobs are compressed with zstd level 3. One that compresses to under 4 KiB is a row of `blobs/pack.db` (SQLite); a larger one is `blobs/ab/cd/.zst`, written to a temp file then renamed, so readers never see half a blob. ## Config config.toml ```toml # ~/.coding.sh/config.toml (coding.sh config get prints the effective values) [store] index = "sqlite://~/.coding.sh/index.db" blobs = "file://~/.coding.sh/blobs" [capture] mode = "full" # or "metadata": no prompts, code or tool output redact = ["secrets"] # "secrets", "env", or "none" redactPatterns = [] # extra regexes exclude = [] # repo globs never captured maxInlineBytes = 4096 # larger payloads move to blobs [retention] keepSpoolDays = 7 toolOutputDays = 90 ``` A repository can carry its own `.coding.sh/config.toml`, but because it arrives with `git clone` it is untrusted: it may only tighten capture (add redaction, exclusions or metadata mode) and turn snapshots off or lower their limits. It can never add a sink or move a store, which would let a repository send your sessions somewhere. ## Redaction and metadata mode - Redaction runs before anything is written to the index, blobs or sinks. The built-in `secrets` rules key on vendor token prefixes and on secret-looking names next to values, so code, paths and hashes pass through. - `capture.mode = "metadata"` keeps ids, timings, kinds, counts and usage, and drops prompts, code and tool output. - A session in which a vendor token was redacted gets the `secret:exposed` tag: the agent and its model provider saw it, so rotate it. `coding.sh sessions --flag secret:exposed` lists them. - [The model API proxy](https://coding.sh/docs/how-to/capture-with-proxy) redacts each request and response before storing it, and never stores `Authorization`, `x-api-key` or cookies. A value that got past redaction can be removed afterwards. Put it in a file, one value per line, and count the copies first: ```text coding.sh purge --literal leaked.txt --dry-run # count the copies coding.sh purge --literal leaked.txt # replace them coding.sh purge --rule 'sk-ant-api03-[A-Za-z0-9_-]{80,}' # every match of a shape ``` Every copy is replaced, in the index, blobs, spool and eval runs: with `[redacted:purged]` in the index and blobs, with asterisks in spool and eval run files. SQLite store only; rotate the secret too. [purge](https://coding.sh/docs/cli/purge) has the details, and [Privacy and redaction](https://coding.sh/docs/privacy) covers every redaction rule. ## Sinks A sink mirrors events to somewhere else. Each sink keeps its own cursor and retries with backoff, so a remote that is down never blocks local capture. Remote sinks default to `metadata` mode: content leaves your machine only when you set `mode = "full"`. config.toml ```toml [[sinks]] kind = "otlp" # OTLP/HTTP JSON traces to {endpoint}/v1/traces name = "collector" endpoint = "http://localhost:4318" mode = "metadata" # the default for every sink [[sinks]] kind = "http" # POSTs {schema, v, mode, events, sessions} endpoint = "https://relay.example.com/ingest" mode = "full" headers = { Authorization = "Bearer ${RELAY_TOKEN}" } # read from the environment ``` - `otlp`: OTLP/HTTP JSON. A session becomes an `invoke_agent` span, tools `execute_tool` spans and replies `chat` spans, with `gen_ai.*` attributes pinned to semconv 1.37.0. Span ids derive from event ids, so a resent batch de-duplicates. - `http`: posts coding.sh/trace JSON as is, for a collector or relay that speaks it. - Sinks mirror every event local ingest stores, from hooks and from imported transcripts, and events from the [OTLP receiver](https://coding.sh/docs/otel). - `coding.sh serve` mirrors every batch it commits to the sinks in its own config, so a team can set one there instead of on each laptop. ## Plugging in a remote store Built-in schemes are `sqlite://` and `memory://` for the index, and `file://` and `memory://` for blobs. For any other scheme the CLI imports an npm package by convention: - `coding.sh-store-` exporting `indexStore(url, config)` and/or `blobStore(url, config)`; - `coding.sh-sink-` exporting `sink(sinkConfig, config)`. The package must be resolvable from where coding.sh is installed. A missing package gives an error that names it; a package that fails to load surfaces its own error. ```js // coding.sh-store-postgres/index.mjs (the real package, abridged) export function indexStore(url, config) { return PgIndexStore.open(url); // resolves to an IndexStore } // coding.sh-sink-kafka/index.mjs (hypothetical package) export function sink(sinkConfig, config) { return { name: sinkConfig.name ?? "kafka", mode: sinkConfig.mode, async write(events, sessions, blobs) { /* … */ return { ok: true }; } }; } ``` The interfaces a plugin implements, abridged. The conformance test suite (`coding.sh/store/conformance`) runs against the built-in stores and can be pointed at a new one. Store interfaces (abridged) ```text interface IndexStore { readonly kind: string; migrate(): Promise; close(): Promise; putEvents(batch: AgentEvent[]): Promise<{ inserted: number }>; // idempotent on event.id upsertSession(session: Session): Promise; getSession(id: string): Promise; listSessions(filter?: SessionFilter): Promise; listEvents(sessionId: string, opts?: { kinds?: string[]; limit?: number; offset?: number }): Promise; search(text: string, opts?: { limit?: number; agent?: string }): Promise; getCursor(source: string): Promise; setCursor(source: string, offset: number): Promise; // plus tasks, harness bundles, runs, labels, referencedBlobs(), // and optional datasets, experiments, judges, kv state and compact() } interface BlobStore { readonly kind: string; put(data: Uint8Array | string): Promise; // returns the sha256; dedupes get(ref: string): Promise; getText(ref: string): Promise; has(refs: string[]): Promise; list(): AsyncIterable; delete(ref: string): Promise; } interface Sink { readonly name: string; readonly mode: "full" | "metadata"; write(batch: AgentEvent[], sessions: Session[], blobs: BlobStore): Promise<{ ok: boolean; error?: string; retryAfterMs?: number }>; } ``` Postgres, ClickHouse and S3: `coding.sh-store-postgres`, `coding.sh-store-clickhouse` and `coding.sh-store-s3` (S3, R2, MinIO) are on npm and back [production mode](https://coding.sh/docs/production); setup is in [Postgres and ClickHouse stores](https://coding.sh/docs/stores). Install one next to coding.sh. The npm package ships the TypeScript types for `coding.sh/store` and `coding.sh/store/conformance`, so a plugin built outside the repository imports them. ## Retention and gc `coding.sh gc` deletes spool files older than `keepSpoolDays` once every sink has them, tool-output blobs older than `toolOutputDays` (diffs and eval tasks are kept), and unreferenced blobs, and trims the judge cache to its size cap. `--compact` also runs SQLite `VACUUM`; `--dry-run` shows what would go. To set coding.sh up for a user, follow the agent workflow at [/agents.md](https://coding.sh/agents.md).