FAILURE MAP
← Case archive

FA-92041 / PLC ladder logic scan cycles / Open access

OTL clears its bit when its rung is false · case 01

A latch behaves like an ordinary output coil and drops as soon as its condition goes away.

Verified by executionVariant 1 · 8 checks per implementationDownload source bundle ↓JSON ↗

ROOT CAUSE

The OTL branch writes the rung state instead of only setting on a true rung.

VERIFIED REPAIR

OTL only sets its bit when the rung is true and leaves it alone otherwise.

Unsuccessful approach: Writing the rung state on first scans still clears retained latches after a restart.

Case contract

Latch (OTL), unlatch (OTU) and non-retentive output (OTE) rungs executed in program order each scan. rungs is a list of [instr, bit, condition_tag]; the rung is true when the condition input is true, or, for condition S:FS, on the first scan after power-up. A scan item {"power_cycle": true} models a power cycle: prescan clears only OTE destination bits, OTL/OTU bits are retentive, and the next scan is a first scan; it also reports the post-prescan state. OTL sets and OTU clears its bit only when its rung is true; the later rung wins. Return the sorted true bits after each item.

Why this case matters

Ladder programs are executed as repeated scans; each defect here changes what a rung, timer, counter or data-table instruction reports on a particular scan, which is how commissioning and field faults are actually observed.

