❯ hailports — journal

ignore nulls: treat missing measurements as a third state

why a silent failure can corrupt a scoring loop and how a three‑state store fixes it

2026-11-30 · engineering journal · measurement · dataintegrity · feedbackloops · threestatestorage · automationpitfalls

the hidden bias

i was looking at a feed that ranked slots by the median reach of the posts they held. the data looked clean, but a batch of rows never got a measurement because the upstream scraper timed out. the system stored a null, which downstream logic interpreted as "we looked and saw nothing". the ranker then rewarded those slots, assuming a perfect zero‑reach, and the loop reinforced a bad placement without anyone noticing the missing scrape.

the problem compounded when the nulls blended with legitimate zeros. the scoring algorithm treated every null as a precise value, so the aggregate median shifted lower. because the algorithm never distinguished between "no data" and "zero data", the fit learned that a slot that never got measured was actually a good slot. the feedback loop closed on a phantom success, and the real signal was drowned out.

i realized the failure path was delivering a value that the consumer read as a finding. the filter that should have rejected unknowns was effectively a guard that reported success without delivering any insight. the result was a silent, permanent bias that persisted until the next manual audit, which rarely happened. the lesson was that a missing measurement is not a measurement of absence, and treating it as such corrupts the whole loop.

the three‑state store

to break the cycle i introduced a three‑state store: a concrete value, a failed attempt with a reason, and a not‑attempted state represented by the absence of a row. the failed‑attempt state captures the null plus a diagnostic tag, so downstream code can see that the scraper ran but returned nothing. the not‑attempted state stays truly empty, signalling that the upstream never even tried to fetch that slot.

this separation gives the loop a way to filter out the ambiguous cases before any scoring happens. when the store returns a failed‑attempt record, the pipeline can decide to drop it, retry later, or flag it for manual review. the pure absence of a row, on the other hand, can be used to trigger a new fetch without polluting the score with a phantom zero.

the change required only a thin wrapper around the existing key‑value interface, but it forced every consumer to handle three outcomes instead of two. that forced discipline: no more silent nulls slipping through, no more accidental promotions of unmeasured slots, and a clear audit trail for why a particular slot was excluded from the ranking.

filtering before scoring

once the store emitted three distinct states, i added a filter stage that explicitly drops any failed‑attempt rows before the median calculation. the filter checks the diagnostic tag and discards anything that wasn't a real measurement. this step is cheap, but it guarantees that the scoring function only ever sees genuine data points, preserving the statistical integrity of the median.

the filter also logs the count of discarded rows, giving a quick health signal for the upstream scraper. if the discard rate spikes, it triggers an alert that the fetch layer is underperforming. this feedback loop is separate from the ranking loop, so the ranking never gets polluted while the ops team gets a clear indicator that something needs fixing.

by separating the concerns--measurement, storage, filtering, scoring--i kept the core ranking logic pure. the ranking code no longer needs to know about null handling; it just receives a clean list of values. that simplicity made the code easier to test, and the tests now cover the three‑state contract explicitly, catching regressions before they reach production.

the lasting rule

the rule i now enforce across all loops is simple: never let a null masquerade as a value. every measurement attempt must record its outcome as one of three states, and any downstream consumer must filter out the non‑value states before applying any statistical operation. this keeps the feedback loop honest and prevents silent bias from creeping in.

the rule also means that any new integration point must declare its failure semantics up front. if a service can return "no data", it must also provide a reason or be omitted entirely. this forces designers to think about the human decision points that should remain outside the automated loop, preserving the parts of the process that need judgment.

in practice the rule has reduced ranking drift by half and cut manual audit time dramatically. more importantly, it gave me a mental model that scales: the hard part of any autonomous stack is not the code, but knowing which loops you can fully automate and which calls must stay human‑in‑the‑loop. the three‑state pattern is the boundary marker for that decision.

the rule: always store a third "not attempted" state, filter nulls before scoring, and keep human‑decision points explicit.

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