Skip to main content

Module session_record

Module session_record 

Source
Expand description

Deterministic session recording and replay for WASM (bd-lff4p.3.7).

Provides SessionRecorder for recording input events, time steps, and resize events during a WASM session, and replay for replaying them through a fresh model to verify that frame checksums match exactly.

§Design

Follows the golden-trace-v1 schema defined in docs/spec/frankenterm-golden-trace-format.md:

  • Header: seed, initial dimensions, capability profile.
  • Input: timestamped terminal events (key, mouse, paste, etc.).
  • Resize: terminal resize events.
  • Tick: explicit time advancement events.
  • Frame: frame checkpoints with FNV-1a checksums and chaining.
  • Summary: total frames and final checksum chain.

§Determinism contract

Given identical recorded inputs and the same model implementation, replay must produce identical frame checksums on the same build. This is guaranteed by:

  1. Host-driven clock (no Instant::now() — time only advances via explicit tick records).
  2. Host-driven events (no polling — events are replayed from the trace).
  3. Deterministic rendering (same model state → same buffer → same checksum).

§Example

let mut recorder = SessionRecorder::new(MyModel::default(), 80, 24, /*seed=*/0);
recorder.init().unwrap();

recorder.push_event(0, key_event('+'));
recorder.advance_time(16_000_000, Duration::from_millis(16));
recorder.step().unwrap();

let trace = recorder.finish();
let result = replay(MyModel::default(), &trace).unwrap();
assert!(result.ok());

Structs§

GateDiff
Detailed diff information for a checksum mismatch.
GateReport
Report from a golden trace gate validation.
ReplayMismatch
Description of a checksum mismatch during replay.
ReplayResult
Result of replaying a session trace.
SessionRecorder
Records a WASM session for deterministic replay.
SessionTrace
A complete recorded session trace.
TraceParseError
Error parsing a JSONL trace.

Enums§

ReplayError
Errors that can occur during replay.
TraceLoadError
Combined load error for parse + validation.
TraceRecord
A single record in a session trace.
TraceValidationError
Typed validation failures for SessionTrace.

Constants§

SCHEMA_VERSION
Schema version for session traces.

Functions§

gate_trace
Validate a trace against a fresh model, returning a detailed report.
replay
Replay a recorded session trace through a fresh model.