gleamunison/transcript
Types
Capture policy: the default redacts privacy-sensitive ability payloads at capture time; CaptureAll is the explicit opt-in for deliberate fixture recording (tape-to-test), whose artifacts are committed by hand.
pub type CapturePolicy {
RedactPrivate
CaptureAll
}
Constructors
-
RedactPrivate -
CaptureAll
One recorded effect call. args/result are inspect-renderings: faithful for the JSON-at-the-boundary abilities (LLM, HTTP), best-effort for opaque values. Live replay uses the raw captured values, not these.
pub type OpRecord {
OpRecord(
ability: String,
op: Int,
args_repr: String,
result_repr: String,
seq: Int,
)
}
Constructors
-
OpRecord( ability: String, op: Int, args_repr: String, result_repr: String, seq: Int, )
Opaque handle to one process-local recording log.
The token is the actual process-dictionary key, so two recorders in the same process own separate tapes.
pub opaque type Recorder
Values
pub fn capture(rec: Recorder) -> Tape
Capture the log as a Tape: serializable entries plus the raw values needed for in-process replay.
pub fn diff(a: Tape, b: Tape) -> List(DiffEntry)
First-divergence diff between two tapes, aligned by seq.
pub fn entries(rec: Recorder) -> List(OpRecord)
Entries recorded so far, in call order (inspect-rendered view).
pub fn from_entries(entries: List(OpRecord)) -> Tape
Build a tape from bare entries (no raw values: audit/diff only, playback from it is empty by construction).
pub fn from_entries_and_raw(
entries: List(OpRecord),
raw: dynamic.Dynamic,
) -> Tape
Build a tape from entries plus their rebuilt raw payloads — the v2 reader’s counterpart to from_entries (the Tape constructor is opaque, so tape assembly stays inside this module).
pub fn is_replayable(tape: Tape) -> Bool
True when the tape carries raw values and can drive a real replay. A tape containing redacted entries is NOT replayable: their payloads were removed at capture, so replay would return markers instead of completions. Run those live. (CaptureAll tapes carry real payloads and stay replayable.)
pub fn run_with_playback(tape: Tape, thunk: fn() -> a) -> a
Run a thunk under playback of the tape. Divergence from the recorded call sequence raises; the tape must be replayable (is_replayable).
pub fn start_with(policy: CapturePolicy) -> Recorder
Deliberate full capture: fixture recording (tape-to-test) and replay auditing. Artifacts contain whatever the recorded code sent — never run this against prompts or sources you would not commit.
pub fn to_json(tape: Tape) -> String
Serialize a tape for audit AND replay: alongside the human-readable reprs, each entry carries base64 term_to_binary blobs of the raw args and result. A tape loaded back from this format replays for real. Tapes built from_entries (no raw) serialize in the old audit-only shape.
pub fn wrap_frames(
rec: Recorder,
frames: List(effects.HandlerFrame),
) -> List(effects.HandlerFrame)
Wrap every op handler in every frame: each call is appended to the log with its ability key, op index, raw args and raw result. The recorded result is what the inner handler passes to the continuation.