Note 03 · Architecture

A mirror is not a second authority

Architecture / PostgreSQL / Knowledge layer

A document product with a knowledge layer has one question to answer before any of the interesting parts: when the same fact exists in two places, which one is true? The layer I built answers it by never letting the second place invent anything.

Two tables, one owner

Facts and summaries live in the product’s own database so the product can read them without asking anyone. The values in those rows come from the inference service and are rewritten on every sync; the only columns the product writes are the review ones - status, reviewer, timestamp.

That asymmetry is the whole design. A mirror that starts writing its own values is how one question ends up with two answers, and the second answer always looks better, because it is the one the page displays.

A fact that moved stays visible

Every fact carries the quote it came from and character offsets into the document. When the document changes under it, the fact is marked stale rather than deleted or hidden.

Hiding it would hide the news. In a document product, “this used to be true, and here is where it used to say so” is information; silently dropping the row turns a visible contradiction into a missing feature, and the reader cannot tell which one they are looking at.

A decision is not an artefact

Re-extracting a document deletes its extracted knowledge units, and it should - they are outputs of a model, and a new model produces new ones. What a person decided about those outputs is not an output.

So the decisions live in their own rows with their own lifecycle. An entity merge is recorded as a decision, survives the re-extraction that removes the units it referred to, and gets relinked by name and document when the artefacts come back. The row can dangle for a while; it is never quietly thrown away, because throwing it away would mean the same person makes the same decision twice.

Why the graph stays in Postgres

Four reasons, in the order they mattered. The questions this product asks are joins two hops deep, and they run inside the same request that serves the page - a second store adds a round trip that costs more than the traversal saves. A second store is also a second truth: a document and its edges could commit on different schedules and quietly disagree, and the corpus is the one thing I refuse to hold twice. Backup, restore and migrations would double for a component that is not the point of the product. And at the sizes this system runs at, SQL over an indexed table is not the bottleneck - the model calls are.

The counter-case is worth stating, because “no graph database” is a decision about this workload, not a position. If traversal depth grew to three or more hops, or if other services needed to query the graph independently of this product, the trade flips and I would move it.

What I refused to report

A recall figure for a corpus I had not labelled. I could have produced one from the embedding scores and it would have looked scientific. Without labelled queries the honest output is “unknown”, and the retrieval service exists because of that refusal.