FA-78756 / Broadcast timecode arithmetic / Open access
Decimal seconds to frame label: negative input · case 01
Negative offsets are silently mirrored to positive frames.
ROOT CAUSE
Negative seconds are negated instead of rejected.
VERIFIED REPAIR
Return None for negative input.
Unsuccessful approach: Clamping to zero hides the invalid input as frame zero.
Case contract
Convert a decimal seconds string exactly (no binary floating point) at rate [N,D] to the nearest frame, halves rounding up, and a non-drop label using the nominal rate ceil(N/D). Negative input returns None.
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
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
num,den=fps
x=Fraction(sec)
if x<0:
x=-x
n=x*num/den
fr=math.floor(n+Fraction(1,2))
nominal=-(-num//den)
return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative input', ['-1', [25, 1]], None), ('regression variant: negative input', ['-0.5', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [24, 1]], None), ('partial repair variant: negative input', ['-1', [30000, 1001]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01'])], [('regression: negative input', ['-1', [24000, 1001]], None), ('regression variant: negative input', ['-1', [50, 1]], None), ('partial repair probe: negative input', ['-0.5', [25, 1]], None), ('partial repair variant: negative input', ['-1', [25, 1]], None), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('normal control', ['0.22', [24, 1]], [5, '00:00:00:05']), ('normal control', ['0', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['7.3', [24, 1]], [175, '00:00:07:07'])], [('regression: negative input', ['-1', [24, 1]], None), ('regression variant: negative input', ['-0.5', [24000, 1001]], None), ('partial repair probe: negative input', ['-0.5', [50, 1]], None), ('partial repair variant: negative input', ['-1', [24000, 1001]], None), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['0.04', [24, 1]], [1, '00:00:00:01']), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['0.02', [30000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [25, 1]], None), ('regression variant: negative input', ['-0.5', [24, 1]], None), ('partial repair probe: negative input', ['-0.5', [30000, 1001]], None), ('partial repair variant: negative input', ['-1', [24, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['0.1', [24000, 1001]], [2, '00:00:00:02']), ('normal control', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('normal control', ['0.04', [24000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [50, 1]], None), ('regression variant: negative input', ['-1', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [50, 1]], None), ('partial repair variant: negative input', ['-0.5', [25, 1]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.14', [30000, 1001]], [4, '00:00:00:04']), ('normal control', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('normal control', ['1.001', [50, 1]], [50, '00:00:01:00'])]]
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: negative input | [25, '00:00:01:00'] | None | Failed |
| regression variant: negative input | [15, '00:00:00:15'] | None | Failed |
| partial repair probe: negative input | [24, '00:00:01:00'] | None | Failed |
| partial repair variant: negative input | [30, '00:00:01:00'] | None | Failed |
| boundary control | [2, '00:00:00:02'] | [2, '00:00:00:02'] | Passed |
| boundary control | [0, '00:00:00:00'] | [0, '00:00:00:00'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
| normal control | [296, '00:00:12:08'] | [296, '00:00:12:08'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
SHA-256 / b7ce14ef2eb019086f0ed24b027f774a84d27eeafc7ed813b3b474b4002f26e8
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
num,den=fps
x=Fraction(sec)
if x<0:
x=0
n=x*num/den
fr=math.floor(n+Fraction(1,2))
nominal=-(-num//den)
return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative input', ['-1', [25, 1]], None), ('regression variant: negative input', ['-0.5', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [24, 1]], None), ('partial repair variant: negative input', ['-1', [30000, 1001]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01'])], [('regression: negative input', ['-1', [24000, 1001]], None), ('regression variant: negative input', ['-1', [50, 1]], None), ('partial repair probe: negative input', ['-0.5', [25, 1]], None), ('partial repair variant: negative input', ['-1', [25, 1]], None), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('normal control', ['0.22', [24, 1]], [5, '00:00:00:05']), ('normal control', ['0', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['7.3', [24, 1]], [175, '00:00:07:07'])], [('regression: negative input', ['-1', [24, 1]], None), ('regression variant: negative input', ['-0.5', [24000, 1001]], None), ('partial repair probe: negative input', ['-0.5', [50, 1]], None), ('partial repair variant: negative input', ['-1', [24000, 1001]], None), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['0.04', [24, 1]], [1, '00:00:00:01']), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['0.02', [30000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [25, 1]], None), ('regression variant: negative input', ['-0.5', [24, 1]], None), ('partial repair probe: negative input', ['-0.5', [30000, 1001]], None), ('partial repair variant: negative input', ['-1', [24, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['0.1', [24000, 1001]], [2, '00:00:00:02']), ('normal control', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('normal control', ['0.04', [24000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [50, 1]], None), ('regression variant: negative input', ['-1', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [50, 1]], None), ('partial repair variant: negative input', ['-0.5', [25, 1]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.14', [30000, 1001]], [4, '00:00:00:04']), ('normal control', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('normal control', ['1.001', [50, 1]], [50, '00:00:01:00'])]]
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: negative input | [0, '00:00:00:00'] | None | Failed |
| regression variant: negative input | [0, '00:00:00:00'] | None | Failed |
| partial repair probe: negative input | [0, '00:00:00:00'] | None | Failed |
| partial repair variant: negative input | [0, '00:00:00:00'] | None | Failed |
| boundary control | [2, '00:00:00:02'] | [2, '00:00:00:02'] | Passed |
| boundary control | [0, '00:00:00:00'] | [0, '00:00:00:00'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
| normal control | [296, '00:00:12:08'] | [296, '00:00:12:08'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
SHA-256 / 5f88214b42d6d5cf6df9086e6c4a681ee2e5c03633e5c106b4aa524765fabf3e
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
import math
from fractions import Fraction
N = 1
observations = []
def solve(sec, fps):
num,den=fps
x=Fraction(sec)
if x<0:
return None
n=x*num/den
fr=math.floor(n+Fraction(1,2))
nominal=-(-num//den)
return [fr,'%02d:%02d:%02d:%02d'%(fr//(3600*nominal)%24,fr//(60*nominal)%60,fr//nominal%60,fr%nominal)]
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative input', ['-1', [25, 1]], None), ('regression variant: negative input', ['-0.5', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [24, 1]], None), ('partial repair variant: negative input', ['-1', [30000, 1001]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['12.345', [24000, 1001]], [296, '00:00:12:08']), ('normal control', ['0.02', [50, 1]], [1, '00:00:00:01'])], [('regression: negative input', ['-1', [24000, 1001]], None), ('regression variant: negative input', ['-1', [50, 1]], None), ('partial repair probe: negative input', ['-0.5', [25, 1]], None), ('partial repair variant: negative input', ['-1', [25, 1]], None), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('normal control', ['0.22', [24, 1]], [5, '00:00:00:05']), ('normal control', ['0', [24000, 1001]], [0, '00:00:00:00']), ('normal control', ['7.3', [24, 1]], [175, '00:00:07:07'])], [('regression: negative input', ['-1', [24, 1]], None), ('regression variant: negative input', ['-0.5', [24000, 1001]], None), ('partial repair probe: negative input', ['-0.5', [50, 1]], None), ('partial repair variant: negative input', ['-1', [24000, 1001]], None), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('boundary control', ['0.02', [25, 1]], [1, '00:00:00:01']), ('normal control', ['0.04', [24, 1]], [1, '00:00:00:01']), ('normal control', ['0.18', [24, 1]], [4, '00:00:00:04']), ('normal control', ['0.02', [30000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [25, 1]], None), ('regression variant: negative input', ['-0.5', [24, 1]], None), ('partial repair probe: negative input', ['-0.5', [30000, 1001]], None), ('partial repair variant: negative input', ['-1', [24, 1]], None), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('boundary control', ['1.001', [30000, 1001]], [30, '00:00:01:00']), ('normal control', ['0.1', [24000, 1001]], [2, '00:00:00:02']), ('normal control', ['3600', [30000, 1001]], [107892, '00:59:56:12']), ('normal control', ['0.04', [24000, 1001]], [1, '00:00:00:01'])], [('regression: negative input', ['-0.5', [50, 1]], None), ('regression variant: negative input', ['-1', [30000, 1001]], None), ('partial repair probe: negative input', ['-1', [50, 1]], None), ('partial repair variant: negative input', ['-0.5', [25, 1]], None), ('boundary control', ['0.06', [25, 1]], [2, '00:00:00:02']), ('boundary control', ['0', [24, 1]], [0, '00:00:00:00']), ('normal control', ['0.14', [30000, 1001]], [4, '00:00:00:04']), ('normal control', ['0.0166', [50, 1]], [1, '00:00:00:01']), ('normal control', ['1.001', [50, 1]], [50, '00:00:01:00'])]]
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: negative input | None | None | Passed |
| regression variant: negative input | None | None | Passed |
| partial repair probe: negative input | None | None | Passed |
| partial repair variant: negative input | None | None | Passed |
| boundary control | [2, '00:00:00:02'] | [2, '00:00:00:02'] | Passed |
| boundary control | [0, '00:00:00:00'] | [0, '00:00:00:00'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
| normal control | [296, '00:00:12:08'] | [296, '00:00:12:08'] | Passed |
| normal control | [1, '00:00:00:01'] | [1, '00:00:00:01'] | Passed |
SHA-256 / 6f906ac1aded622f667cf8719819bbfd2d15a4dbdade4b47aeac0a6a790836f3
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:38.309956+00:00.
Case digest / 2e5b1f4a7c9c88b349c16a8bd1b7281cd5bf1dcbf6acb5295416d32fe3951c57