diff --git a/epiphany-core/src/bin/epiphany-mvp-status.rs b/epiphany-core/src/bin/epiphany-mvp-status.rs index 6763a9dc..903bcd46 100644 --- a/epiphany-core/src/bin/epiphany-mvp-status.rs +++ b/epiphany-core/src/bin/epiphany-mvp-status.rs @@ -2,12 +2,11 @@ use anyhow::{Context, Result, anyhow}; use epiphany_core::{ EpiphanyAgentPassContinuationAction, EpiphanyCoordinatorStatus, EpiphanyCoordinatorStatusInput, EpiphanyCrrcAction, EpiphanyCrrcRecommendation, EpiphanyCrrcResultStatus, - EpiphanyCrrcSceneAction, EpiphanyCurrentWorkProjection, EpiphanyJobsInput, - EpiphanyReorientAction, EpiphanyRoleBoardInput, EpiphanyRoleBoardJob, - EpiphanyRoleBoardJobStatus, EpiphanyRoleResultRoleId, EpiphanyRuntimeJobStatus, + EpiphanyCrrcSceneAction, EpiphanyCurrentWorkProjection, EpiphanyReorientAction, + EpiphanyRoleBoardInput, EpiphanyRoleResultRoleId, EpiphanyRuntimeJobStatus, EpiphanySceneInput, EpiphanyTokenUsageSnapshot, RepoFrontierPlanningLifecycle, RepoFrontierPlanningLifecycleStage, RepoFrontierResearchLifecycle, - RepoFrontierResearchLifecycleStage, derive_jobs, derive_planning_view, derive_pressure_view, + RepoFrontierResearchLifecycleStage, derive_planning_view, derive_pressure_view, derive_role_board, derive_scene, runtime_job_snapshot, }; use epiphany_self_policy::derive_coordinator_status; @@ -148,23 +147,9 @@ fn run_native_status(args: &Args) -> Result { reorientation_work_present: reorientation_work.is_some(), }); let planning = derive_planning_view(mind.as_ref()); - let jobs = derive_jobs(EpiphanyJobsInput { - mind: mind.as_ref(), - }); - let role_jobs = jobs - .iter() - .map(|job| EpiphanyRoleBoardJob { - id: job.id.clone(), - owner_role: job.owner_role.clone(), - status: role_job_status(job.status), - progress_note: job.progress_note.clone(), - blocking_reason: job.blocking_reason.clone(), - }) - .collect::>(); let roles = derive_role_board(EpiphanyRoleBoardInput { mind_present: mind.is_some(), current_work: current_work.clone(), - jobs: role_jobs, }); let coordinator = derive_coordinator_status(EpiphanyCoordinatorStatusInput { mind_present: mind.is_some(), @@ -260,7 +245,6 @@ fn run_native_status(args: &Args) -> Result { "authority": "keyedMindCurrentWork", }, }, - "jobs": {"threadId": thread_id, "source": "native", "jobs": jobs}, "roles": {"threadId": thread_id, "source": "native", "roles": roles}, "planning": planning, "currentWork": current_work, @@ -458,20 +442,6 @@ fn coordinator_status_json(status: &EpiphanyCoordinatorStatus) -> Result Ok(value) } -fn role_job_status(status: epiphany_core::EpiphanyJobStatus) -> EpiphanyRoleBoardJobStatus { - match status { - epiphany_core::EpiphanyJobStatus::Idle => EpiphanyRoleBoardJobStatus::Idle, - epiphany_core::EpiphanyJobStatus::Needed => EpiphanyRoleBoardJobStatus::Needed, - epiphany_core::EpiphanyJobStatus::Pending => EpiphanyRoleBoardJobStatus::Pending, - epiphany_core::EpiphanyJobStatus::Running => EpiphanyRoleBoardJobStatus::Running, - epiphany_core::EpiphanyJobStatus::Completed => EpiphanyRoleBoardJobStatus::Completed, - epiphany_core::EpiphanyJobStatus::Failed => EpiphanyRoleBoardJobStatus::Failed, - epiphany_core::EpiphanyJobStatus::Cancelled => EpiphanyRoleBoardJobStatus::Cancelled, - epiphany_core::EpiphanyJobStatus::Blocked => EpiphanyRoleBoardJobStatus::Blocked, - epiphany_core::EpiphanyJobStatus::Unavailable => EpiphanyRoleBoardJobStatus::Unavailable, - } -} - pub fn render_status(status: &Value) -> String { let read = &status["read"]; let coordinator = &status["coordinator"]; diff --git a/epiphany-core/src/lib.rs b/epiphany-core/src/lib.rs index 498d60d4..a77bfe12 100644 --- a/epiphany-core/src/lib.rs +++ b/epiphany-core/src/lib.rs @@ -672,9 +672,6 @@ pub use surfaces::EpiphanyCrrcReorientAction; pub use surfaces::EpiphanyCrrcResultStatus; pub use surfaces::EpiphanyCrrcSceneAction; pub use surfaces::EpiphanyCrrcStateStatus; -pub use surfaces::EpiphanyJobStatus; -pub use surfaces::EpiphanyJobView; -pub use surfaces::EpiphanyJobsInput; pub use surfaces::EpiphanyPlanningStateStatus; pub use surfaces::EpiphanyPlanningSummary; pub use surfaces::EpiphanyPlanningView; @@ -687,8 +684,6 @@ pub use surfaces::EpiphanyReorientFindingInterpretation; pub use surfaces::EpiphanyReorientWorkerLaunchDocument; pub use surfaces::EpiphanyResearchDecision; pub use surfaces::EpiphanyRoleBoardInput; -pub use surfaces::EpiphanyRoleBoardJob; -pub use surfaces::EpiphanyRoleBoardJobStatus; pub use surfaces::EpiphanyRoleBoardLane; pub use surfaces::EpiphanyRoleFindingInterpretation; pub use surfaces::EpiphanyRoleResultRoleId; @@ -726,7 +721,6 @@ pub use surfaces::RepoFrontierPlanningContextProjection; pub use surfaces::RepoFrontierProposalModelingContextProjection; pub use surfaces::RepoFrontierResearchContextProjection; pub use surfaces::RepoFrontierVerificationContextProjection; -pub use surfaces::derive_jobs; pub use surfaces::derive_planning_view; pub use surfaces::derive_pressure_view; pub use surfaces::derive_role_board; @@ -734,8 +728,6 @@ pub use surfaces::derive_scene; pub use surfaces::interpret_runtime_reorient_worker_result; pub use surfaces::interpret_runtime_role_worker_result; pub use surfaces::recommend_coordinator_action; -pub use surfaces::render_role_board_note; -pub use surfaces::role_board_job_status_to_role_status; pub use weksa_interlingua::WEKSA_INTERLINGUA_PACKET_SCHEMA_VERSION; pub use weksa_interlingua::WEKSA_TARGET_LOWERING_RECEIPT_SCHEMA_VERSION; pub use weksa_interlingua::WEKSA_TARGET_LOWERING_REQUEST_SCHEMA_VERSION; diff --git a/epiphany-core/src/surfaces/jobs.rs b/epiphany-core/src/surfaces/jobs.rs deleted file mode 100644 index f657de16..00000000 --- a/epiphany-core/src/surfaces/jobs.rs +++ /dev/null @@ -1,223 +0,0 @@ -use epiphany_state_model::EpiphanyJobKind; -use serde::{Deserialize, Serialize}; - -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum EpiphanyJobStatus { - Idle, - Needed, - Pending, - Running, - Completed, - Failed, - Cancelled, - Blocked, - Unavailable, -} - -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct EpiphanyJobView { - pub id: String, - pub kind: EpiphanyJobKind, - pub scope: String, - pub owner_role: String, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub authority_scope: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub runtime_job_id: Option, - pub status: EpiphanyJobStatus, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub items_processed: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub items_total: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub progress_note: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub last_checkpoint_at_unix_seconds: Option, - #[serde(default, skip_serializing_if = "Option::is_none")] - pub blocking_reason: Option, - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub active_thread_ids: Vec, - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub linked_subgoal_ids: Vec, - #[serde(default, skip_serializing_if = "Vec::is_empty")] - pub linked_graph_node_ids: Vec, -} - -#[derive(Debug, Clone, Copy)] -pub struct EpiphanyJobsInput<'a> { - pub mind: Option<&'a crate::EpiphanyMindView>, -} - -pub fn derive_jobs(input: EpiphanyJobsInput<'_>) -> Vec { - vec![ - body_observation_job(input.mind), - repo_model_job(input.mind), - verification_job(input.mind), - ] -} - -fn base_job( - id: &str, - kind: EpiphanyJobKind, - scope: &str, - owner_role: &str, - status: EpiphanyJobStatus, -) -> EpiphanyJobView { - EpiphanyJobView { - id: id.into(), - kind, - scope: scope.into(), - owner_role: owner_role.into(), - authority_scope: None, - runtime_job_id: None, - status, - items_processed: None, - items_total: None, - progress_note: None, - last_checkpoint_at_unix_seconds: None, - blocking_reason: None, - active_thread_ids: Vec::new(), - linked_subgoal_ids: Vec::new(), - linked_graph_node_ids: Vec::new(), - } -} - -fn body_observation_job(mind: Option<&crate::EpiphanyMindView>) -> EpiphanyJobView { - let body = mind.and_then(|mind| mind.repository_body_observation.as_ref()); - let mut job = base_job( - "repository-body-observation", - EpiphanyJobKind::Indexing, - "repository Body", - "epiphany-body-observer", - if body.is_some() { - EpiphanyJobStatus::Completed - } else { - EpiphanyJobStatus::Needed - }, - ); - job.linked_subgoal_ids = active_subgoal_ids(mind); - job.progress_note = Some(match body { - Some(body) => format!( - "Mind contains exact Body observation {} at generation {}.", - body.observation_id, body.generation - ), - None => "Mind has no admitted repository Body observation.".into(), - }); - job -} - -fn repo_model_job(mind: Option<&crate::EpiphanyMindView>) -> EpiphanyJobView { - let model = mind.and_then(|mind| mind.repo_model.as_ref()); - let mut job = base_job( - "repo-model", - EpiphanyJobKind::Remap, - "keyed RepoModel", - "epiphany-modeling", - if model.is_some() { - EpiphanyJobStatus::Idle - } else { - EpiphanyJobStatus::Blocked - }, - ); - job.linked_subgoal_ids = active_subgoal_ids(mind); - job.linked_graph_node_ids = active_graph_node_ids(mind); - job.progress_note = model.map(|model| { - format!( - "Keyed RepoModel projects {} node(s), {} edge(s), and {} frontier item(s).", - model.nodes.len(), - model.edges.len(), - model.frontier.len() - ) - }); - if model.is_none() { - job.blocking_reason = Some("Mind has no keyed RepoModel identity.".into()); - } - job -} - -fn verification_job(mind: Option<&crate::EpiphanyMindView>) -> EpiphanyJobView { - let Some(mind) = mind else { - let mut job = base_job( - "verification", - EpiphanyJobKind::Verification, - "invariants/evidence", - "epiphany-soul", - EpiphanyJobStatus::Blocked, - ); - job.blocking_reason = Some("Mind is missing.".into()); - return job; - }; - let total = mind.invariants.len() as u32; - let verified = mind - .invariants - .iter() - .filter(|invariant| invariant_status_is_accepting(&invariant.status)) - .count() as u32; - let mut job = base_job( - "verification", - EpiphanyJobKind::Verification, - "invariants/evidence", - "epiphany-soul", - if total > verified { - EpiphanyJobStatus::Needed - } else { - EpiphanyJobStatus::Idle - }, - ); - job.items_processed = Some(verified); - job.items_total = Some(total); - job.linked_subgoal_ids = active_subgoal_ids(Some(mind)); - job.linked_graph_node_ids = active_graph_node_ids(Some(mind)); - job.progress_note = Some(format!("{verified} of {total} invariant(s) are accepting.")); - job -} - -fn active_subgoal_ids(mind: Option<&crate::EpiphanyMindView>) -> Vec { - mind.and_then(|mind| mind.active_subgoal_id.clone()) - .map(|id| vec![id]) - .unwrap_or_default() -} - -fn active_graph_node_ids(mind: Option<&crate::EpiphanyMindView>) -> Vec { - let mut ids = mind - .and_then(|mind| mind.repo_model.as_ref()) - .into_iter() - .flat_map(|model| model.frontier.iter()) - .filter(|item| { - matches!( - item.status, - epiphany_state_model::RepoFrontierStatus::Proposed - | epiphany_state_model::RepoFrontierStatus::Active - | epiphany_state_model::RepoFrontierStatus::Blocked - ) - }) - .flat_map(|item| item.target_claim_ids.iter().cloned()) - .collect::>(); - ids.sort(); - ids.dedup(); - ids -} - -fn invariant_status_is_accepting(status: &str) -> bool { - matches!( - status, - "ok" | "ready" | "accepted" | "verified" | "pass" | "passed" - ) -} - -#[cfg(test)] -mod tests { - use super::*; - - #[test] - fn missing_mind_has_only_derived_blocked_or_needed_jobs() { - let jobs = derive_jobs(EpiphanyJobsInput { mind: None }); - assert_eq!(jobs.len(), 3); - assert_eq!(jobs[0].status, EpiphanyJobStatus::Needed); - assert_eq!(jobs[1].status, EpiphanyJobStatus::Blocked); - assert_eq!(jobs[2].status, EpiphanyJobStatus::Blocked); - assert!(jobs.iter().all(|job| job.runtime_job_id.is_none())); - } -} diff --git a/epiphany-core/src/surfaces/mod.rs b/epiphany-core/src/surfaces/mod.rs index f455d5ef..93de56a3 100644 --- a/epiphany-core/src/surfaces/mod.rs +++ b/epiphany-core/src/surfaces/mod.rs @@ -1,7 +1,6 @@ mod coordinator_contract; mod coordinator_decision; mod crrc; -mod jobs; mod planning; mod pressure; mod reorient; @@ -19,10 +18,6 @@ pub use crrc::EpiphanyCrrcReorientAction; pub use crrc::EpiphanyCrrcResultStatus; pub use crrc::EpiphanyCrrcSceneAction; pub use crrc::EpiphanyCrrcStateStatus; -pub use jobs::EpiphanyJobStatus; -pub use jobs::EpiphanyJobView; -pub use jobs::EpiphanyJobsInput; -pub use jobs::derive_jobs; pub use planning::EpiphanyPlanningStateStatus; pub use planning::EpiphanyPlanningSummary; pub use planning::EpiphanyPlanningView; @@ -36,12 +31,8 @@ pub use pressure::derive_pressure_view; pub use reorient::EpiphanyReorientAction; pub use research_decision::EpiphanyResearchDecision; pub use role_board::EpiphanyRoleBoardInput; -pub use role_board::EpiphanyRoleBoardJob; -pub use role_board::EpiphanyRoleBoardJobStatus; pub use role_board::EpiphanyRoleBoardLane; pub use role_board::derive_role_board; -pub use role_board::render_role_board_note; -pub use role_board::role_board_job_status_to_role_status; pub use role_result::EpiphanyReorientFindingInterpretation; pub use role_result::EpiphanyRoleFindingInterpretation; pub use role_result::EpiphanyRoleResultRoleId; diff --git a/epiphany-core/src/surfaces/role_board.rs b/epiphany-core/src/surfaces/role_board.rs index 21823e4f..74b480e1 100644 --- a/epiphany-core/src/surfaces/role_board.rs +++ b/epiphany-core/src/surfaces/role_board.rs @@ -7,35 +7,10 @@ use crate::{ }; use serde::{Deserialize, Serialize}; -#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub enum EpiphanyRoleBoardJobStatus { - Idle, - Needed, - Pending, - Running, - Completed, - Failed, - Cancelled, - Blocked, - Unavailable, -} - -#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] -#[serde(rename_all = "camelCase")] -pub struct EpiphanyRoleBoardJob { - pub id: String, - pub owner_role: String, - pub status: EpiphanyRoleBoardJobStatus, - pub progress_note: Option, - pub blocking_reason: Option, -} - #[derive(Debug, Clone, PartialEq, Eq)] pub struct EpiphanyRoleBoardInput { pub mind_present: bool, pub current_work: EpiphanyCurrentWorkProjection, - pub jobs: Vec, } #[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)] @@ -46,7 +21,6 @@ pub struct EpiphanyRoleBoardLane { pub owner_role: String, pub status: EpiphanyCoordinatorRoleStatus, pub note: String, - pub jobs: Vec, pub authority_scopes: Vec, pub recommended_action: Option, } @@ -69,12 +43,6 @@ pub fn derive_role_board(input: EpiphanyRoleBoardInput) -> Vec EpiphanyCoordinatorRoleStatus { - match status { - EpiphanyRoleBoardJobStatus::Idle => EpiphanyCoordinatorRoleStatus::Ready, - EpiphanyRoleBoardJobStatus::Needed => EpiphanyCoordinatorRoleStatus::Needed, - EpiphanyRoleBoardJobStatus::Pending | EpiphanyRoleBoardJobStatus::Running => { - EpiphanyCoordinatorRoleStatus::Running - } - EpiphanyRoleBoardJobStatus::Completed => EpiphanyCoordinatorRoleStatus::Completed, - EpiphanyRoleBoardJobStatus::Failed - | EpiphanyRoleBoardJobStatus::Cancelled - | EpiphanyRoleBoardJobStatus::Blocked => EpiphanyCoordinatorRoleStatus::Blocked, - EpiphanyRoleBoardJobStatus::Unavailable => EpiphanyCoordinatorRoleStatus::Unavailable, - } -} - -pub fn render_role_board_note( - roles: &[EpiphanyRoleBoardLane], - state_status: &str, - recommendation: crate::EpiphanyCrrcAction, -) -> String { - let active = roles - .iter() - .filter(|lane| { - !matches!( - lane.status, - EpiphanyCoordinatorRoleStatus::Ready | EpiphanyCoordinatorRoleStatus::Completed - ) - }) - .count(); - format!( - "Mind {state_status}; {active} role lane(s) carry current work; continuity recommendation {recommendation:?}." - ) -}