Store heartbeat pending timing as typed state

This commit is contained in:
Meta Vens 2026-05-18 07:47:30 +01:00
commit 7088b1a944
6 changed files with 28 additions and 20 deletions

View file

@ -445,6 +445,9 @@ fn tick_once(
started_at: now_iso(),
started_scene_clock: round6(scene_clock),
base_recovery: round6(action.base_recovery),
personality_cooldown_multiplier: Some(round6(personality_cooldown_multiplier(&selected))),
mood_cooldown_multiplier: Some(round6(mood_cooldown_multiplier(&selected))),
effective_cooldown_multiplier: Some(round6(effective_cooldown_multiplier(&selected))),
recovery: round6(recovery),
cooldown_policy: "after_turn_completion".to_string(),
completed_at: None,
@ -452,19 +455,6 @@ fn tick_once(
next_ready_at: None,
extra: BTreeMap::new(),
};
let mut pending = pending;
pending.extra.insert(
"personalityCooldownMultiplier".to_string(),
serde_json::json!(personality_cooldown_multiplier(&selected)),
);
pending.extra.insert(
"moodCooldownMultiplier".to_string(),
serde_json::json!(mood_cooldown_multiplier(&selected)),
);
pending.extra.insert(
"effectiveCooldownMultiplier".to_string(),
serde_json::json!(effective_cooldown_multiplier(&selected)),
);
state.participants[selected_index].pending_turn = Some(pending.clone());
state.participants[selected_index].last_action_id = Some(action.action_id.clone());
state.participants[selected_index].last_woke_at = Some(now_iso());

View file

@ -246,6 +246,12 @@ pub struct HeartbeatPendingTurn {
pub started_scene_clock: f64,
#[serde(rename = "baseRecovery")]
pub base_recovery: f64,
#[serde(rename = "personalityCooldownMultiplier", default)]
pub personality_cooldown_multiplier: Option<f64>,
#[serde(rename = "moodCooldownMultiplier", default)]
pub mood_cooldown_multiplier: Option<f64>,
#[serde(rename = "effectiveCooldownMultiplier", default)]
pub effective_cooldown_multiplier: Option<f64>,
pub recovery: f64,
#[serde(rename = "cooldownPolicy")]
pub cooldown_policy: String,

View file

@ -279,9 +279,9 @@ pub(super) fn pending_turn_json(turn: &HeartbeatPendingTurn) -> Value {
"startedAt": turn.started_at,
"startedSceneClock": turn.started_scene_clock,
"baseRecovery": turn.base_recovery,
"personalityCooldownMultiplier": turn.extra.get("personalityCooldownMultiplier"),
"moodCooldownMultiplier": turn.extra.get("moodCooldownMultiplier"),
"effectiveCooldownMultiplier": turn.extra.get("effectiveCooldownMultiplier"),
"personalityCooldownMultiplier": pending_turn_typed_or_extra(turn, "personalityCooldownMultiplier", turn.personality_cooldown_multiplier),
"moodCooldownMultiplier": pending_turn_typed_or_extra(turn, "moodCooldownMultiplier", turn.mood_cooldown_multiplier),
"effectiveCooldownMultiplier": pending_turn_typed_or_extra(turn, "effectiveCooldownMultiplier", turn.effective_cooldown_multiplier),
"recovery": turn.recovery,
"cooldownPolicy": turn.cooldown_policy,
"completedAt": turn.completed_at,
@ -290,6 +290,17 @@ pub(super) fn pending_turn_json(turn: &HeartbeatPendingTurn) -> Value {
})
}
fn pending_turn_typed_or_extra(
turn: &HeartbeatPendingTurn,
legacy_key: &str,
typed: Option<f64>,
) -> Value {
typed
.map(|value| serde_json::json!(value))
.or_else(|| turn.extra.get(legacy_key).cloned())
.unwrap_or(Value::Null)
}
pub(super) fn history_event_json(event: HeartbeatHistoryEvent) -> Value {
serde_json::json!({
"ts": event.ts,

View file

@ -66,7 +66,7 @@ remembers doctrine; the branch remembers the blade.
- 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.
- 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, and mood timing now live as typed participant fields instead of durable `participant.extra` JSON pockets. Scheduler pacing and status projection read the typed fields first and keep legacy extra fallbacks only as sealed compatibility scars.
- 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 durable document/schema types now live in `epiphany-core/src/heartbeat_state/heartbeat_documents.rs`, role/default construction lives in `epiphany-core/src/heartbeat_state/heartbeat_roles.rs`, persistence/validation lives in `epiphany-core/src/heartbeat_state/heartbeat_store.rs`, and status/artifact JSON projection lives in `epiphany-core/src/heartbeat_state/heartbeat_projection.rs`. The root `heartbeat_state.rs` keeps scheduling and Void cognition orchestration for the next cuts. Focused heartbeat tests and `epiphany-core` check pass after the splits.
- Heartbeat role/default and store seams now have module-local unit tests: fixed lane catalog, Ghostlight scene role projection, and typed state/cognition CultCache round-trip. Keep future heartbeat cuts aligned to those seam tests instead of growing root integration-only coverage.
- Heartbeat adaptive pacing now lives in `epiphany-core/src/heartbeat_state/heartbeat_pacing.rs`, including running-turn count and effective cooldown multipliers. It has a module-local unit test for pending-turn counting; root scheduling calls the pacing seam instead of owning pressure/concurrency math directly.

Binary file not shown.

View file

@ -46,9 +46,10 @@ objective:
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.
Heartbeat participant scene id, personality timing, and mood timing are
typed participant fields with legacy `extra` read fallbacks; scheduler
pacing no longer depends on those values as durable JSON pockets.
Heartbeat participant scene id, personality timing, mood timing, and
pending-turn cooldown multipliers are typed fields with legacy `extra` read
fallbacks; scheduler pacing no longer depends on those values as durable
JSON pockets.
constraints:
- No frontier-scale training tithe.