FA-78096 / Subtitle cue timing / Open access
Adjacent duplicate cue merging: merge gap bound · case 01
Duplicates separated by exactly the allowed gap are not merged.
ROOT CAUSE
The gap bound is exclusive at max_gap.
VERIFIED REPAIR
Merge when the gap from the previous end is at most max_gap.
Unsuccessful approach: Measuring from the previous start ignores the previous duration and rarely merges.
Case contract
Walk cues [start,end,text] in order. Text is normalized by collapsing whitespace runs to single spaces and trimming. A cue whose normalized text is nonempty and equal to the previous output cue text, starting at most max_gap after that cue ends (overlaps included), is merged: the output end becomes the later of the two ends. Output cues carry normalized text.
Why this case matters
Subtitle timing defects shift, hide or overlap captions that viewers depend on for comprehension and accessibility.
1 / The failure
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(cues, max_gap):
out=[]
for s,e,t in cues:
norm=' '.join(t.split())
if out and norm and out[-1][2]==norm and s-out[-1][1]<max_gap:
out[-1][1]=max(out[-1][1],e)
continue
out.append([s,e,norm])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: merge gap bound', [[[0, 500, 'Yes'], [540, 900, 'Yes']], 40], [[0, 900, 'Yes']]), ('regression variant: merge gap bound', [[[500, 1000, 'Yes sir'], [1000, 2000, 'Yes '], [2000, 2500, ' Yes'], [2900, 3000, 'Yes sir']], 0], [[500, 1000, 'Yes sir'], [1000, 2500, 'Yes'], [2900, 3000, 'Yes sir']]), ('partial repair probe: merge gap bound', [[[0, 100, 'Go\nnow'], [100, 1100, 'Yes'], [1200, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go\nnow']], 100], [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']]), ('partial repair variant: merge gap bound', [[[500, 1000, ' Yes'], [1100, 1600, 'Yes sir'], [1699, 2699, 'Yes sir']], 100], [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 1000, 'No'], [1101, 1601, 'Yes sir']], 100], [[500, 1000, 'No'], [1101, 1601, 'Yes sir']]), ('normal control', [[[500, 1000, ''], [1000, 1100, 'Go now']], 100], [[500, 1000, ''], [1000, 1100, 'Go now']]), ('normal control', [[[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']], 100], [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']])], [('regression: merge gap bound', [[[0, 100, 'Go\nnow'], [100, 1100, 'Yes'], [1200, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go\nnow']], 100], [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']]), ('regression variant: merge gap bound', [[[500, 600, 'Yes '], [600, 700, 'Yes sir'], [700, 1700, 'Yes sir'], [1000, 1100, 'Yes'], [400, 900, 'Yes ']], 0], [[500, 600, 'Yes'], [600, 1700, 'Yes sir'], [1000, 1100, 'Yes']]), ('partial repair probe: merge gap bound', [[[0, 500, 'Yes '], [600, 1600, ' Yes'], [1300, 1800, 'Yes '], [1900, 2400, 'Yes '], [2100, 2200, 'Yes sir']], 100], [[0, 2400, 'Yes'], [2100, 2200, 'Yes sir']]), ('partial repair variant: merge gap bound', [[[500, 1000, ' Yes'], [1100, 1600, 'Yes sir'], [1699, 2699, 'Yes sir']], 100], [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('normal control', [[[500, 600, 'Yes sir'], [699, 1199, 'Go\nnow'], [1299, 2299, 'Yes '], [1999, 2999, 'Yes sir']], 100], [[500, 600, 'Yes sir'], [699, 1199, 'Go now'], [1299, 2299, 'Yes'], [1999, 2999, 'Yes sir']]), ('normal control', [[[500, 1000, 'No'], [1099, 1599, 'Go now'], [1700, 1800, ' '], [1899, 1999, '']], 100], [[500, 1000, 'No'], [1099, 1599, 'Go now'], [1700, 1800, ''], [1899, 1999, '']]), ('normal control', [[[0, 500, 'Yes sir'], [-200, -100, ' '], [1, 101, 'Go\nnow'], [501, 601, 'Yes'], [700, 1700, 'Go now']], 100], [[0, 500, 'Yes sir'], [-200, -100, ''], [1, 101, 'Go now'], [501, 601, 'Yes'], [700, 1700, 'Go now']])], [('regression: merge gap bound', [[[0, 500, 'Yes '], [600, 1600, ' Yes'], [1300, 1800, 'Yes '], [1900, 2400, 'Yes '], [2100, 2200, 'Yes sir']], 100], [[0, 2400, 'Yes'], [2100, 2200, 'Yes sir']]), ('regression variant: merge gap bound', [[[500, 600, 'Yes '], [600, 1600, ' Yes'], [2000, 2100, 'Go\nnow'], [1800, 2300, 'Go\nnow'], [2700, 3700, '']], 0], [[500, 1600, 'Yes'], [2000, 2300, 'Go now'], [2700, 3700, '']]), ('partial repair probe: merge gap bound', [[[500, 1000, ' '], [700, 1200, ' Yes'], [1200, 1300, 'Yes '], [1301, 1401, ''], [1401, 2401, 'No']], 0], [[500, 1000, ''], [700, 1300, 'Yes'], [1301, 1401, ''], [1401, 2401, 'No']]), ('partial repair variant: merge gap bound', [[[500, 600, 'Yes'], [639, 739, 'Yes sir'], [439, 1439, 'Yes'], [1439, 1539, 'Yes'], [1239, 2239, ''], [2278, 3278, 'Yes sir']], 40], [[500, 600, 'Yes'], [639, 739, 'Yes sir'], [439, 1539, 'Yes'], [1239, 2239, ''], [2278, 3278, 'Yes sir']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 600, ' '], [601, 1601, 'Yes '], [2001, 2101, 'Yes '], [2100, 2600, 'Go\nnow'], [2599, 2699, 'Yes '], [2699, 3699, 'Go now']], 0], [[500, 600, ''], [601, 1601, 'Yes'], [2001, 2101, 'Yes'], [2100, 2600, 'Go now'], [2599, 2699, 'Yes'], [2699, 3699, 'Go now']]), ('normal control', [[[0, 1000, ' Yes'], [1400, 1900, 'No']], 100], [[0, 1000, 'Yes'], [1400, 1900, 'No']]), ('normal control', [[[0, 1000, 'Yes'], [1041, 2041, ''], [2041, 2541, 'No']], 40], [[0, 1000, 'Yes'], [1041, 2041, ''], [2041, 2541, 'No']])], [('regression: merge gap bound', [[[500, 1000, ' '], [700, 1200, ' Yes'], [1200, 1300, 'Yes '], [1301, 1401, ''], [1401, 2401, 'No']], 0], [[500, 1000, ''], [700, 1300, 'Yes'], [1301, 1401, ''], [1401, 2401, 'No']]), ('regression variant: merge gap bound', [[[0, 1000, ' Yes'], [1100, 1600, ' Yes'], [1300, 1800, 'Yes sir'], [2200, 2300, ' ']], 100], [[0, 1600, 'Yes'], [1300, 1800, 'Yes sir'], [2200, 2300, '']]), ('partial repair probe: merge gap bound', [[[0, 500, ' Yes'], [900, 1900, 'Yes '], [2300, 2800, 'Go now'], [3200, 3700, ' Yes'], [3799, 4799, 'Yes'], [4799, 4899, ' ']], 100], [[0, 500, 'Yes'], [900, 1900, 'Yes'], [2300, 2800, 'Go now'], [3200, 4799, 'Yes'], [4799, 4899, '']]), ('partial repair variant: merge gap bound', [[[500, 1500, 'Yes sir'], [800, 1800, 'Yes '], [1799, 2299, ' Yes'], [1599, 1699, ''], [2099, 3099, 'No'], [2799, 3299, '']], 0], [[500, 1500, 'Yes sir'], [800, 2299, 'Yes'], [1599, 1699, ''], [2099, 3099, 'No'], [2799, 3299, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('normal control', [[[0, 500, 'Go\nnow'], [200, 700, 'Yes sir'], [801, 1801, 'Go\nnow'], [1901, 2401, 'Yes sir'], [1701, 1801, 'Yes ']], 100], [[0, 500, 'Go now'], [200, 700, 'Yes sir'], [801, 1801, 'Go now'], [1901, 2401, 'Yes sir'], [1701, 1801, 'Yes']]), ('normal control', [[[0, 100, ' Yes'], [100, 1100, 'Go now']], 0], [[0, 100, 'Yes'], [100, 1100, 'Go now']]), ('normal control', [[[0, 100, 'Yes sir']], 40], [[0, 100, 'Yes sir']])], [('regression: merge gap bound', [[[500, 1000, ' Yes'], [1041, 2041, 'No'], [1341, 1841, 'Yes '], [1881, 2881, ' Yes'], [2922, 3922, 'Yes ']], 40], [[500, 1000, 'Yes'], [1041, 2041, 'No'], [1341, 2881, 'Yes'], [2922, 3922, 'Yes']]), ('regression variant: merge gap bound', [[[500, 1000, 'Yes'], [1400, 1500, 'Yes'], [1540, 2540, 'Yes'], [2940, 3940, 'Yes sir'], [3640, 3740, 'No'], [3781, 4781, 'No']], 40], [[500, 1000, 'Yes'], [1400, 2540, 'Yes'], [2940, 3940, 'Yes sir'], [3640, 3740, 'No'], [3781, 4781, 'No']]), ('partial repair probe: merge gap bound', [[[500, 1500, 'Yes sir'], [1539, 2539, 'Yes sir']], 40], [[500, 2539, 'Yes sir']]), ('partial repair variant: merge gap bound', [[[500, 600, 'No'], [640, 1140, 'Yes sir'], [1140, 2140, 'Yes sir'], [2179, 2279, 'Go\nnow']], 40], [[500, 600, 'No'], [640, 2140, 'Yes sir'], [2179, 2279, 'Go now']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 1500, 'No']], 40], [[500, 1500, 'No']]), ('normal control', [[[0, 1000, 'Yes sir']], 0], [[0, 1000, 'Yes sir']]), ('normal control', [[[0, 500, 'Yes ']], 100], [[0, 500, 'Yes']])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: merge gap bound | [[0, 500, 'Yes'], [540, 900, 'Yes']] | [[0, 900, 'Yes']] | Failed |
| regression variant: merge gap bound | [[500, 1000, 'Yes sir'], [1000, 2000, 'Yes'], [2000, 2500, 'Yes'], [2900, 3000, 'Yes sir']] | [[500, 1000, 'Yes sir'], [1000, 2500, 'Yes'], [2900, 3000, 'Yes sir']] | Failed |
| partial repair probe: merge gap bound | [[0, 100, 'Go now'], [100, 1100, 'Yes'], [1200, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']] | [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']] | Failed |
| partial repair variant: merge gap bound | [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']] | [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']] | Passed |
| boundary control | [[0, 100, ''], [100, 200, '']] | [[0, 100, ''], [100, 200, '']] | Passed |
| boundary control | [[0, 100, 'A'], [150, 200, 'A']] | [[0, 100, 'A'], [150, 200, 'A']] | Passed |
| normal control | [[500, 1000, 'No'], [1101, 1601, 'Yes sir']] | [[500, 1000, 'No'], [1101, 1601, 'Yes sir']] | Passed |
| normal control | [[500, 1000, ''], [1000, 1100, 'Go now']] | [[500, 1000, ''], [1000, 1100, 'Go now']] | Passed |
| normal control | [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']] | [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']] | Passed |
SHA-256 / c73665145a1f3e362fac05799f64200d9568ef42cf2c58ed1478aad55375daf2
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(cues, max_gap):
out=[]
for s,e,t in cues:
norm=' '.join(t.split())
if out and norm and out[-1][2]==norm and s-out[-1][0]<=max_gap:
out[-1][1]=max(out[-1][1],e)
continue
out.append([s,e,norm])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: merge gap bound', [[[0, 500, 'Yes'], [540, 900, 'Yes']], 40], [[0, 900, 'Yes']]), ('regression variant: merge gap bound', [[[500, 1000, 'Yes sir'], [1000, 2000, 'Yes '], [2000, 2500, ' Yes'], [2900, 3000, 'Yes sir']], 0], [[500, 1000, 'Yes sir'], [1000, 2500, 'Yes'], [2900, 3000, 'Yes sir']]), ('partial repair probe: merge gap bound', [[[0, 100, 'Go\nnow'], [100, 1100, 'Yes'], [1200, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go\nnow']], 100], [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']]), ('partial repair variant: merge gap bound', [[[500, 1000, ' Yes'], [1100, 1600, 'Yes sir'], [1699, 2699, 'Yes sir']], 100], [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 1000, 'No'], [1101, 1601, 'Yes sir']], 100], [[500, 1000, 'No'], [1101, 1601, 'Yes sir']]), ('normal control', [[[500, 1000, ''], [1000, 1100, 'Go now']], 100], [[500, 1000, ''], [1000, 1100, 'Go now']]), ('normal control', [[[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']], 100], [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']])], [('regression: merge gap bound', [[[0, 100, 'Go\nnow'], [100, 1100, 'Yes'], [1200, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go\nnow']], 100], [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']]), ('regression variant: merge gap bound', [[[500, 600, 'Yes '], [600, 700, 'Yes sir'], [700, 1700, 'Yes sir'], [1000, 1100, 'Yes'], [400, 900, 'Yes ']], 0], [[500, 600, 'Yes'], [600, 1700, 'Yes sir'], [1000, 1100, 'Yes']]), ('partial repair probe: merge gap bound', [[[0, 500, 'Yes '], [600, 1600, ' Yes'], [1300, 1800, 'Yes '], [1900, 2400, 'Yes '], [2100, 2200, 'Yes sir']], 100], [[0, 2400, 'Yes'], [2100, 2200, 'Yes sir']]), ('partial repair variant: merge gap bound', [[[500, 1000, ' Yes'], [1100, 1600, 'Yes sir'], [1699, 2699, 'Yes sir']], 100], [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('normal control', [[[500, 600, 'Yes sir'], [699, 1199, 'Go\nnow'], [1299, 2299, 'Yes '], [1999, 2999, 'Yes sir']], 100], [[500, 600, 'Yes sir'], [699, 1199, 'Go now'], [1299, 2299, 'Yes'], [1999, 2999, 'Yes sir']]), ('normal control', [[[500, 1000, 'No'], [1099, 1599, 'Go now'], [1700, 1800, ' '], [1899, 1999, '']], 100], [[500, 1000, 'No'], [1099, 1599, 'Go now'], [1700, 1800, ''], [1899, 1999, '']]), ('normal control', [[[0, 500, 'Yes sir'], [-200, -100, ' '], [1, 101, 'Go\nnow'], [501, 601, 'Yes'], [700, 1700, 'Go now']], 100], [[0, 500, 'Yes sir'], [-200, -100, ''], [1, 101, 'Go now'], [501, 601, 'Yes'], [700, 1700, 'Go now']])], [('regression: merge gap bound', [[[0, 500, 'Yes '], [600, 1600, ' Yes'], [1300, 1800, 'Yes '], [1900, 2400, 'Yes '], [2100, 2200, 'Yes sir']], 100], [[0, 2400, 'Yes'], [2100, 2200, 'Yes sir']]), ('regression variant: merge gap bound', [[[500, 600, 'Yes '], [600, 1600, ' Yes'], [2000, 2100, 'Go\nnow'], [1800, 2300, 'Go\nnow'], [2700, 3700, '']], 0], [[500, 1600, 'Yes'], [2000, 2300, 'Go now'], [2700, 3700, '']]), ('partial repair probe: merge gap bound', [[[500, 1000, ' '], [700, 1200, ' Yes'], [1200, 1300, 'Yes '], [1301, 1401, ''], [1401, 2401, 'No']], 0], [[500, 1000, ''], [700, 1300, 'Yes'], [1301, 1401, ''], [1401, 2401, 'No']]), ('partial repair variant: merge gap bound', [[[500, 600, 'Yes'], [639, 739, 'Yes sir'], [439, 1439, 'Yes'], [1439, 1539, 'Yes'], [1239, 2239, ''], [2278, 3278, 'Yes sir']], 40], [[500, 600, 'Yes'], [639, 739, 'Yes sir'], [439, 1539, 'Yes'], [1239, 2239, ''], [2278, 3278, 'Yes sir']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 600, ' '], [601, 1601, 'Yes '], [2001, 2101, 'Yes '], [2100, 2600, 'Go\nnow'], [2599, 2699, 'Yes '], [2699, 3699, 'Go now']], 0], [[500, 600, ''], [601, 1601, 'Yes'], [2001, 2101, 'Yes'], [2100, 2600, 'Go now'], [2599, 2699, 'Yes'], [2699, 3699, 'Go now']]), ('normal control', [[[0, 1000, ' Yes'], [1400, 1900, 'No']], 100], [[0, 1000, 'Yes'], [1400, 1900, 'No']]), ('normal control', [[[0, 1000, 'Yes'], [1041, 2041, ''], [2041, 2541, 'No']], 40], [[0, 1000, 'Yes'], [1041, 2041, ''], [2041, 2541, 'No']])], [('regression: merge gap bound', [[[500, 1000, ' '], [700, 1200, ' Yes'], [1200, 1300, 'Yes '], [1301, 1401, ''], [1401, 2401, 'No']], 0], [[500, 1000, ''], [700, 1300, 'Yes'], [1301, 1401, ''], [1401, 2401, 'No']]), ('regression variant: merge gap bound', [[[0, 1000, ' Yes'], [1100, 1600, ' Yes'], [1300, 1800, 'Yes sir'], [2200, 2300, ' ']], 100], [[0, 1600, 'Yes'], [1300, 1800, 'Yes sir'], [2200, 2300, '']]), ('partial repair probe: merge gap bound', [[[0, 500, ' Yes'], [900, 1900, 'Yes '], [2300, 2800, 'Go now'], [3200, 3700, ' Yes'], [3799, 4799, 'Yes'], [4799, 4899, ' ']], 100], [[0, 500, 'Yes'], [900, 1900, 'Yes'], [2300, 2800, 'Go now'], [3200, 4799, 'Yes'], [4799, 4899, '']]), ('partial repair variant: merge gap bound', [[[500, 1500, 'Yes sir'], [800, 1800, 'Yes '], [1799, 2299, ' Yes'], [1599, 1699, ''], [2099, 3099, 'No'], [2799, 3299, '']], 0], [[500, 1500, 'Yes sir'], [800, 2299, 'Yes'], [1599, 1699, ''], [2099, 3099, 'No'], [2799, 3299, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('normal control', [[[0, 500, 'Go\nnow'], [200, 700, 'Yes sir'], [801, 1801, 'Go\nnow'], [1901, 2401, 'Yes sir'], [1701, 1801, 'Yes ']], 100], [[0, 500, 'Go now'], [200, 700, 'Yes sir'], [801, 1801, 'Go now'], [1901, 2401, 'Yes sir'], [1701, 1801, 'Yes']]), ('normal control', [[[0, 100, ' Yes'], [100, 1100, 'Go now']], 0], [[0, 100, 'Yes'], [100, 1100, 'Go now']]), ('normal control', [[[0, 100, 'Yes sir']], 40], [[0, 100, 'Yes sir']])], [('regression: merge gap bound', [[[500, 1000, ' Yes'], [1041, 2041, 'No'], [1341, 1841, 'Yes '], [1881, 2881, ' Yes'], [2922, 3922, 'Yes ']], 40], [[500, 1000, 'Yes'], [1041, 2041, 'No'], [1341, 2881, 'Yes'], [2922, 3922, 'Yes']]), ('regression variant: merge gap bound', [[[500, 1000, 'Yes'], [1400, 1500, 'Yes'], [1540, 2540, 'Yes'], [2940, 3940, 'Yes sir'], [3640, 3740, 'No'], [3781, 4781, 'No']], 40], [[500, 1000, 'Yes'], [1400, 2540, 'Yes'], [2940, 3940, 'Yes sir'], [3640, 3740, 'No'], [3781, 4781, 'No']]), ('partial repair probe: merge gap bound', [[[500, 1500, 'Yes sir'], [1539, 2539, 'Yes sir']], 40], [[500, 2539, 'Yes sir']]), ('partial repair variant: merge gap bound', [[[500, 600, 'No'], [640, 1140, 'Yes sir'], [1140, 2140, 'Yes sir'], [2179, 2279, 'Go\nnow']], 40], [[500, 600, 'No'], [640, 2140, 'Yes sir'], [2179, 2279, 'Go now']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 1500, 'No']], 40], [[500, 1500, 'No']]), ('normal control', [[[0, 1000, 'Yes sir']], 0], [[0, 1000, 'Yes sir']]), ('normal control', [[[0, 500, 'Yes ']], 100], [[0, 500, 'Yes']])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: merge gap bound | [[0, 500, 'Yes'], [540, 900, 'Yes']] | [[0, 900, 'Yes']] | Failed |
| regression variant: merge gap bound | [[500, 1000, 'Yes sir'], [1000, 2000, 'Yes'], [2000, 2500, 'Yes'], [2900, 3000, 'Yes sir']] | [[500, 1000, 'Yes sir'], [1000, 2500, 'Yes'], [2900, 3000, 'Yes sir']] | Failed |
| partial repair probe: merge gap bound | [[0, 100, 'Go now'], [100, 1100, 'Yes'], [1200, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']] | [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']] | Failed |
| partial repair variant: merge gap bound | [[500, 1000, 'Yes'], [1100, 1600, 'Yes sir'], [1699, 2699, 'Yes sir']] | [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']] | Failed |
| boundary control | [[0, 100, ''], [100, 200, '']] | [[0, 100, ''], [100, 200, '']] | Passed |
| boundary control | [[0, 100, 'A'], [150, 200, 'A']] | [[0, 100, 'A'], [150, 200, 'A']] | Passed |
| normal control | [[500, 1000, 'No'], [1101, 1601, 'Yes sir']] | [[500, 1000, 'No'], [1101, 1601, 'Yes sir']] | Passed |
| normal control | [[500, 1000, ''], [1000, 1100, 'Go now']] | [[500, 1000, ''], [1000, 1100, 'Go now']] | Passed |
| normal control | [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']] | [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']] | Passed |
SHA-256 / f9dd4265a7e96a7a83e93fc0216c6933043f54f7db7d79d2560622f7524434be
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(cues, max_gap):
out=[]
for s,e,t in cues:
norm=' '.join(t.split())
if out and norm and out[-1][2]==norm and s-out[-1][1]<=max_gap:
out[-1][1]=max(out[-1][1],e)
continue
out.append([s,e,norm])
return out
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: merge gap bound', [[[0, 500, 'Yes'], [540, 900, 'Yes']], 40], [[0, 900, 'Yes']]), ('regression variant: merge gap bound', [[[500, 1000, 'Yes sir'], [1000, 2000, 'Yes '], [2000, 2500, ' Yes'], [2900, 3000, 'Yes sir']], 0], [[500, 1000, 'Yes sir'], [1000, 2500, 'Yes'], [2900, 3000, 'Yes sir']]), ('partial repair probe: merge gap bound', [[[0, 100, 'Go\nnow'], [100, 1100, 'Yes'], [1200, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go\nnow']], 100], [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']]), ('partial repair variant: merge gap bound', [[[500, 1000, ' Yes'], [1100, 1600, 'Yes sir'], [1699, 2699, 'Yes sir']], 100], [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 1000, 'No'], [1101, 1601, 'Yes sir']], 100], [[500, 1000, 'No'], [1101, 1601, 'Yes sir']]), ('normal control', [[[500, 1000, ''], [1000, 1100, 'Go now']], 100], [[500, 1000, ''], [1000, 1100, 'Go now']]), ('normal control', [[[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']], 100], [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']])], [('regression: merge gap bound', [[[0, 100, 'Go\nnow'], [100, 1100, 'Yes'], [1200, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go\nnow']], 100], [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']]), ('regression variant: merge gap bound', [[[500, 600, 'Yes '], [600, 700, 'Yes sir'], [700, 1700, 'Yes sir'], [1000, 1100, 'Yes'], [400, 900, 'Yes ']], 0], [[500, 600, 'Yes'], [600, 1700, 'Yes sir'], [1000, 1100, 'Yes']]), ('partial repair probe: merge gap bound', [[[0, 500, 'Yes '], [600, 1600, ' Yes'], [1300, 1800, 'Yes '], [1900, 2400, 'Yes '], [2100, 2200, 'Yes sir']], 100], [[0, 2400, 'Yes'], [2100, 2200, 'Yes sir']]), ('partial repair variant: merge gap bound', [[[500, 1000, ' Yes'], [1100, 1600, 'Yes sir'], [1699, 2699, 'Yes sir']], 100], [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('normal control', [[[500, 600, 'Yes sir'], [699, 1199, 'Go\nnow'], [1299, 2299, 'Yes '], [1999, 2999, 'Yes sir']], 100], [[500, 600, 'Yes sir'], [699, 1199, 'Go now'], [1299, 2299, 'Yes'], [1999, 2999, 'Yes sir']]), ('normal control', [[[500, 1000, 'No'], [1099, 1599, 'Go now'], [1700, 1800, ' '], [1899, 1999, '']], 100], [[500, 1000, 'No'], [1099, 1599, 'Go now'], [1700, 1800, ''], [1899, 1999, '']]), ('normal control', [[[0, 500, 'Yes sir'], [-200, -100, ' '], [1, 101, 'Go\nnow'], [501, 601, 'Yes'], [700, 1700, 'Go now']], 100], [[0, 500, 'Yes sir'], [-200, -100, ''], [1, 101, 'Go now'], [501, 601, 'Yes'], [700, 1700, 'Go now']])], [('regression: merge gap bound', [[[0, 500, 'Yes '], [600, 1600, ' Yes'], [1300, 1800, 'Yes '], [1900, 2400, 'Yes '], [2100, 2200, 'Yes sir']], 100], [[0, 2400, 'Yes'], [2100, 2200, 'Yes sir']]), ('regression variant: merge gap bound', [[[500, 600, 'Yes '], [600, 1600, ' Yes'], [2000, 2100, 'Go\nnow'], [1800, 2300, 'Go\nnow'], [2700, 3700, '']], 0], [[500, 1600, 'Yes'], [2000, 2300, 'Go now'], [2700, 3700, '']]), ('partial repair probe: merge gap bound', [[[500, 1000, ' '], [700, 1200, ' Yes'], [1200, 1300, 'Yes '], [1301, 1401, ''], [1401, 2401, 'No']], 0], [[500, 1000, ''], [700, 1300, 'Yes'], [1301, 1401, ''], [1401, 2401, 'No']]), ('partial repair variant: merge gap bound', [[[500, 600, 'Yes'], [639, 739, 'Yes sir'], [439, 1439, 'Yes'], [1439, 1539, 'Yes'], [1239, 2239, ''], [2278, 3278, 'Yes sir']], 40], [[500, 600, 'Yes'], [639, 739, 'Yes sir'], [439, 1539, 'Yes'], [1239, 2239, ''], [2278, 3278, 'Yes sir']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 600, ' '], [601, 1601, 'Yes '], [2001, 2101, 'Yes '], [2100, 2600, 'Go\nnow'], [2599, 2699, 'Yes '], [2699, 3699, 'Go now']], 0], [[500, 600, ''], [601, 1601, 'Yes'], [2001, 2101, 'Yes'], [2100, 2600, 'Go now'], [2599, 2699, 'Yes'], [2699, 3699, 'Go now']]), ('normal control', [[[0, 1000, ' Yes'], [1400, 1900, 'No']], 100], [[0, 1000, 'Yes'], [1400, 1900, 'No']]), ('normal control', [[[0, 1000, 'Yes'], [1041, 2041, ''], [2041, 2541, 'No']], 40], [[0, 1000, 'Yes'], [1041, 2041, ''], [2041, 2541, 'No']])], [('regression: merge gap bound', [[[500, 1000, ' '], [700, 1200, ' Yes'], [1200, 1300, 'Yes '], [1301, 1401, ''], [1401, 2401, 'No']], 0], [[500, 1000, ''], [700, 1300, 'Yes'], [1301, 1401, ''], [1401, 2401, 'No']]), ('regression variant: merge gap bound', [[[0, 1000, ' Yes'], [1100, 1600, ' Yes'], [1300, 1800, 'Yes sir'], [2200, 2300, ' ']], 100], [[0, 1600, 'Yes'], [1300, 1800, 'Yes sir'], [2200, 2300, '']]), ('partial repair probe: merge gap bound', [[[0, 500, ' Yes'], [900, 1900, 'Yes '], [2300, 2800, 'Go now'], [3200, 3700, ' Yes'], [3799, 4799, 'Yes'], [4799, 4899, ' ']], 100], [[0, 500, 'Yes'], [900, 1900, 'Yes'], [2300, 2800, 'Go now'], [3200, 4799, 'Yes'], [4799, 4899, '']]), ('partial repair variant: merge gap bound', [[[500, 1500, 'Yes sir'], [800, 1800, 'Yes '], [1799, 2299, ' Yes'], [1599, 1699, ''], [2099, 3099, 'No'], [2799, 3299, '']], 0], [[500, 1500, 'Yes sir'], [800, 2299, 'Yes'], [1599, 1699, ''], [2099, 3099, 'No'], [2799, 3299, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('normal control', [[[0, 500, 'Go\nnow'], [200, 700, 'Yes sir'], [801, 1801, 'Go\nnow'], [1901, 2401, 'Yes sir'], [1701, 1801, 'Yes ']], 100], [[0, 500, 'Go now'], [200, 700, 'Yes sir'], [801, 1801, 'Go now'], [1901, 2401, 'Yes sir'], [1701, 1801, 'Yes']]), ('normal control', [[[0, 100, ' Yes'], [100, 1100, 'Go now']], 0], [[0, 100, 'Yes'], [100, 1100, 'Go now']]), ('normal control', [[[0, 100, 'Yes sir']], 40], [[0, 100, 'Yes sir']])], [('regression: merge gap bound', [[[500, 1000, ' Yes'], [1041, 2041, 'No'], [1341, 1841, 'Yes '], [1881, 2881, ' Yes'], [2922, 3922, 'Yes ']], 40], [[500, 1000, 'Yes'], [1041, 2041, 'No'], [1341, 2881, 'Yes'], [2922, 3922, 'Yes']]), ('regression variant: merge gap bound', [[[500, 1000, 'Yes'], [1400, 1500, 'Yes'], [1540, 2540, 'Yes'], [2940, 3940, 'Yes sir'], [3640, 3740, 'No'], [3781, 4781, 'No']], 40], [[500, 1000, 'Yes'], [1400, 2540, 'Yes'], [2940, 3940, 'Yes sir'], [3640, 3740, 'No'], [3781, 4781, 'No']]), ('partial repair probe: merge gap bound', [[[500, 1500, 'Yes sir'], [1539, 2539, 'Yes sir']], 40], [[500, 2539, 'Yes sir']]), ('partial repair variant: merge gap bound', [[[500, 600, 'No'], [640, 1140, 'Yes sir'], [1140, 2140, 'Yes sir'], [2179, 2279, 'Go\nnow']], 40], [[500, 600, 'No'], [640, 2140, 'Yes sir'], [2179, 2279, 'Go now']]), ('boundary control', [[[0, 100, ' '], [100, 200, ' ']], 0], [[0, 100, ''], [100, 200, '']]), ('boundary control', [[[0, 100, 'A'], [150, 200, 'A']], 40], [[0, 100, 'A'], [150, 200, 'A']]), ('normal control', [[[500, 1500, 'No']], 40], [[500, 1500, 'No']]), ('normal control', [[[0, 1000, 'Yes sir']], 0], [[0, 1000, 'Yes sir']]), ('normal control', [[[0, 500, 'Yes ']], 100], [[0, 500, 'Yes']])]]
for label, args, expected in fixtures[N-1]:
check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
| Boundary fixture | Actual | Expected | Outcome |
|---|---|---|---|
| regression: merge gap bound | [[0, 900, 'Yes']] | [[0, 900, 'Yes']] | Passed |
| regression variant: merge gap bound | [[500, 1000, 'Yes sir'], [1000, 2500, 'Yes'], [2900, 3000, 'Yes sir']] | [[500, 1000, 'Yes sir'], [1000, 2500, 'Yes'], [2900, 3000, 'Yes sir']] | Passed |
| partial repair probe: merge gap bound | [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']] | [[0, 100, 'Go now'], [100, 1700, 'Yes'], [1799, 1899, 'No'], [1599, 2099, 'Go now']] | Passed |
| partial repair variant: merge gap bound | [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']] | [[500, 1000, 'Yes'], [1100, 2699, 'Yes sir']] | Passed |
| boundary control | [[0, 100, ''], [100, 200, '']] | [[0, 100, ''], [100, 200, '']] | Passed |
| boundary control | [[0, 100, 'A'], [150, 200, 'A']] | [[0, 100, 'A'], [150, 200, 'A']] | Passed |
| normal control | [[500, 1000, 'No'], [1101, 1601, 'Yes sir']] | [[500, 1000, 'No'], [1101, 1601, 'Yes sir']] | Passed |
| normal control | [[500, 1000, ''], [1000, 1100, 'Go now']] | [[500, 1000, ''], [1000, 1100, 'Go now']] | Passed |
| normal control | [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']] | [[0, 1000, 'Yes sir'], [1000, 1100, ''], [800, 900, 'Yes sir']] | Passed |
SHA-256 / d686d59668503c37da1301e2fb8d0e5b9cb170b8686ac1da5d601f4da739c35f
Verification & scope
A deterministic bounded teaching model with a stipulated toy contract; it does not claim conformance to any subtitle standard. This reproducer isolates one failure mechanism. Results cover the supplied fixtures. Variants within a family share a test contract and should remain grouped when constructing evaluation splits. Related mechanisms with a shared evaluation_group must also remain together; these controlled models are not independent production incidents.
Observations recorded using Python 3.12.14 at 2026-09-29T14:49:32.056822+00:00.
Case digest / 1d52dac27790e7f8dc7cfc57a77a21d90bc6af9eb3843060254b35ef4d85215f