FA-77866 / Subtitle cue timing / Open access
SRT and WebVTT timestamp formatting: negative clamp · case 01
A cue shifted slightly before zero is written at a positive time mirrored around the origin.
ROOT CAUSE
Negative milliseconds are negated with ms=-ms instead of being clamped to zero.
VERIFIED REPAIR
Clamp every negative value to 0 before splitting fields.
Unsuccessful approach: Clamping only values of a full second or more leaves sub-second negatives to be formatted with negative fields.
Case contract
Format integer milliseconds as a cue timestamp. Negative values clamp to 0. style "srt" gives HH:MM:SS,mmm (hours at least two digits, never wrapped); style "vtt" gives MM:SS.mmm when the hour field is zero and HH:MM:SS.mmm otherwise.
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(ms, style):
if ms<0: ms=-ms
h=ms//3600000
m=(ms-h*3600000)//60000
s=ms//1000%60
f=ms%1000
if style=='srt':
return '%02d:%02d:%02d,%03d'%(h,m,s,f)
if h==0:
return '%02d:%02d.%03d'%(m,s,f)
return '%02d:%02d:%02d.%03d'%(h,m,s,f)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative clamp', [-1, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('partial repair probe: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('boundary control', [0, 'srt'], '00:00:00,000'), ('boundary control', [3599999, 'vtt'], '59:59.999'), ('normal control', [0, 'vtt'], '00:00.000'), ('normal control', [61001, 'vtt'], '01:01.001'), ('normal control', [7834, 'srt'], '00:00:07,834')], [('regression: negative clamp', [-999, 'vtt'], '00:00.000'), ('regression variant: negative clamp', [-1000, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('boundary control', [0, 'vtt'], '00:00.000'), ('boundary control', [61001, 'vtt'], '01:01.001'), ('normal control', [3192469, 'vtt'], '53:12.469'), ('normal control', [893654, 'srt'], '00:14:53,654'), ('normal control', [55880, 'vtt'], '00:55.880')], [('regression: negative clamp', [-5000, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-1, 'srt'], '00:00:00,000'), ('partial repair variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('boundary control', [3600000, 'vtt'], '01:00:00.000'), ('boundary control', [0, 'srt'], '00:00:00,000'), ('normal control', [11761, 'vtt'], '00:11.761'), ('normal control', [360000000, 'vtt'], '100:00:00.000'), ('normal control', [78935, 'srt'], '00:01:18,935')], [('regression: negative clamp', [-5000, 'vtt'], '00:00.000'), ('regression variant: negative clamp', [-1, 'srt'], '00:00:00,000'), ('partial repair probe: negative clamp', [-999, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('boundary control', [3599999, 'vtt'], '59:59.999'), ('boundary control', [0, 'vtt'], '00:00.000'), ('normal control', [3576784, 'srt'], '00:59:36,784'), ('normal control', [59999, 'vtt'], '00:59.999'), ('normal control', [1088867, 'srt'], '00:18:08,867')], [('regression: negative clamp', [-1000, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-999, 'srt'], '00:00:00,000'), ('partial repair variant: negative clamp', [-1, 'vtt'], '00:00.000'), ('boundary control', [61001, 'vtt'], '01:01.001'), ('boundary control', [3600000, 'vtt'], '01:00:00.000'), ('normal control', [3599999, 'srt'], '00:59:59,999'), ('normal control', [3689889, 'srt'], '01:01:29,889'), ('normal control', [19225823, 'srt'], '05:20:25,823')]]
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 clamp | 00:00:00,001 | 00:00:00,000 | Failed |
| regression variant: negative clamp | 00:00:00,999 | 00:00:00,000 | Failed |
| partial repair probe: negative clamp | 00:00.001 | 00:00.000 | Failed |
| partial repair variant: negative clamp | 00:00.999 | 00:00.000 | Failed |
| boundary control | 00:00:00,000 | 00:00:00,000 | Passed |
| boundary control | 59:59.999 | 59:59.999 | Passed |
| normal control | 00:00.000 | 00:00.000 | Passed |
| normal control | 01:01.001 | 01:01.001 | Passed |
| normal control | 00:00:07,834 | 00:00:07,834 | Passed |
SHA-256 / b8fcea50ad1e5262bfd71eb1a596939f3c2fc2a5753b3b30a29a1edb998b4d46
2 / The unsuccessful fix
Exit 1"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(ms, style):
if ms<=-1000: ms=0
h=ms//3600000
m=(ms-h*3600000)//60000
s=ms//1000%60
f=ms%1000
if style=='srt':
return '%02d:%02d:%02d,%03d'%(h,m,s,f)
if h==0:
return '%02d:%02d.%03d'%(m,s,f)
return '%02d:%02d:%02d.%03d'%(h,m,s,f)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative clamp', [-1, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('partial repair probe: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('boundary control', [0, 'srt'], '00:00:00,000'), ('boundary control', [3599999, 'vtt'], '59:59.999'), ('normal control', [0, 'vtt'], '00:00.000'), ('normal control', [61001, 'vtt'], '01:01.001'), ('normal control', [7834, 'srt'], '00:00:07,834')], [('regression: negative clamp', [-999, 'vtt'], '00:00.000'), ('regression variant: negative clamp', [-1000, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('boundary control', [0, 'vtt'], '00:00.000'), ('boundary control', [61001, 'vtt'], '01:01.001'), ('normal control', [3192469, 'vtt'], '53:12.469'), ('normal control', [893654, 'srt'], '00:14:53,654'), ('normal control', [55880, 'vtt'], '00:55.880')], [('regression: negative clamp', [-5000, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-1, 'srt'], '00:00:00,000'), ('partial repair variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('boundary control', [3600000, 'vtt'], '01:00:00.000'), ('boundary control', [0, 'srt'], '00:00:00,000'), ('normal control', [11761, 'vtt'], '00:11.761'), ('normal control', [360000000, 'vtt'], '100:00:00.000'), ('normal control', [78935, 'srt'], '00:01:18,935')], [('regression: negative clamp', [-5000, 'vtt'], '00:00.000'), ('regression variant: negative clamp', [-1, 'srt'], '00:00:00,000'), ('partial repair probe: negative clamp', [-999, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('boundary control', [3599999, 'vtt'], '59:59.999'), ('boundary control', [0, 'vtt'], '00:00.000'), ('normal control', [3576784, 'srt'], '00:59:36,784'), ('normal control', [59999, 'vtt'], '00:59.999'), ('normal control', [1088867, 'srt'], '00:18:08,867')], [('regression: negative clamp', [-1000, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-999, 'srt'], '00:00:00,000'), ('partial repair variant: negative clamp', [-1, 'vtt'], '00:00.000'), ('boundary control', [61001, 'vtt'], '01:01.001'), ('boundary control', [3600000, 'vtt'], '01:00:00.000'), ('normal control', [3599999, 'srt'], '00:59:59,999'), ('normal control', [3689889, 'srt'], '01:01:29,889'), ('normal control', [19225823, 'srt'], '05:20:25,823')]]
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 clamp | -1:59:59,999 | 00:00:00,000 | Failed |
| regression variant: negative clamp | -1:59:59,001 | 00:00:00,000 | Failed |
| partial repair probe: negative clamp | -1:59:59.999 | 00:00.000 | Failed |
| partial repair variant: negative clamp | -1:59:59.001 | 00:00.000 | Failed |
| boundary control | 00:00:00,000 | 00:00:00,000 | Passed |
| boundary control | 59:59.999 | 59:59.999 | Passed |
| normal control | 00:00.000 | 00:00.000 | Passed |
| normal control | 01:01.001 | 01:01.001 | Passed |
| normal control | 00:00:07,834 | 00:00:07,834 | Passed |
SHA-256 / 669a3e44388abc5ab0be6f7f6dd14e7ebe84e8339b95a1fa8d6944a14cedc1ed
3 / The verified repair
Exit 0"""Failure Map reference implementation. Python standard library only."""
import json
N = 1
observations = []
def solve(ms, style):
if ms<0: ms=0
h=ms//3600000
m=(ms-h*3600000)//60000
s=ms//1000%60
f=ms%1000
if style=='srt':
return '%02d:%02d:%02d,%03d'%(h,m,s,f)
if h==0:
return '%02d:%02d.%03d'%(m,s,f)
return '%02d:%02d:%02d.%03d'%(h,m,s,f)
def check(label, actual, expected):
observations.append({"check": label, "actual": actual, "expected": expected, "passed": actual == expected})
fixtures = [[('regression: negative clamp', [-1, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('partial repair probe: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('boundary control', [0, 'srt'], '00:00:00,000'), ('boundary control', [3599999, 'vtt'], '59:59.999'), ('normal control', [0, 'vtt'], '00:00.000'), ('normal control', [61001, 'vtt'], '01:01.001'), ('normal control', [7834, 'srt'], '00:00:07,834')], [('regression: negative clamp', [-999, 'vtt'], '00:00.000'), ('regression variant: negative clamp', [-1000, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('boundary control', [0, 'vtt'], '00:00.000'), ('boundary control', [61001, 'vtt'], '01:01.001'), ('normal control', [3192469, 'vtt'], '53:12.469'), ('normal control', [893654, 'srt'], '00:14:53,654'), ('normal control', [55880, 'vtt'], '00:55.880')], [('regression: negative clamp', [-5000, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-1, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-1, 'srt'], '00:00:00,000'), ('partial repair variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('boundary control', [3600000, 'vtt'], '01:00:00.000'), ('boundary control', [0, 'srt'], '00:00:00,000'), ('normal control', [11761, 'vtt'], '00:11.761'), ('normal control', [360000000, 'vtt'], '100:00:00.000'), ('normal control', [78935, 'srt'], '00:01:18,935')], [('regression: negative clamp', [-5000, 'vtt'], '00:00.000'), ('regression variant: negative clamp', [-1, 'srt'], '00:00:00,000'), ('partial repair probe: negative clamp', [-999, 'vtt'], '00:00.000'), ('partial repair variant: negative clamp', [-999, 'srt'], '00:00:00,000'), ('boundary control', [3599999, 'vtt'], '59:59.999'), ('boundary control', [0, 'vtt'], '00:00.000'), ('normal control', [3576784, 'srt'], '00:59:36,784'), ('normal control', [59999, 'vtt'], '00:59.999'), ('normal control', [1088867, 'srt'], '00:18:08,867')], [('regression: negative clamp', [-1000, 'srt'], '00:00:00,000'), ('regression variant: negative clamp', [-999, 'vtt'], '00:00.000'), ('partial repair probe: negative clamp', [-999, 'srt'], '00:00:00,000'), ('partial repair variant: negative clamp', [-1, 'vtt'], '00:00.000'), ('boundary control', [61001, 'vtt'], '01:01.001'), ('boundary control', [3600000, 'vtt'], '01:00:00.000'), ('normal control', [3599999, 'srt'], '00:59:59,999'), ('normal control', [3689889, 'srt'], '01:01:29,889'), ('normal control', [19225823, 'srt'], '05:20:25,823')]]
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 clamp | 00:00:00,000 | 00:00:00,000 | Passed |
| regression variant: negative clamp | 00:00:00,000 | 00:00:00,000 | Passed |
| partial repair probe: negative clamp | 00:00.000 | 00:00.000 | Passed |
| partial repair variant: negative clamp | 00:00.000 | 00:00.000 | Passed |
| boundary control | 00:00:00,000 | 00:00:00,000 | Passed |
| boundary control | 59:59.999 | 59:59.999 | Passed |
| normal control | 00:00.000 | 00:00.000 | Passed |
| normal control | 01:01.001 | 01:01.001 | Passed |
| normal control | 00:00:07,834 | 00:00:07,834 | Passed |
SHA-256 / 14c40b4f5d3859a1c84c6196ac5ffa6641c7612a7e2099570dd41e3c55457dd7
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:29.978133+00:00.
Case digest / 1b7a26372d9121f5c7f347be9d5122a74d792a2c06aeb0862b57583fb24f1c3c