mirror of
https://github.com/openai/codex.git
synced 2026-11-20 22:40:37 +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
52 lines
1.8 KiB
Rust
52 lines
1.8 KiB
Rust
//! Trace bundle manifest and local layout constants.
|
|
|
|
use serde::Deserialize;
|
|
use serde::Serialize;
|
|
|
|
use crate::model::AgentThreadId;
|
|
|
|
pub(crate) const MANIFEST_FILE_NAME: &str = "manifest.json";
|
|
pub(crate) const RAW_EVENT_LOG_FILE_NAME: &str = "trace.jsonl";
|
|
pub(crate) const PAYLOADS_DIR_NAME: &str = "payloads";
|
|
/// Conventional file name for the reducer's serialized `RolloutTrace`.
|
|
pub const REDUCED_STATE_FILE_NAME: &str = "state.json";
|
|
/// On-disk bundle layout described by manifest.json.
|
|
pub(crate) const TRACE_MANIFEST_SCHEMA_VERSION: u32 = 3;
|
|
/// Bump for every change to the consumer-facing `state.json` schema.
|
|
pub(crate) const REDUCED_TRACE_SCHEMA_VERSION: u32 = 3;
|
|
|
|
/// Manifest stored at the root of a trace bundle.
|
|
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
|
pub(crate) struct TraceBundleManifest {
|
|
pub(crate) schema_version: u32,
|
|
pub(crate) trace_id: String,
|
|
pub(crate) rollout_id: String,
|
|
/// Root thread for the recorded rollout. Replay should fail rather than
|
|
/// inventing a placeholder, because every reduced object is scoped back to
|
|
/// this thread tree.
|
|
pub(crate) root_thread_id: AgentThreadId,
|
|
pub(crate) started_at_unix_ms: i64,
|
|
pub(crate) raw_event_log: String,
|
|
pub(crate) payloads_dir: String,
|
|
}
|
|
|
|
impl TraceBundleManifest {
|
|
/// Builds a manifest that uses the standard local bundle layout.
|
|
pub(crate) fn new(
|
|
trace_id: String,
|
|
rollout_id: String,
|
|
root_thread_id: AgentThreadId,
|
|
started_at_unix_ms: i64,
|
|
) -> Self {
|
|
Self {
|
|
schema_version: TRACE_MANIFEST_SCHEMA_VERSION,
|
|
trace_id,
|
|
rollout_id,
|
|
root_thread_id,
|
|
started_at_unix_ms,
|
|
raw_event_log: RAW_EVENT_LOG_FILE_NAME.to_string(),
|
|
payloads_dir: PAYLOADS_DIR_NAME.to_string(),
|
|
}
|
|
}
|
|
}
|