Collapse Epiphany CRRC reads into view
This commit is contained in:
parent
53bdea881b
commit
32d6eed2d8
14 changed files with 117 additions and 1169 deletions
|
|
@ -155,13 +155,9 @@ use codex_app_server_protocol::ThreadEpiphanyContextResponse;
|
|||
use codex_app_server_protocol::ThreadEpiphanyContextSource;
|
||||
use codex_app_server_protocol::ThreadEpiphanyContextStateStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCoordinatorAction;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCoordinatorParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCoordinatorResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCoordinatorSignals;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCrrcAction;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCrrcParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCrrcRecommendation;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCrrcResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyDistillParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyDistillResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyFreshnessParams;
|
||||
|
|
@ -197,9 +193,6 @@ use codex_app_server_protocol::ThreadEpiphanyPlanningSummary;
|
|||
use codex_app_server_protocol::ThreadEpiphanyPressure;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureBasis;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureLevel;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureSource;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPromoteParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPromoteResponse;
|
||||
|
|
@ -213,9 +206,7 @@ use codex_app_server_protocol::ThreadEpiphanyReorientDecision;
|
|||
use codex_app_server_protocol::ThreadEpiphanyReorientFinding;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientLaunchParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientLaunchResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientReason;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResultParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResultResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus;
|
||||
|
|
@ -1138,10 +1129,6 @@ impl CodexMessageProcessor {
|
|||
self.thread_epiphany_roles(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyCoordinator { request_id, params } => {
|
||||
self.thread_epiphany_coordinator(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyRoleLaunch { request_id, params } => {
|
||||
self.thread_epiphany_role_launch(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
|
|
@ -1170,18 +1157,6 @@ impl CodexMessageProcessor {
|
|||
self.thread_epiphany_graph_query(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyPressure { request_id, params } => {
|
||||
self.thread_epiphany_pressure(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyReorient { request_id, params } => {
|
||||
self.thread_epiphany_reorient(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyCrrc { request_id, params } => {
|
||||
self.thread_epiphany_crrc(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyReorientLaunch { request_id, params } => {
|
||||
self.thread_epiphany_reorient_launch(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
|
|
@ -4965,266 +4940,6 @@ impl CodexMessageProcessor {
|
|||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_coordinator(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyCoordinatorParams,
|
||||
) {
|
||||
let ThreadEpiphanyCoordinatorParams { thread_id } = params;
|
||||
|
||||
let thread_uuid = match ThreadId::from_string(&thread_id) {
|
||||
Ok(id) => id,
|
||||
Err(err) => {
|
||||
self.send_invalid_request_error(request_id, format!("invalid thread id: {err}"))
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let loaded_thread = self.thread_manager.get_thread(thread_uuid).await.ok();
|
||||
let loaded = loaded_thread.is_some();
|
||||
let thread = match self.read_thread_view(thread_uuid, false).await {
|
||||
Ok(thread) => thread,
|
||||
Err(ThreadReadViewError::InvalidRequest(message)) => {
|
||||
self.send_invalid_request_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
Err(ThreadReadViewError::Internal(message)) => {
|
||||
self.send_internal_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let retrieval_override = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_retrieval_state().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let watcher_snapshot = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
let config_snapshot = loaded_thread.config_snapshot().await;
|
||||
self.epiphany_invalidation_manager
|
||||
.ensure_thread_watch(&thread_id, &config_snapshot.cwd)
|
||||
.await;
|
||||
Some(
|
||||
self.epiphany_invalidation_manager
|
||||
.snapshot(&thread_id)
|
||||
.await,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (source, token_usage_info) = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
(
|
||||
ThreadEpiphanyRolesSource::Live,
|
||||
loaded_thread.token_usage_info().await,
|
||||
)
|
||||
} else {
|
||||
let token_usage_info = match thread.path.as_deref() {
|
||||
Some(path) => latest_token_usage_info_from_rollout_path(path).await,
|
||||
None => None,
|
||||
};
|
||||
(ThreadEpiphanyRolesSource::Stored, token_usage_info)
|
||||
};
|
||||
|
||||
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
|
||||
thread.epiphany_state.as_ref(),
|
||||
retrieval_override.as_ref(),
|
||||
watcher_snapshot.as_ref(),
|
||||
);
|
||||
let pressure = map_epiphany_pressure(token_usage_info.as_ref());
|
||||
let (state_status, decision) = map_epiphany_reorient(
|
||||
thread.epiphany_state.as_ref(),
|
||||
&pressure,
|
||||
&retrieval,
|
||||
&graph,
|
||||
&watcher,
|
||||
);
|
||||
|
||||
let runtime_store_path = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_runtime_spine_store_path().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let jobs = map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref());
|
||||
let reorient_job = jobs
|
||||
.iter()
|
||||
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
|
||||
.cloned();
|
||||
let (reorient_result_status, reorient_finding, _) = load_epiphany_reorient_result_snapshot(
|
||||
thread.epiphany_state.as_ref(),
|
||||
runtime_store_path.as_deref(),
|
||||
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
|
||||
)
|
||||
.await;
|
||||
let checkpoint_present = thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.and_then(|state| state.investigation_checkpoint.as_ref())
|
||||
.is_some();
|
||||
let reorient_finding_accepted = reorient_finding.as_ref().is_some_and(|finding| {
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.is_some_and(|state| epiphany_reorient_finding_already_accepted(state, finding))
|
||||
});
|
||||
let recommendation = map_epiphany_crrc_recommendation(
|
||||
loaded,
|
||||
state_status,
|
||||
&pressure,
|
||||
&decision,
|
||||
reorient_result_status,
|
||||
checkpoint_present,
|
||||
reorient_finding.is_some(),
|
||||
reorient_finding_accepted,
|
||||
);
|
||||
let roles = map_epiphany_roles(
|
||||
thread.epiphany_state.as_ref(),
|
||||
&jobs,
|
||||
&decision,
|
||||
&pressure,
|
||||
&recommendation,
|
||||
reorient_result_status,
|
||||
reorient_job.as_ref(),
|
||||
);
|
||||
|
||||
let (modeling_result_status, modeling_finding, _) =
|
||||
if let Some(state) = thread.epiphany_state.as_ref() {
|
||||
load_epiphany_role_result_snapshot(
|
||||
state,
|
||||
runtime_store_path.as_deref(),
|
||||
ThreadEpiphanyRoleId::Modeling,
|
||||
EPIPHANY_MODELING_ROLE_BINDING_ID,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
(
|
||||
ThreadEpiphanyRoleResultStatus::MissingState,
|
||||
None,
|
||||
"No authoritative Epiphany state exists for this thread.".to_string(),
|
||||
)
|
||||
};
|
||||
let modeling_result_accepted = modeling_finding.as_ref().is_some_and(|finding| {
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.is_some_and(|state| epiphany_role_finding_already_accepted(state, finding))
|
||||
});
|
||||
let modeling_result_reviewable = modeling_finding
|
||||
.as_ref()
|
||||
.is_some_and(epiphany_modeling_finding_has_reviewable_state_patch);
|
||||
let (verification_result_status, verification_finding, _) =
|
||||
if let Some(state) = thread.epiphany_state.as_ref() {
|
||||
load_epiphany_role_result_snapshot(
|
||||
state,
|
||||
runtime_store_path.as_deref(),
|
||||
ThreadEpiphanyRoleId::Verification,
|
||||
EPIPHANY_VERIFICATION_ROLE_BINDING_ID,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
(
|
||||
ThreadEpiphanyRoleResultStatus::MissingState,
|
||||
None,
|
||||
"No authoritative Epiphany state exists for this thread.".to_string(),
|
||||
)
|
||||
};
|
||||
let verification_result_accepted = verification_finding.as_ref().is_some_and(|finding| {
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.is_some_and(|state| epiphany_role_finding_already_accepted(state, finding))
|
||||
});
|
||||
let verification_result_covers_current_modeling =
|
||||
thread.epiphany_state.as_ref().is_none_or(|state| {
|
||||
epiphany_verification_finding_covers_current_modeling(
|
||||
state,
|
||||
modeling_result_accepted,
|
||||
modeling_finding.as_ref(),
|
||||
verification_finding.as_ref(),
|
||||
)
|
||||
});
|
||||
let modeling_result_accepted_after_verification =
|
||||
thread.epiphany_state.as_ref().is_some_and(|state| {
|
||||
role_finding_accepted_after(
|
||||
state,
|
||||
modeling_finding.as_ref(),
|
||||
verification_finding.as_ref(),
|
||||
)
|
||||
});
|
||||
let implementation_evidence_after_verification =
|
||||
thread.epiphany_state.as_ref().is_some_and(|state| {
|
||||
implementation_evidence_after_role_finding(state, verification_finding.as_ref())
|
||||
});
|
||||
let verification_result_cites_implementation_evidence =
|
||||
thread.epiphany_state.as_ref().is_some_and(|state| {
|
||||
epiphany_role_finding_cites_implementation_evidence(
|
||||
state,
|
||||
verification_finding.as_ref(),
|
||||
)
|
||||
});
|
||||
let verification_result_allows_implementation = verification_result_accepted
|
||||
&& verification_finding
|
||||
.as_ref()
|
||||
.is_some_and(epiphany_verification_finding_allows_implementation);
|
||||
let verification_result_needs_evidence = verification_result_accepted
|
||||
&& verification_finding
|
||||
.as_ref()
|
||||
.is_some_and(epiphany_verification_finding_needs_evidence);
|
||||
|
||||
let source_signals = ThreadEpiphanyCoordinatorSignals {
|
||||
pressure_level: pressure.level,
|
||||
should_prepare_compaction: pressure.should_prepare_compaction,
|
||||
reorient_action: decision.action,
|
||||
crrc_action: recommendation.action,
|
||||
modeling_result_status,
|
||||
verification_result_status,
|
||||
reorient_result_status,
|
||||
};
|
||||
let coordinator = map_epiphany_coordinator(
|
||||
state_status,
|
||||
checkpoint_present,
|
||||
&pressure,
|
||||
&recommendation,
|
||||
&roles,
|
||||
&source_signals,
|
||||
modeling_result_accepted,
|
||||
modeling_result_reviewable,
|
||||
modeling_result_accepted_after_verification,
|
||||
implementation_evidence_after_verification,
|
||||
verification_result_cites_implementation_evidence,
|
||||
verification_result_covers_current_modeling,
|
||||
verification_result_accepted,
|
||||
verification_result_allows_implementation,
|
||||
verification_result_needs_evidence,
|
||||
reorient_finding_accepted,
|
||||
);
|
||||
let note = render_epiphany_coordinator_note(
|
||||
recommendation.action,
|
||||
pressure.level,
|
||||
modeling_result_status,
|
||||
verification_result_status,
|
||||
reorient_result_status,
|
||||
coordinator.action,
|
||||
);
|
||||
|
||||
let response = ThreadEpiphanyCoordinatorResponse {
|
||||
thread_id,
|
||||
source,
|
||||
state_status,
|
||||
state_revision,
|
||||
action: coordinator.action,
|
||||
target_role: coordinator.target_role,
|
||||
recommended_scene_action: coordinator.recommended_scene_action,
|
||||
requires_review: coordinator.requires_review,
|
||||
can_auto_run: coordinator.can_auto_run,
|
||||
reason: coordinator.reason,
|
||||
source_signals,
|
||||
roles,
|
||||
note,
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_role_launch(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
|
|
@ -5949,282 +5664,6 @@ impl CodexMessageProcessor {
|
|||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_pressure(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyPressureParams,
|
||||
) {
|
||||
let ThreadEpiphanyPressureParams { thread_id } = params;
|
||||
|
||||
let thread_uuid = match ThreadId::from_string(&thread_id) {
|
||||
Ok(id) => id,
|
||||
Err(err) => {
|
||||
self.send_invalid_request_error(request_id, format!("invalid thread id: {err}"))
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let loaded_thread = self.thread_manager.get_thread(thread_uuid).await.ok();
|
||||
let thread = match self.read_thread_view(thread_uuid, false).await {
|
||||
Ok(thread) => thread,
|
||||
Err(ThreadReadViewError::InvalidRequest(message)) => {
|
||||
self.send_invalid_request_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
Err(ThreadReadViewError::Internal(message)) => {
|
||||
self.send_internal_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let (source, token_usage_info) = if let Some(loaded_thread) = loaded_thread {
|
||||
(
|
||||
ThreadEpiphanyPressureSource::Live,
|
||||
loaded_thread.token_usage_info().await,
|
||||
)
|
||||
} else {
|
||||
let token_usage_info = match thread.path.as_deref() {
|
||||
Some(path) => latest_token_usage_info_from_rollout_path(path).await,
|
||||
None => None,
|
||||
};
|
||||
(ThreadEpiphanyPressureSource::Stored, token_usage_info)
|
||||
};
|
||||
|
||||
let response = ThreadEpiphanyPressureResponse {
|
||||
thread_id,
|
||||
source,
|
||||
pressure: map_epiphany_pressure(token_usage_info.as_ref()),
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_reorient(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyReorientParams,
|
||||
) {
|
||||
let ThreadEpiphanyReorientParams { thread_id } = params;
|
||||
|
||||
let thread_uuid = match ThreadId::from_string(&thread_id) {
|
||||
Ok(id) => id,
|
||||
Err(err) => {
|
||||
self.send_invalid_request_error(request_id, format!("invalid thread id: {err}"))
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let loaded_thread = self.thread_manager.get_thread(thread_uuid).await.ok();
|
||||
let thread = match self.read_thread_view(thread_uuid, false).await {
|
||||
Ok(thread) => thread,
|
||||
Err(ThreadReadViewError::InvalidRequest(message)) => {
|
||||
self.send_invalid_request_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
Err(ThreadReadViewError::Internal(message)) => {
|
||||
self.send_internal_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let retrieval_override = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_retrieval_state().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let watcher_snapshot = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
let config_snapshot = loaded_thread.config_snapshot().await;
|
||||
self.epiphany_invalidation_manager
|
||||
.ensure_thread_watch(&thread_id, &config_snapshot.cwd)
|
||||
.await;
|
||||
Some(
|
||||
self.epiphany_invalidation_manager
|
||||
.snapshot(&thread_id)
|
||||
.await,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (pressure_source, token_usage_info) = if let Some(loaded_thread) = loaded_thread {
|
||||
(
|
||||
ThreadEpiphanyReorientSource::Live,
|
||||
loaded_thread.token_usage_info().await,
|
||||
)
|
||||
} else {
|
||||
let token_usage_info = match thread.path.as_deref() {
|
||||
Some(path) => latest_token_usage_info_from_rollout_path(path).await,
|
||||
None => None,
|
||||
};
|
||||
(ThreadEpiphanyReorientSource::Stored, token_usage_info)
|
||||
};
|
||||
|
||||
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
|
||||
thread.epiphany_state.as_ref(),
|
||||
retrieval_override.as_ref(),
|
||||
watcher_snapshot.as_ref(),
|
||||
);
|
||||
let pressure = map_epiphany_pressure(token_usage_info.as_ref());
|
||||
let (state_status, decision) = map_epiphany_reorient(
|
||||
thread.epiphany_state.as_ref(),
|
||||
&pressure,
|
||||
&retrieval,
|
||||
&graph,
|
||||
&watcher,
|
||||
);
|
||||
let response = ThreadEpiphanyReorientResponse {
|
||||
thread_id,
|
||||
source: pressure_source,
|
||||
state_status,
|
||||
state_revision,
|
||||
decision,
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_crrc(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyCrrcParams,
|
||||
) {
|
||||
let ThreadEpiphanyCrrcParams { thread_id } = params;
|
||||
|
||||
let thread_uuid = match ThreadId::from_string(&thread_id) {
|
||||
Ok(id) => id,
|
||||
Err(err) => {
|
||||
self.send_invalid_request_error(request_id, format!("invalid thread id: {err}"))
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let loaded_thread = self.thread_manager.get_thread(thread_uuid).await.ok();
|
||||
let loaded = loaded_thread.is_some();
|
||||
let thread = match self.read_thread_view(thread_uuid, false).await {
|
||||
Ok(thread) => thread,
|
||||
Err(ThreadReadViewError::InvalidRequest(message)) => {
|
||||
self.send_invalid_request_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
Err(ThreadReadViewError::Internal(message)) => {
|
||||
self.send_internal_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let retrieval_override = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_retrieval_state().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let watcher_snapshot = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
let config_snapshot = loaded_thread.config_snapshot().await;
|
||||
self.epiphany_invalidation_manager
|
||||
.ensure_thread_watch(&thread_id, &config_snapshot.cwd)
|
||||
.await;
|
||||
Some(
|
||||
self.epiphany_invalidation_manager
|
||||
.snapshot(&thread_id)
|
||||
.await,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (source, token_usage_info) = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
(
|
||||
ThreadEpiphanyReorientSource::Live,
|
||||
loaded_thread.token_usage_info().await,
|
||||
)
|
||||
} else {
|
||||
let token_usage_info = match thread.path.as_deref() {
|
||||
Some(path) => latest_token_usage_info_from_rollout_path(path).await,
|
||||
None => None,
|
||||
};
|
||||
(ThreadEpiphanyReorientSource::Stored, token_usage_info)
|
||||
};
|
||||
|
||||
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
|
||||
thread.epiphany_state.as_ref(),
|
||||
retrieval_override.as_ref(),
|
||||
watcher_snapshot.as_ref(),
|
||||
);
|
||||
let pressure = map_epiphany_pressure(token_usage_info.as_ref());
|
||||
let (state_status, decision) = map_epiphany_reorient(
|
||||
thread.epiphany_state.as_ref(),
|
||||
&pressure,
|
||||
&retrieval,
|
||||
&graph,
|
||||
&watcher,
|
||||
);
|
||||
|
||||
let runtime_store_path = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_runtime_spine_store_path().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let jobs = map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref());
|
||||
let reorient_job = jobs
|
||||
.iter()
|
||||
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
|
||||
.cloned();
|
||||
let (result_status, finding, result_note) = load_epiphany_reorient_result_snapshot(
|
||||
thread.epiphany_state.as_ref(),
|
||||
runtime_store_path.as_deref(),
|
||||
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
|
||||
)
|
||||
.await;
|
||||
let available_actions = epiphany_scene_available_actions(
|
||||
loaded,
|
||||
thread.epiphany_state.is_some(),
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.and_then(|state| state.investigation_checkpoint.as_ref())
|
||||
.is_some(),
|
||||
reorient_job.is_some(),
|
||||
);
|
||||
let recommendation = map_epiphany_crrc_recommendation(
|
||||
loaded,
|
||||
state_status,
|
||||
&pressure,
|
||||
&decision,
|
||||
result_status,
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.and_then(|state| state.investigation_checkpoint.as_ref())
|
||||
.is_some(),
|
||||
finding.is_some(),
|
||||
finding.as_ref().is_some_and(|finding| {
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.is_some_and(|state| epiphany_reorient_finding_already_accepted(state, finding))
|
||||
}),
|
||||
);
|
||||
let note = format!(
|
||||
"{} Result status: {:?}. {}",
|
||||
recommendation.reason, result_status, result_note
|
||||
);
|
||||
|
||||
let response = ThreadEpiphanyCrrcResponse {
|
||||
thread_id,
|
||||
source,
|
||||
state_status,
|
||||
state_revision,
|
||||
pressure,
|
||||
decision,
|
||||
recommendation,
|
||||
reorient_binding_id: EPIPHANY_REORIENT_LAUNCH_BINDING_ID.to_string(),
|
||||
reorient_result_status: result_status,
|
||||
reorient_job,
|
||||
reorient_finding: finding,
|
||||
available_actions,
|
||||
note,
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_reorient_launch(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
|
|
|
|||
Reference in a new issue