{"abstract":"Canonical Huffman codes advance without shifting at length changes.","category":"Compression format semantics","checks":6,"contract":"Given valid nonzero Huffman lengths keyed by symbol, return integer codes assigned by ascending (length,symbol), incrementing then left-shifting when length grows. Empty input returns {}.","evaluation_group":"model-17b9424646e0465a","failed_approach":"Sorting by symbol alone breaks canonical length-first ordering.","family":"z-compression-canonical-prefixes","id":"FA-11606","implementations":{"attempt":{"sha256":"92a2d65550848dcbcb34088e60e9dcd80b0f3be321a1dd551d8049699c6e79fa","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(lengths):\n    out={}; code=0; previous=0\n    for s,n in sorted(lengths.items()):\n        code = (code << max(0,n-previous))\n        out[s]=code; code+=1; previous=n\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('length jump',solve({'a':1,'b':N+2}),{'a':0,'b':2**(N+1)})\ncheck('symbol order differs',solve({'a':2,'z':1}),{'z':0,'a':2})\ncheck('tie order',solve({'b':2,'a':2}),{'a':0,'b':1})\ncheck('empty',solve({}),{})\ncheck('single',solve({'x':3}),{'x':0})\ncheck('complete tree',solve({'a':1,'b':2,'c':2}),{'a':0,'b':2,'c':3})\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":"61d8471d457ceb17f1d310a3e3936bcfc93ae3da35191e7b404259b0231dee42","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(lengths):\n    return {s:i for i,(s,n) in enumerate(sorted(lengths.items(),key=lambda p:(p[1],p[0])))}\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('length jump',solve({'a':1,'b':N+2}),{'a':0,'b':2**(N+1)})\ncheck('symbol order differs',solve({'a':2,'z':1}),{'z':0,'a':2})\ncheck('tie order',solve({'b':2,'a':2}),{'a':0,'b':1})\ncheck('empty',solve({}),{})\ncheck('single',solve({'x':3}),{'x':0})\ncheck('complete tree',solve({'a':1,'b':2,'c':2}),{'a':0,'b':2,'c':3})\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":"f9f189b27106e5a4af57398b878340ff34eb359a07be53213b5010982cda215e","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(lengths):\n    out={}; code=0; previous=0\n    for s,n in sorted(lengths.items(),key=lambda p:(p[1],p[0])):\n        code <<= n-previous\n        out[s]=code; code+=1; previous=n\n    return out\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('length jump',solve({'a':1,'b':N+2}),{'a':0,'b':2**(N+1)})\ncheck('symbol order differs',solve({'a':2,'z':1}),{'z':0,'a':2})\ncheck('tie order',solve({'b':2,'a':2}),{'a':0,'b':1})\ncheck('empty',solve({}),{})\ncheck('single',solve({'x':3}),{'x':0})\ncheck('complete tree',solve({'a':1,'b':2,'c':2}),{'a':0,'b':2,'c':3})\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":"Controlled educational model, not a complete implementation of a production compression format. 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":"z-compression-canonical-prefixes","generated_at":"2026-09-29T14:38:49.332236+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A small offline codec model isolates a compression-specific failure without external files or libraries.","repair":"Order entries by length then symbol and shift the next available code by the increase in code length.","root_cause":"Code assignment increments without shifting when the next code is longer.","sha256":"510ab691e4db750c65e14be8c62cd78f06859ddc9fb321e26db767eaac662b24","title":"Canonical Huffman codes advance without shifting at length changes · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":39.562,"exit_code":1,"observations":[{"actual":{"a":0,"b":4},"check":"length jump","expected":{"a":0,"b":4},"passed":true},{"actual":{"a":0,"z":1},"check":"symbol order differs","expected":{"a":2,"z":0},"passed":false},{"actual":{"a":0,"b":1},"check":"tie order","expected":{"a":0,"b":1},"passed":true},{"actual":{},"check":"empty","expected":{},"passed":true},{"actual":{"x":0},"check":"single","expected":{"x":0},"passed":true},{"actual":{"a":0,"b":2,"c":3},"check":"complete tree","expected":{"a":0,"b":2,"c":3},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"length jump\", \"actual\": {\"a\": 0, \"b\": 4}, \"expected\": {\"a\": 0, \"b\": 4}, \"passed\": true}, {\"check\": \"symbol order differs\", \"actual\": {\"a\": 0, \"z\": 1}, \"expected\": {\"z\": 0, \"a\": 2}, \"passed\": false}, {\"check\": \"tie order\", \"actual\": {\"a\": 0, \"b\": 1}, \"expected\": {\"a\": 0, \"b\": 1}, \"passed\": true}, {\"check\": \"empty\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"single\", \"actual\": {\"x\": 0}, \"expected\": {\"x\": 0}, \"passed\": true}, {\"check\": \"complete tree\", \"actual\": {\"a\": 0, \"b\": 2, \"c\": 3}, \"expected\": {\"a\": 0, \"b\": 2, \"c\": 3}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":39.027,"exit_code":1,"observations":[{"actual":{"a":0,"b":1},"check":"length jump","expected":{"a":0,"b":4},"passed":false},{"actual":{"a":1,"z":0},"check":"symbol order differs","expected":{"a":2,"z":0},"passed":false},{"actual":{"a":0,"b":1},"check":"tie order","expected":{"a":0,"b":1},"passed":true},{"actual":{},"check":"empty","expected":{},"passed":true},{"actual":{"x":0},"check":"single","expected":{"x":0},"passed":true},{"actual":{"a":0,"b":1,"c":2},"check":"complete tree","expected":{"a":0,"b":2,"c":3},"passed":false}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"length jump\", \"actual\": {\"a\": 0, \"b\": 1}, \"expected\": {\"a\": 0, \"b\": 4}, \"passed\": false}, {\"check\": \"symbol order differs\", \"actual\": {\"z\": 0, \"a\": 1}, \"expected\": {\"z\": 0, \"a\": 2}, \"passed\": false}, {\"check\": \"tie order\", \"actual\": {\"a\": 0, \"b\": 1}, \"expected\": {\"a\": 0, \"b\": 1}, \"passed\": true}, {\"check\": \"empty\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"single\", \"actual\": {\"x\": 0}, \"expected\": {\"x\": 0}, \"passed\": true}, {\"check\": \"complete tree\", \"actual\": {\"a\": 0, \"b\": 1, \"c\": 2}, \"expected\": {\"a\": 0, \"b\": 2, \"c\": 3}, \"passed\": false}], \"passed\": false}\n"},"fixed":{"elapsed_ms":40.58,"exit_code":0,"observations":[{"actual":{"a":0,"b":4},"check":"length jump","expected":{"a":0,"b":4},"passed":true},{"actual":{"a":2,"z":0},"check":"symbol order differs","expected":{"a":2,"z":0},"passed":true},{"actual":{"a":0,"b":1},"check":"tie order","expected":{"a":0,"b":1},"passed":true},{"actual":{},"check":"empty","expected":{},"passed":true},{"actual":{"x":0},"check":"single","expected":{"x":0},"passed":true},{"actual":{"a":0,"b":2,"c":3},"check":"complete tree","expected":{"a":0,"b":2,"c":3},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"length jump\", \"actual\": {\"a\": 0, \"b\": 4}, \"expected\": {\"a\": 0, \"b\": 4}, \"passed\": true}, {\"check\": \"symbol order differs\", \"actual\": {\"z\": 0, \"a\": 2}, \"expected\": {\"z\": 0, \"a\": 2}, \"passed\": true}, {\"check\": \"tie order\", \"actual\": {\"a\": 0, \"b\": 1}, \"expected\": {\"a\": 0, \"b\": 1}, \"passed\": true}, {\"check\": \"empty\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"single\", \"actual\": {\"x\": 0}, \"expected\": {\"x\": 0}, \"passed\": true}, {\"check\": \"complete tree\", \"actual\": {\"a\": 0, \"b\": 2, \"c\": 3}, \"expected\": {\"a\": 0, \"b\": 2, \"c\": 3}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}