{"abstract":"Typing at a moved caret merges with a distant edit.","category":"Undo and history","checks":9,"contract":"Only contiguous insertion edits without explicit boundary coalesce; preserve the first before-state and newest after-state; no-op input creates no history.","evaluation_group":"xi-undo-grouping","failed_approach":"Reversing equality merges only noncontiguous edits.","family":"xi-undo-grouping-caret-contiguity","id":"FA-9041","implementations":{"attempt":{"sha256":"022aa2e7dc0337d5aefbdd021a7ef5b9fcce8f4bc172b75e949643cf53f42f27","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):\n    history = list(history)\n    if before == after: return history\n    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret != caret and not boundary\n    if merge: history[-1] = (history[-1][0], after)\n    else: history.append((before, after))\n    return history\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])\ncheck('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])\ncheck('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])\ncheck('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])\ncheck('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])\ncheck('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])\ncheck('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])\ncheck('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])\nfor repetition in range(N):\n    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])\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":"8cdbc2f048079a0bd4569be01e44c44e0e5b9bdfdb36ddedb98a2fc3d6c1e825","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):\n    history = list(history)\n    if before == after: return history\n    merge = bool(history) and kind == 'insert' and previous_kind == kind and True and not boundary\n    if merge: history[-1] = (history[-1][0], after)\n    else: history.append((before, after))\n    return history\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])\ncheck('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])\ncheck('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])\ncheck('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])\ncheck('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])\ncheck('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])\ncheck('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])\ncheck('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])\nfor repetition in range(N):\n    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])\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":"9040f12ffc91fc2ab35075ff16280fb5513fb66e42e9db5093b7a765e2946624","source":"\"\"\"Failure Map reference implementation. Python standard library only.\"\"\"\nimport json\n\nN = 1\nobservations = []\ndef solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):\n    history = list(history)\n    if before == after: return history\n    merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret == caret and not boundary\n    if merge: history[-1] = (history[-1][0], after)\n    else: history.append((before, after))\n    return history\ndef check(label, actual, expected):\n    observations.append({\"check\": label, \"actual\": actual, \"expected\": expected, \"passed\": actual == expected})\ncheck('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])\ncheck('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])\ncheck('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])\ncheck('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])\ncheck('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])\ncheck('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])\ncheck('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])\ncheck('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])\nfor repetition in range(N):\n    check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])\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":"xi-undo-grouping-caret-contiguity","generated_at":"2026-09-29T14:38:26.618292+00:00","license":"CC0-1.0","python":"3.12.14","seed":1,"split":"open-access"},"relevance":"A deterministic model of adjacent typing undo coalescing; this isolates one interface invariant without requiring a browser.","repair":"Implement the caret contiguity operation as `previous_caret == caret`.","root_cause":"The caret contiguity operation uses `True` where the contract requires `previous_caret == caret`.","sha256":"e8740b0cff62f59b15a6e179ca90292a526169c5012a1539f296b15427d2be5c","title":"Adjacent typing undo coalescing: Typing at a moved caret merges with a distant edit · case 01","variant":1,"variant_policy":"Five numbered records share a model and may reuse boundary fixtures.","verification":{"attempt":{"elapsed_ms":38.097,"exit_code":1,"observations":[{"actual":[["a","ab"]],"check":"noop","expected":[["a","ab"]],"passed":true},{"actual":[],"check":"empty noop","expected":[],"passed":true},{"actual":[["abcd","abc"],["abc","ab"]],"check":"delete","expected":[["abcd","abc"],["abc","ab"]],"passed":true},{"actual":[["a","ab"],["ab","abc"]],"check":"contiguous","expected":[["a","abc"]],"passed":false},{"actual":[["a","axb"]],"check":"moved caret","expected":[["a","ab"],["ab","axb"]],"passed":false},{"actual":[["a","ab"],["ab","abc"]],"check":"boundary","expected":[["a","ab"],["ab","abc"]],"passed":true},{"actual":[["","a"]],"check":"empty","expected":[["","a"]],"passed":true},{"actual":[["","a"]],"check":"parameterized inserted length","expected":[["","a"]],"passed":true},{"actual":[["","a"]],"check":"repeat empty","expected":[["","a"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"noop\", \"actual\": [[\"a\", \"ab\"]], \"expected\": [[\"a\", \"ab\"]], \"passed\": true}, {\"check\": \"empty noop\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"delete\", \"actual\": [[\"abcd\", \"abc\"], [\"abc\", \"ab\"]], \"expected\": [[\"abcd\", \"abc\"], [\"abc\", \"ab\"]], \"passed\": true}, {\"check\": \"contiguous\", \"actual\": [[\"a\", \"ab\"], [\"ab\", \"abc\"]], \"expected\": [[\"a\", \"abc\"]], \"passed\": false}, {\"check\": \"moved caret\", \"actual\": [[\"a\", \"axb\"]], \"expected\": [[\"a\", \"ab\"], [\"ab\", \"axb\"]], \"passed\": false}, {\"check\": \"boundary\", \"actual\": [[\"a\", \"ab\"], [\"ab\", \"abc\"]], \"expected\": [[\"a\", \"ab\"], [\"ab\", \"abc\"]], \"passed\": true}, {\"check\": \"empty\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}, {\"check\": \"parameterized inserted length\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}, {\"check\": \"repeat empty\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}], \"passed\": false}\n"},"broken":{"elapsed_ms":36.878,"exit_code":1,"observations":[{"actual":[["a","ab"]],"check":"noop","expected":[["a","ab"]],"passed":true},{"actual":[],"check":"empty noop","expected":[],"passed":true},{"actual":[["abcd","abc"],["abc","ab"]],"check":"delete","expected":[["abcd","abc"],["abc","ab"]],"passed":true},{"actual":[["a","abc"]],"check":"contiguous","expected":[["a","abc"]],"passed":true},{"actual":[["a","axb"]],"check":"moved caret","expected":[["a","ab"],["ab","axb"]],"passed":false},{"actual":[["a","ab"],["ab","abc"]],"check":"boundary","expected":[["a","ab"],["ab","abc"]],"passed":true},{"actual":[["","a"]],"check":"empty","expected":[["","a"]],"passed":true},{"actual":[["","a"]],"check":"parameterized inserted length","expected":[["","a"]],"passed":true},{"actual":[["","a"]],"check":"repeat empty","expected":[["","a"]],"passed":true}],"passed":false,"stderr":"","stdout":"{\"observations\": [{\"check\": \"noop\", \"actual\": [[\"a\", \"ab\"]], \"expected\": [[\"a\", \"ab\"]], \"passed\": true}, {\"check\": \"empty noop\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"delete\", \"actual\": [[\"abcd\", \"abc\"], [\"abc\", \"ab\"]], \"expected\": [[\"abcd\", \"abc\"], [\"abc\", \"ab\"]], \"passed\": true}, {\"check\": \"contiguous\", \"actual\": [[\"a\", \"abc\"]], \"expected\": [[\"a\", \"abc\"]], \"passed\": true}, {\"check\": \"moved caret\", \"actual\": [[\"a\", \"axb\"]], \"expected\": [[\"a\", \"ab\"], [\"ab\", \"axb\"]], \"passed\": false}, {\"check\": \"boundary\", \"actual\": [[\"a\", \"ab\"], [\"ab\", \"abc\"]], \"expected\": [[\"a\", \"ab\"], [\"ab\", \"abc\"]], \"passed\": true}, {\"check\": \"empty\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}, {\"check\": \"parameterized inserted length\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}, {\"check\": \"repeat empty\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}], \"passed\": false}\n"},"fixed":{"elapsed_ms":37.693,"exit_code":0,"observations":[{"actual":[["a","ab"]],"check":"noop","expected":[["a","ab"]],"passed":true},{"actual":[],"check":"empty noop","expected":[],"passed":true},{"actual":[["abcd","abc"],["abc","ab"]],"check":"delete","expected":[["abcd","abc"],["abc","ab"]],"passed":true},{"actual":[["a","abc"]],"check":"contiguous","expected":[["a","abc"]],"passed":true},{"actual":[["a","ab"],["ab","axb"]],"check":"moved caret","expected":[["a","ab"],["ab","axb"]],"passed":true},{"actual":[["a","ab"],["ab","abc"]],"check":"boundary","expected":[["a","ab"],["ab","abc"]],"passed":true},{"actual":[["","a"]],"check":"empty","expected":[["","a"]],"passed":true},{"actual":[["","a"]],"check":"parameterized inserted length","expected":[["","a"]],"passed":true},{"actual":[["","a"]],"check":"repeat empty","expected":[["","a"]],"passed":true}],"passed":true,"stderr":"","stdout":"{\"observations\": [{\"check\": \"noop\", \"actual\": [[\"a\", \"ab\"]], \"expected\": [[\"a\", \"ab\"]], \"passed\": true}, {\"check\": \"empty noop\", \"actual\": [], \"expected\": [], \"passed\": true}, {\"check\": \"delete\", \"actual\": [[\"abcd\", \"abc\"], [\"abc\", \"ab\"]], \"expected\": [[\"abcd\", \"abc\"], [\"abc\", \"ab\"]], \"passed\": true}, {\"check\": \"contiguous\", \"actual\": [[\"a\", \"abc\"]], \"expected\": [[\"a\", \"abc\"]], \"passed\": true}, {\"check\": \"moved caret\", \"actual\": [[\"a\", \"ab\"], [\"ab\", \"axb\"]], \"expected\": [[\"a\", \"ab\"], [\"ab\", \"axb\"]], \"passed\": true}, {\"check\": \"boundary\", \"actual\": [[\"a\", \"ab\"], [\"ab\", \"abc\"]], \"expected\": [[\"a\", \"ab\"], [\"ab\", \"abc\"]], \"passed\": true}, {\"check\": \"empty\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}, {\"check\": \"parameterized inserted length\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}, {\"check\": \"repeat empty\", \"actual\": [[\"\", \"a\"]], \"expected\": [[\"\", \"a\"]], \"passed\": true}], \"passed\": true}\n"}},"verified":true,"visibility":"public"}