1 / The failure

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(rungs, scans):
    bits = {}
    first = True
    out = []
    for scan in scans:
        if scan.get('power_cycle'):
            for instr, bit, cond in rungs:
                if instr == 'OTE':
                    bits[bit] = False
            first = True
            out.append(sorted(b for b, v in bits.items() if v))
            continue
        for instr, bit, cond in rungs:
            rung = first if cond == 'S:FS' else bool(scan.get(cond, False))
            if instr == 'OTE':
                bits[bit] = rung
            elif instr == 'OTL':
                bits[bit] = rung
            elif rung and instr == 'OTU':
                bits[bit] = False
        first = False
        out.append(sorted(b for b, v in bits.items() if v))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:0', 'I:0'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTE', 'B:2', 'I:1']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTU', 'B:2', 'I:1'], ['OTL', 'B:1', 'I:1'], ['OTL', 'B:1', 'I:2'], ['OTL', 'B:0', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True}]],
   [['B:0'],
    ['B:0'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1']]],
  ['regression: scenario 3',
   [[['OTE', 'B:3', 'I:2'],
     ['OTE', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]],
  ['regression: scenario 4',
   [[['OTL', 'B:3', 'I:1'], ['OTU', 'B:2', 'I:1'], ['OTE', 'B:0', 'I:1']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True}]],
   [['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3']]]],
 [['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['control: scenario 1',
   [[['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'S:FS'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:0', 'S:FS']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [['B:0', 'B:3'], [], [], [], [], []]],
  ['regression: scenario 2',
   [[['OTL', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3']]],
  ['regression: scenario 3',
   [[['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTL', 'B:3', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: scenario 4',
   [[['OTL', 'B:0', 'I:0'],
     ['OTE', 'B:3', 'I:2'],
     ['OTE', 'B:0', 'I:2'],
     ['OTL', 'B:1', 'I:0'],
     ['OTU', 'B:3', 'I:2']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:1'],
    ['B:1'],
    ['B:1'],
    ['B:1']]]],
 [['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 5',
   [[['OTU', 'B:0', 'S:FS'], ['OTL', 'B:1', 'S:FS'], ['OTE', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2']],
    [{'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:2'], ['OTE', 'B:1', 'I:0'], ['OTL', 'B:1', 'I:0']],
    [{'power_cycle': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [[], [], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTL', 'B:0', 'I:2'], ['OTL', 'B:2', 'S:FS'], ['OTU', 'B:0', 'I:2'], ['OTU', 'B:3', 'I:2']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2']]],
  ['control: scenario 3',
   [[['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:3', 'I:0']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [[], [], [], [], ['B:0', 'B:3'], ['B:0']]]],
 [['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 7',
   [[['OTL', 'B:3', 'S:FS'], ['OTL', 'B:1', 'I:1'], ['OTU', 'B:3', 'S:FS'], ['OTU', 'B:2', 'I:2']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:1'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTE', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [['B:0', 'B:2'], ['B:0', 'B:3'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:3'], ['B:0', 'B:3']]],
  ['regression: scenario 2',
   [[['OTE', 'B:1', 'I:1'],
     ['OTU', 'B:3', 'I:2'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:3', 'I:1']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False}]],
   [['B:1', 'B:3'], ['B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3']]],
  ['control: scenario 3',
   [[['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTE', 'B:1', 'S:FS'],
     ['OTU', 'B:2', 'S:FS'],
     ['OTL', 'B:2', 'I:1'],
     ['OTU', 'B:1', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:2'], [], []]]],
 [['regression: scenario 1',
   [[['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'S:FS'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:1']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: scenario 7',
   [[['OTU', 'B:3', 'I:2'], ['OTE', 'B:3', 'S:FS'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:1', 'I:0']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [[], ['B:3'], ['B:3'], [], [], [], [], []]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 2',
   [[['OTU', 'B:0', 'I:2'], ['OTE', 'B:2', 'I:0'], ['OTL', 'B:1', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:1', 'B:2'], ['B:1', 'B:2'], ['B:1'], ['B:1']]],
  ['regression: scenario 3',
   [[['OTU', 'B:0', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:2', 'I:1'],
     ['OTL', 'B:1', 'I:2'],
     ['OTU', 'B:0', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [[],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2']]]]]
for label, args, expected in fixtures[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)
Boundary fixtureActualExpectedOutcome
regression: latched through power cycle[['B:0', 'B:1', 'B:2'], [], [], ['B:2'], []][['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]Failed
regression: latch then idle[['B:0', 'B:1'], [], [], []][['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]Failed
regression: unlatch listed before latch[['B:3'], [], []][['B:3'], ['B:3'], []]Failed
regression: first-scan output then power cycle[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], []][['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]Failed
regression: scenario 1[['B:0'], [], ['B:2', 'B:3'], [], [], [], ['B:2', 'B:3'], ['B:2'], ['B:3']][['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]Failed
regression: scenario 2[['B:0'], ['B:0'], ['B:1'], ['B:0', 'B:1'], ['B:1'], ['B:1'], [], ['B:1'], ['B:1']][['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']]Failed
regression: scenario 3[['B:1', 'B:2', 'B:3'], ['B:3'], ['B:1'], ['B:2'], ['B:2']][['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]Failed
regression: scenario 4[['B:0', 'B:3'], [], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], [], ['B:0', 'B:3']][['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3']]Failed

SHA-256 / c68bc8592ad45bbf3eb3b341d3c2b2c5348a9073851637a423acb34027386a3f

2 / The unsuccessful fix

Exit 1
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(rungs, scans):
    bits = {}
    first = True
    out = []
    for scan in scans:
        if scan.get('power_cycle'):
            for instr, bit, cond in rungs:
                if instr == 'OTE':
                    bits[bit] = False
            first = True
            out.append(sorted(b for b, v in bits.items() if v))
            continue
        for instr, bit, cond in rungs:
            rung = first if cond == 'S:FS' else bool(scan.get(cond, False))
            if instr == 'OTE':
                bits[bit] = rung
            elif instr == 'OTL' and (rung or first):
                bits[bit] = rung
            elif rung and instr == 'OTU':
                bits[bit] = False
        first = False
        out.append(sorted(b for b, v in bits.items() if v))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:0', 'I:0'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTE', 'B:2', 'I:1']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTU', 'B:2', 'I:1'], ['OTL', 'B:1', 'I:1'], ['OTL', 'B:1', 'I:2'], ['OTL', 'B:0', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True}]],
   [['B:0'],
    ['B:0'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1']]],
  ['regression: scenario 3',
   [[['OTE', 'B:3', 'I:2'],
     ['OTE', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]],
  ['regression: scenario 4',
   [[['OTL', 'B:3', 'I:1'], ['OTU', 'B:2', 'I:1'], ['OTE', 'B:0', 'I:1']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True}]],
   [['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3']]]],
 [['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['control: scenario 1',
   [[['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'S:FS'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:0', 'S:FS']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [['B:0', 'B:3'], [], [], [], [], []]],
  ['regression: scenario 2',
   [[['OTL', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3']]],
  ['regression: scenario 3',
   [[['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTL', 'B:3', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: scenario 4',
   [[['OTL', 'B:0', 'I:0'],
     ['OTE', 'B:3', 'I:2'],
     ['OTE', 'B:0', 'I:2'],
     ['OTL', 'B:1', 'I:0'],
     ['OTU', 'B:3', 'I:2']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:1'],
    ['B:1'],
    ['B:1'],
    ['B:1']]]],
 [['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 5',
   [[['OTU', 'B:0', 'S:FS'], ['OTL', 'B:1', 'S:FS'], ['OTE', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2']],
    [{'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:2'], ['OTE', 'B:1', 'I:0'], ['OTL', 'B:1', 'I:0']],
    [{'power_cycle': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [[], [], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTL', 'B:0', 'I:2'], ['OTL', 'B:2', 'S:FS'], ['OTU', 'B:0', 'I:2'], ['OTU', 'B:3', 'I:2']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2']]],
  ['control: scenario 3',
   [[['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:3', 'I:0']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [[], [], [], [], ['B:0', 'B:3'], ['B:0']]]],
 [['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 7',
   [[['OTL', 'B:3', 'S:FS'], ['OTL', 'B:1', 'I:1'], ['OTU', 'B:3', 'S:FS'], ['OTU', 'B:2', 'I:2']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:1'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTE', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [['B:0', 'B:2'], ['B:0', 'B:3'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:3'], ['B:0', 'B:3']]],
  ['regression: scenario 2',
   [[['OTE', 'B:1', 'I:1'],
     ['OTU', 'B:3', 'I:2'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:3', 'I:1']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False}]],
   [['B:1', 'B:3'], ['B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3']]],
  ['control: scenario 3',
   [[['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTE', 'B:1', 'S:FS'],
     ['OTU', 'B:2', 'S:FS'],
     ['OTL', 'B:2', 'I:1'],
     ['OTU', 'B:1', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:2'], [], []]]],
 [['regression: scenario 1',
   [[['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'S:FS'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:1']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: scenario 7',
   [[['OTU', 'B:3', 'I:2'], ['OTE', 'B:3', 'S:FS'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:1', 'I:0']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [[], ['B:3'], ['B:3'], [], [], [], [], []]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 2',
   [[['OTU', 'B:0', 'I:2'], ['OTE', 'B:2', 'I:0'], ['OTL', 'B:1', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:1', 'B:2'], ['B:1', 'B:2'], ['B:1'], ['B:1']]],
  ['regression: scenario 3',
   [[['OTU', 'B:0', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:2', 'I:1'],
     ['OTL', 'B:1', 'I:2'],
     ['OTU', 'B:0', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [[],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2']]]]]
for label, args, expected in fixtures[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)
Boundary fixtureActualExpectedOutcome
regression: latched through power cycle[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:2'], []][['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]Failed
regression: latch then idle[['B:0', 'B:1'], ['B:1'], ['B:1'], []][['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]Failed
regression: unlatch listed before latch[['B:3'], ['B:3'], []][['B:3'], ['B:3'], []]Passed
regression: first-scan output then power cycle[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']][['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]Passed
regression: scenario 1[['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']][['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]Passed
regression: scenario 2[['B:0'], ['B:0'], ['B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], [], ['B:1'], ['B:1']][['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']]Failed
regression: scenario 3[['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']][['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]Passed
regression: scenario 4[['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3']][['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3']]Passed

SHA-256 / 76cec94fe427997a32151b5d652041cb98ecc0e137b8f9b5cefabf944aba3d85

3 / The verified repair

Exit 0
"""Failure Map reference implementation. Python standard library only."""
import json

N = 1
observations = []
def solve(rungs, scans):
    bits = {}
    first = True
    out = []
    for scan in scans:
        if scan.get('power_cycle'):
            for instr, bit, cond in rungs:
                if instr == 'OTE':
                    bits[bit] = False
            first = True
            out.append(sorted(b for b, v in bits.items() if v))
            continue
        for instr, bit, cond in rungs:
            rung = first if cond == 'S:FS' else bool(scan.get(cond, False))
            if instr == 'OTE':
                bits[bit] = rung
            elif rung and instr == 'OTL':
                bits[bit] = True
            elif rung and instr == 'OTU':
                bits[bit] = False
        first = False
        out.append(sorted(b for b, v in bits.items() if v))
    return out
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:0', 'I:0'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTE', 'B:2', 'I:1']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTU', 'B:2', 'I:1'], ['OTL', 'B:1', 'I:1'], ['OTL', 'B:1', 'I:2'], ['OTL', 'B:0', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True}]],
   [['B:0'],
    ['B:0'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1']]],
  ['regression: scenario 3',
   [[['OTE', 'B:3', 'I:2'],
     ['OTE', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]],
  ['regression: scenario 4',
   [[['OTL', 'B:3', 'I:1'], ['OTU', 'B:2', 'I:1'], ['OTE', 'B:0', 'I:1']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True}]],
   [['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3']]]],
 [['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['control: scenario 1',
   [[['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'S:FS'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:0', 'S:FS']],
    [{'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [['B:0', 'B:3'], [], [], [], [], []]],
  ['regression: scenario 2',
   [[['OTL', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3'],
    ['B:0', 'B:2', 'B:3']]],
  ['regression: scenario 3',
   [[['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:2', 'I:2'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTL', 'B:3', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: scenario 4',
   [[['OTL', 'B:0', 'I:0'],
     ['OTE', 'B:3', 'I:2'],
     ['OTE', 'B:0', 'I:2'],
     ['OTL', 'B:1', 'I:0'],
     ['OTU', 'B:3', 'I:2']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:1'],
    ['B:0', 'B:1'],
    ['B:0', 'B:1'],
    ['B:1'],
    ['B:1'],
    ['B:1'],
    ['B:1']]]],
 [['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 5',
   [[['OTU', 'B:0', 'S:FS'], ['OTL', 'B:1', 'S:FS'], ['OTE', 'B:2', 'I:1'], ['OTL', 'B:3', 'I:2']],
    [{'I:0': False, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:2'], ['OTE', 'B:1', 'I:0'], ['OTL', 'B:1', 'I:0']],
    [{'power_cycle': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [[], [], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:3'], ['B:3']]],
  ['regression: scenario 2',
   [[['OTL', 'B:0', 'I:2'], ['OTL', 'B:2', 'S:FS'], ['OTU', 'B:0', 'I:2'], ['OTU', 'B:3', 'I:2']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [['B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:2']]],
  ['control: scenario 3',
   [[['OTU', 'B:0', 'I:0'], ['OTL', 'B:0', 'I:0'], ['OTE', 'B:3', 'I:0']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'power_cycle': True}]],
   [[], [], [], [], ['B:0', 'B:3'], ['B:0']]]],
 [['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 7',
   [[['OTL', 'B:3', 'S:FS'], ['OTL', 'B:1', 'I:1'], ['OTU', 'B:3', 'S:FS'], ['OTU', 'B:2', 'I:2']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: scenario 1',
   [[['OTL', 'B:3', 'I:1'],
     ['OTL', 'B:1', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTE', 'B:2', 'I:0']],
    [{'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [['B:0', 'B:2'], ['B:0', 'B:3'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:3'], ['B:0', 'B:3']]],
  ['regression: scenario 2',
   [[['OTE', 'B:1', 'I:1'],
     ['OTU', 'B:3', 'I:2'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:3', 'I:2'],
     ['OTL', 'B:3', 'I:1']],
    [{'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False}]],
   [['B:1', 'B:3'], ['B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3'], ['B:1', 'B:3']]],
  ['control: scenario 3',
   [[['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:1', 'I:0'],
     ['OTE', 'B:1', 'S:FS'],
     ['OTU', 'B:2', 'S:FS'],
     ['OTL', 'B:2', 'I:1'],
     ['OTU', 'B:1', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:2'], [], []]]],
 [['regression: scenario 1',
   [[['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:1', 'I:1'],
     ['OTL', 'B:2', 'S:FS'],
     ['OTL', 'B:1', 'I:0'],
     ['OTL', 'B:1', 'I:1']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [[],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3'],
    ['B:1', 'B:2', 'B:3']]],
  ['regression: scenario 7',
   [[['OTU', 'B:3', 'I:2'], ['OTE', 'B:3', 'S:FS'], ['OTL', 'B:3', 'I:2'], ['OTU', 'B:1', 'I:0']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'power_cycle': True}]],
   [[], ['B:3'], ['B:3'], [], [], [], [], []]],
  ['regression: latched through power cycle',
   [[['OTL', 'B:0', 'I:0'], ['OTU', 'B:0', 'I:1'], ['OTE', 'B:1', 'I:0'], ['OTE', 'B:2', 'S:FS']],
    [{'I:0': True}, {}, {'power_cycle': True}, {}, {'I:1': True}]],
   [['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]],
  ['regression: unlatch listed before latch',
   [[['OTU', 'B:3', 'I:1'], ['OTL', 'B:3', 'I:0']], [{'I:0': True, 'I:1': True}, {}, {'I:1': True}]],
   [['B:3'], ['B:3'], []]],
  ['regression: first-scan output then power cycle',
   [[['OTE', 'B:2', 'S:FS'], ['OTL', 'B:0', 'S:FS']], [{}, {'power_cycle': True}, {}, {}]],
   [['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]],
  ['regression: latch then idle',
   [[['OTL', 'B:1', 'I:2'], ['OTE', 'B:0', 'I:2']], [{'I:2': True}, {}, {'power_cycle': True}, {}]],
   [['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]],
  ['regression: scenario 2',
   [[['OTU', 'B:0', 'I:2'], ['OTE', 'B:2', 'I:0'], ['OTL', 'B:1', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [[], [], ['B:2'], ['B:2'], ['B:2'], ['B:1', 'B:2'], ['B:1', 'B:2'], ['B:1'], ['B:1']]],
  ['regression: scenario 3',
   [[['OTU', 'B:0', 'S:FS'],
     ['OTU', 'B:1', 'S:FS'],
     ['OTU', 'B:3', 'I:0'],
     ['OTL', 'B:2', 'I:1'],
     ['OTL', 'B:1', 'I:2'],
     ['OTU', 'B:0', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': False, 'I:2': True}]],
   [[],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2'],
    ['B:1', 'B:2']]]]]
for label, args, expected in fixtures[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)
Boundary fixtureActualExpectedOutcome
regression: latched through power cycle[['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []][['B:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]Passed
regression: latch then idle[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']][['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]Passed
regression: unlatch listed before latch[['B:3'], ['B:3'], []][['B:3'], ['B:3'], []]Passed
regression: first-scan output then power cycle[['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']][['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]Passed
regression: scenario 1[['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']][['B:0'], [], ['B:2', 'B:3'], ['B:3'], ['B:3'], ['B:3'], ['B:2', 'B:3'], ['B:2', 'B:3'], ['B:3']]Passed
regression: scenario 2[['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']][['B:0'], ['B:0'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1'], ['B:0', 'B:1']]Passed
regression: scenario 3[['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']][['B:1', 'B:2', 'B:3'], ['B:2', 'B:3'], ['B:1', 'B:2'], ['B:2'], ['B:2']]Passed
regression: scenario 4[['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3']][['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3'], ['B:3'], ['B:0', 'B:3']]Passed

SHA-256 / 8951cf0c4eede99b444a807a611d6186f2390090df90b71767bbe5a6d2fa71f0

Verification & scope

A deterministic bounded teaching model of one PLC instruction or rung pattern evaluated scan by scan. The stated contract is a stipulated toy convention, not a claim of conformance to any vendor controller or IEC 61131-3 runtime. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.

Observations recorded using Python 3.12.14 at 2026-09-29T14:51:41.879139+00:00.

Case digest / f38f27bb92a94583f3534f03a6969767fa9b1bd71a55cdf6afe06ea9e9ccaca2