How I Kept Reading History Intact While Rewriting Card Bodies

← hexisteme · notes · 2026-12-02

I compared the frozen IDs of 261 bundled reading cards with IDs recalculated from their edited copy. Only 129 matched. A compatibility table lets the catalog return the previously assigned UUID when a card's body changes.

In my reading app, fixing a sentence in a bundled card could change which card the app thought it was. Its UUID came from a hash of the domain, title and body. The formula gave the same answer every time it saw the same text. The reader's history, however, needed the same answer after the text changed.

I had a chance to measure the difference during a copy edit. For each of the 261 bundled cards, a catalog test compared its frozen UUID with the one the old formula would produce from the current wording. Only 129 still matched. That count comes from a test over the catalog. It tells me how many references would still line up under the old formula. It tells me nothing about how many readers had opened any particular card.

The reader had already saved the answer

A content-derived ID was convenient when building the catalog. Two entries could share a title and still have different bodies, so adding the body to the hash distinguished them. The trouble started once the resulting UUID became a durable reference. The app used it for reading history, planted cards and saved plans. An installed copy could already hold the previous value when a new catalog arrived.

Imagine a card read yesterday. Today's catalog contains a smoother version of the final sentence. The old formula sees a different input and can produce a different ID. The history record can remain perfectly readable on disk while the lookup for today's card misses it. A database migration that faithfully preserves every byte of the history would do nothing to fix that mismatch.

Minting a fresh UUID and keeping it stable from this release onward would have a similar problem. It would solve future edits while still leaving the previous reference behind. For a card that had already shipped, the value I needed was the one an existing installation could already know.

Freeze the old value before editing the words

I recorded the assigned UUIDs in a compatibility table for the bundled catalog. Its lookup key combines the card's domain, title and ordered tags. Its value is the historical UUID. When loading a card, the app tries that lookup first. An unknown key still uses the old domain/title/body formula.

lookup key       = domain | title | ordered tags
known key        -> return the previously assigned UUID
unknown key      -> derive the UUID from domain, title and current body

The table lets an editor change the body without changing any stored reading records. Keeping old values when rebuilding the table is just as important as choosing its columns. The generator checks for duplicate lookup keys, retains existing mappings and calculates values only for missing entries. Its check mode can report a new card that has no mapping yet. A generator that recomputed every value from today's copy would quietly undo the migration on its next run.

There is a limit hiding in that lookup key. Reordering the tags changes it. So does editing the title or moving the card to another domain. In those cases the new key needs an explicit mapping to the old UUID if it still represents the same card. A fallback makes a genuinely new card loadable, but a successful load alone says nothing about continuity. An automated check for missing entries is useful precisely because a reader could otherwise discover the break long after installation.

Two tests that fail for different reasons

The catalog-wide test checks that the table count matches the number of bundled cards, then looks up every card by its key and compares its actual UUID with the stored value. All 261 bundled cards resolved to their expected table entries in that test run. The per-card lookup matters. A table can have exactly the expected length while an obsolete entry takes the place of a missing one.

A second test takes a real bundled card, appends a sentence to its body and resolves its ID again. Domain, title and tags are preserved. The edited card must receive the original card's UUID. This is the specific operation the editor needs to perform safely. The whole-catalog test catches a missing registration, while the copy-edit test catches an implementation that accidentally puts the body back in charge of identity.

The 129 similarities with the old formula are diagnostic output. The passing criterion is that the app resolves each registered card to its frozen value. Expecting every newly calculated hash to equal the old one would make a legitimate copy edit fail the test. More importantly, it would test a property the reader never requested. The reader needs the saved reference to keep working.

Similar titles answer a separate question

The reading feed had another reason to compare cards. Two entries with different IDs could have titles that a reader experiences as the same, even when their spacing differs. The history filter can compare lowercased titles with whitespace removed, in addition to checking IDs. That helps the picker avoid offering a familiar-looking card again.

It would be tempting to use that title comparison as the migration. A feed that suppresses a duplicate could appear fixed even while a planted card or a saved plan still points to a UUID the catalog no longer returns. The two tests have to stay separate. One asks whether the picker should show a card. The other asks whether a stored reference still names the same catalog entry after editing.

For the next content change, I'd keep a fixture spanning a pair of releases. Take an ID the older app could save, load the edited card, and compare the actual lookup result to that saved value. In this catalog I can make that check before asking a reader to install an update.

FAQ

What did the 129 out of 261 count measure?

It counted bundled cards whose frozen UUID still equaled the value computed from the current domain, title and body. It measured catalog compatibility, with no user histories in the calculation. The separate compatibility check passed for all 261 bundled cards.

What does the app use as its lookup key?

The bundled catalog looks up a previously assigned UUID by domain, title and the tags in their existing order. If the key is absent, it falls back to the original content-based formula.

Can a tag or title edit change the lookup?

Yes. Both are part of the key, and so is tag order. Preserving an ID through those edits requires mapping the new key to the previously assigned UUID.

Related notes

Fixed your problem? Good — that's the whole point of this page. Every note on this site is free to read. I write one of these up whenever I hit a failure worth recording: agent-fleet operations, harness bugs, and the measurement that proved the fix. The email list for these notes — no issue has gone out yet, so you would be on it before the first one.
← hexisteme · notes · about · editorial policy · privacy · contact · CC-BY 4.0