Architecture

YC showed agents need SQL.
We solved who sees which rows.

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

One expressive tool beats twenty narrow ones.

Y Combinator

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

The SF Database Meetup

“The unreasonable effectiveness of giving agents SQL.”

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

Your token bill

The answer, not the records.

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 can trust everyone with everything.
You have salaries.

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

Whatever you model gets three interfaces.

REST APIWrites

Each collection’s own rules validate who can change what.

POST /api/collections/deals/records
Read-only SQLQuestions

A bounded, read-only engine runs against allowlisted columns, or the requester’s private database.

SELECT stage, count(*) FROM deals GROUP BY stage
BM25 searchFinding

Indexes cover configured fields. With filtered snapshots, each requester gets a private index.

search "acme renewal"

Read-only by construction

Writes, schema changes, transactions, PRAGMAs and attachments are denied.

Authorizer in the engine

SQLite checks every table and column a statement touches against your allowlist.

One statement, bounded

Time, row and byte limits stop runaway queries from filling the agent’s context.

Secrets never listed

Auth collections, system collections and hidden fields can’t be exposed at all.

Filtered snapshots

A query can’t leak a row
that isn’t in the file.

  1. 01

    Authenticate

    The normal token identifies the requester. Neither the request nor the SQL can change that identity.

  2. 02

    Check the source

    The server asks whether the write database has changed since this requester’s copy was built.

  3. 03

    Reuse or build

    If nothing changed, the copy is reused. Otherwise your filters copy only permitted rows into a private SQLite file.

  4. 04

    Run the query

    The agent’s SQL runs on that file. The write database is never attached to the connection.

You describe who sees what. Once.

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

Choose exact, or choose never slowed down.

Synchronous, by default

Always current.

Any committed change invalidates the copy, and the next request gets a new one. An unchanged database means instant reuse.

Background refresh

Reads keep running.

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

What stays your responsibility.

Your filters are trusted code.

A wrong filter exposes the wrong rows. Review them, and test them with real roles.

REST is governed separately.

Collection rules, realtime and file access have their own authorization, so write those rules to match.

Background mode is eventually consistent.

A permission change reaches reads when the next copy is ready. Use synchronous mode, or request a fresh read, when that matters.

Copies use disk.

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.

Describe the data.
Say who can see it.

Build your own