The Doozer Brainlive from the knowledge bundle · v2.2.618 · 2026-09-13 17:17 ETall pages · one page

Derive the URL, don't trust the stored domain

craft/derive-dont-store-the-active-domain.md · System · craft, urls, data-integrity, follows, staleness

unverified: no trust signals recorded yet

A saved business's link is always computed from the business's currently-active domain, never read from the domain id we stored when it was saved — because that stored id goes stale and poisons the link.

Derive the URL, don't trust the stored domain

When a user saves a business, the obvious schema records which domain they saved it on (lb_follows.domain_id) so we can link back to it later. Reading that stored id at render time feels correct and is one join cheaper. It is also a bug, and a quiet one.

Why the stored id rots

A business's domain is not stable. Sites move between roots, subdomains get regenerated, a business gets a better home, a domain is deactivated. The moment any of that happens, every lb_follows row that captured the old domain_id now points at a domain that may be inactive, wrong, or gone. The user's "saved" link 404s or lands on a dead host, and nothing errored when it broke, so nobody notices until a person taps a saved item and hits a wall (a dead end, the one thing we refuse to ship).

The rule

Always derive a saved business's URL from that business's currently-active domain, resolved fresh at render time, never from the domain_id stored on the follow. The stored id is treated as poisoned. The join is one step longer and the link is always live.

Why it is craft

The insight is recognizing that a foreign key can capture a fact that was true once rather than a fact that stays true, and that "the domain this was saved on" is the second kind. The stored value looks authoritative and is actually a snapshot with an expiry you cannot see. This is the same shape as fix the source, not the symptom: do not patch dead saved-links after the fact, compute the link from the source of truth every time so it cannot go stale.

Decision vs delivery (the muse was almost never the problem)Fix the source, never trap the symptom