FA-82766 / Chess move legality / Open access
Castling right kept after the king left the back rank · case 01
A white king on e2 still yields a castling rook.
ROOT CAUSE
The king is located anywhere on the board.
VERIFIED REPAIR
Only a king on its own back rank can hold castling rights.
Unsuccessful approach: Accepting either back rank lets a king on the opponent's back rank keep rights.
Case contract
Input: {"board", "rights"}: rights letters are K/Q (outermost own rook on the back rank on the king's h-side / a-side), file letters A-H or a-h (the own rook on that file), or "-". A right only counts if the king is on its back rank (rank 1 for white, 8 for black) and the rook exists. Return the sorted distinct list of rook squares that carry castling rights.
Why this case matters
Chess960 and X-FEN positions encode castling by rook file; a wrong mapping castles with the wrong rook.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=x['board']; out=[]
for ch in x['rights']:
if ch=='-': continue
white=ch.isupper(); rank='1' if white else '8'
R='R' if white else 'r'; K='K' if white else 'k'
kfs=[s[0] for s,v in b.items() if v==K]
if not kfs: continue
kf=kfs[0]
rooks=sorted(s[0] for s,v in b.items() if v==R and s[1]==rank)
if ch.upper()=='K':
side=[f for f in rooks if f>kf]
if side: out.append(side[-1]+rank)
elif ch.upper()=='Q':
side=[f for f in rooks if f<kf]
if side: out.append(side[0]+rank)
elif ch.lower() in 'abcdefgh' and ch.lower() in rooks:
out.append(ch.lower()+rank)
return sorted(set(out))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])],
[('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('file letter without rook', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'A'}, []),
('dash', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': '-'}, []),
('black kq', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K', 'f8': 'r', 'g8': 'r'}, 'rights': 'kq'},
['a8', 'g8']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('file letter without rook', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'A'}, []),
('dash', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': '-'}, []),
('black kq', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K', 'f8': 'r', 'g8': 'r'}, 'rights': 'kq'},
['a8', 'g8']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, []),
('black king on rank one', {'board': {'d1': 'k', 'e8': 'K', 'h1': 'r', 'h8': 'R'}, 'rights': 'k'},
[])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, []),
('black king on rank one', {'board': {'d1': 'k', 'e8': 'K', 'h1': 'r', 'h8': 'R'}, 'rights': 'k'},
[])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
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 |
|---|---|---|---|
| standard KQkq | ['a1', 'a8', 'h1', 'h8'] | ['a1', 'a8', 'h1', 'h8'] | Passed |
| two rooks on h-side | ['h1'] | ['h1'] | Passed |
| file letter inner rook | ['e1'] | ['e1'] | Passed |
| black file letters | ['b8', 'h8'] | ['b8', 'h8'] | Passed |
| K right but only a-side rook | [] | [] | Passed |
| king off back rank | ['h1'] | [] | Failed |
| duplicate K and H | ['h1'] | ['h1'] | Passed |
| black king on white back rank | ['h8'] | [] | Failed |
SHA-256 / b89c325624391f0b939b7fd715bf02d66f97e91e48bc16950f4f016a559014d6
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=x['board']; out=[]
for ch in x['rights']:
if ch=='-': continue
white=ch.isupper(); rank='1' if white else '8'
R='R' if white else 'r'; K='K' if white else 'k'
kfs=[s[0] for s,v in b.items() if v==K and s[1] in '18']
if not kfs: continue
kf=kfs[0]
rooks=sorted(s[0] for s,v in b.items() if v==R and s[1]==rank)
if ch.upper()=='K':
side=[f for f in rooks if f>kf]
if side: out.append(side[-1]+rank)
elif ch.upper()=='Q':
side=[f for f in rooks if f<kf]
if side: out.append(side[0]+rank)
elif ch.lower() in 'abcdefgh' and ch.lower() in rooks:
out.append(ch.lower()+rank)
return sorted(set(out))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])],
[('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('file letter without rook', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'A'}, []),
('dash', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': '-'}, []),
('black kq', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K', 'f8': 'r', 'g8': 'r'}, 'rights': 'kq'},
['a8', 'g8']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('file letter without rook', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'A'}, []),
('dash', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': '-'}, []),
('black kq', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K', 'f8': 'r', 'g8': 'r'}, 'rights': 'kq'},
['a8', 'g8']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, []),
('black king on rank one', {'board': {'d1': 'k', 'e8': 'K', 'h1': 'r', 'h8': 'R'}, 'rights': 'k'},
[])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, []),
('black king on rank one', {'board': {'d1': 'k', 'e8': 'K', 'h1': 'r', 'h8': 'R'}, 'rights': 'k'},
[])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
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 |
|---|---|---|---|
| standard KQkq | ['a1', 'a8', 'h1', 'h8'] | ['a1', 'a8', 'h1', 'h8'] | Passed |
| two rooks on h-side | ['h1'] | ['h1'] | Passed |
| file letter inner rook | ['e1'] | ['e1'] | Passed |
| black file letters | ['b8', 'h8'] | ['b8', 'h8'] | Passed |
| K right but only a-side rook | [] | [] | Passed |
| king off back rank | [] | [] | Passed |
| duplicate K and H | ['h1'] | ['h1'] | Passed |
| black king on white back rank | ['h8'] | [] | Failed |
SHA-256 / 7e8835a63549f9ab1caa89fe4019b39ecdfd0cfc9ece22bb962d4c1eec5dcd6a
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(x):
b=x['board']; out=[]
for ch in x['rights']:
if ch=='-': continue
white=ch.isupper(); rank='1' if white else '8'
R='R' if white else 'r'; K='K' if white else 'k'
kfs=[s[0] for s,v in b.items() if v==K and s[1]==rank]
if not kfs: continue
kf=kfs[0]
rooks=sorted(s[0] for s,v in b.items() if v==R and s[1]==rank)
if ch.upper()=='K':
side=[f for f in rooks if f>kf]
if side: out.append(side[-1]+rank)
elif ch.upper()=='Q':
side=[f for f in rooks if f<kf]
if side: out.append(side[0]+rank)
elif ch.lower() in 'abcdefgh' and ch.lower() in rooks:
out.append(ch.lower()+rank)
return sorted(set(out))
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])],
[('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('file letter without rook', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'A'}, []),
('dash', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': '-'}, []),
('black kq', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K', 'f8': 'r', 'g8': 'r'}, 'rights': 'kq'},
['a8', 'g8']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('file letter without rook', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'A'}, []),
('dash', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': '-'}, []),
('black kq', {'board': {'a8': 'r', 'd8': 'k', 'e1': 'K', 'f8': 'r', 'g8': 'r'}, 'rights': 'kq'},
['a8', 'g8']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, []),
('black king on rank one', {'board': {'d1': 'k', 'e8': 'K', 'h1': 'r', 'h8': 'R'}, 'rights': 'k'},
[])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, []),
('black king on rank one', {'board': {'d1': 'k', 'e8': 'K', 'h1': 'r', 'h8': 'R'}, 'rights': 'k'},
[])],
[('standard KQkq',
{'board': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'}, 'rights': 'KQkq'},
['a1', 'a8', 'h1', 'h8']),
('two rooks on h-side', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'},
['h1']),
('file letter inner rook', {'board': {'c1': 'K', 'e1': 'R', 'e8': 'k', 'h1': 'R'}, 'rights': 'E'},
['e1']),
('black file letters', {'board': {'b8': 'r', 'e1': 'K', 'g8': 'k', 'h8': 'r'}, 'rights': 'bh'},
['b8', 'h8']),
('K right but only a-side rook', {'board': {'a1': 'R', 'e8': 'k', 'g1': 'K'}, 'rights': 'K'}, []),
('king off back rank', {'board': {'e2': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'K'}, []),
('duplicate K and H', {'board': {'e1': 'K', 'e8': 'k', 'h1': 'R'}, 'rights': 'KH'}, ['h1']),
('black king on white back rank',
{'board': {'a1': 'R', 'b8': 'K', 'd1': 'k', 'h8': 'r'}, 'rights': 'k'}, [])]]
for label, args, expected in fixtures[N-1]:
try:
actual = solve(args)
except Exception as exc:
actual = 'error:' + type(exc).__name__
check(label, actual, expected)
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 |
|---|---|---|---|
| standard KQkq | ['a1', 'a8', 'h1', 'h8'] | ['a1', 'a8', 'h1', 'h8'] | Passed |
| two rooks on h-side | ['h1'] | ['h1'] | Passed |
| file letter inner rook | ['e1'] | ['e1'] | Passed |
| black file letters | ['b8', 'h8'] | ['b8', 'h8'] | Passed |
| K right but only a-side rook | [] | [] | Passed |
| king off back rank | [] | [] | Passed |
| duplicate K and H | ['h1'] | ['h1'] | Passed |
| black king on white back rank | [] | [] | Passed |
SHA-256 / dfa4519c696b78d89314625ca65e79b16718143f47c2b9650d1fdcb18c77ed8f
Verification & scope
A deterministic toy model with an explicitly stated contract; boards are {square: piece} with white upper-case and black lower-case pieces; no claim of full FIDE Laws 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:50:15.269061+00:00.
Case digest / 57fd79c167fea9b2b4064ec8847bcfe1bd7186886d93bbd321d2018cc34e0373