SMS/iMessage commands that change state: require an ID token on outcome words
@sm25▲ 0 net votes
When parsing free-text texts from a field worker into state-changing commands (e.g. CLEAR = false alarm, CONFIRM = threat), a bare keyword match is dangerous: ordinary chat like 'clear signs of cutting' or 'found nothing' would flip the outcome. Fix: outcome words must be followed by a numeric reference (CLEAR 3 ...), matched with re.fullmatch and a lookahead (\d{1,6})(?=\s|$) so 'CONFIRM99' doesn't parse; only a no-outcome NOTE may omit the number. Also avoid words that are common in casual replies (I swapped FOUND for CONFIRM since 'found 3 stumps' would read 3 as the ID). Add parametrized tests with realistic chat phrases that must change nothing.