FA-22176 / Autocomplete interactions / Open access
Completion replacement spans: completion delimiter is inserted before the completed token · case 01
The delimiter completion transition produces an incorrect observable state.
ROOT CAUSE
At replacement-range/delimiter, the implementation evaluates `d['suffix']+d['insert']` instead of preserving the specified completion transition.
VERIFIED REPAIR
Implement the delimiter contract using `d['insert']+d['suffix']`.
Unsuccessful approach: The attempted repair uses `d['insert']`, which still violates a normal or boundary completion fixture.
Case contract
Suggestion insertion replaces the half-open token span [start,end), preserving surrounding text. Caret moves after inserted text, explicit selection takes precedence over token fallback, and a stale text epoch rejects replacement. These spans count Python code points, not browser UTF-16 units.
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 == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
if event == 'prefix': return d['text'][:d['start']]
if event == 'suffix': return d['text'][d['end']:]
if event == 'caret': return d['start']+len(d['insert'])
if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
if event == 'stale-span': return d['span_epoch']==d['epoch']
if event == 'collapse': return [d['start']+len(d['insert'])]*2
if event == 'delimiter': return d['suffix']+d['insert']
if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
if event == 'capture': return d['text'][d['start']:d['end']]
return {'unchanged': True}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal replace | red pear blue | red pear blue | Passed |
| boundary replace | x | x | Passed |
| normal prefix | red | red | Passed |
| boundary prefix | | | Passed |
| normal suffix | blue | blue | Passed |
| boundary suffix | | | Passed |
| normal caret | 8 | 8 | Passed |
| boundary caret | 1 | 1 | Passed |
| normal selection | [5, 7] | [5, 7] | Passed |
| boundary selection | [0, 0] | [0, 0] | Passed |
| normal stale-span | False | False | Passed |
| boundary stale-span | True | True | Passed |
| normal collapse | [8, 8] | [8, 8] | Passed |
| boundary collapse | [1, 1] | [1, 1] | Passed |
| normal delimiter | pear | pear | Failed |
| boundary delimiter | x | x | Passed |
| normal delta | 1 | 1 | Passed |
| boundary delta | 1 | 1 | Passed |
| normal capture | pea | pea | Passed |
| boundary capture | | | Passed |
| variant query or selection payload | x | x | Passed |
| unknown completion event | {'unchanged': True} | {'unchanged': True} | Passed |
SHA-256 / f0cd194d31476f9bc2a70fa17a6dc6c20af646383f0330ddd2c90c073305a573
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 == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
if event == 'prefix': return d['text'][:d['start']]
if event == 'suffix': return d['text'][d['end']:]
if event == 'caret': return d['start']+len(d['insert'])
if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
if event == 'stale-span': return d['span_epoch']==d['epoch']
if event == 'collapse': return [d['start']+len(d['insert'])]*2
if event == 'delimiter': return d['insert']
if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
if event == 'capture': return d['text'][d['start']:d['end']]
return {'unchanged': True}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal replace | red pear blue | red pear blue | Passed |
| boundary replace | x | x | Passed |
| normal prefix | red | red | Passed |
| boundary prefix | | | Passed |
| normal suffix | blue | blue | Passed |
| boundary suffix | | | Passed |
| normal caret | 8 | 8 | Passed |
| boundary caret | 1 | 1 | Passed |
| normal selection | [5, 7] | [5, 7] | Passed |
| boundary selection | [0, 0] | [0, 0] | Passed |
| normal stale-span | False | False | Passed |
| boundary stale-span | True | True | Passed |
| normal collapse | [8, 8] | [8, 8] | Passed |
| boundary collapse | [1, 1] | [1, 1] | Passed |
| normal delimiter | pear | pear | Failed |
| boundary delimiter | x | x | Passed |
| normal delta | 1 | 1 | Passed |
| boundary delta | 1 | 1 | Passed |
| normal capture | pea | pea | Passed |
| boundary capture | | | Passed |
| variant query or selection payload | x | x | Passed |
| unknown completion event | {'unchanged': True} | {'unchanged': True} | Passed |
SHA-256 / 0daa767a757330e0a23438a833439b5308ab97f1a252153b4879ea91040d8bae
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 == 'replace': return d['text'][:d['start']]+d['insert']+d['text'][d['end']:]
if event == 'prefix': return d['text'][:d['start']]
if event == 'suffix': return d['text'][d['end']:]
if event == 'caret': return d['start']+len(d['insert'])
if event == 'selection': return d['selection'] if d['selection'][0]!=d['selection'][1] else [d['start'],d['end']]
if event == 'stale-span': return d['span_epoch']==d['epoch']
if event == 'collapse': return [d['start']+len(d['insert'])]*2
if event == 'delimiter': return d['insert']+d['suffix']
if event == 'delta': return len(d['insert'])-(d['end']-d['start'])
if event == 'capture': return d['text'][d['start']:d['end']]
return {'unchanged': True}
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
normal = {'text':'red pea blue','start':4,'end':7,'insert':'pear','caret':6,'selection':[5,7],'epoch':N,'span_epoch':N-1,'suffix':' '}
boundary = {'text':'','start':0,'end':0,'insert':'x','caret':0,'selection':[0,0],'epoch':N,'span_epoch':N,'suffix':''}
check('normal replace', solve('replace', normal), 'red pear blue')
check('boundary replace', solve('replace', boundary), 'x')
check('normal prefix', solve('prefix', normal), 'red ')
check('boundary prefix', solve('prefix', boundary), '')
check('normal suffix', solve('suffix', normal), ' blue')
check('boundary suffix', solve('suffix', boundary), '')
check('normal caret', solve('caret', normal), 8)
check('boundary caret', solve('caret', boundary), 1)
check('normal selection', solve('selection', normal), [5,7])
check('boundary selection', solve('selection', boundary), [0,0])
check('normal stale-span', solve('stale-span', normal), False)
check('boundary stale-span', solve('stale-span', boundary), True)
check('normal collapse', solve('collapse', normal), [8,8])
check('boundary collapse', solve('collapse', boundary), [1,1])
check('normal delimiter', solve('delimiter', normal), 'pear ')
check('boundary delimiter', solve('delimiter', boundary), 'x')
check('normal delta', solve('delta', normal), 1)
check('boundary delta', solve('delta', boundary), 1)
check('normal capture', solve('capture', normal), 'pea')
check('boundary capture', solve('capture', boundary), '')
variant = dict(normal, **{'text':'x'*N,'start':0,'end':N})
check('variant query or selection payload', solve('capture', variant), 'x'*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 fixture | Actual | Expected | Outcome |
|---|---|---|---|
| normal replace | red pear blue | red pear blue | Passed |
| boundary replace | x | x | Passed |
| normal prefix | red | red | Passed |
| boundary prefix | | | Passed |
| normal suffix | blue | blue | Passed |
| boundary suffix | | | Passed |
| normal caret | 8 | 8 | Passed |
| boundary caret | 1 | 1 | Passed |
| normal selection | [5, 7] | [5, 7] | Passed |
| boundary selection | [0, 0] | [0, 0] | Passed |
| normal stale-span | False | False | Passed |
| boundary stale-span | True | True | Passed |
| normal collapse | [8, 8] | [8, 8] | Passed |
| boundary collapse | [1, 1] | [1, 1] | Passed |
| normal delimiter | pear | pear | Passed |
| boundary delimiter | x | x | Passed |
| normal delta | 1 | 1 | Passed |
| boundary delta | 1 | 1 | Passed |
| normal capture | pea | pea | Passed |
| boundary capture | | | Passed |
| variant query or selection payload | x | x | Passed |
| unknown completion event | {'unchanged': True} | {'unchanged': True} | Passed |
SHA-256 / a486206721239e530d05ea6db2f429ed4e23ce9930d42829b0c2387ec99508ed
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:35.953283+00:00.
Case digest / 414669e9865cffbfb212ad9d3994f0065556500e71ffba4198486bda5f8eaddd