Andrew Fribush

← All posts

LLM on the write path, not the read path

· January 21, 2027 · 10 min read

Quarry is a data system I designed to turn arbitrary text into a queryable dataset. One document or many go in, each optionally with author, date and source. The design runs a language model over the text once and stores what it extracts in a small, closed schema, with a pointer back to the source on every unit. Every later question is an operation over that store.

The design document says near its top what Quarry is not: "chat with your documents." That's the common design for a data product with a model in it. Every question goes to the model, the model reads the documents, and it answers in prose. The answer is fluent and has no rows behind it, so there's no operation to re-run, and nobody can count how often it's wrong.

The first line of the document's principles is the alternative. The LLM goes on the write path, not the read path. The model works where messy input becomes a closed schema, once, with lineage. On the path where a question becomes an answer, it only translates the question into an operation the system already has. The document puts the read-path rule in one sentence: the model "may route to data, never speak for it."

This essay goes through the nine invariants in section 3 of that document, grouped by what they govern and numbered as the document numbers them. Each gets its argument, and then come the costs. What's mine is where the model sits.

The hard work is in resolving text into data. That means cleaning it, cutting it into units, deciding which mentions are the same entity, and extracting what each unit says. The document puts the risk there plainly: "The hard, risky, unglamorous ~80% is the pre-LLM resolution (assembly, segmentation, identity) plus the calibrated-honesty machinery. The LLM map is the easy ~20%." If that work happens once and its output is stored with a record of how it was made, every read afterwards is a database operation. It's cheap, repeatable and checkable against the rows it returns. If it happens at question time, it happens again for every question and leaves nothing behind to check.

fig. 2.35.1 · the model resolves text into the store once; on the read path its one arrow goes to an operation, and the rows come from the store, never from the model.
THE READ-PATH MODEL ROUTES TO AN OPERATION, NEVER TO YOUONE BOX, ONE STEP; INK ARROW: WHAT RUNS; DASHED ACCENT: THE ARROW THE DESIGN FORBIDSWRITE PATH · ONCEREAD PATH · EVERY QUESTIONA WRITE, WITHLINEAGERUNS ONTEXT INONE DOCUMENT OR MANYOPTIONALLY WITH AUTHOR, DATE, SOURCEMODELRESOLVES TEXT INTO DATA, ONCEQUESTION“EVERY PARAGRAPH CONTAINING LOVEPOETRY”MODELONLY TRANSLATES THE QUESTION INTO ANOPERATIONOPERATIONFROM THE CLOSED ALGEBRASELECT · PROJECT · JOIN · ANNOTATE ·AGGREGATE · DIACHRONIC · ESTIMATE ·AUDITSTORE: A CLOSED SCHEMAENTITIES, MENTIONS, STATEMENTS, QUOTES, REFERENCES, DATES, PLACESEVERY UNIT TAGGED: PROVENANCE LOCATOR · CONFIDENCE · LITERAL OR INFERREDROWSFROM THE STORE, EVERY ROWPROVENANCE-BACKEDYOUNEVER: THE MODEL SPEAKS FOR THE DATA

source: quarry PLAN.md section 1 lines 20-25; section 3 invariant 1 lines 48-53, invariant 3 lines 58-60; section 4 lines 126-127; section 5 lines 174-176 · writeReadPath.data.ts

Where the Model Runs

Invariant 1: LLM on the Write Path, Not the Read Path

The invariant says the model resolves text into data once, and "Reads are store operations." A read-path model is permitted "only as a query translator", turning natural language into an operation in the closed algebra, and the "results come from the store, every row provenance-backed."

So the read path does have a model on it, with one job. Take "every paragraph containing love poetry", one of the document's own examples. The translator turns that into a select with that predicate, the store runs it, and you get back rows, each pointing at the segment it came from. The model never writes the answer. The document names what's being ruled out: "Answer-synthesis on the read path is the exact failure mode this product exists to avoid." If the translator picks the wrong operation, you can read which one it picked and with what predicate. The rows that came back are real rows from the store.

Invariant 8: Novelty Gates the Model, Not Size

