Move result snapshot selection into core

This commit is contained in:
Meta Vens 2026-07-11 19:05:05 +01:00
commit 263ed87738
5 changed files with 113 additions and 56 deletions

View file

@ -39,30 +39,7 @@ pub async fn load_core_epiphany_role_result_snapshot(
role_id: EpiphanyRoleResultRoleId,
binding_id: &str,
) -> EpiphanyRoleResultSnapshot {
if let Some(link) = latest_epiphany_runtime_link_for_binding(state, binding_id) {
return load_core_epiphany_role_result_from_runtime_spine_job(
link.runtime_job_id.as_str(),
runtime_store_path,
role_id,
);
}
if !state
.job_bindings
.iter()
.any(|binding| binding.id == binding_id)
{
return EpiphanyRoleResultSnapshot {
status: CoreEpiphanyCoordinatorRoleResultStatus::MissingBinding,
finding: None,
note: "No matching Epiphany role specialist binding exists.".to_string(),
};
}
EpiphanyRoleResultSnapshot {
status: CoreEpiphanyCoordinatorRoleResultStatus::BackendUnavailable,
finding: None,
note: "Role binding has no runtime-spine job id; launch a runtime-linked role worker for typed results.".to_string(),
}
epiphany_core::read_role_result_snapshot(Some(state), runtime_store_path, role_id, binding_id)
}
pub fn load_completed_core_epiphany_role_finding(
@ -120,36 +97,7 @@ pub async fn load_core_epiphany_reorient_result_snapshot(
runtime_store_path: Option<&Path>,
binding_id: &str,
) -> EpiphanyReorientResultSnapshot {
let Some(state) = state else {
return EpiphanyReorientResultSnapshot {
status: CoreEpiphanyCrrcResultStatus::MissingState,
finding: None,
note: "No authoritative Epiphany state exists for this thread.".to_string(),
};
};
if let Some(link) = latest_epiphany_runtime_link_for_binding(state, binding_id) {
return load_core_epiphany_reorient_result_from_runtime_spine_job(
link.runtime_job_id.as_str(),
runtime_store_path,
);
}
if !state
.job_bindings
.iter()
.any(|binding| binding.id == binding_id)
{
return EpiphanyReorientResultSnapshot {
status: CoreEpiphanyCrrcResultStatus::MissingBinding,
finding: None,
note: "No matching Epiphany reorientation worker binding exists.".to_string(),
};
}
EpiphanyReorientResultSnapshot {
status: CoreEpiphanyCrrcResultStatus::BackendUnavailable,
finding: None,
note: "Reorientation binding has no runtime-spine job id; launch a runtime-linked reorient worker for typed results.".to_string(),
}
epiphany_core::read_reorient_result_snapshot(state, runtime_store_path, binding_id)
}
pub fn load_completed_core_epiphany_reorient_finding(

View file

@ -80,6 +80,32 @@ impl EpiphanyCoordinatorService {
load_thread_state(&self.thread_state_store)
}
pub fn role_result(
&self,
role_id: EpiphanyRoleResultRoleId,
binding_id: &str,
) -> Result<EpiphanyCoordinatorRoleResultSnapshot> {
let state = self.state()?;
Ok(read_role_result_snapshot(
state.as_ref(),
Some(&self.runtime_spine_store),
role_id,
binding_id,
))
}
pub fn reorient_result(
&self,
binding_id: &str,
) -> Result<EpiphanyCoordinatorReorientResultSnapshot> {
let state = self.state()?;
Ok(read_reorient_result_snapshot(
state.as_ref(),
Some(&self.runtime_spine_store),
binding_id,
))
}
pub fn apply_state_update(
&self,
thread_id: &str,
@ -101,6 +127,84 @@ impl EpiphanyCoordinatorService {
}
}
pub fn read_role_result_snapshot(
state: Option<&EpiphanyThreadState>,
runtime_store_path: Option<&Path>,
role_id: EpiphanyRoleResultRoleId,
binding_id: &str,
) -> EpiphanyCoordinatorRoleResultSnapshot {
let Some(state) = state else {
return role_snapshot(
role_id,
EpiphanyCoordinatorRoleResultStatus::MissingState,
None,
None,
);
};
if let Some(link) = latest_runtime_link(state, binding_id) {
return read_runtime_role_result(runtime_store_path, &link.runtime_job_id, role_id);
}
if state
.job_bindings
.iter()
.any(|binding| binding.id == binding_id)
{
role_snapshot(
role_id,
EpiphanyCoordinatorRoleResultStatus::BackendUnavailable,
None,
Some(
"Role binding has no runtime-spine job id; launch a runtime-linked role worker for typed results.",
),
)
} else {
role_snapshot(
role_id,
EpiphanyCoordinatorRoleResultStatus::MissingBinding,
None,
None,
)
}
}
pub fn read_reorient_result_snapshot(
state: Option<&EpiphanyThreadState>,
runtime_store_path: Option<&Path>,
binding_id: &str,
) -> EpiphanyCoordinatorReorientResultSnapshot {
let Some(state) = state else {
return reorient_snapshot(EpiphanyCrrcResultStatus::MissingState, None, None);
};
if let Some(link) = latest_runtime_link(state, binding_id) {
return read_runtime_reorient_result(runtime_store_path, &link.runtime_job_id);
}
if state
.job_bindings
.iter()
.any(|binding| binding.id == binding_id)
{
reorient_snapshot(
EpiphanyCrrcResultStatus::BackendUnavailable,
None,
Some(
"Reorientation binding has no runtime-spine job id; launch a runtime-linked reorient worker for typed results.",
),
)
} else {
reorient_snapshot(EpiphanyCrrcResultStatus::MissingBinding, None, None)
}
}
fn latest_runtime_link<'a>(
state: &'a EpiphanyThreadState,
binding_id: &str,
) -> Option<&'a epiphany_state_model::EpiphanyRuntimeLink> {
state
.runtime_links
.iter()
.find(|link| link.binding_id == binding_id && !link.runtime_job_id.trim().is_empty())
}
pub fn read_runtime_role_result(
runtime_store_path: Option<&Path>,
job_id: &str,

View file

@ -124,6 +124,8 @@ pub use coordinator_service::EpiphanyCoordinatorRoleResultSnapshot;
pub use coordinator_service::EpiphanyCoordinatorService;
pub use coordinator_service::EpiphanyCoordinatorStateApplied;
pub use coordinator_service::apply_coordinator_state_update_to_state;
pub use coordinator_service::read_reorient_result_snapshot;
pub use coordinator_service::read_role_result_snapshot;
pub use coordinator_service::read_runtime_reorient_result;
pub use coordinator_service::read_runtime_role_result;
pub use cultcache_rs::CacheBackingStore;

View file

@ -657,8 +657,11 @@ cancelled finding projection, and operator note rendering no longer belong to
`epiphany-codex-bridge::runtime_results`. The bridge retains compatibility type
aliases and delegates job readback to core. Native coordinator tests and all
eight bridge library tests pass, including typed-result enforcement and failed
lifecycle projection. Binding selection and acceptance choreography still live
in the bridge and remain the next extraction seam.
lifecycle projection. Binding selection for role/reorientation result readback
now also lives in core and the concrete service exposes `role_result` and
`reorient_result` over its canonical thread-state/runtime-spine stores. The
bridge delegates snapshot selection. Completed-finding acceptance choreography
and launch still live in the bridge and remain the next extraction seam.
Bridge identity correction from 2026-06-22: Epiphany owns swarm execution,
repo Body work, branch-local lanes, memory, evidence, and Persona cognition.

Binary file not shown.