{"abstract":"A shared reference incorrectly makes its referent lifetime invariant.","category":"Borrow checking","checks":12,"contract":"Infer lifetime parameter variance in a toy type tree. Variance signs are +1 covariant, -1 contravariant, 0 invariant; repeated different signs join to invariant. var(name); ref(lifetime,type) covariant both; mut(lifetime,type) covariant lifetime invariant payload; fn(argument,result) flips argument; tuple(list) joins; cell(type) invariant; phantom(type) covariant; array(type,length) covariant; opaque(parameters) invariant for every listed parameter; unused(name) contributes nothing. Return parameter-to-sign map.","evaluation_group":"s3-borrow-checking-variance-inference","failed_approach":"The partial repair uses if kind=='ref': children=[('var',t[1]),t[2]]; signs=[sign,0], which still violates the stipulated analysis contract.","family":"s3-borrow-checking-variance-inference-shared-referent","id":"FA-43501","implementations":{"attempt":{"sha256":"3be57c50f2ec9543bbeaa2e228d6d44e521da2ff2cf5aa9bd63d9f6897768c88","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tree):\n    def walk(t,sign):\n        kind=t[0]\n        if kind=='var': return {t[1]:sign}\n        if kind=='unused': return {}\n        if kind=='ref': children=[('var',t[1]),t[2]]; signs=[sign,0]\n        elif kind=='mut': children=[('var',t[1]),t[2]]; signs=[sign,0]\n        elif kind=='fn': children=[t[1],t[2]]; signs=[-sign,sign]\n        elif kind=='tuple': children=t[1]; signs=[sign]*len(children)\n        elif kind=='cell': children=[t[1]]; signs=[0]\n        elif kind=='phantom': children=[t[1]]; signs=[sign]\n        elif kind=='array': children=[t[1]]; signs=[sign]\n        elif kind=='opaque': children=[('var',p) for p in t[1]]; signs=[0]*len(children)\n        else: return {}\n        out={}\n        for child,s in zip(children,signs):\n            for p,v in walk(child,s).items():\n                out[p]=v if p not in out or out[p]==v else 0\n        return out\n    return walk(tree,1)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('variable',solve(('var','a')),{'a':1})\ncheck('unused',solve(('unused','a')), {})\ncheck('shared',solve(('ref','a',('var','b'))),{'a':1,'b':1})\ncheck('mutable',solve(('mut','a',('var','b'))),{'a':1,'b':0})\ncheck('function',solve(('fn',('var','a'),('var','b'))),{'a':-1,'b':1})\ncheck('tuple',solve(('tuple',[('var','a'),('var','b')])),{'a':1,'b':1})\ncheck('cell',solve(('cell',('var','a'))),{'a':0})\ncheck('phantom',solve(('phantom',('var','a'))),{'a':1})\ncheck('opaque',solve(('opaque',['a','b'])),{'a':0,'b':0})\ncheck('both positions',solve(('fn',('var','a'),('var','a'))),{'a':0})\ncheck('array',solve(('array',('var','a'),N)),{'a':1})\ncheck('variable arity',solve(('tuple',[('var',str(i)) for i in range(N+1)])),{str(i):1 for i in range(N+1)})\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":"dbdcaf8c7ea21005c1d4a3e90184275e4a9d81ddbbe1907ae123cdb8a29a36e2","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tree):\n    def walk(t,sign):\n        kind=t[0]\n        if kind=='var': return {t[1]:sign}\n        if kind=='unused': return {}\n        if kind=='ref': children=[('var',t[1])]; signs=[sign]\n        elif kind=='mut': children=[('var',t[1]),t[2]]; signs=[sign,0]\n        elif kind=='fn': children=[t[1],t[2]]; signs=[-sign,sign]\n        elif kind=='tuple': children=t[1]; signs=[sign]*len(children)\n        elif kind=='cell': children=[t[1]]; signs=[0]\n        elif kind=='phantom': children=[t[1]]; signs=[sign]\n        elif kind=='array': children=[t[1]]; signs=[sign]\n        elif kind=='opaque': children=[('var',p) for p in t[1]]; signs=[0]*len(children)\n        else: return {}\n        out={}\n        for child,s in zip(children,signs):\n            for p,v in walk(child,s).items():\n                out[p]=v if p not in out or out[p]==v else 0\n        return out\n    return walk(tree,1)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('variable',solve(('var','a')),{'a':1})\ncheck('unused',solve(('unused','a')), {})\ncheck('shared',solve(('ref','a',('var','b'))),{'a':1,'b':1})\ncheck('mutable',solve(('mut','a',('var','b'))),{'a':1,'b':0})\ncheck('function',solve(('fn',('var','a'),('var','b'))),{'a':-1,'b':1})\ncheck('tuple',solve(('tuple',[('var','a'),('var','b')])),{'a':1,'b':1})\ncheck('cell',solve(('cell',('var','a'))),{'a':0})\ncheck('phantom',solve(('phantom',('var','a'))),{'a':1})\ncheck('opaque',solve(('opaque',['a','b'])),{'a':0,'b':0})\ncheck('both positions',solve(('fn',('var','a'),('var','a'))),{'a':0})\ncheck('array',solve(('array',('var','a'),N)),{'a':1})\ncheck('variable arity',solve(('tuple',[('var',str(i)) for i in range(N+1)])),{str(i):1 for i in range(N+1)})\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":"a1c0aadac82f1b47dd4624fe34dce0cabf2f31e95f3ad2501a6130bc28bed72d","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(tree):\n    def walk(t,sign):\n        kind=t[0]\n        if kind=='var': return {t[1]:sign}\n        if kind=='unused': return {}\n        if kind=='ref': children=[('var',t[1]),t[2]]; signs=[sign,sign]\n        elif kind=='mut': children=[('var',t[1]),t[2]]; signs=[sign,0]\n        elif kind=='fn': children=[t[1],t[2]]; signs=[-sign,sign]\n        elif kind=='tuple': children=t[1]; signs=[sign]*len(children)\n        elif kind=='cell': children=[t[1]]; signs=[0]\n        elif kind=='phantom': children=[t[1]]; signs=[sign]\n        elif kind=='array': children=[t[1]]; signs=[sign]\n        elif kind=='opaque': children=[('var',p) for p in t[1]]; signs=[0]*len(children)\n        else: return {}\n        out={}\n        for child,s in zip(children,signs):\n            for p,v in walk(child,s).items():\n                out[p]=v if p not in out or out[p]==v else 0\n        return out\n    return walk(tree,1)\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('variable',solve(('var','a')),{'a':1})\ncheck('unused',solve(('unused','a')), {})\ncheck('shared',solve(('ref','a',('var','b'))),{'a':1,'b':1})\ncheck('mutable',solve(('mut','a',('var','b'))),{'a':1,'b':0})\ncheck('function',solve(('fn',('var','a'),('var','b'))),{'a':-1,'b':1})\ncheck('tuple',solve(('tuple',[('var','a'),('var','b')])),{'a':1,'b':1})\ncheck('cell',solve(('cell',('var','a'))),{'a':0})\ncheck('phantom',solve(('phantom',('var','a'))),{'a':1})\ncheck('opaque',solve(('opaque',['a','b'])),{'a':0,'b':0})\ncheck('both positions',solve(('fn',('var','a'),('var','a'))),{'a':0})\ncheck('array',solve(('array',('var','a'),N)),{'a':1})\ncheck('variable arity',solve(('tuple',[('var',str(i)) for i in range(N+1)])),{str(i):1 for i in range(N+1)})\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":"The explicitly stated toy language is the complete scope; this is not a production compiler or a claim about Rust semantics. 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":"s3-borrow-checking-variance-inference-shared-referent","generated_at":"2026-09-29T14:44:02.533672+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A finite offline static-analysis model of ownership and borrowing; it does not execute the analyzed program.","repair":"Apply the specified transfer or inference rule at this site: if kind=='ref': children=[('var',t[1]),t[2]]; signs=[sign,sign].","root_cause":"The static analyzer mishandles shared referent: a shared reference incorrectly makes its referent lifetime invariant.","sha256":"8e796203d441d64f4b7de4399f2754dfef6c29029d6ebd4e46364cab2311b44b","title":"A shared reference incorrectly makes its referent lifetime invariant · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":44.183,"exit_code":1,"observations":[{"actual":{"a":1},"check":"variable","expected":{"a":1},"passed":true},{"actual":{},"check":"unused","expected":{},"passed":true},{"actual":{"a":1,"b":0},"check":"shared","expected":{"a":1,"b":1},"passed":false},{"actual":{"a":1,"b":0},"check":"mutable","expected":{"a":1,"b":0},"passed":true},{"actual":{"a":-1,"b":1},"check":"function","expected":{"a":-1,"b":1},"passed":true},{"actual":{"a":1,"b":1},"check":"tuple","expected":{"a":1,"b":1},"passed":true},{"actual":{"a":0},"check":"cell","expected":{"a":0},"passed":true},{"actual":{"a":1},"check":"phantom","expected":{"a":1},"passed":true},{"actual":{"a":0,"b":0},"check":"opaque","expected":{"a":0,"b":0},"passed":true},{"actual":{"a":0},"check":"both positions","expected":{"a":0},"passed":true},{"actual":{"a":1},"check":"array","expected":{"a":1},"passed":true},{"actual":{"0":1,"1":1},"check":"variable arity","expected":{"0":1,"1":1},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"variable\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"unused\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"shared\", \"actual\": {\"a\": 1, \"b\": 0}, \"expected\": {\"a\": 1, \"b\": 1}, \"passed\": false}, {\"check\": \"mutable\", \"actual\": {\"a\": 1, \"b\": 0}, \"expected\": {\"a\": 1, \"b\": 0}, \"passed\": true}, {\"check\": \"function\", \"actual\": {\"a\": -1, \"b\": 1}, \"expected\": {\"a\": -1, \"b\": 1}, \"passed\": true}, {\"check\": \"tuple\", \"actual\": {\"a\": 1, \"b\": 1}, \"expected\": {\"a\": 1, \"b\": 1}, \"passed\": true}, {\"check\": \"cell\", \"actual\": {\"a\": 0}, \"expected\": {\"a\": 0}, \"passed\": true}, {\"check\": \"phantom\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"opaque\", \"actual\": {\"a\": 0, \"b\": 0}, \"expected\": {\"a\": 0, \"b\": 0}, \"passed\": true}, {\"check\": \"both positions\", \"actual\": {\"a\": 0}, \"expected\": {\"a\": 0}, \"passed\": true}, {\"check\": \"array\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"variable arity\", \"actual\": {\"0\": 1, \"1\": 1}, \"expected\": {\"0\": 1, \"1\": 1}, \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":47.71,"exit_code":1,"observations":[{"actual":{"a":1},"check":"variable","expected":{"a":1},"passed":true},{"actual":{},"check":"unused","expected":{},"passed":true},{"actual":{"a":1},"check":"shared","expected":{"a":1,"b":1},"passed":false},{"actual":{"a":1,"b":0},"check":"mutable","expected":{"a":1,"b":0},"passed":true},{"actual":{"a":-1,"b":1},"check":"function","expected":{"a":-1,"b":1},"passed":true},{"actual":{"a":1,"b":1},"check":"tuple","expected":{"a":1,"b":1},"passed":true},{"actual":{"a":0},"check":"cell","expected":{"a":0},"passed":true},{"actual":{"a":1},"check":"phantom","expected":{"a":1},"passed":true},{"actual":{"a":0,"b":0},"check":"opaque","expected":{"a":0,"b":0},"passed":true},{"actual":{"a":0},"check":"both positions","expected":{"a":0},"passed":true},{"actual":{"a":1},"check":"array","expected":{"a":1},"passed":true},{"actual":{"0":1,"1":1},"check":"variable arity","expected":{"0":1,"1":1},"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"variable\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"unused\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"shared\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1, \"b\": 1}, \"passed\": false}, {\"check\": \"mutable\", \"actual\": {\"a\": 1, \"b\": 0}, \"expected\": {\"a\": 1, \"b\": 0}, \"passed\": true}, {\"check\": \"function\", \"actual\": {\"a\": -1, \"b\": 1}, \"expected\": {\"a\": -1, \"b\": 1}, \"passed\": true}, {\"check\": \"tuple\", \"actual\": {\"a\": 1, \"b\": 1}, \"expected\": {\"a\": 1, \"b\": 1}, \"passed\": true}, {\"check\": \"cell\", \"actual\": {\"a\": 0}, \"expected\": {\"a\": 0}, \"passed\": true}, {\"check\": \"phantom\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"opaque\", \"actual\": {\"a\": 0, \"b\": 0}, \"expected\": {\"a\": 0, \"b\": 0}, \"passed\": true}, {\"check\": \"both positions\", \"actual\": {\"a\": 0}, \"expected\": {\"a\": 0}, \"passed\": true}, {\"check\": \"array\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"variable arity\", \"actual\": {\"0\": 1, \"1\": 1}, \"expected\": {\"0\": 1, \"1\": 1}, \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":43.446,"exit_code":0,"observations":[{"actual":{"a":1},"check":"variable","expected":{"a":1},"passed":true},{"actual":{},"check":"unused","expected":{},"passed":true},{"actual":{"a":1,"b":1},"check":"shared","expected":{"a":1,"b":1},"passed":true},{"actual":{"a":1,"b":0},"check":"mutable","expected":{"a":1,"b":0},"passed":true},{"actual":{"a":-1,"b":1},"check":"function","expected":{"a":-1,"b":1},"passed":true},{"actual":{"a":1,"b":1},"check":"tuple","expected":{"a":1,"b":1},"passed":true},{"actual":{"a":0},"check":"cell","expected":{"a":0},"passed":true},{"actual":{"a":1},"check":"phantom","expected":{"a":1},"passed":true},{"actual":{"a":0,"b":0},"check":"opaque","expected":{"a":0,"b":0},"passed":true},{"actual":{"a":0},"check":"both positions","expected":{"a":0},"passed":true},{"actual":{"a":1},"check":"array","expected":{"a":1},"passed":true},{"actual":{"0":1,"1":1},"check":"variable arity","expected":{"0":1,"1":1},"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"variable\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"unused\", \"actual\": {}, \"expected\": {}, \"passed\": true}, {\"check\": \"shared\", \"actual\": {\"a\": 1, \"b\": 1}, \"expected\": {\"a\": 1, \"b\": 1}, \"passed\": true}, {\"check\": \"mutable\", \"actual\": {\"a\": 1, \"b\": 0}, \"expected\": {\"a\": 1, \"b\": 0}, \"passed\": true}, {\"check\": \"function\", \"actual\": {\"a\": -1, \"b\": 1}, \"expected\": {\"a\": -1, \"b\": 1}, \"passed\": true}, {\"check\": \"tuple\", \"actual\": {\"a\": 1, \"b\": 1}, \"expected\": {\"a\": 1, \"b\": 1}, \"passed\": true}, {\"check\": \"cell\", \"actual\": {\"a\": 0}, \"expected\": {\"a\": 0}, \"passed\": true}, {\"check\": \"phantom\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"opaque\", \"actual\": {\"a\": 0, \"b\": 0}, \"expected\": {\"a\": 0, \"b\": 0}, \"passed\": true}, {\"check\": \"both positions\", \"actual\": {\"a\": 0}, \"expected\": {\"a\": 0}, \"passed\": true}, {\"check\": \"array\", \"actual\": {\"a\": 1}, \"expected\": {\"a\": 1}, \"passed\": true}, {\"check\": \"variable arity\", \"actual\": {\"0\": 1, \"1\": 1}, \"expected\": {\"0\": 1, \"1\": 1}, \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}