Add ephemeral turn context support

Introduce app-server ephemeralContext, render it as additional_context_for_this_turn fragments, and strip it correctly across contextual-user diffing and compaction flows.

Regenerate app-server schema fixtures and add coverage for model-visible layout, compaction, oversize validation, and resumed/forked context reconstruction.

Co-authored-by: Codex <noreply@openai.com>
This commit is contained in:
Charles Cunningham
2026-03-13 11:41:35 -07:00
co-authored by Codex
parent 4bcfdafd01
commit 72d53a2c9b
54 changed files with 1422 additions and 26 deletions
+19 -1
View File
@@ -19,7 +19,9 @@
//! - `ContextualUserContextRole` for contextual user-role state that must be
//! parsed as context rather than literal user intent
//! - If the fragment is durable turn/session state that should rebuild across
//! resume, compaction, backtracking, or fork, implement `build(...)`.
//! resume, compaction, backtracking, or fork, implement `build(...)` for the
//! common zero-or-one case, or override `build_many(...)` when a fragment
//! source needs to emit multiple content items from one turn-state source.
//! `reference_context_item` is the baseline already represented in
//! model-visible history; compare against it to avoid duplicates, and use
//! `TurnContextDiffParams` for other runtime/session inputs such as
@@ -187,6 +189,22 @@ pub(crate) trait ModelVisibleContextFragment: Sized {
None
}
/// Build zero or more fragments from the current turn state.
///
/// Most fragments should implement `build(...)` and use this default,
/// which lifts the common zero-or-one case into a vector. Override this
/// only when one turn-state source intentionally renders multiple
/// model-visible content items.
fn build_many(
turn_context: &TurnContext,
reference_context_item: Option<&TurnContextItem>,
params: &TurnContextDiffParams<'_>,
) -> Vec<Self> {
Self::build(turn_context, reference_context_item, params)
.into_iter()
.collect()
}
/// Stable markers used to recognize contextual-user fragments in persisted
/// history. Developer fragments should keep the default `None`.
fn contextual_user_markers() -> Option<ContextualUserFragmentMarkers> {