Project current work from keyed Mind

This commit is contained in:
Meta Vens 2026-08-17 20:05:56 +02:00
commit e42788c9f1
3 changed files with 79 additions and 13 deletions

View file

@ -38,9 +38,7 @@ use epiphany_core::derive_scene;
use epiphany_core::read_accepted_coordinator_state;
use epiphany_core::recommend_crrc_action;
use epiphany_core::recommend_reorientation;
use epiphany_core::runtime_has_actionable_hands_frontier;
use epiphany_core::runtime_job_snapshot;
use epiphany_core::runtime_repo_frontier_research_lifecycle;
use epiphany_self_policy::crrc_scene_action_to_coordinator_scene_action;
use epiphany_self_policy::derive_coordinator_finding_signals;
use epiphany_self_policy::derive_coordinator_status;
@ -296,6 +294,8 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
.unwrap_or_else(|| "native-local".to_string());
let state_ref = state.as_ref();
let loaded = state_ref.is_some();
let current_work = epiphany_core::project_current_work(&runtime_store_path)
.context("failed to derive current work from keyed Mind and runtime receipts")?;
let scene = derive_scene(EpiphanySceneInput {
state: state_ref,
@ -481,11 +481,8 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
}
None => false,
};
let hands_frontier_ready = runtime_has_actionable_hands_frontier(&runtime_store_path)
.context("failed to derive actionable Hands frontier from runtime-spine state")?;
let research_lifecycle = runtime_repo_frontier_research_lifecycle(&runtime_store_path)
.context("failed to derive exact Eyes frontier lifecycle from runtime-spine state")?;
let research_continuation_action = research_lifecycle.continuation_action();
let hands_frontier_ready = current_work.hands_frontier_ready;
let research_continuation_action = current_work.research_continuation_action;
let frontier_planning_eligibility = epiphany_core::runtime_repo_frontier_planning_eligibility(
&runtime_store_path,
)
@ -498,6 +495,9 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
let frontier_planning =
epiphany_core::runtime_repo_frontier_planning_lifecycle(&runtime_store_path)
.context("failed to derive frontier planning lifecycle from runtime-spine state")?;
if frontier_planning.stage != current_work.frontier_planning_stage {
return Err(anyhow!("current-work frontier planning projection diverged"));
}
let frontier_relinquishment =
epiphany_core::runtime_latest_repo_frontier_relinquishment(&runtime_store_path)
.context("failed to derive latest frontier relinquishment from runtime-spine state")?;
@ -506,9 +506,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
&runtime_store_path,
frontier_relinquishment.as_ref(),
)?;
let pending_proposal =
epiphany_core::runtime_pending_repo_frontier_proposal_modeling_request(&runtime_store_path)
.context("failed to derive pending proposal Modeling authority")?;
let pending_proposal = current_work.proposal_modeling_request.as_ref();
let coordinator = derive_coordinator_status(EpiphanyCoordinatorStatusInput {
state_status,
checkpoint_present: durable_checkpoint_present,
@ -620,6 +618,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
"roles": roles,
},
"planning": planning,
"currentWork": &current_work,
"frontierPlanning": {
"lifecycle": frontier_planning,
"eligibility": frontier_planning_eligibility,
@ -642,7 +641,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
"modelingResultProposalBound": modeling_result_proposal_bound,
"nativeHandsConsequenceAfterBoundary": native_hands_consequence_after_boundary,
"imaginationFrontierReady": imagination_frontier_ready,
"pendingProposalModelingRequestId": pending_proposal.as_ref().map(|request| request.request_id.as_str()),
"pendingProposalModelingRequestId": pending_proposal.map(|request| request.request_id.as_str()),
"verificationResultAccepted": finding_signals.verification_result_accepted,
"verificationResultFailureReviewed": finding_signals.verification_result_failure_reviewed,
},

View file

@ -4,11 +4,25 @@ use serde::{Deserialize, Serialize};
use sha2::{Digest, Sha256};
use std::path::Path;
use crate::{EpiphanyMindDocumentVersion, EpiphanyRepoModelBasis, RepositoryBodyObservationBasis};
use crate::{
EpiphanyMindDocumentVersion, EpiphanyRepoModelBasis, RepoFrontierPlanningLifecycleStage,
RepoFrontierProposalModelingRequest, RepoFrontierResearchContinuationAction,
RepositoryBodyObservationBasis,
};
pub const BODY_MODELING_DECISION_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.mind.body_modeling_decision.v1";
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct EpiphanyCurrentWorkProjection {
pub mind_projection_digest: String,
pub body_modeling: Option<EpiphanyBodyModelingWorkProjection>,
pub research_continuation_action: Option<RepoFrontierResearchContinuationAction>,
pub frontier_planning_stage: RepoFrontierPlanningLifecycleStage,
pub proposal_modeling_request: Option<RepoFrontierProposalModelingRequest>,
pub hands_frontier_ready: bool,
}
#[derive(Clone, Debug, PartialEq, Eq, Serialize, Deserialize)]
pub struct EpiphanyBodyModelingWorkProjection {
pub work_id: String,
@ -208,6 +222,47 @@ pub fn unresolved_body_modeling_work(
resolve_body_modeling_work(work, decision)
}
pub fn project_current_work(
store_path: impl AsRef<Path>,
) -> Result<EpiphanyCurrentWorkProjection> {
let store_path = store_path.as_ref();
let mind = crate::assemble_mind_view(store_path)?;
let body_modeling = match (
mind.repository_body_observation.clone(),
mind.repo_model.as_ref(),
) {
(Some(body), Some(repo_model)) => {
let work = EpiphanyBodyModelingWorkProjection::derive(
mind.runtime_id.clone(),
body,
repo_model.reasoning_basis(),
)?;
let mut cache = crate::runtime_spine_cache(store_path)?;
cache.pull_all_backing_stores()?;
resolve_body_modeling_work(
work.clone(),
cache.get::<EpiphanyBodyModelingDecisionReceipt>(&work.work_id)?,
)?
}
(None, None) | (Some(_), None) => None,
(None, Some(_)) => {
return Err(anyhow!(
"current work has a RepoModel but no admitted repository Body observation"
));
}
};
Ok(EpiphanyCurrentWorkProjection {
mind_projection_digest: mind.projection_digest,
body_modeling,
research_continuation_action: crate::runtime_repo_frontier_research_lifecycle(store_path)?
.continuation_action(),
frontier_planning_stage: crate::runtime_repo_frontier_planning_lifecycle(store_path)?.stage,
proposal_modeling_request:
crate::runtime_pending_repo_frontier_proposal_modeling_request(store_path)?,
hands_frontier_ready: crate::runtime_has_actionable_hands_frontier(store_path)?,
})
}
fn resolve_body_modeling_work(
work: EpiphanyBodyModelingWorkProjection,
receipt: Option<EpiphanyBodyModelingDecisionReceipt>,
@ -390,6 +445,13 @@ mod tests {
let projected_work = current_body_modeling_work(&store)?;
assert_eq!(projected_work.body_basis, body);
assert_eq!(crate::repository_body_read_counters(), (0, 0));
let current_work = project_current_work(&store)?;
assert_eq!(current_work.body_modeling, Some(projected_work.clone()));
assert_eq!(
current_work.mind_projection_digest,
crate::assemble_mind_view(&store)?.projection_digest
);
assert_eq!(crate::repository_body_read_counters(), (0, 0));
let document =
crate::EpiphanyWorkerLaunchDocument::Role(crate::EpiphanyRoleWorkerLaunchDocument {
thread_id: "creation-thread".into(),
@ -514,6 +576,10 @@ mod tests {
receipt.repo_model_projection_digest,
crate::assemble_repo_model_view(&store)?.projection_digest
);
let mut cache = crate::runtime_spine_cache(&store)?;
cache.put(&receipt.work_id, &receipt)?;
assert!(project_current_work(&store)?.body_modeling.is_none());
assert_eq!(crate::repository_body_read_counters(), (0, 0));
Ok(())
}
}

View file

@ -7840,7 +7840,8 @@ pub enum RepoFrontierResearchLifecycleStage {
ResultReady,
}
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
#[derive(Clone, Copy, Debug, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum RepoFrontierResearchContinuationAction {
LaunchResearch,
ReviewResearchResult,