coding.sh-store-postgres
v0.1.6
Published
Postgres store for coding.sh, observability and evals for any AI agent: point CODING_SH_STORE_URL at postgres:// and run serve, the CLI, MCP and evals on one database.
Maintainers
Readme
coding.sh-store-postgres
Postgres storage for coding.sh. Install it next to coding.sh and point the
store URL at a database. coding.sh serve, the CLI, MCP tools, datasets and experiments then all
read and write that database.
npm i -g coding.sh coding.sh-store-postgres
export CODING_SH_STORE_URL='postgres://coding:[email protected]:5432/coding?sslmode=require'
coding.sh serveThe core package loads this plugin by its name (coding.sh-store-<scheme>), so there is nothing to
register. Both postgres:// and postgresql:// work. When the index is on Postgres, blobs default
to the same database. Set CODING_SH_BLOB_URL=s3://… to keep them in object storage instead.
URL
postgres://user:pass@host:5432/db?sslmode=require&schema=coding_sh&pool_max=10| Parameter | Default | Meaning |
|---|---|---|
| schema | public | Created if missing. Separate deployments can share a database with separate schemas. |
| pool_max | 10 | Connections in the pool. The writer lock uses one more. |
| anything else | | Passed to pg as is (sslmode, host=/socket/dir, …). |
Statements time out after 30 s.
What it stores
The tables mirror the SQLite store: events, sessions, cursors, tasks, bundles, runs, labels,
kv, datasets, dataset_latest, experiments, judges and blobs, plus coding_sh_migrations.
- Migrations run on open, in one transaction under an advisory lock, so replicas can start together.
eventsandsessionscarryproject_id(defaultwhen unset).- JSON fields are
textholding JSON, sostats::jsonb->>'events'works in ad-hoc SQL. putEventsis idempotent: retries and replays never duplicate an event.- Full-text search uses a GIN-indexed
tsvectorover diacritic-folded terms. It needs no extensions. Each event indexes up to 200,000 characters of text. coding.sh servetakes a session advisory lock per schema, so only one replica writes. It needs a direct connection or a session-mode pooler. Transaction-mode poolers drop session locks.- Blobs are zstd-compressed
bytearows keyed by sha256. --where(the query language) runs in the database as one parameterized statement: every session and event key,has:,is:, bare words (on thetsvector),sort:,limit:and--facets. Event keys use theevents (session_id, …)index. A key this plugin doesn't know yet, from a newer coding.sh, fails withunsupported_store.
Tests
The conformance suite from coding.sh/store/conformance and the Postgres-specific tests run against
CODING_SH_TEST_PG_URL. They skip when it is unset. Each test creates a schema t_<random> and drops it
afterwards. npm ci builds this package's dist/ through its prepare script; after editing src/,
rebuild with npm run build -w coding.sh-store-postgres.
npm run build -w coding.sh
CODING_SH_TEST_PG_URL=postgres://coding:[email protected]:5432/coding npm test -w coding.sh-store-postgres