Design rules for replaying and streaming large CAN datasets - time bases, deterministic replay engine, seek and indexing, back-pressure, batching to the webview, chart decimation, memory bounds. Use when building replay, recording, Signal Lab data paths or anything that handles high frame rates.
Installs into .claude/skills of the current project.
Sponsors
SSkills DirectorySkills Directory
Know which skills are safe — weekly.
SSkills DirectorySkills Directory
Is that skill safe to install?
Are you the author of Data Replay And Streaming?
Add the live security badge to your README. It updates with every re-scan.
[](https://www.skillsdirectory.com/skills/afri-bit-data-replay-and-streaming)
---
name: data-replay-and-streaming
description: Design rules for replaying and streaming large CAN datasets - time bases, deterministic replay engine, seek and indexing, back-pressure, batching to the webview, chart decimation, memory bounds. Use when building replay, recording, Signal Lab data paths or anything that handles high frame rates.
---
# Data replay and streaming
## Model
`Source` (hardware | virtual | log | recording) -> `FramePipeline` (`onFrameReceived`) -> decode -> `EventBus` -> subscribers (monitor table, charts, recorder). **Replay is just another source.** It must never transmit to a hardware adapter.
## Time
- Internal unit: **integer nanoseconds**; keep the clock domain (hardware / host / file-relative) with the frame.
- Replay clock: `PlaybackClock` interface (`now()`, `sleepUntil(t)`) with a real monotonic implementation (`process.hrtime.bigint()`) and a **fake clock for tests**. Speed factor scales the timeline; 1x preserves recorded inter-frame gaps; "as fast as possible" is a separate mode.
- Scheduling: coarse timers drift - compute each deadline from the start time, not from the previous wake-up, and emit due frames in batches. Report dropped/late counts rather than hiding them.
## Determinism
Frame order = source order. No dependence on wall clock for *content*. Same input + same settings -> byte-identical output stream. Seed any randomness (virtual bus) and expose the seed.
## Seek and index
Build a sparse index (every N frames or every T ms: byte offset + timestamp) in a background pass; seek = binary search index, then scan. Show progress for the first pass; allow use before it completes (degrade seek).
## Back-pressure and batching
- Pull-based reading (async iterator) with a bounded queue; pause the source when the consumer lags.
- Host -> webview: batch (for example every 16-50 ms, max N frames per message) and send compact arrays, not per-frame objects; cap UI table rows with a ring buffer and virtualised rendering.
- Never post a message per frame at kHz rates.
## Charts
Keep full-resolution data in the host only when needed; send decimated series (min/max per pixel bucket, or LTTB) for display. Preserve extrema so spikes are not smoothed away - a validation tool must not hide glitches.
## Memory and failure
Bounded buffers everywhere; document the maximum. Corrupt/truncated input ends the stream with an explicit error event; partial results stay visible and labelled partial.
## Tests
Fake clock tests for pause/resume/seek/speed; property test: concatenating chunks equals whole; large synthetic stream (1e6 frames) completes within memory and time budgets.