❯ hailports — journal

the cache answers the wrong question about publishing

a missing page reported as 'unchanged' taught me that hash caches measure source drift, not delivery, and the fix is smaller than the failure suggests.

2026-12-02 · engineering journal · caching · publishing · state · reconciliation · debugging

what it looked like from the outside

the symptom was quiet in the way that quiet is worse than loud. one published page on the stack just wasn't there anymore -- a plain not-found at the destination -- while every run in the publisher's log ended with the same bland line: unchanged, nothing to do. no error, no retry count climbing, nothing in the alert channel. the site rendered fine except for the one gap, and nothing in the telemetry thought the gap was worth mentioning.

it was easy to misread because everything downstream was telling the truth from its own seat. the publisher genuinely believed it had nothing to do. the scheduler genuinely believed the job had run. the destination genuinely had no file. three honest components, one contradiction between them, and no single log line that captured the disagreement. the failure lived entirely in the space between what a component knew and what it claimed.

the day-job instinct here is old and reliable: when a distributed pipeline reports success but the artifact is missing, stop reading the success messages and start reading the memory. something cached a conclusion instead of a fact. in a fortune-a few hundred pipeline that mismatch gets a postmortem and a dashboard; on a one-machine stack it gets me at a kitchen table on a weeknight, diffing state files by hand.

what made it extra slippery is that the same publisher had produced this exact artifact dozens of times before without complaint. the change that broke it wasn't in publishing logic at all. it was in what the publisher had stopped checking. that distinction -- logic versus belief -- turned out to be the whole story.

the wrong theory

my first theory was that the publisher itself had a regression. something in its decision path had gone stale -- a template change, a route rename, an id that drifted -- and the code was silently skipping a class of artifacts it didn't recognize. that theory fit the evidence well enough. the artifact category in question had been touched recently, the skip was deterministic-looking, and deterministic-looking failures usually mean code.

so i spent the better part of an evening reading publisher logic line by line, adding debug output, rerunning the job against a scratch destination, watching it correctly generate the artifact every single time. which was, of course, the evidence against my theory wearing the costume of evidence for it. if the publisher could produce the artifact when pointed at a clean destination, then its logic was fine and the problem was upstream of the decision -- in the inputs to the decision.

the specific upstream component was the hash cache: a little state file where the publisher records, per artifact, the source hash it last saw, so it can skip work when nothing changed. the skip path was answering the question 'did the source change since last time' and answering it correctly. but the question the run actually needed answered was 'does the published artifact exist at the destination and match what i would produce'. those sound like the same question. they are not, and the distance between them is where my page went missing.

i'd seen this exact shape before in a production feed that normalized drafts on the way through -- there too the cache held a truth about inputs while the pipeline depended on a truth about outputs. i didn't reuse that fix, but i did reuse the suspicion. sometimes the transferable part of a day-job incident isn't the code, it's the direction you look first.

what actually settled it

the measurement that decided it was almost embarrassingly simple. i took the state json the publisher keeps, found the single key corresponding to the missing artifact, and deleted that one key. then i reran the publisher, unchanged, no flags, no repair mode. it immediately regenerated the artifact, wrote it to the destination, and updated the cache. the page was back. one key, one rerun, one confirmed cause.

i then reran the full publish cycle a second and third time to make sure the cache re-converged and nothing else regressed -- no other artifact changed, no other key got touched, the run stayed quiet. that mattered because it told me the corruption was local to one entry, not systemic to the file. a single lost or never-written key, not a schema problem, not a versioning problem, not the publisher misreading its own state.

the method generalizes and i'd describe it to anyone the same way: isolate the belief, not the code. find where the system recorded its conclusion, remove that one conclusion, and rerun. if the behavior heals, the decision layer is fine and the memory layer was wrong. if it doesn't heal, you've learned the problem is genuinely in logic and you've spent ten minutes instead of an evening finding that out.

what the measurement couldn't tell me was why the key went missing in the first place -- an interrupted run, most likely, some earlier crash between computing the hash and writing the state. i didn't chase that all the way down. the recoverable failure mattered more than the unprovable origin, and the stack's whole philosophy is to make state boring enough that boring failures stay cheap.

the fix

the actual fix, for now, is procedural: when a published artifact is missing but the publisher reports success or unchanged, suspect the hash cache before the publisher logic, and drop the single offending key rather than the whole cache. that last clause is load-bearing. wiping the cache forces a full republish of everything -- slow, noisy, and it destroys the signal about which artifacts actually drifted, which is signal i want when i'm already debugging.

i deliberately did not rewrite the publisher. its skip logic is correct within its model; the model is just incomplete. i also didn't add a global verify-everything pass on every run, which would have turned a one-machine stack into a perpetual full-scan job and burned the whole point of caching in the first place. the temptation on a side project is to overcorrect after any incident, because nobody stops you. restraint is a feature you have to ship yourself.

the real fix, the one i've scoped but not shipped, is small: before trusting a cache hit, stat the destination. check that the file exists and matches the recorded fingerprint, and treat a mismatch as a miss rather than a truth. one filesystem call per artifact on the skip path, a few hundred microseconds on this box, and the cache stops answering a question nobody asked. it's worth doing if this recurs; i've decided once is not enough to justify it and i've written that decision down so it survives my memory.

i almost didn't record the decision and immediately regretted the instinct, because six months from now the recurrence won't come with tonight's context attached. the fix log and the not-fix log are the same log. what i chose not to build is as much part of the architecture as what i did.

the rule i keep now

the rule is: a cache about inputs can never vouch for outputs, so every publisher on the stack must be able to answer 'does the artifact exist and match' from the destination side, and any success or unchanged message that can't is a claim, not a fact. in the day job this rule comes with a compliance apparatus around it -- reconciliation jobs, drift detection, the whole liturgy. on a one-machine business there's no apparatus, so the rule has to live in the design instead: keep state small enough to inspect by hand, make conclusions cheap to invalidate one at a time, and never couple a repair action to a full rebuild. the same loops transfer, but on the small stack they transfer as judgment rather than as tooling, and judgment is the part i actually have to maintain. the hard part was never knowing how to fix it -- it was knowing which day-job instinct to import wholesale and which one to shrink until it fits a machine that also has to do everything else.

the rule: the cache tells me the source didn't change; only the destination can tell me the artifact is real, so drop one key and rerun before you touch any logic.

related field guides

earlier entries

see the machine this came out of

the board is public. the scan is free. the playbook is the long version of entries like this one.

← journal · hailports