FAILURE MAP
← Case archive

FA-22306 / Autocomplete interactions / Open access

Cached autocomplete presentation: empty-result cache entries are treated as misses · case 01

The empty-hit completion transition produces an incorrect observable state.

Verified by executionVariant 1 · 22 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

At query-cache-presentation/empty-hit, the implementation evaluates `bool(d['cached'])` instead of preserving the specified completion transition.

VERIFIED REPAIR

Implement the empty-hit contract using `d['has_entry']`.

Unsuccessful approach: The attempted repair uses `d['has_entry'] and bool(d['query'])`, which still violates a normal or boundary completion fixture.

Case contract

Cached result presentation is bound to exact query and dependency scope. A cache hit may render immediately but must be marked stale until refreshed. Empty cached results are valid hits. Cache misses preserve no previous-query selectable rows; selected labels are independently retained.

Why this case matters

Autocomplete couples draft text, suggestion identity and asynchronous presentation; this bounded lifecycle model isolates one observable interaction defect.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(event, d):
    if event == 'key': return [d['scope'],d['query']]
    if event == 'query-match': return d['query']==d['cache_query']
    if event == 'scope-match': return d['scope']==d['cache_scope']
    if event == 'empty-hit': return bool(d['cached'])
    if event == 'stale-badge': return not d['fresh']
    if event == 'refresh': return not d['fresh']
    if event == 'miss-rows': return d['cached'] if d['query']==d['cache_query'] and d['scope']==d['cache_scope'] else []
    if event == 'value-label': return d['selected_label']
    if event == 'cache-provenance': return {'origin':'cache','query':d['cache_query'],'epoch':d['cache_epoch']}
    if event == 'refresh-error': return {'rows':d['cached'],'warning':d['error']}
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'query':'pe','scope':'fruit','cache_query':'p','cache_scope':'all','cached':['p1'],'has_entry':True,'fresh':False,'selected_label':'Pear','epoch':N,'cache_epoch':N-1,'error':'offline'}
boundary = {'query':'','scope':'all','cache_query':'','cache_scope':'all','cached':[],'has_entry':True,'fresh':True,'selected_label':'','epoch':N,'cache_epoch':N,'error':None}
check('normal key', solve('key', normal), ['fruit','pe'])
check('boundary key', solve('key', boundary), ['all',''])
check('normal query-match', solve('query-match', normal), False)
check('boundary query-match', solve('query-match', boundary), True)
check('normal scope-match', solve('scope-match', normal), False)
check('boundary scope-match', solve('scope-match', boundary), True)
check('normal empty-hit', solve('empty-hit', normal), True)
check('boundary empty-hit', solve('empty-hit', boundary), True)
check('normal stale-badge', solve('stale-badge', normal), True)
check('boundary stale-badge', solve('stale-badge', boundary), False)
check('normal refresh', solve('refresh', normal), True)
check('boundary refresh', solve('refresh', boundary), False)
check('normal miss-rows', solve('miss-rows', normal), [])
check('boundary miss-rows', solve('miss-rows', boundary), [])
check('normal value-label', solve('value-label', normal), 'Pear')
check('boundary value-label', solve('value-label', boundary), '')
check('normal cache-provenance', solve('cache-provenance', normal), {'origin':'cache','query':'p','epoch':N-1})
check('boundary cache-provenance', solve('cache-provenance', boundary), {'origin':'cache','query':'','epoch':N})
check('normal refresh-error', solve('refresh-error', normal), {'rows':['p1'],'warning':'offline'})
check('boundary refresh-error', solve('refresh-error', boundary), {'rows':[],'warning':None})
variant = dict(normal, **{'selected_label':'L'*N})
check('variant query or selection payload', solve('value-label', variant), 'L'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
normal key['fruit', 'pe']['fruit', 'pe']Passed
boundary key['all', '']['all', '']Passed
normal query-matchFalseFalsePassed
boundary query-matchTrueTruePassed
normal scope-matchFalseFalsePassed
boundary scope-matchTrueTruePassed
normal empty-hitTrueTruePassed
boundary empty-hitFalseTrueFailed
normal stale-badgeTrueTruePassed
boundary stale-badgeFalseFalsePassed
normal refreshTrueTruePassed
boundary refreshFalseFalsePassed
normal miss-rows[][]Passed
boundary miss-rows[][]Passed
normal value-labelPearPearPassed
boundary value-labelPassed
normal cache-provenance{'epoch': 0, 'origin': 'cache', 'query': 'p'}{'epoch': 0, 'origin': 'cache', 'query': 'p'}Passed
boundary cache-provenance{'epoch': 1, 'origin': 'cache', 'query': ''}{'epoch': 1, 'origin': 'cache', 'query': ''}Passed
normal refresh-error{'rows': ['p1'], 'warning': 'offline'}{'rows': ['p1'], 'warning': 'offline'}Passed
boundary refresh-error{'rows': [], 'warning': None}{'rows': [], 'warning': None}Passed
variant query or selection payloadLLPassed
unknown completion event{'unchanged': True}{'unchanged': True}Passed

SHA-256 / adfd6630819fa494845ce08364f314ad545f5c1a246df27f9a41ebe81d8ecbc1

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(event, d):
    if event == 'key': return [d['scope'],d['query']]
    if event == 'query-match': return d['query']==d['cache_query']
    if event == 'scope-match': return d['scope']==d['cache_scope']
    if event == 'empty-hit': return d['has_entry'] and bool(d['query'])
    if event == 'stale-badge': return not d['fresh']
    if event == 'refresh': return not d['fresh']
    if event == 'miss-rows': return d['cached'] if d['query']==d['cache_query'] and d['scope']==d['cache_scope'] else []
    if event == 'value-label': return d['selected_label']
    if event == 'cache-provenance': return {'origin':'cache','query':d['cache_query'],'epoch':d['cache_epoch']}
    if event == 'refresh-error': return {'rows':d['cached'],'warning':d['error']}
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'query':'pe','scope':'fruit','cache_query':'p','cache_scope':'all','cached':['p1'],'has_entry':True,'fresh':False,'selected_label':'Pear','epoch':N,'cache_epoch':N-1,'error':'offline'}
boundary = {'query':'','scope':'all','cache_query':'','cache_scope':'all','cached':[],'has_entry':True,'fresh':True,'selected_label':'','epoch':N,'cache_epoch':N,'error':None}
check('normal key', solve('key', normal), ['fruit','pe'])
check('boundary key', solve('key', boundary), ['all',''])
check('normal query-match', solve('query-match', normal), False)
check('boundary query-match', solve('query-match', boundary), True)
check('normal scope-match', solve('scope-match', normal), False)
check('boundary scope-match', solve('scope-match', boundary), True)
check('normal empty-hit', solve('empty-hit', normal), True)
check('boundary empty-hit', solve('empty-hit', boundary), True)
check('normal stale-badge', solve('stale-badge', normal), True)
check('boundary stale-badge', solve('stale-badge', boundary), False)
check('normal refresh', solve('refresh', normal), True)
check('boundary refresh', solve('refresh', boundary), False)
check('normal miss-rows', solve('miss-rows', normal), [])
check('boundary miss-rows', solve('miss-rows', boundary), [])
check('normal value-label', solve('value-label', normal), 'Pear')
check('boundary value-label', solve('value-label', boundary), '')
check('normal cache-provenance', solve('cache-provenance', normal), {'origin':'cache','query':'p','epoch':N-1})
check('boundary cache-provenance', solve('cache-provenance', boundary), {'origin':'cache','query':'','epoch':N})
check('normal refresh-error', solve('refresh-error', normal), {'rows':['p1'],'warning':'offline'})
check('boundary refresh-error', solve('refresh-error', boundary), {'rows':[],'warning':None})
variant = dict(normal, **{'selected_label':'L'*N})
check('variant query or selection payload', solve('value-label', variant), 'L'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
normal key['fruit', 'pe']['fruit', 'pe']Passed
boundary key['all', '']['all', '']Passed
normal query-matchFalseFalsePassed
boundary query-matchTrueTruePassed
normal scope-matchFalseFalsePassed
boundary scope-matchTrueTruePassed
normal empty-hitTrueTruePassed
boundary empty-hitFalseTrueFailed
normal stale-badgeTrueTruePassed
boundary stale-badgeFalseFalsePassed
normal refreshTrueTruePassed
boundary refreshFalseFalsePassed
normal miss-rows[][]Passed
boundary miss-rows[][]Passed
normal value-labelPearPearPassed
boundary value-labelPassed
normal cache-provenance{'epoch': 0, 'origin': 'cache', 'query': 'p'}{'epoch': 0, 'origin': 'cache', 'query': 'p'}Passed
boundary cache-provenance{'epoch': 1, 'origin': 'cache', 'query': ''}{'epoch': 1, 'origin': 'cache', 'query': ''}Passed
normal refresh-error{'rows': ['p1'], 'warning': 'offline'}{'rows': ['p1'], 'warning': 'offline'}Passed
boundary refresh-error{'rows': [], 'warning': None}{'rows': [], 'warning': None}Passed
variant query or selection payloadLLPassed
unknown completion event{'unchanged': True}{'unchanged': True}Passed

SHA-256 / 83f2d3bfcb733aaa6ae728212efa974f8b777086c88903d756641d1452ac0be4

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(event, d):
    if event == 'key': return [d['scope'],d['query']]
    if event == 'query-match': return d['query']==d['cache_query']
    if event == 'scope-match': return d['scope']==d['cache_scope']
    if event == 'empty-hit': return d['has_entry']
    if event == 'stale-badge': return not d['fresh']
    if event == 'refresh': return not d['fresh']
    if event == 'miss-rows': return d['cached'] if d['query']==d['cache_query'] and d['scope']==d['cache_scope'] else []
    if event == 'value-label': return d['selected_label']
    if event == 'cache-provenance': return {'origin':'cache','query':d['cache_query'],'epoch':d['cache_epoch']}
    if event == 'refresh-error': return {'rows':d['cached'],'warning':d['error']}
    return {'unchanged': True}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'query':'pe','scope':'fruit','cache_query':'p','cache_scope':'all','cached':['p1'],'has_entry':True,'fresh':False,'selected_label':'Pear','epoch':N,'cache_epoch':N-1,'error':'offline'}
