Module

testing._record

Session recording — action log writer.

Classes

ActionRecord 3
Single recorded action with timestamp.

Single recorded action with timestamp.

Attributes

Name Type Description
timestamp float
action Action
state_hash str
SessionRecording 4
Complete recorded session.

Complete recorded session.

Attributes

Name Type Description
initial_state Any
records tuple[ActionRecord, ...]
final_state Any
metadata dict[str, str]

Functions

state_hash 1 str
SHA256 hash of state repr, truncated to 16 chars.
def state_hash(state: Any) -> str
Parameters
Name Type Description
state Any
Returns
str
recording_middleware 1 Any
Create a middleware that records actions and state hashes.
def recording_middleware(records: list[dict]) -> Any
Parameters
Name Type Description
records list[dict]
Returns
Any
save_recording 5 None
Save a session recording to JSONL.
def save_recording(path: str | Path, initial_state: Any, records: list[dict], final_state: Any, metadata: dict[str, str] | None = None) -> None
Parameters
Name Type Description
path str | Path
initial_state Any
records list[dict]
final_state Any
metadata dict[str, str] | None Default:None
load_recording 1 SessionRecording
Load a session recording from JSONL.
def load_recording(path: str | Path) -> SessionRecording
Parameters
Name Type Description
path str | Path
Returns
SessionRecording