FA-22161 / Autocomplete interactions / Open access
Completion replacement spans: nonempty selection is ignored when accepting a completion · case 01
The selection completion transition produces an incorrect observable state.
ROOT CAUSE
At replacement-range/selection, the implementation evaluates `[d['start'],d['end']]` instead of preserving the specified completion transition.
THE FAILURE
At replacement-range/selection, the implementation evaluates `[d['start'],d['end']]` instead of preserving the specified completion transition.
Unsuccessful approach: The attempted repair uses `[d['caret'],d['caret']]`, 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['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 | [4, 7] | [5, 7] | Failed |
| 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 / bcc221340aa4a2b5c331319a6f93a3b6438ddd5e0f1c563298f800032461e146
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['caret'],d['caret']]
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 | [6, 6] | [5, 7] | Failed |
| 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 / 2a78f2b7da170cd3b6422305290f17f714f1a650c44c942cd1c9e89d1bb6d52a
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 22 recorded checks per implementation. The open-access tier publishes the failure and the unsuccessful fix; the repaired source that passes every check, and the observations that prove it, are available to members.
Every case sharing this mechanism uses the same contract and the same repair, so this one record is held back for all of them.
Member access is invitation-based. Sign in with your invited account to inspect the repair.
Sign in to the archive ↗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.994260+00:00.
Case digest / 89406a96c122e8a0d13232b11aff8800a286f8ceeff1e857f69e071377421ec7