broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT id,SUM(v) OVER(PARTITION BY k ORDER BY id ROWS BETWEEN UNBOUNDED PRECEDING AND 1 PRECEDING) FROM a')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [[101, None], [11, None], [111, 0], [121, 0], [131, None], [141, -1], [151, 2], [161, 2], [171, None], [181, 8], [191, 0], [201, -1], [21, 0], [31, 2], [41, 4], [51, 3], [61, 6], [71, -2], [81, 0], [91, 0]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [[101, None], [11, None], [111, 0], [121, 0], [131, None], [141, -1], [151, 2], [161, 2], [171, None], [181, 8], [191, 0], [201, -1], [21, 0], [31, 2], [41, 4], [51, 3], [61, 6], [71, -2], [81, 0], [91, 0]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [[11, None], [21, None], [31, None]])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [[11, 0]])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [[11, -2], [21, -2], [31, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [[11, 2], [21, 4], [31, 7], [41, 7]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [[102, None], [112, 0], [12, None], [122, 0], [132, None], [142, -1], [152, 2], [162, 2], [172, None], [182, 8], [192, 0], [202, -1], [22, 0], [32, 2], [42, 4], [52, 3], [62, 6], [72, -2], [82, 0], [92, 0]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [[102, None], [112, 0], [12, None], [122, 0], [132, None], [142, -1], [152, 2], [162, 2], [172, None], [182, 8], [192, 0], [202, -1], [22, 0], [32, 2], [42, 4], [52, 3], [62, 6], [72, -2], [82, 0], [92, 0]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [[12, None], [22, None], [32, None]])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [[12, 0]])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [[12, -2], [22, -2], [32, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [[12, 2], [22, 4], [32, 7], [42, 7]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [[103, None], [113, 0], [123, 0], [13, None], [133, None], [143, -1], [153, 2], [163, 2], [173, None], [183, 8], [193, 0], [203, -1], [23, 0], [33, 2], [43, 4], [53, 3], [63, 6], [73, -2], [83, 0], [93, 0]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [[103, None], [113, 0], [123, 0], [13, None], [133, None], [143, -1], [153, 2], [163, 2], [173, None], [183, 8], [193, 0], [203, -1], [23, 0], [33, 2], [43, 4], [53, 3], [63, 6], [73, -2], [83, 0], [93, 0]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [[13, None], [23, None], [33, None]])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [[13, 0]])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [[13, -2], [23, -2], [33, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [[13, 2], [23, 4], [33, 7], [43, 7]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [[104, None], [114, 0], [124, 0], [134, None], [14, None], [144, -1], [154, 2], [164, 2], [174, None], [184, 8], [194, 0], [204, -1], [24, 0], [34, 2], [44, 4], [54, 3], [64, 6], [74, -2], [84, 0], [94, 0]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [[104, None], [114, 0], [124, 0], [134, None], [14, None], [144, -1], [154, 2], [164, 2], [174, None], [184, 8], [194, 0], [204, -1], [24, 0], [34, 2], [44, 4], [54, 3], [64, 6], [74, -2], [84, 0], [94, 0]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [[14, None], [24, None], [34, None]])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [[14, 0]])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [[14, -2], [24, -2], [34, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [[14, 2], [24, 4], [34, 7], [44, 7]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [[105, None], [115, 0], [125, 0], [135, None], [145, -1], [15, None], [155, 2], [165, 2], [175, None], [185, 8], [195, 0], [205, -1], [25, 0], [35, 2], [45, 4], [55, 3], [65, 6], [75, -2], [85, 0], [95, 0]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [[105, None], [115, 0], [125, 0], [135, None], [145, -1], [15, None], [155, 2], [165, 2], [175, None], [185, 8], [195, 0], [205, -1], [25, 0], [35, 2], [45, 4], [55, 3], [65, 6], [75, -2], [85, 0], [95, 0]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [[15, None], [25, None], [35, None]])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [[15, 0]])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [[15, -2], [25, -2], [35, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [[15, 2], [25, 4], [35, 7], [45, 7]])
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)

evaluation_group: xs-running-row-sum

prompt:
The query violates its result contract: omits the current contribution from its prefix.

Return each ID with cumulative known v within k in ID order, including the current row. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


meaning: Fixture-count band, not measured model difficulty

deps: stdlib

evaluation_group: xs-running-row-sum

prompt:
The query violates its result contract: keeps only current and preceding row.

Return each ID with cumulative known v within k in ID order, including the current row. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-running-row-sum

prompt:
The query violates its result contract: accumulates other key groups into the prefix.

