Skip to content

refactor(trace-analyst): single source of truth for span-timestamp parsing#257

Merged
drewstone merged 1 commit into
mainfrom
refactor/trace-timestamp-helpers
Jun 19, 2026
Merged

refactor(trace-analyst): single source of truth for span-timestamp parsing#257
drewstone merged 1 commit into
mainfrom
refactor/trace-timestamp-helpers

Conversation

@drewstone

Copy link
Copy Markdown
Contributor

What

Remove a duplicated timestamp parser. store-otlp.ts had local epochOrNull/epochMs that duplicated otlp-span.ts's exported spanEpochMillis/compareSpanTime (identical ISO + epoch-millis dialect handling). Import the shared helpers; drop the local copies.

Why

The two OTLP readers (OtlpFileTraceStore and otlpToRunRecords) 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, tsc clean, biome check src clean, timestamp regression tests unchanged.

…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 tangletools left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ 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 tangletools left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟢 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 epochOrNull and epochMs helper functions (lines 60–75 in the old file) from store-otlp.ts and replaces their 7 call sites with imports of spanEpochMillis and compareSpanTime from otlp-span.ts. The imported functions are byte-identical in logic: spanEpochMillis handles ISO-8601 and epoch-millis-string dialects identically to epochOrNull; compareSpanTime is `(span
  • Goals it achieves: Single source of truth for OTLP span-timestamp parsing. The two OTLP readers (OtlpFileTraceStore and otlpToRunRecords) now both route through the same canonical helpers in otlp-span.ts, eliminating the risk of dialect-handling drift between them. otlpToRunRecords already used the shared imports; this change brings store-otlp.ts into 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-790 already stated that the per-line projection lives in ./otlp-span so 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.ts is the documented canonical module for shared OTLP vocabulary (src/trace-analyst/otlp-span.ts:7-11 explicitly 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 imports compareSpanTime and spanEpochMillis from 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.

value-audit · 20260619T192311Z

@tangletools

Copy link
Copy Markdown
Contributor

✅ No Blockers — 35902acc

Readiness 95/100 · Confidence 65/100 · 0 findings (none)

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

@drewstone drewstone merged commit 7eb7a65 into main Jun 19, 2026
1 check passed
@drewstone drewstone mentioned this pull request Jun 19, 2026
drewstone added a commit that referenced this pull request Jun 19, 2026
…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
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants