FA-7921 / Text editing / Open access
Text selection replacement: Selected text remains after the inserted replacement · case 01
Selected text remains after the inserted replacement.
ROOT CAUSE
The suffix operation uses `text[lo:]` where the contract requires `text[hi:]`.
THE FAILURE
The suffix operation uses `text[lo:]` where the contract requires `text[hi:]`.
Unsuccessful approach: Deleting all suffix text also removes unselected content.
Case contract
Composition is preserved; replace the normalized half-open selection and collapse both endpoints immediately after inserted text.
Why this case matters
A deterministic model of text selection replacement; this isolates one interface invariant without requiring a browser.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(text, anchor, focus, replacement, composing):
if composing: return (text, anchor, focus)
lo = min(anchor, focus)
hi = max(anchor, focus)
result = text[:lo] + replacement + text[lo:]
caret = lo + len(replacement)
return (result, caret, caret)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('abcdef', 1, 4, 'XY', True), ('abcdef', 1, 4))
check('forward', solve('abcdef', 1, 4, 'XY', False), ('aXYef', 3, 3))
check('backward', solve('abcdef', 4, 1, 'XY', False), ('aXYef', 3, 3))
check('insertion', solve('ab', 1, 1, 'XYZ', False), ('aXYZb', 4, 4))
check('delete', solve('abc', 0, 3, '', False), ('', 0, 0))
check('no selection', solve('abc', 2, 2, '', False), ('abc', 2, 2))
check('parameterized selected length', solve('a'*N, 0, N, 'X', False), ('X', 1, 1))
for repetition in range(N):
check('repeat no selection', solve('abc', 2, 2, '', False), ('abc', 2, 2))
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 |
|---|---|---|---|
| composition | ['abcdef', 1, 4] | ['abcdef', 1, 4] | Passed |
| forward | ['aXYbcdef', 3, 3] | ['aXYef', 3, 3] | Failed |
| backward | ['aXYbcdef', 3, 3] | ['aXYef', 3, 3] | Failed |
| insertion | ['aXYZb', 4, 4] | ['aXYZb', 4, 4] | Passed |
| delete | ['abc', 0, 0] | ['', 0, 0] | Failed |
| no selection | ['abc', 2, 2] | ['abc', 2, 2] | Passed |
| parameterized selected length | ['Xa', 1, 1] | ['X', 1, 1] | Failed |
| repeat no selection | ['abc', 2, 2] | ['abc', 2, 2] | Passed |
SHA-256 / 1496acce7e08f2f3a780c554ef097110a2d19dfd9338ba27e8fde37dfb64b939
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(text, anchor, focus, replacement, composing):
if composing: return (text, anchor, focus)
lo = min(anchor, focus)
hi = max(anchor, focus)
result = text[:lo] + replacement + ''
caret = lo + len(replacement)
return (result, caret, caret)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition', solve('abcdef', 1, 4, 'XY', True), ('abcdef', 1, 4))
check('forward', solve('abcdef', 1, 4, 'XY', False), ('aXYef', 3, 3))
check('backward', solve('abcdef', 4, 1, 'XY', False), ('aXYef', 3, 3))
check('insertion', solve('ab', 1, 1, 'XYZ', False), ('aXYZb', 4, 4))
check('delete', solve('abc', 0, 3, '', False), ('', 0, 0))
check('no selection', solve('abc', 2, 2, '', False), ('abc', 2, 2))
check('parameterized selected length', solve('a'*N, 0, N, 'X', False), ('X', 1, 1))
for repetition in range(N):
check('repeat no selection', solve('abc', 2, 2, '', False), ('abc', 2, 2))
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 |
|---|---|---|---|
| composition | ['abcdef', 1, 4] | ['abcdef', 1, 4] | Passed |
| forward | ['aXY', 3, 3] | ['aXYef', 3, 3] | Failed |
| backward | ['aXY', 3, 3] | ['aXYef', 3, 3] | Failed |
| insertion | ['aXYZ', 4, 4] | ['aXYZb', 4, 4] | Failed |
| delete | ['', 0, 0] | ['', 0, 0] | Passed |
| no selection | ['ab', 2, 2] | ['abc', 2, 2] | Failed |
| parameterized selected length | ['X', 1, 1] | ['X', 1, 1] | Passed |
| repeat no selection | ['ab', 2, 2] | ['abc', 2, 2] | Failed |
SHA-256 / 90b3041f46603ac84bd7bcb4121da48a19482f9742fa6fd58367dd58953f9eed
HELD IN THE MEMBER ARCHIVE
The verified repair and its recorded checks are member-only.
This mechanism has 8 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
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:38:16.617078+00:00.
Case digest / 144af548653ccfdbb0c1310289891328185f26a9b88658b5bb0b55abb5c204b8