pub async fn run_replay<B: LlmBackend + ?Sized>(
baseline: &[Record],
backend: &B,
clock: &dyn Clock,
) -> Result<Vec<Record>, ReplayError>Expand description
Run a replay: walk baseline, dispatch every chat_request to backend,
and produce a fresh trace with the same structure.
Algorithm (SPEC §10.1):
- Emit a new
metadatarecord withparent = Noneand an envelopemeta.baseline_of = baseline_root_id. - For each baseline record in file order:
chat_request: re-emit with a fresh ts and parent = previous output record id; then callbackend.complete(request.payload)and emit achat_responsewhose parent = the re-emitted request.tool_call,tool_result,error: copy-through with fresh ts and relinked parent.chat_response,metadata,replay_summary: skipped (the backend produces responses; replay_summary is added at the end; a baseline can only have one metadata record and it’s the root).
- Emit a
replay_summaryat the end.