oc_chat
Loading...
Searching...
No Matches
oc_chat.benchmarks.presenter Namespace Reference

Classes

class  BenchmarkPresenter

Detailed Description

BenchmarkPresenter — the measurement tap over the presenter contract.

Purpose
-------
A standalone :class:`~oc_ui.presenter_base.Presenter` (not a delegating
wrapper) that records, per turn, exactly what the measurement surface
exposes — and nothing else. It is the single lowest-blast-radius way to
observe a turn with zero production changes (plan 136 ADR-136-1):

- **TTFT** = monotonic at ``show_waiting`` (fired immediately before
  ``client.stream_chat``) → the first ``show_reasoning`` / ``show_content``
  chunk of that iteration. Iterations that emit only tool calls have no
  first-chunk token, so their TTFT is ``None`` — never fabricated.
- **Raw usage** — ``show_usage`` receives the raw provider dict (the
  only place ``reasoning_tokens`` and the DeepSeek cache split survive).
- **Main-loop tool names** — ``show_tool_call`` fires for main-loop
  calls only; sub-loop internal tools never reach the presenter, so the
  count is derived and the *names* are marked unavailable (ADR-136-5).
- **Turn summary** — ``iterations`` and ``tool_calls`` drive the
  sub-loop-count derivation (``tool_calls - main_loop_names``).

Every other presenter hook is a no-op (the benchmark has no UI, and
the real startup composition path calls ``show_info`` etc.).

Responsibilities
----------------
- :class:`BenchmarkPresenter` — implement the full ``Presenter`` ABC;
  capture per-turn buffers; :meth:`reset_turn`; :meth:`build_turn`.

Diagnostics
-----------
Domain: OC_CHAT.MAIN
Levels:
    L2 — lifecycle events
    L3 — semantic details
    L4 — deep tracing

Contracts
---------
- A *fresh* presenter (or one used only for a discarded warmup) leaks
  nothing into a measured run; the runner uses a separate throwaway
  presenter for warmup (plan §3.2 step 6).
- :meth:`build_turn` is pure given the captured buffers; it does not
  mutate them.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.benchmarks.metrics (CallMetrics, TurnMetrics, extract_call_metrics)
- oc_ui.presenter_base (Presenter ABC)
- oc_chat.core.session (lazy; ChatSession - type hint for the no-op show_welcome)