Return each ID with cumulative known v within k in ID order, including the current row. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-running-row-sum

prompt:
The query violates its result contract: accumulates in measurement order instead of identity order.

Return each ID with cumulative known v within k in ID order, including the current row. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-peer-range-sum

prompt:
The query violates its result contract: accumulates peers individually rather than as a range.

Return each ID with sum of known v in its k partition at v no greater than the current peer value; peers share cumulative sum. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-peer-range-sum

prompt:
The query violates its result contract: adds unique identity and destroys range peers.

Return each ID with sum of known v in its k partition at v no greater than the current peer value; peers share cumulative sum. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-peer-range-sum

prompt:
The query violates its result contract: ignores the current peer cutoff.

Return each ID with sum of known v in its k partition at v no greater than the current peer value; peers share cumulative sum. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-peer-range-sum

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT id,SUM(v) OVER(PARTITION BY k ORDER BY v RANGE UNBOUNDED PRECEDING EXCLUDE GROUP) FROM a')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [[101, None], [11, None], [111, 0], [121, None], [131, None], [141, -2], [151, 2], [161, 2], [171, None], [181, 5], [191, -1], [201, -2], [21, -1], [31, 5], [41, 5], [51, -1], [61, 8], [71, -2], [81, 0], [91, None]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [[101, None], [11, None], [111, 0], [121, None], [131, None], [141, -2], [151, 2], [161, 2], [171, None], [181, 5], [191, -1], [201, -2], [21, -1], [31, 5], [41, 5], [51, -1], [61, 8], [71, -2], [81, 0], [91, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [[11, None], [21, None], [31, None]])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [[11, 0]])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [[11, -2], [21, None], [31, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [[11, 4], [21, 4], [31, 7], [41, None]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [[102, None], [112, 0], [12, None], [122, None], [132, None], [142, -2], [152, 2], [162, 2], [172, None], [182, 5], [192, -1], [202, -2], [22, -1], [32, 5], [42, 5], [52, -1], [62, 8], [72, -2], [82, 0], [92, None]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [[102, None], [112, 0], [12, None], [122, None], [132, None], [142, -2], [152, 2], [162, 2], [172, None], [182, 5], [192, -1], [202, -2], [22, -1], [32, 5], [42, 5], [52, -1], [62, 8], [72, -2], [82, 0], [92, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [[12, None], [22, None], [32, None]])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [[12, 0]])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [[12, -2], [22, None], [32, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [[12, 4], [22, 4], [32, 7], [42, None]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [[103, None], [113, 0], [123, None], [13, None], [133, None], [143, -2], [153, 2], [163, 2], [173, None], [183, 5], [193, -1], [203, -2], [23, -1], [33, 5], [43, 5], [53, -1], [63, 8], [73, -2], [83, 0], [93, None]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [[103, None], [113, 0], [123, None], [13, None], [133, None], [143, -2], [153, 2], [163, 2], [173, None], [183, 5], [193, -1], [203, -2], [23, -1], [33, 5], [43, 5], [53, -1], [63, 8], [73, -2], [83, 0], [93, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [[13, None], [23, None], [33, None]])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [[13, 0]])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [[13, -2], [23, None], [33, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [[13, 4], [23, 4], [33, 7], [43, None]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [[104, None], [114, 0], [124, None], [134, None], [14, None], [144, -2], [154, 2], [164, 2], [174, None], [184, 5], [194, -1], [204, -2], [24, -1], [34, 5], [44, 5], [54, -1], [64, 8], [74, -2], [84, 0], [94, None]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [[104, None], [114, 0], [124, None], [134, None], [14, None], [144, -2], [154, 2], [164, 2], [174, None], [184, 5], [194, -1], [204, -2], [24, -1], [34, 5], [44, 5], [54, -1], [64, 8], [74, -2], [84, 0], [94, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [[14, None], [24, None], [34, None]])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [[14, 0]])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [[14, -2], [24, None], [34, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [[14, 4], [24, 4], [34, 7], [44, None]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [[105, None], [115, 0], [125, None], [135, None], [145, -2], [15, None], [155, 2], [165, 2], [175, None], [185, 5], [195, -1], [205, -2], [25, -1], [35, 5], [45, 5], [55, -1], [65, 8], [75, -2], [85, 0], [95, None]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [[105, None], [115, 0], [125, None], [135, None], [145, -2], [15, None], [155, 2], [165, 2], [175, None], [185, 5], [195, -1], [205, -2], [25, -1], [35, 5], [45, 5], [55, -1], [65, 8], [75, -2], [85, 0], [95, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [[15, None], [25, None], [35, None]])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [[15, 0]])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [[15, -2], [25, None], [35, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [[15, 4], [25, 4], [35, 7], [45, None]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The query violates its result contract: accumulates values greater than the current value.

