Twenty years of data, one query away.
YC gave its internal agents read-only SQL over its production database, plus the schema. Questions that took a data ticket became a prompt. Inside YC’s AI Playbook
Architecture
Read-only SQL is the most powerful interface an agent can have, and the hardest to make safe when people see different data. PocketContext does it by giving each reader a database of their own.
Why SQL
YC gave its internal agents read-only SQL over its production database, plus the schema. Questions that took a data ticket became a prompt. Inside YC’s AI Playbook
Lewis Ellis’s talk makes the case: agents read schemas, follow foreign keys and fix their own failed queries. YC’s agent did better once vector search was removed and it had to write SQL. Watch the talk
An aggregate returns one line instead of a thousand rows. In a synthetic Crew benchmark, the same answers took up to 611 times fewer bytes.
The missing piece
YC’s setup works because its culture is open by default and its data sits in one database. Most organizations need the opposite: the same powerful interface, with each person’s agent limited to what that person may see.
That has usually meant engineers writing policies across many separate stores. PocketContext solved row-level security on top of SQL. With every record and index in one system, your agent can set it up with the data model.
Out of the box
Each collection’s own rules validate who can change what.
POST /api/collections/deals/recordsA bounded, read-only engine runs against allowlisted columns, or the requester’s private database.
SELECT stage, count(*) FROM deals GROUP BY stageIndexes cover configured fields. With filtered snapshots, each requester gets a private index.
search "acme renewal"Writes, schema changes, transactions, PRAGMAs and attachments are denied.
SQLite checks every table and column a statement touches against your allowlist.
Time, row and byte limits stop runaway queries from filling the agent’s context.
Auth collections, system collections and hidden fields can’t be exposed at all.
Filtered snapshots
The normal token identifies the requester. Neither the request nor the SQL can change that identity.
The server asks whether the write database has changed since this requester’s copy was built.
If nothing changed, the copy is reused. Otherwise your filters copy only permitted rows into a private SQLite file.
The agent’s SQL runs on that file. The write database is never attached to the connection.
A filter is a SQL condition, bound to the signed-in user. Permission tables are used to build the copy and never appear in it. Your agent can write these along with the data model.
Search follows the same boundary, with an index built only from rows that user may read.
{
"tables": { "documents": ["id", "title", "body"] },
"snapshot": {
"filters": {
"documents": "EXISTS (SELECT 1 FROM document_readers r
WHERE r.document = documents.id
AND r.reader = :requester)"
},
"policyTables": { "document_readers": ["document", "reader"] }
}
}Freshness
Any committed change invalidates the copy, and the next request gets a new one. An unchanged database means instant reuse.
The new copy builds on the side and swaps in atomically. Queries see the previous version until then, and can ask to wait for a fresh one after a write.
The honest part
A wrong filter exposes the wrong rows. Review them, and test them with real roles.
Collection rules, realtime and file access have their own authorization, so write those rules to match.
A permission change reaches reads when the next copy is ready. Use synchronous mode, or request a fresh read, when that matters.
Each active reader has a file. Disk budget, builder count and cached users are limits you set.
Most apps need none of this. If the software is only for you, the column allowlist is enough.