mirror of
https://github.com/openai/codex.git
synced 2026-11-13 21:30:47 +00:00
## What changed - Replace individual JSON payload files with numbered Zstandard shards in trace schema v3. Add `PayloadReader` to resolve payload references, cache decoded shards, and validate payloads during replay. - Capture exact outgoing HTTP bodies and WebSocket messages alongside prepared prompts. Preserve full formatted context for continuations from unrecorded WebSocket warmups while retaining the actual incremental request. - Flush payload records before publishing references and seal the final shard before recording completion. Replace `recording_complete` with `recording_status` to distinguish unclosed recordings, closed recordings with partial payloads, and complete recordings. Reduce trace bundles with the binary that recorded them. ## Testing Add coverage for shard rotation, oversized records, live reads, cache eviction, and malformed or corrupt payloads. Extend HTTP and WebSocket integration assertions to verify captured requests and prepared prompts, including warmup continuations. GitOrigin-RevId: 40ce3c11383f48e08f52e7120b706c61a449df9c
84 lines
3.5 KiB
Rust
84 lines
3.5 KiB
Rust
//! Trace bundle format, writer, and reducer for Codex rollouts.
|
|
//!
|
|
//! This crate owns the trace schema. Hot-path Codex code should depend on the
|
|
//! small writer API here; semantic replay and viewer projections stay outside
|
|
//! `codex-core`.
|
|
//!
|
|
//! Only the recording executable replays raw events. Consumers read the reduced
|
|
//! `state.json` and use manifest metadata for bundle discovery. See `README.md`.
|
|
|
|
mod bundle;
|
|
mod code_cell;
|
|
mod compaction;
|
|
mod inference;
|
|
mod mcp;
|
|
mod model;
|
|
mod payload;
|
|
mod protocol_event;
|
|
mod raw_event;
|
|
mod reducer;
|
|
mod shard;
|
|
mod thread;
|
|
mod tool_dispatch;
|
|
mod writer;
|
|
|
|
/// Conventional file name for the consumer-facing reduced trace.
|
|
pub use bundle::REDUCED_STATE_FILE_NAME;
|
|
/// No-op-capable handle for recording one code-mode runtime cell.
|
|
pub use code_cell::CodeCellTraceContext;
|
|
/// Raw checkpoint payload for a remote compaction install event.
|
|
pub use compaction::CompactionCheckpointTracePayload;
|
|
/// No-op-capable handle for recording remote-compaction requests.
|
|
pub use compaction::CompactionTraceAttempt;
|
|
/// Shared recorder context for a compaction checkpoint.
|
|
pub use compaction::CompactionTraceContext;
|
|
/// No-op-capable handle for recording one upstream inference attempt.
|
|
pub use inference::InferenceTraceAttempt;
|
|
/// Shared recorder context for inference attempts within one Codex turn.
|
|
pub use inference::InferenceTraceContext;
|
|
pub use inference::serialize_trace_items;
|
|
/// Trace-owned MCP execution correlation propagated to bridge request metadata.
|
|
pub use mcp::McpCallTraceContext;
|
|
/// Public reduced trace model returned by replay.
|
|
pub use model::*;
|
|
pub use payload::PayloadCapture;
|
|
/// Stable identifier for one raw payload inside a rollout bundle.
|
|
pub use payload::RawPayloadId;
|
|
/// Coarse role labels for raw payload files.
|
|
pub use payload::RawPayloadKind;
|
|
/// Reference to a raw request/response/log payload stored in the bundle.
|
|
pub use payload::RawPayloadRef;
|
|
/// Monotonic sequence number assigned by the raw trace writer.
|
|
pub use raw_event::RawEventSeq;
|
|
/// Runtime requester observed before semantic reduction.
|
|
pub use raw_event::RawToolCallRequester;
|
|
/// One append-only raw trace event from `trace.jsonl`.
|
|
pub use raw_event::RawTraceEvent;
|
|
/// Event-envelope context supplied by hot-path trace producers.
|
|
pub use raw_event::RawTraceEventContext;
|
|
/// Typed payload for one raw trace event.
|
|
pub use raw_event::RawTraceEventPayload;
|
|
/// Replay a bundle recorded by this executable into a `RolloutTrace`.
|
|
pub use reducer::replay_bundle;
|
|
pub use shard::PayloadReader;
|
|
/// Raw payload captured when a child agent reports completion to its parent.
|
|
pub use thread::AgentResultTracePayload;
|
|
/// Environment variable that enables local trace-bundle recording.
|
|
pub use thread::CODEX_ROLLOUT_TRACE_ROOT_ENV;
|
|
/// Raw metadata captured when a thread starts.
|
|
pub use thread::ThreadStartedTraceMetadata;
|
|
/// No-op-capable handle for recording one thread in a rollout bundle.
|
|
pub use thread::ThreadTraceContext;
|
|
/// Request data for the canonical Codex tool boundary.
|
|
pub use tool_dispatch::ToolDispatchInvocation;
|
|
/// Tool input observed at the registry boundary.
|
|
pub use tool_dispatch::ToolDispatchPayload;
|
|
/// Runtime source that caused a dispatch-level tool call.
|
|
pub use tool_dispatch::ToolDispatchRequester;
|
|
/// Result data returned from a dispatch-level tool call.
|
|
pub use tool_dispatch::ToolDispatchResult;
|
|
/// No-op-capable handle for recording one resolved tool dispatch.
|
|
pub use tool_dispatch::ToolDispatchTraceContext;
|
|
/// Append-only writer used by hot-path Codex instrumentation.
|
|
pub use writer::TraceWriter;
|