Return each ID with sum of known v in its k partition at v no greater than the current peer value; peers share cumulative sum. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT id,SUM(v) OVER(PARTITION BY k ORDER BY v RANGE UNBOUNDED PRECEDING EXCLUDE GROUP) FROM a')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [[101, None], [11, None], [111, 0], [121, None], [131, None], [141, -2], [151, 2], [161, 2], [171, None], [181, 5], [191, -1], [201, -2], [21, -1], [31, 5], [41, 5], [51, -1], [61, 8], [71, -2], [81, 0], [91, None]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [[101, None], [11, None], [111, 0], [121, None], [131, None], [141, -2], [151, 2], [161, 2], [171, None], [181, 5], [191, -1], [201, -2], [21, -1], [31, 5], [41, 5], [51, -1], [61, 8], [71, -2], [81, 0], [91, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [[11, None], [21, None], [31, None]])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [[11, 0]])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [[11, -2], [21, None], [31, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [[11, 4], [21, 4], [31, 7], [41, None]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [[102, None], [112, 0], [12, None], [122, None], [132, None], [142, -2], [152, 2], [162, 2], [172, None], [182, 5], [192, -1], [202, -2], [22, -1], [32, 5], [42, 5], [52, -1], [62, 8], [72, -2], [82, 0], [92, None]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [[102, None], [112, 0], [12, None], [122, None], [132, None], [142, -2], [152, 2], [162, 2], [172, None], [182, 5], [192, -1], [202, -2], [22, -1], [32, 5], [42, 5], [52, -1], [62, 8], [72, -2], [82, 0], [92, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [[12, None], [22, None], [32, None]])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [[12, 0]])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [[12, -2], [22, None], [32, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [[12, 4], [22, 4], [32, 7], [42, None]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [[103, None], [113, 0], [123, None], [13, None], [133, None], [143, -2], [153, 2], [163, 2], [173, None], [183, 5], [193, -1], [203, -2], [23, -1], [33, 5], [43, 5], [53, -1], [63, 8], [73, -2], [83, 0], [93, None]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [[103, None], [113, 0], [123, None], [13, None], [133, None], [143, -2], [153, 2], [163, 2], [173, None], [183, 5], [193, -1], [203, -2], [23, -1], [33, 5], [43, 5], [53, -1], [63, 8], [73, -2], [83, 0], [93, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [[13, None], [23, None], [33, None]])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [[13, 0]])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [[13, -2], [23, None], [33, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [[13, 4], [23, 4], [33, 7], [43, None]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [[104, None], [114, 0], [124, None], [134, None], [14, None], [144, -2], [154, 2], [164, 2], [174, None], [184, 5], [194, -1], [204, -2], [24, -1], [34, 5], [44, 5], [54, -1], [64, 8], [74, -2], [84, 0], [94, None]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [[104, None], [114, 0], [124, None], [134, None], [14, None], [144, -2], [154, 2], [164, 2], [174, None], [184, 5], [194, -1], [204, -2], [24, -1], [34, 5], [44, 5], [54, -1], [64, 8], [74, -2], [84, 0], [94, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [[14, None], [24, None], [34, None]])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [[14, 0]])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [[14, -2], [24, None], [34, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [[14, 4], [24, 4], [34, 7], [44, None]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [[105, None], [115, 0], [125, None], [135, None], [145, -2], [15, None], [155, 2], [165, 2], [175, None], [185, 5], [195, -1], [205, -2], [25, -1], [35, 5], [45, 5], [55, -1], [65, 8], [75, -2], [85, 0], [95, None]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [[105, None], [115, 0], [125, None], [135, None], [145, -2], [15, None], [155, 2], [165, 2], [175, None], [185, 5], [195, -1], [205, -2], [25, -1], [35, 5], [45, 5], [55, -1], [65, 8], [75, -2], [85, 0], [95, None]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [[15, None], [25, None], [35, None]])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [[15, 0]])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [[15, -2], [25, None], [35, -3]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [[15, 4], [25, 4], [35, 7], [45, None]])
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)

evaluation_group: xs-peer-range-sum

prompt:
The query violates its result contract: excludes the current peer group from its prefix.

Return each ID with sum of known v in its k partition at v no greater than the current peer value; peers share cumulative sum. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-previous-value

