From 3b55f322f1f17a5fb9d8ed96d704ac25a163615c Mon Sep 17 00:00:00 2001 From: Meta Vens Date: Mon, 18 May 2026 00:41:34 +0100 Subject: [PATCH] Split heartbeat role defaults --- epiphany-core/src/heartbeat_state.rs | 269 +---------------- .../src/heartbeat_state/heartbeat_roles.rs | 271 ++++++++++++++++++ notes/fresh-workspace-handoff.md | 2 +- state/ledgers.msgpack | Bin 127378 -> 127748 bytes state/map.yaml | 6 +- 5 files changed, 284 insertions(+), 264 deletions(-) create mode 100644 epiphany-core/src/heartbeat_state/heartbeat_roles.rs diff --git a/epiphany-core/src/heartbeat_state.rs b/epiphany-core/src/heartbeat_state.rs index 4fa6be07..b0387d67 100644 --- a/epiphany-core/src/heartbeat_state.rs +++ b/epiphany-core/src/heartbeat_state.rs @@ -10,9 +10,14 @@ use std::path::Path; mod heartbeat_documents; mod heartbeat_projection; +mod heartbeat_roles; mod heartbeat_store; pub use heartbeat_documents::*; pub use heartbeat_projection::heartbeat_status_projection; +pub use heartbeat_roles::default_heartbeat_state; +pub use heartbeat_roles::ghostlight_scene_heartbeat_state; +pub use heartbeat_roles::initialize_ghostlight_scene_heartbeat_store; +pub use heartbeat_roles::initialize_heartbeat_store; pub use heartbeat_store::heartbeat_state_cache; pub use heartbeat_store::load_heartbeat_cognition_entry; pub use heartbeat_store::load_heartbeat_state_entry; @@ -24,23 +29,16 @@ 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; +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"; pub(super) const PARTICIPANT_KIND_AGENT: &str = "agent"; pub(super) const PARTICIPANT_KIND_CHARACTER: &str = "character"; -const ROLE_ORDER: &[&str] = &[ - "coordinator", - "face", - "imagination", - "research", - "modeling", - "implementation", - "verification", - "reorientation", -]; - #[derive(Clone, Debug, PartialEq)] struct HeartbeatAction { action_id: String, @@ -53,86 +51,6 @@ struct HeartbeatAction { local_affordance_basis: Vec, } -pub fn default_heartbeat_state(target_heartbeat_rate: f64) -> EpiphanyHeartbeatStateEntry { - EpiphanyHeartbeatStateEntry { - schema_version: HEARTBEAT_STATE_SCHEMA_VERSION.to_string(), - target_heartbeat_rate, - scene_clock: 0.0, - selection_policy: HeartbeatSelectionPolicy { - mode: "readiness_queue".to_string(), - reaction_precedence: true, - minimum_speed: 0.2, - tie_breakers: vec![ - "reaction_readiness_desc".to_string(), - "next_ready_at_asc".to_string(), - "initiative_speed_desc".to_string(), - "stable_actor_id_asc".to_string(), - ], - extra: BTreeMap::new(), - }, - pacing_policy: HeartbeatPacingPolicy { - cooldown_starts_after_turn_completion: true, - work_base_recovery: 6.0, - idle_base_recovery: 2.0, - sleep_heartbeat_rate_multiplier: 0.05, - minimum_effective_rate: 0.001, - extra: BTreeMap::new(), - }, - participants: ROLE_ORDER - .iter() - .map(|role_id| default_participant(role_id)) - .collect(), - history: Vec::new(), - extra: BTreeMap::new(), - } -} - -pub fn initialize_heartbeat_store( - store_path: impl AsRef, - target_heartbeat_rate: f64, -) -> Result { - write_heartbeat_state_entry(store_path, &default_heartbeat_state(target_heartbeat_rate)) -} - -pub fn ghostlight_scene_heartbeat_state( - target_heartbeat_rate: f64, - scene_id: impl Into, - participants: Vec, -) -> Result { - if participants.is_empty() { - return Err(anyhow!( - "Ghostlight scene heartbeat requires at least one participant" - )); - } - let scene_id = scene_id.into(); - let mut state = default_heartbeat_state(target_heartbeat_rate); - state.participants = participants - .into_iter() - .map(|seed| ghostlight_scene_participant(&scene_id, seed)) - .collect(); - state.extra.insert( - "protocol".to_string(), - serde_json::json!({ - "domain": "ghostlight", - "sceneId": scene_id, - "arena": HEARTBEAT_ARENA_SCENE, - "contract": "Characters and maintenance organs use one initiative timing law; scene participants receive only projected local context.", - }), - ); - validate_heartbeat_state(&state)?; - Ok(state) -} - -pub fn initialize_ghostlight_scene_heartbeat_store( - store_path: impl AsRef, - target_heartbeat_rate: f64, - scene_id: impl Into, - participants: Vec, -) -> Result { - let state = ghostlight_scene_heartbeat_state(target_heartbeat_rate, scene_id, participants)?; - write_heartbeat_state_entry(store_path, &state) -} - pub fn run_void_routine_store( store_path: impl AsRef, artifact_dir: impl AsRef, @@ -885,77 +803,6 @@ fn is_ghostlight_scene_state(state: &EpiphanyHeartbeatStateEntry) -> bool { == Some("ghostlight") } -fn default_participant(role_id: &str) -> HeartbeatParticipant { - HeartbeatParticipant { - agent_id: agent_id_for_role(role_id).to_string(), - role_id: role_id.to_string(), - display_name: display_name_for_role(role_id).to_string(), - arena: HEARTBEAT_ARENA_MAINTENANCE.to_string(), - participant_kind: PARTICIPANT_KIND_AGENT.to_string(), - initiative_speed: initiative_speed_for_role(role_id), - next_ready_at: 0.0, - reaction_bias: reaction_bias_for_role(role_id), - interrupt_threshold: interrupt_threshold_for_role(role_id), - current_load: 0.0, - status: "active".to_string(), - constraints: participant_constraints(role_id) - .into_iter() - .map(str::to_string) - .collect(), - last_action_id: None, - last_woke_at: None, - last_finished_at: None, - pending_turn: None, - extra: BTreeMap::new(), - } -} - -fn ghostlight_scene_participant( - scene_id: &str, - seed: GhostlightSceneParticipantSeed, -) -> HeartbeatParticipant { - let role_id = ghostlight_role_id(seed.agent_id.as_str()); - let mut extra = BTreeMap::new(); - extra.insert("sceneId".to_string(), Value::String(scene_id.to_string())); - HeartbeatParticipant { - agent_id: seed.agent_id, - role_id, - display_name: seed.display_name, - arena: HEARTBEAT_ARENA_SCENE.to_string(), - participant_kind: PARTICIPANT_KIND_CHARACTER.to_string(), - initiative_speed: seed.initiative_speed, - next_ready_at: 0.0, - reaction_bias: seed.reaction_bias, - interrupt_threshold: seed.interrupt_threshold, - current_load: 0.0, - status: "active".to_string(), - constraints: seed.constraints, - last_action_id: None, - last_woke_at: None, - last_finished_at: None, - pending_turn: None, - extra, - } -} - -fn ghostlight_role_id(agent_id: &str) -> String { - format!( - "ghostlight.character.{}", - agent_id - .trim() - .chars() - .map(|ch| { - if ch.is_ascii_alphanumeric() { - ch.to_ascii_lowercase() - } else { - '-' - } - }) - .collect::() - .trim_matches('-') - ) -} - fn participant_index_by_role(state: &EpiphanyHeartbeatStateEntry, role_id: &str) -> Result { state .participants @@ -3399,104 +3246,6 @@ const STOP_WORDS: &[&str] = &[ "through", "when", "with", "work", ]; -fn agent_id_for_role(role_id: &str) -> &'static str { - match role_id { - "coordinator" => "epiphany.self", - "face" => "epiphany.face", - "imagination" => "epiphany.imagination", - "research" => "epiphany.eyes", - "modeling" => "epiphany.body", - "implementation" => "epiphany.hands", - "verification" => "epiphany.soul", - "reorientation" => "epiphany.life", - _ => "epiphany.unknown", - } -} - -fn display_name_for_role(role_id: &str) -> &'static str { - match role_id { - "coordinator" => "Self", - "face" => "Face", - "imagination" => "Imagination", - "research" => "Eyes", - "modeling" => "Body", - "implementation" => "Hands", - "verification" => "Soul", - "reorientation" => "Life", - _ => "Unknown", - } -} - -fn initiative_speed_for_role(role_id: &str) -> f64 { - match role_id { - "coordinator" => 1.28, - "face" => 1.12, - "imagination" => 0.82, - "research" => 0.78, - "modeling" => 0.92, - "implementation" => 0.74, - "verification" => 0.88, - "reorientation" => 1.04, - _ => 1.0, - } -} - -fn reaction_bias_for_role(role_id: &str) -> f64 { - match role_id { - "coordinator" => 0.88, - "face" => 0.84, - "imagination" => 0.54, - "research" => 0.62, - "modeling" => 0.74, - "implementation" => 0.58, - "verification" => 0.82, - "reorientation" => 0.86, - _ => 0.5, - } -} - -fn interrupt_threshold_for_role(role_id: &str) -> f64 { - match role_id { - "coordinator" => 0.42, - "face" => 0.52, - "imagination" => 0.64, - "research" => 0.58, - "modeling" => 0.5, - "implementation" => 0.5, - "verification" => 0.48, - "reorientation" => 0.44, - _ => 0.5, - } -} - -fn participant_constraints(role_id: &str) -> Vec<&'static str> { - let role_specific = match role_id { - "coordinator" => { - "Routes and reviews; must not implement, verify, or accept its own comfort." - } - "face" => { - "Publicly translates agent thought into #aquarium only; must not moderate or speak outside the room." - } - "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." - } - "implementation" => { - "Touches source only with accepted guidance and verifier-readable evidence." - } - "verification" => "Falsifies promises; must not bless theater.", - "reorientation" => "Protects continuity; must not fake survived context.", - _ => "Unknown role.", - }; - vec![ - "Runs Ghostlight-shaped persistent role memory.", - "May improve lane memory when awake and idle.", - "Project truth belongs in EpiphanyThreadState, not role memory.", - role_specific, - ] -} - #[cfg(test)] mod tests { use super::*; diff --git a/epiphany-core/src/heartbeat_state/heartbeat_roles.rs b/epiphany-core/src/heartbeat_state/heartbeat_roles.rs new file mode 100644 index 00000000..d1256b77 --- /dev/null +++ b/epiphany-core/src/heartbeat_state/heartbeat_roles.rs @@ -0,0 +1,271 @@ +use super::EpiphanyHeartbeatStateEntry; +use super::GhostlightSceneParticipantSeed; +use super::HEARTBEAT_ARENA_MAINTENANCE; +use super::HEARTBEAT_ARENA_SCENE; +use super::HEARTBEAT_STATE_SCHEMA_VERSION; +use super::HeartbeatPacingPolicy; +use super::HeartbeatParticipant; +use super::HeartbeatSelectionPolicy; +use super::PARTICIPANT_KIND_AGENT; +use super::PARTICIPANT_KIND_CHARACTER; +use super::write_heartbeat_state_entry; +use anyhow::Result; +use anyhow::anyhow; +use std::collections::BTreeMap; +use std::path::Path; + +pub(super) const ROLE_ORDER: &[&str] = &[ + "coordinator", + "face", + "imagination", + "research", + "modeling", + "implementation", + "verification", + "reorientation", +]; + +pub fn default_heartbeat_state(target_heartbeat_rate: f64) -> EpiphanyHeartbeatStateEntry { + EpiphanyHeartbeatStateEntry { + schema_version: HEARTBEAT_STATE_SCHEMA_VERSION.to_string(), + target_heartbeat_rate, + scene_clock: 0.0, + selection_policy: HeartbeatSelectionPolicy { + mode: "readiness_queue".to_string(), + reaction_precedence: true, + minimum_speed: 0.2, + tie_breakers: vec![ + "reaction_readiness_desc".to_string(), + "next_ready_at_asc".to_string(), + "initiative_speed_desc".to_string(), + "stable_actor_id_asc".to_string(), + ], + extra: BTreeMap::new(), + }, + pacing_policy: HeartbeatPacingPolicy { + cooldown_starts_after_turn_completion: true, + work_base_recovery: 6.0, + idle_base_recovery: 2.0, + sleep_heartbeat_rate_multiplier: 0.05, + minimum_effective_rate: 0.001, + extra: BTreeMap::new(), + }, + participants: ROLE_ORDER + .iter() + .map(|role_id| default_participant(role_id)) + .collect(), + history: Vec::new(), + extra: BTreeMap::new(), + } +} + +pub fn initialize_heartbeat_store( + store_path: impl AsRef, + target_heartbeat_rate: f64, +) -> Result { + write_heartbeat_state_entry(store_path, &default_heartbeat_state(target_heartbeat_rate)) +} + +pub fn ghostlight_scene_heartbeat_state( + target_heartbeat_rate: f64, + scene_id: impl Into, + participants: Vec, +) -> Result { + if participants.is_empty() { + return Err(anyhow!( + "Ghostlight scene heartbeat requires at least one participant" + )); + } + let scene_id = scene_id.into(); + let mut state = default_heartbeat_state(target_heartbeat_rate); + state.participants = participants + .into_iter() + .map(|seed| ghostlight_scene_participant(&scene_id, seed)) + .collect(); + state.extra.insert( + "protocol".to_string(), + serde_json::json!({ + "domain": "ghostlight", + "sceneId": scene_id, + "arena": HEARTBEAT_ARENA_SCENE, + "contract": "Characters and maintenance organs use one initiative timing law; scene participants receive only projected local context.", + }), + ); + super::validate_heartbeat_state(&state)?; + Ok(state) +} + +pub fn initialize_ghostlight_scene_heartbeat_store( + store_path: impl AsRef, + target_heartbeat_rate: f64, + scene_id: impl Into, + participants: Vec, +) -> Result { + let state = ghostlight_scene_heartbeat_state(target_heartbeat_rate, scene_id, participants)?; + write_heartbeat_state_entry(store_path, &state) +} + +pub(super) fn default_participant(role_id: &str) -> HeartbeatParticipant { + HeartbeatParticipant { + agent_id: agent_id_for_role(role_id).to_string(), + role_id: role_id.to_string(), + display_name: display_name_for_role(role_id).to_string(), + arena: HEARTBEAT_ARENA_MAINTENANCE.to_string(), + participant_kind: PARTICIPANT_KIND_AGENT.to_string(), + initiative_speed: initiative_speed_for_role(role_id), + next_ready_at: 0.0, + reaction_bias: reaction_bias_for_role(role_id), + interrupt_threshold: interrupt_threshold_for_role(role_id), + current_load: 0.0, + status: "active".to_string(), + constraints: participant_constraints(role_id) + .into_iter() + .map(str::to_string) + .collect(), + last_action_id: None, + last_woke_at: None, + last_finished_at: None, + pending_turn: None, + extra: BTreeMap::new(), + } +} + +fn ghostlight_scene_participant( + scene_id: &str, + seed: GhostlightSceneParticipantSeed, +) -> HeartbeatParticipant { + let role_id = ghostlight_role_id(seed.agent_id.as_str()); + let mut extra = BTreeMap::new(); + extra.insert("sceneId".to_string(), serde_json::json!(scene_id)); + HeartbeatParticipant { + agent_id: seed.agent_id, + role_id, + display_name: seed.display_name, + arena: HEARTBEAT_ARENA_SCENE.to_string(), + participant_kind: PARTICIPANT_KIND_CHARACTER.to_string(), + initiative_speed: seed.initiative_speed, + next_ready_at: 0.0, + reaction_bias: seed.reaction_bias, + interrupt_threshold: seed.interrupt_threshold, + current_load: 0.0, + status: "active".to_string(), + constraints: seed.constraints, + last_action_id: None, + last_woke_at: None, + last_finished_at: None, + pending_turn: None, + extra, + } +} + +fn ghostlight_role_id(agent_id: &str) -> String { + let sanitized = agent_id + .chars() + .map(|character| { + if character.is_ascii_alphanumeric() { + character.to_ascii_lowercase() + } else { + '-' + } + }) + .collect::() + .trim_matches('-') + .to_string(); + format!("ghostlight.character.{sanitized}") +} + +pub(super) fn agent_id_for_role(role_id: &str) -> &'static str { + match role_id { + "coordinator" => "epiphany.self", + "face" => "epiphany.face", + "imagination" => "epiphany.imagination", + "research" => "epiphany.eyes", + "modeling" => "epiphany.body", + "implementation" => "epiphany.hands", + "verification" => "epiphany.soul", + "reorientation" => "epiphany.life", + _ => "epiphany.unknown", + } +} + +pub(super) fn display_name_for_role(role_id: &str) -> &'static str { + match role_id { + "coordinator" => "Self", + "face" => "Face", + "imagination" => "Imagination", + "research" => "Eyes", + "modeling" => "Body", + "implementation" => "Hands", + "verification" => "Soul", + "reorientation" => "Life", + _ => "Unknown", + } +} + +fn initiative_speed_for_role(role_id: &str) -> f64 { + match role_id { + "coordinator" => 1.28, + "face" => 1.12, + "imagination" => 0.82, + "research" => 0.78, + "modeling" => 0.92, + "implementation" => 0.74, + "verification" => 0.88, + "reorientation" => 1.04, + _ => 1.0, + } +} + +fn reaction_bias_for_role(role_id: &str) -> f64 { + match role_id { + "coordinator" => 0.88, + "face" => 0.84, + "imagination" => 0.54, + "research" => 0.62, + "modeling" => 0.74, + "implementation" => 0.58, + "verification" => 0.82, + "reorientation" => 0.86, + _ => 0.5, + } +} + +fn interrupt_threshold_for_role(role_id: &str) -> f64 { + match role_id { + "coordinator" => 0.42, + "face" => 0.52, + "imagination" => 0.64, + "research" => 0.58, + "modeling" => 0.5, + "implementation" => 0.5, + "verification" => 0.48, + "reorientation" => 0.44, + _ => 0.5, + } +} + +fn participant_constraints(role_id: &str) -> Vec<&'static str> { + let role_specific = match role_id { + "coordinator" => { + "Routes and reviews; must not implement, verify, or accept its own comfort." + } + "face" => { + "Publicly translates agent thought into #aquarium only; must not moderate or speak outside the room." + } + "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.", + "implementation" => { + "Touches source only with accepted guidance and verifier-readable evidence." + } + "verification" => "Falsifies promises; must not bless theater.", + "reorientation" => "Protects continuity; must not fake survived context.", + _ => "Unknown role.", + }; + vec![ + "Runs Ghostlight-shaped persistent role memory.", + "May improve lane memory when awake and idle.", + "Project truth belongs in EpiphanyThreadState, not role memory.", + role_specific, + ] +} diff --git a/notes/fresh-workspace-handoff.md b/notes/fresh-workspace-handoff.md index d4ec2859..0adea978 100644 --- a/notes/fresh-workspace-handoff.md +++ b/notes/fresh-workspace-handoff.md @@ -58,7 +58,7 @@ remembers doctrine; the branch remembers the blade. - Thread start route handling and its async lifecycle task now live in `codex_message_processor/thread_start_routes.rs`; root no longer owns `thread_start_task`. - Thread config helpers now live in `codex_message_processor/thread_config.rs`: instruction-source loading, thread config override construction, config-load error shaping, and dynamic-tool validation. The pure dynamic-tool validation contract has module-local unit tests. - Turn control routes now live in `codex_message_processor/turn_routes.rs`: turn start, thread item injection, app-server client info setting, turn steer, turn interrupt, mode normalization, and input-limit validation with module-local unit tests. -- Heartbeat durable document/schema types now live in `epiphany-core/src/heartbeat_state/heartbeat_documents.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 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. - Thread projection now lives in `codex_message_processor/thread_projection.rs`: state-db/thread-store/rollout summary projection, `ConversationSummary` to API `Thread` mapping, thread-title attachment helpers, turn pagination, and rollout turn reconstruction. `codex_message_processor.rs` is about 1,009 lines after this extraction and mostly owns JSON-RPC dispatch, processor construction, shared thread lookup/submit/error helpers, and lifecycle shutdown. - Turn paging/reconstruction now lives in `codex_message_processor/thread_turn_projection.rs`; `thread_projection.rs` keeps state-db/thread-store/rollout summary projection and `ConversationSummary` to API `Thread` mapping. Focused `thread_turns_list` cursor tests and stale in-progress turn interruption coverage pass. - The `thread/turns/list` route handler now lives in `codex_message_processor/thread_turn_routes.rs`, beside the turn projection helpers it consumes. `thread_read_routes.rs` is back to persisted/live thread listing, `thread/read`, loaded-thread listing, and summary reads. diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index 721a674ea99fe5bb3a15e7064ebf4ea6ab7ce7e9..da890a50fb0b2029bc88ebbc9dbda7488215ea14 100644 GIT binary patch delta 198 zcmbRAn7!p0`vhgCPp3AjPGe+@Y~I7TeGen!f%nrp+!^_%FL=VpI(gG2J*``edLF5X zMI}k8i6sg}`8lZy$%!S2Ir-@diFqjsDXD3Rr8y-E#U+U))8`v7s!lKXz^G^lQdg{3 zRII0f(3_WEu8@&ftdNqQT$-DjSE2(pO&?;y^b;Q#<-`<{Qq%H_QWZ)vQWc6)a}zW3 kGV{_EroCenVJ$Am$t;;}@Q%@Wdd){h0X7puD0NMY9<_D7F2aqEI@mR4XmH`1+gS-K^ya55g@0afK0T2c=HaavjS~}Se2mk;8 diff --git a/state/map.yaml b/state/map.yaml index d59f0aca..c5c14ad6 100644 --- a/state/map.yaml +++ b/state/map.yaml @@ -98,7 +98,7 @@ accepted_design: - `notes/codex-auth-spine-inventory.md` is the current source-grounded inventory of the Codex organ that may survive. Corrected compliance invariant: Codex-compatible auth identity should remain anchored in retained vendored Codex-derived auth machinery, while Epiphany owns typed request/status/event/runtime surfaces around it. Codex app-server, apps, skills, marketplace, plugin UX, MCP OAuth handlers, and collaboration-mode surfaces are not part of the keeper spine. - `epiphany-openai-runtime` worker result ingress now parses assistant output directly into launch-kind-specific typed documents and stores typed nested `statePatch` / `selfPatch` payloads as MessagePack inside `EpiphanyRuntimeRoleWorkerResult`; generic `serde_json::Value` no longer mediates role/reorient worker results in that crate. JSON still exists at the OpenAI text edge because the model's output is text, but the runtime boundary after parsing is typed. - 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`; 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 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. - `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. @@ -287,8 +287,8 @@ rejected_paths: current_status: summary: The Codex starvation pass has five typing receipts, fifty-six processor/foundation cuts, a real physical extraction in `epiphany-codex-bridge`, a root `epiphany-state-model` crate for durable Epiphany state, a source-grounded Codex auth spine inventory, the native `epiphany-openai-adapter` document boundary, a buildable Codex auth/model wrapper in `epiphany-openai-codex-spine`, the first native runtime caller in `epiphany-openai-runtime`, native heartbeat launch planning/job opening in `epiphany-core`, native state-update contract/validation/application in `epiphany-core`, native exact retrieval path matching in `epiphany-core`, and the route-facing mutation/view/coordinator projection services in `epiphany-codex-bridge`. `codex-protocol` no longer defines the durable `Epiphany*` state structs; it re-exports the native model for legacy rollout/API compatibility while `epiphany-core` imports the native model directly. `epiphany-core` now has no direct vendored Codex dependency: pressure derivation accepts native `EpiphanyTokenUsageSnapshot`, Codex rollout replay moved to `codex-core::epiphany_rollout`, and exact retrieval search uses Epiphany-owned workspace walking/path scoring instead of `codex-file-search`. The bridge owns Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval/indexing projection, result projection, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, mutation service update/promote/role-accept/reorient-accept/role-launch/reorient-launch/job-launch/job-interrupt application, live-state projection, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, watcher invalidation adaptation, full `thread/epiphany/view` response construction, freshness/context/graph-query response construction, role/reorient result response construction, distill/propose patch-response construction, coordinator status/view construction, and acceptance/evidence signal helpers. Vendored app-server no longer retains root Epiphany modules; `codex_message_processor.rs` still contains route dispatch, JSON-RPC response shaping, watcher registration/snapshotting calls, and notification emission, but its root no longer imports the evacuated Epiphany policy/protocol registry or owns the watcher invalidation manager. Codex product surfaces for apps, skills, plugins, marketplace, and external agent config import are cut from the live app-server/protocol path: list routes return empty lists only where compatibility shells still exist, mutation/detail routes report disabled where they survive, `externalAgentConfig/*` routes and import-completed notification are gone, helper/import modules and stale implementation-shape tests were deleted, runtime feature enablement no longer supports `apps` or `plugins`, config writes no longer emit plugin-toggle analytics, plugin/skill cache invalidation on config writes is gone, plugin startup warmups and app-list refreshes were removed, and app-server no longer directly depends on `codex-plugin`, `codex-chatgpt`, or `codex-core-plugins`. `Config::to_mcp_config` now keeps user-declared MCP servers but no longer accepts `PluginsManager`, folds plugin MCP servers into the runtime, enables Codex apps, enables skill MCP dependency install, or advertises plugin capability summaries; `TurnContext::apps_enabled()` now returns false so model turns cannot awaken Codex Apps through ChatGPT auth or feature flags; session startup and per-turn context no longer load skills, turns receive an empty `SkillLoadOutcome`, internal `Op::ListSkills` is gone from `codex-protocol` / `codex-core` / TUI command routing, the Codex skill watcher has been collapsed to a no-op marker with no file watcher, skill-root registration, cache-clear task, or `SkillsUpdateAvailable` session listener, model turns no longer run skill mention collection, skill env-var prompts, skill MCP dependency installation, skill instruction injection, or implicit skill invocation analytics from shell tools, and the turn prompt/router path no longer loads plugin/app capability summaries, injects available-skill/available-plugin/plugin instruction fragments, parses plugin/app mentions, records app/plugin invocation telemetry, or filters MCP tools through Codex app connectors. Skill mutation/list/notification is gone from the app-server edge too: `skills/list`, `skills/config/write`, `skills/changed`, `Op::ListSkills`, `EventMsg::ListSkillsResponse`, `EventMsg::SkillsUpdateAvailable`, the app-server handlers, TUI slash/startup/list/manage-skill surfaces, generated schema entries, core skill-list suite, and fake live-reload/developer-message tests were deleted. Skill mention plumbing is also gone from the live TUI/protocol edge: no `UserInput::Skill` variant, app-server schema branch, TUI skill popup, `skills_all` cache, composer `set_skill_mentions`, skill mention insertion, `skill://` / `SKILL.md` history decoding, or stale skill popup snapshot remains. The `codex-core-skills` crate, core `skills` re-export shim, no-op `skills_watcher`, session `SkillsManager` service, and per-turn `TurnSkillsContext` are deleted; core/protocol no longer keep legacy `` or `` prompt compatibility, memory usage classification, snapshot normalization, or cleanup paths. Remaining product-shaped skill residue is also cut from memory templates, app-server docs/tests/warnings, TUI tooltips/placeholders/warnings/comments, app-server v1 docs, agent-tool schema text, stale `UserInput::Skill` test arms, and obsolete feature flags/schema entries. App-instruction prompt compatibility is cut too: no `APPS_INSTRUCTIONS` protocol constants, no `` snapshot canonicalization, and MCP fixture tests now use neutral `demo_mcp` / `calendar_mcp` names instead of `codex_apps` / `/api/codex/apps` branding. The TUI app connector product path is also deleted: no `/apps` slash command, app-link view, connector AppEvent variants, app connector cache/popup/refresh loop, app mention insertion, `app://` mention codec support, stale app-popup tests, or TUI browser-opening shim remains. The `app/list` route and `app/list/updated` notification are gone from app-server protocol, generated schemas, app-server dispatch, test helpers, and docs; `AppInfo`/app-list metadata schema structs are deleted; the orphaned `codex-connectors` crate and `core::connectors` shim are deleted from the workspace; Codex app analytics no longer tracks `codex_app_mentioned` / `codex_app_used` facts, events, reducer arms, client APIs, or dedupe cache state; `[apps.*]`, `Feature::Apps`, `include_apps_instructions`, app config/read schemas, app managed requirements, app prompt tests, and app file-MCP tests are gone; `Feature::Plugins`, `Feature::RemotePlugin`, `plugin://` structured mentions, plugin instruction tags, and stale plugin popup snapshots are gone too; `[plugins]` / `[marketplaces]`, `PluginConfig`, `MarketplaceConfig`, marketplace edit helpers, stale plugin/external-agent README route claims, and generated schema entries are removed from config; and the bundled `codex-skills` sample-skill crate plus embedded imagegen/openai-docs/plugin-creator/skill-creator/skill-installer payloads are deleted from the workspace. The vendored `vendor/codex/sdk` subtree is deleted as non-spine app-server client/release scaffolding, including stale generated Python SDK route types for removed product surfaces; the root pnpm workspace no longer lists `sdk/typescript`. Live MCP tool approval is named `McpToolApproval`, not `AppToolApproval`, and remains under MCP server config; live structured user-input mentions are MCP-shaped only. `codex_message_processor.rs` is about 1,009 lines after route/lifecycle/projection/resume-helper/config-helper extraction; root `message_processor.rs` is about 1,292 lines after the external-agent/config-product cuts; `epiphany_read_routes.rs` is about 579 lines after the full view and read-response extractions; `epiphany_mutation_routes.rs` is about 694 lines after route-load/notification helper cuts and product-surface starvation; the old vendored `epiphany_state_helpers.rs` rollout-state loader is deleted and its remaining function lives in `epiphany-codex-bridge::state`; and `codex_thread.rs` is about 1,425 lines after state-update law moved native. `epiphany-openai-adapter` defines CultCache `DatabaseEntry` request/event/receipt/auth-status documents with no Codex app-server or generic JSON dependency. `epiphany-openai-codex-spine` owns the native OpenAI model transport path: it exposes `default_codex_home` and `auth_manager`, projects `epiphany-openai-auth-spine` `AuthManager` / `CodexAuth` into typed `EpiphanyOpenAiAdapterStatus`, builds a local serializable OpenAI Responses request body instead of Codex protocol request/item/config types, opens HTTP Responses streams through `codex-client`, parses Responses SSE frames into typed stream events and receipts, and no longer directly or transitively depends on Codex's Responses client, model-provider stack, `codex-protocol`, `codex-api`, `codex-model-provider`, or `codex-model-provider-info`; it intentionally reaches retained vendored `codex-login` only through `epiphany-openai-auth-spine`. Auth identity, credential storage, and ChatGPT token refresh remain owned by the Codex-compatible auth organ; external bearer command auth and agent identity remain retained Codex auth capabilities to expose only if a typed Epiphany surface needs them. `epiphany-openai-runtime` no longer depends directly on `codex-login`; it writes OpenAI status/request/stream-event/receipt records plus runtime sessions/jobs/results/events into `epiphany-core::runtime_spine_cache`, can emit the assistant text artifact for legacy result consumers, is now the default executor for startup-only repo birth specialists, and now has `run-worker` to load a durable `EpiphanyRuntimeWorkerLaunchRequest`, call the typed OpenAI runtime through the spine, persist typed `EpiphanyRuntimeRoleWorkerResult` / `EpiphanyRuntimeReorientWorkerResult` documents, and complete the original heartbeat/specialist runtime job without Codex worker execution; `codex exec` survives only as explicit fallback in repo-birth startup. `epiphany-mvp-coordinator` now invokes `epiphany-openai-runtime run-worker` for launched runtime job ids and no longer creates a second coordinator-owned shadow runtime job/result as a compensator. `epiphany-core::plan_runtime_spine_heartbeat_launch` validates launch contracts/conflicts and projects durable job bindings/runtime links; `epiphany-core::open_runtime_spine_heartbeat_job` owns the initialize-runtime/ensure-session/create-job sequence and now persists `EpiphanyRuntimeWorkerLaunchRequest` CultCache records keyed by runtime job id, with indexed kind/contract fields plus MessagePack-encoded typed launch documents instead of discarding work intent after queue receipt creation; `roleResult` and `reorientResult` now require typed worker result documents; generic job summaries are lifecycle receipts, not reviewable findings; `epiphany-core::EpiphanyStateUpdate`, `epiphany_state_update_validation_errors`, and `apply_epiphany_state_update` own state-update document shape and mutation law while `codex-core` calls them for compatibility. Vendored `CodexThread::epiphany_launch_job` is now mostly revision check, persistence validation, launch request handoff, and rollout/session writeback for the compatibility route. Vendored `codex-core` no longer has `epiphany_distillation`, `epiphany_promotion`, `epiphany_proposal`, or `epiphany_retrieval` husk modules; it re-exports native surfaces from `epiphany-core` directly, and now owns only the real Codex rollout adapter because it is a host seam. `epiphany-runtime-spine` advertises OpenAI adapter status/model-request/stream-event/receipt CultNet schemas and mutation contracts, so the native caller now has a real storage route instead of only JSON-RPC. MCP itself is correctly JSON at its protocol edge; the target is typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON. The current OpenAI request path no longer pulls `codex-api`; `codex-login` remains deliberately sealed behind `epiphany-openai-auth-spine`, and the next spine decision is another Epiphany-in-vendor evacuation surface unless a concrete typed auth-status/runtime need requires exposing external bearer or agent-identity auth. latest_cut: > - Heartbeat persistence and validation were split into - `heartbeat_state/heartbeat_store.rs`, leaving root `heartbeat_state.rs` + Heartbeat role/default construction was split into + `heartbeat_state/heartbeat_roles.rs`, leaving root `heartbeat_state.rs` responsible for scheduler physiology and Void cognition orchestration. Focused heartbeat tests and `epiphany-core` check pass. next_action: Continue the Codex starvation campaign at the next Epiphany-in-vendor evacuation surface; keep vendored Codex code as host routing/lifecycle glue only, preserve retained `codex-login` auth ownership, and prefer cuts that expose testable ownership boundaries over line-count theater.