{"abstract":"Cosine similarity is treated as a distance.","category":"Vector retrieval ranking","checks":6,"contract":"Rows are [id,similarity]; return highest similarity first, lexical ties.","contract_signature":"rows","evaluation_group":"vector-retrieval-similarity-direction","failed_approach":"Reversing IDs resolves equal scores in the wrong lexical order even though the score direction is repaired.","family":"w3-vector-retrieval-ranking-similarity-direction","id":"FA-99446","implementations":{"attempt":{"sha256":"e7a7094c0c21d67fab9ad4aea4d1b19da6b6f33240a97cd9b6c1173e33300c11","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(rows):\n    return [x[0] for x in sorted(rows,key=lambda x:(-x[1],tuple(-ord(c) for c in x[0])))]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('strong match',solve([['weak',-0.2],['strong',0.8]]),['strong','weak'])\ncheck('positive ordering',solve([['a',N/10],['b',N/10+0.1]]),['b','a'])\ncheck('negative ordering',solve([['a',-0.9],['b',-0.1]]),['b','a'])\ncheck('tie lexical',solve([['z',0.5],['a',0.5]]),['a','z'])\ncheck('zero tie',solve([['z',0.0],['a',0.0]]),['a','z'])\ncheck('input shuffled',solve([['c',0.1],['a',0.9],['b',0.4]]),['a','b','c'])\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":"d41faa4bbed8c1aac29029a1779dbad276dff8dc1173d7eff0ee33b36f74e339","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(rows):\n    return [x[0] for x in sorted(rows,key=lambda x:x[1])]\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('strong match',solve([['weak',-0.2],['strong',0.8]]),['strong','weak'])\ncheck('positive ordering',solve([['a',N/10],['b',N/10+0.1]]),['b','a'])\ncheck('negative ordering',solve([['a',-0.9],['b',-0.1]]),['b','a'])\ncheck('tie lexical',solve([['z',0.5],['a',0.5]]),['a','z'])\ncheck('zero tie',solve([['z',0.0],['a',0.0]]),['a','z'])\ncheck('input shuffled',solve([['c',0.1],['a',0.9],['b',0.4]]),['a','b','c'])\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":"Inputs are small exact toy vectors and scores. No production index, ANN recall, embedding quality, or latency claim is implied. 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":"w3-vector-retrieval-ranking-similarity-direction","generated_at":"2026-09-30T16:48:24.474501+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"An offline vector retrieval toy model isolates one ranking contract from embedding generation, storage, and serving.","root_cause":"Similarity is sorted ascending as if it were a cost.","sha256":"9a2a91839cd45dcaa2305437e2eef4a217de469269ff14ebbaf6dffdee1ff5fd","title":"Vector retrieval: Cosine similarity is treated as a distance · case 01","variant":1,"variant_policy":"The fixture code references N, supplied as 1 through 5. Fixed boundary checks may repeat. These records share one mechanism and must remain together in evaluation splits.","verified":true,"visibility":"public","verification":{"attempt":{"elapsed_ms":28.347,"exit_code":1,"observations":[{"actual":["strong","weak"],"check":"strong match","expected":["strong","weak"],"passed":true},{"actual":["b","a"],"check":"positive ordering","expected":["b","a"],"passed":true},{"actual":["b","a"],"check":"negative ordering","expected":["b","a"],"passed":true},{"actual":["z","a"],"check":"tie lexical","expected":["a","z"],"passed":false},{"actual":["z","a"],"check":"zero tie","expected":["a","z"],"passed":false},{"actual":["a","b","c"],"check":"input shuffled","expected":["a","b","c"],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"strong match\", \"actual\": [\"strong\", \"weak\"], \"expected\": [\"strong\", \"weak\"], \"passed\": true}, {\"check\": \"positive ordering\", \"actual\": [\"b\", \"a\"], \"expected\": [\"b\", \"a\"], \"passed\": true}, {\"check\": \"negative ordering\", \"actual\": [\"b\", \"a\"], \"expected\": [\"b\", \"a\"], \"passed\": true}, {\"check\": \"tie lexical\", \"actual\": [\"z\", \"a\"], \"expected\": [\"a\", \"z\"], \"passed\": false}, {\"check\": \"zero tie\", \"actual\": [\"z\", \"a\"], \"expected\": [\"a\", \"z\"], \"passed\": false}, {\"check\": \"input shuffled\", \"actual\": [\"a\", \"b\", \"c\"], \"expected\": [\"a\", \"b\", \"c\"], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":28.433,"exit_code":1,"observations":[{"actual":["weak","strong"],"check":"strong match","expected":["strong","weak"],"passed":false},{"actual":["a","b"],"check":"positive ordering","expected":["b","a"],"passed":false},{"actual":["a","b"],"check":"negative ordering","expected":["b","a"],"passed":false},{"actual":["z","a"],"check":"tie lexical","expected":["a","z"],"passed":false},{"actual":["z","a"],"check":"zero tie","expected":["a","z"],"passed":false},{"actual":["c","b","a"],"check":"input shuffled","expected":["a","b","c"],"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"strong match\", \"actual\": [\"weak\", \"strong\"], \"expected\": [\"strong\", \"weak\"], \"passed\": false}, {\"check\": \"positive ordering\", \"actual\": [\"a\", \"b\"], \"expected\": [\"b\", \"a\"], \"passed\": false}, {\"check\": \"negative ordering\", \"actual\": [\"a\", \"b\"], \"expected\": [\"b\", \"a\"], \"passed\": false}, {\"check\": \"tie lexical\", \"actual\": [\"z\", \"a\"], \"expected\": [\"a\", \"z\"], \"passed\": false}, {\"check\": \"zero tie\", \"actual\": [\"z\", \"a\"], \"expected\": [\"a\", \"z\"], \"passed\": false}, {\"check\": \"input shuffled\", \"actual\": [\"c\", \"b\", \"a\"], \"expected\": [\"a\", \"b\", \"c\"], \"passed\": false}], \"passed\": false}\n"}},"member_only":{"stages":["fixed"],"fields":["implementations.fixed","verification.fixed","harness","repair"],"note":"The verified repair, its recorded checks, the repair description, and the scoring harness are available to members."}}