Writing / note
Two witnesses: knowing when a transcript is stale
How Spirivia decides a transcript is out of date without timestamps or guesses: every result records the soil it grew from, and a stage is stale exactly when that soil differs from what exists now.
Spirivia keeps a library of my recordings. Each one has a transcript, word timings, who spoke when, and which of those speakers are people I know. All of that was produced by some version of Spirivia, with some models, some code, some settings.
Then Spirivia changes. A model gets a new revision. The diarization engine is swapped. I enroll a new voice. The code that turns words into speaker turns gets a fix. Which recordings are now out of date?
For a long time the honest answer was: I don’t know. This note is about how it stopped being that, and the idea underneath, which I think applies to almost anything that derives data from other data.
The bug class
Before this, the app had no Refresh at all. It read the library once at start. Anything that happened behind its back was invisible until restart. When I added Refresh, I found real bugs along the way: the open record was a position in a list instead of an id, so after a new import the reader showed someone else’s recording, and a removed record panicked the app.
Those are the visible ones. The quieter one was worse. A correction I made to a speaker in one recording was anchored to that recording’s diarization. When the diarization re-ran under exactly the same models and settings, the anchor compared the whole stage object, including when it ran and how long it took. Same result, new timestamp, every correction orphaned.
All of these are one kind of bug: a change on one side that the other side never witnesses.
Two witnesses
The idea, as I put it on 26 November: “The two witnesses here are the audio asset and Spirivia. Reciprocal change. Two loops witnessing each other.”
Loop A: Spirivia witnesses the asset. A recording appears, disappears, moves, changes its bytes, is half-processed, or a person in it gets corrected. Spirivia notices and looks again.
Loop B: the asset witnesses Spirivia. Spirivia changes: models, revisions, code, thresholds, voiceprints. Every recording that grew under the old Spirivia is looked at by the new one.
Each witnessing is recorded on both sides. Neither side is the source of truth with the other as a cache. That’s the part that matters.
Soil
To make loop B precise I needed a word for “everything a result grew from”. I use soil.
The soil of a stage is its model and revision, the code that ran, the environment locks, the settings that act as cache keys, and for speaker recognition, the enrolled voiceprints. Then the rule is one sentence:
A stage is stale exactly when its recorded soil differs from the soil it would grow in now.
Not a timestamp. Not a guess. Not “this file is older than that file”. Two things are compared: what the record says it grew from, and what exists now.
There are two witnesses in the mechanism too, one per side:
- The library publishes its current soil in
library/_soil.json. That’s what Spirivia is today: per stage, which model, which code hash, which voiceprint fingerprint. - Each record keeps its stage history. When a stage is re-run, the old stage object is appended to
stages_historybefore the new one replaces it. History only grows. It is never rewritten.
The app compares the two in Rust (crates/spirivia-library/src/soil.rs) and gives each stage a verdict.
Hashing the right things
The first draft used the git revision as the code part of the soil. That was wrong, and the way it was wrong is worth knowing.
A git rev moves on every commit, including commits that have nothing to do with transcription. So every unrelated change would mark the whole library stale. And it misses edits that aren’t committed. It’s both too sensitive and not sensitive enough.
What the soil holds instead is a content hash of exactly the files a stage runs. Not the repository, not the folder: the files that shape that output.
The first version of that hash also took the whole lock files, and that was still too coarse. Any lock bump or edit to the transcription script re-staled every stage. Now each stage hashes only the packages that compute its output, plus the nix inputs and model revisions it runs on. Looking back over ten past lock or transcription-script changes, MEASURED, one touched a package that computes anything, and none touched ASR. Under the first version, all ten would have re-staled the whole library.
A second correction: the requested language turned out to be soil too. Twelve records forced Portuguese and one auto-detected Portuguese, and the stored language field read the same for all of them. So the stage now also records what was asked for, not only what came out.
And the corrections bug from earlier is fixed by the same idea in reverse. Two stages have the same soil when they are equal except for telemetry: when they ran, how long they took, their history. Re-running under identical soil keeps every correction.
Unknown is not different
Some recordings were processed before the lab recorded code hashes at all. What should they say?
It’s tempting to call them stale. They might be. But that’s a guess, and the rule says no guesses. So they get their own verdict, Unrecorded, listed quietly and not counted as stale. Unknown is not different.
The full set of verdicts: ok, unrecorded, stale, partial, unprocessed, and text only for old transcripts that only have text. Each stale one names why. In the app that reads as “voice separation: impl pyannote, now nemotron-3-diarization”.
The banner reads something like “30 processed by an older pipeline”. Not an alarm. A fact about the library that I didn’t have before.
What it doesn’t do on its own
Re-processing is a button, never automatic. Refresh tells me what’s stale and why. It doesn’t spend hours of compute on my behalf. When I press Process, the plan goes to the processing service: per record, the smallest stale suffix of stages, meaning a stale stage plus everything downstream of it.
There was a gap, and part of it is still open. The lab’s caches used to be keyed without the code hash. After a code change, a re-process could hit the cache, re-run nothing, keep the old hash, and the record would still correctly read stale. Honest, but not useful. The ASR and alignment caches are now keyed by the same stage soil, so a cache hit is a result of the same soil. Diarization’s cache still has its own key without the code hash, so that one can still re-run nothing after a code change.
The GPU runtime fits into the same scheme from the other side. Its results carry a Backend digest that covers everything that decides their bits, down to the GPU’s compiled machine code, and that digest goes into the stage keys. A driver update that changes the machine code becomes a soil change like any other.
The idea, without Spirivia
Strip away the transcripts and this is a small, reusable pattern for anything derived:
- Record the soil on the result. Everything it grew from, hashed at the right grain: the inputs, the exact code that ran, the settings that shape it. Not a git rev, not a timestamp.
- Publish the current soil in one place.
- Stale means different. Compare recorded soil to current soil, key by key. Then you can always say why.
- Keep history append-only. When a result is replaced, keep what it replaced.
- Unknown is its own answer. Don’t promote “not recorded” to “stale”.
- Compare soil, not telemetry. When it ran and how long it took are not what it grew from.
Neither side is the cache. Both sides witness.
The design is in docs/planning/2026-11-26-refresh.md in the Spirivia repository.