prompt:
The query violates its result contract: reads the successor rather than predecessor.

Return each ID and previous row v in the same k partition in ID order, with NULL when no predecessor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-previous-value

prompt:
The query violates its result contract: reads a predecessor from another key partition.

Return each ID and previous row v in the same k partition in ID order, with NULL when no predecessor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-previous-value

prompt:
The query violates its result contract: skips the immediate predecessor.

Return each ID and previous row v in the same k partition in ID order, with NULL when no predecessor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-previous-value

source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT id,LAG(v) OVER(PARTITION BY k ORDER BY id) FROM a WHERE v IS NOT NULL')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [[101, None], [11, None], [111, None], [121, 0], [131, None], [141, None], [151, None], [161, None], [171, None], [181, 3], [191, -1], [201, 1], [21, None], [31, 0], [41, 2], [51, 2], [61, -1], [71, None], [81, -2], [91, 2]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [[101, None], [11, None], [111, None], [121, 0], [131, None], [141, None], [151, None], [161, None], [171, None], [181, 3], [191, -1], [201, 1], [21, None], [31, 0], [41, 2], [51, 2], [61, -1], [71, None], [81, -2], [91, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [[11, None], [21, None], [31, None]])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [[11, None]])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [[11, None], [21, -2], [31, None]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [[11, None], [21, 2], [31, 2], [41, 3]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [[102, None], [112, None], [12, None], [122, 0], [132, None], [142, None], [152, None], [162, None], [172, None], [182, 3], [192, -1], [202, 1], [22, None], [32, 0], [42, 2], [52, 2], [62, -1], [72, None], [82, -2], [92, 2]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [[102, None], [112, None], [12, None], [122, 0], [132, None], [142, None], [152, None], [162, None], [172, None], [182, 3], [192, -1], [202, 1], [22, None], [32, 0], [42, 2], [52, 2], [62, -1], [72, None], [82, -2], [92, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [[12, None], [22, None], [32, None]])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [[12, None]])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [[12, None], [22, -2], [32, None]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [[12, None], [22, 2], [32, 2], [42, 3]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [[103, None], [113, None], [123, 0], [13, None], [133, None], [143, None], [153, None], [163, None], [173, None], [183, 3], [193, -1], [203, 1], [23, None], [33, 0], [43, 2], [53, 2], [63, -1], [73, None], [83, -2], [93, 2]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [[103, None], [113, None], [123, 0], [13, None], [133, None], [143, None], [153, None], [163, None], [173, None], [183, 3], [193, -1], [203, 1], [23, None], [33, 0], [43, 2], [53, 2], [63, -1], [73, None], [83, -2], [93, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [[13, None], [23, None], [33, None]])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [[13, None]])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [[13, None], [23, -2], [33, None]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [[13, None], [23, 2], [33, 2], [43, 3]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [[104, None], [114, None], [124, 0], [134, None], [14, None], [144, None], [154, None], [164, None], [174, None], [184, 3], [194, -1], [204, 1], [24, None], [34, 0], [44, 2], [54, 2], [64, -1], [74, None], [84, -2], [94, 2]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [[104, None], [114, None], [124, 0], [134, None], [14, None], [144, None], [154, None], [164, None], [174, None], [184, 3], [194, -1], [204, 1], [24, None], [34, 0], [44, 2], [54, 2], [64, -1], [74, None], [84, -2], [94, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [[14, None], [24, None], [34, None]])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [[14, None]])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [[14, None], [24, -2], [34, None]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [[14, None], [24, 2], [34, 2], [44, 3]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [[105, None], [115, None], [125, 0], [135, None], [145, None], [15, None], [155, None], [165, None], [175, None], [185, 3], [195, -1], [205, 1], [25, None], [35, 0], [45, 2], [55, 2], [65, -1], [75, None], [85, -2], [95, 2]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [[105, None], [115, None], [125, 0], [135, None], [145, None], [15, None], [155, None], [165, None], [175, None], [185, 3], [195, -1], [205, 1], [25, None], [35, 0], [45, 2], [55, 2], [65, -1], [75, None], [85, -2], [95, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [[15, None], [25, None], [35, None]])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [[15, None]])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [[15, None], [25, -2], [35, None]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [[15, None], [25, 2], [35, 2], [45, 3]])
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)

prompt:
The query violates its result contract: invents zero for absent predecessors.

Return each ID and previous row v in the same k partition in ID order, with NULL when no predecessor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


