oc_chat
Loading...
Searching...
No Matches
oc_chat.scripts.replay Namespace Reference

Classes

class  _UserError

Functions

ReplayTree _load_tree (str event_dir)
str _resolve_turn (ReplayTree tree, str prefix)
argparse.ArgumentParser _build_parser ()
None _run_summary (ReplayTree tree, bool as_json)
int main (Optional[Sequence[str]] argv=None)

Variables

int _MIN_PREFIX = 4

Detailed Description

CLI shell for offline session replay over the event NDJSON — M2.7.

Purpose
-------
A thin ``argparse`` front-end over :mod:`oc_chat.core.replay`. Resolves an event
directory, reads + reconstructs the session tree, and prints it as text or
``replay/v0`` JSON. Three subcommands: ``session`` (full tree), ``turn`` (one
turn by id or ≥4-char prefix), ``summary`` (per-kind counts only). Never calls a
provider; never mutates the log.

Responsibilities
----------------
- :func:`main` — parse args, dispatch, map outcomes to exit codes (0 ok,
  1 unexpected error, 2 user error) with a one-line ``error:`` on stderr.
- :func:`_resolve_turn` — turn-id prefix matching with ambiguity handling.

Diagnostics
-----------
Domain: OC_CHAT.REPLAY
Levels:
    L2 — CLI invocation + chosen subcommand.
    L3 — resolution detail (event count, matched turn).
    L4 — module-load coverage marker.

Contracts
---------
- Exit 0 on success, 2 on user error (missing dir / bad prefix / bad args),
  1 on unexpected exception; all errors print ``error: …`` to stderr first.
- Read-only: no provider calls, no mutation of the event log.

Dependencies
------------
- oc_diagnostics (structured debug logging via _dbg)
- oc_chat.core.replay (read_events_from_dir, build_replay_tree, renderers)

Function Documentation

◆ _build_parser()

argparse.ArgumentParser oc_chat.scripts.replay._build_parser ( )
protected
Build the ``replay`` argument parser with its three subcommands.

Definition at line 90 of file replay.py.

Here is the caller graph for this function:

◆ _load_tree()

ReplayTree oc_chat.scripts.replay._load_tree ( str event_dir)
protected
Read *event_dir* and build the replay tree; raise :class:`_UserError` if missing.

Definition at line 67 of file replay.py.

Here is the caller graph for this function:

◆ _resolve_turn()

str oc_chat.scripts.replay._resolve_turn ( ReplayTree tree,
str prefix )
protected
Return the single ``turn_id`` matching *prefix* (≥4 chars); raise on miss/ambiguity.

Definition at line 78 of file replay.py.

Here is the caller graph for this function:

◆ _run_summary()

None oc_chat.scripts.replay._run_summary ( ReplayTree tree,
bool as_json )
protected
Print the cheap per-kind count view for *tree*.

Definition at line 114 of file replay.py.

Here is the caller graph for this function:

◆ main()

int oc_chat.scripts.replay.main ( Optional[Sequence[str]] argv = None)
Entry point. Returns the process exit code (0 ok, 1 error, 2 user error).

Definition at line 129 of file replay.py.

Here is the call graph for this function:

Variable Documentation

◆ _MIN_PREFIX

int oc_chat.scripts.replay._MIN_PREFIX = 4
protected

Definition at line 60 of file replay.py.