This is the rule that decides each model call: "Operations over already-materialized attributes are deterministic, LLM-free, exact, repeatable. An LLM is invoked only when a step introduces a semantic distinction the data does not yet carry", and that invocation "is a write that materializes the new attribute for all future use." The document's example: "A new predicate on 12 units still needs the model; an old predicate on a million does not. Size changes cost, not whether."

The rule doesn't look at how much data a question covers. It looks at whether the data already has the attribute the question needs. Suppose you ask for love poetry and no unit has been labeled for it. The model runs over the units in scope and stores the label, and that's a write with lineage. The second time anyone asks, it's a select over a stored attribute, and there's no model call whether the corpus is twelve units or a million.

fig. 2.35.2 · a new predicate needs the model on 12 units or a million; an old one needs it on neither: the column decides, the row changes only the cost.
THE PREDICATE DECIDES WHETHER THE MODEL RUNS; SIZE CHANGES ONLY THE COSTONE CELL, ONE CASE; ACCENT: THE MODEL RUNS; INK: A SELECT OVER STORED DATANEW PREDICATEA SEMANTIC DISTINCTION THE DATADOES NOT YET CARRYOLD PREDICATEAN ALREADY-MATERIALIZED ATTRIBUTE12 UNITSMODEL NEEDEDA WRITE THAT MATERIALIZES THENEW ATTRIBUTETHE DOCUMENT’S EXAMPLENO MODELDETERMINISTIC SELECT:LLM-FREE, EXACT, REPEATABLEA MILLION UNITSMODEL NEEDEDA WRITE THAT MATERIALIZES THENEW ATTRIBUTENO MODELDETERMINISTIC SELECT:LLM-FREE, EXACT, REPEATABLETHE DOCUMENT’S EXAMPLEAFTER THE WRITE, THE SAME PREDICATE IS OLD, FOR ALL FUTURE USE

source: quarry PLAN.md section 3, invariant 8, lines 95-101 · noveltyGate.data.ts

Invariant 9: Cheap and Broad Early, Expensive and Narrow Late

"Cheap model for the broad initial canonicalization over the whole corpus; expensive model for interstitial resolution and audits on small, high-stakes leaf sets." The broad pass touches every segment, so it's where the token bill is, and it runs on the cheap model. The expensive model gets what the document calls interstitial resolution, and the audits, both over "small, high-stakes leaf sets."

The audit design explains why the checker should be a different model. A re-sweep by the same model is self-consistency. It catches mechanical loss and can confirm its own blind spot. An independent or stronger checker catches conceptual loss. Even a maximal audit, in the document's words, converges to "two independent methods agree down to the ambiguous cases", and that remaining boundary goes to a human for sign-off.

A Closed Schema and a Closed Algebra

Invariant 2: Canonicalize Once Into a Small, Closed Schema

"The canonical layer is a fixed, closed set of primitives. Arbitrary/bespoke structure lives only in the query/view layer above it." The primitives the write path extracts are entities, mentions, statements, quotes, references, dates and places. That list doesn't grow per user.

The detail that makes this hold is where the user's own structure goes. A user can have the model propose a spec from a sample, edit it and freeze it, but the spec lives in the view layer and doesn't shape ingestion. Two users with different specs over the same corpus share one canonical layer, and their results can be joined because they're made of the same primitives. The document calls this "the single discipline that keeps 'composable' from becoming an unbounded universal-knowledge-graph swamp."

Invariant 3: A Closed Operation Algebra

The operations are select by predicate, project, join through tiered entity identity, annotate, aggregate and diachronic, plus estimate and audit. Anything a user wants is a composition of those. The document's formula is "Closed schema + closed algebra + unbounded composition = the product, buildable. Open either one = the swamp."

The document also corrects its own formula. refine, which means "look harder" at a result, is defined as a bounded rerun of the completeness audit. It's open in its predicate, because predicates are natural language like any select, and it's capped by a spend limit and a snapshot pin. The document says it "adds no primitive", and in the next breath that it does not make the predicate space closed either. It labels that "honesty over rhetoric".

Invariant 4: Closure Under Refinement

Every operation maps a Dataset to a Dataset "of the same kind (same primitives, provenance, metacontext)." A result isn't a report. It's a persisted dataset you can run the next operation on, which the thesis calls compounding data resolution.

