{"abstract":"White pieces listed on the last FEN row appear on rank 8.","category":"Chess move legality","checks":8,"contract":"Input: a FEN string. Return {\"pieces\": {square: piece}, \"turn\", \"castling\", \"ep\", \"halfmove\", \"fullmove\"} or \"invalid\". Placement lists rank 8 first; digits skip empty squares; each rank must total 8; exactly one king per side. Turn is w or b; castling is \"-\" or letters from KQkq (returned as \"\" when \"-\"); ep is \"-\" (null) or a square on rank 6 when white is to move, rank 3 when black is; halfmove is a non-negative integer and fullmove at least 1.","evaluation_group":"w2-chess_move_legality-fen-position-parse","failed_approach":"Using 7 - i shifts every piece down one rank and puts the first row on rank 7.","family":"w2-chess_move_legality-fen-position-parse-rank-order","id":"FA-82541","implementations":{"attempt":{"sha256":"db3a70300d01554cde5a854071cb9ddc2077e6f9f1b4ffe38746cf6b6889e0be","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    parts=x.split()\n    if len(parts)!=6: return 'invalid'\n    rows=parts[0].split('/')\n    if len(rows)!=8: return 'invalid'\n    board={}\n    for i,row in enumerate(rows):\n        rank=7-i; f=0\n        for ch in row:\n            if ch.isdigit(): f+=int(ch)\n            elif ch in 'pnbrqkPNBRQK':\n                if f>7: return 'invalid'\n                board[chr(97+f)+str(rank)]=ch; f+=1\n            else: return 'invalid'\n        if f!=8: return 'invalid'\n    vals=list(board.values())\n    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'\n    turn=parts[1]\n    if turn not in ('w','b'): return 'invalid'\n    cast='' if parts[2]=='-' else parts[2]\n    if any(c not in 'KQkq' for c in cast): return 'invalid'\n    ep=None if parts[3]=='-' else parts[3]\n    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'\n    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'\n    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),\n  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid')],\n [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),\n  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),\n  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),\n  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),\n  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],\n [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),\n  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),\n  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),\n  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],\n [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',\n   {'castling': 'kq',\n    'ep': None,\n    'fullmove': 5,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'w'}),\n  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',\n   {'castling': 'K',\n    'ep': None,\n    'fullmove': 30,\n    'halfmove': 7,\n    'pieces': {'a7': 'p',\n               'a8': 'r',\n               'b7': 'p',\n               'b8': 'n',\n               'e1': 'K',\n               'e8': 'k',\n               'g1': 'N',\n               'g2': 'P',\n               'h1': 'R',\n               'h2': 'P'},\n    'turn': 'w'}),\n  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],\n [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',\n   {'castling': 'kq',\n    'ep': None,\n    'fullmove': 5,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'w'}),\n  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',\n   {'castling': 'K',\n    'ep': None,\n    'fullmove': 30,\n    'halfmove': 7,\n    'pieces': {'a7': 'p',\n               'a8': 'r',\n               'b7': 'p',\n               'b8': 'n',\n               'e1': 'K',\n               'e8': 'k',\n               'g1': 'N',\n               'g2': 'P',\n               'h1': 'R',\n               'h2': 'P'},\n    'turn': 'w'})]]\nfor label, args, expected in fixtures[N-1]:\n    try:\n        actual = solve(args)\n    except Exception as exc:\n        actual = 'error:' + type(exc).__name__\n    check(label, actual, expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"broken":{"sha256":"3cdfca62871cce868edc8514b20be32aa9bfd944e367803c56bbe630eea53555","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    parts=x.split()\n    if len(parts)!=6: return 'invalid'\n    rows=parts[0].split('/')\n    if len(rows)!=8: return 'invalid'\n    board={}\n    for i,row in enumerate(rows):\n        rank=i+1; f=0\n        for ch in row:\n            if ch.isdigit(): f+=int(ch)\n            elif ch in 'pnbrqkPNBRQK':\n                if f>7: return 'invalid'\n                board[chr(97+f)+str(rank)]=ch; f+=1\n            else: return 'invalid'\n        if f!=8: return 'invalid'\n    vals=list(board.values())\n    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'\n    turn=parts[1]\n    if turn not in ('w','b'): return 'invalid'\n    cast='' if parts[2]=='-' else parts[2]\n    if any(c not in 'KQkq' for c in cast): return 'invalid'\n    ep=None if parts[3]=='-' else parts[3]\n    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'\n    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'\n    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),\n  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid')],\n [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),\n  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),\n  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),\n  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),\n  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],\n [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),\n  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),\n  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),\n  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],\n [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',\n   {'castling': 'kq',\n    'ep': None,\n    'fullmove': 5,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'w'}),\n  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',\n   {'castling': 'K',\n    'ep': None,\n    'fullmove': 30,\n    'halfmove': 7,\n    'pieces': {'a7': 'p',\n               'a8': 'r',\n               'b7': 'p',\n               'b8': 'n',\n               'e1': 'K',\n               'e8': 'k',\n               'g1': 'N',\n               'g2': 'P',\n               'h1': 'R',\n               'h2': 'P'},\n    'turn': 'w'}),\n  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],\n [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',\n   {'castling': 'kq',\n    'ep': None,\n    'fullmove': 5,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'w'}),\n  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',\n   {'castling': 'K',\n    'ep': None,\n    'fullmove': 30,\n    'halfmove': 7,\n    'pieces': {'a7': 'p',\n               'a8': 'r',\n               'b7': 'p',\n               'b8': 'n',\n               'e1': 'K',\n               'e8': 'k',\n               'g1': 'N',\n               'g2': 'P',\n               'h1': 'R',\n               'h2': 'P'},\n    'turn': 'w'})]]\nfor label, args, expected in fixtures[N-1]:\n    try:\n        actual = solve(args)\n    except Exception as exc:\n        actual = 'error:' + type(exc).__name__\n    check(label, actual, expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"},"fixed":{"sha256":"78a9b73881ff913ba212bfe49a7ddcb1b37029d73ee5e3e116db00db9d313748","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(x):\n    parts=x.split()\n    if len(parts)!=6: return 'invalid'\n    rows=parts[0].split('/')\n    if len(rows)!=8: return 'invalid'\n    board={}\n    for i,row in enumerate(rows):\n        rank=8-i; f=0\n        for ch in row:\n            if ch.isdigit(): f+=int(ch)\n            elif ch in 'pnbrqkPNBRQK':\n                if f>7: return 'invalid'\n                board[chr(97+f)+str(rank)]=ch; f+=1\n            else: return 'invalid'\n        if f!=8: return 'invalid'\n    vals=list(board.values())\n    if vals.count('K')!=1 or vals.count('k')!=1: return 'invalid'\n    turn=parts[1]\n    if turn not in ('w','b'): return 'invalid'\n    cast='' if parts[2]=='-' else parts[2]\n    if any(c not in 'KQkq' for c in cast): return 'invalid'\n    ep=None if parts[3]=='-' else parts[3]\n    if ep is not None and ep[1:]!=('6' if turn=='w' else '3'): return 'invalid'\n    if not (parts[4].isdigit() and parts[5].isdigit()) or int(parts[5])<1: return 'invalid'\n    return {'pieces':board,'turn':turn,'castling':cast,'ep':ep,'halfmove':int(parts[4]),'fullmove':int(parts[5])}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\nfixtures = [[('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),\n  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid')],\n [('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('short rank', '4k3/8/8/8/8/8/8/4K2 w - - 0 1', 'invalid'),\n  ('fullmove zero', '4k3/8/8/8/8/8/8/4K3 w - - 0 0', 'invalid'),\n  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),\n  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),\n  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid')],\n [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('halfmove dash', '4k3/8/8/8/8/8/8/4K3 w - - - 1', 'invalid'),\n  ('bad castling letter', '4k3/8/8/8/8/8/8/4K3 w X - 0 1', 'invalid'),\n  ('bad turn', '4k3/8/8/8/8/8/8/4K3 x - - 0 1', 'invalid'),\n  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],\n [('kings and rook', '4k3/8/8/8/8/8/8/R3K3 w Q - 0 1',\n   {'castling': 'Q',\n    'ep': None,\n    'fullmove': 1,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'e1': 'K', 'e8': 'k'},\n    'turn': 'w'}),\n  ('black to move ep', '4k3/8/8/8/3Pp3/8/8/4K3 b - d3 0 12',\n   {'castling': '',\n    'ep': 'd3',\n    'fullmove': 12,\n    'halfmove': 0,\n    'pieces': {'d4': 'P', 'e1': 'K', 'e4': 'p', 'e8': 'k'},\n    'turn': 'b'}),\n  ('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',\n   {'castling': 'kq',\n    'ep': None,\n    'fullmove': 5,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'w'}),\n  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',\n   {'castling': 'K',\n    'ep': None,\n    'fullmove': 30,\n    'halfmove': 7,\n    'pieces': {'a7': 'p',\n               'a8': 'r',\n               'b7': 'p',\n               'b8': 'n',\n               'e1': 'K',\n               'e8': 'k',\n               'g1': 'N',\n               'g2': 'P',\n               'h1': 'R',\n               'h2': 'P'},\n    'turn': 'w'}),\n  ('fullmove dash', '4k3/8/8/8/8/8/8/4K3 w - - 0 -', 'invalid')],\n [('white ep target', '4k3/8/8/3pP3/8/8/8/4K3 w - d6 0 9',\n   {'castling': '',\n    'ep': 'd6',\n    'fullmove': 9,\n    'halfmove': 0,\n    'pieces': {'d5': 'p', 'e1': 'K', 'e5': 'P', 'e8': 'k'},\n    'turn': 'w'}),\n  ('ep wrong side', '4k3/8/8/3pP3/8/8/8/4K3 w - d3 0 9', 'invalid'),\n  ('no castling dash', 'r3k2r/8/8/8/8/8/8/R3K2R b - - 3 20',\n   {'castling': '',\n    'ep': None,\n    'fullmove': 20,\n    'halfmove': 3,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'b'}),\n  ('black rights only', 'r3k2r/8/8/8/8/8/8/R3K2R w kq - 0 5',\n   {'castling': 'kq',\n    'ep': None,\n    'fullmove': 5,\n    'halfmove': 0,\n    'pieces': {'a1': 'R', 'a8': 'r', 'e1': 'K', 'e8': 'k', 'h1': 'R', 'h8': 'r'},\n    'turn': 'w'}),\n  ('two white kings', '4k3/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('two white kings no black', '8/8/8/8/8/8/8/K3K3 w - - 0 1', 'invalid'),\n  ('missing black king', '8/8/8/8/8/8/8/4K3 w - - 0 1', 'invalid'),\n  ('pawns and knights', 'rn2k3/pp6/8/8/8/8/6PP/4K1NR w K - 7 30',\n   {'castling': 'K',\n    'ep': None,\n    'fullmove': 30,\n    'halfmove': 7,\n    'pieces': {'a7': 'p',\n               'a8': 'r',\n               'b7': 'p',\n               'b8': 'n',\n               'e1': 'K',\n               'e8': 'k',\n               'g1': 'N',\n               'g2': 'P',\n               'h1': 'R',\n               'h2': 'P'},\n    'turn': 'w'})]]\nfor label, args, expected in fixtures[N-1]:\n    try:\n        actual = solve(args)\n    except Exception as exc:\n        actual = 'error:' + type(exc).__name__\n    check(label, actual, expected)\nprint(json.dumps({\"observations\": observations, \"passed\": all(x[\"passed\"] for x in observations)}, ensure_ascii=False))\nraise SystemExit(0 if all(x[\"passed\"] for x in observations) else 1)\n"}},"limitations":"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.","method":"Deterministic executable model with adversarial boundary fixtures.","provenance":{"created_by":"Failure Map","dependencies":"Python standard library","family":"w2-chess_move_legality-fen-position-parse-rank-order","generated_at":"2026-09-29T14:50:13.158097+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Every position-based legality check starts from a parsed FEN; a misparse silently changes which moves are legal.","repair":"Row i of the placement field is rank 8 - i.","root_cause":"Rows are numbered from rank 1 although FEN lists rank 8 first.","sha256":"d5d6b5383ad8e4ba902a9db723cc73967295819cb4aa19f1aec6cf37d75796c2","title":"FEN placement read bottom-up · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":41.32,"exit_code":1,"observations":[{"actual":{"castling":"Q","ep":null,"fullmove":1,"halfmove":0,"pieces":{"a0":"R","e0":"K","e7":"k"},"turn":"w"},"check":"kings and rook","expected":{"castling":"Q","ep":null,"fullmove":1,"halfmove":0,"pieces":{"a1":"R","e1":"K","e8":"k"},"turn":"w"},"passed":false},{"actual":{"castling":"","ep":"d3","fullmove":12,"halfmove":0,"pieces":{"d3":"P","e0":"K","e3":"p","e7":"k"},"turn":"b"},"check":"black to move ep","expected":{"castling":"","ep":"d3","fullmove":12,"halfmove":0,"pieces":{"d4":"P","e1":"K","e4":"p","e8":"k"},"turn":"b"},"passed":false},{"actual":"invalid","check":"ep wrong side","expected":"invalid","passed":true},{"actual":"invalid","check":"two white kings","expected":"invalid","passed":true},{"actual":"invalid","check":"two white kings no black","expected":"invalid","passed":true},{"actual":"invalid","check":"missing black king","expected":"invalid","passed":true},{"actual":"invalid","check":"short rank","expected":"invalid","passed":true},{"actual":"invalid","check":"fullmove zero","expected":"invalid","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"kings and rook\", \"actual\": {\"pieces\": {\"e7\": \"k\", \"a0\": \"R\", \"e0\": \"K\"}, \"turn\": \"w\", \"castling\": \"Q\", \"ep\": null, \"halfmove\": 0, \"fullmove\": 1}, \"expected\": {\"castling\": \"Q\", \"ep\": null, \"fullmove\": 1, \"halfmove\": 0, \"pieces\": {\"a1\": \"R\", \"e1\": \"K\", \"e8\": \"k\"}, \"turn\": \"w\"}, \"passed\": false}, {\"check\": \"black to move ep\", \"actual\": {\"pieces\": {\"e7\": \"k\", \"d3\": \"P\", \"e3\": \"p\", \"e0\": \"K\"}, \"turn\": \"b\", \"castling\": \"\", \"ep\": \"d3\", \"halfmove\": 0, \"fullmove\": 12}, \"expected\": {\"castling\": \"\", \"ep\": \"d3\", \"fullmove\": 12, \"halfmove\": 0, \"pieces\": {\"d4\": \"P\", \"e1\": \"K\", \"e4\": \"p\", \"e8\": \"k\"}, \"turn\": \"b\"}, \"passed\": false}, {\"check\": \"ep wrong side\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"two white kings\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"two white kings no black\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"missing black king\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"short rank\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"fullmove zero\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":41.046,"exit_code":1,"observations":[{"actual":{"castling":"Q","ep":null,"fullmove":1,"halfmove":0,"pieces":{"a8":"R","e1":"k","e8":"K"},"turn":"w"},"check":"kings and rook","expected":{"castling":"Q","ep":null,"fullmove":1,"halfmove":0,"pieces":{"a1":"R","e1":"K","e8":"k"},"turn":"w"},"passed":false},{"actual":{"castling":"","ep":"d3","fullmove":12,"halfmove":0,"pieces":{"d5":"P","e1":"k","e5":"p","e8":"K"},"turn":"b"},"check":"black to move ep","expected":{"castling":"","ep":"d3","fullmove":12,"halfmove":0,"pieces":{"d4":"P","e1":"K","e4":"p","e8":"k"},"turn":"b"},"passed":false},{"actual":"invalid","check":"ep wrong side","expected":"invalid","passed":true},{"actual":"invalid","check":"two white kings","expected":"invalid","passed":true},{"actual":"invalid","check":"two white kings no black","expected":"invalid","passed":true},{"actual":"invalid","check":"missing black king","expected":"invalid","passed":true},{"actual":"invalid","check":"short rank","expected":"invalid","passed":true},{"actual":"invalid","check":"fullmove zero","expected":"invalid","passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"kings and rook\", \"actual\": {\"pieces\": {\"e1\": \"k\", \"a8\": \"R\", \"e8\": \"K\"}, \"turn\": \"w\", \"castling\": \"Q\", \"ep\": null, \"halfmove\": 0, \"fullmove\": 1}, \"expected\": {\"castling\": \"Q\", \"ep\": null, \"fullmove\": 1, \"halfmove\": 0, \"pieces\": {\"a1\": \"R\", \"e1\": \"K\", \"e8\": \"k\"}, \"turn\": \"w\"}, \"passed\": false}, {\"check\": \"black to move ep\", \"actual\": {\"pieces\": {\"e1\": \"k\", \"d5\": \"P\", \"e5\": \"p\", \"e8\": \"K\"}, \"turn\": \"b\", \"castling\": \"\", \"ep\": \"d3\", \"halfmove\": 0, \"fullmove\": 12}, \"expected\": {\"castling\": \"\", \"ep\": \"d3\", \"fullmove\": 12, \"halfmove\": 0, \"pieces\": {\"d4\": \"P\", \"e1\": \"K\", \"e4\": \"p\", \"e8\": \"k\"}, \"turn\": \"b\"}, \"passed\": false}, {\"check\": \"ep wrong side\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"two white kings\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"two white kings no black\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"missing black king\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"short rank\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"fullmove zero\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":42.307,"exit_code":0,"observations":[{"actual":{"castling":"Q","ep":null,"fullmove":1,"halfmove":0,"pieces":{"a1":"R","e1":"K","e8":"k"},"turn":"w"},"check":"kings and rook","expected":{"castling":"Q","ep":null,"fullmove":1,"halfmove":0,"pieces":{"a1":"R","e1":"K","e8":"k"},"turn":"w"},"passed":true},{"actual":{"castling":"","ep":"d3","fullmove":12,"halfmove":0,"pieces":{"d4":"P","e1":"K","e4":"p","e8":"k"},"turn":"b"},"check":"black to move ep","expected":{"castling":"","ep":"d3","fullmove":12,"halfmove":0,"pieces":{"d4":"P","e1":"K","e4":"p","e8":"k"},"turn":"b"},"passed":true},{"actual":"invalid","check":"ep wrong side","expected":"invalid","passed":true},{"actual":"invalid","check":"two white kings","expected":"invalid","passed":true},{"actual":"invalid","check":"two white kings no black","expected":"invalid","passed":true},{"actual":"invalid","check":"missing black king","expected":"invalid","passed":true},{"actual":"invalid","check":"short rank","expected":"invalid","passed":true},{"actual":"invalid","check":"fullmove zero","expected":"invalid","passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"kings and rook\", \"actual\": {\"pieces\": {\"e8\": \"k\", \"a1\": \"R\", \"e1\": \"K\"}, \"turn\": \"w\", \"castling\": \"Q\", \"ep\": null, \"halfmove\": 0, \"fullmove\": 1}, \"expected\": {\"castling\": \"Q\", \"ep\": null, \"fullmove\": 1, \"halfmove\": 0, \"pieces\": {\"a1\": \"R\", \"e1\": \"K\", \"e8\": \"k\"}, \"turn\": \"w\"}, \"passed\": true}, {\"check\": \"black to move ep\", \"actual\": {\"pieces\": {\"e8\": \"k\", \"d4\": \"P\", \"e4\": \"p\", \"e1\": \"K\"}, \"turn\": \"b\", \"castling\": \"\", \"ep\": \"d3\", \"halfmove\": 0, \"fullmove\": 12}, \"expected\": {\"castling\": \"\", \"ep\": \"d3\", \"fullmove\": 12, \"halfmove\": 0, \"pieces\": {\"d4\": \"P\", \"e1\": \"K\", \"e4\": \"p\", \"e8\": \"k\"}, \"turn\": \"b\"}, \"passed\": true}, {\"check\": \"ep wrong side\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"two white kings\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"two white kings no black\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"missing black king\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"short rank\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}, {\"check\": \"fullmove zero\", \"actual\": \"invalid\", \"expected\": \"invalid\", \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}