oc_chat
Loading...
Searching...
No Matches
oc_ui.terminal.stats Namespace Reference

Classes

class  TokenStats
class  TimingStats
class  SessionStats
class  AgentStats
class  StatisticsTracker

Variables

int DEFAULT_CONTEXT_WINDOW_SIZE = 128_000

Detailed Description

Real-time statistics tracking for the OC Chat enhanced terminal UI.

Purpose
-------
Provides the presentation-side statistics tracker that backs the
enhanced terminal header with real-time turn / session / context-usage
counters. Relocated here from ``oc_chat.core.stats`` by plan 153: the
tracker's sole owner and mutator is :class:`~oc_ui.terminal.enhanced_presenter.EnhancedPresenter`,
so it belongs in the ``oc_ui`` adapter layer, not in the harness core.
Keeping it here removes the ``oc_ui -> oc_chat.core.stats`` import edge
named as a boundary residual in plan 151 ยง8.

Responsibilities
-------------
- StatisticsTracker: Main class for tracking all metrics
- Token formatting utilities for K/MB/GB display
- Color-coded statistics for different metric types
- Real-time updates during sessions

Diagnostics
-----------
Domain: OC_UI.STATS
Levels:
    L2 โ€” lifecycle events
    L3 โ€” semantic details
    L4 โ€” deep tracing

Contracts
---------
- All statistics are thread-safe and atomic
- Token counts are formatted with proper units
- Percentages are always displayed with % symbol
- Time values are formatted with appropriate units
- This module imports stdlib + oc_diagnostics only; it MUST NOT import
  ``oc_chat`` (the plan-153 boundary the DAG guard asserts).

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)

Variable Documentation

◆ DEFAULT_CONTEXT_WINDOW_SIZE

int oc_ui.terminal.stats.DEFAULT_CONTEXT_WINDOW_SIZE = 128_000

Definition at line 54 of file stats.py.