From b75872387885b4d0937bfbac1b2d3ccc483ce474 Mon Sep 17 00:00:00 2001 From: Charles Cunningham Date: Mon, 16 Mar 2026 11:19:47 -0700 Subject: [PATCH] codex: clarify replace_compacted_history contract (#14563) Co-authored-by: Codex --- codex-rs/core/src/codex.rs | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/codex-rs/core/src/codex.rs b/codex-rs/core/src/codex.rs index b5a97c334a..ebdeeef18c 100644 --- a/codex-rs/core/src/codex.rs +++ b/codex-rs/core/src/codex.rs @@ -3358,6 +3358,15 @@ impl Session { state.replace_history(items, reference_context_item); } + /// Replaces session history with a compacted transcript and preserves any + /// append-only concurrent `GhostSnapshot` tail seen under the same state + /// lock. + /// + /// Returns `true` when live history was unchanged or when the only + /// concurrent writes were appended `GhostSnapshot` items that were merged + /// into `items` before replacement. Returns `false` when live history + /// diverged in any other way, in which case replacement still happens but + /// no concurrent tail is merged. pub(crate) async fn replace_compacted_history( &self, mut items: Vec,