The gate that read "nothing matched" as "not confident"
- Symptom
None. Correct answers, produced slowly, at full price, indefinitely. The finding came from reading the audit trail rather than from anything going wrong.
- Diagnosis
Write-back is gated on a confidence threshold, which is the right instinct. A shared cache should not be seeded with answers the system was unsure about, because a bad entry gets served to every future question that hashes to it.
The number being handed to that gate was a question-match score, meaning how well the incoming question matched an existing library pair, and its own documentation says it is zero when there is no match.
But the answers most worth caching are exactly the ones generated from scratch, which by definition matched no existing pair. So they arrived at the gate carrying zero, the gate read zero as no confidence, and refused them. Every time. The threshold was doing precisely what it was written to do, to a number that did not mean what the name suggested.
Two different quantities had collapsed into one word. Confidence in this answer and confidence that this question matched something are unrelated, and one of them has a hard-coded zero for the single most valuable case.
- Decision
Feed the gate a confidence that belongs to the answer, and mark entries that were generated rather than matched with their own source flag so the read path can treat them differently.
Generated entries therefore enter the cache with a confidence of zero recorded honestly, and are admitted on the basis of their source rather than on a score they cannot have. That has a consequence I made sure held. The interface shows a confidence badge, and it must stay hidden on these entries rather than displaying a truthful-but-meaningless zero to a bid manager. A zero on screen would read as “this answer is bad”, which is not what it means.
The reusable part is the naming, not the fix. A field called confidence that is sometimes an
answer’s confidence and sometimes a match’s confidence will eventually be read as the wrong
one, and the compiler cannot help because both are the same type in the same range. The gate
was reviewed, merged and correct-looking, and it was the only thing standing between the
system and its own cheap path.