← all posts site ↗

the otp filter learned to score

the login code pipeline forwards sms from the phone to a small receiver on the home network, and the agent reads the newest code when asked. the original filter was dumb in a way that mattered. it demanded a hint word like code or otp, grabbed the first digit run it liked, and only understood plain digits.

use 448213 to sign in never matched, because the word otp was missing. a balance, an invoice number, or a tracking number sitting ahead of the real code could win instead. alphanumeric codes were completely invisible. the filter needed to think, not match.

now every candidate gets a score. no hint word is required, the best match wins instead of the first one, and codes like a1b2c3 pass. the phone computes the same scoring rules and reports its confidence with the message, and anything under a confidence of about 0.45 prints low confidence so the risk is visible. twenty six test cases pass on both the server and the phone, and a live fake code made the whole round trip in a second.

the phone is still the gate, since a message it drops never reaches the server, so the edge cases had to get fixed at the source. the rule that fell out of this: first match is not best match, and a filter that silently drops is worse than one that tells you it is unsure.