Files
codex/codex-rs/rollout-trace/src/payload.rs
cassirer-openai 27d9673273 [rollout_trace] Add rollout trace crate (#18876)
## Summary

Adds the standalone `codex-rollout-trace` crate, which defines the raw
trace event format, replay/reduction model, writer, and reducer logic
for reconstructing model-visible conversation/runtime state from
recorded rollout data.

The crate-level design is documented in
[`codex-rs/rollout-trace/README.md`](https://github.com/openai/codex/blob/codex/rollout-trace-crate/codex-rs/rollout-trace/README.md).

## Stack

This is PR 1/5 in the rollout trace stack.

- [#18876](https://github.com/openai/codex/pull/18876): Add rollout
trace crate
- [#18877](https://github.com/openai/codex/pull/18877): Record core
session rollout traces
- [#18878](https://github.com/openai/codex/pull/18878): Trace tool and
code-mode boundaries
- [#18879](https://github.com/openai/codex/pull/18879): Trace sessions
and multi-agent edges
- [#18880](https://github.com/openai/codex/pull/18880): Add debug trace
reduction command

## Review Notes

This PR intentionally does not wire tracing into live Codex execution.
It establishes the data model and reducer contract first, with
crate-local tests covering conversation reconstruction, compaction
boundaries, tool/session edges, and code-cell lifecycle reduction. Later
PRs emit into this model.

The README is the best entry point for reviewing the intended trace
format and reduction semantics before diving into the reducer modules.
2026-04-21 21:54:05 +00:00

50 lines
1.9 KiB
Rust

//! References to heavyweight trace payloads stored outside the reduced graph.
use serde::Deserialize;
use serde::Serialize;
/// Stable identifier for one raw payload inside a rollout bundle.
pub type RawPayloadId = String;
/// Reference to a raw request/response/log payload.
///
/// `RolloutTrace` stores these references so normal timeline and conversation
/// rendering does not require the browser or reducer output to inline every
/// upstream request, tool response, or terminal log.
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
pub struct RawPayloadRef {
pub raw_payload_id: RawPayloadId,
/// Payload role. This lets details UI choose syntax highlighting and labels
/// without opening the payload file first.
pub kind: RawPayloadKind,
/// Path relative to the trace bundle root.
///
/// The writer always materializes payloads as bundle-local files. Keeping
/// this as a plain path avoids exposing storage modes we do not produce.
pub path: String,
}
/// Coarse role of a raw payload.
#[derive(Debug, Clone, PartialEq, Eq, PartialOrd, Ord, Serialize, Deserialize)]
#[serde(rename_all = "snake_case", tag = "type", content = "value")]
pub enum RawPayloadKind {
InferenceRequest,
/// Full upstream inference response or non-delta response stream summary.
InferenceResponse,
CompactionRequest,
/// Trace-only checkpoint captured when processed replacement history is installed.
CompactionCheckpoint,
CompactionResponse,
ToolInvocation,
ToolResult,
/// Raw runtime/protocol observation for an executing tool.
ToolRuntimeEvent,
/// Raw terminal runtime event or stream shard.
TerminalRuntimeEvent,
ProtocolEvent,
/// One-shot metadata captured when a Codex session/thread starts.
SessionMetadata,
/// Runtime notification payload carried when a child agent reports back to its parent.
AgentResult,
}