Split coordinator protocol projection

This commit is contained in:
Meta Vens 2026-05-20 14:56:39 +01:00
commit da9aa18dd4
7 changed files with 319 additions and 304 deletions

View file

@ -1,23 +1,6 @@
use codex_app_server_protocol::ThreadEpiphanyCoordinatorAction;
use codex_app_server_protocol::ThreadEpiphanyCoordinatorSignals;
use codex_app_server_protocol::ThreadEpiphanyCrrcAction;
use codex_app_server_protocol::ThreadEpiphanyCrrcRecommendation;
use codex_app_server_protocol::ThreadEpiphanyJob;
use codex_app_server_protocol::ThreadEpiphanyReorientAction;
use codex_app_server_protocol::ThreadEpiphanyRoleId;
use codex_app_server_protocol::ThreadEpiphanyRoleLane;
use codex_app_server_protocol::ThreadEpiphanyRoleStatus;
use codex_app_server_protocol::ThreadEpiphanyRolesSource;
use codex_app_server_protocol::ThreadEpiphanySceneAction;
use codex_app_server_protocol::ThreadEpiphanyViewCoordinator;
use epiphany_core::EpiphanyCoordinatorAction as CoreEpiphanyCoordinatorAction;
use epiphany_core::EpiphanyCoordinatorAutomationAction as CoreEpiphanyCoordinatorAutomationAction;
use epiphany_core::EpiphanyCoordinatorDecision as CoreEpiphanyCoordinatorDecision;
use epiphany_core::EpiphanyCoordinatorRoleId as CoreEpiphanyCoordinatorRoleId;
use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus;
use epiphany_core::EpiphanyCoordinatorRoleStatus as CoreEpiphanyCoordinatorRoleStatus;
use epiphany_core::EpiphanyCoordinatorSceneAction as CoreEpiphanyCoordinatorSceneAction;
use epiphany_core::EpiphanyCoordinatorSourceSignals;
use epiphany_core::EpiphanyCoordinatorStatus as CoreEpiphanyCoordinatorStatus;
use epiphany_core::EpiphanyCoordinatorStatusInput;
use epiphany_core::EpiphanyCrrcAction as CoreEpiphanyCrrcAction;
@ -25,7 +8,6 @@ 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::EpiphanyCrrcSceneAction as CoreEpiphanyCrrcSceneAction;
use epiphany_core::EpiphanyCrrcStateStatus as CoreEpiphanyCrrcStateStatus;
use epiphany_core::EpiphanyJobLaunchRequest;
use epiphany_core::EpiphanyJobStatus as CoreEpiphanyJobStatus;
@ -49,7 +31,6 @@ use epiphany_core::recommend_crrc_action;
use epiphany_core::render_role_board_note;
use epiphany_core::reorient_finding_already_accepted;
use epiphany_core::select_coordinator_automation_action;
use epiphany_state_model::EpiphanyJobKind as CoreEpiphanyJobKind;
use epiphany_state_model::EpiphanyRetrievalState;
use epiphany_state_model::EpiphanyThreadState;
@ -62,11 +43,6 @@ use crate::launch::EPIPHANY_VERIFICATION_ROLE_BINDING_ID;
use crate::launch::build_epiphany_reorient_launch_request;
use crate::launch::render_epiphany_coordinator_note;
use crate::pressure::derive_epiphany_pressure;
use crate::protocol_edge::protocol_job_from_surface;
use crate::protocol_edge::protocol_pressure_level;
use crate::protocol_edge::protocol_reorient_result_status;
use crate::protocol_edge::protocol_reorient_state_status;
use crate::protocol_edge::protocol_role_result_status;
use crate::reorient::EpiphanyFreshnessWatcherSnapshot;
use crate::reorient::derive_epiphany_freshness_view;
use crate::reorient::derive_epiphany_reorient;
@ -115,71 +91,6 @@ fn map_core_crrc_reorient_action(
}
}
fn map_protocol_coordinator_source_signals(
signals: EpiphanyCoordinatorSourceSignals,
) -> ThreadEpiphanyCoordinatorSignals {
ThreadEpiphanyCoordinatorSignals {
pressure_level: protocol_pressure_level(signals.pressure_level),
should_prepare_compaction: signals.should_prepare_compaction,
reorient_action: map_protocol_reorient_action(signals.reorient_action),
crrc_action: map_protocol_crrc_action(signals.crrc_action),
modeling_result_status: protocol_role_result_status(signals.modeling_result_status),
verification_result_status: protocol_role_result_status(signals.verification_result_status),
reorient_result_status: protocol_reorient_result_status(signals.reorient_result_status),
}
}
fn map_protocol_reorient_action(
action: CoreEpiphanyReorientAction,
) -> ThreadEpiphanyReorientAction {
match action {
CoreEpiphanyReorientAction::Resume => ThreadEpiphanyReorientAction::Resume,
CoreEpiphanyReorientAction::Regather => ThreadEpiphanyReorientAction::Regather,
}
}
pub fn map_protocol_crrc_action(action: CoreEpiphanyCrrcAction) -> ThreadEpiphanyCrrcAction {
match action {
CoreEpiphanyCrrcAction::Continue => ThreadEpiphanyCrrcAction::Continue,
CoreEpiphanyCrrcAction::PrepareCheckpoint => ThreadEpiphanyCrrcAction::PrepareCheckpoint,
CoreEpiphanyCrrcAction::LaunchReorientWorker => {
ThreadEpiphanyCrrcAction::LaunchReorientWorker
}
CoreEpiphanyCrrcAction::WaitForReorientWorker => {
ThreadEpiphanyCrrcAction::WaitForReorientWorker
}
CoreEpiphanyCrrcAction::ReviewReorientResult => {
ThreadEpiphanyCrrcAction::ReviewReorientResult
}
CoreEpiphanyCrrcAction::AcceptReorientResult => {
ThreadEpiphanyCrrcAction::AcceptReorientResult
}
CoreEpiphanyCrrcAction::RegatherManually => ThreadEpiphanyCrrcAction::RegatherManually,
}
}
fn map_core_crrc_scene_action(action: CoreEpiphanyCrrcSceneAction) -> ThreadEpiphanySceneAction {
match action {
CoreEpiphanyCrrcSceneAction::Update => ThreadEpiphanySceneAction::Update,
CoreEpiphanyCrrcSceneAction::Reorient => ThreadEpiphanySceneAction::Reorient,
CoreEpiphanyCrrcSceneAction::ReorientLaunch => ThreadEpiphanySceneAction::ReorientLaunch,
CoreEpiphanyCrrcSceneAction::ReorientResult => ThreadEpiphanySceneAction::ReorientResult,
CoreEpiphanyCrrcSceneAction::ReorientAccept => ThreadEpiphanySceneAction::ReorientAccept,
}
}
pub fn map_protocol_crrc_recommendation(
recommendation: CoreEpiphanyCrrcRecommendation,
) -> ThreadEpiphanyCrrcRecommendation {
ThreadEpiphanyCrrcRecommendation {
action: map_protocol_crrc_action(recommendation.action),
recommended_scene_action: recommendation
.recommended_scene_action
.map(map_core_crrc_scene_action),
reason: recommendation.reason,
}
}
pub type EpiphanyCoordinatorDecision = CoreEpiphanyCoordinatorDecision;
pub struct EpiphanyCoordinatorStatus {
@ -269,43 +180,6 @@ pub async fn derive_epiphany_coordinator_status(
EpiphanyCoordinatorStatus { core, note }
}
pub fn map_epiphany_coordinator_view(
thread_id: String,
loaded: bool,
state_status: CoreEpiphanyReorientStateStatus,
state_revision: Option<u64>,
status: EpiphanyCoordinatorStatus,
roles: EpiphanyRoleBoardStatus,
) -> ThreadEpiphanyViewCoordinator {
ThreadEpiphanyViewCoordinator {
thread_id,
source: if loaded {
ThreadEpiphanyRolesSource::Live
} else {
ThreadEpiphanyRolesSource::Stored
},
state_status: protocol_reorient_state_status(state_status),
state_revision,
action: map_protocol_coordinator_action(status.core.decision.action),
target_role: status
.core
.decision
.target_role
.map(map_protocol_coordinator_role_id),
recommended_scene_action: status
.core
.decision
.recommended_scene_action
.map(map_protocol_coordinator_scene_action),
requires_review: status.core.decision.requires_review,
can_auto_run: status.core.decision.can_auto_run,
reason: status.core.decision.reason,
source_signals: map_protocol_coordinator_source_signals(status.core.source_signals),
roles: map_protocol_role_board_lanes(&roles),
note: status.note,
}
}
pub type EpiphanyCoordinatorAutomationAction = CoreEpiphanyCoordinatorAutomationAction;
pub struct EpiphanyCoordinatorAutomationInput<'a> {
@ -432,82 +306,10 @@ pub async fn select_epiphany_coordinator_automation(
}
}
fn map_protocol_coordinator_role_id(
role_id: CoreEpiphanyCoordinatorRoleId,
) -> ThreadEpiphanyRoleId {
match role_id {
CoreEpiphanyCoordinatorRoleId::Implementation => ThreadEpiphanyRoleId::Implementation,
CoreEpiphanyCoordinatorRoleId::Imagination => ThreadEpiphanyRoleId::Imagination,
CoreEpiphanyCoordinatorRoleId::Modeling => ThreadEpiphanyRoleId::Modeling,
CoreEpiphanyCoordinatorRoleId::Verification => ThreadEpiphanyRoleId::Verification,
CoreEpiphanyCoordinatorRoleId::Reorientation => ThreadEpiphanyRoleId::Reorientation,
}
}
fn map_protocol_coordinator_scene_action(
action: CoreEpiphanyCoordinatorSceneAction,
) -> ThreadEpiphanySceneAction {
match action {
CoreEpiphanyCoordinatorSceneAction::Update => ThreadEpiphanySceneAction::Update,
CoreEpiphanyCoordinatorSceneAction::Reorient => ThreadEpiphanySceneAction::Reorient,
CoreEpiphanyCoordinatorSceneAction::ReorientLaunch => {
ThreadEpiphanySceneAction::ReorientLaunch
}
CoreEpiphanyCoordinatorSceneAction::ReorientResult => {
ThreadEpiphanySceneAction::ReorientResult
}
CoreEpiphanyCoordinatorSceneAction::ReorientAccept => {
ThreadEpiphanySceneAction::ReorientAccept
}
CoreEpiphanyCoordinatorSceneAction::RoleLaunch => ThreadEpiphanySceneAction::RoleLaunch,
CoreEpiphanyCoordinatorSceneAction::RoleResult => ThreadEpiphanySceneAction::RoleResult,
}
}
fn map_protocol_coordinator_action(
action: CoreEpiphanyCoordinatorAction,
) -> ThreadEpiphanyCoordinatorAction {
match action {
CoreEpiphanyCoordinatorAction::PrepareCheckpoint => {
ThreadEpiphanyCoordinatorAction::PrepareCheckpoint
}
CoreEpiphanyCoordinatorAction::CompactRehydrateReorient => {
ThreadEpiphanyCoordinatorAction::CompactRehydrateReorient
}
CoreEpiphanyCoordinatorAction::LaunchReorientWorker => {
ThreadEpiphanyCoordinatorAction::LaunchReorientWorker
}
CoreEpiphanyCoordinatorAction::WaitForReorientWorker => {
ThreadEpiphanyCoordinatorAction::WaitForReorientWorker
}
CoreEpiphanyCoordinatorAction::ReviewReorientResult => {
ThreadEpiphanyCoordinatorAction::ReviewReorientResult
}
CoreEpiphanyCoordinatorAction::RegatherManually => {
ThreadEpiphanyCoordinatorAction::RegatherManually
}
CoreEpiphanyCoordinatorAction::LaunchModeling => {
ThreadEpiphanyCoordinatorAction::LaunchModeling
}
CoreEpiphanyCoordinatorAction::ReviewModelingResult => {
ThreadEpiphanyCoordinatorAction::ReviewModelingResult
}
CoreEpiphanyCoordinatorAction::LaunchVerification => {
ThreadEpiphanyCoordinatorAction::LaunchVerification
}
CoreEpiphanyCoordinatorAction::ReviewVerificationResult => {
ThreadEpiphanyCoordinatorAction::ReviewVerificationResult
}
CoreEpiphanyCoordinatorAction::ContinueImplementation => {
ThreadEpiphanyCoordinatorAction::ContinueImplementation
}
}
}
#[derive(Debug, Clone)]
pub struct EpiphanyRoleBoardStatus {
pub roles: Vec<EpiphanyRoleBoardLane>,
source_jobs: Vec<EpiphanyJobView>,
pub(crate) source_jobs: Vec<EpiphanyJobView>,
}
pub fn map_epiphany_roles(
@ -594,104 +396,6 @@ fn map_core_role_board_job_status(status: CoreEpiphanyJobStatus) -> EpiphanyRole
}
}
pub fn map_protocol_role_board_lanes(
role_board: &EpiphanyRoleBoardStatus,
) -> Vec<ThreadEpiphanyRoleLane> {
role_board
.roles
.iter()
.cloned()
.map(|lane| map_protocol_role_board_lane(lane, &role_board.source_jobs))
.collect()
}
fn map_protocol_role_board_lane(
lane: EpiphanyRoleBoardLane,
source_jobs: &[EpiphanyJobView],
) -> ThreadEpiphanyRoleLane {
ThreadEpiphanyRoleLane {
id: map_protocol_coordinator_role_id(lane.id),
title: lane.title,
owner_role: lane.owner_role,
status: map_protocol_coordinator_role_status(lane.status),
note: lane.note,
jobs: lane
.jobs
.iter()
.map(|job| map_protocol_role_board_job(job, source_jobs))
.collect(),
authority_scopes: lane.authority_scopes,
recommended_action: lane
.recommended_action
.map(map_protocol_coordinator_scene_action),
}
}
fn map_protocol_role_board_job(
job: &EpiphanyRoleBoardJob,
source_jobs: &[EpiphanyJobView],
) -> ThreadEpiphanyJob {
source_jobs
.iter()
.find(|source_job| source_job.id == job.id && source_job.owner_role == job.owner_role)
.cloned()
.map(|job| protocol_job_from_surface(job, None, None))
.unwrap_or_else(|| {
protocol_job_from_surface(
EpiphanyJobView {
id: job.id.clone(),
kind: CoreEpiphanyJobKind::Specialist,
scope: job.id.clone(),
owner_role: job.owner_role.clone(),
authority_scope: None,
runtime_job_id: None,
status: map_core_epiphany_job_status_from_role_board(job.status),
items_processed: None,
items_total: None,
progress_note: job.progress_note.clone(),
last_checkpoint_at_unix_seconds: None,
blocking_reason: job.blocking_reason.clone(),
active_thread_ids: Vec::new(),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
},
None,
None,
)
})
}
fn map_core_epiphany_job_status_from_role_board(
status: EpiphanyRoleBoardJobStatus,
) -> CoreEpiphanyJobStatus {
match status {
EpiphanyRoleBoardJobStatus::Idle => CoreEpiphanyJobStatus::Idle,
EpiphanyRoleBoardJobStatus::Needed => CoreEpiphanyJobStatus::Needed,
EpiphanyRoleBoardJobStatus::Pending => CoreEpiphanyJobStatus::Pending,
EpiphanyRoleBoardJobStatus::Running => CoreEpiphanyJobStatus::Running,
EpiphanyRoleBoardJobStatus::Completed => CoreEpiphanyJobStatus::Completed,
EpiphanyRoleBoardJobStatus::Failed => CoreEpiphanyJobStatus::Failed,
EpiphanyRoleBoardJobStatus::Cancelled => CoreEpiphanyJobStatus::Cancelled,
EpiphanyRoleBoardJobStatus::Blocked => CoreEpiphanyJobStatus::Blocked,
EpiphanyRoleBoardJobStatus::Unavailable => CoreEpiphanyJobStatus::Unavailable,
}
}
fn map_protocol_coordinator_role_status(
status: CoreEpiphanyCoordinatorRoleStatus,
) -> ThreadEpiphanyRoleStatus {
match status {
CoreEpiphanyCoordinatorRoleStatus::Ready => ThreadEpiphanyRoleStatus::Ready,
CoreEpiphanyCoordinatorRoleStatus::Needed => ThreadEpiphanyRoleStatus::Needed,
CoreEpiphanyCoordinatorRoleStatus::Running => ThreadEpiphanyRoleStatus::Running,
CoreEpiphanyCoordinatorRoleStatus::Waiting => ThreadEpiphanyRoleStatus::Waiting,
CoreEpiphanyCoordinatorRoleStatus::Review => ThreadEpiphanyRoleStatus::Review,
CoreEpiphanyCoordinatorRoleStatus::Blocked => ThreadEpiphanyRoleStatus::Blocked,
CoreEpiphanyCoordinatorRoleStatus::Unavailable => ThreadEpiphanyRoleStatus::Unavailable,
CoreEpiphanyCoordinatorRoleStatus::Completed => ThreadEpiphanyRoleStatus::Completed,
}
}
pub fn render_epiphany_roles_note(
roles: &[EpiphanyRoleBoardLane],
state_status: CoreEpiphanyReorientStateStatus,

View file

@ -0,0 +1,304 @@
use codex_app_server_protocol::ThreadEpiphanyCoordinatorAction;
use codex_app_server_protocol::ThreadEpiphanyCoordinatorSignals;
use codex_app_server_protocol::ThreadEpiphanyCrrcAction;
use codex_app_server_protocol::ThreadEpiphanyCrrcRecommendation;
use codex_app_server_protocol::ThreadEpiphanyJob;
use codex_app_server_protocol::ThreadEpiphanyReorientAction;
use codex_app_server_protocol::ThreadEpiphanyRoleId;
use codex_app_server_protocol::ThreadEpiphanyRoleLane;
use codex_app_server_protocol::ThreadEpiphanyRoleStatus;
use codex_app_server_protocol::ThreadEpiphanyRolesSource;
use codex_app_server_protocol::ThreadEpiphanySceneAction;
use codex_app_server_protocol::ThreadEpiphanyViewCoordinator;
use epiphany_core::EpiphanyCoordinatorAction as CoreEpiphanyCoordinatorAction;
use epiphany_core::EpiphanyCoordinatorRoleId as CoreEpiphanyCoordinatorRoleId;
use epiphany_core::EpiphanyCoordinatorRoleStatus as CoreEpiphanyCoordinatorRoleStatus;
use epiphany_core::EpiphanyCoordinatorSceneAction as CoreEpiphanyCoordinatorSceneAction;
use epiphany_core::EpiphanyCoordinatorSourceSignals;
use epiphany_core::EpiphanyCrrcAction as CoreEpiphanyCrrcAction;
use epiphany_core::EpiphanyCrrcRecommendation as CoreEpiphanyCrrcRecommendation;
use epiphany_core::EpiphanyCrrcSceneAction as CoreEpiphanyCrrcSceneAction;
use epiphany_core::EpiphanyJobStatus as CoreEpiphanyJobStatus;
use epiphany_core::EpiphanyJobView;
use epiphany_core::EpiphanyReorientAction as CoreEpiphanyReorientAction;
use epiphany_core::EpiphanyReorientStateStatus as CoreEpiphanyReorientStateStatus;
use epiphany_core::EpiphanyRoleBoardJob;
use epiphany_core::EpiphanyRoleBoardJobStatus;
use epiphany_core::EpiphanyRoleBoardLane;
use epiphany_state_model::EpiphanyJobKind as CoreEpiphanyJobKind;
use crate::coordinator::EpiphanyCoordinatorStatus;
use crate::coordinator::EpiphanyRoleBoardStatus;
use crate::protocol_edge::protocol_job_from_surface;
use crate::protocol_edge::protocol_pressure_level;
use crate::protocol_edge::protocol_reorient_result_status;
use crate::protocol_edge::protocol_reorient_state_status;
use crate::protocol_edge::protocol_role_result_status;
fn protocol_coordinator_source_signals(
signals: EpiphanyCoordinatorSourceSignals,
) -> ThreadEpiphanyCoordinatorSignals {
ThreadEpiphanyCoordinatorSignals {
pressure_level: protocol_pressure_level(signals.pressure_level),
should_prepare_compaction: signals.should_prepare_compaction,
reorient_action: protocol_reorient_action(signals.reorient_action),
crrc_action: protocol_crrc_action(signals.crrc_action),
modeling_result_status: protocol_role_result_status(signals.modeling_result_status),
verification_result_status: protocol_role_result_status(signals.verification_result_status),
reorient_result_status: protocol_reorient_result_status(signals.reorient_result_status),
}
}
fn protocol_reorient_action(action: CoreEpiphanyReorientAction) -> ThreadEpiphanyReorientAction {
match action {
CoreEpiphanyReorientAction::Resume => ThreadEpiphanyReorientAction::Resume,
CoreEpiphanyReorientAction::Regather => ThreadEpiphanyReorientAction::Regather,
}
}
pub fn protocol_crrc_action(action: CoreEpiphanyCrrcAction) -> ThreadEpiphanyCrrcAction {
match action {
CoreEpiphanyCrrcAction::Continue => ThreadEpiphanyCrrcAction::Continue,
CoreEpiphanyCrrcAction::PrepareCheckpoint => ThreadEpiphanyCrrcAction::PrepareCheckpoint,
CoreEpiphanyCrrcAction::LaunchReorientWorker => {
ThreadEpiphanyCrrcAction::LaunchReorientWorker
}
CoreEpiphanyCrrcAction::WaitForReorientWorker => {
ThreadEpiphanyCrrcAction::WaitForReorientWorker
}
CoreEpiphanyCrrcAction::ReviewReorientResult => {
ThreadEpiphanyCrrcAction::ReviewReorientResult
}
CoreEpiphanyCrrcAction::AcceptReorientResult => {
ThreadEpiphanyCrrcAction::AcceptReorientResult
}
CoreEpiphanyCrrcAction::RegatherManually => ThreadEpiphanyCrrcAction::RegatherManually,
}
}
fn protocol_crrc_scene_action(action: CoreEpiphanyCrrcSceneAction) -> ThreadEpiphanySceneAction {
match action {
CoreEpiphanyCrrcSceneAction::Update => ThreadEpiphanySceneAction::Update,
CoreEpiphanyCrrcSceneAction::Reorient => ThreadEpiphanySceneAction::Reorient,
CoreEpiphanyCrrcSceneAction::ReorientLaunch => ThreadEpiphanySceneAction::ReorientLaunch,
CoreEpiphanyCrrcSceneAction::ReorientResult => ThreadEpiphanySceneAction::ReorientResult,
CoreEpiphanyCrrcSceneAction::ReorientAccept => ThreadEpiphanySceneAction::ReorientAccept,
}
}
pub fn protocol_crrc_recommendation(
recommendation: CoreEpiphanyCrrcRecommendation,
) -> ThreadEpiphanyCrrcRecommendation {
ThreadEpiphanyCrrcRecommendation {
action: protocol_crrc_action(recommendation.action),
recommended_scene_action: recommendation
.recommended_scene_action
.map(protocol_crrc_scene_action),
reason: recommendation.reason,
}
}
pub fn protocol_coordinator_view(
thread_id: String,
loaded: bool,
state_status: CoreEpiphanyReorientStateStatus,
state_revision: Option<u64>,
status: EpiphanyCoordinatorStatus,
roles: EpiphanyRoleBoardStatus,
) -> ThreadEpiphanyViewCoordinator {
ThreadEpiphanyViewCoordinator {
thread_id,
source: if loaded {
ThreadEpiphanyRolesSource::Live
} else {
ThreadEpiphanyRolesSource::Stored
},
state_status: protocol_reorient_state_status(state_status),
state_revision,
action: protocol_coordinator_action(status.core.decision.action),
target_role: status
.core
.decision
.target_role
.map(protocol_coordinator_role_id),
recommended_scene_action: status
.core
.decision
.recommended_scene_action
.map(protocol_coordinator_scene_action),
requires_review: status.core.decision.requires_review,
can_auto_run: status.core.decision.can_auto_run,
reason: status.core.decision.reason,
source_signals: protocol_coordinator_source_signals(status.core.source_signals),
roles: protocol_role_board_lanes(&roles),
note: status.note,
}
}
fn protocol_coordinator_role_id(role_id: CoreEpiphanyCoordinatorRoleId) -> ThreadEpiphanyRoleId {
match role_id {
CoreEpiphanyCoordinatorRoleId::Implementation => ThreadEpiphanyRoleId::Implementation,
CoreEpiphanyCoordinatorRoleId::Imagination => ThreadEpiphanyRoleId::Imagination,
CoreEpiphanyCoordinatorRoleId::Modeling => ThreadEpiphanyRoleId::Modeling,
CoreEpiphanyCoordinatorRoleId::Verification => ThreadEpiphanyRoleId::Verification,
CoreEpiphanyCoordinatorRoleId::Reorientation => ThreadEpiphanyRoleId::Reorientation,
}
}
fn protocol_coordinator_scene_action(
action: CoreEpiphanyCoordinatorSceneAction,
) -> ThreadEpiphanySceneAction {
match action {
CoreEpiphanyCoordinatorSceneAction::Update => ThreadEpiphanySceneAction::Update,
CoreEpiphanyCoordinatorSceneAction::Reorient => ThreadEpiphanySceneAction::Reorient,
CoreEpiphanyCoordinatorSceneAction::ReorientLaunch => {
ThreadEpiphanySceneAction::ReorientLaunch
}
CoreEpiphanyCoordinatorSceneAction::ReorientResult => {
ThreadEpiphanySceneAction::ReorientResult
}
CoreEpiphanyCoordinatorSceneAction::ReorientAccept => {
ThreadEpiphanySceneAction::ReorientAccept
}
CoreEpiphanyCoordinatorSceneAction::RoleLaunch => ThreadEpiphanySceneAction::RoleLaunch,
CoreEpiphanyCoordinatorSceneAction::RoleResult => ThreadEpiphanySceneAction::RoleResult,
}
}
fn protocol_coordinator_action(
action: CoreEpiphanyCoordinatorAction,
) -> ThreadEpiphanyCoordinatorAction {
match action {
CoreEpiphanyCoordinatorAction::PrepareCheckpoint => {
ThreadEpiphanyCoordinatorAction::PrepareCheckpoint
}
CoreEpiphanyCoordinatorAction::CompactRehydrateReorient => {
ThreadEpiphanyCoordinatorAction::CompactRehydrateReorient
}
CoreEpiphanyCoordinatorAction::LaunchReorientWorker => {
ThreadEpiphanyCoordinatorAction::LaunchReorientWorker
}
CoreEpiphanyCoordinatorAction::WaitForReorientWorker => {
ThreadEpiphanyCoordinatorAction::WaitForReorientWorker
}
CoreEpiphanyCoordinatorAction::ReviewReorientResult => {
ThreadEpiphanyCoordinatorAction::ReviewReorientResult
}
CoreEpiphanyCoordinatorAction::RegatherManually => {
ThreadEpiphanyCoordinatorAction::RegatherManually
}
CoreEpiphanyCoordinatorAction::LaunchModeling => {
ThreadEpiphanyCoordinatorAction::LaunchModeling
}
CoreEpiphanyCoordinatorAction::ReviewModelingResult => {
ThreadEpiphanyCoordinatorAction::ReviewModelingResult
}
CoreEpiphanyCoordinatorAction::LaunchVerification => {
ThreadEpiphanyCoordinatorAction::LaunchVerification
}
CoreEpiphanyCoordinatorAction::ReviewVerificationResult => {
ThreadEpiphanyCoordinatorAction::ReviewVerificationResult
}
CoreEpiphanyCoordinatorAction::ContinueImplementation => {
ThreadEpiphanyCoordinatorAction::ContinueImplementation
}
}
}
pub fn protocol_role_board_lanes(
role_board: &EpiphanyRoleBoardStatus,
) -> Vec<ThreadEpiphanyRoleLane> {
role_board
.roles
.iter()
.cloned()
.map(|lane| protocol_role_board_lane(lane, &role_board.source_jobs))
.collect()
}
fn protocol_role_board_lane(
lane: EpiphanyRoleBoardLane,
source_jobs: &[EpiphanyJobView],
) -> ThreadEpiphanyRoleLane {
ThreadEpiphanyRoleLane {
id: protocol_coordinator_role_id(lane.id),
title: lane.title,
owner_role: lane.owner_role,
status: protocol_coordinator_role_status(lane.status),
note: lane.note,
jobs: lane
.jobs
.iter()
.map(|job| protocol_role_board_job(job, source_jobs))
.collect(),
authority_scopes: lane.authority_scopes,
recommended_action: lane
.recommended_action
.map(protocol_coordinator_scene_action),
}
}
fn protocol_role_board_job(
job: &EpiphanyRoleBoardJob,
source_jobs: &[EpiphanyJobView],
) -> ThreadEpiphanyJob {
source_jobs
.iter()
.find(|source_job| source_job.id == job.id && source_job.owner_role == job.owner_role)
.cloned()
.map(|job| protocol_job_from_surface(job, None, None))
.unwrap_or_else(|| {
protocol_job_from_surface(
EpiphanyJobView {
id: job.id.clone(),
kind: CoreEpiphanyJobKind::Specialist,
scope: job.id.clone(),
owner_role: job.owner_role.clone(),
authority_scope: None,
runtime_job_id: None,
status: core_epiphany_job_status_from_role_board(job.status),
items_processed: None,
items_total: None,
progress_note: job.progress_note.clone(),
last_checkpoint_at_unix_seconds: None,
blocking_reason: job.blocking_reason.clone(),
active_thread_ids: Vec::new(),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
},
None,
None,
)
})
}
fn core_epiphany_job_status_from_role_board(
status: EpiphanyRoleBoardJobStatus,
) -> CoreEpiphanyJobStatus {
match status {
EpiphanyRoleBoardJobStatus::Idle => CoreEpiphanyJobStatus::Idle,
EpiphanyRoleBoardJobStatus::Needed => CoreEpiphanyJobStatus::Needed,
EpiphanyRoleBoardJobStatus::Pending => CoreEpiphanyJobStatus::Pending,
EpiphanyRoleBoardJobStatus::Running => CoreEpiphanyJobStatus::Running,
EpiphanyRoleBoardJobStatus::Completed => CoreEpiphanyJobStatus::Completed,
EpiphanyRoleBoardJobStatus::Failed => CoreEpiphanyJobStatus::Failed,
EpiphanyRoleBoardJobStatus::Cancelled => CoreEpiphanyJobStatus::Cancelled,
EpiphanyRoleBoardJobStatus::Blocked => CoreEpiphanyJobStatus::Blocked,
EpiphanyRoleBoardJobStatus::Unavailable => CoreEpiphanyJobStatus::Unavailable,
}
}
fn protocol_coordinator_role_status(
status: CoreEpiphanyCoordinatorRoleStatus,
) -> ThreadEpiphanyRoleStatus {
match status {
CoreEpiphanyCoordinatorRoleStatus::Ready => ThreadEpiphanyRoleStatus::Ready,
CoreEpiphanyCoordinatorRoleStatus::Needed => ThreadEpiphanyRoleStatus::Needed,
CoreEpiphanyCoordinatorRoleStatus::Running => ThreadEpiphanyRoleStatus::Running,
CoreEpiphanyCoordinatorRoleStatus::Waiting => ThreadEpiphanyRoleStatus::Waiting,
CoreEpiphanyCoordinatorRoleStatus::Review => ThreadEpiphanyRoleStatus::Review,
CoreEpiphanyCoordinatorRoleStatus::Blocked => ThreadEpiphanyRoleStatus::Blocked,
CoreEpiphanyCoordinatorRoleStatus::Unavailable => ThreadEpiphanyRoleStatus::Unavailable,
CoreEpiphanyCoordinatorRoleStatus::Completed => ThreadEpiphanyRoleStatus::Completed,
}
}

View file

@ -1,6 +1,7 @@
pub mod checkpoint;
pub mod context;
pub mod coordinator;
pub mod coordinator_protocol;
pub mod cultnet;
pub mod error;
pub mod invalidation;

View file

@ -23,12 +23,12 @@ use crate::context::map_epiphany_context;
use crate::context::map_epiphany_graph_query;
use crate::context::map_epiphany_planning;
use crate::coordinator::derive_epiphany_coordinator_status;
use crate::coordinator::map_epiphany_coordinator_view;
use crate::coordinator::map_epiphany_crrc_recommendation;
use crate::coordinator::map_epiphany_roles;
use crate::coordinator::map_protocol_crrc_recommendation;
use crate::coordinator::map_protocol_role_board_lanes;
use crate::coordinator::render_epiphany_roles_note;
use crate::coordinator_protocol::protocol_coordinator_view;
use crate::coordinator_protocol::protocol_crrc_recommendation;
use crate::coordinator_protocol::protocol_role_board_lanes;
use crate::cultnet::EpiphanyFreshnessSurface;
use crate::cultnet::EpiphanySurfaceSource;
use crate::jobs::map_epiphany_jobs;
@ -286,7 +286,7 @@ pub async fn map_epiphany_view_response(
checkpoint_present,
)
.await;
Some(map_epiphany_coordinator_view(
Some(protocol_coordinator_view(
thread_id.clone(),
loaded,
core_reorient_state_status,
@ -318,7 +318,7 @@ pub async fn map_epiphany_view_response(
let role_board = roles.clone();
let protocol_roles = role_board
.as_ref()
.map(map_protocol_role_board_lanes)
.map(protocol_role_board_lanes)
.unwrap_or_default();
ThreadEpiphanyViewRoles {
thread_id: thread_id.clone(),
@ -386,8 +386,7 @@ pub async fn map_epiphany_view_response(
let pressure = pressure.clone()?;
let decision = reorient_decision.clone()?;
let recommendation = recommendation.clone()?;
let protocol_recommendation =
map_protocol_crrc_recommendation(recommendation.clone());
let protocol_recommendation = protocol_crrc_recommendation(recommendation.clone());
let available_actions = derive_scene(EpiphanySceneInput {
state,
loaded,

View file

@ -87,6 +87,7 @@ remembers doctrine; the branch remembers the blade.
- Result projection moved to the edge. `results.rs` now renders typed result notes only; `protocol_edge` owns role-id request conversion plus role/reorient finding and state-patch projection for Codex JSON-RPC responses.
- State-updated notification projection moved to the edge as well. `mutation.rs` now owns typed mutation/acceptance mechanics without importing app-server protocol DTOs.
- `pressure.rs` is typed-only now. The convenience helper returning `ThreadEpiphanyPressure` was deleted; view response assembly derives typed pressure and calls `protocol_edge` for projection.
- Coordinator projection is split out too. `coordinator.rs` no longer imports app-server protocol DTOs; it owns typed coordinator status, CRRC input shaping, role-board derivation, automation verdict selection, and note rendering. `coordinator_protocol.rs` owns Codex JSON-RPC projection for coordinator, CRRC, and role-board response payloads.
- MCP remains JSON because MCP is a JSON protocol. The latest processor cut only moved MCP refresh/OAuth/status/resource/tool-call route handling into `codex_message_processor/mcp_routes.rs`, reducing the root processor to about 8,977 lines; it did not claim MCP payloads are CultNet or make MCP an Epiphany-owned runtime contract.
- Codex account auth route handling remains in vendored Codex but now lives in `codex_message_processor/auth_routes.rs`: API-key login, ChatGPT browser/device-code/external-token login, logout, auth status, account, rate limits, and add-credits nudge handling. This preserves Codex ownership of subscription auth while cutting the root processor to about 8,094 lines.
- One-off command execution and command stream write/resize/terminate route handling now live in `codex_message_processor/command_routes.rs`; `CommandExecManager` remains the lifecycle owner, while the root processor is about 7,800 lines.

Binary file not shown.

View file

@ -426,6 +426,12 @@ current_status:
`pressure.rs` is typed-only now as well: the last convenience helper that
returned `ThreadEpiphanyPressure` was deleted, and view response assembly
explicitly derives typed pressure before calling `protocol_edge`.
Coordinator projection has its own edge module now:
`coordinator.rs` no longer imports Codex app-server protocol DTOs and owns
typed coordinator status, CRRC recommendation input shaping, role-board
derivation, automation verdict selection, and role-board note rendering;
`coordinator_protocol.rs` owns Codex JSON-RPC projection for coordinator,
CRRC, and role-board response payloads.
The bridge still depends on vendored Codex for app-server protocol DTOs and
absolute path validation, so the purification is not done.
next_action: Continue Codex starvation and CultNet liberation by cutting bridge-internal response/projection authority. Prioritize the next coordinator/view seam that still composes policy-shaped facts instead of merely loading host facts and projecting core surfaces; keep MCP/OpenAI JSON only at their true protocol/text edges. Do not add compatibility adapters unless they protect a named ownership invariant.