Repair runtime link authority in MVP loop
This commit is contained in:
parent
32b48c683f
commit
f996274a29
7 changed files with 211 additions and 30 deletions
|
|
@ -2780,10 +2780,10 @@ fn validate_heartbeat_launch_options(
|
|||
.job_bindings
|
||||
.iter()
|
||||
.find(|binding| binding.id == options.binding_id);
|
||||
let existing_runtime_link = state.runtime_links.iter().find(|link| {
|
||||
let latest_runtime_link = state.runtime_links.iter().find(|link| {
|
||||
link.binding_id == options.binding_id && !link.runtime_job_id.trim().is_empty()
|
||||
});
|
||||
if existing_runtime_link.is_some()
|
||||
if latest_runtime_link.is_some_and(|link| link.runtime_result_id.is_none())
|
||||
&& existing_binding.is_none_or(|binding| binding.blocking_reason.is_none())
|
||||
{
|
||||
return Err(anyhow!(
|
||||
|
|
@ -3165,6 +3165,79 @@ mod tests {
|
|||
assert_eq!(launch_plan.runtime_link.role_id, "epiphany-modeler");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn heartbeat_launch_allows_replacement_after_terminal_runtime_link() {
|
||||
let mut state = EpiphanyThreadState::default();
|
||||
state.runtime_links.push(EpiphanyRuntimeLink {
|
||||
id: "runtime-link-modeling-checkpoint-worker-old".to_string(),
|
||||
binding_id: "modeling-checkpoint-worker".to_string(),
|
||||
surface: "runtimeResult".to_string(),
|
||||
role_id: "epiphany-modeler".to_string(),
|
||||
authority_scope: "epiphany.role.modeling".to_string(),
|
||||
runtime_job_id: "old-turn".to_string(),
|
||||
runtime_result_id: Some("result-old-turn".to_string()),
|
||||
linked_subgoal_ids: Vec::new(),
|
||||
linked_graph_node_ids: Vec::new(),
|
||||
});
|
||||
state.runtime_links.push(EpiphanyRuntimeLink {
|
||||
id: "runtime-link-modeling-checkpoint-worker-stale-active".to_string(),
|
||||
binding_id: "modeling-checkpoint-worker".to_string(),
|
||||
surface: "jobLaunch".to_string(),
|
||||
role_id: "epiphany-modeler".to_string(),
|
||||
authority_scope: "epiphany.role.modeling".to_string(),
|
||||
runtime_job_id: "stale-turn".to_string(),
|
||||
runtime_result_id: None,
|
||||
linked_subgoal_ids: Vec::new(),
|
||||
linked_graph_node_ids: Vec::new(),
|
||||
});
|
||||
|
||||
let launch_plan = plan_runtime_spine_heartbeat_launch(
|
||||
&state,
|
||||
RuntimeSpineHeartbeatLaunchPlanOptions {
|
||||
binding_id: "modeling-checkpoint-worker".to_string(),
|
||||
kind: EpiphanyJobKind::Specialist,
|
||||
scope: "role-scoped modeling/checkpoint maintenance".to_string(),
|
||||
owner_role: "epiphany-modeler".to_string(),
|
||||
authority_scope: "epiphany.role.modeling".to_string(),
|
||||
linked_subgoal_ids: Vec::new(),
|
||||
linked_graph_node_ids: Vec::new(),
|
||||
instruction: "Model the target before implementation.".to_string(),
|
||||
launch_document: EpiphanyWorkerLaunchDocument::Role(
|
||||
crate::EpiphanyRoleWorkerLaunchDocument {
|
||||
thread_id: "thread-1".to_string(),
|
||||
role_id: "modeling".to_string(),
|
||||
state_revision: 7,
|
||||
objective: None,
|
||||
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,
|
||||
},
|
||||
),
|
||||
output_contract_id: crate::ROLE_WORKER_OUTPUT_CONTRACT_ID.to_string(),
|
||||
organ_launch_contract: crate::default_launch_organ_contract(
|
||||
"epiphany.role.modeling",
|
||||
"role",
|
||||
crate::ROLE_WORKER_OUTPUT_CONTRACT_ID,
|
||||
),
|
||||
max_runtime_seconds: Some(60),
|
||||
runtime_job_id: "new-turn".to_string(),
|
||||
},
|
||||
)
|
||||
.expect("terminal runtime links should not block replacement launch");
|
||||
|
||||
assert_eq!(launch_plan.runtime_link.runtime_job_id, "new-turn");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn runtime_spine_emits_cultnet_hello_frame() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
|
|
|
|||
|
|
@ -634,12 +634,12 @@ pub fn recommend_coordinator_action(
|
|||
{
|
||||
if !input.modeling_result_reviewable {
|
||||
return build(
|
||||
EpiphanyCoordinatorAction::LaunchModeling,
|
||||
EpiphanyCoordinatorAction::ReviewModelingResult,
|
||||
Some(EpiphanyCoordinatorRoleId::Modeling),
|
||||
Some(EpiphanyCoordinatorSceneAction::RoleLaunch),
|
||||
Some(EpiphanyCoordinatorSceneAction::RoleResult),
|
||||
false,
|
||||
true,
|
||||
"The completed modeling/checkpoint finding is not reviewable because it has no acceptable statePatch; relaunch modeling with the typed patch contract before verification or implementation continues.",
|
||||
false,
|
||||
"The completed modeling/checkpoint finding has no acceptable statePatch; inspect the finding instead of relaunching the same lane.",
|
||||
);
|
||||
}
|
||||
return build(
|
||||
|
|
@ -1187,18 +1187,18 @@ mod tests {
|
|||
);
|
||||
assert!(!review_failed_modeling.can_auto_run);
|
||||
|
||||
let relaunch_unreviewable_modeling =
|
||||
recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
signals: EpiphanyCoordinatorSignals {
|
||||
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
|
||||
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
|
||||
},
|
||||
..input()
|
||||
});
|
||||
let review_unreviewable_modeling = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
signals: EpiphanyCoordinatorSignals {
|
||||
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
|
||||
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
|
||||
},
|
||||
..input()
|
||||
});
|
||||
assert_eq!(
|
||||
relaunch_unreviewable_modeling.action,
|
||||
EpiphanyCoordinatorAction::LaunchModeling
|
||||
review_unreviewable_modeling.action,
|
||||
EpiphanyCoordinatorAction::ReviewModelingResult
|
||||
);
|
||||
assert!(!review_unreviewable_modeling.can_auto_run);
|
||||
|
||||
let launch_verification = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
signals: EpiphanyCoordinatorSignals {
|
||||
|
|
|
|||
|
|
@ -141,7 +141,7 @@ fn overlay_job_binding(
|
|||
return job;
|
||||
}
|
||||
|
||||
if runtime_link.is_some() {
|
||||
if runtime_link.is_some_and(|link| link.runtime_result_id.is_none()) {
|
||||
job.status = EpiphanyJobStatus::Pending;
|
||||
job.blocking_reason = None;
|
||||
job.progress_note =
|
||||
|
|
@ -149,6 +149,14 @@ fn overlay_job_binding(
|
|||
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
|
||||
}
|
||||
|
||||
|
|
@ -501,4 +509,57 @@ mod tests {
|
|||
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.")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue