broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[1:]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)
                    if number<=0x10ffff and not 0xd800<=number<=0xdfff: out.append(number)
                    else: invalid+=1
                radix=None; digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=""
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)
                    if number<=0x10ffff and not 0xd800<=number<=0xdfff: out.append(number)
                    else: invalid+=1
                radix=None; digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

prompt:
The event trace violates the buffer backspace rule and produces incorrect keyboard state or command output.

Events [kind,value]. Begin with radix 10 or16 resets digit buffer and activates. Digit is one ASCII hexadecimal character admitted only if below radix and fewer than6digits; rejection increments invalid count. Backspace removes last buffered digit. Commit with digits emits the integer Unicode scalar value if <=0x10ffff and outside surrogate range, else rejects; commit always closes and clears. Cancel closes without committing. Text outside mode appends as literal string. Return chunks, active radix or None, digits and invalid count. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[:-1]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,16)
                    if number<=0x10ffff and not 0xd800<=number<=0xdfff: out.append(number)
                    else: invalid+=1
                radix=None; digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

meaning: Fixture-count band, not measured model difficulty

deps: stdlib

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[:-1]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)+1
                    if number<=0x10ffff and not 0xd800<=number<=0xdfff: out.append(number)
                    else: invalid+=1
                radix=None; digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

prompt:
The event trace violates the commit radix rule and produces incorrect keyboard state or command output.

Events [kind,value]. Begin with radix 10 or16 resets digit buffer and activates. Digit is one ASCII hexadecimal character admitted only if below radix and fewer than6digits; rejection increments invalid count. Backspace removes last buffered digit. Commit with digits emits the integer Unicode scalar value if <=0x10ffff and outside surrogate range, else rejects; commit always closes and clears. Cancel closes without committing. Text outside mode appends as literal string. Return chunks, active radix or None, digits and invalid count. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[:-1]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)
                    if number<0x10ffff and not 0xd800<=number<=0xdfff: out.append(number)
                    else: invalid+=1
                radix=None; digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[:-1]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)
                    if number<=0xffff and not 0xd800<=number<=0xdfff: out.append(number)
                    else: invalid+=1
                radix=None; digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

prompt:
The event trace violates the scalar upper rule and produces incorrect keyboard state or command output.

Events [kind,value]. Begin with radix 10 or16 resets digit buffer and activates. Digit is one ASCII hexadecimal character admitted only if below radix and fewer than6digits; rejection increments invalid count. Backspace removes last buffered digit. Commit with digits emits the integer Unicode scalar value if <=0x10ffff and outside surrogate range, else rejects; commit always closes and clears. Cancel closes without committing. Text outside mode appends as literal string. Return chunks, active radix or None, digits and invalid count. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[:-1]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)
                    if number<=0x10ffff and not 0xd800<number<0xdfff: out.append(number)
                    else: invalid+=1
                radix=None; digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[:-1]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)
                    if number<=0x10ffff and not 0xd800<=number<=0xdbff: out.append(number)
                    else: invalid+=1
                radix=None; digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

prompt:
The event trace violates the scalar surrogates rule and produces incorrect keyboard state or command output.

Events [kind,value]. Begin with radix 10 or16 resets digit buffer and activates. Digit is one ASCII hexadecimal character admitted only if below radix and fewer than6digits; rejection increments invalid count. Backspace removes last buffered digit. Commit with digits emits the integer Unicode scalar value if <=0x10ffff and outside surrogate range, else rejects; commit always closes and clears. Cancel closes without committing. Text outside mode appends as literal string. Return chunks, active radix or None, digits and invalid count. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[:-1]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)
                    if number<=0x10ffff and not 0xd800<=number<=0xdfff: out.append(number)
                    else: invalid+=1
                radix=None
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        radix=None; digits=''; out=[]; invalid=0
        for kind,value in c:
            if kind=='begin' and value in (10,16):
                radix=value; digits=''
            elif kind=='digit' and radix is not None:
                char=str(value).lower()
                valid=len(char)==1 and char in '0123456789abcdef'
                if valid and int(char,16)<radix and len(digits)<6:
                    digits+=char
                else: invalid+=1
            elif kind=='backspace' and radix is not None: digits=digits[:-1]
            elif kind=='commit' and radix is not None:
                if digits:
                    number=int(digits,radix)
                    if number<=0x10ffff and not 0xd800<=number<=0xdfff: out.append(number)
                    else: invalid+=1
                digits=''
            elif kind=='cancel': radix=None; digits=''
            elif kind=='text' and radix is None: out.append(value)
        return [out,radix,digits,invalid]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('numeric-character-entry scenario 0', solve([[]] * N), [[[], None, '', 0]] * N)