broken_source:
"""Failure Map reference implementation. Python standard library only."""
import json
import sqlite3
N = 1
observations = []
def solve(rows, refs):
    db = sqlite3.connect(':memory:')
    try:
        for name, records in [('a', rows), ('b', refs)]:
            db.execute('CREATE TABLE ' + name + ' (id INTEGER PRIMARY KEY, k TEXT, v INTEGER, w INTEGER, flag INTEGER, parent INTEGER)')
            db.executemany('INSERT INTO ' + name + ' VALUES (?,?,?,?,?,?)', records)
        return sorted([list(row) for row in db.execute('SELECT id,LAG(v) OVER(PARTITION BY k ORDER BY id) FROM a WHERE v IS NOT NULL')], key=repr)
    finally:
        db.close()
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
if N == 1:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], []), [[101, None], [11, None], [111, None], [121, 0], [131, None], [141, None], [151, None], [161, None], [171, None], [181, 3], [191, -1], [201, 1], [21, None], [31, 0], [41, 2], [51, 2], [61, -1], [71, None], [81, -2], [91, 2]])
    check('references without candidates', solve([], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[11, 'a', None, 8, None, None], [21, 'a', 0, 3, 0, 11], [31, 'a', 2, 1, 1, 21], [41, 'a', 2, 2, 2, 901], [51, 'a', -1, 4, -1, 31], [61, 'a', 3, 1, 1, 41], [71, 'b', -2, 2, 0, 11], [81, 'b', 2, 8, 1, 21], [91, 'b', None, 4, None, None], [101, None, None, 0, 1, 901], [111, None, 0, 5, 0, 11], [121, None, None, 7, None, 21], [131, 'c', None, 6, None, 31], [141, 'd', -1, 1, 0, 41], [151, 'A', 2, 2, 1, 51], [161, ' a ', 2, 8, 1, None], [171, '', None, 2, 0, None], [181, 'a', 2, 8, 1, 11], [191, 'd', 1, 3, 0, 41], [201, 'd', -1, 0, -1, 21]], [[11, 'a', None, 0, 1, None], [21, 'a', 2, 2, 0, None], [31, 'a', 2, 3, 2, None], [41, 'a', 3, 4, None, None], [51, 'b', -2, 2, 1, None], [61, 'b', 0, 8, -1, None], [71, None, None, 2, 1, None], [81, None, 0, 5, None, None], [91, 'z', 3, 2, 0, None], [101, 'z', 3, 2, 1, None], [111, 'A', 2, 1, 1, None], [121, 'c', None, 2, 0, None]]), [[101, None], [11, None], [111, None], [121, 0], [131, None], [141, None], [151, None], [161, None], [171, None], [181, 3], [191, -1], [201, 1], [21, None], [31, 0], [41, 2], [51, 2], [61, -1], [71, None], [81, -2], [91, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[11, None, None, 3, None, None], [21, None, None, 4, None, None], [31, 'x', None, 5, None, None]], [[11, None, None, 2, None, None]]), [[11, None], [21, None], [31, None]])
    check('single known zero and matching reference', solve([[11, 'a', 0, 9, 0, 11]], [[11, 'a', 0, 3, 1, None]]), [[11, None]])
    check('negative-only group and missing measurement', solve([[11, 'n', -2, 4, -1, 11], [21, 'n', None, 2, 0, 21], [31, 'n', -1, 0, 2, None]], [[11, 'n', -2, 1, 1, None]]), [[11, None], [21, -2], [31, None]])
    check('positive-only group with repeated measurements and NULL', solve([[11, 'p', 2, 1, 1, 11], [21, 'p', 2, 2, 1, 11], [31, 'p', 3, 0, 1, 11], [41, 'p', None, 1, 0, None]], [[11, 'p', 2, 1, 1, None], [21, 'p', 2, 1, 1, None]]), [[11, None], [21, 2], [31, 2], [41, 3]])
