FA-7916 / Text editing / Open access
Text selection replacement: Backward selections retain selected suffix text · case 01
Backward selections retain selected suffix text.
ROOT CAUSE
The backward end operation uses `focus` where the contract requires `max(anchor, focus)`.
THE FAILURE
The backward end operation uses `focus` where the contract requires `max(anchor, focus)`.
Unsuccessful approach: Using the lower endpoint never removes the full range.
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 = focus
result = text[:lo] + replacement + text[hi:]
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 | ['aXYef', 3, 3] | ['aXYef', 3, 3] | Passed |
| backward | ['aXYbcdef', 3, 3] | ['aXYef', 3, 3] | Failed |
| insertion | ['aXYZb', 4, 4] | ['aXYZb', 4, 4] | Passed |
| delete | ['', 0, 0] | ['', 0, 0] | Passed |
| no selection | ['abc', 2, 2] | ['abc', 2, 2] | Passed |
| parameterized selected length | ['X', 1, 1] | ['X', 1, 1] | Passed |
| repeat no selection | ['abc', 2, 2] | ['abc', 2, 2] | Passed |
SHA-256 / 648e983a84ebd0c902d256df118be1f7a416d48187bf87452efba8db872c0d52
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 = min(anchor, focus)
result = text[:lo] + replacement + text[hi:]
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 / 2cd79b1e8518e4f922f2cee0f965220c2c8e19e04d8b2aacc89612f947151708
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 / 255ba99e6e2353acd83367854024e7f29dbcbcfdb05ec6f7d5ceb0ff54209234