Skip to content

feat(phase2): Latency Display + Buffer Health (Goal 6)#49

Open
roiguri wants to merge 1 commit into
mainfrom
feat/phase2-latency-health
Open

feat(phase2): Latency Display + Buffer Health (Goal 6)#49
roiguri wants to merge 1 commit into
mainfrom
feat/phase2-latency-health

Conversation

@roiguri

@roiguri roiguri commented Jun 8, 2026

Copy link
Copy Markdown
Owner

@

What

Wires the header to StreamWorker.latency_ready (previously emitted but consumed by nobody) and surfaces it as live diagnostics (M2 Goal 6):

  • Latency readoutLatency: p50 / p95 ms, rolling over the last 100 batches.
  • Buffer-health pill — green BUFFER OK when the backlog is comfortably below the batch size, amber BACKLOG when the worker is falling behind (pending_samples >= batch_size * 2).

Why this one (data-agnostic)

Latency and backlog are pure system timing — independent of whether the predictions are correct. So this works regardless of the open prediction-fidelity bug, and it doubles as instrumentation for the deferred Goal 18 / Goal 1 work: per-batch timing and queue depth become visible the moment you next replay.

Changes

  • Phase2Header gains set_latency / set_buffer_health / clear_diagnostics plus the right-aligned label + pill.
  • Phase2Screen subscribes to latency_ready (queued): a data-only slot buffers total_ms in deque(maxlen=100) and records the latest pending_samples; a 5 Hz QTimer (decoupled from the ~25 Hz stream) computes p50/p95 (numpy) and the pill state. Started on Start; stopped + cleared on Halt and on error.
  • LiveStreamSession.batch_size_samples — new read-only property so the backlog threshold scales to the session's batch size without reaching into _worker (fallback 40).

Testing

  • 8 new headless tests (tests/frontend/test_latency_health.py): header text/pill/clear, latency buffering + summary, backlog→amber threshold, timer start/stop lifecycle, clear-on-error, empty-window no-op.
  • Full frontend suite: 69 passed; session/backend suite: 31 passed (session.py touched).
  • Live replay verification (numbers update ~5×/s) remains an operator step on Windows.

Notes

Branched from main, independent of #47 (chart perf) and #48 (Trigger Log). All three merge in any order; #48 and this one both touch Phase2Screen (disjoint regions — header/diagnostics here vs. the log card there), so expect a trivial merge.
@

@roiguri roiguri force-pushed the feat/phase2-latency-health branch 4 times, most recently from bc62a4c to ef1c27d Compare June 8, 2026 10:44
…l 6)

Consumes StreamWorker.latency_ready (previously unconsumed) and surfaces it
on the header: rolling p50/p95 latency readout + a buffer-health pill
(BUFFER OK green / BACKLOG amber).

Data-agnostic: latency/backlog are system timing, independent of prediction
correctness — works regardless of the fidelity bug and doubles as live
instrumentation for the deferred Goal 18/1 work.

- Phase2Header: set_latency / set_buffer_health / clear_diagnostics
- Phase2Screen: queued latency_ready -> deque(maxlen=100) + pending_samples;
  5 Hz QTimer summarises onto the header; started on Start, cleared on
  Halt/error
- LiveStreamSession.batch_size_samples property for the backlog threshold
  (pending < batch*2); fallback 40
- 8 headless tests; plan doc Goal 6 marked done
@roiguri roiguri force-pushed the feat/phase2-latency-health branch from ef1c27d to 3eb9b68 Compare June 8, 2026 10:46
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.

1 participant