elif N == 2:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], []), [[102, None], [112, None], [12, None], [122, 0], [132, None], [142, None], [152, None], [162, None], [172, None], [182, 3], [192, -1], [202, 1], [22, None], [32, 0], [42, 2], [52, 2], [62, -1], [72, None], [82, -2], [92, 2]])
    check('references without candidates', solve([], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[12, 'a', None, 8, None, None], [22, 'a', 0, 3, 0, 12], [32, 'a', 2, 1, 1, 22], [42, 'a', 2, 2, 2, 902], [52, 'a', -1, 4, -1, 32], [62, 'a', 3, 1, 1, 42], [72, 'b', -2, 2, 0, 12], [82, 'b', 2, 8, 1, 22], [92, 'b', None, 4, None, None], [102, None, None, 0, 1, 902], [112, None, 0, 5, 0, 12], [122, None, None, 7, None, 22], [132, 'c', None, 6, None, 32], [142, 'd', -1, 1, 0, 42], [152, 'A', 2, 2, 1, 52], [162, ' a ', 2, 8, 1, None], [172, '', None, 2, 0, None], [182, 'a', 2, 8, 1, 12], [192, 'd', 1, 3, 0, 42], [202, 'd', -1, 0, -1, 22]], [[12, 'a', None, 0, 1, None], [22, 'a', 2, 2, 0, None], [32, 'a', 2, 3, 2, None], [42, 'a', 3, 4, None, None], [52, 'b', -2, 2, 1, None], [62, 'b', 0, 8, -1, None], [72, None, None, 2, 1, None], [82, None, 0, 5, None, None], [92, 'z', 3, 2, 0, None], [102, 'z', 3, 2, 1, None], [112, 'A', 2, 1, 1, None], [122, 'c', None, 2, 0, None]]), [[102, None], [112, None], [12, None], [122, 0], [132, None], [142, None], [152, None], [162, None], [172, None], [182, 3], [192, -1], [202, 1], [22, None], [32, 0], [42, 2], [52, 2], [62, -1], [72, None], [82, -2], [92, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[12, None, None, 3, None, None], [22, None, None, 4, None, None], [32, 'x', None, 5, None, None]], [[12, None, None, 2, None, None]]), [[12, None], [22, None], [32, None]])
    check('single known zero and matching reference', solve([[12, 'a', 0, 9, 0, 12]], [[12, 'a', 0, 3, 1, None]]), [[12, None]])
    check('negative-only group and missing measurement', solve([[12, 'n', -2, 4, -1, 12], [22, 'n', None, 2, 0, 22], [32, 'n', -1, 0, 2, None]], [[12, 'n', -2, 1, 1, None]]), [[12, None], [22, -2], [32, None]])
    check('positive-only group with repeated measurements and NULL', solve([[12, 'p', 2, 1, 1, 12], [22, 'p', 2, 2, 1, 12], [32, 'p', 3, 0, 1, 12], [42, 'p', None, 1, 0, None]], [[12, 'p', 2, 1, 1, None], [22, 'p', 2, 1, 1, None]]), [[12, None], [22, 2], [32, 2], [42, 3]])
elif N == 3:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], []), [[103, None], [113, None], [123, 0], [13, None], [133, None], [143, None], [153, None], [163, None], [173, None], [183, 3], [193, -1], [203, 1], [23, None], [33, 0], [43, 2], [53, 2], [63, -1], [73, None], [83, -2], [93, 2]])
    check('references without candidates', solve([], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[13, 'a', None, 8, None, None], [23, 'a', 0, 3, 0, 13], [33, 'a', 2, 1, 1, 23], [43, 'a', 2, 2, 2, 903], [53, 'a', -1, 4, -1, 33], [63, 'a', 3, 1, 1, 43], [73, 'b', -2, 2, 0, 13], [83, 'b', 2, 8, 1, 23], [93, 'b', None, 4, None, None], [103, None, None, 0, 1, 903], [113, None, 0, 5, 0, 13], [123, None, None, 7, None, 23], [133, 'c', None, 6, None, 33], [143, 'd', -1, 1, 0, 43], [153, 'A', 2, 2, 1, 53], [163, ' a ', 2, 8, 1, None], [173, '', None, 2, 0, None], [183, 'a', 2, 8, 1, 13], [193, 'd', 1, 3, 0, 43], [203, 'd', -1, 0, -1, 23]], [[13, 'a', None, 0, 1, None], [23, 'a', 2, 2, 0, None], [33, 'a', 2, 3, 2, None], [43, 'a', 3, 4, None, None], [53, 'b', -2, 2, 1, None], [63, 'b', 0, 8, -1, None], [73, None, None, 2, 1, None], [83, None, 0, 5, None, None], [93, 'z', 3, 2, 0, None], [103, 'z', 3, 2, 1, None], [113, 'A', 2, 1, 1, None], [123, 'c', None, 2, 0, None]]), [[103, None], [113, None], [123, 0], [13, None], [133, None], [143, None], [153, None], [163, None], [173, None], [183, 3], [193, -1], [203, 1], [23, None], [33, 0], [43, 2], [53, 2], [63, -1], [73, None], [83, -2], [93, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[13, None, None, 3, None, None], [23, None, None, 4, None, None], [33, 'x', None, 5, None, None]], [[13, None, None, 2, None, None]]), [[13, None], [23, None], [33, None]])
    check('single known zero and matching reference', solve([[13, 'a', 0, 9, 0, 13]], [[13, 'a', 0, 3, 1, None]]), [[13, None]])
    check('negative-only group and missing measurement', solve([[13, 'n', -2, 4, -1, 13], [23, 'n', None, 2, 0, 23], [33, 'n', -1, 0, 2, None]], [[13, 'n', -2, 1, 1, None]]), [[13, None], [23, -2], [33, None]])
    check('positive-only group with repeated measurements and NULL', solve([[13, 'p', 2, 1, 1, 13], [23, 'p', 2, 2, 1, 13], [33, 'p', 3, 0, 1, 13], [43, 'p', None, 1, 0, None]], [[13, 'p', 2, 1, 1, None], [23, 'p', 2, 1, 1, None]]), [[13, None], [23, 2], [33, 2], [43, 3]])
