2026-05-28 21:02:26 +01:00
use epiphany_core ::EPIPHANY_IMAGINATION_OWNER_ROLE ;
use epiphany_core ::EPIPHANY_IMAGINATION_ROLE_BINDING_ID ;
use epiphany_core ::EPIPHANY_MODELING_ROLE_BINDING_ID ;
use epiphany_core ::EPIPHANY_REORIENT_LAUNCH_BINDING_ID ;
use epiphany_core ::EPIPHANY_REORIENT_OWNER_ROLE ;
2026-06-02 14:12:10 +01:00
use epiphany_core ::EPIPHANY_RESEARCH_ROLE_BINDING_ID ;
2026-05-28 21:02:26 +01:00
use epiphany_core ::EPIPHANY_VERIFICATION_ROLE_BINDING_ID ;
2026-05-13 01:33:32 +01:00
use epiphany_core ::EpiphanyCoordinatorAutomationAction as CoreEpiphanyCoordinatorAutomationAction ;
use epiphany_core ::EpiphanyCoordinatorDecision as CoreEpiphanyCoordinatorDecision ;
use epiphany_core ::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus ;
2026-05-20 08:39:56 +01:00
use epiphany_core ::EpiphanyCoordinatorStatus as CoreEpiphanyCoordinatorStatus ;
use epiphany_core ::EpiphanyCoordinatorStatusInput ;
2026-05-13 01:33:32 +01:00
use epiphany_core ::EpiphanyCrrcAction as CoreEpiphanyCrrcAction ;
use epiphany_core ::EpiphanyCrrcInput ;
use epiphany_core ::EpiphanyCrrcRecommendation as CoreEpiphanyCrrcRecommendation ;
use epiphany_core ::EpiphanyCrrcReorientAction as CoreEpiphanyCrrcReorientAction ;
use epiphany_core ::EpiphanyCrrcResultStatus as CoreEpiphanyCrrcResultStatus ;
use epiphany_core ::EpiphanyCrrcStateStatus as CoreEpiphanyCrrcStateStatus ;
2026-05-17 21:01:26 +01:00
use epiphany_core ::EpiphanyJobLaunchRequest ;
2026-05-20 02:19:06 +01:00
use epiphany_core ::EpiphanyJobStatus as CoreEpiphanyJobStatus ;
use epiphany_core ::EpiphanyJobView ;
2026-05-19 21:51:42 +01:00
use epiphany_core ::EpiphanyReorientAction as CoreEpiphanyReorientAction ;
2026-05-19 22:11:58 +01:00
use epiphany_core ::EpiphanyReorientDecision as CoreEpiphanyReorientDecision ;
2026-05-20 01:32:32 +01:00
use epiphany_core ::EpiphanyReorientFindingInterpretation as CoreEpiphanyReorientFinding ;
2026-05-19 22:11:58 +01:00
use epiphany_core ::EpiphanyReorientStateStatus as CoreEpiphanyReorientStateStatus ;
2026-05-13 01:33:32 +01:00
use epiphany_core ::EpiphanyRoleBoardCheckpointSummary ;
use epiphany_core ::EpiphanyRoleBoardInput ;
use epiphany_core ::EpiphanyRoleBoardJob ;
use epiphany_core ::EpiphanyRoleBoardJobStatus ;
use epiphany_core ::EpiphanyRoleBoardLane ;
use epiphany_core ::EpiphanyRoleBoardPlanningSummary ;
2026-05-20 02:44:47 +01:00
use epiphany_core ::EpiphanyRoleResultRoleId ;
2026-05-19 15:33:45 +01:00
use epiphany_core ::EpiphanyTokenUsageSnapshot ;
2026-06-02 14:12:10 +01:00
use epiphany_core ::build_epiphany_reorient_launch_request_with_dynamic_context ;
2026-05-20 09:45:40 +01:00
use epiphany_core ::derive_coordinator_finding_signals ;
2026-05-20 08:39:56 +01:00
use epiphany_core ::derive_coordinator_status ;
2026-05-13 01:33:32 +01:00
use epiphany_core ::derive_role_board ;
use epiphany_core ::recommend_crrc_action ;
2026-05-28 21:02:26 +01:00
use epiphany_core ::render_epiphany_coordinator_note ;
2026-05-13 01:33:32 +01:00
use epiphany_core ::render_role_board_note ;
2026-05-20 09:45:40 +01:00
use epiphany_core ::reorient_finding_already_accepted ;
2026-05-13 01:33:32 +01:00
use epiphany_core ::select_coordinator_automation_action ;
2026-05-19 15:24:57 +01:00
use epiphany_state_model ::EpiphanyRetrievalState ;
use epiphany_state_model ::EpiphanyThreadState ;
2026-05-13 01:33:32 +01:00
2026-06-02 14:12:10 +01:00
use crate ::launch_context ::render_launch_dynamic_prompt_context ;
use crate ::launch_context ::reorient_launch_context_focus ;
2026-05-19 16:47:28 +01:00
use crate ::pressure ::derive_epiphany_pressure ;
2026-05-14 08:49:03 +01:00
use crate ::reorient ::EpiphanyFreshnessWatcherSnapshot ;
2026-05-19 16:58:37 +01:00
use crate ::reorient ::derive_epiphany_freshness_view ;
2026-05-19 17:05:26 +01:00
use crate ::reorient ::derive_epiphany_reorient ;
2026-05-20 01:32:32 +01:00
use crate ::runtime_results ::load_core_epiphany_reorient_result_snapshot ;
use crate ::runtime_results ::load_core_epiphany_role_result_snapshot ;
2026-05-13 01:33:32 +01:00
2026-05-13 09:41:16 +01:00
use std ::path ::Path ;
2026-05-13 01:33:32 +01:00
2026-05-13 03:07:24 +01:00
pub fn map_epiphany_crrc_recommendation (
2026-05-13 01:33:32 +01:00
loaded : bool ,
2026-05-19 22:11:58 +01:00
state_status : CoreEpiphanyReorientStateStatus ,
2026-05-19 21:51:42 +01:00
pressure : & epiphany_core ::EpiphanyPressure ,
2026-05-19 22:11:58 +01:00
decision : & CoreEpiphanyReorientDecision ,
result_status : CoreEpiphanyCrrcResultStatus ,
2026-05-13 01:33:32 +01:00
checkpoint_present : bool ,
finding_present : bool ,
finding_accepted : bool ,
2026-05-19 21:58:29 +01:00
) -> CoreEpiphanyCrrcRecommendation {
recommend_crrc_action ( EpiphanyCrrcInput {
2026-05-13 01:33:32 +01:00
loaded ,
2026-05-19 22:11:58 +01:00
state_status : map_core_crrc_state_status_from_reorient ( state_status ) ,
2026-05-13 01:33:32 +01:00
should_prepare_compaction : pressure . should_prepare_compaction ,
reorient_action : map_core_crrc_reorient_action ( decision . action ) ,
2026-05-19 22:11:58 +01:00
result_status ,
2026-05-13 01:33:32 +01:00
checkpoint_present ,
finding_present ,
finding_accepted ,
2026-05-19 21:58:29 +01:00
} )
2026-05-13 01:33:32 +01:00
}
2026-05-19 22:11:58 +01:00
fn map_core_crrc_state_status_from_reorient (
status : CoreEpiphanyReorientStateStatus ,
2026-05-13 01:33:32 +01:00
) -> CoreEpiphanyCrrcStateStatus {
match status {
2026-05-19 22:11:58 +01:00
CoreEpiphanyReorientStateStatus ::Missing = > CoreEpiphanyCrrcStateStatus ::Missing ,
CoreEpiphanyReorientStateStatus ::Ready = > CoreEpiphanyCrrcStateStatus ::Ready ,
2026-05-13 01:33:32 +01:00
}
}
fn map_core_crrc_reorient_action (
2026-05-19 22:11:58 +01:00
action : CoreEpiphanyReorientAction ,
2026-05-13 01:33:32 +01:00
) -> CoreEpiphanyCrrcReorientAction {
match action {
2026-05-19 22:11:58 +01:00
CoreEpiphanyReorientAction ::Resume = > CoreEpiphanyCrrcReorientAction ::Resume ,
CoreEpiphanyReorientAction ::Regather = > CoreEpiphanyCrrcReorientAction ::Regather ,
2026-05-19 21:51:42 +01:00
}
}
pub type EpiphanyCoordinatorDecision = CoreEpiphanyCoordinatorDecision ;
2026-05-13 09:41:16 +01:00
pub struct EpiphanyCoordinatorStatus {
2026-05-20 08:39:56 +01:00
pub core : CoreEpiphanyCoordinatorStatus ,
2026-05-13 09:41:16 +01:00
pub note : String ,
}
pub async fn derive_epiphany_coordinator_status (
state : Option < & EpiphanyThreadState > ,
runtime_store_path : Option < & Path > ,
2026-05-19 22:11:58 +01:00
state_status : CoreEpiphanyReorientStateStatus ,
2026-05-19 21:51:42 +01:00
pressure : & epiphany_core ::EpiphanyPressure ,
2026-05-19 21:58:29 +01:00
recommendation : & CoreEpiphanyCrrcRecommendation ,
2026-05-19 22:06:09 +01:00
roles : Vec < EpiphanyRoleBoardLane > ,
2026-05-19 22:11:58 +01:00
reorient_decision : Option < & CoreEpiphanyReorientDecision > ,
2026-05-20 08:12:18 +01:00
reorient_result_status : CoreEpiphanyCrrcResultStatus ,
2026-05-20 01:32:32 +01:00
reorient_finding : Option < & CoreEpiphanyReorientFinding > ,
2026-05-13 09:41:16 +01:00
checkpoint_present : bool ,
) -> EpiphanyCoordinatorStatus {
2026-05-20 01:32:32 +01:00
let ( modeling_result_status , modeling_finding ) = if let Some ( state ) = state {
let snapshot = load_core_epiphany_role_result_snapshot (
2026-05-13 09:41:16 +01:00
state ,
runtime_store_path ,
2026-05-20 02:44:47 +01:00
EpiphanyRoleResultRoleId ::Modeling ,
2026-05-13 09:41:16 +01:00
EPIPHANY_MODELING_ROLE_BINDING_ID ,
)
2026-05-20 01:32:32 +01:00
. await ;
( snapshot . status , snapshot . finding )
2026-05-13 09:41:16 +01:00
} else {
2026-05-20 01:32:32 +01:00
( CoreEpiphanyCoordinatorRoleResultStatus ::MissingState , None )
2026-05-13 09:41:16 +01:00
} ;
2026-05-30 01:02:16 +01:00
let ( research_result_status , research_finding ) = if let Some ( state ) = state {
let snapshot = load_core_epiphany_role_result_snapshot (
state ,
runtime_store_path ,
EpiphanyRoleResultRoleId ::Research ,
EPIPHANY_RESEARCH_ROLE_BINDING_ID ,
)
. await ;
( snapshot . status , snapshot . finding )
} else {
( CoreEpiphanyCoordinatorRoleResultStatus ::MissingState , None )
} ;
2026-05-20 01:32:32 +01:00
let ( verification_result_status , verification_finding ) = if let Some ( state ) = state {
let snapshot = load_core_epiphany_role_result_snapshot (
2026-05-13 09:41:16 +01:00
state ,
runtime_store_path ,
2026-05-20 02:44:47 +01:00
EpiphanyRoleResultRoleId ::Verification ,
2026-05-13 09:41:16 +01:00
EPIPHANY_VERIFICATION_ROLE_BINDING_ID ,
)
2026-05-20 01:32:32 +01:00
. await ;
( snapshot . status , snapshot . finding )
2026-05-13 09:41:16 +01:00
} else {
2026-05-20 01:32:32 +01:00
( CoreEpiphanyCoordinatorRoleResultStatus ::MissingState , None )
2026-05-13 09:41:16 +01:00
} ;
2026-05-20 09:45:40 +01:00
let finding_signals = derive_coordinator_finding_signals (
state ,
2026-05-30 01:02:16 +01:00
research_finding . as_ref ( ) ,
2026-05-20 09:45:40 +01:00
modeling_finding . as_ref ( ) ,
verification_finding . as_ref ( ) ,
reorient_finding ,
) ;
2026-05-20 08:39:56 +01:00
let core = derive_coordinator_status ( EpiphanyCoordinatorStatusInput {
state_status : map_core_crrc_state_status_from_reorient ( state_status ) ,
checkpoint_present ,
pressure : pressure . clone ( ) ,
recommendation : recommendation . clone ( ) ,
roles ,
2026-05-13 09:41:16 +01:00
reorient_action : reorient_decision
. map ( | decision | decision . action )
2026-05-19 21:51:42 +01:00
. unwrap_or ( CoreEpiphanyReorientAction ::Resume ) ,
2026-05-30 01:02:16 +01:00
research_result_status ,
2026-05-20 01:32:32 +01:00
modeling_result_status ,
verification_result_status ,
2026-05-20 08:12:18 +01:00
reorient_result_status ,
2026-05-30 01:02:16 +01:00
research_result_accepted : finding_signals . research_result_accepted ,
research_result_reviewable : finding_signals . research_result_reviewable ,
modeling_result_requests_regather : finding_signals . modeling_result_requests_regather ,
2026-05-20 09:45:40 +01:00
modeling_result_accepted : finding_signals . modeling_result_accepted ,
modeling_result_reviewable : finding_signals . modeling_result_reviewable ,
modeling_result_accepted_after_verification : finding_signals
. modeling_result_accepted_after_verification ,
implementation_evidence_after_verification : finding_signals
. implementation_evidence_after_verification ,
verification_result_cites_implementation_evidence : finding_signals
. verification_result_cites_implementation_evidence ,
verification_result_covers_current_modeling : finding_signals
. verification_result_covers_current_modeling ,
verification_result_accepted : finding_signals . verification_result_accepted ,
verification_result_allows_implementation : finding_signals
. verification_result_allows_implementation ,
verification_result_needs_evidence : finding_signals . verification_result_needs_evidence ,
reorient_finding_accepted : finding_signals . reorient_finding_accepted ,
2026-05-20 08:39:56 +01:00
} ) ;
2026-05-13 09:41:16 +01:00
let note = render_epiphany_coordinator_note (
2026-05-20 07:46:37 +01:00
recommendation . action ,
pressure . level ,
modeling_result_status ,
verification_result_status ,
2026-05-20 08:39:56 +01:00
core . source_signals . reorient_result_status ,
core . decision . action ,
2026-05-13 09:41:16 +01:00
) ;
2026-05-20 08:39:56 +01:00
EpiphanyCoordinatorStatus { core , note }
2026-05-13 09:41:16 +01:00
}
2026-05-20 08:39:56 +01:00
pub type EpiphanyCoordinatorAutomationAction = CoreEpiphanyCoordinatorAutomationAction ;
2026-05-13 01:33:32 +01:00
2026-05-14 08:49:03 +01:00
pub struct EpiphanyCoordinatorAutomationInput < ' a > {
pub thread_id : & ' a str ,
pub state : & ' a EpiphanyThreadState ,
pub retrieval_override : & ' a EpiphanyRetrievalState ,
pub watcher_snapshot : EpiphanyFreshnessWatcherSnapshot < ' a > ,
2026-05-19 15:33:45 +01:00
pub token_usage_info : Option < & ' a EpiphanyTokenUsageSnapshot > ,
2026-05-14 08:49:03 +01:00
pub runtime_store_path : & ' a Path ,
pub force_checkpoint_compaction : bool ,
}
pub struct EpiphanyCoordinatorAutomationVerdict {
pub action : EpiphanyCoordinatorAutomationAction ,
pub launch_request : Option < EpiphanyJobLaunchRequest > ,
}
pub async fn select_epiphany_coordinator_automation (
input : EpiphanyCoordinatorAutomationInput < '_ > ,
) -> EpiphanyCoordinatorAutomationVerdict {
2026-05-19 16:58:37 +01:00
let core_freshness = derive_epiphany_freshness_view (
2026-05-14 08:49:03 +01:00
Some ( input . state ) ,
Some ( input . retrieval_override ) ,
Some ( input . watcher_snapshot ) ,
) ;
2026-05-19 16:47:28 +01:00
let core_pressure = derive_epiphany_pressure ( input . token_usage_info ) ;
2026-05-19 22:11:58 +01:00
let ( state_status , reorient_decision ) = derive_epiphany_reorient (
2026-05-19 17:05:26 +01:00
Some ( input . state ) ,
& core_pressure ,
& core_freshness . retrieval ,
& core_freshness . graph ,
& core_freshness . watcher ,
) ;
2026-05-19 22:11:58 +01:00
if state_status ! = CoreEpiphanyReorientStateStatus ::Ready {
2026-05-14 08:49:03 +01:00
return EpiphanyCoordinatorAutomationVerdict {
action : EpiphanyCoordinatorAutomationAction ::None ,
launch_request : None ,
} ;
}
let jobs = crate ::jobs ::map_epiphany_jobs ( Some ( input . state ) , Some ( input . retrieval_override ) ) ;
let reorient_job = jobs
. iter ( )
. find ( | job | job . id = = EPIPHANY_REORIENT_LAUNCH_BINDING_ID )
. cloned ( ) ;
2026-05-20 01:32:32 +01:00
let reorient_result = load_core_epiphany_reorient_result_snapshot (
2026-05-14 08:49:03 +01:00
Some ( input . state ) ,
Some ( input . runtime_store_path ) ,
EPIPHANY_REORIENT_LAUNCH_BINDING_ID ,
)
. await ;
2026-05-20 01:32:32 +01:00
let reorient_finding_accepted = reorient_result
. finding
2026-05-14 08:49:03 +01:00
. as_ref ( )
2026-05-20 09:45:40 +01:00
. is_some_and ( | finding | reorient_finding_already_accepted ( input . state , finding ) ) ;
2026-05-14 08:49:03 +01:00
let crrc_recommendation = map_epiphany_crrc_recommendation (
true ,
state_status ,
2026-05-19 21:51:42 +01:00
& core_pressure ,
2026-05-14 08:49:03 +01:00
& reorient_decision ,
2026-05-20 01:32:32 +01:00
reorient_result . status ,
2026-05-14 08:49:03 +01:00
input . state . investigation_checkpoint . as_ref ( ) . is_some ( ) ,
2026-05-20 01:32:32 +01:00
reorient_result . finding . is_some ( ) ,
2026-05-14 08:49:03 +01:00
reorient_finding_accepted ,
) ;
let roles = map_epiphany_roles (
Some ( input . state ) ,
& jobs ,
& reorient_decision ,
2026-05-20 02:12:50 +01:00
& core_pressure ,
2026-05-14 08:49:03 +01:00
& crrc_recommendation ,
2026-05-20 01:32:32 +01:00
reorient_result . status ,
2026-05-14 08:49:03 +01:00
reorient_job . as_ref ( ) ,
) ;
let coordinator = derive_epiphany_coordinator_status (
Some ( input . state ) ,
Some ( input . runtime_store_path ) ,
state_status ,
2026-05-19 21:51:42 +01:00
& core_pressure ,
2026-05-14 08:49:03 +01:00
& crrc_recommendation ,
2026-05-19 22:06:09 +01:00
roles . roles ,
2026-05-14 08:49:03 +01:00
Some ( & reorient_decision ) ,
2026-05-20 08:12:18 +01:00
reorient_result . status ,
2026-05-20 01:32:32 +01:00
reorient_result . finding . as_ref ( ) ,
2026-05-14 08:49:03 +01:00
input . state . investigation_checkpoint . as_ref ( ) . is_some ( ) ,
)
. await ;
2026-05-20 08:39:56 +01:00
let action = select_coordinator_automation_action (
& coordinator . core . decision ,
2026-05-14 08:49:03 +01:00
input . force_checkpoint_compaction ,
) ;
let launch_request = match action {
EpiphanyCoordinatorAutomationAction ::LaunchReorientWorker = > input
. state
. investigation_checkpoint
. as_ref ( )
. map ( | checkpoint | {
2026-06-02 14:12:10 +01:00
let dynamic_prompt_context = render_launch_dynamic_prompt_context (
input . runtime_store_path ,
input . state ,
reorient_launch_context_focus ( input . state , & reorient_decision . next_action ) ,
)
. ok ( ) ;
build_epiphany_reorient_launch_request_with_dynamic_context (
2026-05-14 08:49:03 +01:00
input . thread_id ,
Some ( input . state . revision ) ,
None ,
input . state ,
checkpoint ,
2026-05-19 22:11:58 +01:00
& reorient_decision ,
2026-06-02 14:12:10 +01:00
dynamic_prompt_context ,
2026-05-14 08:49:03 +01:00
)
} ) ,
EpiphanyCoordinatorAutomationAction ::None
| EpiphanyCoordinatorAutomationAction ::CompactRehydrateReorient = > None ,
} ;
let action = if matches! (
action ,
EpiphanyCoordinatorAutomationAction ::LaunchReorientWorker
) & & launch_request . is_none ( )
{
EpiphanyCoordinatorAutomationAction ::None
} else {
action
} ;
EpiphanyCoordinatorAutomationVerdict {
action ,
launch_request ,
}
}
2026-05-19 22:06:09 +01:00
#[ derive(Debug, Clone) ]
pub struct EpiphanyRoleBoardStatus {
pub roles : Vec < EpiphanyRoleBoardLane > ,
2026-05-20 14:56:39 +01:00
pub ( crate ) source_jobs : Vec < EpiphanyJobView > ,
2026-05-19 22:06:09 +01:00
}
2026-05-13 03:07:24 +01:00
pub fn map_epiphany_roles (
2026-05-13 01:33:32 +01:00
state : Option < & EpiphanyThreadState > ,
2026-05-20 02:19:06 +01:00
jobs : & [ EpiphanyJobView ] ,
2026-05-19 22:11:58 +01:00
decision : & CoreEpiphanyReorientDecision ,
2026-05-20 02:12:50 +01:00
pressure : & epiphany_core ::EpiphanyPressure ,
2026-05-19 21:58:29 +01:00
recommendation : & CoreEpiphanyCrrcRecommendation ,
2026-05-19 22:11:58 +01:00
result_status : CoreEpiphanyCrrcResultStatus ,
2026-05-20 02:19:06 +01:00
reorient_job : Option < & EpiphanyJobView > ,
2026-05-19 22:06:09 +01:00
) -> EpiphanyRoleBoardStatus {
2026-05-13 01:33:32 +01:00
let planning = state . map ( | state | & state . planning ) ;
let checkpoint = state . and_then ( | state | state . investigation_checkpoint . as_ref ( ) ) ;
let mut source_jobs = jobs . to_vec ( ) ;
if let Some ( job ) = reorient_job
& & ! source_jobs
. iter ( )
. any ( | source_job | source_job . id = = job . id & & source_job . owner_role = = job . owner_role )
{
source_jobs . push ( job . clone ( ) ) ;
}
2026-05-19 22:06:09 +01:00
let roles = derive_role_board ( EpiphanyRoleBoardInput {
2026-05-13 01:33:32 +01:00
state_present : state . is_some ( ) ,
planning : EpiphanyRoleBoardPlanningSummary {
capture_count : planning
. map ( | planning | planning . captures . len ( ) )
. unwrap_or ( 0 ) ,
backlog_item_count : planning
. map ( | planning | planning . backlog_items . len ( ) )
. unwrap_or ( 0 ) ,
roadmap_stream_count : planning
. map ( | planning | planning . roadmap_streams . len ( ) )
. unwrap_or ( 0 ) ,
objective_draft_count : planning
. map ( | planning | planning . objective_drafts . len ( ) )
. unwrap_or ( 0 ) ,
} ,
checkpoint : checkpoint . map ( | checkpoint | EpiphanyRoleBoardCheckpointSummary {
disposition : Some ( format! ( " {:?} " , checkpoint . disposition ) ) ,
next_action : checkpoint . next_action . clone ( ) ,
} ) ,
reorient_next_action : decision . next_action . clone ( ) ,
jobs : source_jobs . iter ( ) . map ( map_core_role_board_job ) . collect ( ) ,
2026-05-19 21:58:29 +01:00
crrc_action : recommendation . action ,
2026-05-13 01:33:32 +01:00
crrc_recommended_scene_action : recommendation
. recommended_scene_action
2026-05-19 21:58:29 +01:00
. map ( epiphany_core ::crrc_scene_action_to_coordinator_scene_action ) ,
2026-05-13 01:33:32 +01:00
crrc_reason : recommendation . reason . clone ( ) ,
reorient_decision_action : format ! ( " {:?} " , decision . action ) ,
pressure_level : format ! ( " {:?} " , pressure . level ) ,
2026-05-19 22:11:58 +01:00
reorient_result_status : result_status ,
2026-05-13 01:33:32 +01:00
reorient_job : reorient_job . map ( map_core_role_board_job ) ,
imagination_binding_id : EPIPHANY_IMAGINATION_ROLE_BINDING_ID . to_string ( ) ,
2026-05-30 01:02:16 +01:00
research_binding_id : EPIPHANY_RESEARCH_ROLE_BINDING_ID . to_string ( ) ,
2026-05-13 01:33:32 +01:00
modeling_binding_id : EPIPHANY_MODELING_ROLE_BINDING_ID . to_string ( ) ,
verification_binding_id : EPIPHANY_VERIFICATION_ROLE_BINDING_ID . to_string ( ) ,
reorient_owner_role : EPIPHANY_REORIENT_OWNER_ROLE . to_string ( ) ,
imagination_owner_role : EPIPHANY_IMAGINATION_OWNER_ROLE . to_string ( ) ,
2026-05-30 01:02:16 +01:00
research_owner_role : epiphany_core ::EPIPHANY_RESEARCH_OWNER_ROLE . to_string ( ) ,
2026-05-19 22:06:09 +01:00
} ) ;
EpiphanyRoleBoardStatus { roles , source_jobs }
2026-05-13 01:33:32 +01:00
}
2026-05-20 02:19:06 +01:00
fn map_core_role_board_job ( job : & EpiphanyJobView ) -> EpiphanyRoleBoardJob {
2026-05-13 01:33:32 +01:00
EpiphanyRoleBoardJob {
id : job . id . clone ( ) ,
owner_role : job . owner_role . clone ( ) ,
status : map_core_role_board_job_status ( job . status ) ,
progress_note : job . progress_note . clone ( ) ,
blocking_reason : job . blocking_reason . clone ( ) ,
}
}
2026-05-20 02:19:06 +01:00
fn map_core_role_board_job_status ( status : CoreEpiphanyJobStatus ) -> EpiphanyRoleBoardJobStatus {
2026-05-13 01:33:32 +01:00
match status {
2026-05-20 02:19:06 +01:00
CoreEpiphanyJobStatus ::Idle = > EpiphanyRoleBoardJobStatus ::Idle ,
CoreEpiphanyJobStatus ::Needed = > EpiphanyRoleBoardJobStatus ::Needed ,
CoreEpiphanyJobStatus ::Pending = > EpiphanyRoleBoardJobStatus ::Pending ,
CoreEpiphanyJobStatus ::Running = > EpiphanyRoleBoardJobStatus ::Running ,
CoreEpiphanyJobStatus ::Completed = > EpiphanyRoleBoardJobStatus ::Completed ,
CoreEpiphanyJobStatus ::Failed = > EpiphanyRoleBoardJobStatus ::Failed ,
CoreEpiphanyJobStatus ::Cancelled = > EpiphanyRoleBoardJobStatus ::Cancelled ,
CoreEpiphanyJobStatus ::Blocked = > EpiphanyRoleBoardJobStatus ::Blocked ,
CoreEpiphanyJobStatus ::Unavailable = > EpiphanyRoleBoardJobStatus ::Unavailable ,
2026-05-13 01:33:32 +01:00
}
}
2026-05-13 03:07:24 +01:00
pub fn render_epiphany_roles_note (
2026-05-19 22:06:09 +01:00
roles : & [ EpiphanyRoleBoardLane ] ,
2026-05-20 14:50:15 +01:00
state_status : CoreEpiphanyReorientStateStatus ,
2026-05-19 22:06:09 +01:00
recommendation : CoreEpiphanyCrrcAction ,
2026-05-13 01:33:32 +01:00
) -> String {
render_role_board_note (
2026-05-19 22:06:09 +01:00
roles ,
2026-05-13 01:33:32 +01:00
format! ( " {:?} " , state_status ) . as_str ( ) ,
2026-05-19 22:06:09 +01:00
recommendation ,
2026-05-13 01:33:32 +01:00
)
}