refactor(trace-analyst): single source of truth for span-timestamp parsing#257
Conversation
…rsing store-otlp had local epochOrNull/epochMs that duplicated otlp-span's exported spanEpochMillis/compareSpanTime (identical logic). Import the shared helpers and drop the local copies, so the ISO/epoch dialect handling lives in exactly one place and can't drift between the two readers. Behavior-identical — full suite green, timestamp regression tests unchanged.
tangletools
left a comment
There was a problem hiding this comment.
✅ Auto-approved PR — 35902acc
Blanket team auto-approval is enabled for this reviewer service.
The full PR reviewer audit still runs separately and will publish findings if it detects issues.
tangletools · auto-approval · reason: blanket_auto_approve · 2026-06-19T19:20:29Z
tangletools
left a comment
There was a problem hiding this comment.
🟢 Value Audit — sound
| Verdict | sound |
| Concerns | 0 (none) |
| Heuristic | 0.0s |
| Duplication | 0.0s |
| Interrogation | 56.0s (2 bridge agents) |
| Total | 56.0s |
💰 Value — sound
Replaces a duplicated timestamp parser (epochOrNull/epochMs) in store-otlp.ts with imports of the identical spanEpochMillis/compareSpanTime from otlp-span.ts — the already-canonical source used by otlpToRunRecords. Net −13 lines, no behavioral change.
- What it does: Removes the local
epochOrNullandepochMshelper functions (lines 60–75 in the old file) fromstore-otlp.tsand replaces their 7 call sites with imports ofspanEpochMillisandcompareSpanTimefromotlp-span.ts. The imported functions are byte-identical in logic:spanEpochMillishandles ISO-8601 and epoch-millis-string dialects identically toepochOrNull;compareSpanTimeis `(span - Goals it achieves: Single source of truth for OTLP span-timestamp parsing. The two OTLP readers (
OtlpFileTraceStoreandotlpToRunRecords) now both route through the same canonical helpers inotlp-span.ts, eliminating the risk of dialect-handling drift between them.otlpToRunRecordsalready used the shared imports; this change bringsstore-otlp.tsinto alignment with that established pattern. - Assessment: This is a mechanical, well-scoped deduplication. Every call site maps one-to-one with identical semantics. The file's own lint-level comment at
store-otlp.ts:787-790already stated that the per-line projection lives in./otlp-spanso both consumers read the same vocabulary — this change fulfills that intent for timestamp parsing too. The timestamp-specific test files exist for both modules (`s - Better / existing approach: none — this is the right approach.
otlp-span.tsis the documented canonical module for shared OTLP vocabulary (src/trace-analyst/otlp-span.ts:7-11explicitly states "Canonical OTLP-flat-line readers shared by every consumer … One parser, one vocabulary").otlpToRunRecords(src/trace-analyst/otlp-to-run-records.ts:43,48) already importscompareSpanTimeandspanEpochMillisfrom it. The r - Model: opencode/deepseek/deepseek-v4-pro
- Bridge attempts: 1
🎯 Usefulness — sound
Removes 13 lines of duplicate timestamp-parsing code in store-otlp.ts by importing the canonical spanEpochMillis/compareSpanTime from otlp-span.ts — the shared helpers already used by otlp-to-run-records.ts, exactly the consolidation the codebase's own design comment (store-otlp.ts:788-790) says it
- Integration: All 5 old call sites in store-otlp.ts (lines 181-182, 530-531, 543, 547-548) correctly rewired to the shared imports. The imported functions are already production-hardened: otlp-to-run-records.ts at lines 43, 48, 285, 302, 304, 340, 341, 411 uses the same compareSpanTime/spanEpochMillis. Both OTLP consumers now share a single parse dialect.
- Fit with existing patterns: Fits the established codebase grain exactly. The module header of otlp-span.ts (lines 7-11) states 'One parser, one vocabulary — a divergence between the analyst's view of a trace and the RunRecord projected from it is a class of bug this consolidation removes.' The old local copies were the anomaly; this change removes them and brings store-otlp.ts into alignment with the already-exported shared
- Real-world viability: Behavior-identical at every call site: compareSpanTime(a,b) ≡ epochMs(a)-epochMs(b); spanEpochMillis ≡ epochOrNull (with the minor improvement that spanEpochMillis accepts string|null|undefined vs the old epochOrNull's string-only signature — slightly more robust against null timestamps). The epoch-millis-string / ISO-8601 dual-dialect handling is preserved identically. No new error paths introduc
- Model: opencode/deepseek/deepseek-v4-pro
- Bridge attempts: 1
No concerns — sound change, no better or existing approach found. ✅
What this audit checks
It judges the change on its merits — not whether it was tasked out in an issue. Unticketed, fast-moving work is fine; the question is whether the change is good and whether a better or existing approach should be used instead.
| Pass | What it asks |
|---|---|
| Heuristic | Vague title? Whitespace-only or cruft-bearing diff? (content signals only) |
| Duplication | Do added function/class names already exist elsewhere in the repo? |
| Value Audit | What does it do? What goal does it achieve? Is it good? Better architecture or already-exists? |
| Usefulness Audit | Does it integrate and fit? Will it hold up in real use and actually get used? |
Findings are concerns, not blocks — the human reviewer decides what to do with them.
✅ No Blockers —
|
| deepseek | glm | aggregate | |
|---|---|---|---|
| Readiness | 95 | 95 | 95 |
| Confidence | 65 | 65 | 65 |
| Correctness | 95 | 95 | 95 |
| Security | 95 | 95 | 95 |
| Testing | 95 | 95 | 95 |
| Architecture | 95 | 95 | 95 |
Full multi-shot audit completed 1/1 planned shots over 1 changed files. Global verifier still owns final merge decision. | Full multi-shot audit completed 1/1 planned shots over 1 changed files. Global verifier still owns final merge decision.
No findings.
tangletools · 2026-06-19T19:25:23Z · trace
…hardening (#258) Version-only bump of the trio (package.json + python pyproject + __init__). Ships everything merged since 0.93.0: - #253 data-plane reliability/concurrency/scale hardening - #254 paired-binary + coding-eval estimators (McNemar, risk-diff, Wilson, pass@k) - #255 trace-store append/load race + collision-free rollover - #256 McNemar power + required-N - #257 single source of truth for span-timestamp parsing
What
Remove a duplicated timestamp parser.
store-otlp.tshad localepochOrNull/epochMsthat duplicatedotlp-span.ts's exportedspanEpochMillis/compareSpanTime(identical ISO + epoch-millis dialect handling). Import the shared helpers; drop the local copies.Why
The two OTLP readers (
OtlpFileTraceStoreandotlpToRunRecords) now both go through the one canonical timestamp helper, so the dialect handling can't drift between them. Net −13 lines, no new surface.Verification
Behavior-identical (
compareSpanTime(a,b) ≡ epochMs(a)-epochMs(b);spanEpochMillis ≡ epochOrNull): full suite 2461 pass / 0 fail,tscclean,biome check srcclean, timestamp regression tests unchanged.