core: document compaction tail merge race

Explain the snapshot-to-replace race at both compaction call sites so the extra re-snapshot and append-only tail preservation logic is easier to review.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Charles Cunningham
2026-03-16 20:43:25 -07:00
co-authored by Codex
parent 1023dee640
commit 8335832f1c
2 changed files with 6 additions and 0 deletions
+3
View File
@@ -211,6 +211,9 @@ async fn run_compact_task_inner(
.cloned()
.collect();
new_history.extend(ghost_snapshots);
// Compaction snapshots history, waits on a model call, then replaces
// session history wholesale. Background writers can append during that
// window, so re-snapshot here and preserve any append-only tail items.
let latest_history_snapshot = sess.clone_history().await;
if !append_concurrent_history_tail_if_append_only(
&mut new_history,
+3
View File
@@ -151,6 +151,9 @@ async fn run_remote_compact_task_inner_impl(
if !ghost_snapshots.is_empty() {
new_history.extend(ghost_snapshots);
}
// Remote compaction snapshots history, waits on an API call, then replaces
// session history wholesale. Background writers can append during that
// window, so re-snapshot here and preserve any append-only tail items.
let latest_history_snapshot = sess.clone_history().await;
if !append_concurrent_history_tail_if_append_only(
&mut new_history,