FAILURE MAP
← Case archive

FA-78641 / Broadcast timecode arithmetic / Open access

Programme-relative signed timecode: shorter-way selection · case 01

Bars before the programme start show as nearly 24 hours into the programme.

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

ROOT CAUSE

The wrapped offset is never folded to the negative side.

VERIFIED REPAIR

Fold offsets of half a day or more to negative.

Unsuccessful approach: Folding only when the label is numerically smaller misses negative offsets across midnight.

Case contract

Express label tc relative to programme start as "+HH:MM:SS:FF" or "-HH:MM:SS:FF" along the shorter way round the 24-hour clock (an offset of exactly 12 hours is negative). Zero is "+".

Why this case matters

Timecode arithmetic errors misplace edits, commercial breaks and captions against the broadcast clock.

1 / The failure

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

N = 1
observations = []
def solve(tc, start, fps):
    def fr(t):
        h,m,s,f=map(int,t.split(':'))
        return ((h*60+m)*60+s)*fps+f
    day=86400*fps
    d=(fr(tc)-fr(start))%day
    if d>=day:
        d-=day
    sign='-' if d<0 else '+'
    a=abs(d)
    return '%s%02d:%02d:%02d:%02d'%(sign,a//(3600*fps),a//(60*fps)%60,a//fps%60,a%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: shorter-way selection', ['00:59:30:00', '01:00:00:00', 25], '-00:00:30:00'), ('regression variant: shorter-way selection', ['23:00:59:15', '00:00:10:00', 30], '-00:59:10:15'), ('partial repair probe: shorter-way selection', ['23:59:59:15', '01:00:00:00', 30], '-01:00:00:15'), ('partial repair variant: shorter-way selection', ['23:01:01:12', '00:00:10:00', 25], '-00:59:08:13'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('normal control', ['00:59:30:00', '00:00:10:00', 25], '+00:59:20:00'), ('normal control', ['01:01:01:01', '01:00:00:00', 25], '+00:01:01:01')], [('regression: shorter-way selection', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('regression variant: shorter-way selection', ['00:00:00:00', '00:00:10:00', 25], '-00:00:10:00'), ('partial repair probe: shorter-way selection', ['23:59:59:15', '01:00:00:00', 30], '-01:00:00:15'), ('partial repair variant: shorter-way selection', ['23:59:00:00', '00:00:10:00', 30], '-00:01:10:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('normal control', ['00:59:30:00', '00:00:10:00', 30], '+00:59:20:00'), ('normal control', ['10:59:59:15', '01:00:00:00', 30], '+09:59:59:15'), ('normal control', ['01:01:01:00', '23:59:00:00', 25], '+01:02:01:00')], [('regression: shorter-way selection', ['22:00:00:00', '10:00:00:00', 30], '-12:00:00:00'), ('regression variant: shorter-way selection', ['00:01:59:15', '01:00:00:00', 30], '-00:58:00:15'), ('partial repair probe: shorter-way selection', ['12:59:59:24', '00:00:10:00', 30], '-11:00:10:06'), ('partial repair variant: shorter-way selection', ['23:29:30:15', '00:00:10:00', 30], '-00:30:39:15'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:01:30:01', '01:00:00:00', 30], '+00:01:30:01'), ('normal control', ['01:00:00:00', '23:59:00:00', 30], '+01:01:00:00'), ('normal control', ['10:29:59:24', '00:00:10:00', 25], '+10:29:49:24')], [('regression: shorter-way selection', ['12:59:59:24', '23:59:00:00', 25], '-10:59:00:01'), ('regression variant: shorter-way selection', ['01:00:00:01', '10:00:00:00', 25], '-08:59:59:24'), ('partial repair probe: shorter-way selection', ['23:01:59:12', '10:00:00:00', 25], '-10:58:00:13'), ('partial repair variant: shorter-way selection', ['23:59:00:15', '10:00:00:00', 30], '-10:00:59:15'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('normal control', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('normal control', ['10:59:30:15', '10:00:00:00', 30], '+00:59:30:15'), ('normal control', ['10:00:30:00', '01:00:00:00', 25], '+09:00:30:00')], [('regression: shorter-way selection', ['01:00:01:01', '10:00:00:00', 30], '-08:59:58:29'), ('regression variant: shorter-way selection', ['00:00:00:00', '01:00:00:00', 30], '-01:00:00:00'), ('partial repair probe: shorter-way selection', ['23:29:30:00', '10:00:00:00', 30], '-10:30:30:00'), ('partial repair variant: shorter-way selection', ['23:59:50:00', '00:00:10:00', 30], '-00:00:20:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['10:29:30:01', '01:00:00:00', 25], '+09:29:30:01'), ('normal control', ['11:59:59:00', '01:00:00:00', 30], '+10:59:59:00'), ('normal control', ['10:01:59:01', '23:59:00:00', 30], '+10:02:59:01')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: shorter-way selection+23:59:30:00-00:00:30:00Failed
regression variant: shorter-way selection+23:00:49:15-00:59:10:15Failed
partial repair probe: shorter-way selection+22:59:59:15-01:00:00:15Failed
partial repair variant: shorter-way selection+23:00:51:12-00:59:08:13Failed
boundary control+00:02:00:00+00:02:00:00Passed
boundary control+00:00:00:00+00:00:00:00Passed
normal control+02:00:59:29+02:00:59:29Passed
normal control+00:59:20:00+00:59:20:00Passed
normal control+00:01:01:01+00:01:01:01Passed

SHA-256 / 69946a7b31f6ab506208cfe60a76092caef4d67fa7ccedc3a7c1852690bc8a90

2 / The unsuccessful fix

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

N = 1
observations = []
def solve(tc, start, fps):
    def fr(t):
        h,m,s,f=map(int,t.split(':'))
        return ((h*60+m)*60+s)*fps+f
    day=86400*fps
    d=(fr(tc)-fr(start))%day
    if d>=day//2 and fr(tc)<fr(start):
        d-=day
    sign='-' if d<0 else '+'
    a=abs(d)
    return '%s%02d:%02d:%02d:%02d'%(sign,a//(3600*fps),a//(60*fps)%60,a//fps%60,a%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: shorter-way selection', ['00:59:30:00', '01:00:00:00', 25], '-00:00:30:00'), ('regression variant: shorter-way selection', ['23:00:59:15', '00:00:10:00', 30], '-00:59:10:15'), ('partial repair probe: shorter-way selection', ['23:59:59:15', '01:00:00:00', 30], '-01:00:00:15'), ('partial repair variant: shorter-way selection', ['23:01:01:12', '00:00:10:00', 25], '-00:59:08:13'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('normal control', ['00:59:30:00', '00:00:10:00', 25], '+00:59:20:00'), ('normal control', ['01:01:01:01', '01:00:00:00', 25], '+00:01:01:01')], [('regression: shorter-way selection', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('regression variant: shorter-way selection', ['00:00:00:00', '00:00:10:00', 25], '-00:00:10:00'), ('partial repair probe: shorter-way selection', ['23:59:59:15', '01:00:00:00', 30], '-01:00:00:15'), ('partial repair variant: shorter-way selection', ['23:59:00:00', '00:00:10:00', 30], '-00:01:10:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('normal control', ['00:59:30:00', '00:00:10:00', 30], '+00:59:20:00'), ('normal control', ['10:59:59:15', '01:00:00:00', 30], '+09:59:59:15'), ('normal control', ['01:01:01:00', '23:59:00:00', 25], '+01:02:01:00')], [('regression: shorter-way selection', ['22:00:00:00', '10:00:00:00', 30], '-12:00:00:00'), ('regression variant: shorter-way selection', ['00:01:59:15', '01:00:00:00', 30], '-00:58:00:15'), ('partial repair probe: shorter-way selection', ['12:59:59:24', '00:00:10:00', 30], '-11:00:10:06'), ('partial repair variant: shorter-way selection', ['23:29:30:15', '00:00:10:00', 30], '-00:30:39:15'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:01:30:01', '01:00:00:00', 30], '+00:01:30:01'), ('normal control', ['01:00:00:00', '23:59:00:00', 30], '+01:01:00:00'), ('normal control', ['10:29:59:24', '00:00:10:00', 25], '+10:29:49:24')], [('regression: shorter-way selection', ['12:59:59:24', '23:59:00:00', 25], '-10:59:00:01'), ('regression variant: shorter-way selection', ['01:00:00:01', '10:00:00:00', 25], '-08:59:59:24'), ('partial repair probe: shorter-way selection', ['23:01:59:12', '10:00:00:00', 25], '-10:58:00:13'), ('partial repair variant: shorter-way selection', ['23:59:00:15', '10:00:00:00', 30], '-10:00:59:15'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('normal control', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('normal control', ['10:59:30:15', '10:00:00:00', 30], '+00:59:30:15'), ('normal control', ['10:00:30:00', '01:00:00:00', 25], '+09:00:30:00')], [('regression: shorter-way selection', ['01:00:01:01', '10:00:00:00', 30], '-08:59:58:29'), ('regression variant: shorter-way selection', ['00:00:00:00', '01:00:00:00', 30], '-01:00:00:00'), ('partial repair probe: shorter-way selection', ['23:29:30:00', '10:00:00:00', 30], '-10:30:30:00'), ('partial repair variant: shorter-way selection', ['23:59:50:00', '00:00:10:00', 30], '-00:00:20:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['10:29:30:01', '01:00:00:00', 25], '+09:29:30:01'), ('normal control', ['11:59:59:00', '01:00:00:00', 30], '+10:59:59:00'), ('normal control', ['10:01:59:01', '23:59:00:00', 30], '+10:02:59:01')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: shorter-way selection-00:00:30:00-00:00:30:00Passed
regression variant: shorter-way selection+23:00:49:15-00:59:10:15Failed
partial repair probe: shorter-way selection+22:59:59:15-01:00:00:15Failed
partial repair variant: shorter-way selection+23:00:51:12-00:59:08:13Failed
boundary control+00:02:00:00+00:02:00:00Passed
boundary control+00:00:00:00+00:00:00:00Passed
normal control+02:00:59:29+02:00:59:29Passed
normal control+00:59:20:00+00:59:20:00Passed
normal control+00:01:01:01+00:01:01:01Passed

SHA-256 / 3bb12d3bb3994c2ddaf22844c473f8191f2e661d728ca129a3518005dbdab1a6

3 / The verified repair

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

N = 1
observations = []
def solve(tc, start, fps):
    def fr(t):
        h,m,s,f=map(int,t.split(':'))
        return ((h*60+m)*60+s)*fps+f
    day=86400*fps
    d=(fr(tc)-fr(start))%day
    if d>=day//2:
        d-=day
    sign='-' if d<0 else '+'
    a=abs(d)
    return '%s%02d:%02d:%02d:%02d'%(sign,a//(3600*fps),a//(60*fps)%60,a//fps%60,a%fps)
def check(label, actual, expected):
    observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: shorter-way selection', ['00:59:30:00', '01:00:00:00', 25], '-00:00:30:00'), ('regression variant: shorter-way selection', ['23:00:59:15', '00:00:10:00', 30], '-00:59:10:15'), ('partial repair probe: shorter-way selection', ['23:59:59:15', '01:00:00:00', 30], '-01:00:00:15'), ('partial repair variant: shorter-way selection', ['23:01:01:12', '00:00:10:00', 25], '-00:59:08:13'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:59:59:29', '23:59:00:00', 30], '+02:00:59:29'), ('normal control', ['00:59:30:00', '00:00:10:00', 25], '+00:59:20:00'), ('normal control', ['01:01:01:01', '01:00:00:00', 25], '+00:01:01:01')], [('regression: shorter-way selection', ['23:59:50:00', '00:00:10:00', 25], '-00:00:20:00'), ('regression variant: shorter-way selection', ['00:00:00:00', '00:00:10:00', 25], '-00:00:10:00'), ('partial repair probe: shorter-way selection', ['23:59:59:15', '01:00:00:00', 30], '-01:00:00:15'), ('partial repair variant: shorter-way selection', ['23:59:00:00', '00:00:10:00', 30], '-00:01:10:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('normal control', ['00:59:30:00', '00:00:10:00', 30], '+00:59:20:00'), ('normal control', ['10:59:59:15', '01:00:00:00', 30], '+09:59:59:15'), ('normal control', ['01:01:01:00', '23:59:00:00', 25], '+01:02:01:00')], [('regression: shorter-way selection', ['22:00:00:00', '10:00:00:00', 30], '-12:00:00:00'), ('regression variant: shorter-way selection', ['00:01:59:15', '01:00:00:00', 30], '-00:58:00:15'), ('partial repair probe: shorter-way selection', ['12:59:59:24', '00:00:10:00', 30], '-11:00:10:06'), ('partial repair variant: shorter-way selection', ['23:29:30:15', '00:00:10:00', 30], '-00:30:39:15'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['01:01:30:01', '01:00:00:00', 30], '+00:01:30:01'), ('normal control', ['01:00:00:00', '23:59:00:00', 30], '+01:01:00:00'), ('normal control', ['10:29:59:24', '00:00:10:00', 25], '+10:29:49:24')], [('regression: shorter-way selection', ['12:59:59:24', '23:59:00:00', 25], '-10:59:00:01'), ('regression variant: shorter-way selection', ['01:00:00:01', '10:00:00:00', 25], '-08:59:59:24'), ('partial repair probe: shorter-way selection', ['23:01:59:12', '10:00:00:00', 25], '-10:58:00:13'), ('partial repair variant: shorter-way selection', ['23:59:00:15', '10:00:00:00', 30], '-10:00:59:15'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('normal control', ['01:00:30:01', '23:59:00:00', 25], '+01:01:30:01'), ('normal control', ['10:59:30:15', '10:00:00:00', 30], '+00:59:30:15'), ('normal control', ['10:00:30:00', '01:00:00:00', 25], '+09:00:30:00')], [('regression: shorter-way selection', ['01:00:01:01', '10:00:00:00', 30], '-08:59:58:29'), ('regression variant: shorter-way selection', ['00:00:00:00', '01:00:00:00', 30], '-01:00:00:00'), ('partial repair probe: shorter-way selection', ['23:29:30:00', '10:00:00:00', 30], '-10:30:30:00'), ('partial repair variant: shorter-way selection', ['23:59:50:00', '00:00:10:00', 30], '-00:00:20:00'), ('boundary control', ['00:01:00:00', '23:59:00:00', 25], '+00:02:00:00'), ('boundary control', ['01:00:00:00', '01:00:00:00', 30], '+00:00:00:00'), ('normal control', ['10:29:30:01', '01:00:00:00', 25], '+09:29:30:01'), ('normal control', ['11:59:59:00', '01:00:00:00', 30], '+10:59:59:00'), ('normal control', ['10:01:59:01', '23:59:00:00', 30], '+10:02:59:01')]]
for label, args, expected in fixtures[N-1]:
    check(label, solve(*args), expected)
print(json.dumps({"observations": observations, "passed": all(x["passed"] for x in observations)}, ensure_ascii=False))
raise SystemExit(0 if all(x["passed"] for x in observations) else 1)
Boundary fixtureActualExpectedOutcome
regression: shorter-way selection-00:00:30:00-00:00:30:00Passed
regression variant: shorter-way selection-00:59:10:15-00:59:10:15Passed
partial repair probe: shorter-way selection-01:00:00:15-01:00:00:15Passed
partial repair variant: shorter-way selection-00:59:08:13-00:59:08:13Passed
boundary control+00:02:00:00+00:02:00:00Passed
boundary control+00:00:00:00+00:00:00:00Passed
normal control+02:00:59:29+02:00:59:29Passed
normal control+00:59:20:00+00:59:20:00Passed
normal control+00:01:01:01+00:01:01:01Passed

SHA-256 / 4a128dd836b025d0057a6dd7131c22e9b8c83fe6ce194bd4913479818a86de6d

Verification & scope

A deterministic bounded teaching model with a stipulated toy contract; it does not claim conformance to SMPTE or any broadcast 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:37.337760+00:00.

Case digest / 61e6795e36f303599c1a2979dfeba586e9e59491785b1cc399492a917617bdac