Each derived set carries its lineage: "parent set, operation, predicate text, model+version, timestamp, per-unit confidence." That record is what makes a set re-resolvable. When a better model is available, you can rerun the operation that made a set, with the same parent and the same predicate, and compare. A prose answer from a read-path model comes with no parent set, no predicate text and no version. To check it, you ask the question again and read the new answer.

Provenance, Position and Calibrated Honesty

Invariant 5: Provenance Retention

The invariant opens with "Pointers/locators by default". Verbatim text is gated by the corpus's source_class (public_domain, contributed or encumbered) and by a quote-length knob, set per source as policy rather than argued in code. Storage has two layers. The raw layer is private and access-controlled, it's the provenance anchor, and it's never redistributed. The canonical derivative is the composable, shareable layer.

The reason is a problem the design was written for. Some sources permit research or derived use and forbid redistribution. With pointers as the default, a dataset built on such a source can be shared and queried without shipping the source text, and every row still points at the exact place it came from.

Invariant 6: Every Unit Carries Its Position

Position is "computed once at segmentation, never reconstructed". It's the exact locator (page, line, offset), the fraction through the document, the ordinal across the corpus, the structural path, and the date where one exists. Each fraction is stored with its denominator, characters or structural units or pages, and the document's line on it is "No single ambiguous 'percent through.'"

This is what lets a positional or over-time question be an operation. Take a query like how a speaker's framing of one phrase changed over time. It's a diachronic over stored dates and ordinals, and it never has to reopen the text to find out where a unit sat. The denominator is stored because the fractions disagree. A unit's fraction through a book counted in characters isn't its fraction counted in chapters, and two datasets that mixed the two would line up wrong when joined.

Invariant 7: Calibrated Honesty

"No asserted totals. literal vs inferred always separated." Every annotation is marked as either what the text says or what the model inferred from it. The system also never reports how many matches exist in the corpus, because recall over a corpus can't be verified in principle.

It reports a recall floor you can spend compute to raise, and the document is exact about the form. The floor is "a one-sided lower bound at a stated confidence (e.g. a one-sided binomial bound from sample hits)", never a two-sided interval, "because a two-sided interval needs a population denominator, which is the very total this principle forbids." Uncertainty propagates down the lineage, so "a 3rd-generation derived set is never rendered as if it were the corpus." The same rule reaches the job queue. An extraction run has to reconcile expected segments, enqueued jobs and jobs in a terminal state to one equal count before it may report any recall floor. A run that doesn't reconcile reports incomplete and no number.

Every Answer Comes Back as Rows With Lineage

A select takes a natural-language predicate, so a question nobody anticipated is still answerable. It becomes a write that materializes the new attribute, and the answer is rows with lineage. What the design gives up is the prose answer with no rows behind it.

The discipline has three prices, and I'd pay all three. A closed schema means data that doesn't fit the primitives gets rejected or flagged at ingestion. Segmentation, for example, "never guesses". Under ambiguity it emits the unit with an anomaly flag and an unresolved boundary for sign-off. A closed algebra means a question that needs a new kind of operation, as opposed to a new predicate, can't be asked until someone adds one. And the novelty gate means a new distinction costs a full model pass over the units it applies to before the first answer comes back.

The alternative is a system whose answers can't be checked, and the document's own risk section names the failure the discipline is there to prevent, the universal-parser, universal-knowledge-graph swamp. "The product is useful only while the discipline holds", it says, and the next sentence is "Everything good here is downstream of saying no." The discipline it lists is closed schema, closed algebra, one adapter, optional audit and no UI yet.

I built a good part of it: the repo has the pipeline, the operation algebra, the audit subsystem and an end-to-end dry run committed.

Where the Model Is Allowed to Be Wrong

Every data product with a model in it has to decide where the model is allowed to be wrong. In this design it's at ingestion, once. Each stored annotation carries its confidence, whether it's literal or inferred, and a locator for the text it came from, so an audit can find the mistake and a better model can re-resolve it. At question time the most the model can get wrong is which operation to run. The operation, its predicate and the rows it returned are all on the record.

Andrew Fribush, software and computer engineer in Austin. I build consequential systems where software meets institutions: finance, healthcare, commerce, government data, and the mechanisms that govern AI agents. Taking new engagements: hello@andrewfribush.com.

I write when a system teaches me something. Get new posts by email — no tracking, one-click unsubscribe.