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:
- Host-driven clock (no
Instant::now()— time only advances via explicit tick records). - Host-driven events (no polling — events are replayed from the trace).
- 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§
- Gate
Diff - Detailed diff information for a checksum mismatch.
- Gate
Report - Report from a golden trace gate validation.
- Replay
Mismatch - Description of a checksum mismatch during replay.
- Replay
Result - Result of replaying a session trace.
- Session
Recorder - Records a WASM session for deterministic replay.
- Session
Trace - A complete recorded session trace.
- Trace
Parse Error - Error parsing a JSONL trace.
Enums§
- Replay
Error - Errors that can occur during replay.
- Trace
Load Error - Combined load error for parse + validation.
- Trace
Record - A single record in a session trace.
- Trace
Validation Error - 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.