FAILURE MAP
← Case archive

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

First-scan bit is not re-armed after a power cycle · case 01

Initialization rungs conditioned on the first-scan bit run at initial power-up but not after later restarts.

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

ROOT CAUSE

The power-cycle path does not set the first-scan flag again.

VERIFIED REPAIR

Every power cycle makes the following scan a first scan.

Unsuccessful approach: Re-arming only when no bit is latched skips initialization whenever a latch survived the 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
            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: 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: 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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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: 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 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: 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'], []]],
  ['control: 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'], []]],
  ['control: 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']]],
  ['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'], [], [], [], [], []]],
  ['control: 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']]],
  ['control: 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: scenario 15',
   [[['OTU', 'B:3', 'I:2'],
     ['OTL', 'B:0', 'I:1'],
     ['OTU', 'B:0', 'I:2'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:2', 'S:FS']],
    [{'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},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2']]],
  ['regression: scenario 21',
   [[['OTL', 'B:3', 'I:1'],
     ['OTL', 'B:0', 'I:2'],
     ['OTE', 'B:3', 'I:2'],
     ['OTL', 'B:2', 'I:1'],
     ['OTE', 'B:2', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'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': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [['B:0', 'B:2', 'B:3'],
    ['B:0', 'B:3'],
    ['B:0'],
    ['B:0'],
    ['B:0'],
    ['B:0', 'B:2'],
    ['B:0', 'B:3'],
    ['B:0'],
    ['B:0'],
    ['B:0', 'B:2']]],
  ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]],
 [['regression: scenario 5',
   [[['OTU', 'B:0', 'I:2'],
     ['OTU', 'B:1', 'I:1'],
     ['OTE', 'B:3', 'I:0'],
     ['OTL', 'B:1', 'I:1'],
     ['OTU', 'B:0', 'S:FS'],
     ['OTE', 'B:3', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': True, '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},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[], ['B:1', 'B:3'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1', 'B:3'], ['B:1']]],
  ['regression: scenario 28',
   [[['OTU', 'B:0', 'S:FS'], ['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'I:1']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:3'], ['B:0'], ['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0']]],
  ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]],
 [['regression: scenario 9',
   [[['OTU', 'B:0', 'I:1'],
     ['OTE', 'B:3', 'S:FS'],
     ['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:3', 'I:1']],
    [{'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
  ['regression: scenario 12',
   [[['OTE', 'B:0', 'I:2'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'I:1'],
     ['OTE', 'B:2', 'I:2'],
     ['OTU', 'B:3', 'S:FS'],
     ['OTL', 'B:1', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[], ['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:0', 'B:1', 'B:2'], ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]]]
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:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]Failed
regression: first-scan output then power cycle[['B:0', 'B:2'], ['B:0'], ['B:0'], ['B:0']][['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]Failed
control: unlatch listed before latch[['B:3'], ['B:3'], []][['B:3'], ['B:3'], []]Passed
control: latch then idle[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']][['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]Passed
control: 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
control: 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
control: 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
control: 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 / f0edade98dfbd1672013c9a49802accb3dc3c9c7f8a698ffbc34fa4218f37d96

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 = not any(bits.values())
            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: 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: 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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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: 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 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: 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'], []]],
  ['control: 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'], []]],
  ['control: 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']]],
  ['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'], [], [], [], [], []]],
  ['control: 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']]],
  ['control: 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: scenario 15',
   [[['OTU', 'B:3', 'I:2'],
     ['OTL', 'B:0', 'I:1'],
     ['OTU', 'B:0', 'I:2'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:2', 'S:FS']],
    [{'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},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2']]],
  ['regression: scenario 21',
   [[['OTL', 'B:3', 'I:1'],
     ['OTL', 'B:0', 'I:2'],
     ['OTE', 'B:3', 'I:2'],
     ['OTL', 'B:2', 'I:1'],
     ['OTE', 'B:2', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'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': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [['B:0', 'B:2', 'B:3'],
    ['B:0', 'B:3'],
    ['B:0'],
    ['B:0'],
    ['B:0'],
    ['B:0', 'B:2'],
    ['B:0', 'B:3'],
    ['B:0'],
    ['B:0'],
    ['B:0', 'B:2']]],
  ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]],
 [['regression: scenario 5',
   [[['OTU', 'B:0', 'I:2'],
     ['OTU', 'B:1', 'I:1'],
     ['OTE', 'B:3', 'I:0'],
     ['OTL', 'B:1', 'I:1'],
     ['OTU', 'B:0', 'S:FS'],
     ['OTE', 'B:3', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': True, '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},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[], ['B:1', 'B:3'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1', 'B:3'], ['B:1']]],
  ['regression: scenario 28',
   [[['OTU', 'B:0', 'S:FS'], ['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'I:1']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:3'], ['B:0'], ['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0']]],
  ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]],
 [['regression: scenario 9',
   [[['OTU', 'B:0', 'I:1'],
     ['OTE', 'B:3', 'S:FS'],
     ['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:3', 'I:1']],
    [{'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
  ['regression: scenario 12',
   [[['OTE', 'B:0', 'I:2'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'I:1'],
     ['OTE', 'B:2', 'I:2'],
     ['OTU', 'B:3', 'S:FS'],
     ['OTL', 'B:1', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[], ['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:0', 'B:1', 'B:2'], ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]]]
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:0', 'B:1', 'B:2'], ['B:0'], ['B:0'], ['B:0', 'B:2'], []]Failed
regression: first-scan output then power cycle[['B:0', 'B:2'], ['B:0'], ['B:0'], ['B:0']][['B:0', 'B:2'], ['B:0'], ['B:0', 'B:2'], ['B:0']]Failed
control: unlatch listed before latch[['B:3'], ['B:3'], []][['B:3'], ['B:3'], []]Passed
control: latch then idle[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']][['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]Passed
control: 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
control: 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
control: 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
control: 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 / 58cf0fb99e75f7c650767084dd2754c225d68ac27adba82408edaaa93fa67c28

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: 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: 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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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: 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 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: 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'], []]],
  ['control: 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'], []]],
  ['control: 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']]],
  ['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'], [], [], [], [], []]],
  ['control: 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']]],
  ['control: 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: scenario 15',
   [[['OTU', 'B:3', 'I:2'],
     ['OTL', 'B:0', 'I:1'],
     ['OTU', 'B:0', 'I:2'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:2', 'S:FS']],
    [{'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},
     {'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:2'], ['B:2'], ['B:2'], ['B:2'], ['B:0', 'B:2']]],
  ['regression: scenario 21',
   [[['OTL', 'B:3', 'I:1'],
     ['OTL', 'B:0', 'I:2'],
     ['OTE', 'B:3', 'I:2'],
     ['OTL', 'B:2', 'I:1'],
     ['OTE', 'B:2', 'S:FS']],
    [{'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'power_cycle': True},
     {'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': False},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False}]],
   [['B:0', 'B:2', 'B:3'],
    ['B:0', 'B:3'],
    ['B:0'],
    ['B:0'],
    ['B:0'],
    ['B:0', 'B:2'],
    ['B:0', 'B:3'],
    ['B:0'],
    ['B:0'],
    ['B:0', 'B:2']]],
  ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]],
 [['regression: scenario 5',
   [[['OTU', 'B:0', 'I:2'],
     ['OTU', 'B:1', 'I:1'],
     ['OTE', 'B:3', 'I:0'],
     ['OTL', 'B:1', 'I:1'],
     ['OTU', 'B:0', 'S:FS'],
     ['OTE', 'B:3', 'S:FS']],
    [{'power_cycle': True},
     {'I:0': True, '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},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[], ['B:1', 'B:3'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1'], ['B:1', 'B:3'], ['B:1']]],
  ['regression: scenario 28',
   [[['OTU', 'B:0', 'S:FS'], ['OTE', 'B:3', 'S:FS'], ['OTL', 'B:0', 'I:1']],
    [{'I:0': True, 'I:1': True, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'I:0': True, 'I:1': False, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [['B:0', 'B:3'], ['B:0'], ['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0'], ['B:0']]],
  ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]],
 [['regression: scenario 9',
   [[['OTU', 'B:0', 'I:1'],
     ['OTE', 'B:3', 'S:FS'],
     ['OTL', 'B:2', 'I:0'],
     ['OTL', 'B:0', 'S:FS'],
     ['OTL', 'B:3', 'S:FS'],
     ['OTL', 'B:3', 'I:1']],
    [{'I:0': False, 'I:1': True, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': True},
     {'power_cycle': True},
     {'I:0': True, 'I:1': False, 'I:2': True},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': True}]],
   [['B:0', 'B:3'], ['B:0'], ['B:0'], ['B:0', 'B:2', 'B:3'], ['B:0', 'B:2'], ['B:0', 'B:2']]],
  ['regression: scenario 12',
   [[['OTE', 'B:0', 'I:2'],
     ['OTE', 'B:0', 'S:FS'],
     ['OTL', 'B:1', 'I:1'],
     ['OTE', 'B:2', 'I:2'],
     ['OTU', 'B:3', 'S:FS'],
     ['OTL', 'B:1', 'I:2']],
    [{'power_cycle': True},
     {'I:0': False, 'I:1': True, 'I:2': False},
     {'I:0': False, 'I:1': False, 'I:2': False},
     {'power_cycle': True},
     {'I:0': True, 'I:1': True, 'I:2': True},
     {'I:0': True, 'I:1': True, 'I:2': False}]],
   [[], ['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:0', 'B:1', 'B:2'], ['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'], []]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]],
  ['control: 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']]]]]
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: 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
control: unlatch listed before latch[['B:3'], ['B:3'], []][['B:3'], ['B:3'], []]Passed
control: latch then idle[['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']][['B:0', 'B:1'], ['B:1'], ['B:1'], ['B:1']]Passed
control: 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
control: 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
control: 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
control: 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 / 814c0615283226a162659277743cde8491dd680a91d3cbfe9b94477c9ecf769b

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.863682+00:00.

Case digest / 9b1c0c4fa6a890fdc35aca35fb8e0ea20116f834081741868b3c093d141677c8