elif N == 4:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], []), [[104, None], [114, None], [124, 0], [134, None], [14, None], [144, None], [154, None], [164, None], [174, None], [184, 3], [194, -1], [204, 1], [24, None], [34, 0], [44, 2], [54, 2], [64, -1], [74, None], [84, -2], [94, 2]])
    check('references without candidates', solve([], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[14, 'a', None, 8, None, None], [24, 'a', 0, 3, 0, 14], [34, 'a', 2, 1, 1, 24], [44, 'a', 2, 2, 2, 904], [54, 'a', -1, 4, -1, 34], [64, 'a', 3, 1, 1, 44], [74, 'b', -2, 2, 0, 14], [84, 'b', 2, 8, 1, 24], [94, 'b', None, 4, None, None], [104, None, None, 0, 1, 904], [114, None, 0, 5, 0, 14], [124, None, None, 7, None, 24], [134, 'c', None, 6, None, 34], [144, 'd', -1, 1, 0, 44], [154, 'A', 2, 2, 1, 54], [164, ' a ', 2, 8, 1, None], [174, '', None, 2, 0, None], [184, 'a', 2, 8, 1, 14], [194, 'd', 1, 3, 0, 44], [204, 'd', -1, 0, -1, 24]], [[14, 'a', None, 0, 1, None], [24, 'a', 2, 2, 0, None], [34, 'a', 2, 3, 2, None], [44, 'a', 3, 4, None, None], [54, 'b', -2, 2, 1, None], [64, 'b', 0, 8, -1, None], [74, None, None, 2, 1, None], [84, None, 0, 5, None, None], [94, 'z', 3, 2, 0, None], [104, 'z', 3, 2, 1, None], [114, 'A', 2, 1, 1, None], [124, 'c', None, 2, 0, None]]), [[104, None], [114, None], [124, 0], [134, None], [14, None], [144, None], [154, None], [164, None], [174, None], [184, 3], [194, -1], [204, 1], [24, None], [34, 0], [44, 2], [54, 2], [64, -1], [74, None], [84, -2], [94, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[14, None, None, 3, None, None], [24, None, None, 4, None, None], [34, 'x', None, 5, None, None]], [[14, None, None, 2, None, None]]), [[14, None], [24, None], [34, None]])
    check('single known zero and matching reference', solve([[14, 'a', 0, 9, 0, 14]], [[14, 'a', 0, 3, 1, None]]), [[14, None]])
    check('negative-only group and missing measurement', solve([[14, 'n', -2, 4, -1, 14], [24, 'n', None, 2, 0, 24], [34, 'n', -1, 0, 2, None]], [[14, 'n', -2, 1, 1, None]]), [[14, None], [24, -2], [34, None]])
    check('positive-only group with repeated measurements and NULL', solve([[14, 'p', 2, 1, 1, 14], [24, 'p', 2, 2, 1, 14], [34, 'p', 3, 0, 1, 14], [44, 'p', None, 1, 0, None]], [[14, 'p', 2, 1, 1, None], [24, 'p', 2, 1, 1, None]]), [[14, None], [24, 2], [34, 2], [44, 3]])
