strategy

Precomputing's Moat: One SQLite File Format and Answers That Match to the Last Bit

Keeping answers ready is an old idea. Databases have offered materialized views for decades, and every time-series database rolls up its metrics as they arrive. So the useful questions about Precomputing are narrower: what does this version do that the others don’t, and which parts would a rival struggle to copy?

The answer comes in two halves. What sets it apart today is where it runs and how much it covers. One small policy language drives four jobs that usually take four separate products, and all of it lives in an ordinary SQLite file. What makes it hard to copy is the proof work behind those claims: two runtimes that write the same file to the last bit, and exact counts checked against separate recounts, crash after crash.

Today, four jobs take four stacks: metrics dashboards run on a time-series database with its own query language, market candles on a feed handler or a streaming engine, usage billing on a metering service with its own rules for retries and closed months, and log costs on a pipeline product in front of the log platform, each with its own storage and its own idea of time. Precomputing covers them with one policy language, two runtimes (SQL triggers inside any SQLite, and the Engine, 12 to 17 times faster) and one SQLite file that holds the same values from either runtime.

Four jobs that usually take four stacks, kept in one policy language and one SQLite file.

It Runs Inside SQLite

Most tools that keep answers ready are servers. Someone has to run them and pay for them, and the answers live wherever that server lives. Precomputing compiles a policy into plain SQLite: tables, views and one trigger per stream. SQLite already sits inside every phone and every web browser, so the answers can live where the data is born: in an app, in a browser tab, on a device in the field, or in one small file per customer on a server.

That changes who can use it. A developer who already has a SQLite database adds ready answers with one file of SQL, and there’s nothing to install. In the SQLite world the nearest alternatives are triggers written by hand, and Turso’s live materialized views, an experimental feature without time windows or retention.

One Language, Four Jobs

Today each of these jobs brings its own stack. Metrics dashboards sit on a time-series database. Market candles come from a feed handler or a streaming engine. Usage billing needs a metering service with its own rules for retries and closed months, and teams trying to cut log bills put a pipeline product in front of their log platform. Each one keeps its own storage and its own idea of time.

Precomputing covers all four with one language and one file format. A policy for API latency and a policy for AI token billing use the same few words: streams, keys, windows and precomputes. The Meter adds an exact mode for money. Logs adds a front end that reads log lines, plus a tool that turns an existing dashboard into a policy. Underneath, it’s the same file, read with the same SQL.

The Same Answers, to the Last Bit

There are two runtimes. The SQL runtime does its work in SQLite triggers; the Engine does the same work in Go, 12 to 17 times faster on Demo 2’s trades. Both write the same file, value for value. A team can start with plain SQL and move to the Engine when volume grows, with no migration, because either runtime can carry on in a file the other wrote.

Getting there took detailed work that a rival would have to repeat. The Engine follows SQLite’s arithmetic step by step, down to which value wins a tie and how integers stay exact. Even the logarithm matches: the browser build agrees with Go’s on every one of 2,000,000 test values. The tests feed the same events through both runtimes and compare every value, and three small deliberate changes to the Engine’s rules each make that comparison fail. So the check catches real mistakes.

Exact Where Money Is Involved

Monitoring can be approximate. Billing can’t. The Meter counts a retried request once and puts a late report in the hour it happened. Once a month closes, nothing can change its totals. In Demo 3, a month of AI usage from six customers, full of retries and late reports, ended in invoices equal to a separate recount to the billionth of a dollar.

The Engine also survives crashes without losing a confirmed event. In the crash lab it was killed 100 times while taking in a trading day, more than 40 of those times in the middle of writing its file, and it lost nothing it had acknowledged. For a meter, that’s the difference between an invoice you can defend and one you can’t.

Answers Go Up, Log Lines Stay Home

Log platforms charge by volume. Logs, the fourth part, reads the dashboard a team already has and works out which numbers it needs. It sends those upstream and keeps every raw line on the team’s own machines for 48 hours. In Demo 4 the dashboard went upstream in 120 times fewer bytes, and every count on it matched a recount of the raw lines. Tools that cut log volume usually filter or sample lines; starting from the dashboard gives a simpler rule for what to keep.

What Would Be Hard to Copy

Code can be rewritten. The slow parts are the ones around it:

  • The file format. Every file carries its own policy and its rules for letting detail fade, so any SQLite tool can read it years later. If files in this format spread, the format becomes something other tools have to read, much as SQLite’s own file format did.
  • The policies people write. A team’s policies describe its business, from what it bills to how long it keeps each record. They get written once and kept, which makes the language sticky.
  • A record of exactness. Billing teams change meters rarely and carefully. Recounts that match to the billionth of a dollar, and crash tests that lose nothing, are how a meter earns that trust, and the record only grows.
  • The last-bit work. Two runtimes that agree on every value took engineering that is slow to repeat and easy to get subtly wrong.

Where It Stands

All of this is version 0.1, tested on simulated data. Today it’s a head start, and use is what turns a head start into a moat. That means pilots on real traffic first, then a file format frozen at 1.0 so every file stays readable. The roadmap sets out the order.