check('numeric-character-entry scenario 1', solve([[['begin', 16], ['digit', '4'], ['digit', '1'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 2', solve([[['begin', 10], ['digit', '6'], ['digit', '5'], ['commit', '']]] * N), [[[65], None, '', 0]] * N)
check('numeric-character-entry scenario 3', solve([[['begin', 16], ['digit', 'a'], ['digit', 'F']]] * N), [[[], 16, 'af', 0]] * N)
check('numeric-character-entry scenario 4', solve([[['begin', 10], ['digit', 'A']]] * N), [[[], 10, '', 1]] * N)
check('numeric-character-entry scenario 5', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['digit', '4'], ['digit', '5'], ['digit', '6'], ['digit', '7']]] * N), [[[], 16, '123456', 1]] * N)
check('numeric-character-entry scenario 6', solve([[['begin', 16], ['digit', '1'], ['digit', '2'], ['digit', '3'], ['backspace', '']]] * N), [[[], 16, '12', 0]] * N)
check('numeric-character-entry scenario 7', solve([[['begin', 16], ['digit', '1'], ['digit', '0'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[1114111], None, '', 0]] * N)
check('numeric-character-entry scenario 8', solve([[['begin', 16], ['digit', 'd'], ['digit', '8'], ['digit', '0'], ['digit', '0'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 9', solve([[['begin', 16], ['digit', 'd'], ['digit', 'f'], ['digit', 'f'], ['digit', 'f'], ['commit', '']]] * N), [[[], None, '', 1]] * N)
check('numeric-character-entry scenario 10', solve([[['begin', 16], ['digit', '4'], ['begin', 10]]] * N), [[[], 10, '', 0]] * N)
check('numeric-character-entry scenario 11', solve([[['begin', 10], ['commit', ''], ['text', 'ok']]] * N), [[['ok'], None, '', 0]] * N)
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)

prompt:
The event trace violates the commit close rule and produces incorrect keyboard state or command output.

Events [kind,value]. Begin with radix 10 or16 resets digit buffer and activates. Digit is one ASCII hexadecimal character admitted only if below radix and fewer than6digits; rejection increments invalid count. Backspace removes last buffered digit. Commit with digits emits the integer Unicode scalar value if <=0x10ffff and outside surrogate range, else rejects; commit always closes and clears. Cancel closes without committing. Text outside mode appends as literal string. Return chunks, active radix or None, digits and invalid count. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,document[a:b]]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,'']
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the initial preedit rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pass
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None; revision+=1
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the cancel preedit rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,0,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision+1,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the capture revision rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]+=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=pending[3]
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the preedit update rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the external revision rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base<=revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base!=revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the conflict compare rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document+=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the external payload rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision=1
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=len(preedit)
                else: conflicts+=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the commit revision rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts=1
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=revision-base
                pending=None
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the conflict count rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=pending
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

source:
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(cases):
    def run(c):
        document,revision,events=c
        pending=None; conflicts=0
        for kind,a,b,text in events:
            if kind=='begin': pending=[a,b,revision,text]
            elif kind=='update' and pending is not None: pending[3]=text
            elif kind=='external': document=text; revision+=1
            elif kind=='commit' and pending is not None:
                lo,hi,base,preedit=pending
                if base==revision:
                    document=document[:lo]+preedit+document[hi:]
                    revision+=1
                else: conflicts+=1
                pending=[lo,hi,revision,preedit]
            elif kind=='cancel': pending=None
        return [document,revision,pending,conflicts]
    return [run(c) for c in cases]
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
check('composition-revision scenario 0', solve([['abcd', 4, []]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 1', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['commit', 0, 0, '']]]] * N), [['aXd', 5, None, 0]] * N)
check('composition-revision scenario 2', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['update', 0, 0, 'YZ'], ['commit', 0, 0, '']]]] * N), [['aYZd', 5, None, 0]] * N)
check('composition-revision scenario 3', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'new'], ['commit', 0, 0, '']]]] * N), [['new', 5, None, 1]] * N)
check('composition-revision scenario 4', solve([['abcd', 4, [['external', 0, 0, 'one'], ['external', 0, 0, 'two']]]] * N), [['two', 6, None, 0]] * N)
check('composition-revision scenario 5', solve([['abcd', 4, [['begin', 1, 3, 'X'], ['external', 0, 0, 'one'], ['external', 0, 0, 'two'], ['commit', 0, 0, ''], ['begin', 0, 1, 'Z'], ['external', 0, 0, 'three'], ['commit', 0, 0, '']]]] * N), [['three', 7, None, 2]] * N)
check('composition-revision scenario 6', solve([['abcd', 4, [['begin', 0, 0, ''], ['cancel', 0, 0, '']]]] * N), [['abcd', 4, None, 0]] * N)
check('composition-revision scenario 7', solve([['abcd', 0, [['begin', 1, 3, 'X'], ['commit', 0, 0, ''], ['commit', 0, 0, '']]]] * N), [['aXd', 1, None, 0]] * N)
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)

prompt:
The event trace violates the close pending rule and produces incorrect keyboard state or command output.

Case [document,revision,events]. Events [kind,a,b,text]. Begin captures valid range [a,b) and current revision with preedit text; update replaces pending preedit; external replaces entire document and increments revision. Commit applies pending replacement only if captured revision still equals current, otherwise counts stale conflict; either path closes pending. Cancel discards pending. Return document, revision, pending [lo,hi,base,text] or None, conflicts. Inputs are finite ordered event traces; return the stated deterministic state. Batch entries are independent. N varies the number of independent input transactions.

split: open-access