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

N = 1
observations = []
def solve(initial, frames):
    locals_ = list(initial)
    out = []
    offset = 0
    for idx, fr in enumerate(frames):
        t = fr[0]
        stack = []
        if t <= 63:
            delta = t
        elif t <= 127:
            delta = t - 64
            stack = [fr[1]]
        elif t <= 247:
            return ['ClassFormatError', idx]
        elif t == 247:
            delta = fr[1]
            stack = [fr[2]]
        elif t <= 250:
            delta = fr[1]
            k = 251 - t
            if k > len(locals_):
                return ['ClassFormatError', idx]
            locals_ = locals_[:len(locals_) - k]
        elif t == 251:
            delta = fr[1]
        elif t <= 254:
            delta = fr[1]
            locals_ = locals_ + list(fr[2:2 + t - 251])
        else:
            delta = fr[1]
            locals_ = list(fr[2])
            stack = list(fr[3])
        offset = delta if idx == 0 else offset + delta + 1
        out.append([offset, locals_, stack])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [13, ['I', 'Object'], ['I']],
    [17, ['I', 'Object', 'F'], []],
    [20, ['I'], []],
    [321, ['I'], []],
    [323, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[11], [3]]),
   [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[65, 'Object'], [64, 'I']]),
   [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 5, 'Object']]),
   [[5, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
  ('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [2, ['I', 'Object', 'I', 'I', 'F'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
   [[1, ['Object'], []], [4, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [14, ['I', 'Object'], ['I']],
    [18, ['I', 'Object', 'F'], []],
    [21, ['I'], []],
    [322, ['I'], []],
    [324, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[12], [3]]),
   [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[66, 'Object'], [64, 'I']]),
   [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 6, 'Object']]),
   [[6, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
  ('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
   [[2, ['Object'], []], [5, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [15, ['I', 'Object'], ['I']],
    [19, ['I', 'Object', 'F'], []],
    [22, ['I'], []],
    [323, ['I'], []],
    [325, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[13], [3]]),
   [[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[67, 'Object'], [64, 'I']]),
   [[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 7, 'Object']]),
   [[7, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
  ('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
   [[3, ['Object'], []], [6, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [16, ['I', 'Object'], ['I']],
    [20, ['I', 'Object', 'F'], []],
    [23, ['I'], []],
    [324, ['I'], []],
    [326, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[14], [3]]),
   [[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[68, 'Object'], [64, 'I']]),
   [[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 8, 'Object']]),
   [[8, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
  ('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
   [[4, ['Object'], []], [7, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [17, ['I', 'Object'], ['I']],
    [21, ['I', 'Object', 'F'], []],
    [24, ['I'], []],
    [325, ['I'], []],
    [327, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[15], [3]]),
   [[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[69, 'Object'], [64, 'I']]),
   [[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 9, 'Object']]),
   [[9, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
  ('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []],
    [7, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
   [[5, ['Object'], []], [8, ['Object'], []]])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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(initial, frames):
    locals_ = list(initial)
    out = []
    offset = 0
    for idx, fr in enumerate(frames):
        t = fr[0]
        stack = []
        if t <= 63:
            delta = t
        elif t <= 127:
            delta = t - 64
            stack = [fr[1]]
        elif t < 246:
            return ['ClassFormatError', idx]
        elif t == 247:
            delta = fr[1]
            stack = [fr[2]]
        elif t <= 250:
            delta = fr[1]
            k = 251 - t
            if k > len(locals_):
                return ['ClassFormatError', idx]
            locals_ = locals_[:len(locals_) - k]
        elif t == 251:
            delta = fr[1]
        elif t <= 254:
            delta = fr[1]
            locals_ = locals_ + list(fr[2:2 + t - 251])
        else:
            delta = fr[1]
            locals_ = list(fr[2])
            stack = list(fr[3])
        offset = delta if idx == 0 else offset + delta + 1
        out.append([offset, locals_, stack])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [13, ['I', 'Object'], ['I']],
    [17, ['I', 'Object', 'F'], []],
    [20, ['I'], []],
    [321, ['I'], []],
    [323, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[11], [3]]),
   [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[65, 'Object'], [64, 'I']]),
   [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 5, 'Object']]),
   [[5, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
  ('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [2, ['I', 'Object', 'I', 'I', 'F'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
   [[1, ['Object'], []], [4, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [14, ['I', 'Object'], ['I']],
    [18, ['I', 'Object', 'F'], []],
    [21, ['I'], []],
    [322, ['I'], []],
    [324, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[12], [3]]),
   [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[66, 'Object'], [64, 'I']]),
   [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 6, 'Object']]),
   [[6, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
  ('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
   [[2, ['Object'], []], [5, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [15, ['I', 'Object'], ['I']],
    [19, ['I', 'Object', 'F'], []],
    [22, ['I'], []],
    [323, ['I'], []],
    [325, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[13], [3]]),
   [[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[67, 'Object'], [64, 'I']]),
   [[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 7, 'Object']]),
   [[7, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
  ('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
   [[3, ['Object'], []], [6, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [16, ['I', 'Object'], ['I']],
    [20, ['I', 'Object', 'F'], []],
    [23, ['I'], []],
    [324, ['I'], []],
    [326, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[14], [3]]),
   [[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[68, 'Object'], [64, 'I']]),
   [[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 8, 'Object']]),
   [[8, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
  ('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
   [[4, ['Object'], []], [7, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [17, ['I', 'Object'], ['I']],
    [21, ['I', 'Object', 'F'], []],
    [24, ['I'], []],
    [325, ['I'], []],
    [327, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[15], [3]]),
   [[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[69, 'Object'], [64, 'I']]),
   [[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 9, 'Object']]),
   [[9, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
  ('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []],
    [7, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
   [[5, ['Object'], []], [8, ['Object'], []]])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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:
Methods using frame type 247 fail verification.

Expand compressed stack map frames. Types: 0-63 same (delta = type), 64-127 same_locals_1_stack_item (delta = type - 64, one stack item), 128-246 reserved (["ClassFormatError", index]), 247 extended one item [247, delta, item], 248-250 chop 251-type locals [t, delta], 251 same extended [251, delta], 252-254 append type-251 locals [t, delta, items...], 255 full [255, delta, locals, stack]. The first frame's offset is its delta; each later offset is previous + delta + 1. Chopping more locals than exist is an error. Return [offset, locals, stack] for every frame; each frame's locals are an independent snapshot.

split: open-access


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

N = 1
observations = []
def solve(initial, frames):
    locals_ = list(initial)
    out = []
    offset = 0
    for idx, fr in enumerate(frames):
        t = fr[0]
        stack = []
        if t <= 63:
            delta = t
        elif t <= 127:
            delta = t - 64
            stack = [fr[1]]
        elif t < 247:
            return ['ClassFormatError', idx]
        elif t == 247:
            delta = fr[1]
            stack = [fr[2]]
        elif t <= 250:
            delta = fr[1]
            k = t - 247
            if k > len(locals_):
                return ['ClassFormatError', idx]
            locals_ = locals_[:len(locals_) - k]
        elif t == 251:
            delta = fr[1]
        elif t <= 254:
            delta = fr[1]
            locals_ = locals_ + list(fr[2:2 + t - 251])
        else:
            delta = fr[1]
            locals_ = list(fr[2])
            stack = list(fr[3])
        offset = delta if idx == 0 else offset + delta + 1
        out.append([offset, locals_, stack])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [13, ['I', 'Object'], ['I']],
    [17, ['I', 'Object', 'F'], []],
    [20, ['I'], []],
    [321, ['I'], []],
    [323, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[11], [3]]),
   [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[65, 'Object'], [64, 'I']]),
   [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 5, 'Object']]),
   [[5, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
  ('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [2, ['I', 'Object', 'I', 'I', 'F'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
   [[1, ['Object'], []], [4, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [14, ['I', 'Object'], ['I']],
    [18, ['I', 'Object', 'F'], []],
    [21, ['I'], []],
    [322, ['I'], []],
    [324, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[12], [3]]),
   [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[66, 'Object'], [64, 'I']]),
   [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 6, 'Object']]),
   [[6, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
  ('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
   [[2, ['Object'], []], [5, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [15, ['I', 'Object'], ['I']],
    [19, ['I', 'Object', 'F'], []],
    [22, ['I'], []],
    [323, ['I'], []],
    [325, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[13], [3]]),
   [[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[67, 'Object'], [64, 'I']]),
   [[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 7, 'Object']]),
   [[7, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
  ('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
   [[3, ['Object'], []], [6, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [16, ['I', 'Object'], ['I']],
    [20, ['I', 'Object', 'F'], []],
    [23, ['I'], []],
    [324, ['I'], []],
    [326, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[14], [3]]),
   [[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[68, 'Object'], [64, 'I']]),
   [[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 8, 'Object']]),
   [[8, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
  ('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
   [[4, ['Object'], []], [7, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [17, ['I', 'Object'], ['I']],
    [21, ['I', 'Object', 'F'], []],
    [24, ['I'], []],
    [325, ['I'], []],
    [327, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[15], [3]]),
   [[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[69, 'Object'], [64, 'I']]),
   [[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 9, 'Object']]),
   [[9, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
  ('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []],
    [7, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
   [[5, ['Object'], []], [8, ['Object'], []]])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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(initial, frames):
    locals_ = list(initial)
    out = []
    offset = 0
    for idx, fr in enumerate(frames):
        t = fr[0]
        stack = []
        if t <= 63:
            delta = t
        elif t <= 127:
            delta = t - 64
            stack = [fr[1]]
        elif t < 247:
            return ['ClassFormatError', idx]
        elif t == 247:
            delta = fr[1]
            stack = [fr[2]]
        elif t <= 250:
            delta = fr[1]
            k = 250 - t
            if k > len(locals_):
                return ['ClassFormatError', idx]
            locals_ = locals_[:len(locals_) - k]
        elif t == 251:
            delta = fr[1]
        elif t <= 254:
            delta = fr[1]
            locals_ = locals_ + list(fr[2:2 + t - 251])
        else:
            delta = fr[1]
            locals_ = list(fr[2])
            stack = list(fr[3])
        offset = delta if idx == 0 else offset + delta + 1
        out.append([offset, locals_, stack])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [13, ['I', 'Object'], ['I']],
    [17, ['I', 'Object', 'F'], []],
    [20, ['I'], []],
    [321, ['I'], []],
    [323, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[11], [3]]),
   [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[65, 'Object'], [64, 'I']]),
   [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 5, 'Object']]),
   [[5, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
  ('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [2, ['I', 'Object', 'I', 'I', 'F'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
   [[1, ['Object'], []], [4, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [14, ['I', 'Object'], ['I']],
    [18, ['I', 'Object', 'F'], []],
    [21, ['I'], []],
    [322, ['I'], []],
    [324, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[12], [3]]),
   [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[66, 'Object'], [64, 'I']]),
   [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 6, 'Object']]),
   [[6, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
  ('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
   [[2, ['Object'], []], [5, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [15, ['I', 'Object'], ['I']],
    [19, ['I', 'Object', 'F'], []],
    [22, ['I'], []],
    [323, ['I'], []],
    [325, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[13], [3]]),
   [[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[67, 'Object'], [64, 'I']]),
   [[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 7, 'Object']]),
   [[7, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
  ('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
   [[3, ['Object'], []], [6, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [16, ['I', 'Object'], ['I']],
    [20, ['I', 'Object', 'F'], []],
    [23, ['I'], []],
    [324, ['I'], []],
    [326, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[14], [3]]),
   [[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[68, 'Object'], [64, 'I']]),
   [[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 8, 'Object']]),
   [[8, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
  ('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
   [[4, ['Object'], []], [7, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [17, ['I', 'Object'], ['I']],
    [21, ['I', 'Object', 'F'], []],
    [24, ['I'], []],
    [325, ['I'], []],
    [327, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[15], [3]]),
   [[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[69, 'Object'], [64, 'I']]),
   [[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 9, 'Object']]),
   [[9, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
  ('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []],
    [7, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
   [[5, ['Object'], []], [8, ['Object'], []]])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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:
Type 248 removes one local instead of three and 250 removes three instead of one.

Expand compressed stack map frames. Types: 0-63 same (delta = type), 64-127 same_locals_1_stack_item (delta = type - 64, one stack item), 128-246 reserved (["ClassFormatError", index]), 247 extended one item [247, delta, item], 248-250 chop 251-type locals [t, delta], 251 same extended [251, delta], 252-254 append type-251 locals [t, delta, items...], 255 full [255, delta, locals, stack]. The first frame's offset is its delta; each later offset is previous + delta + 1. Chopping more locals than exist is an error. Return [offset, locals, stack] for every frame; each frame's locals are an independent snapshot.

split: open-access


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

N = 1
observations = []
def solve(initial, frames):
    locals_ = list(initial)
    out = []
    offset = 0
    for idx, fr in enumerate(frames):
        t = fr[0]
        stack = []
        if t <= 63:
            delta = t
        elif t <= 127:
            delta = t - 64
            stack = [fr[1]]
        elif t < 247:
            return ['ClassFormatError', idx]
        elif t == 247:
            delta = fr[1]
            stack = [fr[2]]
        elif t <= 250:
            delta = fr[1]
            k = 251 - t
            if k > len(locals_):
                return ['ClassFormatError', idx]
            locals_ = locals_[:len(locals_) - k]
        elif t == 251:
            delta = fr[1]
        elif t <= 254:
            delta = fr[1]
            locals_.extend(fr[2:2 + t - 251])
        else:
            delta = fr[1]
            locals_ = list(fr[2])
            stack = list(fr[3])
        offset = delta if idx == 0 else offset + delta + 1
        out.append([offset, locals_, stack])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [13, ['I', 'Object'], ['I']],
    [17, ['I', 'Object', 'F'], []],
    [20, ['I'], []],
    [321, ['I'], []],
    [323, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[11], [3]]),
   [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[65, 'Object'], [64, 'I']]),
   [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 5, 'Object']]),
   [[5, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
  ('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [2, ['I', 'Object', 'I', 'I', 'F'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
   [[1, ['Object'], []], [4, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [14, ['I', 'Object'], ['I']],
    [18, ['I', 'Object', 'F'], []],
    [21, ['I'], []],
    [322, ['I'], []],
    [324, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[12], [3]]),
   [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[66, 'Object'], [64, 'I']]),
   [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 6, 'Object']]),
   [[6, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
  ('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
   [[2, ['Object'], []], [5, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [15, ['I', 'Object'], ['I']],
    [19, ['I', 'Object', 'F'], []],
    [22, ['I'], []],
    [323, ['I'], []],
    [325, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[13], [3]]),
   [[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[67, 'Object'], [64, 'I']]),
   [[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 7, 'Object']]),
   [[7, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
  ('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
   [[3, ['Object'], []], [6, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [16, ['I', 'Object'], ['I']],
    [20, ['I', 'Object', 'F'], []],
    [23, ['I'], []],
    [324, ['I'], []],
    [326, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[14], [3]]),
   [[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[68, 'Object'], [64, 'I']]),
   [[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 8, 'Object']]),
   [[8, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
  ('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
   [[4, ['Object'], []], [7, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [17, ['I', 'Object'], ['I']],
    [21, ['I', 'Object', 'F'], []],
    [24, ['I'], []],
    [325, ['I'], []],
    [327, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[15], [3]]),
   [[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[69, 'Object'], [64, 'I']]),
   [[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 9, 'Object']]),
   [[9, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
  ('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []],
    [7, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
   [[5, ['Object'], []], [8, ['Object'], []]])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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(initial, frames):
    locals_ = list(initial)
    out = []
    offset = 0
    for idx, fr in enumerate(frames):
        t = fr[0]
        stack = []
        if t <= 63:
            delta = t
        elif t <= 127:
            delta = t - 64
            stack = [fr[1]]
        elif t < 247:
            return ['ClassFormatError', idx]
        elif t == 247:
            delta = fr[1]
            stack = [fr[2]]
        elif t <= 250:
            delta = fr[1]
            k = 251 - t
            if k > len(locals_):
                return ['ClassFormatError', idx]
            locals_ = locals_[:len(locals_) - k]
        elif t == 251:
            delta = fr[1]
        elif t <= 254:
            delta = fr[1]
            locals_ += fr[2:2 + t - 251]
        else:
            delta = fr[1]
            locals_ = list(fr[2])
            stack = list(fr[3])
        offset = delta if idx == 0 else offset + delta + 1
        out.append([offset, locals_, stack])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [13, ['I', 'Object'], ['I']],
    [17, ['I', 'Object', 'F'], []],
    [20, ['I'], []],
    [321, ['I'], []],
    [323, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[11], [3]]),
   [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[65, 'Object'], [64, 'I']]),
   [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 5, 'Object']]),
   [[5, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
  ('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [2, ['I', 'Object', 'I', 'I', 'F'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
   [[1, ['Object'], []], [4, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [14, ['I', 'Object'], ['I']],
    [18, ['I', 'Object', 'F'], []],
    [21, ['I'], []],
    [322, ['I'], []],
    [324, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[12], [3]]),
   [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[66, 'Object'], [64, 'I']]),
   [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 6, 'Object']]),
   [[6, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
  ('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
   [[2, ['Object'], []], [5, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [15, ['I', 'Object'], ['I']],
    [19, ['I', 'Object', 'F'], []],
    [22, ['I'], []],
    [323, ['I'], []],
    [325, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[13], [3]]),
   [[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[67, 'Object'], [64, 'I']]),
   [[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 7, 'Object']]),
   [[7, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
  ('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
   [[3, ['Object'], []], [6, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [16, ['I', 'Object'], ['I']],
    [20, ['I', 'Object', 'F'], []],
    [23, ['I'], []],
    [324, ['I'], []],
    [326, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[14], [3]]),
   [[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[68, 'Object'], [64, 'I']]),
   [[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 8, 'Object']]),
   [[8, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
  ('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
   [[4, ['Object'], []], [7, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [17, ['I', 'Object'], ['I']],
    [21, ['I', 'Object', 'F'], []],
    [24, ['I'], []],
    [325, ['I'], []],
    [327, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[15], [3]]),
   [[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[69, 'Object'], [64, 'I']]),
   [[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 9, 'Object']]),
   [[9, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
  ('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []],
    [7, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
   [[5, ['Object'], []], [8, ['Object'], []]])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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:
Frames recorded before an append frame suddenly list the appended locals too.

Expand compressed stack map frames. Types: 0-63 same (delta = type), 64-127 same_locals_1_stack_item (delta = type - 64, one stack item), 128-246 reserved (["ClassFormatError", index]), 247 extended one item [247, delta, item], 248-250 chop 251-type locals [t, delta], 251 same extended [251, delta], 252-254 append type-251 locals [t, delta, items...], 255 full [255, delta, locals, stack]. The first frame's offset is its delta; each later offset is previous + delta + 1. Chopping more locals than exist is an error. Return [offset, locals, stack] for every frame; each frame's locals are an independent snapshot.

split: open-access


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

N = 1
observations = []
def solve(initial, frames):
    locals_ = list(initial)
    out = []
    offset = 0
    for idx, fr in enumerate(frames):
        t = fr[0]
        stack = []
        if t <= 63:
            delta = t
        elif t <= 127:
            delta = t - 64
            stack = [fr[1]]
        elif t < 247:
            return ['ClassFormatError', idx]
        elif t == 247:
            delta = fr[1]
            stack = [fr[2]]
        elif t <= 250:
            delta = fr[1]
            k = 251 - t
            if k > len(locals_):
                return ['ClassFormatError', idx]
            locals_ = locals_[:len(locals_) - k]
        elif t == 251:
            delta = fr[1]
        elif t <= 254:
            delta = fr[1]
            locals_ = locals_ + list(fr[2:2 + t - 252])
        else:
            delta = fr[1]
            locals_ = list(fr[2])
            stack = list(fr[3])
        offset = delta if idx == 0 else offset + delta + 1
        out.append([offset, locals_, stack])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [13, ['I', 'Object'], ['I']],
    [17, ['I', 'Object', 'F'], []],
    [20, ['I'], []],
    [321, ['I'], []],
    [323, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[11], [3]]),
   [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[65, 'Object'], [64, 'I']]),
   [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 5, 'Object']]),
   [[5, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
  ('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [2, ['I', 'Object', 'I', 'I', 'F'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
   [[1, ['Object'], []], [4, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [14, ['I', 'Object'], ['I']],
    [18, ['I', 'Object', 'F'], []],
    [21, ['I'], []],
    [322, ['I'], []],
    [324, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[12], [3]]),
   [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[66, 'Object'], [64, 'I']]),
   [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 6, 'Object']]),
   [[6, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
  ('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
   [[2, ['Object'], []], [5, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [15, ['I', 'Object'], ['I']],
    [19, ['I', 'Object', 'F'], []],
    [22, ['I'], []],
    [323, ['I'], []],
    [325, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[13], [3]]),
   [[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[67, 'Object'], [64, 'I']]),
   [[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 7, 'Object']]),
   [[7, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
  ('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
   [[3, ['Object'], []], [6, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [16, ['I', 'Object'], ['I']],
    [20, ['I', 'Object', 'F'], []],
    [23, ['I'], []],
    [324, ['I'], []],
    [326, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[14], [3]]),
   [[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[68, 'Object'], [64, 'I']]),
   [[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 8, 'Object']]),
   [[8, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
  ('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
   [[4, ['Object'], []], [7, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [17, ['I', 'Object'], ['I']],
    [21, ['I', 'Object', 'F'], []],
    [24, ['I'], []],
    [325, ['I'], []],
    [327, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[15], [3]]),
   [[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[69, 'Object'], [64, 'I']]),
   [[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 9, 'Object']]),
   [[9, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
  ('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []],
    [7, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
   [[5, ['Object'], []], [8, ['Object'], []]])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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(initial, frames):
    locals_ = list(initial)
    out = []
    offset = 0
    for idx, fr in enumerate(frames):
        t = fr[0]
        stack = []
        if t <= 63:
            delta = t
        elif t <= 127:
            delta = t - 64
            stack = [fr[1]]
        elif t < 247:
            return ['ClassFormatError', idx]
        elif t == 247:
            delta = fr[1]
            stack = [fr[2]]
        elif t <= 250:
            delta = fr[1]
            k = 251 - t
            if k > len(locals_):
                return ['ClassFormatError', idx]
            locals_ = locals_[:len(locals_) - k]
        elif t == 251:
            delta = fr[1]
        elif t <= 254:
            delta = fr[1]
            locals_ = locals_ + list(fr[2:2 + 254 - t])
        else:
            delta = fr[1]
            locals_ = list(fr[2])
            stack = list(fr[3])
        offset = delta if idx == 0 else offset + delta + 1
        out.append([offset, locals_, stack])
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [71, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [13, ['I', 'Object'], ['I']],
    [17, ['I', 'Object', 'F'], []],
    [20, ['I'], []],
    [321, ['I'], []],
    [323, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[11], [3]]),
   [[11, ['I', 'Object'], []], [15, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[65, 'Object'], [64, 'I']]),
   [[1, ['I', 'Object'], ['Object']], [2, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 5, 'Object']]),
   [[5, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 1], [251, 0]]), [[1, [], []], [2, [], []]]),
  ('chop more locals than exist', ([], [[250, 1]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 1, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [2, ['I', 'Object', 'I', 'I', 'F'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 1, ['Object'], []], [2]]),
   [[1, ['Object'], []], [4, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [72, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [14, ['I', 'Object'], ['I']],
    [18, ['I', 'Object', 'F'], []],
    [21, ['I'], []],
    [322, ['I'], []],
    [324, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[12], [3]]),
   [[12, ['I', 'Object'], []], [16, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[66, 'Object'], [64, 'I']]),
   [[2, ['I', 'Object'], ['Object']], [3, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 6, 'Object']]),
   [[6, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 2], [251, 0]]), [[2, [], []], [3, [], []]]),
  ('chop more locals than exist', ([], [[250, 2]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 2, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [3, ['I', 'Object', 'I', 'I', 'F'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 2, ['Object'], []], [2]]),
   [[2, ['Object'], []], [5, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [73, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [15, ['I', 'Object'], ['I']],
    [19, ['I', 'Object', 'F'], []],
    [22, ['I'], []],
    [323, ['I'], []],
    [325, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[13], [3]]),
   [[13, ['I', 'Object'], []], [17, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[67, 'Object'], [64, 'I']]),
   [[3, ['I', 'Object'], ['Object']], [4, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 7, 'Object']]),
   [[7, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 3], [251, 0]]), [[3, [], []], [4, [], []]]),
  ('chop more locals than exist', ([], [[250, 3]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 3, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [4, ['I', 'Object', 'I', 'I', 'F'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 3, ['Object'], []], [2]]),
   [[3, ['Object'], []], [6, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [74, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [16, ['I', 'Object'], ['I']],
    [20, ['I', 'Object', 'F'], []],
    [23, ['I'], []],
    [324, ['I'], []],
    [326, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[14], [3]]),
   [[14, ['I', 'Object'], []], [18, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[68, 'Object'], [64, 'I']]),
   [[4, ['I', 'Object'], ['Object']], [5, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 8, 'Object']]),
   [[8, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 4], [251, 0]]), [[4, [], []], [5, [], []]]),
  ('chop more locals than exist', ([], [[250, 4]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 4, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [5, ['I', 'Object', 'I', 'I', 'F'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 4, ['Object'], []], [2]]),
   [[4, ['Object'], []], [7, ['Object'], []]])],
 [('regression: every compressed frame kind',
   (['I', 'Object'], [[5], [75, 'I'], [252, 3, 'F'], [249, 2], [251, 300], [255, 1, ['I'], ['Object', 'J']]]),
   [[5, ['I', 'Object'], []],
    [17, ['I', 'Object'], ['I']],
    [21, ['I', 'Object', 'F'], []],
    [24, ['I'], []],
    [325, ['I'], []],
    [327, ['I'], ['Object', 'J']]]),
  ('first frame offset is its delta',
   (['I', 'Object'], [[15], [3]]),
   [[15, ['I', 'Object'], []], [19, ['I', 'Object'], []]]),
  ('same_locals_1_stack_item delta',
   (['I', 'Object'], [[69, 'Object'], [64, 'I']]),
   [[5, ['I', 'Object'], ['Object']], [6, ['I', 'Object'], ['I']]]),
  ('reserved frame type', (['I', 'I', 'J', 'F', 'Object', 'D'], [[1], [246, 0]]), ['ClassFormatError', 1]),
  ('extended one-item frame type',
   (['I', 'Object'], [[247, 9, 'Object']]),
   [[9, ['I', 'Object'], ['Object']]]),
  ('chop three locals', (['I', 'J', 'F'], [[248, 5], [251, 0]]), [[5, [], []], [6, [], []]]),
  ('chop more locals than exist', ([], [[250, 5]]), ['ClassFormatError', 0]),
  ('append three locals then snapshot',
   (['I', 'Object'], [[0], [254, 5, 'I', 'I', 'F'], [0]]),
   [[0, ['I', 'Object'], []],
    [6, ['I', 'Object', 'I', 'I', 'F'], []],
    [7, ['I', 'Object', 'I', 'I', 'F'], []]]),
  ('control: full frame replaces locals',
   (['I', 'Object'], [[255, 5, ['Object'], []], [2]]),
   [[5, ['Object'], []], [8, ['Object'], []]])]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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:
Type 252 frames add nothing and 254 frames drop their last local.

Expand compressed stack map frames. Types: 0-63 same (delta = type), 64-127 same_locals_1_stack_item (delta = type - 64, one stack item), 128-246 reserved (["ClassFormatError", index]), 247 extended one item [247, delta, item], 248-250 chop 251-type locals [t, delta], 251 same extended [251, delta], 252-254 append type-251 locals [t, delta, items...], 255 full [255, delta, locals, stack]. The first frame's offset is its delta; each later offset is previous + delta + 1. Chopping more locals than exist is an error. Return [offset, locals, stack] for every frame; each frame's locals are an independent snapshot.

split: open-access


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

N = 1
observations = []
def solve(heap, roots, events):
    heap = {k: list(v) for k, v in heap.items()}
    roots = list(roots)
    color = {}
    grey = []
    marking = False
    log = []
    def shade(o):
        if o is not None and color.get(o, 'white') == 'white':
            color[o] = 'grey'
            grey.append(o)
    def step():
        o = grey.pop()
        for c in heap[o]:
            shade(c)
        color[o] = 'black'
    for ev in events:
        op = ev[0]
        if op == 'start':
            color = {o: 'white' for o in heap}
            grey.clear()
            marking = True
            for r in roots:
                shade(r)
        elif op == 'mark':
            for _ in range(ev[1]):
                if grey:
                    step()
        elif op == 'store':
            if marking:
                shade(ev[1])
            heap[ev[1]][ev[2]] = ev[3]
        elif op == 'alloc':
            heap[ev[1]] = [None] * ev[2]
            color[ev[1]] = 'black' if marking else 'white'
        elif op == 'root':
            roots.append(ev[1])
            if marking:
                shade(ev[1])
        elif op == 'unroot':
            roots.remove(ev[1])
        else:
            while grey:
                step()
            dead = sorted(o for o in heap if color.get(o, 'white') == 'white')
            for o in dead:
                del heap[o]
            marking = False
            log.append(dead)
    return {'freed': log, 'live': sorted(heap)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: pointer stored into a black object',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['start'], ['mark', 1], ['store', 11, 1, 14], ['finish']]),
   {'freed': [[16]], 'live': [11, 12, 13, 14, 15]}),
  ('allocation after the worklist drained',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['start'], ['mark', 10], ['alloc', 17, 1], ['finish']]),
   {'freed': [[14, 15, 16]], 'live': [11, 12, 13, 17]}),
  ('second cycle starts from all-white',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['start'], ['finish'], ['unroot', 11], ['start'], ['finish']]),
   {'freed': [[14, 15, 16], [11, 12, 13]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]}, [11], [['start'], ['finish']]),
   {'freed': [[14, 15, 16]], 'live': [11, 12, 13]}),
  ('root registered while marking',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['start'], ['mark', 10], ['root', 16], ['finish']]),
   {'freed': [[14, 15]], 'live': [11, 12, 13, 16]}),
  ('store before marking needs no barrier',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['alloc', 18, 1], ['store', 18, 0, 14], ['root', 18], ['start'], ['finish']]),
   {'freed': [[16]], 'live': [11, 12, 13, 14, 15, 18]}),
  ('control: unreachable cycle is freed',
   ({11: [12], 12: [11], 13: []}, [13], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[11, 12]], 'live': [13]})],
 [('regression: pointer stored into a black object',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['start'], ['mark', 1], ['store', 21, 1, 24], ['finish']]),
   {'freed': [[26]], 'live': [21, 22, 23, 24, 25]}),
  ('allocation after the worklist drained',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['start'], ['mark', 10], ['alloc', 27, 1], ['finish']]),
   {'freed': [[24, 25, 26]], 'live': [21, 22, 23, 27]}),
  ('second cycle starts from all-white',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['start'], ['finish'], ['unroot', 21], ['start'], ['finish']]),
   {'freed': [[24, 25, 26], [21, 22, 23]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]}, [21], [['start'], ['finish']]),
   {'freed': [[24, 25, 26]], 'live': [21, 22, 23]}),
  ('root registered while marking',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['start'], ['mark', 10], ['root', 26], ['finish']]),
   {'freed': [[24, 25]], 'live': [21, 22, 23, 26]}),
  ('store before marking needs no barrier',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['alloc', 28, 1], ['store', 28, 0, 24], ['root', 28], ['start'], ['finish']]),
   {'freed': [[26]], 'live': [21, 22, 23, 24, 25, 28]}),
  ('control: unreachable cycle is freed',
   ({21: [22], 22: [21], 23: []}, [23], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[21, 22]], 'live': [23]})],
 [('regression: pointer stored into a black object',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['start'], ['mark', 1], ['store', 31, 1, 34], ['finish']]),
   {'freed': [[36]], 'live': [31, 32, 33, 34, 35]}),
  ('allocation after the worklist drained',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['start'], ['mark', 10], ['alloc', 37, 1], ['finish']]),
   {'freed': [[34, 35, 36]], 'live': [31, 32, 33, 37]}),
  ('second cycle starts from all-white',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['start'], ['finish'], ['unroot', 31], ['start'], ['finish']]),
   {'freed': [[34, 35, 36], [31, 32, 33]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]}, [31], [['start'], ['finish']]),
   {'freed': [[34, 35, 36]], 'live': [31, 32, 33]}),
  ('root registered while marking',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['start'], ['mark', 10], ['root', 36], ['finish']]),
   {'freed': [[34, 35]], 'live': [31, 32, 33, 36]}),
  ('store before marking needs no barrier',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['alloc', 38, 1], ['store', 38, 0, 34], ['root', 38], ['start'], ['finish']]),
   {'freed': [[36]], 'live': [31, 32, 33, 34, 35, 38]}),
  ('control: unreachable cycle is freed',
   ({31: [32], 32: [31], 33: []}, [33], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[31, 32]], 'live': [33]})],
 [('regression: pointer stored into a black object',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['start'], ['mark', 1], ['store', 41, 1, 44], ['finish']]),
   {'freed': [[46]], 'live': [41, 42, 43, 44, 45]}),
  ('allocation after the worklist drained',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['start'], ['mark', 10], ['alloc', 47, 1], ['finish']]),
   {'freed': [[44, 45, 46]], 'live': [41, 42, 43, 47]}),
  ('second cycle starts from all-white',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['start'], ['finish'], ['unroot', 41], ['start'], ['finish']]),
   {'freed': [[44, 45, 46], [41, 42, 43]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]}, [41], [['start'], ['finish']]),
   {'freed': [[44, 45, 46]], 'live': [41, 42, 43]}),
  ('root registered while marking',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['start'], ['mark', 10], ['root', 46], ['finish']]),
   {'freed': [[44, 45]], 'live': [41, 42, 43, 46]}),
  ('store before marking needs no barrier',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['alloc', 48, 1], ['store', 48, 0, 44], ['root', 48], ['start'], ['finish']]),
   {'freed': [[46]], 'live': [41, 42, 43, 44, 45, 48]}),
  ('control: unreachable cycle is freed',
   ({41: [42], 42: [41], 43: []}, [43], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[41, 42]], 'live': [43]})],
 [('regression: pointer stored into a black object',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['start'], ['mark', 1], ['store', 51, 1, 54], ['finish']]),
   {'freed': [[56]], 'live': [51, 52, 53, 54, 55]}),
  ('allocation after the worklist drained',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['start'], ['mark', 10], ['alloc', 57, 1], ['finish']]),
   {'freed': [[54, 55, 56]], 'live': [51, 52, 53, 57]}),
  ('second cycle starts from all-white',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['start'], ['finish'], ['unroot', 51], ['start'], ['finish']]),
   {'freed': [[54, 55, 56], [51, 52, 53]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]}, [51], [['start'], ['finish']]),
   {'freed': [[54, 55, 56]], 'live': [51, 52, 53]}),
  ('root registered while marking',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['start'], ['mark', 10], ['root', 56], ['finish']]),
   {'freed': [[54, 55]], 'live': [51, 52, 53, 56]}),
  ('store before marking needs no barrier',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['alloc', 58, 1], ['store', 58, 0, 54], ['root', 58], ['start'], ['finish']]),
   {'freed': [[56]], 'live': [51, 52, 53, 54, 55, 58]}),
  ('control: unreachable cycle is freed',
   ({51: [52], 52: [51], 53: []}, [53], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[51, 52]], 'live': [53]})]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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(heap, roots, events):
    heap = {k: list(v) for k, v in heap.items()}
    roots = list(roots)
    color = {}
    grey = []
    marking = False
    log = []
    def shade(o):
        if o is not None and color.get(o, 'white') == 'white':
            color[o] = 'grey'
            grey.append(o)
    def step():
        o = grey.pop()
        for c in heap[o]:
            shade(c)
        color[o] = 'black'
    for ev in events:
        op = ev[0]
        if op == 'start':
            color = {o: 'white' for o in heap}
            grey.clear()
            marking = True
            for r in roots:
                shade(r)
        elif op == 'mark':
            for _ in range(ev[1]):
                if grey:
                    step()
        elif op == 'store':
            if marking:
                shade(heap[ev[1]][ev[2]])
            heap[ev[1]][ev[2]] = ev[3]
        elif op == 'alloc':
            heap[ev[1]] = [None] * ev[2]
            color[ev[1]] = 'black' if marking else 'white'
        elif op == 'root':
            roots.append(ev[1])
            if marking:
                shade(ev[1])
        elif op == 'unroot':
            roots.remove(ev[1])
        else:
            while grey:
                step()
            dead = sorted(o for o in heap if color.get(o, 'white') == 'white')
            for o in dead:
                del heap[o]
            marking = False
            log.append(dead)
    return {'freed': log, 'live': sorted(heap)}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
cases = [[('regression: pointer stored into a black object',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['start'], ['mark', 1], ['store', 11, 1, 14], ['finish']]),
   {'freed': [[16]], 'live': [11, 12, 13, 14, 15]}),
  ('allocation after the worklist drained',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['start'], ['mark', 10], ['alloc', 17, 1], ['finish']]),
   {'freed': [[14, 15, 16]], 'live': [11, 12, 13, 17]}),
  ('second cycle starts from all-white',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['start'], ['finish'], ['unroot', 11], ['start'], ['finish']]),
   {'freed': [[14, 15, 16], [11, 12, 13]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]}, [11], [['start'], ['finish']]),
   {'freed': [[14, 15, 16]], 'live': [11, 12, 13]}),
  ('root registered while marking',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['start'], ['mark', 10], ['root', 16], ['finish']]),
   {'freed': [[14, 15]], 'live': [11, 12, 13, 16]}),
  ('store before marking needs no barrier',
   ({11: [12, None], 12: [13], 13: [], 14: [15], 15: [], 16: [11]},
    [11],
    [['alloc', 18, 1], ['store', 18, 0, 14], ['root', 18], ['start'], ['finish']]),
   {'freed': [[16]], 'live': [11, 12, 13, 14, 15, 18]}),
  ('control: unreachable cycle is freed',
   ({11: [12], 12: [11], 13: []}, [13], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[11, 12]], 'live': [13]})],
 [('regression: pointer stored into a black object',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['start'], ['mark', 1], ['store', 21, 1, 24], ['finish']]),
   {'freed': [[26]], 'live': [21, 22, 23, 24, 25]}),
  ('allocation after the worklist drained',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['start'], ['mark', 10], ['alloc', 27, 1], ['finish']]),
   {'freed': [[24, 25, 26]], 'live': [21, 22, 23, 27]}),
  ('second cycle starts from all-white',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['start'], ['finish'], ['unroot', 21], ['start'], ['finish']]),
   {'freed': [[24, 25, 26], [21, 22, 23]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]}, [21], [['start'], ['finish']]),
   {'freed': [[24, 25, 26]], 'live': [21, 22, 23]}),
  ('root registered while marking',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['start'], ['mark', 10], ['root', 26], ['finish']]),
   {'freed': [[24, 25]], 'live': [21, 22, 23, 26]}),
  ('store before marking needs no barrier',
   ({21: [22, None], 22: [23], 23: [], 24: [25], 25: [], 26: [21]},
    [21],
    [['alloc', 28, 1], ['store', 28, 0, 24], ['root', 28], ['start'], ['finish']]),
   {'freed': [[26]], 'live': [21, 22, 23, 24, 25, 28]}),
  ('control: unreachable cycle is freed',
   ({21: [22], 22: [21], 23: []}, [23], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[21, 22]], 'live': [23]})],
 [('regression: pointer stored into a black object',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['start'], ['mark', 1], ['store', 31, 1, 34], ['finish']]),
   {'freed': [[36]], 'live': [31, 32, 33, 34, 35]}),
  ('allocation after the worklist drained',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['start'], ['mark', 10], ['alloc', 37, 1], ['finish']]),
   {'freed': [[34, 35, 36]], 'live': [31, 32, 33, 37]}),
  ('second cycle starts from all-white',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['start'], ['finish'], ['unroot', 31], ['start'], ['finish']]),
   {'freed': [[34, 35, 36], [31, 32, 33]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]}, [31], [['start'], ['finish']]),
   {'freed': [[34, 35, 36]], 'live': [31, 32, 33]}),
  ('root registered while marking',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['start'], ['mark', 10], ['root', 36], ['finish']]),
   {'freed': [[34, 35]], 'live': [31, 32, 33, 36]}),
  ('store before marking needs no barrier',
   ({31: [32, None], 32: [33], 33: [], 34: [35], 35: [], 36: [31]},
    [31],
    [['alloc', 38, 1], ['store', 38, 0, 34], ['root', 38], ['start'], ['finish']]),
   {'freed': [[36]], 'live': [31, 32, 33, 34, 35, 38]}),
  ('control: unreachable cycle is freed',
   ({31: [32], 32: [31], 33: []}, [33], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[31, 32]], 'live': [33]})],
 [('regression: pointer stored into a black object',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['start'], ['mark', 1], ['store', 41, 1, 44], ['finish']]),
   {'freed': [[46]], 'live': [41, 42, 43, 44, 45]}),
  ('allocation after the worklist drained',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['start'], ['mark', 10], ['alloc', 47, 1], ['finish']]),
   {'freed': [[44, 45, 46]], 'live': [41, 42, 43, 47]}),
  ('second cycle starts from all-white',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['start'], ['finish'], ['unroot', 41], ['start'], ['finish']]),
   {'freed': [[44, 45, 46], [41, 42, 43]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]}, [41], [['start'], ['finish']]),
   {'freed': [[44, 45, 46]], 'live': [41, 42, 43]}),
  ('root registered while marking',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['start'], ['mark', 10], ['root', 46], ['finish']]),
   {'freed': [[44, 45]], 'live': [41, 42, 43, 46]}),
  ('store before marking needs no barrier',
   ({41: [42, None], 42: [43], 43: [], 44: [45], 45: [], 46: [41]},
    [41],
    [['alloc', 48, 1], ['store', 48, 0, 44], ['root', 48], ['start'], ['finish']]),
   {'freed': [[46]], 'live': [41, 42, 43, 44, 45, 48]}),
  ('control: unreachable cycle is freed',
   ({41: [42], 42: [41], 43: []}, [43], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[41, 42]], 'live': [43]})],
 [('regression: pointer stored into a black object',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['start'], ['mark', 1], ['store', 51, 1, 54], ['finish']]),
   {'freed': [[56]], 'live': [51, 52, 53, 54, 55]}),
  ('allocation after the worklist drained',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['start'], ['mark', 10], ['alloc', 57, 1], ['finish']]),
   {'freed': [[54, 55, 56]], 'live': [51, 52, 53, 57]}),
  ('second cycle starts from all-white',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['start'], ['finish'], ['unroot', 51], ['start'], ['finish']]),
   {'freed': [[54, 55, 56], [51, 52, 53]], 'live': []}),
  ('finish drains outstanding grey objects',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]}, [51], [['start'], ['finish']]),
   {'freed': [[54, 55, 56]], 'live': [51, 52, 53]}),
  ('root registered while marking',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['start'], ['mark', 10], ['root', 56], ['finish']]),
   {'freed': [[54, 55]], 'live': [51, 52, 53, 56]}),
  ('store before marking needs no barrier',
   ({51: [52, None], 52: [53], 53: [], 54: [55], 55: [], 56: [51]},
    [51],
    [['alloc', 58, 1], ['store', 58, 0, 54], ['root', 58], ['start'], ['finish']]),
   {'freed': [[56]], 'live': [51, 52, 53, 54, 55, 58]}),
  ('control: unreachable cycle is freed',
   ({51: [52], 52: [51], 53: []}, [53], [['start'], ['mark', 1], ['finish']]),
   {'freed': [[51, 52]], 'live': [53]})]]
for label, args, expected in cases[N - 1]:
    check(label, solve(*args), expected)
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:
An object stored into an already-black object is freed while still referenced.

Incremental tri-colour mark-sweep with a Dijkstra insertion barrier. start: every object white, roots shaded grey. mark k: up to k worklist steps (pop a grey object, shade its white children, blacken it). store src i dst: while marking, shade dst before writing. alloc id k: new object with k null fields, black while marking (allocate-black), otherwise white. root id: add a root, shaded if marking. unroot id removes a root. finish: drain the worklist, free all white objects, stop marking. Return the freed ids per finish and the surviving ids.

split: open-access