elif N == 5:
    check('empty relations', solve([], []), [])
    check('left facts without references', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], []), [[105, None], [115, None], [125, 0], [135, None], [145, None], [15, None], [155, None], [165, None], [175, None], [185, 3], [195, -1], [205, 1], [25, None], [35, 0], [45, 2], [55, 2], [65, -1], [75, None], [85, -2], [95, 2]])
    check('references without candidates', solve([], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [])
    check('mixed nullable groups duplicates ties and truth flags', solve([[15, 'a', None, 8, None, None], [25, 'a', 0, 3, 0, 15], [35, 'a', 2, 1, 1, 25], [45, 'a', 2, 2, 2, 905], [55, 'a', -1, 4, -1, 35], [65, 'a', 3, 1, 1, 45], [75, 'b', -2, 2, 0, 15], [85, 'b', 2, 8, 1, 25], [95, 'b', None, 4, None, None], [105, None, None, 0, 1, 905], [115, None, 0, 5, 0, 15], [125, None, None, 7, None, 25], [135, 'c', None, 6, None, 35], [145, 'd', -1, 1, 0, 45], [155, 'A', 2, 2, 1, 55], [165, ' a ', 2, 8, 1, None], [175, '', None, 2, 0, None], [185, 'a', 2, 8, 1, 15], [195, 'd', 1, 3, 0, 45], [205, 'd', -1, 0, -1, 25]], [[15, 'a', None, 0, 1, None], [25, 'a', 2, 2, 0, None], [35, 'a', 2, 3, 2, None], [45, 'a', 3, 4, None, None], [55, 'b', -2, 2, 1, None], [65, 'b', 0, 8, -1, None], [75, None, None, 2, 1, None], [85, None, 0, 5, None, None], [95, 'z', 3, 2, 0, None], [105, 'z', 3, 2, 1, None], [115, 'A', 2, 1, 1, None], [125, 'c', None, 2, 0, None]]), [[105, None], [115, None], [125, 0], [135, None], [145, None], [15, None], [155, None], [165, None], [175, None], [185, 3], [195, -1], [205, 1], [25, None], [35, 0], [45, 2], [55, 2], [65, -1], [75, None], [85, -2], [95, 2]])
    check('unknown-only group with duplicate nullable index keys', solve([[15, None, None, 3, None, None], [25, None, None, 4, None, None], [35, 'x', None, 5, None, None]], [[15, None, None, 2, None, None]]), [[15, None], [25, None], [35, None]])
    check('single known zero and matching reference', solve([[15, 'a', 0, 9, 0, 15]], [[15, 'a', 0, 3, 1, None]]), [[15, None]])
    check('negative-only group and missing measurement', solve([[15, 'n', -2, 4, -1, 15], [25, 'n', None, 2, 0, 25], [35, 'n', -1, 0, 2, None]], [[15, 'n', -2, 1, 1, None]]), [[15, None], [25, -2], [35, None]])
    check('positive-only group with repeated measurements and NULL', solve([[15, 'p', 2, 1, 1, 15], [25, 'p', 2, 2, 1, 15], [35, 'p', 3, 0, 1, 15], [45, 'p', None, 1, 0, None]], [[15, 'p', 2, 1, 1, None], [25, 'p', 2, 1, 1, None]]), [[15, None], [25, 2], [35, 2], [45, 3]])
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)

evaluation_group: xs-previous-value

prompt:
The query violates its result contract: removes unknown values and their output rows before lagging.

Return each ID and previous row v in the same k partition in ID order, with NULL when no predecessor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-next-value

prompt:
The query violates its result contract: reads the predecessor instead of successor.

Return each ID and next row v in the same k partition in ID order, with NULL when no successor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-next-value

prompt:
The query violates its result contract: crosses partition boundaries when reading the successor.

Return each ID and next row v in the same k partition in ID order, with NULL when no successor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-next-value

prompt:
The query violates its result contract: skips the immediate successor.

Return each ID and next row v in the same k partition in ID order, with NULL when no successor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-next-value

prompt:
The query violates its result contract: invents zero beyond the end of a partition.

Return each ID and next row v in the same k partition in ID order, with NULL when no successor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-next-value

prompt:
The query violates its result contract: selects successor in value order instead of identity order.

Return each ID and next row v in the same k partition in ID order, with NULL when no successor exists. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-partition-last-value

prompt:
The query violates its result contract: uses default frame ending at current row.

Return each ID and the v of the last ID in its k partition, including NULL if the final value is unknown. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access


evaluation_group: xs-partition-last-value

prompt:
The query violates its result contract: selects the first partition value.

Return each ID and the v of the last ID in its k partition, including NULL if the final value is unknown. Inputs are finite relations a=rows and b=refs with columns (id,k,v,w,flag,parent). IDs are unique within each relation, None is SQL NULL, keys are ASCII strings or None, and other values are integers or None. Return an unordered result bag as lists sorted by repr, preserving multiplicity unless explicitly distinct.

split: open-access