mirror of
https://github.com/openai/codex.git
synced 2026-11-05 20:10:33 +00:00
Allow prepared forks to use source revalidation (#59468)
## What changed Add `PreparedFork::with_source_revalidation` for backends that revalidate the source when making the child's history reference durable, allowing the source reservation to be omitted. Rename the reservation-backed constructor to `with_source_reservation` and update the local thread store to use it, preserving its source deletion protection. GitOrigin-RevId: 659c23aaf83a3856eb628ea37f1b0a153d376516
This commit is contained in:
@@ -51,7 +51,7 @@ pub(super) async fn prepare(
|
||||
read_fork_history(store, thread_id, boundary, lineage)
|
||||
})
|
||||
.await?;
|
||||
Ok(PreparedFork::new(
|
||||
Ok(PreparedFork::with_source_reservation(
|
||||
thread_id,
|
||||
history_base,
|
||||
Arc::new(model_context),
|
||||
|
||||
@@ -244,13 +244,17 @@ pub struct PreparedFork {
|
||||
pub history_base: Option<HistoryPosition>,
|
||||
/// Bounded model context selected by the requested fork boundary.
|
||||
pub model_context: Arc<Vec<RolloutItem>>,
|
||||
/// Blocks source deletion until the child's history reference is durable.
|
||||
_source_reservation: Box<dyn std::fmt::Debug + Send>,
|
||||
/// Prevents the source thread from being deleted until the child's history reference is
|
||||
/// finalized.
|
||||
///
|
||||
/// If absent, the backend must revalidate the prepared fork as part of finalizing that
|
||||
/// reference.
|
||||
_source_reservation: Option<Box<dyn std::fmt::Debug + Send>>,
|
||||
}
|
||||
|
||||
impl PreparedFork {
|
||||
/// Creates a frozen fork snapshot while retaining a backend-owned source reservation.
|
||||
pub fn new(
|
||||
pub fn with_source_reservation(
|
||||
source_thread_id: ThreadId,
|
||||
history_base: Option<HistoryPosition>,
|
||||
model_context: Arc<Vec<RolloutItem>>,
|
||||
@@ -260,7 +264,22 @@ impl PreparedFork {
|
||||
source_thread_id,
|
||||
history_base,
|
||||
model_context,
|
||||
_source_reservation: Box::new(source_reservation),
|
||||
_source_reservation: Some(Box::new(source_reservation)),
|
||||
}
|
||||
}
|
||||
|
||||
/// Creates a frozen fork snapshot for a backend that revalidates the source while making the
|
||||
/// child's history reference durable.
|
||||
pub fn with_source_revalidation(
|
||||
source_thread_id: ThreadId,
|
||||
history_base: Option<HistoryPosition>,
|
||||
model_context: Arc<Vec<RolloutItem>>,
|
||||
) -> Self {
|
||||
Self {
|
||||
source_thread_id,
|
||||
history_base,
|
||||
model_context,
|
||||
_source_reservation: None,
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user