FA-9036 / Undo and history / Open access
Adjacent typing undo coalescing: Deletion transactions merge as if they were adjacent typing · case 01
Deletion transactions merge as if they were adjacent typing.
ROOT CAUSE
The kind operation uses `True` where the contract requires `kind == 'insert'`.
VERIFIED REPAIR
Implement the kind operation as `kind == 'insert'`.
Unsuccessful approach: Allowing only deletion prevents normal insertion grouping.
Case contract
Only contiguous insertion edits without explicit boundary coalesce; preserve the first before-state and newest after-state; no-op input creates no history.
Why this case matters
A deterministic model of adjacent typing undo coalescing; this isolates one interface invariant without requiring a browser.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
history = list(history)
if before == after: return history
merge = bool(history) and True and previous_kind == kind and previous_caret == caret and not boundary
if merge: history[-1] = (history[-1][0], after)
else: history.append((before, after))
return history
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| noop | [['a', 'ab']] | [['a', 'ab']] | Passed |
| empty noop | [] | [] | Passed |
| delete | [['abcd', 'ab']] | [['abcd', 'abc'], ['abc', 'ab']] | Failed |
| contiguous | [['a', 'abc']] | [['a', 'abc']] | Passed |
| moved caret | [['a', 'ab'], ['ab', 'axb']] | [['a', 'ab'], ['ab', 'axb']] | Passed |
| boundary | [['a', 'ab'], ['ab', 'abc']] | [['a', 'ab'], ['ab', 'abc']] | Passed |
| empty | [['', 'a']] | [['', 'a']] | Passed |
| parameterized inserted length | [['', 'a']] | [['', 'a']] | Passed |
| repeat empty | [['', 'a']] | [['', 'a']] | Passed |
SHA-256 / 987d9bf3a722e7fcb8871b6d33eea0134f6579bda3d27e1ceceba5d29ead675a
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
history = list(history)
if before == after: return history
merge = bool(history) and kind == 'delete' and previous_kind == kind and previous_caret == caret and not boundary
if merge: history[-1] = (history[-1][0], after)
else: history.append((before, after))
return history
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| noop | [['a', 'ab']] | [['a', 'ab']] | Passed |
| empty noop | [] | [] | Passed |
| delete | [['abcd', 'ab']] | [['abcd', 'abc'], ['abc', 'ab']] | Failed |
| contiguous | [['a', 'ab'], ['ab', 'abc']] | [['a', 'abc']] | Failed |
| moved caret | [['a', 'ab'], ['ab', 'axb']] | [['a', 'ab'], ['ab', 'axb']] | Passed |
| boundary | [['a', 'ab'], ['ab', 'abc']] | [['a', 'ab'], ['ab', 'abc']] | Passed |
| empty | [['', 'a']] | [['', 'a']] | Passed |
| parameterized inserted length | [['', 'a']] | [['', 'a']] | Passed |
| repeat empty | [['', 'a']] | [['', 'a']] | Passed |
SHA-256 / e0875b533128df38f7eb1295f18d3b129e221fbd4eaa8ab92866f5557b94ca9a
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(history, before, after, previous_kind, kind, previous_caret, caret, boundary):
history = list(history)
if before == after: return history
merge = bool(history) and kind == 'insert' and previous_kind == kind and previous_caret == caret and not boundary
if merge: history[-1] = (history[-1][0], after)
else: history.append((before, after))
return history
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('noop', solve([('a','ab')], 'ab', 'ab', 'insert', 'insert', 2, 2, False), [('a', 'ab')])
check('empty noop', solve([], 'a', 'a', None, 'insert', None, 1, False), [])
check('delete', solve([('abcd','abc')], 'abc', 'ab', 'delete', 'delete', 3, 3, False), [('abcd', 'abc'), ('abc', 'ab')])
check('contiguous', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, False), [('a', 'abc')])
check('moved caret', solve([('a','ab')], 'ab', 'axb', 'insert', 'insert', 2, 1, False), [('a', 'ab'), ('ab', 'axb')])
check('boundary', solve([('a','ab')], 'ab', 'abc', 'insert', 'insert', 2, 2, True), [('a', 'ab'), ('ab', 'abc')])
check('empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
check('parameterized inserted length', solve([], '', 'a'*N, None, 'insert', None, 0, False), [('', 'a'*N)])
for repetition in range(N):
check('repeat empty', solve([], '', 'a', None, 'insert', None, 0, False), [('', 'a')])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| noop | [['a', 'ab']] | [['a', 'ab']] | Passed |
| empty noop | [] | [] | Passed |
| delete | [['abcd', 'abc'], ['abc', 'ab']] | [['abcd', 'abc'], ['abc', 'ab']] | Passed |
| contiguous | [['a', 'abc']] | [['a', 'abc']] | Passed |
| moved caret | [['a', 'ab'], ['ab', 'axb']] | [['a', 'ab'], ['ab', 'axb']] | Passed |
| boundary | [['a', 'ab'], ['ab', 'abc']] | [['a', 'ab'], ['ab', 'abc']] | Passed |
| empty | [['', 'a']] | [['', 'a']] | Passed |
| parameterized inserted length | [['', 'a']] | [['', 'a']] | Passed |
| repeat empty | [['', 'a']] | [['', 'a']] | Passed |
SHA-256 / 9040f12ffc91fc2ab35075ff16280fb5513fb66e42e9db5093b7a765e2946624
Verification & scope
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.
Observations recorded using Python 3.12.14 at 2026-09-29T14:38:26.568539+00:00.
Case digest / 7782b31174d41a448ea73c799a250316f278570f2de8cefcf9040dbbe5892434