Route coordinator from keyed current work

This commit is contained in:
Meta Vens 2026-08-18 04:18:02 +02:00
commit 1662a012c0
12 changed files with 1686 additions and 5175 deletions

File diff suppressed because it is too large Load diff

File diff suppressed because it is too large Load diff

View file

@ -16,6 +16,7 @@ pub const BODY_MODELING_LAUNCH_BINDING_SCHEMA_VERSION: &str =
"epiphany.runtime.body_modeling_launch.v1";
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyCurrentWorkProjection {
pub mind_projection_digest: String,
pub body_modeling: Option<EpiphanyBodyModelingWorkProjection>,
@ -26,6 +27,9 @@ pub struct EpiphanyCurrentWorkProjection {
pub frontier_verdict_modeling: Option<EpiphanyFrontierVerdictModelingWorkProjection>,
pub verification: Option<EpiphanyVerificationWorkProjection>,
pub reorientation: Option<crate::EpiphanyReorientationWorkProjection>,
pub imagination_considerations: Vec<EpiphanyImaginationConsiderationWorkProjection>,
pub admitted_model_direction_consideration:
Option<EpiphanyAdmittedModelDirectionConsiderationWorkProjection>,
pub hands_frontier_ready: bool,
}
@ -38,6 +42,7 @@ pub enum EpiphanyAgentPassContinuationAction {
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyProposalModelingWorkProjection {
pub request: RepoFrontierProposalModelingRequest,
pub action: EpiphanyAgentPassContinuationAction,
@ -45,6 +50,7 @@ pub struct EpiphanyProposalModelingWorkProjection {
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyFrontierVerdictModelingWorkProjection {
pub request: crate::RepoFrontierModelingRequest,
pub action: EpiphanyAgentPassContinuationAction,
@ -52,6 +58,7 @@ pub struct EpiphanyFrontierVerdictModelingWorkProjection {
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyVerificationWorkProjection {
pub request: crate::RepoFrontierVerificationRequest,
pub action: EpiphanyAgentPassContinuationAction,
@ -59,6 +66,23 @@ pub struct EpiphanyVerificationWorkProjection {
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyImaginationConsiderationWorkProjection {
pub request: crate::ImaginationConsiderationRequest,
pub action: EpiphanyAgentPassContinuationAction,
pub job_id: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyAdmittedModelDirectionConsiderationWorkProjection {
pub request: crate::AdmittedModelDirectionConsiderationRequest,
pub action: EpiphanyAgentPassContinuationAction,
pub job_id: Option<String>,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyBodyModelingWorkProjection {
pub work_id: String,
pub runtime_id: String,
@ -330,6 +354,15 @@ pub fn project_current_work(store_path: impl AsRef<Path>) -> Result<EpiphanyCurr
));
}
};
let (imagination_considerations, admitted_model_direction_consideration) =
if mind.repo_model.is_some() {
(
current_imagination_consideration_work(&cache)?,
current_admitted_model_direction_consideration_work(&cache)?,
)
} else {
(Vec::new(), None)
};
Ok(EpiphanyCurrentWorkProjection {
mind_projection_digest: mind.projection_digest,
body_modeling,
@ -341,10 +374,136 @@ pub fn project_current_work(store_path: impl AsRef<Path>) -> Result<EpiphanyCurr
frontier_verdict_modeling: current_frontier_verdict_modeling_work(&cache)?,
verification: current_verification_work(&cache)?,
reorientation: crate::reorientation_work::current_reorientation_work(&cache)?,
imagination_considerations,
admitted_model_direction_consideration,
hands_frontier_ready: crate::runtime_has_actionable_hands_frontier(store_path)?,
})
}
fn consideration_attempt_action(
cache: &CultCache,
job_ids: &[String],
) -> Result<(EpiphanyAgentPassContinuationAction, Option<String>)> {
let Some(job_id) = job_ids.last() else {
return Ok((EpiphanyAgentPassContinuationAction::Launch, None));
};
let job = cache
.get::<crate::EpiphanyRuntimeJob>(job_id)?
.ok_or_else(|| anyhow!("consideration launch lost its runtime job"))?;
let action = match job.status {
crate::EpiphanyRuntimeJobStatus::Failed | crate::EpiphanyRuntimeJobStatus::Cancelled => {
EpiphanyAgentPassContinuationAction::Launch
}
_ => EpiphanyAgentPassContinuationAction::Wait,
};
Ok((action, Some(job_id.clone())))
}
fn consideration_attempt_ordinal(request_id: &str, job_id: &str) -> Result<usize> {
let prefix = format!("consideration-{request_id}-attempt-");
job_id
.strip_prefix(&prefix)
.ok_or_else(|| anyhow!("consideration job identity is not canonical"))?
.parse::<usize>()
.map_err(|_| anyhow!("consideration attempt ordinal is invalid"))
}
fn current_imagination_consideration_work(
cache: &CultCache,
) -> Result<Vec<EpiphanyImaginationConsiderationWorkProjection>> {
let model_basis =
crate::repo_model_documents::assemble_repo_model_view_from_cache(cache)?.reasoning_basis();
let candidates = cache.get_all::<crate::ImaginationConsiderationCandidate>()?;
let bindings = cache.get_all::<crate::ImaginationConsiderationLaunchBinding>()?;
let mut requests = cache.get_all::<crate::ImaginationConsiderationRequest>()?;
requests.sort_by(|left, right| left.request_id.cmp(&right.request_id));
let mut work = Vec::new();
for request in requests {
if request.model_projection_digest != model_basis.projection_digest
|| request.model_source_documents != model_basis.source_documents
|| candidates
.iter()
.any(|candidate| candidate.request_id == request.request_id)
{
continue;
}
crate::validate_current_imagination_consideration_request(cache, &request)?;
let mut launches = bindings
.iter()
.filter(|binding| binding.request_id == request.request_id)
.map(|binding| {
Ok((
consideration_attempt_ordinal(&request.request_id, &binding.job_id)?,
binding.job_id.clone(),
))
})
.collect::<Result<Vec<_>>>()?;
launches.sort_by_key(|(ordinal, _)| *ordinal);
let launches = launches
.into_iter()
.map(|(_, job_id)| job_id)
.collect::<Vec<_>>();
let (action, job_id) = consideration_attempt_action(cache, &launches)?;
work.push(EpiphanyImaginationConsiderationWorkProjection {
request,
action,
job_id,
});
}
Ok(work)
}
fn current_admitted_model_direction_consideration_work(
cache: &CultCache,
) -> Result<Option<EpiphanyAdmittedModelDirectionConsiderationWorkProjection>> {
let model_basis =
crate::repo_model_documents::assemble_repo_model_view_from_cache(cache)?.reasoning_basis();
let results = cache.get_all::<crate::AdmittedModelDirectionConsiderationResult>()?;
let launches = cache.get_all::<crate::EpiphanyRuntimeWorkerLaunchRequest>()?;
let mut requests = cache.get_all::<crate::AdmittedModelDirectionConsiderationRequest>()?;
requests.sort_by(|left, right| left.request_id.cmp(&right.request_id));
for request in requests.into_iter().rev() {
if request.model_projection_digest != model_basis.projection_digest
|| request.model_source_documents != model_basis.source_documents
|| results
.iter()
.any(|result| result.request_id == request.request_id && result.terminal)
{
continue;
}
crate::validate_current_admitted_model_direction_consideration_request(cache, &request)?;
let mut job_ids = launches
.iter()
.filter(|launch| {
launch
.admitted_model_direction_consideration_request_id
.as_deref()
== Some(request.request_id.as_str())
})
.map(|launch| {
Ok((
consideration_attempt_ordinal(&request.request_id, &launch.job_id)?,
launch.job_id.clone(),
))
})
.collect::<Result<Vec<_>>>()?;
job_ids.sort_by_key(|(ordinal, _)| *ordinal);
let job_ids = job_ids
.into_iter()
.map(|(_, job_id)| job_id)
.collect::<Vec<_>>();
let (action, job_id) = consideration_attempt_action(cache, &job_ids)?;
return Ok(Some(
EpiphanyAdmittedModelDirectionConsiderationWorkProjection {
request,
action,
job_id,
},
));
}
Ok(None)
}
fn verification_attempt_ordinal(request_id: &str, job_id: &str) -> Result<usize> {
let prefix = format!("frontier-verification-{request_id}-attempt-");
job_id
@ -666,6 +825,11 @@ pub fn current_body_modeling_review_job_id(store_path: impl AsRef<Path>) -> Resu
{
return Ok(None);
}
current_body_modeling_job_id(store_path)
}
pub fn current_body_modeling_job_id(store_path: impl AsRef<Path>) -> Result<Option<String>> {
let store_path = store_path.as_ref();
let mut cache = crate::runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
let work = current_body_modeling_work(store_path)?;
@ -2155,6 +2319,306 @@ pub(crate) fn commit_current_work_launch(
Ok(())
}
#[derive(Clone, Copy)]
enum ConsiderationLaunch<'a> {
PersonaFeedback(&'a crate::ImaginationConsiderationRequest),
AdmittedModelDirection(&'a crate::AdmittedModelDirectionConsiderationRequest),
}
impl ConsiderationLaunch<'_> {
fn request_id(&self) -> &str {
match self {
Self::PersonaFeedback(request) => &request.request_id,
Self::AdmittedModelDirection(request) => &request.request_id,
}
}
fn model_source_documents(&self) -> &[EpiphanyMindDocumentVersion] {
match self {
Self::PersonaFeedback(request) => &request.model_source_documents,
Self::AdmittedModelDirection(request) => &request.model_source_documents,
}
}
}
fn exact_mind_source_envelopes(
cache: &CultCache,
sources: &[EpiphanyMindDocumentVersion],
) -> Result<Vec<CultCacheEnvelope>> {
let snapshot = cache.snapshot_envelopes();
sources
.iter()
.map(|source| {
let envelope = snapshot
.iter()
.find(|envelope| {
envelope.r#type == source.document_type && envelope.key == source.document_key
})
.ok_or_else(|| anyhow!("consideration launch lost exact Mind source"))?;
if EpiphanyMindDocumentVersion::from_envelope("epiphany-mind", envelope)? != *source {
return Err(anyhow!("consideration launch Mind source changed"));
}
Ok(envelope.clone())
})
.collect()
}
fn launch_consideration_work(
store_path: &Path,
launch: ConsiderationLaunch<'_>,
created_at: &str,
) -> Result<String> {
chrono::DateTime::parse_from_rfc3339(created_at)
.map_err(|_| anyhow!("consideration launch time is invalid"))?;
let mut cache = crate::runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
let identity = cache
.get::<crate::EpiphanyRuntimeIdentity>(crate::RUNTIME_IDENTITY_KEY)?
.ok_or_else(|| anyhow!("consideration launch requires runtime identity"))?;
let model = crate::repo_model_documents::assemble_repo_model_view_from_cache(&cache)?;
let (attempt_ordinal, dynamic_prompt_context, imagination_context, direction_context) =
match launch {
ConsiderationLaunch::PersonaFeedback(request) => {
crate::validate_current_imagination_consideration_request(&cache, request)?;
let current = current_imagination_consideration_work(&cache)?
.into_iter()
.find(|work| work.request.request_id == request.request_id)
.ok_or_else(|| anyhow!("Persona feedback consideration is not current"))?;
if current.action != EpiphanyAgentPassContinuationAction::Launch {
return Err(anyhow!("Persona feedback consideration is not launchable"));
}
let ordinal = cache
.get_all::<crate::ImaginationConsiderationLaunchBinding>()?
.into_iter()
.filter(|binding| binding.request_id == request.request_id)
.count();
(
ordinal,
crate::render_imagination_consideration_prompt(request)?,
Some(crate::ImaginationConsiderationContextProjection::new(
request, &model,
)),
None,
)
}
ConsiderationLaunch::AdmittedModelDirection(request) => {
crate::validate_current_admitted_model_direction_consideration_request(
&cache, request,
)?;
let current = current_admitted_model_direction_consideration_work(&cache)?
.filter(|work| work.request.request_id == request.request_id)
.ok_or_else(|| {
anyhow!("admitted model direction consideration is not current")
})?;
if current.action != EpiphanyAgentPassContinuationAction::Launch {
return Err(anyhow!(
"admitted model direction consideration is not launchable"
));
}
let ordinal = cache
.get_all::<crate::EpiphanyRuntimeWorkerLaunchRequest>()?
.into_iter()
.filter(|worker| {
worker
.admitted_model_direction_consideration_request_id
.as_deref()
== Some(request.request_id.as_str())
})
.count();
(
ordinal,
crate::render_admitted_model_direction_consideration_prompt(request),
None,
Some(
crate::AdmittedModelDirectionConsiderationContextProjection::new(
request, &model,
),
),
)
}
};
let request_id = launch.request_id().to_string();
let job_id = format!("consideration-{request_id}-attempt-{attempt_ordinal}");
let launch_document =
crate::EpiphanyWorkerLaunchDocument::Role(crate::EpiphanyRoleWorkerLaunchDocument {
thread_id: job_id.clone(),
role_id: "imagination".into(),
state_revision: 0,
objective: None,
dynamic_prompt_context: Some(dynamic_prompt_context),
repository_body_observation_basis: None,
proposal_modeling_context: None,
frontier_verdict_modeling_context: None,
frontier_planning_context: None,
frontier_research_context: None,
frontier_verification_context: None,
frontier_plan_mind_context: None,
imagination_consideration_context: imagination_context,
admitted_model_direction_consideration_context: direction_context,
active_subgoal_id: None,
active_subgoals: Vec::new(),
active_graph_node_ids: Vec::new(),
investigation_checkpoint: None,
scratch: None,
invariants: Vec::new(),
graphs: None,
recent_evidence: Vec::new(),
recent_observations: Vec::new(),
graph_frontier: None,
graph_checkpoint: None,
planning: None,
churn: None,
});
let authority_scope = if matches!(launch, ConsiderationLaunch::PersonaFeedback(_)) {
"epiphany.imagination.persona_feedback_consideration.proposal_only"
} else {
"epiphany.imagination.admitted_model_direction_consideration.proposal_only"
}
.to_string();
let output_contract_id = launch_document.output_contract_id().to_string();
let is_feedback = matches!(launch, ConsiderationLaunch::PersonaFeedback(_));
let prepared = crate::prepare_runtime_spine_heartbeat_job(
&cache,
crate::RuntimeSpineHeartbeatJobOptions {
runtime_id: identity.runtime_id,
display_name: "Epiphany Local".into(),
session_id: crate::EPIPHANY_RUNTIME_ROOT_SESSION_ID.into(),
objective: "Consider one exact typed proposal-only obligation".into(),
coordinator_note: "Consideration current-work launch opened this attempt.".into(),
job_id: job_id.clone(),
role: crate::EPIPHANY_IMAGINATION_OWNER_ROLE.into(),
binding_id: crate::EPIPHANY_IMAGINATION_ROLE_BINDING_ID.into(),
authority_scope: authority_scope.clone(),
instruction: "Act as Epiphany Imagination for one exact proposal-only typed consideration pass and return only its dedicated terminal contract.".into(),
launch_document,
output_contract_id: output_contract_id.clone(),
organ_launch_contract: crate::default_launch_organ_contract(
&authority_scope,
"role",
&output_contract_id,
),
proposal_modeling_request_id: None,
frontier_planning_request_id: None,
frontier_plan_mind_request_id: None,
imagination_consideration_request_id: is_feedback.then_some(request_id.clone()),
admitted_model_direction_consideration_request_id: (!is_feedback)
.then_some(request_id.clone()),
repo_frontier_modeling_request_id: None,
repo_frontier_research_request_id: None,
repo_frontier_verification_request_id: None,
created_at: created_at.into(),
},
)?;
let mut expected = vec![
cache
.snapshot_envelopes()
.into_iter()
.find(|envelope| {
envelope.key == request_id && {
matches!(
launch,
ConsiderationLaunch::PersonaFeedback(_)
if envelope.r#type == crate::ImaginationConsiderationRequest::TYPE
) || matches!(
launch,
ConsiderationLaunch::AdmittedModelDirection(_)
if envelope.r#type
== crate::AdmittedModelDirectionConsiderationRequest::TYPE
)
}
})
.ok_or_else(|| anyhow!("consideration launch lost its request envelope"))?,
];
expected.extend(exact_mind_source_envelopes(
&cache,
launch.model_source_documents(),
)?);
let mut companions = Vec::new();
if let ConsiderationLaunch::PersonaFeedback(request) = launch {
let worker = prepared
.envelopes
.iter()
.find(|envelope| {
envelope.r#type == crate::EpiphanyRuntimeWorkerLaunchRequest::TYPE
&& envelope.key == job_id
})
.ok_or_else(|| anyhow!("consideration launch preparation lost its worker"))?;
let worker: crate::EpiphanyRuntimeWorkerLaunchRequest =
rmp_serde::from_slice(&worker.payload)?;
let binding_record_id = format!(
"imagination-consideration-launch-{}-attempt-{attempt_ordinal}",
request.request_id
);
companions.push(
cache
.prepare_entry(
&binding_record_id,
&crate::ImaginationConsiderationLaunchBinding {
schema_version:
crate::IMAGINATION_CONSIDERATION_LAUNCH_BINDING_SCHEMA_VERSION.into(),
binding_record_id: binding_record_id.clone(),
request_id: request.request_id.clone(),
job_id: job_id.clone(),
binding_id: crate::EPIPHANY_IMAGINATION_ROLE_BINDING_ID.into(),
runtime_id: request.runtime_id.clone(),
thread_id: request.thread_id.clone(),
launched_at: created_at.into(),
worker_launch_document_sha256: format!(
"{:x}",
Sha256::digest(&worker.launch_document_msgpack)
),
},
)?
.0,
);
}
commit_current_work_launch(
store_path,
&cache,
expected,
prepared.envelopes,
companions,
"consideration",
)?;
Ok(job_id)
}
pub fn launch_current_imagination_consideration_work(
store_path: impl AsRef<Path>,
request_id: &str,
created_at: &str,
) -> Result<String> {
let store_path = store_path.as_ref();
let mut cache = crate::runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
let request = cache
.get::<crate::ImaginationConsiderationRequest>(request_id)?
.ok_or_else(|| anyhow!("Persona feedback consideration request does not exist"))?;
launch_consideration_work(
store_path,
ConsiderationLaunch::PersonaFeedback(&request),
created_at,
)
}
pub fn launch_current_admitted_model_direction_consideration_work(
store_path: impl AsRef<Path>,
request_id: &str,
created_at: &str,
) -> Result<String> {
let store_path = store_path.as_ref();
let mut cache = crate::runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
let request = cache
.get::<crate::AdmittedModelDirectionConsiderationRequest>(request_id)?
.ok_or_else(|| anyhow!("admitted model direction request does not exist"))?;
launch_consideration_work(
store_path,
ConsiderationLaunch::AdmittedModelDirection(&request),
created_at,
)
}
pub fn launch_current_body_modeling_work(
store_path: impl AsRef<Path>,
options: EpiphanyBodyModelingLaunchOptions,

View file

@ -1216,14 +1216,11 @@ pub use surfaces::EpiphanyCoordinatorAction;
pub use surfaces::EpiphanyCoordinatorAutomationAction;
pub use surfaces::EpiphanyCoordinatorCrrcRecommendation;
pub use surfaces::EpiphanyCoordinatorDecision;
pub use surfaces::EpiphanyCoordinatorFindingSignals;
pub use surfaces::EpiphanyCoordinatorInput;
pub use surfaces::EpiphanyCoordinatorRoleId;
pub use surfaces::EpiphanyCoordinatorRoleLane;
pub use surfaces::EpiphanyCoordinatorRoleResultStatus;
pub use surfaces::EpiphanyCoordinatorRoleStatus;
pub use surfaces::EpiphanyCoordinatorSceneAction;
pub use surfaces::EpiphanyCoordinatorSignals;
pub use surfaces::EpiphanyCoordinatorSourceSignals;
pub use surfaces::EpiphanyCoordinatorStatus;
pub use surfaces::EpiphanyCoordinatorStatusInput;
@ -1266,12 +1263,10 @@ pub use surfaces::EpiphanyReorientWorkerLaunchDocument;
pub use surfaces::EpiphanyRetrievalFreshness;
pub use surfaces::EpiphanyRetrievalFreshnessStatus;
pub use surfaces::EpiphanyRoleAcceptanceFinding;
pub use surfaces::EpiphanyRoleBoardCheckpointSummary;
pub use surfaces::EpiphanyRoleBoardInput;
pub use surfaces::EpiphanyRoleBoardJob;
pub use surfaces::EpiphanyRoleBoardJobStatus;
pub use surfaces::EpiphanyRoleBoardLane;
pub use surfaces::EpiphanyRoleBoardPlanningSummary;
pub use surfaces::EpiphanyRoleFindingInterpretation;
pub use surfaces::EpiphanyRoleResultRoleId;
pub use surfaces::EpiphanyRoleSelfPersistenceReview;
@ -1333,7 +1328,6 @@ pub use surfaces::interpret_runtime_role_worker_result;
pub use surfaces::modeling_role_state_patch_policy_errors;
pub use surfaces::recommend_crrc_action;
pub use surfaces::render_role_board_note;
pub use surfaces::reorientation_role_status;
pub use surfaces::research_role_state_patch_policy_errors;
pub use surfaces::review_role_self_patch_document;
pub use surfaces::role_board_job_status_to_role_status;

View file

@ -4982,10 +4982,12 @@ pub fn put_runtime_role_worker_result(
let bindings = cache
.get_all::<crate::ImaginationConsiderationLaunchBinding>()?
.into_iter()
.filter(|binding| binding.request_id == request_id)
.filter(|binding| binding.request_id == request_id && binding.job_id == result.job_id)
.collect::<Vec<_>>();
if bindings.len() != 1 {
return Err(anyhow!("consideration result requires one launch binding"));
return Err(anyhow!(
"consideration result requires one exact attempt binding"
));
}
let binding = &bindings[0];
let worker = cache

File diff suppressed because it is too large Load diff

View file

@ -1,15 +1,10 @@
use super::EpiphanyCrrcAction;
use super::EpiphanyCrrcRecommendation;
use super::EpiphanyCrrcResultStatus;
use super::EpiphanyCrrcStateStatus;
use super::EpiphanyPressure;
use super::EpiphanyPressureLevel;
use super::EpiphanyReorientAction;
use super::EpiphanyRoleBoardLane;
use crate::EpiphanyAgentPassContinuationAction;
use crate::RepoFrontierPlanningLifecycleStage;
use crate::RepoFrontierResearchContinuationAction;
use super::{
EpiphanyCrrcAction, EpiphanyCrrcResultStatus, EpiphanyPressure, EpiphanyPressureLevel,
EpiphanyReorientAction, EpiphanyRoleBoardLane,
};
use crate::EpiphanyCurrentWorkProjection;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum EpiphanyCoordinatorRoleId {
@ -74,6 +69,10 @@ pub enum EpiphanyCoordinatorAction {
WaitForMindPlanResult,
CommitFrontierPlanDecision,
ReviewFrontierPlanningFailure,
LaunchImaginationConsideration,
WaitForImaginationConsideration,
LaunchAdmittedModelDirectionConsideration,
WaitForAdmittedModelDirectionConsideration,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@ -103,78 +102,12 @@ pub struct EpiphanyCoordinatorCrrcRecommendation {
pub recommended_scene_action: Option<EpiphanyCoordinatorSceneAction>,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyCoordinatorSignals {
pub research_result_status: EpiphanyCoordinatorRoleResultStatus,
pub modeling_result_status: EpiphanyCoordinatorRoleResultStatus,
pub verification_result_status: EpiphanyCoordinatorRoleResultStatus,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyCoordinatorSourceSignals {
pub pressure_level: EpiphanyPressureLevel,
pub should_prepare_compaction: bool,
pub reorient_action: EpiphanyReorientAction,
pub crrc_action: EpiphanyCrrcAction,
pub research_result_status: EpiphanyCoordinatorRoleResultStatus,
pub modeling_result_status: EpiphanyCoordinatorRoleResultStatus,
pub verification_result_status: EpiphanyCoordinatorRoleResultStatus,
pub reorient_result_status: EpiphanyCrrcResultStatus,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyCoordinatorRoleLane {
pub id: EpiphanyCoordinatorRoleId,
pub status: EpiphanyCoordinatorRoleStatus,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyCoordinatorInput {
pub state_status: EpiphanyCrrcStateStatus,
pub checkpoint_present: bool,
pub mind_present: bool,
pub should_prepare_compaction: bool,
pub recommendation: EpiphanyCoordinatorCrrcRecommendation,
pub roles: Vec<EpiphanyCoordinatorRoleLane>,
pub signals: EpiphanyCoordinatorSignals,
pub research_result_accepted: bool,
pub research_result_reviewable: bool,
pub research_result_failure_reviewed: bool,
pub modeling_result_accepted_after_research: bool,
pub modeling_result_requests_regather: bool,
pub modeling_result_accepted: bool,
pub modeling_result_reviewable: bool,
pub modeling_result_failure_reviewed: bool,
pub modeling_result_proposal_bound: bool,
pub modeling_result_accepted_after_verification: bool,
pub implementation_evidence_after_verification: bool,
pub verification_result_cites_implementation_evidence: bool,
pub verification_result_covers_current_modeling: bool,
pub verification_result_accepted: bool,
pub verification_result_failure_reviewed: bool,
pub verification_result_allows_implementation: bool,
pub verification_result_needs_evidence: bool,
pub reorient_finding_accepted: bool,
/// True only when the canonical runtime RepoModel has exactly one current
/// admission and an Active, dependency-ready Hands frontier item.
pub hands_frontier_ready: bool,
/// Exact next action projected by the current frontier Research lifecycle.
/// Legacy role-lane status remains observable but cannot override it.
pub research_continuation_action: Option<RepoFrontierResearchContinuationAction>,
/// Read-only projection of the single typed Imagination -> Mind planning
/// lifecycle. Self may advance it, but only Mind's result can decide adoption.
pub frontier_planning_stage: RepoFrontierPlanningLifecycleStage,
/// Exact current action for the oldest unresolved proposal Modeling request.
pub proposal_modeling_action: Option<EpiphanyAgentPassContinuationAction>,
/// Exact current action for one Soul-verdict-bound Modeling request.
pub frontier_verdict_modeling_action: Option<EpiphanyAgentPassContinuationAction>,
/// Exact current action for one Hands-consequence-bound Verification request.
/// Role lanes, timestamps, and latest-result slots are display-only.
pub verification_action: Option<EpiphanyAgentPassContinuationAction>,
pub body_modeling_work_ready: bool,
pub body_modeling_review_ready: bool,
pub current_work: EpiphanyCurrentWorkProjection,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@ -190,42 +123,23 @@ pub struct EpiphanyCoordinatorDecision {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyCoordinatorStatusInput {
pub state_status: EpiphanyCrrcStateStatus,
pub checkpoint_present: bool,
pub mind_present: bool,
pub pressure: EpiphanyPressure,
pub recommendation: EpiphanyCrrcRecommendation,
pub recommendation: crate::EpiphanyCrrcRecommendation,
pub roles: Vec<EpiphanyRoleBoardLane>,
pub reorient_action: EpiphanyReorientAction,
pub research_result_status: EpiphanyCoordinatorRoleResultStatus,
pub modeling_result_status: EpiphanyCoordinatorRoleResultStatus,
pub verification_result_status: EpiphanyCoordinatorRoleResultStatus,
pub reorient_result_status: EpiphanyCrrcResultStatus,
pub research_result_accepted: bool,
pub research_result_reviewable: bool,
pub research_result_failure_reviewed: bool,
pub modeling_result_accepted_after_research: bool,
pub modeling_result_requests_regather: bool,
pub modeling_result_accepted: bool,
pub modeling_result_reviewable: bool,
pub modeling_result_failure_reviewed: bool,
pub modeling_result_proposal_bound: bool,
pub modeling_result_accepted_after_verification: bool,
pub implementation_evidence_after_verification: bool,
pub verification_result_cites_implementation_evidence: bool,
pub verification_result_covers_current_modeling: bool,
pub verification_result_accepted: bool,
pub verification_result_failure_reviewed: bool,
pub verification_result_allows_implementation: bool,
pub verification_result_needs_evidence: bool,
pub reorient_finding_accepted: bool,
pub hands_frontier_ready: bool,
pub research_continuation_action: Option<RepoFrontierResearchContinuationAction>,
pub frontier_planning_stage: RepoFrontierPlanningLifecycleStage,
pub proposal_modeling_action: Option<EpiphanyAgentPassContinuationAction>,
pub frontier_verdict_modeling_action: Option<EpiphanyAgentPassContinuationAction>,
pub verification_action: Option<EpiphanyAgentPassContinuationAction>,
pub body_modeling_work_ready: bool,
pub body_modeling_review_ready: bool,
pub current_work: EpiphanyCurrentWorkProjection,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyCoordinatorSourceSignals {
pub pressure_level: EpiphanyPressureLevel,
pub should_prepare_compaction: bool,
pub reorient_action: EpiphanyReorientAction,
pub crrc_action: EpiphanyCrrcAction,
pub reorient_result_status: EpiphanyCrrcResultStatus,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@ -235,25 +149,3 @@ pub struct EpiphanyCoordinatorStatus {
pub source_signals: EpiphanyCoordinatorSourceSignals,
pub roles: Vec<EpiphanyRoleBoardLane>,
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct EpiphanyCoordinatorFindingSignals {
pub research_result_accepted: bool,
pub research_result_reviewable: bool,
pub research_result_failure_reviewed: bool,
pub modeling_result_accepted_after_research: bool,
pub modeling_result_requests_regather: bool,
pub modeling_result_accepted: bool,
pub modeling_result_reviewable: bool,
pub modeling_result_failure_reviewed: bool,
pub modeling_result_proposal_bound: bool,
pub modeling_result_accepted_after_verification: bool,
pub implementation_evidence_after_verification: bool,
pub verification_result_cites_implementation_evidence: bool,
pub verification_result_covers_current_modeling: bool,
pub verification_result_accepted: bool,
pub verification_result_failure_reviewed: bool,
pub verification_result_allows_implementation: bool,
pub verification_result_needs_evidence: bool,
pub reorient_finding_accepted: bool,
}

View file

@ -1,12 +1,5 @@
use super::freshness::graph_freshness;
use epiphany_state_model::EpiphanyJobBinding;
use epiphany_state_model::EpiphanyJobKind;
use epiphany_state_model::EpiphanyRetrievalState;
use epiphany_state_model::EpiphanyRetrievalStatus;
use epiphany_state_model::EpiphanyRuntimeLink;
use epiphany_state_model::EpiphanyThreadState;
use serde::Deserialize;
use serde::Serialize;
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
@ -54,310 +47,157 @@ pub struct EpiphanyJobView {
#[derive(Debug, Clone, Copy)]
pub struct EpiphanyJobsInput<'a> {
pub state: Option<&'a EpiphanyThreadState>,
pub retrieval_override: Option<&'a EpiphanyRetrievalState>,
pub mind: Option<&'a crate::EpiphanyMindView>,
}
pub fn derive_jobs(input: EpiphanyJobsInput<'_>) -> Vec<EpiphanyJobView> {
let mut jobs = vec![
index_job(input.state, input.retrieval_override),
remap_job(input.state),
verification_job(input.state),
];
let Some(state) = input.state else {
return jobs;
};
for binding in &state.job_bindings {
let runtime_link = latest_runtime_link_for_binding(state, binding.id.as_str());
let replacement = if let Some(existing) = jobs.iter().find(|job| job.id == binding.id) {
overlay_job_binding(existing.clone(), binding, runtime_link)
} else {
bound_job(binding, runtime_link)
};
if let Some(existing) = jobs.iter_mut().find(|job| job.id == binding.id) {
*existing = replacement;
} else {
jobs.push(replacement);
}
}
jobs
vec![
body_observation_job(input.mind),
repo_model_job(input.mind),
verification_job(input.mind),
]
}
fn bound_job(
binding: &EpiphanyJobBinding,
runtime_link: Option<&EpiphanyRuntimeLink>,
) -> EpiphanyJobView {
overlay_job_binding(
EpiphanyJobView {
id: binding.id.clone(),
kind: binding.kind,
scope: binding.scope.clone(),
owner_role: binding.owner_role.clone(),
authority_scope: binding.authority_scope.clone(),
runtime_job_id: runtime_link.map(|link| link.runtime_job_id.clone()),
status: if binding.blocking_reason.is_some() {
EpiphanyJobStatus::Blocked
} else {
EpiphanyJobStatus::Idle
},
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: binding.linked_subgoal_ids.clone(),
linked_graph_node_ids: binding.linked_graph_node_ids.clone(),
},
binding,
runtime_link,
)
}
fn overlay_job_binding(
mut job: EpiphanyJobView,
binding: &EpiphanyJobBinding,
runtime_link: Option<&EpiphanyRuntimeLink>,
) -> EpiphanyJobView {
job.kind = binding.kind;
job.scope = binding.scope.clone();
job.owner_role = binding.owner_role.clone();
job.authority_scope = binding.authority_scope.clone();
job.runtime_job_id = runtime_link.map(|link| link.runtime_job_id.clone());
if !binding.linked_subgoal_ids.is_empty() {
job.linked_subgoal_ids = binding.linked_subgoal_ids.clone();
}
if !binding.linked_graph_node_ids.is_empty() {
job.linked_graph_node_ids = binding.linked_graph_node_ids.clone();
}
if let Some(blocking_reason) = binding.blocking_reason.clone() {
job.blocking_reason = Some(blocking_reason);
}
if binding.blocking_reason.is_some() {
job.status = EpiphanyJobStatus::Blocked;
return job;
}
if runtime_link.is_some_and(|link| link.runtime_result_id.is_none()) {
job.status = EpiphanyJobStatus::Pending;
job.blocking_reason = None;
job.progress_note =
Some("Queued for Epiphany heartbeat activation through runtime_links.".to_string());
return job;
}
if runtime_link.is_some() {
job.status = EpiphanyJobStatus::Completed;
job.blocking_reason = None;
job.progress_note =
Some("Epiphany heartbeat runtime result is ready for review.".to_string());
return job;
}
job
}
fn index_job(
state: Option<&EpiphanyThreadState>,
retrieval_override: Option<&EpiphanyRetrievalState>,
) -> EpiphanyJobView {
let retrieval = state
.and_then(|state| state.retrieval.as_ref())
.or(retrieval_override);
let linked_subgoal_ids = active_subgoal_ids(state);
let linked_graph_node_ids = active_graph_node_ids(state);
let Some(retrieval) = retrieval else {
return EpiphanyJobView {
id: "retrieval-index".to_string(),
kind: EpiphanyJobKind::Indexing,
scope: "workspace".to_string(),
owner_role: "epiphany-core".to_string(),
authority_scope: None,
runtime_job_id: None,
status: EpiphanyJobStatus::Unavailable,
items_processed: None,
items_total: None,
progress_note: None,
last_checkpoint_at_unix_seconds: None,
blocking_reason: Some("Retrieval state is unavailable for this thread.".to_string()),
active_thread_ids: Vec::new(),
linked_subgoal_ids,
linked_graph_node_ids,
};
};
let dirty_path_count = retrieval.dirty_paths.len();
let progress_note = match retrieval.status {
EpiphanyRetrievalStatus::Ready if dirty_path_count == 0 => {
"Retrieval catalog is ready.".to_string()
}
EpiphanyRetrievalStatus::Ready => {
format!("Retrieval catalog is ready with {dirty_path_count} dirty path(s) noted.")
}
EpiphanyRetrievalStatus::Stale => {
format!("Retrieval catalog is stale; {dirty_path_count} dirty path(s) need refresh.")
}
EpiphanyRetrievalStatus::Indexing => "Retrieval catalog is indexing.".to_string(),
EpiphanyRetrievalStatus::Unavailable => "Retrieval catalog is unavailable.".to_string(),
};
EpiphanyJobView {
id: "retrieval-index".to_string(),
kind: EpiphanyJobKind::Indexing,
scope: retrieval.workspace_root.display().to_string(),
owner_role: "unowned-legacy-projection".to_string(),
authority_scope: None,
runtime_job_id: None,
status: job_status_from_retrieval_status(retrieval.status),
items_processed: retrieval.indexed_file_count,
items_total: None,
progress_note: Some(progress_note),
last_checkpoint_at_unix_seconds: retrieval.last_indexed_at_unix_seconds,
blocking_reason: matches!(
retrieval.status,
EpiphanyRetrievalStatus::Ready | EpiphanyRetrievalStatus::Unavailable
)
.then(|| {
"No Body-bound workspace coverage owner is installed; legacy retrieval state cannot authorize readiness.".to_string()
}),
active_thread_ids: Vec::new(),
linked_subgoal_ids,
linked_graph_node_ids,
}
}
fn job_status_from_retrieval_status(status: EpiphanyRetrievalStatus) -> EpiphanyJobStatus {
match status {
EpiphanyRetrievalStatus::Ready => EpiphanyJobStatus::Unavailable,
EpiphanyRetrievalStatus::Stale => EpiphanyJobStatus::Needed,
EpiphanyRetrievalStatus::Indexing => EpiphanyJobStatus::Running,
EpiphanyRetrievalStatus::Unavailable => EpiphanyJobStatus::Unavailable,
}
}
fn remap_job(state: Option<&EpiphanyThreadState>) -> EpiphanyJobView {
let Some(state) = state else {
return blocked_state_job(
"graph-remap",
EpiphanyJobKind::Remap,
"architecture/dataflow graphs",
"Epiphany state is missing, so there is no graph to remap.",
);
};
let freshness = graph_freshness(Some(state));
// The legacy thread projection has no Body-generation witness and therefore
// cannot authorize a completed remap. Canonical readiness belongs to the
// future joined RepoModel/Body/retrieval authority.
EpiphanyJobView {
id: "graph-remap".to_string(),
kind: EpiphanyJobKind::Remap,
scope: "architecture/dataflow graphs".to_string(),
owner_role: "epiphany-core".to_string(),
authority_scope: None,
runtime_job_id: None,
status: EpiphanyJobStatus::Needed,
items_processed: None,
items_total: None,
progress_note: Some(freshness.note),
last_checkpoint_at_unix_seconds: None,
blocking_reason: None,
active_thread_ids: Vec::new(),
linked_subgoal_ids: active_subgoal_ids(Some(state)),
linked_graph_node_ids: active_graph_node_ids(Some(state)),
}
}
fn verification_job(state: Option<&EpiphanyThreadState>) -> EpiphanyJobView {
let Some(state) = state else {
return blocked_state_job(
"verification",
EpiphanyJobKind::Verification,
"invariants/evidence",
"Epiphany state is missing, so there are no invariants to verify.",
);
};
let total = state.invariants.len() as u32;
let verified = state
.invariants
.iter()
.filter(|invariant| invariant_status_is_accepting(&invariant.status))
.count() as u32;
let status = if total > 0 && verified < total {
EpiphanyJobStatus::Needed
} else {
EpiphanyJobStatus::Idle
};
let progress_note = if total == 0 {
"No invariants are recorded yet.".to_string()
} else if verified == total {
format!("All {total} invariant(s) are currently accepting.")
} else {
format!("{verified} of {total} invariant(s) are currently accepting.")
};
EpiphanyJobView {
id: "verification".to_string(),
kind: EpiphanyJobKind::Verification,
scope: "invariants/evidence".to_string(),
owner_role: "epiphany-harness".to_string(),
authority_scope: None,
runtime_job_id: None,
status,
items_processed: Some(verified),
items_total: Some(total),
progress_note: Some(progress_note),
last_checkpoint_at_unix_seconds: None,
blocking_reason: None,
active_thread_ids: Vec::new(),
linked_subgoal_ids: active_subgoal_ids(Some(state)),
linked_graph_node_ids: active_graph_node_ids(Some(state)),
}
}
fn blocked_state_job(
fn base_job(
id: &str,
kind: EpiphanyJobKind,
scope: &str,
blocking_reason: &str,
owner_role: &str,
status: EpiphanyJobStatus,
) -> EpiphanyJobView {
EpiphanyJobView {
id: id.to_string(),
id: id.into(),
kind,
scope: scope.to_string(),
owner_role: "epiphany-harness".to_string(),
scope: scope.into(),
owner_role: owner_role.into(),
authority_scope: None,
runtime_job_id: None,
status: EpiphanyJobStatus::Blocked,
status,
items_processed: None,
items_total: None,
progress_note: None,
last_checkpoint_at_unix_seconds: None,
blocking_reason: Some(blocking_reason.to_string()),
blocking_reason: None,
active_thread_ids: Vec::new(),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
}
}
fn active_subgoal_ids(state: Option<&EpiphanyThreadState>) -> Vec<String> {
state
.and_then(|state| state.active_subgoal_id.clone())
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<String> {
mind.and_then(|mind| mind.active_subgoal_id.clone())
.map(|id| vec![id])
.unwrap_or_default()
}
fn active_graph_node_ids(state: Option<&EpiphanyThreadState>) -> Vec<String> {
state
.and_then(|state| state.graph_frontier.as_ref())
.map(|frontier| frontier.active_node_ids.clone())
.unwrap_or_default()
fn active_graph_node_ids(mind: Option<&crate::EpiphanyMindView>) -> Vec<String> {
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::<Vec<_>>();
ids.sort();
ids.dedup();
ids
}
fn invariant_status_is_accepting(status: &str) -> bool {
@ -367,222 +207,32 @@ fn invariant_status_is_accepting(status: &str) -> bool {
)
}
fn latest_runtime_link_for_binding<'a>(
state: &'a EpiphanyThreadState,
binding_id: &str,
) -> Option<&'a EpiphanyRuntimeLink> {
state
.runtime_links
.iter()
.find(|link| link.binding_id == binding_id && !link.runtime_job_id.trim().is_empty())
}
#[cfg(test)]
mod tests {
use super::*;
use epiphany_state_model::EpiphanyChurnState;
use epiphany_state_model::EpiphanyGraphCheckpoint;
use epiphany_state_model::EpiphanyGraphFrontier;
use epiphany_state_model::EpiphanyInvariant;
use std::path::PathBuf;
#[test]
fn derives_builtin_jobs_without_state() {
let jobs = derive_jobs(EpiphanyJobsInput {
state: None,
retrieval_override: None,
});
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].id, "retrieval-index");
assert_eq!(jobs[0].status, EpiphanyJobStatus::Unavailable);
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()));
}
#[test]
fn reflects_retrieval_and_graph_pressure() {
let state = EpiphanyThreadState {
active_subgoal_id: Some("subgoal-1".to_string()),
retrieval: Some(EpiphanyRetrievalState {
workspace_root: PathBuf::from("E:/repo"),
status: EpiphanyRetrievalStatus::Stale,
dirty_paths: vec![PathBuf::from("src/lib.rs")],
indexed_file_count: Some(7),
..Default::default()
}),
graph_frontier: Some(EpiphanyGraphFrontier {
active_node_ids: vec!["node-1".to_string()],
dirty_paths: vec![PathBuf::from("src/lib.rs")],
open_question_ids: vec!["q-1".to_string()],
..Default::default()
}),
invariants: vec![
EpiphanyInvariant {
id: "inv-1".to_string(),
description: "verified".to_string(),
status: "verified".to_string(),
rationale: None,
},
EpiphanyInvariant {
id: "inv-2".to_string(),
description: "pending".to_string(),
status: "pending".to_string(),
rationale: None,
},
],
..Default::default()
};
let jobs = derive_jobs(EpiphanyJobsInput {
state: Some(&state),
retrieval_override: None,
});
let retrieval = jobs.iter().find(|job| job.id == "retrieval-index").unwrap();
assert_eq!(retrieval.status, EpiphanyJobStatus::Needed);
assert_eq!(retrieval.items_processed, Some(7));
assert_eq!(retrieval.linked_subgoal_ids, vec!["subgoal-1".to_string()]);
let remap = jobs.iter().find(|job| job.id == "graph-remap").unwrap();
assert_eq!(remap.status, EpiphanyJobStatus::Needed);
assert_eq!(remap.linked_graph_node_ids, vec!["node-1".to_string()]);
let verification = jobs.iter().find(|job| job.id == "verification").unwrap();
assert_eq!(verification.status, EpiphanyJobStatus::Needed);
assert_eq!(verification.items_processed, Some(1));
assert_eq!(verification.items_total, Some(2));
}
#[test]
fn remap_job_refuses_legacy_graph_readiness_authority() {
let incomplete = EpiphanyThreadState::default();
let jobs = derive_jobs(EpiphanyJobsInput {
state: Some(&incomplete),
retrieval_override: None,
});
assert_eq!(
jobs.iter()
.find(|job| job.id == "graph-remap")
.unwrap()
.status,
EpiphanyJobStatus::Needed
);
let forged_legacy_ready = EpiphanyThreadState {
graph_checkpoint: Some(EpiphanyGraphCheckpoint {
checkpoint_id: "graph-1".to_string(),
..Default::default()
}),
churn: Some(EpiphanyChurnState {
..Default::default()
}),
..Default::default()
};
let jobs = derive_jobs(EpiphanyJobsInput {
state: Some(&forged_legacy_ready),
retrieval_override: None,
});
assert_eq!(
jobs.iter()
.find(|job| job.id == "graph-remap")
.unwrap()
.status,
EpiphanyJobStatus::Needed
);
}
#[test]
fn overlays_binding_with_runtime_link() {
let state = EpiphanyThreadState {
job_bindings: vec![EpiphanyJobBinding {
id: "binding-1".to_string(),
kind: EpiphanyJobKind::Specialist,
scope: "modeling".to_string(),
owner_role: "body".to_string(),
authority_scope: Some("epiphany.role.modeling".to_string()),
linked_subgoal_ids: vec!["subgoal-1".to_string()],
linked_graph_node_ids: vec!["node-1".to_string()],
blocking_reason: None,
}],
runtime_links: vec![EpiphanyRuntimeLink {
id: "link-1".to_string(),
binding_id: "binding-1".to_string(),
surface: "role".to_string(),
role_id: "modeling".to_string(),
authority_scope: "epiphany.role.modeling".to_string(),
runtime_job_id: "runtime-job-1".to_string(),
runtime_result_id: None,
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
}],
..Default::default()
};
let jobs = derive_jobs(EpiphanyJobsInput {
state: Some(&state),
retrieval_override: None,
});
let binding = jobs.iter().find(|job| job.id == "binding-1").unwrap();
assert_eq!(binding.status, EpiphanyJobStatus::Pending);
assert_eq!(binding.runtime_job_id.as_deref(), Some("runtime-job-1"));
assert_eq!(
binding.progress_note.as_deref(),
Some("Queued for Epiphany heartbeat activation through runtime_links.")
);
}
#[test]
fn terminal_runtime_link_owns_binding_over_stale_active_history() {
let state = EpiphanyThreadState {
job_bindings: vec![EpiphanyJobBinding {
id: "binding-1".to_string(),
kind: EpiphanyJobKind::Specialist,
scope: "modeling".to_string(),
owner_role: "body".to_string(),
authority_scope: Some("epiphany.role.modeling".to_string()),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
blocking_reason: None,
}],
runtime_links: vec![
EpiphanyRuntimeLink {
id: "link-terminal".to_string(),
binding_id: "binding-1".to_string(),
surface: "runtimeResult".to_string(),
role_id: "modeling".to_string(),
authority_scope: "epiphany.role.modeling".to_string(),
runtime_job_id: "runtime-job-1".to_string(),
runtime_result_id: Some("result-1".to_string()),
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
},
EpiphanyRuntimeLink {
id: "link-stale-active".to_string(),
binding_id: "binding-1".to_string(),
surface: "jobLaunch".to_string(),
role_id: "modeling".to_string(),
authority_scope: "epiphany.role.modeling".to_string(),
runtime_job_id: "runtime-job-1".to_string(),
runtime_result_id: None,
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
},
],
..Default::default()
};
let jobs = derive_jobs(EpiphanyJobsInput {
state: Some(&state),
retrieval_override: None,
});
let binding = jobs.iter().find(|job| job.id == "binding-1").unwrap();
assert_eq!(binding.status, EpiphanyJobStatus::Completed);
assert_eq!(
binding.progress_note.as_deref(),
Some("Epiphany heartbeat runtime result is ready for review.")
);
fn source_contains_no_aggregate_job_or_runtime_link_owner() {
let source = include_str!("jobs.rs");
let production = source.split("#[cfg(test)]").next().unwrap_or(source);
for forbidden in [
"EpiphanyThreadState",
"EpiphanyJobBinding",
"EpiphanyRuntimeLink",
"latest_runtime_link",
"state_revision",
] {
assert!(!production.contains(forbidden));
}
}
}

View file

@ -61,15 +61,12 @@ pub use pressure::EpiphanyPressureStatus;
pub use pressure::EpiphanyTokenUsageSnapshot;
pub use pressure::derive_pressure_view;
pub use reorient::EpiphanyReorientAction;
pub use role_board::EpiphanyRoleBoardCheckpointSummary;
pub use role_board::EpiphanyRoleBoardInput;
pub use role_board::EpiphanyRoleBoardJob;
pub use role_board::EpiphanyRoleBoardJobStatus;
pub use role_board::EpiphanyRoleBoardLane;
pub use role_board::EpiphanyRoleBoardPlanningSummary;
pub use role_board::derive_role_board;
pub use role_board::render_role_board_note;
pub use role_board::reorientation_role_status;
pub use role_board::role_board_job_status_to_role_status;
pub use role_result::EpiphanyAcceptanceBundle;
pub use role_result::EpiphanyReorientAcceptanceBundle;

View file

@ -1,5 +1,4 @@
use epiphany_state_model::EpiphanyPlanningState;
use epiphany_state_model::EpiphanyThreadState;
use serde::Deserialize;
use serde::Serialize;
@ -29,16 +28,16 @@ pub struct EpiphanyPlanningSummary {
#[serde(rename_all = "camelCase")]
pub struct EpiphanyPlanningView {
pub state_status: EpiphanyPlanningStateStatus,
pub state_revision: Option<u64>,
pub projection_digest: Option<String>,
pub planning: EpiphanyPlanningState,
pub summary: EpiphanyPlanningSummary,
}
pub fn derive_planning_view(state: Option<&EpiphanyThreadState>) -> EpiphanyPlanningView {
let Some(state) = state else {
pub fn derive_planning_view(mind: Option<&crate::EpiphanyMindView>) -> EpiphanyPlanningView {
let Some(mind) = mind else {
return EpiphanyPlanningView {
state_status: EpiphanyPlanningStateStatus::Missing,
state_revision: None,
projection_digest: None,
planning: EpiphanyPlanningState::default(),
summary: EpiphanyPlanningSummary {
capture_count: 0,
@ -55,7 +54,7 @@ pub fn derive_planning_view(state: Option<&EpiphanyThreadState>) -> EpiphanyPlan
};
};
let planning = state.planning.clone();
let planning = mind.planning.clone();
let pending_capture_count = planning
.captures
.iter()
@ -85,7 +84,7 @@ pub fn derive_planning_view(state: Option<&EpiphanyThreadState>) -> EpiphanyPlan
EpiphanyPlanningView {
state_status: EpiphanyPlanningStateStatus::Ready,
state_revision: Some(state.revision),
projection_digest: Some(mind.projection_digest.clone()),
planning: planning.clone(),
summary: EpiphanyPlanningSummary {
capture_count: planning.captures.len() as u32,
@ -96,7 +95,7 @@ pub fn derive_planning_view(state: Option<&EpiphanyThreadState>) -> EpiphanyPlan
roadmap_stream_count: planning.roadmap_streams.len() as u32,
objective_draft_count: planning.objective_drafts.len() as u32,
draft_objective_count,
active_objective: state.objective.clone(),
active_objective: mind.objective.clone(),
note,
},
}
@ -113,16 +112,29 @@ mod tests {
let view = derive_planning_view(None);
assert_eq!(view.state_status, EpiphanyPlanningStateStatus::Missing);
assert_eq!(view.state_revision, None);
assert_eq!(view.projection_digest, None);
assert_eq!(view.summary.capture_count, 0);
assert!(view.planning.is_empty());
}
#[test]
fn summarizes_planning_counts_without_adopting_objective() {
let state = EpiphanyThreadState {
revision: 3,
let mind = crate::EpiphanyMindView {
schema_epoch: crate::MIND_SCHEMA_EPOCH.into(),
runtime_id: "runtime-1".into(),
projection_digest: "sha256:mind-3".into(),
source_documents: Vec::new(),
objective: Some("active objective".to_string()),
active_subgoal_id: None,
subgoals: Vec::new(),
invariants: Vec::new(),
observations: Vec::new(),
evidence: Vec::new(),
verification_audits: Vec::new(),
reorientation_decisions: Vec::new(),
reorientation_failures: Vec::new(),
investigation_checkpoint: None,
mode: None,
planning: EpiphanyPlanningState {
captures: vec![
EpiphanyPlanningCapture {
@ -151,13 +163,14 @@ mod tests {
],
..Default::default()
},
..Default::default()
repository_body_observation: None,
repo_model: None,
};
let view = derive_planning_view(Some(&state));
let view = derive_planning_view(Some(&mind));
assert_eq!(view.state_status, EpiphanyPlanningStateStatus::Ready);
assert_eq!(view.state_revision, Some(3));
assert_eq!(view.projection_digest.as_deref(), Some("sha256:mind-3"));
assert_eq!(view.summary.capture_count, 2);
assert_eq!(view.summary.pending_capture_count, 1);
assert_eq!(view.summary.github_issue_capture_count, 1);

View file

@ -1,8 +1,10 @@
use super::EpiphanyCoordinatorRoleId;
use super::EpiphanyCoordinatorRoleStatus;
use super::EpiphanyCoordinatorSceneAction;
use super::EpiphanyCrrcAction;
use super::EpiphanyCrrcResultStatus;
use super::{
EpiphanyCoordinatorRoleId, EpiphanyCoordinatorRoleStatus, EpiphanyCoordinatorSceneAction,
};
use crate::{
EpiphanyAgentPassContinuationAction, EpiphanyCurrentWorkProjection,
RepoFrontierPlanningLifecycleStage, RepoFrontierResearchContinuationAction,
};
use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
@ -29,44 +31,11 @@ pub struct EpiphanyRoleBoardJob {
pub blocking_reason: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyRoleBoardPlanningSummary {
pub capture_count: usize,
pub backlog_item_count: usize,
pub roadmap_stream_count: usize,
pub objective_draft_count: usize,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyRoleBoardCheckpointSummary {
pub disposition: Option<String>,
pub next_action: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyRoleBoardInput {
pub state_present: bool,
pub planning: EpiphanyRoleBoardPlanningSummary,
pub checkpoint: Option<EpiphanyRoleBoardCheckpointSummary>,
pub reorient_next_action: String,
pub mind_present: bool,
pub current_work: EpiphanyCurrentWorkProjection,
pub jobs: Vec<EpiphanyRoleBoardJob>,
pub crrc_action: EpiphanyCrrcAction,
pub crrc_recommended_scene_action: Option<EpiphanyCoordinatorSceneAction>,
pub crrc_reason: String,
pub reorient_decision_action: String,
pub pressure_level: String,
pub reorient_result_status: EpiphanyCrrcResultStatus,
pub reorient_job: Option<EpiphanyRoleBoardJob>,
pub imagination_binding_id: String,
pub research_binding_id: String,
pub modeling_binding_id: String,
pub verification_binding_id: String,
pub reorient_owner_role: String,
pub imagination_owner_role: String,
pub research_owner_role: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@ -83,228 +52,228 @@ pub struct EpiphanyRoleBoardLane {
}
pub fn derive_role_board(input: EpiphanyRoleBoardInput) -> Vec<EpiphanyRoleBoardLane> {
let state_present = input.state_present;
let checkpoint_present = input.checkpoint.is_some();
let imagination_jobs = input
.jobs
.iter()
.filter(|job| job.id == input.imagination_binding_id)
.cloned()
.collect::<Vec<_>>();
let imagination_bound_job = imagination_jobs
.iter()
.find(|job| job.id == input.imagination_binding_id);
let imagination_has_bound_job = imagination_bound_job.is_some();
let imagination_status = imagination_bound_job
.map(|job| role_board_job_status_to_role_status(job.status))
.unwrap_or_else(|| imagination_role_status(state_present, &input.planning));
let imagination_note = imagination_bound_job
.and_then(job_note)
.unwrap_or_else(|| render_imagination_role_note(state_present, &input.planning));
let imagination_recommended_action = if imagination_has_bound_job {
Some(EpiphanyCoordinatorSceneAction::RoleResult)
} else if state_present {
Some(EpiphanyCoordinatorSceneAction::RoleLaunch)
} else {
Some(EpiphanyCoordinatorSceneAction::Update)
};
let missing = !input.mind_present;
let lane =
|id, title: &str, owner_role: &str, status, note: &str, scope: &str, recommended_action| {
EpiphanyRoleBoardLane {
id,
title: title.into(),
owner_role: owner_role.into(),
status: if missing {
EpiphanyCoordinatorRoleStatus::Blocked
} else {
status
},
note: if missing {
"Canonical keyed Mind is missing.".into()
} else {
note.into()
},
jobs: input
.jobs
.iter()
.filter(|job| job.owner_role == owner_role)
.cloned()
.collect(),
authority_scopes: vec![scope.into()],
recommended_action,
}
};
let modeling_jobs = input
.jobs
.iter()
.filter(|job| job.id == input.modeling_binding_id || job.id == "graph-remap")
.cloned()
.collect::<Vec<_>>();
let modeling_bound_job = modeling_jobs
.iter()
.find(|job| job.id == input.modeling_binding_id);
let modeling_has_bound_job = modeling_bound_job.is_some();
let modeling_status = modeling_role_status(
checkpoint_present,
modeling_bound_job.or_else(|| modeling_jobs.first()),
);
let modeling_recommended_action = if modeling_has_bound_job {
Some(EpiphanyCoordinatorSceneAction::RoleResult)
} else if state_present {
Some(EpiphanyCoordinatorSceneAction::RoleLaunch)
} else {
Some(EpiphanyCoordinatorSceneAction::Update)
};
let research_jobs = input
.jobs
.iter()
.filter(|job| job.id == input.research_binding_id)
.cloned()
.collect::<Vec<_>>();
let research_bound_job = research_jobs
.iter()
.find(|job| job.id == input.research_binding_id);
let research_has_bound_job = research_bound_job.is_some();
let research_status = research_bound_job
.map(|job| role_board_job_status_to_role_status(job.status))
.unwrap_or(if state_present {
EpiphanyCoordinatorRoleStatus::Ready
} else {
EpiphanyCoordinatorRoleStatus::Blocked
});
let research_note = research_bound_job.and_then(job_note).unwrap_or_else(|| {
"Gather citable source evidence before Modeling models from it.".to_string()
});
let research_recommended_action = if research_has_bound_job {
Some(EpiphanyCoordinatorSceneAction::RoleResult)
} else if state_present {
Some(EpiphanyCoordinatorSceneAction::RoleLaunch)
} else {
Some(EpiphanyCoordinatorSceneAction::Update)
};
let verification_jobs = input
.jobs
.iter()
.filter(|job| job.id == input.verification_binding_id || job.id == "verification")
.cloned()
.collect::<Vec<_>>();
let verification_bound_job = verification_jobs
.iter()
.find(|job| job.id == input.verification_binding_id);
let verification_has_bound_job = verification_bound_job.is_some();
let verification_primary_job = verification_bound_job.or_else(|| verification_jobs.first());
let verification_status = verification_primary_job
.map(|job| role_board_job_status_to_role_status(job.status))
.unwrap_or(EpiphanyCoordinatorRoleStatus::Unavailable);
let verification_note = verification_primary_job
.and_then(job_note)
.unwrap_or_else(|| {
"Review evidence, worker findings, and verifier results before promotion.".to_string()
});
let verification_recommended_action = if verification_has_bound_job {
Some(EpiphanyCoordinatorSceneAction::RoleResult)
} else if state_present {
Some(EpiphanyCoordinatorSceneAction::RoleLaunch)
} else {
None
};
let reorientation_jobs = input.reorient_job.clone().into_iter().collect::<Vec<_>>();
let modeling_action = input
.current_work
.proposal_modeling
.as_ref()
.map(|work| work.action)
.or(input.current_work.body_modeling_action)
.or(input
.current_work
.frontier_verdict_modeling
.as_ref()
.map(|work| work.action));
let imagination_action = consideration_action(&input.current_work);
vec![
EpiphanyRoleBoardLane {
id: EpiphanyCoordinatorRoleId::Implementation,
title: "Implementation".to_string(),
owner_role: "coding-agent".to_string(),
status: if input.crrc_action == EpiphanyCrrcAction::Continue {
lane(
EpiphanyCoordinatorRoleId::Implementation,
"Hands / Implementation",
"epiphany-hands",
if input.current_work.hands_frontier_ready {
EpiphanyCoordinatorRoleStatus::Ready
} else {
EpiphanyCoordinatorRoleStatus::Blocked
},
note: if input.crrc_action == EpiphanyCrrcAction::Continue {
"Continue the bounded coding task.".to_string()
if input.current_work.hands_frontier_ready {
"An adopted plan has an exact actionable Hands route."
} else {
format!("Wait for CRRC action: {:?}.", input.crrc_action)
"No exact actionable Hands route exists."
},
jobs: input
.jobs
.iter()
.filter(|job| {
matches!(
job.owner_role.as_str(),
"coding-agent" | "implementation" | "epiphany-implementation"
)
})
.cloned()
.collect(),
authority_scopes: Vec::new(),
recommended_action: if input.crrc_action == EpiphanyCrrcAction::Continue {
None
} else {
input.crrc_recommended_scene_action
},
},
EpiphanyRoleBoardLane {
id: EpiphanyCoordinatorRoleId::Imagination,
title: "Imagination / Planning".to_string(),
owner_role: input.imagination_owner_role,
status: imagination_status,
note: imagination_note,
jobs: imagination_jobs,
authority_scopes: vec![
"epiphany.coordinator.role.launch".to_string(),
"epiphany.coordinator.role.result.read".to_string(),
"epiphany.coordinator.role.accept".to_string(),
"epiphany.coordinator.state.update".to_string(),
],
recommended_action: imagination_recommended_action,
},
EpiphanyRoleBoardLane {
id: EpiphanyCoordinatorRoleId::Research,
title: "Eyes / Research".to_string(),
owner_role: input.research_owner_role,
status: research_status,
note: research_note,
jobs: research_jobs,
authority_scopes: vec![
"epiphany.coordinator.role.launch".to_string(),
"epiphany.coordinator.role.result.read".to_string(),
"epiphany.coordinator.role.accept".to_string(),
"epiphany.coordinator.state.update".to_string(),
],
recommended_action: research_recommended_action,
},
EpiphanyRoleBoardLane {
id: EpiphanyCoordinatorRoleId::Modeling,
title: "Modeling / Checkpoint".to_string(),
owner_role: "epiphany-modeler".to_string(),
status: modeling_status,
note: render_modeling_role_note(input.checkpoint.as_ref(), &input.reorient_next_action),
jobs: modeling_jobs,
authority_scopes: vec![
"epiphany.coordinator.role.launch".to_string(),
"epiphany.coordinator.role.result.read".to_string(),
"epiphany.coordinator.role.accept".to_string(),
"epiphany.coordinator.state.update".to_string(),
],
recommended_action: modeling_recommended_action,
},
EpiphanyRoleBoardLane {
id: EpiphanyCoordinatorRoleId::Verification,
title: "Verification / Review".to_string(),
owner_role: "epiphany-verifier".to_string(),
status: verification_status,
note: verification_note,
jobs: verification_jobs,
authority_scopes: vec![
"epiphany.coordinator.role.launch".to_string(),
"epiphany.coordinator.role.result.read".to_string(),
"epiphany.coordinator.role.accept".to_string(),
"epiphany.mind.distill".to_string(),
"epiphany.mind.propose".to_string(),
"epiphany.mind.promote".to_string(),
],
recommended_action: verification_recommended_action,
},
EpiphanyRoleBoardLane {
id: EpiphanyCoordinatorRoleId::Reorientation,
title: "Reorientation".to_string(),
owner_role: input.reorient_owner_role,
status: reorientation_role_status(input.crrc_action, input.reorient_result_status),
note: format!(
"{} verdict, result {:?}, pressure {}. {}",
input.reorient_decision_action,
input.reorient_result_status,
input.pressure_level,
input.crrc_reason
"epiphany.hands.route",
None,
),
lane(
EpiphanyCoordinatorRoleId::Imagination,
"Imagination / Planning",
"epiphany-imagination",
planning_or_consideration_status(
input.current_work.frontier_planning_stage,
imagination_action,
),
jobs: reorientation_jobs,
authority_scopes: vec![
"epiphany.coordinator.reorient.launch".to_string(),
"epiphany.coordinator.reorient.result.read".to_string(),
"epiphany.coordinator.reorient.accept".to_string(),
],
recommended_action: input.crrc_recommended_scene_action,
},
"Status derives from exact planning and consideration obligations.",
"epiphany.imagination.current_work",
action_scene(imagination_action),
),
lane(
EpiphanyCoordinatorRoleId::Research,
"Eyes / Research",
"epiphany-eyes",
research_status(input.current_work.research_continuation_action),
"Eyes runs only for an explicit external-evidence obligation.",
"epiphany.eyes.current_work",
input
.current_work
.research_continuation_action
.map(|action| match action {
RepoFrontierResearchContinuationAction::LaunchResearch => {
EpiphanyCoordinatorSceneAction::RoleLaunch
}
RepoFrontierResearchContinuationAction::ReviewResearchResult => {
EpiphanyCoordinatorSceneAction::RoleResult
}
}),
),
lane(
EpiphanyCoordinatorRoleId::Modeling,
"Modeling / Body Map",
"epiphany-modeling",
continuation_status(modeling_action),
"Status derives from exact Body, proposal, or Soul-verdict Modeling work.",
"epiphany.modeling.current_work",
action_scene(modeling_action),
),
lane(
EpiphanyCoordinatorRoleId::Verification,
"Soul / Verification",
"epiphany-soul",
continuation_status(
input
.current_work
.verification
.as_ref()
.map(|work| work.action),
),
"Verification consumes exact Hands consequences and invariant obligations.",
"epiphany.soul.current_work",
action_scene(
input
.current_work
.verification
.as_ref()
.map(|work| work.action),
),
),
lane(
EpiphanyCoordinatorRoleId::Reorientation,
"Continuity / Reorientation",
"epiphany-continuity",
continuation_status(
input
.current_work
.reorientation
.as_ref()
.map(|work| work.action),
),
"Status derives from the exact keyed continuity obligation.",
"epiphany.continuity.current_work",
action_scene(
input
.current_work
.reorientation
.as_ref()
.map(|work| work.action),
),
),
]
}
fn consideration_action(
work: &EpiphanyCurrentWorkProjection,
) -> Option<EpiphanyAgentPassContinuationAction> {
work.imagination_considerations
.first()
.map(|item| item.action)
.or(work
.admitted_model_direction_consideration
.as_ref()
.map(|item| item.action))
}
fn continuation_status(
action: Option<EpiphanyAgentPassContinuationAction>,
) -> EpiphanyCoordinatorRoleStatus {
match action {
Some(EpiphanyAgentPassContinuationAction::Launch) => EpiphanyCoordinatorRoleStatus::Needed,
Some(EpiphanyAgentPassContinuationAction::Wait) => EpiphanyCoordinatorRoleStatus::Running,
Some(EpiphanyAgentPassContinuationAction::Review) => EpiphanyCoordinatorRoleStatus::Review,
None => EpiphanyCoordinatorRoleStatus::Ready,
}
}
fn action_scene(
action: Option<EpiphanyAgentPassContinuationAction>,
) -> Option<EpiphanyCoordinatorSceneAction> {
match action {
Some(EpiphanyAgentPassContinuationAction::Launch) => {
Some(EpiphanyCoordinatorSceneAction::RoleLaunch)
}
Some(EpiphanyAgentPassContinuationAction::Wait)
| Some(EpiphanyAgentPassContinuationAction::Review) => {
Some(EpiphanyCoordinatorSceneAction::RoleResult)
}
None => None,
}
}
fn research_status(
action: Option<RepoFrontierResearchContinuationAction>,
) -> EpiphanyCoordinatorRoleStatus {
match action {
Some(RepoFrontierResearchContinuationAction::LaunchResearch) => {
EpiphanyCoordinatorRoleStatus::Needed
}
Some(RepoFrontierResearchContinuationAction::ReviewResearchResult) => {
EpiphanyCoordinatorRoleStatus::Review
}
None => EpiphanyCoordinatorRoleStatus::Ready,
}
}
fn planning_or_consideration_status(
stage: RepoFrontierPlanningLifecycleStage,
consideration: Option<EpiphanyAgentPassContinuationAction>,
) -> EpiphanyCoordinatorRoleStatus {
if !matches!(
stage,
RepoFrontierPlanningLifecycleStage::Unavailable
| RepoFrontierPlanningLifecycleStage::Terminal
) {
return match stage {
RepoFrontierPlanningLifecycleStage::ImaginationRunning
| RepoFrontierPlanningLifecycleStage::MindRunning => {
EpiphanyCoordinatorRoleStatus::Running
}
RepoFrontierPlanningLifecycleStage::ImaginationFailed
| RepoFrontierPlanningLifecycleStage::MindFailed
| RepoFrontierPlanningLifecycleStage::ImaginationResultReady
| RepoFrontierPlanningLifecycleStage::MindResultReady => {
EpiphanyCoordinatorRoleStatus::Review
}
_ => EpiphanyCoordinatorRoleStatus::Needed,
};
}
continuation_status(consideration)
}
pub fn role_board_job_status_to_role_status(
status: EpiphanyRoleBoardJobStatus,
) -> EpiphanyCoordinatorRoleStatus {
@ -322,243 +291,39 @@ pub fn role_board_job_status_to_role_status(
}
}
pub fn reorientation_role_status(
action: EpiphanyCrrcAction,
result_status: EpiphanyCrrcResultStatus,
) -> EpiphanyCoordinatorRoleStatus {
match result_status {
EpiphanyCrrcResultStatus::Pending | EpiphanyCrrcResultStatus::Running => {
return EpiphanyCoordinatorRoleStatus::Waiting;
}
EpiphanyCrrcResultStatus::Failed
| EpiphanyCrrcResultStatus::Cancelled
| EpiphanyCrrcResultStatus::BackendUnavailable
| EpiphanyCrrcResultStatus::BackendMissing => {
return EpiphanyCoordinatorRoleStatus::Blocked;
}
_ => {}
}
match action {
EpiphanyCrrcAction::Continue => EpiphanyCoordinatorRoleStatus::Ready,
EpiphanyCrrcAction::PrepareCheckpoint
| EpiphanyCrrcAction::LaunchReorientWorker
| EpiphanyCrrcAction::RegatherManually => EpiphanyCoordinatorRoleStatus::Needed,
EpiphanyCrrcAction::WaitForReorientWorker => EpiphanyCoordinatorRoleStatus::Waiting,
EpiphanyCrrcAction::ReviewReorientResult | EpiphanyCrrcAction::AcceptReorientResult => {
EpiphanyCoordinatorRoleStatus::Review
}
}
}
pub fn render_role_board_note(
roles: &[EpiphanyRoleBoardLane],
state_status: &str,
recommendation: EpiphanyCrrcAction,
recommendation: crate::EpiphanyCrrcAction,
) -> String {
let blocked_count = roles
let active = roles
.iter()
.filter(|role| {
matches!(
role.status,
EpiphanyCoordinatorRoleStatus::Blocked | EpiphanyCoordinatorRoleStatus::Needed
.filter(|lane| {
!matches!(
lane.status,
EpiphanyCoordinatorRoleStatus::Ready | EpiphanyCoordinatorRoleStatus::Completed
)
})
.count();
format!(
"Role ownership is derived read-only from Epiphany state, jobs, and CRRC. State: {state_status}; recommendation: {recommendation:?}; blocked-or-needed lanes: {blocked_count}.",
"Mind {state_status}; {active} role lane(s) carry current work; continuity recommendation {recommendation:?}."
)
}
fn imagination_role_status(
state_present: bool,
planning: &EpiphanyRoleBoardPlanningSummary,
) -> EpiphanyCoordinatorRoleStatus {
if !state_present {
return EpiphanyCoordinatorRoleStatus::Blocked;
}
if planning.capture_count == 0
&& planning.backlog_item_count == 0
&& planning.roadmap_stream_count == 0
&& planning.objective_draft_count == 0
{
EpiphanyCoordinatorRoleStatus::Needed
} else {
EpiphanyCoordinatorRoleStatus::Ready
}
}
fn render_imagination_role_note(
state_present: bool,
planning: &EpiphanyRoleBoardPlanningSummary,
) -> String {
if !state_present {
return "No authoritative Epiphany state exists for planning synthesis.".to_string();
}
if planning.capture_count == 0
&& planning.backlog_item_count == 0
&& planning.roadmap_stream_count == 0
&& planning.objective_draft_count == 0
{
return "Planning substrate is empty; capture or import backlog material before synthesis."
.to_string();
}
format!(
"Planning material ready: {} captures, {} backlog items, {} roadmap streams, {} objective drafts.",
planning.capture_count,
planning.backlog_item_count,
planning.roadmap_stream_count,
planning.objective_draft_count
)
}
fn modeling_role_status(
checkpoint_present: bool,
graph_remap_job: Option<&EpiphanyRoleBoardJob>,
) -> EpiphanyCoordinatorRoleStatus {
if let Some(job) = graph_remap_job
&& matches!(
job.status,
EpiphanyRoleBoardJobStatus::Pending | EpiphanyRoleBoardJobStatus::Running
)
{
return EpiphanyCoordinatorRoleStatus::Running;
}
if checkpoint_present {
EpiphanyCoordinatorRoleStatus::Ready
} else {
EpiphanyCoordinatorRoleStatus::Needed
}
}
fn render_modeling_role_note(
checkpoint: Option<&EpiphanyRoleBoardCheckpointSummary>,
reorient_next_action: &str,
) -> String {
let Some(checkpoint) = checkpoint else {
return format!("Checkpoint missing: {reorient_next_action}");
};
let next_action = checkpoint
.next_action
.as_deref()
.unwrap_or(reorient_next_action);
let disposition = checkpoint.disposition.as_deref().unwrap_or("unknown");
format!("{disposition}: {next_action}")
}
fn job_note(job: &EpiphanyRoleBoardJob) -> Option<String> {
job.blocking_reason
.clone()
.or_else(|| job.progress_note.clone())
}
#[cfg(test)]
mod tests {
use super::*;
fn input() -> EpiphanyRoleBoardInput {
EpiphanyRoleBoardInput {
state_present: true,
planning: EpiphanyRoleBoardPlanningSummary {
capture_count: 0,
backlog_item_count: 0,
roadmap_stream_count: 0,
objective_draft_count: 0,
},
checkpoint: Some(EpiphanyRoleBoardCheckpointSummary {
disposition: Some("resume_ready".to_string()),
next_action: Some("keep cutting".to_string()),
}),
reorient_next_action: "regather".to_string(),
jobs: Vec::new(),
crrc_action: EpiphanyCrrcAction::Continue,
crrc_recommended_scene_action: Some(EpiphanyCoordinatorSceneAction::Reorient),
crrc_reason: "continue".to_string(),
reorient_decision_action: "Resume".to_string(),
pressure_level: "Low".to_string(),
reorient_result_status: EpiphanyCrrcResultStatus::MissingBinding,
reorient_job: None,
imagination_binding_id: "imagination-synthesis-worker".to_string(),
research_binding_id: "research-source-gather-worker".to_string(),
modeling_binding_id: "modeling-checkpoint-worker".to_string(),
verification_binding_id: "verification-review-worker".to_string(),
reorient_owner_role: "epiphany-reorienter".to_string(),
imagination_owner_role: "epiphany-imagination".to_string(),
research_owner_role: "epiphany-eyes".to_string(),
}
}
#[test]
fn projects_mvp_lanes() {
let roles = derive_role_board(EpiphanyRoleBoardInput {
jobs: vec![EpiphanyRoleBoardJob {
id: "verification".to_string(),
owner_role: "epiphany-verifier".to_string(),
status: EpiphanyRoleBoardJobStatus::Needed,
progress_note: None,
blocking_reason: None,
}],
..input()
});
assert_eq!(roles.len(), 6);
assert_eq!(roles[0].id, EpiphanyCoordinatorRoleId::Implementation);
assert_eq!(roles[0].status, EpiphanyCoordinatorRoleStatus::Ready);
assert_eq!(roles[1].status, EpiphanyCoordinatorRoleStatus::Needed);
assert_eq!(roles[2].status, EpiphanyCoordinatorRoleStatus::Ready);
assert_eq!(roles[3].status, EpiphanyCoordinatorRoleStatus::Ready);
assert_eq!(roles[4].status, EpiphanyCoordinatorRoleStatus::Needed);
assert_eq!(roles[5].status, EpiphanyCoordinatorRoleStatus::Ready);
}
#[test]
fn blocks_implementation_when_crrc_blocks() {
let roles = derive_role_board(EpiphanyRoleBoardInput {
crrc_action: EpiphanyCrrcAction::LaunchReorientWorker,
crrc_recommended_scene_action: Some(EpiphanyCoordinatorSceneAction::ReorientLaunch),
..input()
});
assert_eq!(roles[0].status, EpiphanyCoordinatorRoleStatus::Blocked);
assert_eq!(
roles[0].recommended_action,
Some(EpiphanyCoordinatorSceneAction::ReorientLaunch)
);
}
#[test]
fn reorientation_waits_for_running_worker() {
assert_eq!(
reorientation_role_status(
EpiphanyCrrcAction::Continue,
EpiphanyCrrcResultStatus::Running
),
EpiphanyCoordinatorRoleStatus::Waiting
);
}
#[test]
fn authority_scopes_name_live_typed_capabilities() {
let roles = derive_role_board(input());
let scopes = roles
.iter()
.flat_map(|role| role.authority_scopes.iter())
.collect::<Vec<_>>();
assert!(!scopes.is_empty());
assert!(
scopes
.iter()
.all(|scope| scope.starts_with("epiphany.") && !scope.contains('/'))
);
for required in [
fn source_has_no_generic_lane_or_aggregate_authority() {
let source = include_str!("role_board.rs");
let production = source.split("#[cfg(test)]").next().unwrap_or(source);
for forbidden in [
"EpiphanyThreadState",
"binding_id",
"acceptance_receipt",
"state_revision",
"epiphany.coordinator.role.launch",
"epiphany.coordinator.role.result.read",
"epiphany.coordinator.role.accept",
"epiphany.coordinator.reorient.launch",
"epiphany.coordinator.reorient.result.read",
"epiphany.coordinator.reorient.accept",
] {
assert!(scopes.iter().any(|scope| scope.as_str() == required));
assert!(!production.contains(forbidden));
}
}
}

View file

@ -1,6 +1,6 @@
use epiphany_state_model::EpiphanyInvestigationDisposition;
use epiphany_state_model::EpiphanyRetrievalStatus;
use epiphany_state_model::EpiphanyThreadState;
use epiphany_state_model::{EpiphanyMemoryProfile, RepoFrontierStatus};
use serde::Deserialize;
use serde::Serialize;
use std::collections::BTreeMap;
@ -34,11 +34,6 @@ pub enum EpiphanySceneAction {
Jobs,
Roles,
Coordinator,
RoleLaunch,
RoleResult,
RoleAccept,
JobLaunch,
JobInterrupt,
Freshness,
Pressure,
Reorient,
@ -46,9 +41,6 @@ pub enum EpiphanySceneAction {
ReorientLaunch,
ReorientResult,
ReorientAccept,
Propose,
Promote,
Update,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@ -144,7 +136,7 @@ pub struct EpiphanySceneChurn {
pub struct EpiphanyScene {
pub state_status: EpiphanySceneStateStatus,
pub source: EpiphanySceneSource,
pub revision: Option<u64>,
pub projection_digest: Option<String>,
pub objective: Option<String>,
pub active_subgoal: Option<EpiphanySceneSubgoal>,
pub subgoals: Vec<EpiphanySceneSubgoal>,
@ -160,9 +152,9 @@ pub struct EpiphanyScene {
#[derive(Debug, Clone, Copy)]
pub struct EpiphanySceneInput<'a> {
pub state: Option<&'a EpiphanyThreadState>,
pub mind: Option<&'a crate::EpiphanyMindView>,
pub loaded: bool,
pub reorient_binding_id: &'a str,
pub reorientation_work_present: bool,
}
pub fn derive_scene(input: EpiphanySceneInput<'_>) -> EpiphanyScene {
@ -171,25 +163,19 @@ pub fn derive_scene(input: EpiphanySceneInput<'_>) -> EpiphanyScene {
} else {
EpiphanySceneSource::Stored
};
let state = input.state;
let mind = input.mind;
let available_actions = scene_available_actions(
input.loaded,
state.is_some(),
state
.and_then(|state| state.investigation_checkpoint.as_ref())
mind.is_some(),
mind.and_then(|mind| mind.investigation_checkpoint.as_ref())
.is_some(),
state.is_some_and(|state| {
state
.job_bindings
.iter()
.any(|binding| binding.id == input.reorient_binding_id)
}),
input.reorientation_work_present,
);
let Some(state) = state else {
let Some(mind) = mind else {
return EpiphanyScene {
state_status: EpiphanySceneStateStatus::Missing,
source,
revision: None,
projection_digest: None,
objective: None,
active_subgoal: None,
subgoals: Vec::new(),
@ -204,34 +190,22 @@ pub fn derive_scene(input: EpiphanySceneInput<'_>) -> EpiphanyScene {
};
};
let subgoals = scene_subgoals(state);
let subgoals = scene_subgoals(mind);
let active_subgoal = subgoals.iter().find(|subgoal| subgoal.active).cloned();
EpiphanyScene {
state_status: EpiphanySceneStateStatus::Ready,
source,
revision: Some(state.revision),
objective: state.objective.clone(),
projection_digest: Some(mind.projection_digest.clone()),
objective: mind.objective.clone(),
active_subgoal,
subgoals,
invariant_status_counts: status_counts(
state.invariants.iter().map(|item| item.status.as_str()),
mind.invariants.iter().map(|item| item.status.as_str()),
),
graph: scene_graph(state),
retrieval: state
.retrieval
.as_ref()
.map(|retrieval| EpiphanySceneRetrieval {
workspace_root: retrieval.workspace_root.clone(),
status: retrieval.status,
semantic_available: retrieval.semantic_available,
index_revision: retrieval.index_revision.clone(),
indexed_file_count: retrieval.indexed_file_count,
indexed_chunk_count: retrieval.indexed_chunk_count,
shard_count: retrieval.shards.len() as u32,
dirty_path_count: retrieval.dirty_paths.len() as u32,
}),
investigation_checkpoint: state.investigation_checkpoint.as_ref().map(|checkpoint| {
graph: scene_graph(mind),
retrieval: None,
investigation_checkpoint: mind.investigation_checkpoint.as_ref().map(|checkpoint| {
EpiphanySceneInvestigationCheckpoint {
checkpoint_id: checkpoint.checkpoint_id.clone(),
kind: checkpoint.kind.clone(),
@ -246,8 +220,8 @@ pub fn derive_scene(input: EpiphanySceneInput<'_>) -> EpiphanyScene {
}
}),
observations: EpiphanySceneRecords {
total_count: state.observations.len() as u32,
latest: state
total_count: mind.observations.len() as u32,
latest: mind
.observations
.iter()
.take(EPIPHANY_SCENE_RECORD_LIMIT)
@ -261,9 +235,9 @@ pub fn derive_scene(input: EpiphanySceneInput<'_>) -> EpiphanyScene {
.collect(),
},
evidence: EpiphanySceneRecords {
total_count: state.recent_evidence.len() as u32,
latest: state
.recent_evidence
total_count: mind.evidence.len() as u32,
latest: mind
.evidence
.iter()
.take(EPIPHANY_SCENE_RECORD_LIMIT)
.map(|evidence| EpiphanySceneRecord {
@ -275,12 +249,7 @@ pub fn derive_scene(input: EpiphanySceneInput<'_>) -> EpiphanyScene {
})
.collect(),
},
churn: state.churn.as_ref().map(|churn| EpiphanySceneChurn {
understanding_status: churn.understanding_status.clone(),
diff_pressure: churn.diff_pressure.clone(),
warning: churn.warning.clone(),
unexplained_writes: churn.unexplained_writes,
}),
churn: None,
available_actions,
}
}
@ -305,10 +274,6 @@ fn scene_available_actions(
EpiphanySceneAction::Jobs,
EpiphanySceneAction::Roles,
EpiphanySceneAction::Coordinator,
EpiphanySceneAction::RoleLaunch,
EpiphanySceneAction::RoleResult,
EpiphanySceneAction::RoleAccept,
EpiphanySceneAction::JobLaunch,
EpiphanySceneAction::Freshness,
EpiphanySceneAction::Pressure,
EpiphanySceneAction::Reorient,
@ -321,19 +286,13 @@ fn scene_available_actions(
actions.push(EpiphanySceneAction::ReorientResult);
actions.push(EpiphanySceneAction::ReorientAccept);
}
actions.push(EpiphanySceneAction::Update);
if state_present {
actions.push(EpiphanySceneAction::JobInterrupt);
actions.push(EpiphanySceneAction::Propose);
actions.push(EpiphanySceneAction::Promote);
}
let _ = state_present;
actions
}
fn scene_subgoals(state: &EpiphanyThreadState) -> Vec<EpiphanySceneSubgoal> {
let active_id = state.active_subgoal_id.as_deref();
state
.subgoals
fn scene_subgoals(mind: &crate::EpiphanyMindView) -> Vec<EpiphanySceneSubgoal> {
let active_id = mind.active_subgoal_id.as_deref();
mind.subgoals
.iter()
.map(|subgoal| EpiphanySceneSubgoal {
id: subgoal.id.clone(),
@ -345,32 +304,63 @@ fn scene_subgoals(state: &EpiphanyThreadState) -> Vec<EpiphanySceneSubgoal> {
.collect()
}
fn scene_graph(state: &EpiphanyThreadState) -> EpiphanySceneGraph {
let frontier = state.graph_frontier.as_ref();
let checkpoint = state.graph_checkpoint.as_ref();
fn scene_graph(mind: &crate::EpiphanyMindView) -> EpiphanySceneGraph {
let Some(model) = mind.repo_model.as_ref() else {
return EpiphanySceneGraph::default();
};
let active = model
.frontier
.iter()
.filter(|item| {
matches!(
item.status,
RepoFrontierStatus::Proposed
| RepoFrontierStatus::Active
| RepoFrontierStatus::Blocked
)
})
.collect::<Vec<_>>();
EpiphanySceneGraph {
architecture_node_count: state.graphs.architecture.nodes.len() as u32,
architecture_edge_count: state.graphs.architecture.edges.len() as u32,
dataflow_node_count: state.graphs.dataflow.nodes.len() as u32,
dataflow_edge_count: state.graphs.dataflow.edges.len() as u32,
link_count: state.graphs.links.len() as u32,
active_node_ids: frontier
.map(|frontier| frontier.active_node_ids.clone())
.unwrap_or_default(),
active_edge_ids: frontier
.map(|frontier| frontier.active_edge_ids.clone())
.unwrap_or_default(),
open_question_count: frontier
.map(|frontier| frontier.open_question_ids.len() as u32)
.unwrap_or_default(),
open_gap_count: frontier
.map(|frontier| frontier.open_gap_ids.len() as u32)
.unwrap_or_default(),
dirty_paths: frontier
.map(|frontier| frontier.dirty_paths.clone())
.unwrap_or_default(),
checkpoint_id: checkpoint.map(|checkpoint| checkpoint.checkpoint_id.clone()),
checkpoint_summary: checkpoint.and_then(|checkpoint| checkpoint.summary.clone()),
architecture_node_count: model
.nodes
.iter()
.filter(|node| node.profile == EpiphanyMemoryProfile::RepoArchitecture)
.count() as u32,
architecture_edge_count: model
.edges
.iter()
.filter(|edge| edge.profile == EpiphanyMemoryProfile::RepoArchitecture)
.count() as u32,
dataflow_node_count: model
.nodes
.iter()
.filter(|node| node.profile == EpiphanyMemoryProfile::RepoDataflow)
.count() as u32,
dataflow_edge_count: model
.edges
.iter()
.filter(|edge| edge.profile == EpiphanyMemoryProfile::RepoDataflow)
.count() as u32,
link_count: model.edges.len() as u32,
active_node_ids: active
.iter()
.flat_map(|item| item.target_claim_ids.iter().cloned())
.collect(),
active_edge_ids: Vec::new(),
open_question_count: active.len() as u32,
open_gap_count: active
.iter()
.filter(|item| item.status == RepoFrontierStatus::Blocked)
.count() as u32,
dirty_paths: Vec::new(),
checkpoint_id: mind
.investigation_checkpoint
.as_ref()
.map(|checkpoint| checkpoint.checkpoint_id.clone()),
checkpoint_summary: mind
.investigation_checkpoint
.as_ref()
.and_then(|checkpoint| checkpoint.summary.clone()),
}
}
@ -389,16 +379,15 @@ fn status_counts<'a>(statuses: impl Iterator<Item = &'a str>) -> Vec<EpiphanySce
mod tests {
use super::*;
use epiphany_state_model::EpiphanyInvariant;
use epiphany_state_model::EpiphanyJobBinding;
use epiphany_state_model::EpiphanyJobKind;
use epiphany_state_model::EpiphanyPlanningState;
use epiphany_state_model::EpiphanySubgoal;
#[test]
fn missing_stored_scene_has_no_actions() {
let scene = derive_scene(EpiphanySceneInput {
state: None,
mind: None,
loaded: false,
reorient_binding_id: "reorient-worker",
reorientation_work_present: false,
});
assert_eq!(scene.state_status, EpiphanySceneStateStatus::Missing);
@ -408,8 +397,11 @@ mod tests {
#[test]
fn live_scene_projects_state_and_actions() {
let state = EpiphanyThreadState {
revision: 4,
let mind = crate::EpiphanyMindView {
schema_epoch: crate::MIND_SCHEMA_EPOCH.into(),
runtime_id: "runtime-1".into(),
projection_digest: "sha256:mind-4".into(),
source_documents: Vec::new(),
objective: Some("purify".to_string()),
active_subgoal_id: Some("subgoal-1".to_string()),
subgoals: vec![EpiphanySubgoal {
@ -432,27 +424,26 @@ mod tests {
rationale: None,
},
],
job_bindings: vec![EpiphanyJobBinding {
id: "reorient-worker".to_string(),
kind: EpiphanyJobKind::Specialist,
scope: "reorient".to_string(),
owner_role: "life".to_string(),
authority_scope: None,
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
blocking_reason: None,
}],
..Default::default()
observations: Vec::new(),
evidence: Vec::new(),
verification_audits: Vec::new(),
reorientation_decisions: Vec::new(),
reorientation_failures: Vec::new(),
investigation_checkpoint: None,
mode: None,
planning: EpiphanyPlanningState::default(),
repository_body_observation: None,
repo_model: None,
};
let scene = derive_scene(EpiphanySceneInput {
state: Some(&state),
mind: Some(&mind),
loaded: true,
reorient_binding_id: "reorient-worker",
reorientation_work_present: true,
});
assert_eq!(scene.state_status, EpiphanySceneStateStatus::Ready);
assert_eq!(scene.revision, Some(4));
assert_eq!(scene.projection_digest.as_deref(), Some("sha256:mind-4"));
assert_eq!(
scene.active_subgoal.as_ref().map(|item| item.active),
Some(true)
@ -463,10 +454,5 @@ mod tests {
.available_actions
.contains(&EpiphanySceneAction::ReorientResult)
);
assert!(
scene
.available_actions
.contains(&EpiphanySceneAction::Promote)
);
}
}