mirror of
https://github.com/openai/codex.git
synced 2026-11-06 20:20:34 +00:00
## What changed Add `history_initialization` to `x-codex-turn-metadata`, distinguishing `new`, `cleared`, `cold_resume`, `warm_fork`, `cold_fork`, and `supplied_history`. Classify forks by whether the source runtime is loaded and has not shut down. Preserve the classification for the runtime's lifetime, including warm resumes and compaction. This records how history was initialized; it does not establish whether tool metadata is missing. Reserve the field against client-supplied overrides. ## Testing Extend coverage for warm and cold forks, cold resumes, warm reconnects, supplied history, WebSocket metadata serialization, and reserved-field filtering. GitOrigin-RevId: 468153512a84d0f4d4ea742198a29e0fa3873a72
35 lines
1.3 KiB
Rust
35 lines
1.3 KiB
Rust
//! Request-only provenance for the history installed when a runtime starts.
|
|
//! Warm resumes retain this value: reconnecting does not reconstruct history or
|
|
//! explain metadata that was already missing before the reconnect.
|
|
|
|
use crate::InitialHistory;
|
|
use serde::Serialize;
|
|
|
|
/// Describes a reconstruction path, not proof that tool metadata was captured or lost.
|
|
/// Fork temperature records whether the source runtime was loaded and not shut down
|
|
/// at initialization. The value lasts for the runtime, including after compaction;
|
|
/// consumers must check missing tool metadata independently for each window.
|
|
#[derive(Clone, Copy, Debug, Serialize)]
|
|
#[serde(rename_all = "snake_case")]
|
|
pub enum HistoryInitialization {
|
|
New,
|
|
Cleared,
|
|
ColdResume,
|
|
WarmFork,
|
|
ColdFork,
|
|
SuppliedHistory,
|
|
}
|
|
|
|
impl HistoryInitialization {
|
|
/// Classifies history without assuming that a fork's source runtime is available.
|
|
pub fn from_history(history: &InitialHistory) -> Self {
|
|
match history {
|
|
InitialHistory::New => Self::New,
|
|
InitialHistory::Cleared => Self::Cleared,
|
|
InitialHistory::Resumed(_) => Self::ColdResume,
|
|
// Callers with a known fork source supply its runtime availability.
|
|
InitialHistory::Forked(_) => Self::SuppliedHistory,
|
|
}
|
|
}
|
|
}
|