diff --git a/epiphany-core/src/bin/epiphany-heartbeat-store.rs b/epiphany-core/src/bin/epiphany-heartbeat-store.rs index 34ddf15b..01734e56 100644 --- a/epiphany-core/src/bin/epiphany-heartbeat-store.rs +++ b/epiphany-core/src/bin/epiphany-heartbeat-store.rs @@ -3,6 +3,7 @@ use anyhow::Result; use anyhow::anyhow; use epiphany_core::GhostlightSceneParticipantSeed; use epiphany_core::HeartbeatCompleteOptions; +use epiphany_core::HeartbeatHeatUpdateOptions; use epiphany_core::HeartbeatPumpOptions; use epiphany_core::HeartbeatTickOptions; use epiphany_core::VoidRoutineOptions; @@ -15,6 +16,7 @@ use epiphany_core::load_heartbeat_state_entry; use epiphany_core::pump_heartbeat_store; use epiphany_core::run_void_routine_store; use epiphany_core::tick_heartbeat_store; +use epiphany_core::update_heartbeat_heat_store; use epiphany_core::validate_agent_memory_store; use std::env; use std::fs; @@ -52,6 +54,14 @@ fn main() -> Result<()> { let mut scene_participants = Vec::::new(); let mut source = "epiphany/void-routine".to_string(); let mut no_dream = false; + let mut heat_scope = "global".to_string(); + let mut heat_selector = String::new(); + let mut heat_multiplier = 1.0_f64; + let mut heat_id: Option = None; + let mut heat_label: Option = None; + let mut heat_reason: Option = None; + let mut heat_expires_after: Option = None; + let mut heat_clear = false; while let Some(arg) = args.next() { match arg.as_str() { @@ -96,6 +106,16 @@ fn main() -> Result<()> { )?), "--source" => source = next_value(&mut args, "--source")?, "--no-dream" => no_dream = true, + "--scope" => heat_scope = next_value(&mut args, "--scope")?, + "--selector" => heat_selector = next_value(&mut args, "--selector")?, + "--multiplier" => heat_multiplier = next_value(&mut args, "--multiplier")?.parse()?, + "--id" => heat_id = Some(next_value(&mut args, "--id")?), + "--label" => heat_label = Some(next_value(&mut args, "--label")?), + "--reason" => heat_reason = Some(next_value(&mut args, "--reason")?), + "--expires-after" => { + heat_expires_after = Some(next_value(&mut args, "--expires-after")?.parse()?) + } + "--clear" => heat_clear = true, _ => return Err(anyhow!("unknown argument {arg:?}")), } } @@ -207,6 +227,23 @@ fn main() -> Result<()> { )?; println!("{}", result); } + "heat" => { + let store_path = store_path.ok_or_else(|| anyhow!("heat requires --store"))?; + let result = update_heartbeat_heat_store( + &store_path, + HeartbeatHeatUpdateOptions { + scope: heat_scope, + selector: heat_selector, + multiplier: heat_multiplier, + id: heat_id, + label: heat_label, + reason: heat_reason, + expires_after_scene_clock: heat_expires_after, + clear: heat_clear, + }, + )?; + println!("{}", result); + } "status" => { let store_path = store_path.ok_or_else(|| anyhow!("status requires --store"))?; if let Some(artifact_dir) = artifact_dir { @@ -285,7 +322,7 @@ fn next_value(args: &mut impl Iterator, name: &str) -> Result Result<()> { Err(anyhow!( - "usage: epiphany-heartbeat-store init --store [--profile epiphany|ghostlight-scene] [--scene-id ] [--scene-participant ]\n epiphany-heartbeat-store tick --store --artifact-dir [--coordinator-action ] [--agent-store --apply-rumination] [--defer-completion]\n epiphany-heartbeat-store pump --store --artifact-dir [--agent-store ] [--urgency <0..1>] [--min-heartbeat-rate ] [--max-heartbeat-rate ] [--min-concurrency ] [--max-concurrency ] [--max-ticks ]\n epiphany-heartbeat-store complete --store --artifact-dir --role [--action-id ]\n epiphany-heartbeat-store status --store [--artifact-dir ]\n epiphany-heartbeat-store routine --store --artifact-dir [--agent-store ] [--source ] [--no-dream]\n epiphany-heartbeat-store smoke [--agent-store ]" + "usage: epiphany-heartbeat-store init --store [--profile epiphany|ghostlight-scene] [--scene-id ] [--scene-participant ]\n epiphany-heartbeat-store tick --store --artifact-dir [--coordinator-action ] [--agent-store --apply-rumination] [--defer-completion]\n epiphany-heartbeat-store pump --store --artifact-dir [--agent-store ] [--urgency <0..1>] [--min-heartbeat-rate ] [--max-heartbeat-rate ] [--min-concurrency ] [--max-concurrency ] [--max-ticks ]\n epiphany-heartbeat-store heat --store [--scope global|all|agent|role|arena|participant_kind|group] [--selector ] [--multiplier ] [--id ] [--label ] [--reason ] [--expires-after ] [--clear]\n epiphany-heartbeat-store complete --store --artifact-dir --role [--action-id ]\n epiphany-heartbeat-store status --store [--artifact-dir ]\n epiphany-heartbeat-store routine --store --artifact-dir [--agent-store ] [--source ] [--no-dream]\n epiphany-heartbeat-store smoke [--agent-store ]" )) } @@ -335,6 +372,21 @@ fn run_smoke(agent_store: &Path) -> Result { } initialize_heartbeat_store(&store_path, 1.0)?; + let heat = update_heartbeat_heat_store( + &store_path, + HeartbeatHeatUpdateOptions { + scope: "role".to_string(), + selector: "implementation".to_string(), + multiplier: 4.0, + id: Some("smoke-implementation-heat".to_string()), + label: Some("Smoke implementation heat".to_string()), + reason: Some( + "Prove heartbeat initiative heat changes the live turn surface.".to_string(), + ), + expires_after_scene_clock: Some(20.0), + clear: false, + }, + )?; let work = tick_heartbeat_store( &store_path, &artifact_dir, @@ -477,6 +529,21 @@ fn run_smoke(agent_store: &Path) -> Result { && idle["rumination"]["result"]["status"] == "accepted" && validation_errors.is_empty() && initiative_errors.is_empty() + && heat["heat"]["multipliers"] + .as_array() + .is_some_and(|multipliers| { + multipliers.iter().any(|multiplier| { + multiplier["id"] == "smoke-implementation-heat" + && multiplier["scope"] == "role" + && multiplier["selector"] == "implementation" + && multiplier["multiplier"].as_f64() == Some(4.0) + }) + }) + && work["schedule"]["action_catalog"] + .as_array() + .and_then(|actions| actions.first()) + .and_then(|action| action["initiative_heat_multiplier"].as_f64()) + == Some(4.0) && artifact_dir.join("smoke-work.initiative.json").exists() && artifact_dir.join("smoke-work.completion.json").exists() && artifact_dir.join("smoke-idle.rumination.json").exists() @@ -557,6 +624,7 @@ fn run_smoke(agent_store: &Path) -> Result { let result = serde_json::json!({ "ok": ok, "workEvent": work["event"], + "heat": heat["heat"], "blockedRepeat": blocked_repeat, "completionEvent": completed["event"], "idleEvent": idle["event"], diff --git a/epiphany-core/src/heartbeat_state.rs b/epiphany-core/src/heartbeat_state.rs index 8b04ca3f..96914a40 100644 --- a/epiphany-core/src/heartbeat_state.rs +++ b/epiphany-core/src/heartbeat_state.rs @@ -14,8 +14,23 @@ mod heartbeat_projection; mod heartbeat_roles; mod heartbeat_store; pub use heartbeat_documents::*; +use heartbeat_pacing::adaptive_swarm_pacing; +use heartbeat_pacing::apply_initiative_heat_policy; +use heartbeat_pacing::effective_cooldown_multiplier; +use heartbeat_pacing::initiative_heat_multiplier; +use heartbeat_pacing::mood_cooldown_multiplier; +use heartbeat_pacing::personality_cooldown_multiplier; +use heartbeat_pacing::running_turn_count; pub use heartbeat_projection::heartbeat_status_projection; +use heartbeat_projection::history_event_json; +use heartbeat_projection::pending_turn_json; +use heartbeat_projection::schedule_participant_json; +use heartbeat_projection::selection_policy_json; +use heartbeat_roles::ROLE_ORDER; +use heartbeat_roles::agent_id_for_role; pub use heartbeat_roles::default_heartbeat_state; +use heartbeat_roles::default_participant; +use heartbeat_roles::display_name_for_role; pub use heartbeat_roles::ghostlight_scene_heartbeat_state; pub use heartbeat_roles::initialize_ghostlight_scene_heartbeat_store; pub use heartbeat_roles::initialize_heartbeat_store; @@ -26,19 +41,6 @@ pub use heartbeat_store::validate_heartbeat_cognition; pub use heartbeat_store::validate_heartbeat_state; pub use heartbeat_store::write_heartbeat_cognition_entry; pub use heartbeat_store::write_heartbeat_state_entry; -use heartbeat_projection::history_event_json; -use heartbeat_projection::pending_turn_json; -use heartbeat_projection::schedule_participant_json; -use heartbeat_projection::selection_policy_json; -use heartbeat_pacing::adaptive_swarm_pacing; -use heartbeat_pacing::effective_cooldown_multiplier; -use heartbeat_pacing::mood_cooldown_multiplier; -use heartbeat_pacing::personality_cooldown_multiplier; -use heartbeat_pacing::running_turn_count; -use heartbeat_roles::ROLE_ORDER; -use heartbeat_roles::agent_id_for_role; -use heartbeat_roles::default_participant; -use heartbeat_roles::display_name_for_role; pub(super) const HEARTBEAT_ARENA_MAINTENANCE: &str = "maintenance"; pub(super) const HEARTBEAT_ARENA_SCENE: &str = "scene"; @@ -73,8 +75,12 @@ pub fn run_void_routine_store( apply_personality_timing_profiles(&mut state, &appraisal_profiles); let resonance = build_memory_resonance(&memory_records); let incubation = build_incubation( - &previous_cognition.as_ref().and_then(|entry| entry.incubation.clone()), - &previous_cognition.as_ref().and_then(|entry| entry.bridge.clone()), + &previous_cognition + .as_ref() + .and_then(|entry| entry.incubation.clone()), + &previous_cognition + .as_ref() + .and_then(|entry| entry.bridge.clone()), &previous_cognition .as_ref() .and_then(|entry| entry.candidate_interventions.clone()), @@ -83,7 +89,9 @@ pub fn run_void_routine_store( ); let thought_lanes = build_thought_lanes(&resonance, &incubation, &memory_records); let bridge = build_thought_bridge( - &previous_cognition.as_ref().and_then(|entry| entry.bridge.clone()), + &previous_cognition + .as_ref() + .and_then(|entry| entry.bridge.clone()), &thought_lanes, &resonance, &incubation, @@ -181,6 +189,7 @@ pub fn tick_heartbeat_store( { apply_mood_timing_from_appraisals(&mut state, &appraisals); } + apply_initiative_heat_policy(&mut state); let result = tick_once(&mut state, &options)?; write_heartbeat_state_entry(store_path, &state)?; @@ -228,6 +237,7 @@ pub fn pump_heartbeat_store( { apply_mood_timing_from_appraisals(&mut state, &appraisals); } + apply_initiative_heat_policy(&mut state); let pacing = adaptive_swarm_pacing(&state, &options); state.target_heartbeat_rate = pacing.effective_heartbeat_rate; @@ -335,6 +345,96 @@ pub fn pump_heartbeat_store( })) } +pub fn update_heartbeat_heat_store( + store_path: impl AsRef, + options: HeartbeatHeatUpdateOptions, +) -> Result { + let store_path = store_path.as_ref(); + let mut state = load_heartbeat_state_entry(store_path)?.unwrap_or_else(|| { + let mut state = default_heartbeat_state(1.0); + patch_missing_participants(&mut state); + state + }); + patch_missing_participants(&mut state); + let scope = options.scope.trim().to_lowercase(); + let selector = options.selector.trim().to_string(); + let id = options.id.clone().unwrap_or_else(|| { + if scope == "global" { + "global".to_string() + } else { + format!("{scope}:{selector}") + } + }); + + if options.clear { + if scope == "global" || id == "global" { + state.initiative_heat.global_multiplier = 1.0; + } + state + .initiative_heat + .multipliers + .retain(|multiplier| multiplier.id != id); + } else if scope == "global" { + state.initiative_heat.global_multiplier = options.multiplier.clamp(0.05, 25.0); + } else { + if selector.is_empty() && scope != "all" { + return Err(anyhow!( + "heartbeat heat selector is required for scope {scope}" + )); + } + let multiplier = HeartbeatInitiativeMultiplier { + id: id.clone(), + label: options.label.clone().unwrap_or_default(), + scope: scope.clone(), + selector: selector.clone(), + multiplier: options.multiplier.clamp(0.05, 25.0), + reason: options.reason.clone().unwrap_or_default(), + updated_at: Some(now_iso()), + expires_at_scene_clock: options + .expires_after_scene_clock + .map(|delta| round6(state.scene_clock + delta.max(0.0))), + extra: BTreeMap::new(), + }; + state + .initiative_heat + .multipliers + .retain(|existing| existing.id != id); + state.initiative_heat.multipliers.push(multiplier); + state + .initiative_heat + .multipliers + .sort_by(|left, right| left.id.cmp(&right.id)); + } + apply_initiative_heat_policy(&mut state); + write_heartbeat_state_entry(store_path, &state)?; + Ok(serde_json::json!({ + "ok": true, + "command": "heat", + "storeFile": store_path, + "heat": initiative_heat_json(&state), + "participants": state.participants.iter().map(schedule_participant_json).collect::>(), + })) +} + +fn initiative_heat_json(state: &EpiphanyHeartbeatStateEntry) -> Value { + serde_json::json!({ + "schemaVersion": state.initiative_heat.schema_version, + "globalMultiplier": state.initiative_heat.global_multiplier, + "multipliers": state.initiative_heat.multipliers.iter().map(|multiplier| { + serde_json::json!({ + "id": multiplier.id, + "label": multiplier.label, + "scope": multiplier.scope, + "selector": multiplier.selector, + "multiplier": multiplier.multiplier, + "reason": multiplier.reason, + "updatedAt": multiplier.updated_at, + "expiresAtSceneClock": multiplier.expires_at_scene_clock, + }) + }).collect::>(), + }) +} + pub fn complete_heartbeat_store( store_path: impl AsRef, artifact_dir: impl AsRef, @@ -462,6 +562,10 @@ fn tick_once( "effectiveCooldownMultiplier".to_string(), serde_json::json!(effective_cooldown_multiplier(&selected)), ); + pending.extra.insert( + "initiativeHeatMultiplier".to_string(), + serde_json::json!(initiative_heat_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()); @@ -516,6 +620,7 @@ fn tick_once( "base_recovery": action.base_recovery, "personality_cooldown_multiplier": personality_cooldown_multiplier(&selected_after), "mood_cooldown_multiplier": mood_cooldown_multiplier(&selected_after), + "initiative_heat_multiplier": initiative_heat_multiplier(&selected_after), "effective_cooldown_multiplier": effective_cooldown_multiplier(&selected_after), "initiative_cost": action.initiative_cost, "interruptibility": action.interruptibility, diff --git a/epiphany-core/src/heartbeat_state/heartbeat_documents.rs b/epiphany-core/src/heartbeat_state/heartbeat_documents.rs index 4187e84a..a31b7ed0 100644 --- a/epiphany-core/src/heartbeat_state/heartbeat_documents.rs +++ b/epiphany-core/src/heartbeat_state/heartbeat_documents.rs @@ -34,6 +34,8 @@ pub struct EpiphanyHeartbeatStateEntry { pub participants: Vec, #[cultcache(key = 6)] pub history: Vec, + #[cultcache(key = 16, default)] + pub initiative_heat: HeartbeatInitiativeHeatPolicy, #[cultcache(key = 15, default)] pub extra: BTreeMap, } @@ -135,6 +137,50 @@ pub struct HeartbeatPacingPolicy { pub extra: BTreeMap, } +#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)] +pub struct HeartbeatInitiativeHeatPolicy { + #[serde(default = "default_heat_schema_version")] + pub schema_version: String, + #[serde(default = "default_heat_global_multiplier")] + pub global_multiplier: f64, + #[serde(default)] + pub multipliers: Vec, + #[serde(flatten)] + pub extra: BTreeMap, +} + +impl Default for HeartbeatInitiativeHeatPolicy { + fn default() -> Self { + Self { + schema_version: default_heat_schema_version(), + global_multiplier: default_heat_global_multiplier(), + multipliers: Vec::new(), + extra: BTreeMap::new(), + } + } +} + +#[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] +pub struct HeartbeatInitiativeMultiplier { + pub id: String, + #[serde(default)] + pub label: String, + #[serde(default = "default_heat_scope")] + pub scope: String, + #[serde(default)] + pub selector: String, + #[serde(default = "default_heat_global_multiplier")] + pub multiplier: f64, + #[serde(default)] + pub reason: String, + #[serde(default)] + pub updated_at: Option, + #[serde(default)] + pub expires_at_scene_clock: Option, + #[serde(flatten)] + pub extra: BTreeMap, +} + #[derive(Clone, Debug, Default, PartialEq, Serialize, Deserialize)] pub struct HeartbeatParticipant { pub agent_id: String, @@ -256,6 +302,18 @@ pub struct HeartbeatPumpOptions { pub agent_store: Option, } +#[derive(Clone, Debug, PartialEq)] +pub struct HeartbeatHeatUpdateOptions { + pub scope: String, + pub selector: String, + pub multiplier: f64, + pub id: Option, + pub label: Option, + pub reason: Option, + pub expires_after_scene_clock: Option, + pub clear: bool, +} + #[derive(Clone, Debug, PartialEq)] pub struct HeartbeatCompleteOptions { pub role: String, @@ -278,3 +336,15 @@ pub struct GhostlightSceneParticipantSeed { pub interrupt_threshold: f64, pub constraints: Vec, } + +fn default_heat_schema_version() -> String { + "epiphany.heartbeat_initiative_heat.v0".to_string() +} + +fn default_heat_global_multiplier() -> f64 { + 1.0 +} + +fn default_heat_scope() -> String { + "agent".to_string() +} diff --git a/epiphany-core/src/heartbeat_state/heartbeat_pacing.rs b/epiphany-core/src/heartbeat_state/heartbeat_pacing.rs index 15f76a80..17c6c892 100644 --- a/epiphany-core/src/heartbeat_state/heartbeat_pacing.rs +++ b/epiphany-core/src/heartbeat_state/heartbeat_pacing.rs @@ -1,4 +1,5 @@ use super::EpiphanyHeartbeatStateEntry; +use super::HeartbeatInitiativeMultiplier; use super::HeartbeatParticipant; use super::HeartbeatPumpOptions; use super::round3; @@ -164,8 +165,102 @@ pub(super) fn mood_cooldown_multiplier(participant: &HeartbeatParticipant) -> f6 } pub(super) fn effective_cooldown_multiplier(participant: &HeartbeatParticipant) -> f64 { - round3(personality_cooldown_multiplier(participant) * mood_cooldown_multiplier(participant)) - .clamp(0.20, 4.0) + round3( + personality_cooldown_multiplier(participant) * mood_cooldown_multiplier(participant) + / initiative_heat_multiplier(participant), + ) + .clamp(0.05, 8.0) +} + +pub(super) fn initiative_heat_multiplier(participant: &HeartbeatParticipant) -> f64 { + participant + .extra + .get("initiativeHeatMultiplier") + .and_then(Value::as_f64) + .unwrap_or(1.0) + .clamp(0.05, 25.0) +} + +pub(super) fn apply_initiative_heat_policy(state: &mut EpiphanyHeartbeatStateEntry) { + let global = state.initiative_heat.global_multiplier.clamp(0.05, 25.0); + let active_multipliers = state + .initiative_heat + .multipliers + .iter() + .filter(|multiplier| { + multiplier + .expires_at_scene_clock + .is_none_or(|expires| expires > state.scene_clock) + }) + .cloned() + .collect::>(); + for participant in &mut state.participants { + let mut heat = global; + let mut basis = Vec::::new(); + for multiplier in &active_multipliers { + if multiplier_matches_participant(multiplier, participant) { + let value = multiplier.multiplier.clamp(0.05, 25.0); + heat *= value; + basis.push(serde_json::json!({ + "id": multiplier.id, + "scope": multiplier.scope, + "selector": multiplier.selector, + "multiplier": value, + "reason": multiplier.reason, + })); + } + } + let heat = round3(heat.clamp(0.05, 25.0)); + participant.extra.insert( + "initiativeHeatMultiplier".to_string(), + serde_json::json!(heat), + ); + participant.extra.insert( + "initiativeHeat".to_string(), + serde_json::json!({ + "schema_version": "epiphany.heartbeat_initiative_heat_projection.v0", + "globalMultiplier": global, + "effectiveMultiplier": heat, + "basis": basis, + "contract": "Initiative heat accelerates turn recovery. Proximity or agency pressure may raise heat, but the typed heat policy remains the authority." + }), + ); + } +} + +fn multiplier_matches_participant( + multiplier: &HeartbeatInitiativeMultiplier, + participant: &HeartbeatParticipant, +) -> bool { + let selector = multiplier.selector.trim(); + match multiplier.scope.as_str() { + "all" => true, + "agent" | "agent_id" => eq_key(&participant.agent_id, selector), + "role" | "role_id" => eq_key(&participant.role_id, selector), + "arena" => eq_key(participant.arena.as_str(), selector), + "participant_kind" | "kind" => eq_key(participant.participant_kind.as_str(), selector), + "group" | "constraint" => { + participant + .constraints + .iter() + .any(|constraint| eq_key(constraint, selector)) + || participant + .extra + .get("groups") + .and_then(Value::as_array) + .is_some_and(|groups| { + groups + .iter() + .filter_map(Value::as_str) + .any(|group| eq_key(group, selector)) + }) + } + _ => false, + } +} + +fn eq_key(left: &str, right: &str) -> bool { + left.trim().eq_ignore_ascii_case(right.trim()) } #[cfg(test)] @@ -177,17 +272,55 @@ mod tests { #[test] fn running_turn_count_reads_only_running_pending_turns() { let mut state = default_heartbeat_state(1.0); - state.participants[0].pending_turn = - Some(crate::heartbeat_state::HeartbeatPendingTurn { - status: "running".to_string(), - ..Default::default() - }); - state.participants[1].pending_turn = - Some(crate::heartbeat_state::HeartbeatPendingTurn { - status: "completed".to_string(), - ..Default::default() - }); + state.participants[0].pending_turn = Some(crate::heartbeat_state::HeartbeatPendingTurn { + status: "running".to_string(), + ..Default::default() + }); + state.participants[1].pending_turn = Some(crate::heartbeat_state::HeartbeatPendingTurn { + status: "completed".to_string(), + ..Default::default() + }); assert_eq!(running_turn_count(&state), 1); } + + #[test] + fn initiative_heat_multiplies_agent_and_group_recovery_speed() { + let mut state = default_heartbeat_state(1.0); + state.initiative_heat.global_multiplier = 2.0; + state.initiative_heat.multipliers = vec![ + HeartbeatInitiativeMultiplier { + id: "hands".to_string(), + scope: "role".to_string(), + selector: "implementation".to_string(), + multiplier: 3.0, + ..Default::default() + }, + HeartbeatInitiativeMultiplier { + id: "all-maintenance".to_string(), + scope: "arena".to_string(), + selector: "maintenance".to_string(), + multiplier: 1.5, + ..Default::default() + }, + ]; + + apply_initiative_heat_policy(&mut state); + let implementation = state + .participants + .iter() + .find(|participant| participant.role_id == "implementation") + .expect("implementation participant"); + let research = state + .participants + .iter() + .find(|participant| participant.role_id == "research") + .expect("research participant"); + + assert_eq!(initiative_heat_multiplier(implementation), 9.0); + assert_eq!(initiative_heat_multiplier(research), 3.0); + assert!( + effective_cooldown_multiplier(implementation) < effective_cooldown_multiplier(research) + ); + } } diff --git a/epiphany-core/src/heartbeat_state/heartbeat_projection.rs b/epiphany-core/src/heartbeat_state/heartbeat_projection.rs index f4454ec5..b4f1ddb1 100644 --- a/epiphany-core/src/heartbeat_state/heartbeat_projection.rs +++ b/epiphany-core/src/heartbeat_state/heartbeat_projection.rs @@ -9,6 +9,7 @@ use super::HeartbeatPendingTurn; use super::HeartbeatSelectionPolicy; use super::VOID_ROUTINE_SCHEMA_VERSION; use super::effective_cooldown_multiplier; +use super::initiative_heat_multiplier; use super::load_heartbeat_cognition_entry; use super::load_heartbeat_state_entry; use super::mood_cooldown_multiplier; @@ -68,6 +69,22 @@ pub fn heartbeat_status_projection( "artifactDir": artifact_dir.as_ref(), "targetHeartbeatRate": state.target_heartbeat_rate, "sceneClock": state.scene_clock, + "initiativeHeat": { + "schemaVersion": state.initiative_heat.schema_version, + "globalMultiplier": state.initiative_heat.global_multiplier, + "multipliers": state.initiative_heat.multipliers.iter().map(|multiplier| { + serde_json::json!({ + "id": multiplier.id, + "label": multiplier.label, + "scope": multiplier.scope, + "selector": multiplier.selector, + "multiplier": multiplier.multiplier, + "reason": multiplier.reason, + "updatedAt": multiplier.updated_at, + "expiresAtSceneClock": multiplier.expires_at_scene_clock, + }) + }).collect::>(), + }, "participants": state.participants.iter().map(participant_status_json).collect::>(), "latestEvent": history.last().cloned(), "history": history, @@ -82,7 +99,7 @@ pub fn heartbeat_status_projection( "appraisals": cognition.as_ref().and_then(|entry| entry.appraisals.clone()), "reactions": cognition.as_ref().and_then(|entry| entry.reactions.clone()), "adaptivePacing": state.extra.get("adaptivePacing"), - "availableActions": ["init", "tick", "pump", "complete", "status", "routine"], + "availableActions": ["init", "tick", "pump", "heat", "complete", "status", "routine"], })) } @@ -94,7 +111,10 @@ fn latest_json_artifacts(artifact_dir: impl AsRef, limit: usize) -> Vec = read_dir .filter_map(Result::ok) .map(|entry| entry.path()) - .filter(|path| path.extension().is_some_and(|extension| extension == "json")) + .filter(|path| { + path.extension() + .is_some_and(|extension| extension == "json") + }) .filter_map(|path| { let modified = path.metadata().and_then(|meta| meta.modified()).ok()?; Some((path, modified)) @@ -121,7 +141,8 @@ fn latest_json_artifacts(artifact_dir: impl AsRef, limit: usize) -> Vec Value { - if payload.get("schema_version") == Some(&Value::String(VOID_ROUTINE_SCHEMA_VERSION.to_string())) + if payload.get("schema_version") + == Some(&Value::String(VOID_ROUTINE_SCHEMA_VERSION.to_string())) { return serde_json::json!({ "runId": payload.get("runId"), @@ -203,6 +224,8 @@ fn participant_status_json(participant: &HeartbeatParticipant) -> Value { "initiativeSpeed": participant.initiative_speed, "personalityCooldownMultiplier": personality_cooldown_multiplier(participant), "moodCooldownMultiplier": mood_cooldown_multiplier(participant), + "initiativeHeatMultiplier": initiative_heat_multiplier(participant), + "initiativeHeat": participant.extra.get("initiativeHeat"), "effectiveCooldownMultiplier": effective_cooldown_multiplier(participant), "personalityTiming": participant.extra.get("personalityTiming"), "moodTiming": participant.extra.get("moodTiming"), @@ -228,6 +251,7 @@ pub(super) fn schedule_participant_json(participant: &HeartbeatParticipant) -> V "initiative_speed": participant.initiative_speed, "personality_cooldown_multiplier": personality_cooldown_multiplier(participant), "mood_cooldown_multiplier": mood_cooldown_multiplier(participant), + "initiative_heat_multiplier": initiative_heat_multiplier(participant), "effective_cooldown_multiplier": effective_cooldown_multiplier(participant), "next_ready_at": participant.next_ready_at, "reaction_bias": participant.reaction_bias, @@ -261,6 +285,7 @@ pub(super) fn pending_turn_json(turn: &HeartbeatPendingTurn) -> Value { "baseRecovery": turn.base_recovery, "personalityCooldownMultiplier": turn.extra.get("personalityCooldownMultiplier"), "moodCooldownMultiplier": turn.extra.get("moodCooldownMultiplier"), + "initiativeHeatMultiplier": turn.extra.get("initiativeHeatMultiplier"), "effectiveCooldownMultiplier": turn.extra.get("effectiveCooldownMultiplier"), "recovery": turn.recovery, "cooldownPolicy": turn.cooldown_policy, diff --git a/epiphany-core/src/heartbeat_state/heartbeat_roles.rs b/epiphany-core/src/heartbeat_state/heartbeat_roles.rs index 0fec8355..8081d18c 100644 --- a/epiphany-core/src/heartbeat_state/heartbeat_roles.rs +++ b/epiphany-core/src/heartbeat_state/heartbeat_roles.rs @@ -55,6 +55,7 @@ pub fn default_heartbeat_state(target_heartbeat_rate: f64) -> EpiphanyHeartbeatS .map(|role_id| default_participant(role_id)) .collect(), history: Vec::new(), + initiative_heat: Default::default(), extra: BTreeMap::new(), } } @@ -254,7 +255,9 @@ fn participant_constraints(role_id: &str) -> Vec<&'static str> { } "imagination" => "Synthesizes futures; must not adopt objectives.", "research" => "Scouts known work; must not turn research into procrastination.", - "modeling" => "Grows source-grounded maps and checkpoints; must not edit implementation code.", + "modeling" => { + "Grows source-grounded maps and checkpoints; must not edit implementation code." + } "implementation" => { "Touches source only with accepted guidance and verifier-readable evidence." } diff --git a/epiphany-core/src/heartbeat_state/heartbeat_store.rs b/epiphany-core/src/heartbeat_state/heartbeat_store.rs index d451e7ce..f4e8f9a1 100644 --- a/epiphany-core/src/heartbeat_state/heartbeat_store.rs +++ b/epiphany-core/src/heartbeat_state/heartbeat_store.rs @@ -59,7 +59,8 @@ pub fn load_heartbeat_cognition_entry( ) -> Result> { let store_path = store_path.as_ref(); let cache = heartbeat_state_cache(store_path)?; - if let Some(cognition) = cache.get::(HEARTBEAT_COGNITION_KEY)? + if let Some(cognition) = + cache.get::(HEARTBEAT_COGNITION_KEY)? { return Ok(Some(cognition)); } @@ -154,6 +155,29 @@ pub fn validate_heartbeat_state(state: &EpiphanyHeartbeatStateEntry) -> Result<( "heartbeat target_heartbeat_rate must be non-negative" )); } + if state.initiative_heat.global_multiplier <= 0.0 { + return Err(anyhow!( + "heartbeat initiative_heat global_multiplier must be positive" + )); + } + for multiplier in &state.initiative_heat.multipliers { + if multiplier.id.trim().is_empty() { + return Err(anyhow!("heartbeat initiative heat multiplier has empty id")); + } + if multiplier.multiplier <= 0.0 { + return Err(anyhow!( + "heartbeat initiative heat multiplier {} must be positive", + multiplier.id + )); + } + if multiplier.selector.trim().is_empty() && multiplier.scope != "all" { + return Err(anyhow!( + "heartbeat initiative heat multiplier {} selector is empty for scope {}", + multiplier.id, + multiplier.scope + )); + } + } for participant in &state.participants { if participant.agent_id.trim().is_empty() { return Err(anyhow!("heartbeat participant has empty agent_id")); @@ -233,7 +257,10 @@ mod tests { let loaded_cognition = load_heartbeat_cognition_entry(&store_path)? .expect("heartbeat cognition should round-trip through CultCache"); - assert_eq!(loaded_cognition.schema_version, HEARTBEAT_COGNITION_SCHEMA_VERSION); + assert_eq!( + loaded_cognition.schema_version, + HEARTBEAT_COGNITION_SCHEMA_VERSION + ); assert_eq!(loaded_cognition.latest_run_id.as_deref(), Some("run-1")); Ok(()) } diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 47a9e258..6048e99f 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -63,7 +63,10 @@ pub use heartbeat_state::HEARTBEAT_STATE_KEY; pub use heartbeat_state::HEARTBEAT_STATE_SCHEMA_VERSION; pub use heartbeat_state::HEARTBEAT_STATE_TYPE; pub use heartbeat_state::HeartbeatCompleteOptions; +pub use heartbeat_state::HeartbeatHeatUpdateOptions; pub use heartbeat_state::HeartbeatHistoryEvent; +pub use heartbeat_state::HeartbeatInitiativeHeatPolicy; +pub use heartbeat_state::HeartbeatInitiativeMultiplier; pub use heartbeat_state::HeartbeatPacingPolicy; pub use heartbeat_state::HeartbeatParticipant; pub use heartbeat_state::HeartbeatPendingTurn; @@ -83,6 +86,7 @@ pub use heartbeat_state::load_heartbeat_state_entry; pub use heartbeat_state::pump_heartbeat_store; pub use heartbeat_state::run_void_routine_store; pub use heartbeat_state::tick_heartbeat_store; +pub use heartbeat_state::update_heartbeat_heat_store; pub use heartbeat_state::validate_heartbeat_cognition; pub use heartbeat_state::validate_heartbeat_state; pub use heartbeat_state::write_heartbeat_cognition_entry; diff --git a/epiphany-core/src/runtime_spine.rs b/epiphany-core/src/runtime_spine.rs index 7d33923e..567aa75b 100644 --- a/epiphany-core/src/runtime_spine.rs +++ b/epiphany-core/src/runtime_spine.rs @@ -1501,11 +1501,13 @@ fn epiphany_mutation_contracts() -> Vec { CultNetMutationAuthority::Coordinator, vec![ "epiphany.heartbeat_pump_intent.v0", + "epiphany.heartbeat_heat_intent.v0", "epiphany.circadian_rhythm_intent.v0", ], vec!["epiphany.swarm_control_receipt.v0"], vec![ "Aquarium controls heartbeat and circadian rhythm through typed intents, not blind state replacement.", + "Initiative heat is heartbeat policy: global, group, role, and agent tempo changes enter through the heartbeat heat intent.", ], ), mutation_contract( @@ -2154,6 +2156,14 @@ mod tests { .operations .contains(&CultNetDocumentOperation::IntentSubmit) ); + assert!( + heartbeat_contract + .intent_document_types + .as_ref() + .is_some_and(|items| items + .iter() + .any(|item| item == "epiphany.heartbeat_heat_intent.v0")) + ); let coordinator_contract = contracts .iter() .find(|contract| contract.document_type == SURFACE_COORDINATOR_TYPE) @@ -2260,6 +2270,14 @@ mod tests { schema.document_type.as_deref() == Some("epiphany.role_launch_intent.v0") && schema.schema_version.as_deref() == Some("epiphany.role_launch_intent.v0") })); + assert!(schemas.iter().any(|schema| { + schema.document_type.as_deref() == Some("epiphany.heartbeat_initiative_heat.v0") + && schema.schema_version.as_deref() == Some("epiphany.heartbeat_initiative_heat.v0") + })); + assert!(schemas.iter().any(|schema| { + schema.document_type.as_deref() == Some("epiphany.heartbeat_heat_intent.v0") + && schema.schema_version.as_deref() == Some("epiphany.heartbeat_heat_intent.v0") + })); assert!(schemas.iter().any(|schema| { schema.document_type.as_deref() == Some("epiphany.swarm_control_receipt.v0") && schema.schema_version.as_deref() == Some("epiphany.swarm_control_receipt.v0") diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index ca7f6488..706fbd5b 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -94,6 +94,8 @@ remembers doctrine; the branch remembers the blade. - The Ghostlight memory pass is landed. `epiphany_specialists.toml` now has a shared persistent-memory projection prepended by the harness to fixed role specialists, reorientation workers, coordinator notes, and CRRC checkpoint interventions. The rendered base doctrine also states the Perfect Machine rule directly: prompt is projection, durable typed state is the mind, every lane must improve its own memory/model/prompt/evidence habit or name the repair, and each lane phrases that duty in its own organ language so the salience sticks. - The role self-memory persistence pass is native now. Each lane has a Ghostlight-shaped typed dossier in `state/agents.msgpack`, and specialists may return optional `selfPatch` requests beside their normal role result. `roleResult`/`roleAccept` project coordinator review as `selfPersistence`: accepted requests are role-matched, bounded lane memory/goal/value/private-note mutations; refused requests explain wrong role, project-truth smuggling, authority grabs, bloat, missing reason, or malformed records. GUI/coordinator accept paths apply accepted `selfPatch` requests through the native `epiphany-agent-memory-store` binary; project truth still belongs only in `EpiphanyThreadState`. - The heartbeat initiative pass is landed as a bounded tool seam. `state/agent-heartbeats.msgpack` tracks Self, Face, Imagination, Eyes, Body, Hands, Soul, and Life as Ghostlight-style initiative participants with arena, participant kind, speed, next-ready time, reaction bias, interrupt threshold, load, status, constraints, personality cooldown, mood cooldown, effective cooldown, adaptive pacing, history, and pending turns through `epiphany-core::EpiphanyHeartbeatStateEntry` and the native `epiphany-heartbeat-store` binary. Role dossiers set baseline timing; appraisal mood/anxiety bends it through urgency, arousal, thought pressure, guardedness, and reaction intensity, so Hands-like work pressure and high-need anxious lanes recover sooner without being heartbeaten while a prior turn is running. `epiphany-heartbeat-store pump` computes pressure from external urgency, mood/anxiety, reaction intensity, thought pressure, and current pending load, then chooses tempo plus target concurrency: calm can launch zero and sleep slow; alarm can fill most active lanes. Idle turns are for rumination: light thought shuffling, role-quality attention, and candidate selfPatch pressure. Sleep/dream cycle passes are the intended distillation window for durable self-memory and doctrine. JSON heartbeat state and Python wrapper state are gone; general CultCache schema sync, polyglot domain loading, and debug display tools belong in CultLib. This is a callable scheduler seam, not yet an always-on daemon; a heart valve, not a whole circulatory god. + +- Heartbeat initiative heat is now part of that seam. `EpiphanyHeartbeatStateEntry` owns `initiative_heat`, pacing applies active global/all/agent/role/arena/participant-kind/group/constraint multipliers into per-participant `initiativeHeatMultiplier`, and recovery divides by that multiplier. The CLI exposes `epiphany-heartbeat-store heat`, status/schedule projections show heat, and the CultNet catalog advertises both `epiphany.heartbeat_initiative_heat.v0` and coordinator intent `epiphany.heartbeat_heat_intent.v0`; runtime-spine hello lists the heat intent on the heartbeat mutation contract. Smoke proves a heated implementation lane reaches the live action catalog with `initiative_heat_multiplier: 4.0`. - The first Ghostlight-derived timing slice is landed in Epiphany, but Ghostlight is reference lineage rather than a sibling runtime to preserve. `epiphany-heartbeat-store init --profile ghostlight-scene --scene-id --scene-participant ` creates a typed CultCache MessagePack scene heartbeat store whose participants are `arena=scene`, `participantKind=character`; `tick` emits `ghostlight.initiative_schedule.v0` receipts with `scene_turn` actions and local-affordance basis. The generic Epiphany maintenance lanes are not auto-patched into scene stores. - The first Void-derived routine slice is landed in Epiphany, but VoidBot is reference lineage rather than a runtime dependency. `epiphany-heartbeat-store routine --store .\state\agent-heartbeats.msgpack --artifact-dir .\.epiphany-heartbeats --agent-store .\state\agents.msgpack` reads typed role dossiers, computes bounded memory resonance, maintains incubation themes, runs analytic and associative cognition lanes, writes bridge syntheses/saturation/tension, projects the active thought cluster through each role's Ghostlight-shaped personality vectors, derives participant-local reactions, applies personality/mood timing, advances the sleep/dream cycle, updates the typed heartbeat store, and emits an auditable `epiphany.void_routine.v0` receipt. The routine now also carries anti-loop physiology imported from Void's calmer brain: `noveltyToSelf`, `noveltyToRoom`, source coverage, saturation pressure, refractory cooling, and explicit permission to let a live unsaturated thought deepen without forcing novelty theater every pass. This mutates only heartbeat physiology fields: project truth and role memory mutation remain on their reviewed surfaces. - The next memory foundation must not build separate engines for repo graph and agent mind. Heartbeat cognition, role self-memory, repo architecture/dataflow, evidence scars, incubation, agency pressure, and context packets should converge through `EpiphanyMemoryGraph` profiles so one typed graph owns anchors, lifecycle, summaries, freshness, context cuts, and Qdrant embedding manifests. Repo, agent, and heartbeat profile producers now map accepted graph truth, reviewed role dossier memories/goals/values, and provisional heartbeat short-term/incubation/agency/candidate pressure into memory graph documents without scanner/Qdrant/model work. Heartbeat import deliberately does not mark durable promotion. Compose now merges profile snapshots into one validated graph and rejects duplicate authority; `epiphany-memory-graph compose` writes a composed typed CultCache graph from typed source graph stores; `epiphany-memory-graph refresh` can invoke live agent-memory plus heartbeat-cognition producers from their typed stores into one graph store; `epiphany-core` has a native typed `EpiphanyThreadState` CultCache store seam; the bridge mirrors loaded Codex-thread Epiphany state into `state/thread-state.msgpack`; and CultNet now advertises logical `EpiphanyThreadState` plus `EpiphanyMemoryGraph` snapshot contracts. The next clean slice is local refresh/dogfood once a mirrored thread-state store exists, then a Qdrant embedding cache writer that treats embeddings as rebuildable manifests, not canonical memory. diff --git a/schemas/cultnet/epiphany.agent-heartbeat.schema.json b/schemas/cultnet/epiphany.agent-heartbeat.schema.json index 33fdad17..c327aa29 100644 --- a/schemas/cultnet/epiphany.agent-heartbeat.schema.json +++ b/schemas/cultnet/epiphany.agent-heartbeat.schema.json @@ -23,6 +23,9 @@ "type": "object", "additionalProperties": true }, + "initiativeHeat": { + "$ref": "epiphany.heartbeat_initiative_heat.v0.schema.json" + }, "participants": { "type": "array", "items": { diff --git a/schemas/cultnet/epiphany.heartbeat_heat_intent.v0.schema.json b/schemas/cultnet/epiphany.heartbeat_heat_intent.v0.schema.json new file mode 100644 index 00000000..d750a0fe --- /dev/null +++ b/schemas/cultnet/epiphany.heartbeat_heat_intent.v0.schema.json @@ -0,0 +1,82 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_heat_intent.v0.schema.json", + "title": "epiphany heartbeat_heat_intent v0", + "description": "Coordinator intent for changing heartbeat initiative heat at global, group, arena, role, or agent scope.", + "type": "object", + "additionalProperties": true, + "properties": { + "threadId": { + "type": "string" + }, + "storeKey": { + "type": [ + "string", + "null" + ], + "description": "Optional heartbeat store key when the coordinator hosts more than one heartbeat arena." + }, + "scope": { + "$ref": "epiphany.heartbeat_initiative_heat.v0.schema.json#/definitions/scope" + }, + "selector": { + "type": "string", + "description": "Agent id, role id, arena, participant kind, group, or constraint selected by scope. Empty only for global/all." + }, + "multiplier": { + "type": "number", + "exclusiveMinimum": 0, + "description": "Recovery-speed multiplier. Values above 1 turn up heat; values below 1 cool the selected lane." + }, + "id": { + "type": [ + "string", + "null" + ], + "description": "Stable policy id. Defaults to global or scope:selector when omitted." + }, + "label": { + "type": [ + "string", + "null" + ] + }, + "reason": { + "type": [ + "string", + "null" + ] + }, + "expiresAfterSceneClock": { + "type": [ + "number", + "null" + ], + "description": "Relative scene-clock duration before the multiplier stops affecting participants." + }, + "clear": { + "type": "boolean", + "default": false + } + }, + "required": [ + "threadId", + "scope" + ], + "allOf": [ + { + "if": { + "properties": { + "clear": { + "const": false + } + } + }, + "then": { + "required": [ + "multiplier" + ] + } + } + ] +} diff --git a/schemas/cultnet/epiphany.heartbeat_initiative_heat.v0.schema.json b/schemas/cultnet/epiphany.heartbeat_initiative_heat.v0.schema.json new file mode 100644 index 00000000..434fed25 --- /dev/null +++ b/schemas/cultnet/epiphany.heartbeat_initiative_heat.v0.schema.json @@ -0,0 +1,91 @@ +{ + "$schema": "http://json-schema.org/draft-07/schema#", + "$id": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_initiative_heat.v0.schema.json", + "title": "epiphany heartbeat_initiative_heat v0", + "description": "Heartbeat initiative heat policy. Multipliers accelerate or relax turn recovery without granting project authority.", + "type": "object", + "additionalProperties": true, + "properties": { + "schemaVersion": { + "const": "epiphany.heartbeat_initiative_heat.v0" + }, + "globalMultiplier": { + "type": "number", + "exclusiveMinimum": 0 + }, + "multipliers": { + "type": "array", + "items": { + "$ref": "#/definitions/multiplier" + } + } + }, + "required": [ + "schemaVersion", + "globalMultiplier", + "multipliers" + ], + "definitions": { + "scope": { + "type": "string", + "enum": [ + "global", + "all", + "agent", + "agent_id", + "role", + "role_id", + "arena", + "participant_kind", + "kind", + "group", + "constraint" + ] + }, + "multiplier": { + "type": "object", + "additionalProperties": true, + "properties": { + "id": { + "type": "string", + "minLength": 1 + }, + "label": { + "type": "string" + }, + "scope": { + "$ref": "#/definitions/scope" + }, + "selector": { + "type": "string" + }, + "multiplier": { + "type": "number", + "exclusiveMinimum": 0 + }, + "reason": { + "type": "string" + }, + "updatedAt": { + "type": [ + "string", + "null" + ], + "format": "date-time" + }, + "expiresAtSceneClock": { + "type": [ + "number", + "null" + ] + } + }, + "required": [ + "id", + "scope", + "selector", + "multiplier" + ] + } + } +} diff --git a/schemas/cultnet/index.json b/schemas/cultnet/index.json index d688f4f8..dd833d25 100644 --- a/schemas/cultnet/index.json +++ b/schemas/cultnet/index.json @@ -122,6 +122,17 @@ "title": "Epiphany Heartbeat State", "path": "epiphany.agent-heartbeat.schema.json" }, + { + "schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_initiative_heat.v0.schema.json", + "kind": "document_payload", + "wireContracts": [ + "cultnet.schema.v0" + ], + "schemaVersion": "epiphany.heartbeat_initiative_heat.v0", + "documentType": "epiphany.heartbeat_initiative_heat.v0", + "title": "epiphany heartbeat_initiative_heat v0", + "path": "epiphany.heartbeat_initiative_heat.v0.schema.json" + }, { "schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.agent-heartbeat-cognition.schema.json", "kind": "document_payload", @@ -397,6 +408,17 @@ "title": "epiphany heartbeat_pump_intent v0", "path": "epiphany.heartbeat_pump_intent.v0.schema.json" }, + { + "schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.heartbeat_heat_intent.v0.schema.json", + "kind": "document_payload", + "wireContracts": [ + "cultnet.schema.v0" + ], + "schemaVersion": "epiphany.heartbeat_heat_intent.v0", + "documentType": "epiphany.heartbeat_heat_intent.v0", + "title": "epiphany heartbeat_heat_intent v0", + "path": "epiphany.heartbeat_heat_intent.v0.schema.json" + }, { "schemaId": "https://gamecult.dev/epiphany/cultnet/epiphany.circadian_rhythm_intent.v0.schema.json", "kind": "document_payload", diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index d583bff5..655c398d 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ diff --git a/state/map.yaml b/state/map.yaml index 827d18fc..bde9e483 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -77,7 +77,7 @@ active_subgoals: - Preserve read-only boundaries for retrieve, distill, propose, freshness, context, graphQuery, roleResult, reorientResult, and the canonical view lenses for scene, jobs, roles, planning, pressure, reorient, crrc, and coordinator. - Use `notes/epiphany-memory-graph-unified-plan.md` as the source-grounded memory architecture direction. The repo fractal dataflow graph and agent memory are one `EpiphanyMemoryGraph` substrate with repo, role, short-term, incubation, agency, candidate-intervention, and evidence profiles. Qdrant stores rebuildable semantic embeddings for typed graph documents; it is never canonical memory. The first live skeleton now exists in `epiphany-state-model` plus `epiphany-core::memory_graph`: typed graph documents, stable ids, profile/lifecycle validation, freshness propagation, context cuts, a CultCache store seam, and the native `epiphany-memory-graph` status/validate/context/smoke CLI. Do not add repo scanners, sleep runners, Qdrant cache plumbing, CultNet advertisement, or prompt integration before routing them through this shared substrate. - Keep the landed Phase 6 coordinator, limited safe-boundary CRRC automation, and pre-compaction checkpoint intervention ready for the next bridge-equipped dogfood run. - - Preserve the Ghostlight-derived heartbeat initiative seam: every lane, including coordinator/Self and Face, has a role dossier and competes for heartbeat slots through readiness/reaction timing; idle winners ruminate instead of inventing project work, and sleep windows distill the accumulated thought pressure into reviewed self-memory or doctrine. + - Preserve the Ghostlight-derived heartbeat initiative seam: every lane, including coordinator/Self and Face, has a role dossier and competes for heartbeat slots through readiness/reaction timing; initiative heat can raise or cool global, group, arena, role, and agent tempo through typed heartbeat policy; idle winners ruminate instead of inventing project work, and sleep windows distill the accumulated thought pressure into reviewed self-memory or doctrine. - Treat Ghostlight as reference lineage, not a sibling runtime to preserve. The useful organ is Epiphany-native character-loop protocol: any role can project its typed dossier plus visible stimulus into a local turn packet, with Face as the first public-surface actor. - Treat VoidBot as reference lineage, not a runtime dependency. The useful organ is Epiphany-native Void routine physiology: heartbeat state owns sleep cycle, memory resonance, incubation, analytic/associative cognition lanes, bridge judgment, candidate interventions, dream residue, and Aquarium-visible routine receipts over typed role dossiers. - Preserve review gates for semantic findings; automatic CRRC may compact or launch the fixed reorient-worker, but not accept or promote. @@ -101,7 +101,7 @@ accepted_design: - Agent self-memory review/application now has typed `AgentSelfPatch` core APIs. The old JSON-value selfPatch functions remain only as edge compatibility wrappers for CLI/artifact ingress; `epiphany-agent-memory-store`, heartbeat rumination application, and repo initialization selfPatch processing parse once at the edge and then operate on typed documents. Role-result self-persistence no longer exports a JSON-value reviewer; native review uses `review_role_self_patch_document`. - Heartbeat durable document/schema types live in `epiphany-core/src/heartbeat_state/heartbeat_documents.rs`; role/default construction lives in `epiphany-core/src/heartbeat_state/heartbeat_roles.rs`; heartbeat persistence/validation lives in `epiphany-core/src/heartbeat_state/heartbeat_store.rs`; heartbeat status/artifact JSON projection lives in `epiphany-core/src/heartbeat_state/heartbeat_projection.rs`; the root heartbeat module remains the scheduling/cognition orchestration surface until those responsibilities are split into their own tested seams. - Heartbeat role/default and store seams are pinned by module-local unit tests for fixed lane catalog, Ghostlight scene role projection, and typed state/cognition CultCache round-trip. - - Heartbeat adaptive pacing lives in `epiphany-core/src/heartbeat_state/heartbeat_pacing.rs`; it owns pressure/concurrency derivation, running-turn count, and effective cooldown multipliers for scheduler/projection callers. + - Heartbeat adaptive pacing lives in `epiphany-core/src/heartbeat_state/heartbeat_pacing.rs`; it owns pressure/concurrency derivation, running-turn count, initiative heat projection, and effective cooldown multipliers for scheduler/projection callers. - `epiphany-openai-auth-spine` is now a thin Epiphany-named boundary over retained vendored `codex-login`, not a clean-room credential store or token-refresh clone. Keep this impurity sealed as the Codex-compatible subscription auth organ while Epiphany owns typed request/status/event/runtime documents around it. - `notes/epiphany-architectural-teardown.md` is the current foundation-cleanup directive. Its suspicion pass supersedes outward Phase 6 expansion as the active priority until the control-plane ownership problems are resolved. - `notes/epiphany-ideal-architecture-rebuild-plan.md` is the replacement blueprint: the smallest coherent architecture is durable `EpiphanyState`, runtime-spine-owned `RuntimeState`, separate role memory/heartbeat state, `epiphany-core` as policy owner, app-server as adapter, Aquarium as reflector, typed result acceptance receipts, and derived view lenses instead of a protocol verb zoo. @@ -172,7 +172,7 @@ accepted_design: - Specialist prompts are role-distilled instead of generic and their live text is config-backed in app-server: modeling/checkpoint is the Body of code, dataflow, seams, and frontier; research/scout is the Eyes prompt surface for existing work, vendor guidance, libraries, papers, and anti-Greenspun source selection; implementation is the Hands, the main coding lane and actuator rather than a `roleLaunch` specialist; verification/review is the Soul of promise, invariants, evidence, and user truth; reorientation is Life across compaction and source drift; coordinator is the read-only Self that routes attention without implementing, verifying, promoting, or accepting; Face is the public Discord #aquarium surface that translates agent thought-weather without moderating or leaking sealed thought. - Epiphany prompt surfaces now carry a shared Ghostlight-derived persistent memory projection before lane-specific text: prompt is not memory, durable typed state is the mind, personality and protected values are first-class salience handles, and every lane is explicitly responsible for making its own memory/model/prompt/evidence habit sharper or naming the needed repair. Each lane states self-improvement in its own rite-language: Imagination selects futures, Body clarifies anatomy, Eyes sees earlier, Hands touches source more precisely, Soul becomes harder to fool, Life loses less continuity, Self routes repair, and Face becomes clearer at turning inner weather into useful social presence. - Specialist self-memory now has a bounded Ghostlight-shaped CultCache persistence surface in `state/agents.msgpack`: Imagination, Body, Eyes, Hands, Soul, Life, Self, and Face each have an individual typed role dossier for identity, personality, semantic/episodic/relationship memory, goals, and values. These entries are lane memory only; project truth remains in authoritative `EpiphanyThreadState`. - - `state/agent-heartbeats.msgpack`, `epiphany-core::EpiphanyHeartbeatStateEntry`, and the native `epiphany-heartbeat-store` binary are the Ghostlight-derived heartbeat initiative seam. The harness sets a target heartbeat rate; participants carry arena, participant kind, initiative speed, next-ready time, reaction bias, interrupt threshold, current load, status, constraints, personality cooldown, mood cooldown, and effective cooldown; pending coordinator work can pull its owning lane through a reaction window; otherwise the earliest ready active participant wins the slot. Role dossiers set the personality baseline, appraisals bend it with mood/anxiety signals such as urgency, arousal, thought pressure, guardedness, and reaction intensity, and lower effective cooldown means the lane recovers sooner and gets the floor more often. The native `pump` command computes adaptive swarm pressure from external urgency, mood/anxiety, reaction intensity, thought pressure, and current pending load; relaxed pressure can launch nothing and run at crawl tempo, while alarm pressure can fill most or all active lanes up to a configured concurrency cap without waking any lane already running. If the winner has no routeable maintenance work, it ruminates on role quality and prepares bounded selfPatch pressure rather than pretending rumination has already consolidated doctrine. Sleep/dream cycle passes are the intended distillation window for reviewed self-memory and doctrine. Face can win `surfaceAgentThoughts` or `discordAquariumChat` work slots. Epiphany also owns native character-loop projection through `epiphany-character-loop`, so role dossiers can respond to visible stimuli without importing Ghostlight as runtime. The same heartbeat store now owns the Void-derived routine fields `sleep_cycle`, `memory_resonance`, `incubation`, `thought_lanes`, `bridge`, and `candidate_interventions` through the native `epiphany-heartbeat-store routine` command. + - `state/agent-heartbeats.msgpack`, `epiphany-core::EpiphanyHeartbeatStateEntry`, and the native `epiphany-heartbeat-store` binary are the Ghostlight-derived heartbeat initiative seam. The harness sets a target heartbeat rate; participants carry arena, participant kind, initiative speed, next-ready time, reaction bias, interrupt threshold, current load, status, constraints, personality cooldown, mood cooldown, initiative heat, and effective cooldown; pending coordinator work can pull its owning lane through a reaction window; otherwise the earliest ready active participant wins the slot. Role dossiers set the personality baseline, appraisals bend it with mood/anxiety signals such as urgency, arousal, thought pressure, guardedness, and reaction intensity, and lower effective cooldown means the lane recovers sooner and gets the floor more often. Initiative heat is typed heartbeat policy, not a side flag: `epiphany-heartbeat-store heat` and the CultNet `epiphany.heartbeat_heat_intent.v0` contract can set or clear global, all, agent, role, arena, participant-kind, group, and constraint multipliers, with optional scene-clock expiry. The native `pump` command computes adaptive swarm pressure from external urgency, mood/anxiety, reaction intensity, thought pressure, and current pending load; relaxed pressure can launch nothing and run at crawl tempo, while alarm pressure can fill most or all active lanes up to a configured concurrency cap without waking any lane already running. If the winner has no routeable maintenance work, it ruminates on role quality and prepares bounded selfPatch pressure rather than pretending rumination has already consolidated doctrine. Sleep/dream cycle passes are the intended distillation window for reviewed self-memory and doctrine. Face can win `surfaceAgentThoughts` or `discordAquariumChat` work slots. Epiphany also owns native character-loop projection through `epiphany-character-loop`, so role dossiers can respond to visible stimuli without importing Ghostlight as runtime. The same heartbeat store now owns the Void-derived routine fields `sleep_cycle`, `memory_resonance`, `incubation`, `thought_lanes`, `bridge`, and `candidate_interventions` through the native `epiphany-heartbeat-store routine` command. - `state/ledgers.msgpack`, `epiphany-core::EpiphanyStateLedgerEntry`, the `epiphany-state-ledger-store` binary, and the native `epiphany-state` CLI now own durable branch and evidence ledgers. The old tracked JSON ledger files and the migration/projection CLI hatches are gone. - CultCache inspection, cross-language schema synchronization, and debug display tooling belong in CultLib, not in EpiphanyAgent. Epiphany should consume typed CultCache documents and expose product-specific status through its API, while general polyglot domain loading/inspection lives with the shared CultCache ecosystem. - VoidBot's current routine is reference lineage only. Epiphany's native routine pass lives in Rust as `epiphany-heartbeat-store routine`: it reads typed role dossiers, projects memory resonance, maintains incubation themes, runs analytic and associative cognition lanes, writes bridge syntheses/saturation/tension, produces reviewed candidate interventions, advances the sleep/dream cycle, and writes an auditable routine receipt while leaving project truth and role memory mutation on their dedicated reviewed surfaces. Qdrant-backed memory vectors remain a future enhancement; the current native pass uses bounded local resonance over typed memories.