Seal Epiphany rollout snapshot anchoring

This commit is contained in:
Meta Vens 2026-05-18 10:40:45 +01:00
commit 6d4b83d1c4
6 changed files with 68 additions and 8 deletions

View file

@ -15,6 +15,26 @@ pub struct EpiphanyStateItem {
pub state: EpiphanyThreadState,
}
impl EpiphanyStateItem {
pub fn anchored_to_turn(turn_id: impl Into<String>, state: EpiphanyThreadState) -> Self {
Self {
turn_id: Some(turn_id.into()),
state,
}
}
pub fn for_optional_turn(turn_id: Option<String>, state: EpiphanyThreadState) -> Self {
Self { turn_id, state }
}
pub fn out_of_band(state: EpiphanyThreadState) -> Self {
Self {
turn_id: None,
state,
}
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS, Default)]
pub struct EpiphanyThreadState {
pub revision: u64,
@ -98,6 +118,41 @@ pub struct EpiphanyAcceptanceReceipt {
pub summary: Option<String>,
}
#[cfg(test)]
mod tests {
use super::EpiphanyStateItem;
use super::EpiphanyThreadState;
#[test]
fn state_item_constructors_name_snapshot_anchoring() {
let state = EpiphanyThreadState {
revision: 7,
..Default::default()
};
let anchored = EpiphanyStateItem::anchored_to_turn("turn-7", state.clone());
assert_eq!(anchored.turn_id.as_deref(), Some("turn-7"));
assert_eq!(anchored.state, state);
let optional = EpiphanyStateItem::for_optional_turn(
Some("turn-8".to_string()),
EpiphanyThreadState {
revision: 8,
..Default::default()
},
);
assert_eq!(optional.turn_id.as_deref(), Some("turn-8"));
assert_eq!(optional.state.revision, 8);
let out_of_band = EpiphanyStateItem::out_of_band(EpiphanyThreadState {
revision: 9,
..Default::default()
});
assert!(out_of_band.turn_id.is_none());
assert_eq!(out_of_band.state.revision, 9);
}
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, Eq, JsonSchema, TS, Default)]
pub struct EpiphanyRuntimeLink {
pub id: String,

View file

@ -65,6 +65,7 @@ remembers doctrine; the branch remembers the blade.
- Vendored app-server no longer imports `epiphany_core` directly. Retrieval query normalization and raw route job-launch DTO construction are bridge-owned adapters; the remaining direct native render call is in Codex core's model-context prompt fragment host seam.
- Coordinator automation input assembly and pre-compaction intervention text rendering now belong to `epiphany-codex-bridge`; vendored app-server keeps only host actions: submit Codex compaction, launch through bridge, steer active turns, and emit JSON-RPC notifications.
- Epiphany prompt-state boundary tags now live in `epiphany-state-model` and are re-exported through `codex-protocol`; Codex compatibility may wrap the prompt fragment, but it no longer owns those marker constants.
- Epiphany rollout snapshot anchoring now lives in typed `EpiphanyStateItem` constructors (`anchored_to_turn`, `for_optional_turn`, `out_of_band`) in `epiphany-state-model`. Codex core still physically writes rollout/session items, but live host code no longer hand-assembles the turn/out-of-band snapshot shape.
- Heartbeat adaptive pacing now lives as typed CultCache state on `EpiphanyHeartbeatStateEntry` instead of being written into `state.extra["adaptivePacing"]` as JSON. Status projection still emits JSON and reads the old extra pocket as a legacy fallback.
- Heartbeat participant scene id, personality timing, mood timing, and pending-turn cooldown multipliers now live as typed fields instead of durable `participant.extra` / `pendingTurn.extra` JSON pockets. Scheduler pacing and status projection read the typed fields first and keep legacy extra fallbacks only as sealed compatibility scars.
- Heartbeat cognition appraisals and reactions now live as typed CultCache fields instead of `Option<Value>` blobs. The mood-timing scheduler consumes typed appraisals directly; legacy cognition migration parses old appraisal/reaction JSON only when loading prior stores.

Binary file not shown.

View file

@ -43,6 +43,9 @@ objective:
JSON-RPC notifications.
Epiphany prompt-state boundary tags live in `epiphany-state-model` and are
re-exported through `codex-protocol` for compatibility.
Epiphany rollout snapshot anchoring lives on the typed state item
constructors in `epiphany-state-model`; Codex may physically persist
snapshots, but it should not hand-assemble their turn/out-of-band meaning.
Heartbeat adaptive pacing is now a typed CultCache field on
`EpiphanyHeartbeatStateEntry`; JSON projection remains only for status and
artifact output, with legacy `extra["adaptivePacing"]` as read fallback.

View file

@ -345,10 +345,9 @@ impl CodexThread {
.await;
self.codex
.session
.persist_rollout_items(&[RolloutItem::EpiphanyState(EpiphanyStateItem {
turn_id: reference_turn_id,
state: state.clone(),
})])
.persist_rollout_items(&[RolloutItem::EpiphanyState(
EpiphanyStateItem::for_optional_turn(reference_turn_id, state.clone()),
)])
.await;
self.codex.session.flush_rollout().await?;
Ok(state)

View file

@ -2550,10 +2550,12 @@ impl Session {
self.persist_rollout_items(&[RolloutItem::TurnContext(turn_context_item.clone())])
.await;
if let Some(epiphany_state) = self.epiphany_state().await {
self.persist_rollout_items(&[RolloutItem::EpiphanyState(EpiphanyStateItem {
turn_id: turn_context_item.turn_id.clone(),
state: epiphany_state,
})])
self.persist_rollout_items(&[RolloutItem::EpiphanyState(
EpiphanyStateItem::for_optional_turn(
turn_context_item.turn_id.clone(),
epiphany_state,
),
)])
.await;
}