In the first part I described how an investigation wiki on the murder of Chiara Poggi came to life, starting from an idea file by Andrej Karpathy and growing, one ingest at a time, into a vault of a few hundred source pages, people, pieces of evidence and contradictions, all of it written and maintained by a language model. It ended at the point where that first design began to break, not because the model wrote badly, but because everything that had to stay consistent across the whole corpus (indexes, chronologies, the timeline, even the check that the work had been done) lived in prose, and prose kept by hand does not scale, even when the hand belongs to a machine that never gets bored.
This second part is about what came next: the rework that turned the wiki into something closer to a database, the small idea it rests on, the scripts that now do the bookkeeping, and the long and rather tedious work of carrying several months of old prose over to the new structure. As before, you can browse the public wiki while you read, and everything I quote comes from the repository1.
1. Patching the old design first
I did not start with a rewrite. When the problems described at the end of Part 1 became evident, my first reaction was the one most of us have with a codebase that has started to creak, which is to fix the worst symptoms one by one and see whether that is enough.
The checklist was the first thing to go. Instead of asking the model to review its own work, I wrote a script, verify-ingest.py, that looked at what was staged in git and checked it deterministically: a log entry had to be present, the relationship arrays could not be empty when the body linked out, tags could not be bare integers, the frontmatter had to match the template, and the category files had to be updated together with the pages they indexed. A pre-commit hook ran it, so an ingest that did not pass simply could not be committed. The duplicate check went next, since "read the last twenty log entries" was useless against a backlog of seven hundred articles ingested out of order, and it became the most boring question possible, that is, whether the source page already existed on disk. The log, which had become a second copy of the wiki, was closed as a historical archive and replaced by one file per year in a terse format that only records bookkeeping. And the timeline, which every ingest had to read in full just to find where a new date belonged, was split into one file per event year with a thin hub listing them.
Each of these fixes helped, and yet all of them were of the same kind: the scripts could notice that an edit was missing, but they could not produce it. The categories were still written by hand, the chronologies on people pages were still prose, and every timeline entry was still placed, by the model, in the right position of the right file. What I had built, to be honest, was a hand-maintained wiki with a linter, whose job was to notice when the hand slipped.
There was one more symptom, and it is the one that convinced me the problem was structural. The case overview, the page every session read first, had grown a section of "recent updates" to which every ingest appended a few paragraphs, and by then that section made up 93% of the page, so that a new session spent around fifty thousand tokens reading a changelog before doing anything useful. Moving it to an archive was easy enough, but it showed the same pattern once more, since the model had been asked to keep the page current and, lacking any better place to put the news, had kept adding to it.
2. The idea: write once, derive the rest
The way out came from looking at the wiki the way I would look at a software project. In a codebase there is a clear line between what people write (the source code) and what is produced from it (the compiled binaries, the generated documentation, the indexes your editor builds), and nobody would ever think of editing a compiled file by hand and hoping it stays in sync with the source. The first wiki had no such line, and the timeline, the category indexes and the chronology on each person's page were all, in effect, build artifacts maintained by hand.
So the rework, which in the repository goes by the name of v2, rests on a single decision: everything redundant in the wiki is generated, and only what requires judgment is written. What is redundant is easy to spot once you look for it, because it is everything that repeats a fact already stated somewhere else (the timeline entry repeating what a source says, the person page listing the same event again, the index listing the page), while what requires judgment is the summary of a source, the analysis of a contradiction, the argument for or against a hypothesis.
For the generator to work, though, the facts had to stop living inside paragraphs, and needed a structured home of their own, a file that a script could read without having to understand Italian prose. That home is the claims ledger, one YAML file per source, and the architecture became the following:
flowchart TB
RAW["raw/<br/>immutable sources"] -->|ingest| SP["wiki/sources/<br/>source summary"]
RAW -->|"ingest:<br/>verbatim quotes"| CL["claims/<br/>one YAML per source"]
CL -->|build.py| GEN["generated views<br/>timeline, indexes, links"]
CL -->|distill| CUR["curated prose<br/>pages, hypotheses"]
CL -->|query.py| DB[("SQLite<br/>cache")]
CUR --> SITE["published wiki"]
GEN --> SITEThe raw sources are still immutable, and each ingest still writes a source page, which remains the human-readable summary. Next to it, though, the ingest now writes a claims file, and from those claims a script called build.py derives everything that used to be maintained by hand. The prose that requires judgment (the profile of a person, the reasoning on a piece of evidence, the state of a hypothesis) is revised separately, in sessions called distill that I will get to later. The schema document puts it in one sentence, which is probably the most important rule in the whole vault:
Never hand-edit generated content. To change it, edit the claims (or the page frontmatter), then run the build.
3. Anatomy of a claim
A claim is a single statement made by a source, recorded with enough structure for a script to place it, check it and render it. This is the beginning of the claims file for a Panorama article from May 2025, about the palm print found on the wall of the basement stairs, the one known in the case as "impronta 33":
Every field is there for a reason, and most of the reasons come straight from the failures of the first design:
| Field | What it holds | Why it exists |
|---|---|---|
id | c01, c02, … unique in the file | gives each claim a global address, <source>#c01, that pages can cite |
type | fatto, dichiarazione, inferenza, ipotesi, contesto | the inline labels of Part 1, turned into a closed list |
date | the date of the event, not of the article, with ~ for approximate and / for ranges | places the claim in chronologies and in the timeline |
subjects | the pages the claim is about, such as people/andrea-sempio | every subject must be an existing page, so links cannot break |
text | a standalone Italian sentence | what gets rendered, readable without opening the source |
quote | a verbatim excerpt of the raw file | the anchor that a script can verify |
confidence | verified, claimed, inferred, speculative, unknown | the epistemic status of this claim, independent of the source's reliability |
speaker | the person making a dichiarazione | builds the "attributed statements" section of their page |
timeline, title | whether this is a major event, and its header | the only way an entry reaches the master timeline |
The type field deserves a word, because it is the direct heir of the labels [FATTO], [DICHIARAZIONE] and the others, the convention I described in Part 1 as the most useful one in the whole project, and of the [CONTESTATO] label that the model had made up on the very first ingest. In the first design those labels were a request, while now they are a closed list that a script checks, and a claim with any other type is simply rejected. A fifth value, contesto, was added for background, since newspaper articles about a case that has been going on for nineteen years spend a good part of their length recapping what happened in 2007, and those recaps, if rendered on every person page, would bury the new information under hundreds of copies of the same old facts. contesto claims stay in the ledger and on the source page, but they do not reach the chronologies.
The date is always the date of the event. A 2025 article explaining that the palm print was catalogued by the RIS in 2007 produces a claim dated 2007, as c02 shows, and that one decision is what lets a script build a chronology out of hundreds of articles written in a completely different order.
And then there is the quote, which is the heart of the whole rework. Every fatto and dichiarazione must carry an excerpt copied word for word from the raw file, and if no quote can be found (because the information comes from a table, say, or from a caption) the claim has to say so explicitly in a no_quote_reason field. Out of almost twenty-seven thousand claims in the vault today, thirty-one use that escape hatch.
4. The verifier
The reason the quote matters is that it can be checked by something other than the model. verify-ingest.py, the script born as a replacement for the self-review checklist, grew into the gatekeeper of v2, and its central check is very simple: take the quote, take the raw file, normalize both, and see whether one contains the other. The normalization is the only clever part, and it is small enough to show in full:
Accents, case, typographic quotes, dashes, markdown emphasis and whitespace are all flattened, because Italian newspapers are inconsistent about all of them and a model copying a passage will sometimes "fix" a curly apostrophe without meaning to. Everything else must match exactly, which is why c02 above can quote “ **numero 33**” with the bold markers of the converted article and still pass, while a quote that rewords a single word does not. The check that uses it, inside the loop over a file's claims, is just as short:
Here raw_norm is the whole raw file passed through the same normalization, once per claims file, so the test is a plain substring search, with no fuzzy matching, no similarity threshold and no model involved. A model can still make up a fact, of course, but it can no longer make up a quote, and a fact without a quote does not get into the wiki.
The quote is only one of the checks. The full list for a claims file looks like this:
| The commit is rejected when… | Why it matters |
|---|---|
a fatto or dichiarazione has no quote and no no_quote_reason | every fact must be anchored |
| a quote is not found in the raw file after normalization | paraphrase is not a quote |
type or confidence is outside its list | no more invented labels, no more scales swapped for each other |
a subject or speaker has no page | links cannot break, entities cannot be misspelled into existence silently |
a speaker is set on something other than a statement | only statements have speakers |
timeline: true has no title or no date | every timeline entry must be complete |
a date does not follow [~]YYYY[-MM[-DD]], optionally as a range | chronologies must be sortable |
| the claims file has no source page, or the other way round | the two halves of an ingest travel together |
| any generated file is stale or edited by hand | the build output must always match its inputs |
Bear in mind that the confidence and reliability mix-up I mentioned at the end of Part 1, the one that went unnoticed for seven weeks, would now fail the third row on the very first commit. When something does fail, the commit stops and the model gets a message precise enough to fix the problem without guessing, for example:
The hook runs on every commit, and since a hook is installed locally and could in theory be skipped, the same script runs again on the server, over the whole corpus, every time the vault is pushed. Only after that does the public site get rebuilt.
flowchart TD
W["ingest or distill session<br/>writes pages and claims"] --> B["build.py<br/>regenerates every view"]
B --> C["git commit"]
C --> H{"pre-commit hook<br/>verify-ingest.py"}
H -- fail --> F["read the message,<br/>fix, stage again"]
F --> C
H -- pass --> P["git push"]
P --> CI{"CI<br/>verify-ingest.py --all"}
CI -- pass --> S["public site rebuilt"]The point of all this, and I think it is worth stating plainly, is that the judge is no longer the model that did the work. The model can be careless, tired (in the sense that its context is full), or simply wrong, and the commit will still be rejected, without anyone having to read the diff.
5. The generator
With the facts in a structured ledger, build.py can produce everything that used to be written by hand. It is a pure generator, meaning that it reads the claims and the page frontmatter and writes its output, without ever deciding anything, and it owns the following:
- the master timeline, as one file per event year plus a hub, built from the claims marked
timeline: true; - the category indexes in
categories/, one line per page, using a short description stored in each page's frontmatter; - two marked regions on every entity page: the chronology (every claim about that person, place or piece of evidence, in date order) and, for people, their attributed statements;
- the
sources:andrelated_*arrays in the frontmatter, which the first design asked the model to keep up to date and which were often empty or incomplete; entities.json, a registry of every entity with its aliases, which the ingest uses to recognize that "il fidanzato di Chiara" and "Stasi" are the same person;- a report of candidate conflicts, that is, groups of claims on the same subject and date coming from different sources, which a later session examines by hand.
A single claim, then, ends up in several places at once, without anyone having to remember to put it there. This is what happens to c01 of the Panorama article above:
flowchart LR
C["claim c01<br/>impronta 33, May 2025"]
C --> T["timeline 2025<br/>entry with title"]
C --> P1["Andrea Sempio<br/>chronology"]
C --> E1["evidence: palm print<br/>chronology"]
C --> A["frontmatter arrays<br/>sources, related_people"]
C --> X["category index<br/>source listed"]
C --> R["conflict candidates<br/>if sources disagree"]It is the same fan-out as the "one source, thirty-three pages" diagram of Part 1, with the difference that now a script draws it. The timeline entry it produces has exactly the format the first design had invented, so the published pages did not change their appearance, only their origin:
On entity pages the line between written and generated is drawn with two HTML comments. Everything above the marker is curated prose and belongs to the distill sessions, and everything between the markers belongs to the build, which rewrites it from scratch every time it runs. Here is the point where the two meet on Andrea Sempio's page:
The function that writes those regions does little more than find the two markers and replace whatever sits between them, and when a page has no markers yet it appends the section at the end, so the hand-written part above is never touched:
The build also has a --check mode, and it is the reason the whole arrangement holds. The entry point computes every output in memory first, then compares each one with the file on disk, and either writes the files that differ or, with --check, lists them and exits with an error:
Since the output depends only on the claims and the frontmatter, running the build twice gives the same files, and any difference between what the build would write and what is on disk means one of two things: someone (human or model) edited a generated region by hand, or someone changed a claim and forgot to run the build. Either way, that is the last row of the verifier's table, and the commit fails.
The effect on the files that held the shared state was immediate. When the category indexes became generated, the index of sources went from about 312 KB to 83 KB and the index of people from 49 KB to 10.5 KB, simply because a generated line says what it needs to say and nothing else, while the hand-written ones had accumulated summaries, notes and second thoughts. More importantly, the files that every ingest used to read and rewrite (the indexes, the timeline, the chronologies) are no longer touched by the ingest at all, so two ingests can no longer conflict over them, and the model no longer has to load them into its context.
Queries changed too, although less visibly. Instead of opening pages and following links, a query session now starts from a small command-line tool, query.py, which loads the claims into a local SQLite database and can answer questions such as "every statement by this person", "every claim about this piece of evidence after this date" or "every claim with this word in its quote", each with its citation, before the model opens a single page.
6. Cutover: freezing the past
The difficult part of a rework like this is not the new design but the old content. At the moment of the switch the wiki held 448 source pages, written over a few months, and not a single machine-readable claim: every fact lived inside a paragraph, readable by a person and opaque to a script. Rewriting all of it before switching would have meant stopping the wiki for weeks, while switching without it would have meant publishing a timeline with a hole the size of the whole first design.
The solution was a forward-only migration, which is a common pattern for databases and works just as well here. A migration script extracted the old content that the generator was about to take over (the 354 entries of the master timeline and 857 dated bullets from the chronologies on people pages) and froze it, word for word, in a legacy/ directory. From that moment build.py merged two inputs, the frozen legacy entries and the new claims, and sorted them together, so that the published timeline and chronologies looked exactly as before while their source of truth had changed underneath. The rules for legacy/ were strict: it could be read, it could shrink, but it could never grow, and nobody, model included, could edit it by hand.
After the cutover, every new source went through the new ingest and produced claims, while the old ones waited for what the plan called the backfill.
7. The backfill
Backfilling meant going back to each of the 448 pre-v2 sources, reading its raw file again, and writing the claims file that it would have had if it had been ingested under v2. It is a long and repetitive job, exactly the kind that a model is well suited for, provided that something checks its output, and in this case the verifier did. The sources were processed in batches of five to eight, oldest first, one subagent per source, and each batch ended with a script, legacy-retire.py, deciding which frozen legacy entries could now be deleted because their content was covered by the new claims.
The retirement rule is deliberately conservative. A legacy entry usually cites one or more sources through their links, and it is retired only when every source it cites has been backfilled, so that an entry built on two articles waits until both of them have claims. In code, the whole rule is a subset test between the sources an entry cites and the sources that have a claims file:
cited is the set of sources linked from the entry's text, and cited <= effective is Python's way of asking whether it is a subset. An entry with no links at all is never retired automatically, and neither is one placed on hold by hand. This is why the curve below flattens towards the end: the entries retired first were the simple ones, while those citing several sources kept waiting for their last one.
xychart-beta
title "Backfill: legacy entries left (bars) and backfilled claims (line)"
x-axis ["start", "6", "12", "18", "24", "30", "36", "42", "48", "54", "60", "66", "67", "end"]
y-axis "count" 0 --> 5000
bar [1211, 939, 796, 656, 549, 463, 389, 316, 264, 226, 185, 153, 152, 0]
line [0, 494, 889, 1290, 1637, 1965, 2337, 2729, 3202, 3798, 4282, 4764, 4790, 4790]It took sixty-seven batches, spread over the summer and autumn whenever I had time and usage left on my subscriptions, and it produced 4,790 claims from the old sources. At the end, 152 legacy entries were still there, the ones that no backfilled claim covered, and those needed a different kind of work, because a script could not decide what to do with them. For each of them a session followed a fixed order: if the same fact was already in a claim, the entry was retired with a reference to that claim; if a distinctive phrase could be found in a raw file, a claim with a verbatim quote was added to that source's claims file and the entry was retired; if nothing supported it, it was retired as unsupported; and if it was a plausible historical fact whose source simply could not be found, it could be kept, explicitly marked as unattributed. Every one of these decisions was written to a log with its reason. In the end all 152 were retired, twelve of them after a new claim had been written from a raw file that the original ingest had not fully exploited, and legacy/ is now empty.
I would argue that this is the part of the project where the deterministic approach paid off the most, even though it is the least visible. A model asked to "migrate the old content to the new format" would have produced something plausible and impossible to check, while a script that deletes a legacy entry only when every source it cites has quote-anchored claims, and a log that records why each of the remaining ones was retired, turn the migration into something you can actually audit.
8. Bookkeeping and judgment
Once the generated views were taken away from it, the ingest became much smaller. In the first design a single ingest had to read the source, write its page, update the overview, update every person, place, piece of evidence and hypothesis it touched, insert entries in the timeline, flag contradictions, update the indexes and write the log, which is why the median article touched seven files and a single context had to hold most of the wiki. The new ingest is proportional to the source and nothing else:
flowchart TD
A["ingest request"] --> B{"does wiki/sources/slug.md<br/>already exist?"}
B -- yes --> STOP["stop: already ingested"]
B -- no --> C["read the raw file in full"]
C --> D["write the source page"]
C --> E["write claims/slug.yaml<br/>quotes, subjects, stubs"]
D --> F["build.py"]
E --> F
F --> G["flag contradictions, leads<br/>only if warranted"]
G --> H["terse log entry"]
H --> I["commit through the hook"]The source page, the claims file, a stub page for any entity that does not exist yet, a line in the log, and very little else. Rewriting the curated prose (a person's profile, the reasoning on a piece of evidence, the arguments for and against a hypothesis, the overview) moved out of the ingest into a separate operation called distill, which runs every few dozen ingests and takes as its input the claims added since the previous one. Its first rule is to rewrite rather than append, because a curated section should state what is known now, while the history of how we got there already lives, generated, in the chronology below it.
The split matters because the two kinds of work are very different. Extracting claims from a source is narrow and checkable, and it can be given to a smaller, cheaper model, while deciding what a new set of claims means for a hypothesis needs the whole picture and the best model available, and it cannot be checked by a script at all. Keeping them in the same session meant paying the expensive kind of attention for the cheap kind of work, and filling the context with pages that had nothing to do with the source being read.
That said, the extraction did not come out right at the first attempt, and a few lessons were learned along the way, each of which became a rule in the ingest workflow. Recap passages, as I mentioned, were flooding the chronologies until contesto was separated from the other types, and an audit had to go back and retype a hundred and forty claims. Subagents on smaller models turned out to extract investigative articles thoroughly but to treat profile articles (the kind of piece that tells you a person's age, job, family, and how long they have known the other people in the case) as colour to skip, so that a long profile of a consultant produced a single claim, until the workflow said explicitly that for people who are, or should be, entities in the wiki, those details are claims. And distill sessions, even with the rewrite rule, kept making the curated pages longer, so the verifier gained a size check on the hand-written part of each page, which for now only warns, and which will block a commit that makes an already oversized page grow once the largest pages have been brought back within their limits.
9. What code cannot check
It would be dishonest to present the verifier as a guarantee of truth, because it guarantees something narrower, and it is worth being precise about what.
A quote can be verbatim and still not support the claim. Look again at c01 above: the quote says that the new expert report "accende i riflettori su un dettaglio finora inedito", which is true and does appear in the article, but the claim's text says that the report attributes the palm print to Andrea Sempio, and that part is supported by other sentences of the article, not by the one chosen as the anchor. The verifier checks that the words exist, not that they mean what the claim says, and that is why audits still spot-check a sample of claims against the context of their raw file, by reading them.
Entities can still be duplicated. The verifier checks that a subject has a page, but when an ingest decides that a person is new it creates that page itself, and a name misspelled by a newspaper (the vault had, at one point, a Marchigiani, a Marchegiani and a Machegiani, all the same person) produces three perfectly valid pages. A guard against near-identical names now rejects most of these cases, but it cannot tell a typo from two people whose names really are almost the same.
Conflicts are found, but not understood. The report of candidate conflicts groups claims on the same subject and date from different sources, which is useful in a small corpus and overwhelming in a large one, since twenty articles on the same day of a hearing produce many groups that are not conflicts at all. The report has grown to several megabytes, and the rule today is that no session ever opens it whole. A lexical filter for duplicate timeline entries was also tried and abandoned, because on a sample most of what it would have removed were different events that happened to share a date, a subject and some vocabulary (an exhumation and a funeral, a summons and a refusal to answer).
And the deeper question of whether different sources are repeating the same fact was measured before anything was built: on a month of claims, the share that was truly redundant with a claim from another source came out below three percent, while many more refined each other, each article repeating a known theme with one more detail. Merging them would have lost that detail, so the wiki keeps every source's claims separate and leaves the reconciliation to distill.
None of this undermines the approach, as far as I can tell. The deterministic layer does not replace judgment, it moves judgment to where it is needed, and takes it away from places where a machine can do better, such as checking that a string appears in a file, or that a date can be sorted.
10. Where it stands
This is the wiki at the three points that matter for this story2:
| End of the first design | End of the backfill | Today | |
|---|---|---|---|
| Source pages | 448 | 777 | 1,729 |
| Claims | 0 | 9,326 | 26,912 |
| Timeline entries | 354 | 607 from claims, plus legacy | 1,123 |
| People pages | 143 | 251 | 417 |
| Evidence pages | 33 | 46 | 71 |
| Contradiction pages | 13 | 30 | 58 |
| Legacy entries | n/a | 152 | 0 |
The claims, by type, are distributed as you would expect from a corpus made mostly of newspaper articles about an ongoing investigation, with statements outnumbering facts:
| Type | Claims |
|---|---|
dichiarazione (statement) | 12,772 |
fatto (fact, according to the source) | 8,249 |
contesto (background) | 3,269 |
ipotesi (hypothesis) | 1,365 |
inferenza (inference) | 1,257 |
Looking at these numbers, though, I cannot help noticing that the hardest problem of Part 1 has been solved and replaced by a different one. Keeping the wiki consistent is now mechanical, and a source can be ingested without the model having to hold the rest of the wiki in its head, but the sources still had to be found, converted to markdown and filed by hand, and every ingest session still began with a model reading the operating manual, the workflow, the schema and the entity registry before even looking at the article, a fixed cost paid again by every subagent. When the backlog of articles waiting on disk passed five hundred, it became clear that the expensive part was no longer maintenance, but everything around it: finding the sources, and the agent loop itself.
That is where the third part begins, with a crawler that looks for new sources on its own, a single-call extraction that replaced the subagents for articles, and a loop that runs ingest, distill and audit unattended, along with what all of that cost, measured.