{"abstract":"Tie handling either truncates equivalent rows or admits an extra lower-scoring group beyond the kth-row boundary.","category":"Storage and queries","checks":7,"contract":"Rows are [unique_integer_id,integer_score]. For nonnegative k, return all rows tied with or above the kth row under score-descending ordering, with id ascending within ties. k=0 returns empty; k>=row_count returns all rows.","evaluation_group":"model-4be22d99e44bb322","failed_approach":"Keeping the first k distinct score levels over-includes rows when earlier ties already consumed multiple positions.","family":"store-topk-with-ties","id":"FA-151","implementations":{"attempt":{"sha256":"2fca6e4f5fad31094b0c5ce6a4fa130fc45c0a0a28557d629fefd3ff2d0221c1","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(rows, k):\n    levels = sorted({row[1] for row in rows}, reverse=True)[:k]\n    return sorted([row for row in rows if row[1] in levels], key=lambda row: (-row[1], row[0]))\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('tie straddles a row-count boundary', solve([[3, N], [2, 3*N], [1, 3*N]], 1), [[1, 3*N], [2, 3*N]])\ncheck('earlier tie consumes two row positions', solve([[4, N], [3, 2*N], [2, 3*N], [1, 3*N]], 2), [[1, 3*N], [2, 3*N]])\ncheck('tie at a later cutoff includes every equal score', solve([[1, 4*N], [4, N], [3, 2*N], [2, 2*N]], 2), [[1, 4*N], [2, 2*N], [3, 2*N]])\ncheck('zero limit', solve([[1, N]], 0), [])\ncheck('oversized limit sorts all rows', solve([[2, -N], [1, 0]], N+3), [[1, 0], [2, -N]])\ncheck('negative scores also tie', solve([[2, -N], [1, -N], [3, -N-1]], 1), [[1, -N], [2, -N]])\ncheck('empty relation', solve([], N), [])\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":"c081fcca1eed11ba8ac528195f96fb2228704c777b5c067694645659421f976e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(rows, k):\n    ordered = sorted(rows, key=lambda row: (-row[1], row[0]))\n    return ordered[:k]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('tie straddles a row-count boundary', solve([[3, N], [2, 3*N], [1, 3*N]], 1), [[1, 3*N], [2, 3*N]])\ncheck('earlier tie consumes two row positions', solve([[4, N], [3, 2*N], [2, 3*N], [1, 3*N]], 2), [[1, 3*N], [2, 3*N]])\ncheck('tie at a later cutoff includes every equal score', solve([[1, 4*N], [4, N], [3, 2*N], [2, 2*N]], 2), [[1, 4*N], [2, 2*N], [3, 2*N]])\ncheck('zero limit', solve([[1, N]], 0), [])\ncheck('oversized limit sorts all rows', solve([[2, -N], [1, 0]], N+3), [[1, 0], [2, -N]])\ncheck('negative scores also tie', solve([[2, -N], [1, -N], [3, -N-1]], 1), [[1, -N], [2, -N]])\ncheck('empty relation', solve([], N), [])\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":"7d0672c2d2f393b86474a5fbc7e51ea1ca7db8c6ee4bd5b260061703bae34221","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(rows, k):\n    ordered = sorted(rows, key=lambda row: (-row[1], row[0]))\n    if k == 0 or not ordered:\n        return []\n    cutoff = ordered[min(k, len(ordered))-1][1]\n    return [row for row in ordered if row[1] >= cutoff]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('tie straddles a row-count boundary', solve([[3, N], [2, 3*N], [1, 3*N]], 1), [[1, 3*N], [2, 3*N]])\ncheck('earlier tie consumes two row positions', solve([[4, N], [3, 2*N], [2, 3*N], [1, 3*N]], 2), [[1, 3*N], [2, 3*N]])\ncheck('tie at a later cutoff includes every equal score', solve([[1, 4*N], [4, N], [3, 2*N], [2, 2*N]], 2), [[1, 4*N], [2, 2*N], [3, 2*N]])\ncheck('zero limit', solve([[1, N]], 0), [])\ncheck('oversized limit sorts all rows', solve([[2, -N], [1, 0]], N+3), [[1, 0], [2, -N]])\ncheck('negative scores also tie', solve([[2, -N], [1, -N], [3, -N-1]], 1), [[1, -N], [2, -N]])\ncheck('empty relation', solve([], N), [])\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":" 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":"store-topk-with-ties","generated_at":"2026-09-29T14:36:50.986728+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"Models FETCH FIRST k ROWS WITH TIES using an explicit score-only tie definition and deterministic output order. The task concerns rank cutoff cardinality, not cursor state or duplicate delivery.","repair":"Sort rows deterministically, locate the kth row's score, and include every row with a score at least that cutoff.","root_cause":"A row-count limit and a count of distinct score values are treated as the same ranking cutoff.","sha256":"62b070e277697517f22479c92a88d5c4fd92cc4c1e0884cfa29f949625ff1674","title":"A top-k query uses distinct score levels instead of the kth row's score · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":31.599,"exit_code":1,"observations":[{"actual":[[1,3],[2,3]],"check":"tie straddles a row-count boundary","expected":[[1,3],[2,3]],"passed":true},{"actual":[[1,3],[2,3],[3,2]],"check":"earlier tie consumes two row positions","expected":[[1,3],[2,3]],"passed":false},{"actual":[[1,4],[2,2],[3,2]],"check":"tie at a later cutoff includes every equal score","expected":[[1,4],[2,2],[3,2]],"passed":true},{"actual":[],"check":"zero limit","expected":[],"passed":true},{"actual":[[1,0],[2,-1]],"check":"oversized limit sorts all rows","expected":[[1,0],[2,-1]],"passed":true},{"actual":[[1,-1],[2,-1]],"check":"negative scores also tie","expected":[[1,-1],[2,-1]],"passed":true},{"actual":[],"check":"empty relation","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"tie straddles a row-count boundary\", \"actual\": [[1, 3], [2, 3]], \"expected\": [[1, 3], [2, 3]], \"passed\": true}, {\"check\": \"earlier tie consumes two row positions\", \"actual\": [[1, 3], [2, 3], [3, 2]], \"expected\": [[1, 3], [2, 3]], \"passed\": false}, {\"check\": \"tie at a later cutoff includes every equal score\", \"actual\": [[1, 4], [2, 2], [3, 2]], \"expected\": [[1, 4], [2, 2], [3, 2]], \"passed\": true}, {\"check\": \"zero limit\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"oversized limit sorts all rows\", \"actual\": [[1, 0], [2, -1]], \"expected\": [[1, 0], [2, -1]], \"passed\": true}, {\"check\": \"negative scores also tie\", \"actual\": [[1, -1], [2, -1]], \"expected\": [[1, -1], [2, -1]], \"passed\": true}, {\"check\": \"empty relation\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":33.354,"exit_code":1,"observations":[{"actual":[[1,3]],"check":"tie straddles a row-count boundary","expected":[[1,3],[2,3]],"passed":false},{"actual":[[1,3],[2,3]],"check":"earlier tie consumes two row positions","expected":[[1,3],[2,3]],"passed":true},{"actual":[[1,4],[2,2]],"check":"tie at a later cutoff includes every equal score","expected":[[1,4],[2,2],[3,2]],"passed":false},{"actual":[],"check":"zero limit","expected":[],"passed":true},{"actual":[[1,0],[2,-1]],"check":"oversized limit sorts all rows","expected":[[1,0],[2,-1]],"passed":true},{"actual":[[1,-1]],"check":"negative scores also tie","expected":[[1,-1],[2,-1]],"passed":false},{"actual":[],"check":"empty relation","expected":[],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"tie straddles a row-count boundary\", \"actual\": [[1, 3]], \"expected\": [[1, 3], [2, 3]], \"passed\": false}, {\"check\": \"earlier tie consumes two row positions\", \"actual\": [[1, 3], [2, 3]], \"expected\": [[1, 3], [2, 3]], \"passed\": true}, {\"check\": \"tie at a later cutoff includes every equal score\", \"actual\": [[1, 4], [2, 2]], \"expected\": [[1, 4], [2, 2], [3, 2]], \"passed\": false}, {\"check\": \"zero limit\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"oversized limit sorts all rows\", \"actual\": [[1, 0], [2, -1]], \"expected\": [[1, 0], [2, -1]], \"passed\": true}, {\"check\": \"negative scores also tie\", \"actual\": [[1, -1]], \"expected\": [[1, -1], [2, -1]], \"passed\": false}, {\"check\": \"empty relation\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":31.0,"exit_code":0,"observations":[{"actual":[[1,3],[2,3]],"check":"tie straddles a row-count boundary","expected":[[1,3],[2,3]],"passed":true},{"actual":[[1,3],[2,3]],"check":"earlier tie consumes two row positions","expected":[[1,3],[2,3]],"passed":true},{"actual":[[1,4],[2,2],[3,2]],"check":"tie at a later cutoff includes every equal score","expected":[[1,4],[2,2],[3,2]],"passed":true},{"actual":[],"check":"zero limit","expected":[],"passed":true},{"actual":[[1,0],[2,-1]],"check":"oversized limit sorts all rows","expected":[[1,0],[2,-1]],"passed":true},{"actual":[[1,-1],[2,-1]],"check":"negative scores also tie","expected":[[1,-1],[2,-1]],"passed":true},{"actual":[],"check":"empty relation","expected":[],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"tie straddles a row-count boundary\", \"actual\": [[1, 3], [2, 3]], \"expected\": [[1, 3], [2, 3]], \"passed\": true}, {\"check\": \"earlier tie consumes two row positions\", \"actual\": [[1, 3], [2, 3]], \"expected\": [[1, 3], [2, 3]], \"passed\": true}, {\"check\": \"tie at a later cutoff includes every equal score\", \"actual\": [[1, 4], [2, 2], [3, 2]], \"expected\": [[1, 4], [2, 2], [3, 2]], \"passed\": true}, {\"check\": \"zero limit\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"oversized limit sorts all rows\", \"actual\": [[1, 0], [2, -1]], \"expected\": [[1, 0], [2, -1]], \"passed\": true}, {\"check\": \"negative scores also tie\", \"actual\": [[1, -1], [2, -1]], \"expected\": [[1, -1], [2, -1]], \"passed\": true}, {\"check\": \"empty relation\", \"actual\": [], \"expected\": [], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}