FAILURE MAP
← Case archive

FA-54691 / Accessibility interaction semantics / Open access

Negative text offsets are clamped to the first visual line · case 01

Negative text offsets are clamped to the first visual line.

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

ROOT CAUSE

The negative query decision in the visual line query adapter violates its declared contract.

VERIFIED REPAIR

Apply the exact contract at the negative query decision: if offset < 0 or offset > len(text): return None

Unsuccessful approach: The local repair substitutes offset = 0 if offset == -1 else offset if offset < 0 or offset > len(text): return None but still mishandles the regression fixtures.

Case contract

Input [text,lines,offset,affinity] lines ordered nonoverlapping [start,end,hard_break] in codepoint coordinates. Each line covers half-open text range; an offset on shared line boundary selects next line for forward affinity, previous for backward. Final document-end offset selects final line. Empty text with one empty line is valid. Return [index,start,end,text_segment,hard_break], or None for offsets outside text or gaps. Newline characters are included only if line bounds include them. No text wrapping is performed.

Why this case matters

Offline accessibility bridge model with explicit policy; useful for testing semantic API adapters independently of browser implementations.

1 / The failure

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

N = 1
observations = []
def solve(data):
    text,lines,offset,affinity = data
    offset = max(0,offset)
    if offset > len(text): return None
    matches = []
    for i,(start,end,hard) in enumerate(lines):
        inside = start <= offset < end
        boundary = offset == end and (affinity == 'backward' or offset == len(text))
        empty = start == end == offset and len(text) == 0
        if inside or boundary or empty: matches.append(i)
    if not matches: return None
    index = matches[0] if affinity == 'backward' else matches[-1]
    start,end,hard = lines[index]
    return [index,start,end,text[start:end],hard]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',[[0,N,False],[N,N+2,True]],N,'forward'],), [1,N,N+2,'BC',True])
check('contract fixture 2', solve(['A'*N+'BC',[[0,N,False],[N,N+2,True]],N,'backward'],), [0,0,N,'A'*N,False])
check('contract fixture 3', solve(['abc',[[0,3,False]],3,'forward'],), [0,0,3,'abc',False])
check('contract fixture 4', solve(['a\nb',[[0,2,True],[2,3,False]],1,'forward'],), [0,0,2,'a\n',True])
check('contract fixture 5', solve(['abc',[[0,1,False],[2,3,False]],1,'forward'],), None)
check('contract fixture 6', solve(['abc',[[0,3,False]],-1,'backward'],), None)
check('contract fixture 7', solve(['abc',[[0,3,False]],4,'backward'],), None)
check('contract fixture 8', solve(['',[[0,0,False]],0,'forward'],), [0,0,0,'',False])
check('contract fixture 9', solve(['abc',[],0,'forward'],), None)
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
contract fixture 1[1, 1, 3, 'BC', True][1, 1, 3, 'BC', True]Passed
contract fixture 2[0, 0, 1, 'A', False][0, 0, 1, 'A', False]Passed
contract fixture 3[0, 0, 3, 'abc', False][0, 0, 3, 'abc', False]Passed
contract fixture 4[0, 0, 2, 'a\n', True][0, 0, 2, 'a\n', True]Passed
contract fixture 5NoneNonePassed
contract fixture 6[0, 0, 3, 'abc', False]NoneFailed
contract fixture 7NoneNonePassed
contract fixture 8[0, 0, 0, '', False][0, 0, 0, '', False]Passed
contract fixture 9NoneNonePassed

SHA-256 / 93fa249a4c5ec62573ceec90da817ca619e59145ac57ba139c213065c4f0edc9

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(data):
    text,lines,offset,affinity = data
    offset = 0 if offset == -1 else offset
    if offset < 0 or offset > len(text): return None
    matches = []
    for i,(start,end,hard) in enumerate(lines):
        inside = start <= offset < end
        boundary = offset == end and (affinity == 'backward' or offset == len(text))
        empty = start == end == offset and len(text) == 0
        if inside or boundary or empty: matches.append(i)
    if not matches: return None
    index = matches[0] if affinity == 'backward' else matches[-1]
    start,end,hard = lines[index]
    return [index,start,end,text[start:end],hard]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',[[0,N,False],[N,N+2,True]],N,'forward'],), [1,N,N+2,'BC',True])
