Gate Hands commits on Proprioception refresh
This commit is contained in:
parent
38548c42c2
commit
e6416a0dfd
8 changed files with 536 additions and 7 deletions
|
|
@ -33,6 +33,7 @@ use epiphany_core::load_thread_state_entry;
|
|||
use epiphany_core::recommend_crrc_action;
|
||||
use epiphany_core::recommend_reorientation;
|
||||
use epiphany_core::runtime_job_snapshot;
|
||||
use epiphany_core::runtime_role_worker_result;
|
||||
use epiphany_state_model::EpiphanyThreadState;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
|
|
@ -260,6 +261,8 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
native_role_result_status(state_ref, &runtime_store_path, RESEARCH_BINDING_ID);
|
||||
let verification_result_status =
|
||||
native_role_result_status(state_ref, &runtime_store_path, VERIFICATION_BINDING_ID);
|
||||
let implementation_commit_requires_modeling_refresh =
|
||||
native_implementation_commit_requires_modeling_refresh(state_ref, &runtime_store_path);
|
||||
let recommendation = recommend_crrc_action(EpiphanyCrrcInput {
|
||||
loaded,
|
||||
state_status,
|
||||
|
|
@ -353,6 +356,7 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
verification_result_allows_implementation: finding_signals
|
||||
.verification_result_allows_implementation,
|
||||
verification_result_needs_evidence: finding_signals.verification_result_needs_evidence,
|
||||
implementation_commit_requires_modeling_refresh,
|
||||
reorient_finding_accepted: finding_signals.reorient_finding_accepted,
|
||||
});
|
||||
let coordinator_json = coordinator_status_json(&coordinator)?;
|
||||
|
|
@ -741,6 +745,62 @@ fn native_role_result_status(
|
|||
}
|
||||
}
|
||||
|
||||
fn native_implementation_commit_requires_modeling_refresh(
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
runtime_store: &Path,
|
||||
) -> bool {
|
||||
let Some(job_id) = latest_runtime_job_id_for_binding(state, IMPLEMENTATION_BINDING_ID) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(Some(snapshot)) = runtime_job_snapshot(runtime_store, job_id) else {
|
||||
return false;
|
||||
};
|
||||
if map_runtime_role_result_status(&snapshot) != EpiphanyCoordinatorRoleResultStatus::Completed {
|
||||
return false;
|
||||
}
|
||||
let Ok(Some(result)) = runtime_role_worker_result(runtime_store, job_id) else {
|
||||
return false;
|
||||
};
|
||||
if !result
|
||||
.evidence_ids
|
||||
.iter()
|
||||
.any(|id| id.starts_with("hands-receipt:hands-commit-") || id.starts_with("hands-commit-"))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
let Some(completed_at) = snapshot
|
||||
.result
|
||||
.as_ref()
|
||||
.map(|receipt| receipt.completed_at.as_str())
|
||||
else {
|
||||
return true;
|
||||
};
|
||||
!native_modeling_accepted_after(state, runtime_store, completed_at)
|
||||
}
|
||||
|
||||
fn native_modeling_accepted_after(
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
runtime_store: &Path,
|
||||
completed_at: &str,
|
||||
) -> bool {
|
||||
let Some(state) = state else {
|
||||
return false;
|
||||
};
|
||||
let Some(job_id) = latest_runtime_job_id_for_binding(Some(state), MODELING_BINDING_ID) else {
|
||||
return false;
|
||||
};
|
||||
let Ok(Some(result)) = runtime_role_worker_result(runtime_store, job_id) else {
|
||||
return false;
|
||||
};
|
||||
state.acceptance_receipts.iter().any(|receipt| {
|
||||
receipt.result_id == result.result_id
|
||||
&& receipt.status == "accepted"
|
||||
&& receipt.surface == "roleAccept"
|
||||
&& receipt.role_id == "modeling"
|
||||
&& receipt.accepted_at.as_str() > completed_at
|
||||
})
|
||||
}
|
||||
|
||||
fn native_reorient_result_status(
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
runtime_store: &Path,
|
||||
|
|
|
|||
|
|
@ -114,6 +114,7 @@ pub struct EpiphanyCoordinatorSourceSignals {
|
|||
pub modeling_result_status: EpiphanyCoordinatorRoleResultStatus,
|
||||
pub verification_result_status: EpiphanyCoordinatorRoleResultStatus,
|
||||
pub reorient_result_status: super::EpiphanyCrrcResultStatus,
|
||||
pub implementation_commit_requires_modeling_refresh: bool,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
@ -143,6 +144,7 @@ pub struct EpiphanyCoordinatorInput {
|
|||
pub verification_result_accepted: bool,
|
||||
pub verification_result_allows_implementation: bool,
|
||||
pub verification_result_needs_evidence: bool,
|
||||
pub implementation_commit_requires_modeling_refresh: bool,
|
||||
pub reorient_finding_accepted: bool,
|
||||
}
|
||||
|
||||
|
|
@ -181,6 +183,7 @@ pub struct EpiphanyCoordinatorStatusInput {
|
|||
pub verification_result_accepted: bool,
|
||||
pub verification_result_allows_implementation: bool,
|
||||
pub verification_result_needs_evidence: bool,
|
||||
pub implementation_commit_requires_modeling_refresh: bool,
|
||||
pub reorient_finding_accepted: bool,
|
||||
}
|
||||
|
||||
|
|
@ -233,6 +236,8 @@ pub fn derive_coordinator_status(
|
|||
modeling_result_status: input.modeling_result_status,
|
||||
verification_result_status: input.verification_result_status,
|
||||
reorient_result_status: input.reorient_result_status,
|
||||
implementation_commit_requires_modeling_refresh: input
|
||||
.implementation_commit_requires_modeling_refresh,
|
||||
};
|
||||
let coordinator_roles = input
|
||||
.roles
|
||||
|
|
@ -272,6 +277,8 @@ pub fn derive_coordinator_status(
|
|||
verification_result_accepted: input.verification_result_accepted,
|
||||
verification_result_allows_implementation: input.verification_result_allows_implementation,
|
||||
verification_result_needs_evidence: input.verification_result_needs_evidence,
|
||||
implementation_commit_requires_modeling_refresh: input
|
||||
.implementation_commit_requires_modeling_refresh,
|
||||
reorient_finding_accepted: input.reorient_finding_accepted,
|
||||
});
|
||||
EpiphanyCoordinatorStatus {
|
||||
|
|
@ -789,6 +796,17 @@ pub fn recommend_coordinator_action(
|
|||
);
|
||||
}
|
||||
|
||||
if input.implementation_commit_requires_modeling_refresh {
|
||||
return build(
|
||||
EpiphanyCoordinatorAction::LaunchModeling,
|
||||
Some(EpiphanyCoordinatorRoleId::Modeling),
|
||||
Some(EpiphanyCoordinatorSceneAction::RoleLaunch),
|
||||
false,
|
||||
true,
|
||||
"A Hands commit landed after the latest accepted Proprioception map; refresh modeling before another implementation cut.",
|
||||
);
|
||||
}
|
||||
|
||||
if input.signals.verification_result_status == EpiphanyCoordinatorRoleResultStatus::Completed
|
||||
&& !input.verification_result_covers_current_modeling
|
||||
{
|
||||
|
|
@ -1123,6 +1141,7 @@ mod tests {
|
|||
verification_result_accepted: false,
|
||||
verification_result_allows_implementation: false,
|
||||
verification_result_needs_evidence: false,
|
||||
implementation_commit_requires_modeling_refresh: false,
|
||||
reorient_finding_accepted: false,
|
||||
}
|
||||
}
|
||||
|
|
@ -1401,6 +1420,20 @@ mod tests {
|
|||
EpiphanyCoordinatorAction::LaunchVerification
|
||||
);
|
||||
|
||||
let refresh_after_commit = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
signals: verification_done,
|
||||
modeling_result_accepted: true,
|
||||
modeling_result_reviewable: true,
|
||||
verification_result_accepted: true,
|
||||
verification_result_allows_implementation: true,
|
||||
implementation_commit_requires_modeling_refresh: true,
|
||||
..input()
|
||||
});
|
||||
assert_eq!(
|
||||
refresh_after_commit.action,
|
||||
EpiphanyCoordinatorAction::LaunchModeling
|
||||
);
|
||||
|
||||
let review_verification = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
signals: verification_done,
|
||||
modeling_result_accepted: true,
|
||||
|
|
|
|||
Reference in a new issue