diff --git a/docs/roadmap/audit/catalog.md b/docs/roadmap/audit/catalog.md index ed3fe5af..ae15a74c 100644 --- a/docs/roadmap/audit/catalog.md +++ b/docs/roadmap/audit/catalog.md @@ -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 work from the remaining audit remediation. -The **45 original finding entries** reduce to **28 outstanding catalog entries -and six resolved entries**. Repeated responsibility findings are +The **45 original finding entries** reduce to **27 outstanding catalog entries +and seven resolved entries**. Repeated responsibility findings are merged. Regression gaps are attached to the defects they protect rather than 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 @@ -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 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 -outstanding. The original reports and their baseline observations are historical. +CAT-001, CAT-002, CAT-007, CAT-011, CAT-015, CAT-016, and CAT-034 are resolved; +the other entries remain outstanding. The original reports and their baseline +observations are historical. "Refactoring" denotes a maintenance opportunity, not a confirmed runtime failure. CAT-024 explicitly requires revisiting an existing evidence-convenience 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. +**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), [TEST-001](08-testing.md#test-001--accepted-numeric-boundaries-lack-regression-cases). diff --git a/docs/roadmap/implementation.md b/docs/roadmap/implementation.md index ac28c325..583df261 100644 --- a/docs/roadmap/implementation.md +++ b/docs/roadmap/implementation.md @@ -177,6 +177,11 @@ Existing public contracts need no rewrite. ## 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. In Seriatim `adapter.go`/`validTimestamp`, check rational sign while retaining diff --git a/internal/modules/seriatim/input/transcript/adapter.go b/internal/modules/seriatim/input/transcript/adapter.go index 336cc51f..acb8f2a1 100644 --- a/internal/modules/seriatim/input/transcript/adapter.go +++ b/internal/modules/seriatim/input/transcript/adapter.go @@ -183,13 +183,13 @@ func validTimestamp(value fmt.Stringer, label string) (*big.Rat, error) { if math.IsInf(parsed, 0) || math.IsNaN(parsed) { 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) if !ok { 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 } diff --git a/internal/modules/seriatim/input/transcript/adapter_test.go b/internal/modules/seriatim/input/transcript/adapter_test.go index 5550f953..52d17abe 100644 --- a/internal/modules/seriatim/input/transcript/adapter_test.go +++ b/internal/modules/seriatim/input/transcript/adapter_test.go @@ -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) { raw := readFixture(t, "testdata/valid_minimal.json")