check('contract fixture 2', solve(['A'*N+'BC',[[0,N,False],[N,N+2,True]],N,'backward'],), [0,0,N,'A'*N,False])
check('contract fixture 3', solve(['abc',[[0,3,False]],3,'forward'],), [0,0,3,'abc',False])
check('contract fixture 4', solve(['a\nb',[[0,2,True],[2,3,False]],1,'forward'],), [0,0,2,'a\n',True])
check('contract fixture 5', solve(['abc',[[0,1,False],[2,3,False]],1,'forward'],), None)
check('contract fixture 6', solve(['abc',[[0,3,False]],-1,'backward'],), None)
check('contract fixture 7', solve(['abc',[[0,3,False]],4,'backward'],), None)
check('contract fixture 8', solve(['',[[0,0,False]],0,'forward'],), [0,0,0,'',False])
check('contract fixture 9', solve(['abc',[],0,'forward'],), None)
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
contract fixture 1[1, 1, 3, 'BC', True][1, 1, 3, 'BC', True]Passed
contract fixture 2[0, 0, 1, 'A', False][0, 0, 1, 'A', False]Passed
contract fixture 3[0, 0, 3, 'abc', False][0, 0, 3, 'abc', False]Passed
contract fixture 4[0, 0, 2, 'a\n', True][0, 0, 2, 'a\n', True]Passed
contract fixture 5NoneNonePassed
contract fixture 6[0, 0, 3, 'abc', False]NoneFailed
contract fixture 7NoneNonePassed
contract fixture 8[0, 0, 0, '', False][0, 0, 0, '', False]Passed
contract fixture 9NoneNonePassed

SHA-256 / e8d1f9716b572fe35ee9cf0204798d9347c70a3100efc399362746f75e2af4f4

3 / The verified repair

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

N = 1
observations = []
def solve(data):
    text,lines,offset,affinity = data
    if offset < 0 or offset > len(text): return None
    matches = []
    for i,(start,end,hard) in enumerate(lines):
        inside = start <= offset < end
        boundary = offset == end and (affinity == 'backward' or offset == len(text))
        empty = start == end == offset and len(text) == 0
        if inside or boundary or empty: matches.append(i)
    if not matches: return None
    index = matches[0] if affinity == 'backward' else matches[-1]
    start,end,hard = lines[index]
    return [index,start,end,text[start:end],hard]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('contract fixture 1', solve(['A'*N+'BC',[[0,N,False],[N,N+2,True]],N,'forward'],), [1,N,N+2,'BC',True])
check('contract fixture 2', solve(['A'*N+'BC',[[0,N,False],[N,N+2,True]],N,'backward'],), [0,0,N,'A'*N,False])
check('contract fixture 3', solve(['abc',[[0,3,False]],3,'forward'],), [0,0,3,'abc',False])
check('contract fixture 4', solve(['a\nb',[[0,2,True],[2,3,False]],1,'forward'],), [0,0,2,'a\n',True])
check('contract fixture 5', solve(['abc',[[0,1,False],[2,3,False]],1,'forward'],), None)
check('contract fixture 6', solve(['abc',[[0,3,False]],-1,'backward'],), None)
check('contract fixture 7', solve(['abc',[[0,3,False]],4,'backward'],), None)
check('contract fixture 8', solve(['',[[0,0,False]],0,'forward'],), [0,0,0,'',False])
check('contract fixture 9', solve(['abc',[],0,'forward'],), None)
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
contract fixture 1[1, 1, 3, 'BC', True][1, 1, 3, 'BC', True]Passed
contract fixture 2[0, 0, 1, 'A', False][0, 0, 1, 'A', False]Passed
contract fixture 3[0, 0, 3, 'abc', False][0, 0, 3, 'abc', False]Passed
contract fixture 4[0, 0, 2, 'a\n', True][0, 0, 2, 'a\n', True]Passed
contract fixture 5NoneNonePassed
contract fixture 6NoneNonePassed
contract fixture 7NoneNonePassed
contract fixture 8[0, 0, 0, '', False][0, 0, 0, '', False]Passed
contract fixture 9NoneNonePassed

SHA-256 / 5bd3511058a4540f596756549d23920ba4477c6cd763bc2e38b206815f8b18a1

Verification & scope

Stipulated finite adapter contract, not a claim of platform accessibility or ARIA conformance. 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:45:50.680053+00:00.

Case digest / c520828d37df275f8935f16ee0d298f3ca67486816bfcf1d64db6d18894c7c79