Reject exactly negative transcript timestamps

This commit is contained in:
2026-11-26 01:27:39 +00:00
parent 4026e26e76
commit 08a9bea23b
4 changed files with 48 additions and 7 deletions

View File

@@ -20,8 +20,8 @@ The [Core And Integration API Roadmap](../core-integration-api.md) established
the core/integration boundary. The reassessment below distinguishes its completed the core/integration boundary. The reassessment below distinguishes its completed
work from the remaining audit remediation. work from the remaining audit remediation.
The **45 original finding entries** reduce to **28 outstanding catalog entries The **45 original finding entries** reduce to **27 outstanding catalog entries
and six resolved entries**. Repeated responsibility findings are and seven resolved entries**. Repeated responsibility findings are
merged. Regression gaps are attached to the defects they protect rather than merged. Regression gaps are attached to the defects they protect rather than
counted as additional runtime bugs. In particular, TEST-001, TEST-002, and counted as additional runtime bugs. In particular, TEST-001, TEST-002, and
TEST-004 each cover several distinct defects; TEST-003's native-fixture oracle TEST-004 each cover several distinct defects; TEST-003's native-fixture oracle
@@ -65,8 +65,9 @@ Original P2/P3 ratings and relative refactoring priorities are retained for
context; they are not one universal severity scale. No audit establishes a P1 context; they are not one universal severity scale. No audit establishes a P1
incident or a measured end-to-end production speedup. incident or a measured end-to-end production speedup.
CAT-001, CAT-007, CAT-011, CAT-015, CAT-016, and CAT-034 are resolved; the other entries remain CAT-001, CAT-002, CAT-007, CAT-011, CAT-015, CAT-016, and CAT-034 are resolved;
outstanding. The original reports and their baseline observations are historical. the other entries remain outstanding. The original reports and their baseline
observations are historical.
"Refactoring" denotes a maintenance opportunity, not a confirmed runtime "Refactoring" denotes a maintenance opportunity, not a confirmed runtime
failure. CAT-024 explicitly requires revisiting an existing evidence-convenience failure. CAT-024 explicitly requires revisiting an existing evidence-convenience
choice. Related entries choice. Related entries
@@ -105,6 +106,9 @@ Preserve the accepted option domain rather than adding an arbitrary maximum.
**Assessment:** Reproduced input-contract defect; original P2, extreme-value case. **Assessment:** Reproduced input-contract defect; original P2, extreme-value case.
**Status:** Resolved. Validation checks the exact rational sign, and parser
regressions cover both endpoints, tiny positive values, zero, and exact ordering.
**Sources:** [Correctness / Finding 2](01-correctness.md#finding-2-negative-timestamp-underflow-bypasses-non-negativity-validation), **Sources:** [Correctness / Finding 2](01-correctness.md#finding-2-negative-timestamp-underflow-bypasses-non-negativity-validation),
[TEST-001](08-testing.md#test-001--accepted-numeric-boundaries-lack-regression-cases). [TEST-001](08-testing.md#test-001--accepted-numeric-boundaries-lack-regression-cases).

View File

@@ -177,6 +177,11 @@ Existing public contracts need no rewrite.
## Stage 2 — Check Exact Timestamp Negativity ## Stage 2 — Check Exact Timestamp Negativity
**Completed.** Timestamp validation checks the exact rational sign after the
existing finite-number check. Parser regressions cover tiny negative endpoints,
tiny positives, negative zero, ordinary values, exact ordering, and retained
numeric metadata. The specified package test passes. No follow-up remains.
**Coverage:** CAT-002. **Prerequisites:** none. **Coverage:** CAT-002. **Prerequisites:** none.
In Seriatim `adapter.go`/`validTimestamp`, check rational sign while retaining In Seriatim `adapter.go`/`validTimestamp`, check rational sign while retaining

View File

@@ -183,13 +183,13 @@ func validTimestamp(value fmt.Stringer, label string) (*big.Rat, error) {
if math.IsInf(parsed, 0) || math.IsNaN(parsed) { if math.IsInf(parsed, 0) || math.IsNaN(parsed) {
return nil, inputErrorf("%s must be finite", label) return nil, inputErrorf("%s must be finite", label)
} }
if parsed < 0 {
return nil, inputErrorf("%s must not be negative", label)
}
rat, ok := new(big.Rat).SetString(raw) rat, ok := new(big.Rat).SetString(raw)
if !ok { if !ok {
return nil, inputErrorf("%s must be a valid number", label) return nil, inputErrorf("%s must be a valid number", label)
} }
if rat.Sign() < 0 {
return nil, inputErrorf("%s must not be negative", label)
}
return rat, nil return rat, nil
} }

View File

@@ -111,6 +111,38 @@ func TestParseAcceptsNumericSegmentIDs(t *testing.T) {
} }
} }
func TestParseTimestampPrecisionAndSign(t *testing.T) {
for _, tt := range []struct {
name, start, end string
wantError bool
}{
{"tiny negative start", "-1e-1000", "0", true},
{"tiny negative end", "0", "-1e-1000", true},
{"tiny positive", "1e-1000", "2e-1000", false},
{"negative zero", "-0", "0", false},
{"ordinary", "1.25", "2.5", false},
{"precise reversed", "2e-1000", "1e-1000", true},
} {
t.Run(tt.name, func(t *testing.T) {
raw := validJSONWithSegment(`"id":1,"start":` + tt.start + `,"end":` + tt.end + `,"speaker":"Narrator","text":"Text"`)
doc, err := New().Parse(context.Background(), contracts.ParseRequest{Raw: raw})
if (err != nil) != tt.wantError {
t.Fatalf("Parse() error = %v, want error %t", err, tt.wantError)
}
if strings.HasPrefix(tt.name, "tiny negative") && !strings.Contains(err.Error(), "negative") {
t.Fatalf("Parse() error = %v, want negative timestamp error", err)
}
if err == nil {
start, _ := Start(doc.Units[0])
end, _ := End(doc.Units[0])
if start != json.Number(tt.start) || end != json.Number(tt.end) {
t.Fatalf("timestamps = %q, %q, want %q, %q", start, end, tt.start, tt.end)
}
}
})
}
}
func TestParseRequestSourceIDOverridesMetadataIDs(t *testing.T) { func TestParseRequestSourceIDOverridesMetadataIDs(t *testing.T) {
raw := readFixture(t, "testdata/valid_minimal.json") raw := readFixture(t, "testdata/valid_minimal.json")