FAILURE MAP
← Case archive

FA-67271 / Railway interlocking logic / Open access

Flank protection selection: lock agreement · case 01

A flank point already locked in the protecting lie is treated as unavailable.

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

ROOT CAUSE

Only free flank points are accepted.

VERIFIED REPAIR

Accept a flank point that is free or already lies in the protecting lie.

Unsuccessful approach: Accepting only already-lying points never uses a free flank point.

Case contract

For each route point (sorted) in its lie, the flank table (key point+lie) lists flank points with the protecting lie and an optional flank signal. A flank point is set to its protecting lie if it is free, locked in that lie by another route, or already demanded in that lie by this route; if it is unavailable, its flank signal is held at danger when the signal exists and is holdable; otherwise the route is refused (refused:<flank point>, nothing set or held). Held signals are returned sorted and unique.

Why this case matters

Interlocking logic decides whether trains may be given authority; a wrong decision at this point either grants unsafe movements or strands traffic.

1 / The failure

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

N = 1
observations = []
def solve(x):
    set_pts = {}
    held = []
    locks = x['point_locks']
    for p, pos in sorted(x['route_points'].items()):
        for fp, fpos, fsig in x['flank'].get(p + pos, []):
            lk = locks.get(fp, set_pts.get(fp))
            if lk is None:
                set_pts[fp] = fpos
            elif fsig is not None and fsig in x['holdable']:
                held.append(fsig)
            else:
                return {'result': 'refused:' + fp, 'set_points': {}, 'held_signals': []}
    return {'result': 'protected', 'set_points': set_pts, 'held_signals': sorted(set(held))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: flank point locked in the protecting lie', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank point free', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank signal not holdable', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': []}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 1', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'N'}, 'holdable': ['S23', 'S24']}, {'result': 'refused:P9', 'set_points': {}, 'held_signals': []}), ('control 4', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N'}, 'held_signals': []}), ('control 7', {'route_points': {'P2': 'R', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'R', 'P9': 'R'}, 'holdable': ['S22', 'S24']}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []})], [('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank point free', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('sampled regression 18', {'route_points': {'P3': 'R', 'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P9': 'N'}, 'holdable': ['S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N', 'P8': 'N'}, 'held_signals': []}), ('control 2', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P9': 'R'}, 'held_signals': []}), ('boundary: flank signal not holdable', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': []}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 12', {'route_points': {'P1': 'R', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'N'}, 'held_signals': []}), ('control 15', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'N'}, 'holdable': ['S24']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': []}), ('control 21', {'route_points': {'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': []})], [('regression: same signal held twice', {'route_points': {'P1': 'N', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N', 'P9': 'N'}, 'holdable': ['S20', 'S22']}, {'result': 'protected', 'set_points': {'P8': 'N'}, 'held_signals': ['S20', 'S22']}), ('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('sampled regression 37', {'route_points': {'P2': 'N', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S21', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('sampled regression 10', {'route_points': {'P3': 'N', 'P2': 'N', 'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'R'}, 'holdable': ['S22']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N', 'P9': 'R'}, 'held_signals': ['S22']}), ('boundary: no flank signal available', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'N'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'refused:P9', 'set_points': {}, 'held_signals': []}), ('control 23', {'route_points': {'P1': 'R', 'P2': 'N', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': ['S24']}), ('control 26', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'N'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P9': 'R'}, 'held_signals': []}), ('sampled regression 29', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': ['S23']})], [('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: reverse lie flank entry', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': ['S23']}), ('sampled regression 52', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N'}, 'holdable': ['S20', 'S22', 'S23']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N'}, 'held_signals': []}), ('sampled regression 16', {'route_points': {'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S20', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('regression: same signal held twice', {'route_points': {'P1': 'N', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N', 'P9': 'N'}, 'holdable': ['S20', 'S22']}, {'result': 'protected', 'set_points': {'P8': 'N'}, 'held_signals': ['S20', 'S22']}), ('control 34', {'route_points': {'P3': 'R', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'N'}, 'holdable': ['S20', 'S21', 'S24']}, {'result': 'protected', 'set_points': {'P8': 'R'}, 'held_signals': ['S20', 'S24']}), ('sampled regression 37', {'route_points': {'P2': 'N', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S21', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('control 40', {'route_points': {'P3': 'R', 'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'N'}, 'held_signals': []})], [('regression: flank point locked in the protecting lie', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('sampled regression 64', {'route_points': {'P2': 'R', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': ['S23']}), ('control 21', {'route_points': {'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': []}), ('boundary: own conflicting demand without a signal', {'route_points': {'P1': 'N', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 45', {'route_points': {'P2': 'N', 'P1': 'N', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'R'}, 'holdable': ['S20', 'S21', 'S23', 'S24']}, {'result': 'refused:P8', 'set_points': {}, 'held_signals': []}), ('sampled regression 48', {'route_points': {'P2': 'R', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N'}, 'holdable': ['S20', 'S21', 'S22']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N', 'P8': 'N'}, 'held_signals': []}), ('sampled regression 51', {'route_points': {'P3': 'N', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': ['S23']})]]
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: flank point locked in the protecting lie{'held_signals': ['S20'], 'result': 'protected', 'set_points': {'P8': 'N'}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}Failed
regression: own conflicting demand with a holdable signal{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Failed
boundary: flank point free{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}Passed
regression: two route points disagree on a flank point{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Failed
boundary: flank signal not holdable{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}Passed
control 1{'held_signals': [], 'result': 'refused:P9', 'set_points': {}}{'held_signals': [], 'result': 'refused:P9', 'set_points': {}}Passed
control 4{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Passed
control 7{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}Passed

SHA-256 / 08892123b115218ebdf362e4b17a200eeb7a04822afe831d8ae4f41c0d12e45e

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(x):
    set_pts = {}
    held = []
    locks = x['point_locks']
    for p, pos in sorted(x['route_points'].items()):
        for fp, fpos, fsig in x['flank'].get(p + pos, []):
            lk = locks.get(fp, set_pts.get(fp))
            if lk == fpos:
                set_pts[fp] = fpos
            elif fsig is not None and fsig in x['holdable']:
                held.append(fsig)
            else:
                return {'result': 'refused:' + fp, 'set_points': {}, 'held_signals': []}
    return {'result': 'protected', 'set_points': set_pts, 'held_signals': sorted(set(held))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: flank point locked in the protecting lie', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank point free', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank signal not holdable', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': []}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 1', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'N'}, 'holdable': ['S23', 'S24']}, {'result': 'refused:P9', 'set_points': {}, 'held_signals': []}), ('control 4', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N'}, 'held_signals': []}), ('control 7', {'route_points': {'P2': 'R', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'R', 'P9': 'R'}, 'holdable': ['S22', 'S24']}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []})], [('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank point free', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('sampled regression 18', {'route_points': {'P3': 'R', 'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P9': 'N'}, 'holdable': ['S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N', 'P8': 'N'}, 'held_signals': []}), ('control 2', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P9': 'R'}, 'held_signals': []}), ('boundary: flank signal not holdable', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': []}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 12', {'route_points': {'P1': 'R', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'N'}, 'held_signals': []}), ('control 15', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'N'}, 'holdable': ['S24']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': []}), ('control 21', {'route_points': {'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': []})], [('regression: same signal held twice', {'route_points': {'P1': 'N', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N', 'P9': 'N'}, 'holdable': ['S20', 'S22']}, {'result': 'protected', 'set_points': {'P8': 'N'}, 'held_signals': ['S20', 'S22']}), ('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('sampled regression 37', {'route_points': {'P2': 'N', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S21', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('sampled regression 10', {'route_points': {'P3': 'N', 'P2': 'N', 'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'R'}, 'holdable': ['S22']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N', 'P9': 'R'}, 'held_signals': ['S22']}), ('boundary: no flank signal available', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'N'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'refused:P9', 'set_points': {}, 'held_signals': []}), ('control 23', {'route_points': {'P1': 'R', 'P2': 'N', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': ['S24']}), ('control 26', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'N'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P9': 'R'}, 'held_signals': []}), ('sampled regression 29', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': ['S23']})], [('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: reverse lie flank entry', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': ['S23']}), ('sampled regression 52', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N'}, 'holdable': ['S20', 'S22', 'S23']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N'}, 'held_signals': []}), ('sampled regression 16', {'route_points': {'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S20', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('regression: same signal held twice', {'route_points': {'P1': 'N', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N', 'P9': 'N'}, 'holdable': ['S20', 'S22']}, {'result': 'protected', 'set_points': {'P8': 'N'}, 'held_signals': ['S20', 'S22']}), ('control 34', {'route_points': {'P3': 'R', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'N'}, 'holdable': ['S20', 'S21', 'S24']}, {'result': 'protected', 'set_points': {'P8': 'R'}, 'held_signals': ['S20', 'S24']}), ('sampled regression 37', {'route_points': {'P2': 'N', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S21', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('control 40', {'route_points': {'P3': 'R', 'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'N'}, 'held_signals': []})], [('regression: flank point locked in the protecting lie', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('sampled regression 64', {'route_points': {'P2': 'R', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': ['S23']}), ('control 21', {'route_points': {'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': []}), ('boundary: own conflicting demand without a signal', {'route_points': {'P1': 'N', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 45', {'route_points': {'P2': 'N', 'P1': 'N', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'R'}, 'holdable': ['S20', 'S21', 'S23', 'S24']}, {'result': 'refused:P8', 'set_points': {}, 'held_signals': []}), ('sampled regression 48', {'route_points': {'P2': 'R', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N'}, 'holdable': ['S20', 'S21', 'S22']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N', 'P8': 'N'}, 'held_signals': []}), ('sampled regression 51', {'route_points': {'P3': 'N', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': ['S23']})]]
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: flank point locked in the protecting lie{'held_signals': [], 'result': 'refused:P8', 'set_points': {}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}Failed
regression: own conflicting demand with a holdable signal{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Failed
boundary: flank point free{'held_signals': [], 'result': 'refused:P8', 'set_points': {}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}Failed
regression: two route points disagree on a flank point{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Failed
boundary: flank signal not holdable{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}Passed
control 1{'held_signals': [], 'result': 'refused:P9', 'set_points': {}}{'held_signals': [], 'result': 'refused:P9', 'set_points': {}}Passed
control 4{'held_signals': [], 'result': 'refused:P9', 'set_points': {}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Failed
control 7{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}Passed

SHA-256 / f41290165e71dbffad7f5333c1948f3e5954f6c3612eb68d37e0e513376823b9

3 / The verified repair

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

N = 1
observations = []
def solve(x):
    set_pts = {}
    held = []
    locks = x['point_locks']
    for p, pos in sorted(x['route_points'].items()):
        for fp, fpos, fsig in x['flank'].get(p + pos, []):
            lk = locks.get(fp, set_pts.get(fp))
            if lk is None or lk == fpos:
                set_pts[fp] = fpos
            elif fsig is not None and fsig in x['holdable']:
                held.append(fsig)
            else:
                return {'result': 'refused:' + fp, 'set_points': {}, 'held_signals': []}
    return {'result': 'protected', 'set_points': set_pts, 'held_signals': sorted(set(held))}
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: flank point locked in the protecting lie', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank point free', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank signal not holdable', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': []}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 1', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'N'}, 'holdable': ['S23', 'S24']}, {'result': 'refused:P9', 'set_points': {}, 'held_signals': []}), ('control 4', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N'}, 'held_signals': []}), ('control 7', {'route_points': {'P2': 'R', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'R', 'P9': 'R'}, 'holdable': ['S22', 'S24']}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []})], [('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: flank point free', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('sampled regression 18', {'route_points': {'P3': 'R', 'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P9': 'N'}, 'holdable': ['S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N', 'P8': 'N'}, 'held_signals': []}), ('control 2', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P9': 'R'}, 'held_signals': []}), ('boundary: flank signal not holdable', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': []}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 12', {'route_points': {'P1': 'R', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'N'}, 'held_signals': []}), ('control 15', {'route_points': {'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'N'}, 'holdable': ['S24']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': []}), ('control 21', {'route_points': {'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': []})], [('regression: same signal held twice', {'route_points': {'P1': 'N', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N', 'P9': 'N'}, 'holdable': ['S20', 'S22']}, {'result': 'protected', 'set_points': {'P8': 'N'}, 'held_signals': ['S20', 'S22']}), ('regression: two route points disagree on a flank point', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('sampled regression 37', {'route_points': {'P2': 'N', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S21', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('sampled regression 10', {'route_points': {'P3': 'N', 'P2': 'N', 'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'R'}, 'holdable': ['S22']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N', 'P9': 'R'}, 'held_signals': ['S22']}), ('boundary: no flank signal available', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'N'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'refused:P9', 'set_points': {}, 'held_signals': []}), ('control 23', {'route_points': {'P1': 'R', 'P2': 'N', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': ['S24']}), ('control 26', {'route_points': {'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'N'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P9': 'R'}, 'held_signals': []}), ('sampled regression 29', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': ['S23']})], [('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('boundary: reverse lie flank entry', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N'}, 'held_signals': ['S23']}), ('sampled regression 52', {'route_points': {'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N'}, 'holdable': ['S20', 'S22', 'S23']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N'}, 'held_signals': []}), ('sampled regression 16', {'route_points': {'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S20', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('regression: same signal held twice', {'route_points': {'P1': 'N', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N', 'P9': 'N'}, 'holdable': ['S20', 'S22']}, {'result': 'protected', 'set_points': {'P8': 'N'}, 'held_signals': ['S20', 'S22']}), ('control 34', {'route_points': {'P3': 'R', 'P2': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P9': 'N'}, 'holdable': ['S20', 'S21', 'S24']}, {'result': 'protected', 'set_points': {'P8': 'R'}, 'held_signals': ['S20', 'S24']}), ('sampled regression 37', {'route_points': {'P2': 'N', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P8': 'R'}, 'holdable': ['S21', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'R', 'P9': 'R'}, 'held_signals': []}), ('control 40', {'route_points': {'P3': 'R', 'P1': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P8': 'N'}, 'held_signals': []})], [('regression: flank point locked in the protecting lie', {'route_points': {'P1': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}, 'held_signals': []}), ('regression: own conflicting demand with a holdable signal', {'route_points': {'P1': 'R', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S23']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}, 'held_signals': []}), ('sampled regression 64', {'route_points': {'P2': 'R', 'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': ['S23']}), ('control 21', {'route_points': {'P1': 'R', 'P3': 'N'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S21', 'S22']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': []}), ('boundary: own conflicting demand without a signal', {'route_points': {'P1': 'N', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'refused:P7', 'set_points': {}, 'held_signals': []}), ('control 45', {'route_points': {'P2': 'N', 'P1': 'N', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'R', 'P8': 'R'}, 'holdable': ['S20', 'S21', 'S23', 'S24']}, {'result': 'refused:P8', 'set_points': {}, 'held_signals': []}), ('sampled regression 48', {'route_points': {'P2': 'R', 'P3': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P7': 'N', 'P8': 'N'}, 'holdable': ['S20', 'S21', 'S22']}, {'result': 'protected', 'set_points': {'P9': 'N', 'P7': 'N', 'P8': 'N'}, 'held_signals': []}), ('sampled regression 51', {'route_points': {'P3': 'N', 'P2': 'R'}, 'flank': {'P1N': [['P7', 'R', 'S20'], ['P8', 'N', None]], 'P1R': [['P7', 'N', 'S21']], 'P2N': [['P8', 'R', 'S22'], ['P9', 'R', 'S20']], 'P2R': [['P9', 'N', 'S23'], ['P7', 'N', None]], 'P3N': [['P9', 'R', None]], 'P3R': [['P8', 'N', 'S24']]}, 'point_locks': {'P9': 'R'}, 'holdable': ['S20', 'S21', 'S22', 'S23', 'S24']}, {'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'R'}, 'held_signals': ['S23']})]]
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: flank point locked in the protecting lie{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}Passed
regression: own conflicting demand with a holdable signal{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Passed
boundary: flank point free{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'R', 'P8': 'N'}}Passed
regression: two route points disagree on a flank point{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Passed
boundary: flank signal not holdable{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}Passed
control 1{'held_signals': [], 'result': 'refused:P9', 'set_points': {}}{'held_signals': [], 'result': 'refused:P9', 'set_points': {}}Passed
control 4{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}{'held_signals': [], 'result': 'protected', 'set_points': {'P7': 'N', 'P9': 'N'}}Passed
control 7{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}{'held_signals': [], 'result': 'refused:P7', 'set_points': {}}Passed

SHA-256 / 7c6d8ab251d258fc6f43f1743e38a45c218f9a7a57bdbe9d94cfb014433dac11

Verification & scope

Stipulated toy interlocking contract for a bounded teaching model; it makes no claim of conformance to any railway signalling standard and omits real safety cases. 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:47:51.304491+00:00.

Case digest / fe34e66e64c787fe55883a1d00665359d039c3454d02d0140677f64237631e72