boundary = {'query':'','scope':'all','cache_query':'','cache_scope':'all','cached':[],'has_entry':True,'fresh':True,'selected_label':'','epoch':N,'cache_epoch':N,'error':None}
check('normal key', solve('key', normal), ['fruit','pe'])
check('boundary key', solve('key', boundary), ['all',''])
check('normal query-match', solve('query-match', normal), False)
check('boundary query-match', solve('query-match', boundary), True)
check('normal scope-match', solve('scope-match', normal), False)
check('boundary scope-match', solve('scope-match', boundary), True)
check('normal empty-hit', solve('empty-hit', normal), True)
check('boundary empty-hit', solve('empty-hit', boundary), True)
check('normal stale-badge', solve('stale-badge', normal), True)
check('boundary stale-badge', solve('stale-badge', boundary), False)
check('normal refresh', solve('refresh', normal), True)
check('boundary refresh', solve('refresh', boundary), False)
check('normal miss-rows', solve('miss-rows', normal), [])
check('boundary miss-rows', solve('miss-rows', boundary), [])
check('normal value-label', solve('value-label', normal), 'Pear')
check('boundary value-label', solve('value-label', boundary), '')
check('normal cache-provenance', solve('cache-provenance', normal), {'origin':'cache','query':'p','epoch':N-1})
check('boundary cache-provenance', solve('cache-provenance', boundary), {'origin':'cache','query':'','epoch':N})
check('normal refresh-error', solve('refresh-error', normal), {'rows':['p1'],'warning':'offline'})
check('boundary refresh-error', solve('refresh-error', boundary), {'rows':[],'warning':None})
variant = dict(normal, **{'selected_label':'L'*N})
check('variant query or selection payload', solve('value-label', variant), 'L'*N)
check('unknown completion event', solve('unrecognized', normal), {'unchanged': True})
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
normal key['fruit', 'pe']['fruit', 'pe']Passed
boundary key['all', '']['all', '']Passed
normal query-matchFalseFalsePassed
boundary query-matchTrueTruePassed
normal scope-matchFalseFalsePassed
boundary scope-matchTrueTruePassed
normal empty-hitTrueTruePassed
boundary empty-hitTrueTruePassed
normal stale-badgeTrueTruePassed
boundary stale-badgeFalseFalsePassed
normal refreshTrueTruePassed
boundary refreshFalseFalsePassed
normal miss-rows[][]Passed
boundary miss-rows[][]Passed
normal value-labelPearPearPassed
boundary value-labelPassed
normal cache-provenance{'epoch': 0, 'origin': 'cache', 'query': 'p'}{'epoch': 0, 'origin': 'cache', 'query': 'p'}Passed
boundary cache-provenance{'epoch': 1, 'origin': 'cache', 'query': ''}{'epoch': 1, 'origin': 'cache', 'query': ''}Passed
normal refresh-error{'rows': ['p1'], 'warning': 'offline'}{'rows': ['p1'], 'warning': 'offline'}Passed
boundary refresh-error{'rows': [], 'warning': None}{'rows': [], 'warning': None}Passed
variant query or selection payloadLLPassed
unknown completion event{'unchanged': True}{'unchanged': True}Passed

SHA-256 / 3399b161777d62d0d69ab5bc5a36c6cfc426afc4f2dfabd2f96dab92bb32dea4

Verification & scope

Stipulated deterministic widget transition model; inputs are validated snapshots. It does not model browser event dispatch, network transport, or linguistic standards. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:40:37.111195+00:00.

Case digest / 4cada348e7a01a514b9cb136dca5fbe2be9c80ba80b8d62526b1cd5030b73359