Derive CRRC checkpoint from admitted RepoModel

This commit is contained in:
Meta Vens 2026-08-08 11:11:20 +01:00
commit 253ef34084
4 changed files with 76 additions and 16 deletions

View file

@ -308,9 +308,52 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
epiphany_core::EpiphanyPressureLevel::High => EpiphanyReorientPressureLevel::High,
epiphany_core::EpiphanyPressureLevel::Critical => EpiphanyReorientPressureLevel::Critical,
};
let admitted_model_projection =
match epiphany_core::runtime_current_repo_model(&runtime_store_path)? {
Some(_) => Some(
epiphany_core::runtime_modeling_semantic_projection_input(&runtime_store_path)
.context("failed to validate current RepoModel continuity projection")?,
),
None => None,
};
let investigation_checkpoint =
state_ref.and_then(|state| state.investigation_checkpoint.as_ref());
let repo_model_code_refs = admitted_model_projection
.as_ref()
.map(|projection| {
projection
.snapshot()
.frontier
.iter()
.filter(|item| item.status == epiphany_core::RepoFrontierStatus::Active)
.flat_map(|item| item.source_scope.iter())
.map(|path| epiphany_state_model::EpiphanyCodeRef {
path: path.into(),
start_line: None,
end_line: None,
symbol: None,
note: Some("Current admitted RepoModel frontier scope".to_string()),
})
.collect::<Vec<_>>()
})
.unwrap_or_default();
let reorient_checkpoint = investigation_checkpoint
.map(epiphany_core::EpiphanyReorientCheckpoint::from)
.or_else(|| {
admitted_model_projection.as_ref().map(|projection| {
epiphany_core::EpiphanyReorientCheckpoint {
checkpoint_id: &projection.obligation().obligation_id,
disposition:
epiphany_state_model::EpiphanyInvestigationDisposition::ResumeReady,
next_action: Some("Resume from the current Mind-admitted RepoModel frontier."),
code_refs: &repo_model_code_refs,
}
})
});
let durable_checkpoint_present = reorient_checkpoint.is_some();
let (reorient_state_status, reorient_decision) =
recommend_reorientation(EpiphanyReorientInput {
checkpoint: state_ref.and_then(|state| state.investigation_checkpoint.as_ref()),
checkpoint: reorient_checkpoint,
state_present: state_ref.is_some(),
pressure_level: reorient_pressure_level,
retrieval_status: reorient_retrieval_status(freshness.retrieval.status),
@ -359,9 +402,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
should_prepare_compaction: pressure.should_prepare_compaction,
reorient_action,
result_status,
checkpoint_present: state_ref
.and_then(|state| state.investigation_checkpoint.as_ref())
.is_some(),
checkpoint_present: durable_checkpoint_present,
finding_present: reorient_finding.is_some(),
finding_accepted: reorient_finding_accepted,
});
@ -480,9 +521,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
.context("failed to derive pending proposal Modeling authority")?;
let coordinator = derive_coordinator_status(EpiphanyCoordinatorStatusInput {
state_status,
checkpoint_present: state_ref
.and_then(|state| state.investigation_checkpoint.as_ref())
.is_some(),
checkpoint_present: durable_checkpoint_present,
pressure: pressure.clone(),
recommendation: recommendation.clone(),
roles: roles.clone(),

View file

@ -1183,6 +1183,7 @@ pub use surfaces::EpiphanyPressureStatus;
pub use surfaces::EpiphanyReorientAcceptanceBundle;
pub use surfaces::EpiphanyReorientAcceptanceFinding;
pub use surfaces::EpiphanyReorientAction;
pub use surfaces::EpiphanyReorientCheckpoint;
pub use surfaces::EpiphanyReorientCheckpointStatus;
pub use surfaces::EpiphanyReorientDecision;
pub use surfaces::EpiphanyReorientFindingInterpretation;

View file

@ -82,6 +82,7 @@ pub use pressure::EpiphanyPressureStatus;
pub use pressure::EpiphanyTokenUsageSnapshot;
pub use pressure::derive_pressure_view;
pub use reorient::EpiphanyReorientAction;
pub use reorient::EpiphanyReorientCheckpoint;
pub use reorient::EpiphanyReorientCheckpointStatus;
pub use reorient::EpiphanyReorientDecision;
pub use reorient::EpiphanyReorientFreshnessStatus;

View file

@ -66,7 +66,7 @@ pub enum EpiphanyReorientFreshnessStatus {
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyReorientInput<'a> {
pub checkpoint: Option<&'a EpiphanyInvestigationCheckpoint>,
pub checkpoint: Option<EpiphanyReorientCheckpoint<'a>>,
pub state_present: bool,
pub pressure_level: EpiphanyReorientPressureLevel,
pub retrieval_status: EpiphanyReorientFreshnessStatus,
@ -80,6 +80,25 @@ pub struct EpiphanyReorientInput<'a> {
pub watched_root: Option<PathBuf>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyReorientCheckpoint<'a> {
pub checkpoint_id: &'a str,
pub disposition: EpiphanyInvestigationDisposition,
pub next_action: Option<&'a str>,
pub code_refs: &'a [epiphany_state_model::EpiphanyCodeRef],
}
impl<'a> From<&'a EpiphanyInvestigationCheckpoint> for EpiphanyReorientCheckpoint<'a> {
fn from(checkpoint: &'a EpiphanyInvestigationCheckpoint) -> Self {
Self {
checkpoint_id: &checkpoint.checkpoint_id,
disposition: checkpoint.disposition,
next_action: checkpoint.next_action.as_deref(),
code_refs: &checkpoint.code_refs,
}
}
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyReorientDecision {
@ -196,7 +215,7 @@ pub fn recommend_reorientation(
};
let workspace_root = input.watched_root.as_deref();
let checkpoint_dirty_paths = overlapping_checkpoint_paths(
checkpoint,
&checkpoint,
input
.retrieval_dirty_paths
.iter()
@ -204,7 +223,7 @@ pub fn recommend_reorientation(
workspace_root,
);
let checkpoint_changed_paths = overlapping_checkpoint_paths(
checkpoint,
&checkpoint,
input.watcher_changed_paths.iter(),
workspace_root,
);
@ -266,12 +285,12 @@ pub fn recommend_reorientation(
build_decision(
EpiphanyReorientAction::Resume,
checkpoint_status,
Some(checkpoint.checkpoint_id.clone()),
Some(checkpoint.checkpoint_id.to_string()),
reasons,
Vec::new(),
Vec::new(),
Vec::new(),
checkpoint.next_action.clone().unwrap_or_else(|| {
checkpoint.next_action.map(str::to_string).unwrap_or_else(|| {
"Resume from the durable checkpoint focus and verify the seam before broad edits."
.to_string()
}),
@ -333,14 +352,14 @@ pub fn recommend_reorientation(
build_decision(
EpiphanyReorientAction::Regather,
checkpoint_status,
Some(checkpoint.checkpoint_id.clone()),
Some(checkpoint.checkpoint_id.to_string()),
reasons,
checkpoint_dirty_paths,
checkpoint_changed_paths,
input.active_frontier_node_ids,
checkpoint
.next_action
.clone()
.map(str::to_string)
.unwrap_or_else(|| "Re-gather source context before editing.".to_string()),
format!("Re-gather before editing: {}.", note_fragments.join("; ")),
),
@ -348,7 +367,7 @@ pub fn recommend_reorientation(
}
fn overlapping_checkpoint_paths<'a>(
checkpoint: &EpiphanyInvestigationCheckpoint,
checkpoint: &EpiphanyReorientCheckpoint<'_>,
candidate_paths: impl IntoIterator<Item = &'a PathBuf>,
workspace_root: Option<&Path>,
) -> Vec<PathBuf> {
@ -416,7 +435,7 @@ mod tests {
fn input(checkpoint: Option<&EpiphanyInvestigationCheckpoint>) -> EpiphanyReorientInput<'_> {
EpiphanyReorientInput {
checkpoint,
checkpoint: checkpoint.map(EpiphanyReorientCheckpoint::from),
state_present: true,
pressure_level: EpiphanyReorientPressureLevel::Low,
retrieval_status: EpiphanyReorientFreshnessStatus::Clean,