Demote stale CRRC routing after relinquishment
This commit is contained in:
parent
e000b354c6
commit
9bf8a5a243
9 changed files with 140 additions and 18 deletions
|
|
@ -491,6 +491,11 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
|
|||
let frontier_relinquishment =
|
||||
epiphany_core::runtime_latest_repo_frontier_relinquishment(&runtime_store_path)
|
||||
.context("failed to derive latest frontier relinquishment from runtime-spine state")?;
|
||||
let crrc_regather_current = crrc_regather_current_after_relinquishment(
|
||||
state_ref,
|
||||
&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")?;
|
||||
|
|
@ -499,6 +504,7 @@ fn run_native_status(args: &Args, include_auxiliary_status: bool) -> Result<Valu
|
|||
checkpoint_present: durable_checkpoint_present,
|
||||
pressure: pressure.clone(),
|
||||
recommendation: recommendation.clone(),
|
||||
crrc_regather_current,
|
||||
roles: roles.clone(),
|
||||
reorient_action: reorient_decision.action,
|
||||
research_result_status,
|
||||
|
|
@ -960,6 +966,27 @@ fn native_reorient_result_status(
|
|||
}
|
||||
}
|
||||
|
||||
fn crrc_regather_current_after_relinquishment(
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
runtime_store: &Path,
|
||||
relinquishment: Option<&epiphany_core::RepoFrontierRelinquishmentReceipt>,
|
||||
) -> Result<bool> {
|
||||
let Some(relinquishment) = relinquishment else {
|
||||
return Ok(true);
|
||||
};
|
||||
let Some(job_id) = latest_runtime_job_id_for_binding(state, REORIENT_BINDING_ID) else {
|
||||
return Ok(false);
|
||||
};
|
||||
let Some(snapshot) = runtime_job_snapshot(runtime_store, job_id)? else {
|
||||
return Ok(false);
|
||||
};
|
||||
let reorient_updated_at = chrono::DateTime::parse_from_rfc3339(&snapshot.job.updated_at)
|
||||
.context("reorientation job updated_at is not RFC3339")?;
|
||||
let relinquished_at = chrono::DateTime::parse_from_rfc3339(&relinquishment.relinquished_at)
|
||||
.context("frontier relinquishment timestamp is not RFC3339")?;
|
||||
Ok(reorient_updated_at > relinquished_at)
|
||||
}
|
||||
|
||||
fn reconcile_native_runtime_jobs(
|
||||
jobs: &mut [epiphany_core::EpiphanyJobView],
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
|
|
|
|||
|
|
@ -55,17 +55,13 @@ pub fn derive_coordinator_status(
|
|||
.iter()
|
||||
.map(coordinator_role_lane_from_role_board)
|
||||
.collect();
|
||||
let routing_recommendation =
|
||||
routing_crrc_recommendation(&input.recommendation, input.crrc_regather_current);
|
||||
let decision = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
state_status: input.state_status,
|
||||
checkpoint_present: input.checkpoint_present,
|
||||
should_prepare_compaction: input.pressure.should_prepare_compaction,
|
||||
recommendation: EpiphanyCoordinatorCrrcRecommendation {
|
||||
action: input.recommendation.action,
|
||||
recommended_scene_action: input
|
||||
.recommendation
|
||||
.recommended_scene_action
|
||||
.map(crrc_scene_action_to_coordinator_scene_action),
|
||||
},
|
||||
recommendation: routing_recommendation,
|
||||
roles: coordinator_roles,
|
||||
signals: EpiphanyCoordinatorSignals {
|
||||
research_result_status: input.research_result_status,
|
||||
|
|
@ -106,6 +102,24 @@ pub fn derive_coordinator_status(
|
|||
}
|
||||
}
|
||||
|
||||
fn routing_crrc_recommendation(
|
||||
recommendation: &epiphany_core::EpiphanyCrrcRecommendation,
|
||||
regather_current: bool,
|
||||
) -> EpiphanyCoordinatorCrrcRecommendation {
|
||||
if recommendation.action == EpiphanyCrrcAction::RegatherManually && !regather_current {
|
||||
return EpiphanyCoordinatorCrrcRecommendation {
|
||||
action: EpiphanyCrrcAction::Continue,
|
||||
recommended_scene_action: None,
|
||||
};
|
||||
}
|
||||
EpiphanyCoordinatorCrrcRecommendation {
|
||||
action: recommendation.action,
|
||||
recommended_scene_action: recommendation
|
||||
.recommended_scene_action
|
||||
.map(crrc_scene_action_to_coordinator_scene_action),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn derive_coordinator_finding_signals(
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
research_finding: Option<&EpiphanyRoleFindingInterpretation>,
|
||||
|
|
@ -1249,6 +1263,26 @@ mod tests {
|
|||
use epiphany_state_model::EpiphanyAcceptanceReceipt;
|
||||
use epiphany_state_model::EpiphanyEvidenceRecord;
|
||||
|
||||
#[test]
|
||||
fn relinquishment_demotes_older_manual_regather_to_observation_only() {
|
||||
let recommendation = epiphany_core::EpiphanyCrrcRecommendation {
|
||||
action: EpiphanyCrrcAction::RegatherManually,
|
||||
recommended_scene_action: Some(EpiphanyCrrcSceneAction::ReorientResult),
|
||||
reason: "historical failed reorientation".to_string(),
|
||||
};
|
||||
|
||||
let stale = routing_crrc_recommendation(&recommendation, false);
|
||||
assert_eq!(stale.action, EpiphanyCrrcAction::Continue);
|
||||
assert_eq!(stale.recommended_scene_action, None);
|
||||
|
||||
let current = routing_crrc_recommendation(&recommendation, true);
|
||||
assert_eq!(current.action, EpiphanyCrrcAction::RegatherManually);
|
||||
assert_eq!(
|
||||
current.recommended_scene_action,
|
||||
Some(EpiphanyCoordinatorSceneAction::ReorientResult)
|
||||
);
|
||||
}
|
||||
|
||||
fn base_roles() -> Vec<EpiphanyCoordinatorRoleLane> {
|
||||
vec![
|
||||
role(
|
||||
|
|
|
|||
|
|
@ -184,6 +184,10 @@ pub struct EpiphanyCoordinatorStatusInput {
|
|||
pub checkpoint_present: bool,
|
||||
pub pressure: EpiphanyPressure,
|
||||
pub recommendation: EpiphanyCrrcRecommendation,
|
||||
/// True when CRRC's manual-regather pressure is causally newer than the
|
||||
/// latest typed frontier relinquishment. Raw CRRC remains observable when
|
||||
/// false, but it cannot route Self from stale continuity history.
|
||||
pub crrc_regather_current: bool,
|
||||
pub roles: Vec<EpiphanyRoleBoardLane>,
|
||||
pub reorient_action: EpiphanyReorientAction,
|
||||
pub research_result_status: EpiphanyCoordinatorRoleResultStatus,
|
||||
|
|
|
|||
Reference in a new issue