Originally published on hexisteme notes.

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.

Email list for these notes: hexisteme.beehiiv.com — no issue has gone out yet, so you would be on it before the first one. No welcome sequence, no course, no upsell.

More notes at hexisteme.github.io/notes.