Migrate Reorientation to keyed Mind authority
This commit is contained in:
parent
237fb81cf5
commit
d5df53ae40
17 changed files with 1542 additions and 1664 deletions
|
|
@ -57,8 +57,7 @@ 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 routing_recommendation = routing_crrc_recommendation(&input.recommendation);
|
||||
let decision = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
state_status: input.state_status,
|
||||
checkpoint_present: input.checkpoint_present,
|
||||
|
|
@ -110,14 +109,7 @@ 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
|
||||
|
|
@ -1057,26 +1049,6 @@ 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(
|
||||
|
|
|
|||
|
|
@ -194,10 +194,6 @@ 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,
|
||||
|
|
|
|||
|
|
@ -61,14 +61,6 @@ pub use pressure::EpiphanyPressureStatus;
|
|||
pub use pressure::EpiphanyTokenUsageSnapshot;
|
||||
pub use pressure::derive_pressure_view;
|
||||
pub use reorient::EpiphanyReorientAction;
|
||||
pub use reorient::EpiphanyReorientCheckpointStatus;
|
||||
pub use reorient::EpiphanyReorientDecision;
|
||||
pub use reorient::EpiphanyReorientFreshnessStatus;
|
||||
pub use reorient::EpiphanyReorientInput;
|
||||
pub use reorient::EpiphanyReorientPressureLevel;
|
||||
pub use reorient::EpiphanyReorientReason;
|
||||
pub use reorient::EpiphanyReorientStateStatus;
|
||||
pub use reorient::recommend_reorientation;
|
||||
pub use role_board::EpiphanyRoleBoardCheckpointSummary;
|
||||
pub use role_board::EpiphanyRoleBoardInput;
|
||||
pub use role_board::EpiphanyRoleBoardJob;
|
||||
|
|
@ -119,7 +111,6 @@ pub use view::epiphany_view_needs_pressure;
|
|||
pub use view::epiphany_view_needs_reorientation_inputs;
|
||||
pub use view::epiphany_view_needs_runtime_store;
|
||||
pub use worker_launch::AdmittedModelDirectionConsiderationContextProjection;
|
||||
pub use worker_launch::EpiphanyReorientLaunchRequestInput;
|
||||
pub use worker_launch::EpiphanyReorientWorkerLaunchDocument;
|
||||
pub use worker_launch::EpiphanyRoleWorkerLaunchDocument;
|
||||
pub use worker_launch::EpiphanyWorkerLaunchDocument;
|
||||
|
|
@ -141,4 +132,3 @@ pub use worker_launch::RepoFrontierPlanningContextProjection;
|
|||
pub use worker_launch::RepoFrontierProposalModelingContextProjection;
|
||||
pub use worker_launch::RepoFrontierResearchContextProjection;
|
||||
pub use worker_launch::RepoFrontierVerificationContextProjection;
|
||||
pub use worker_launch::build_reorient_job_launch_request;
|
||||
|
|
|
|||
|
|
@ -1,566 +1,13 @@
|
|||
use epiphany_state_model::EpiphanyInvestigationCheckpoint;
|
||||
use epiphany_state_model::EpiphanyInvestigationDisposition;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::collections::HashSet;
|
||||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
/// Display projection of an accepted keyed continuity decision.
|
||||
///
|
||||
/// This enum does not decide whether Reorientation should run. The keyed
|
||||
/// current-work owner in `reorientation_work` owns launch, wait, review, and
|
||||
/// admission behavior.
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyReorientAction {
|
||||
Resume,
|
||||
Regather,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyReorientStateStatus {
|
||||
Missing,
|
||||
Ready,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyReorientCheckpointStatus {
|
||||
Missing,
|
||||
ResumeReady,
|
||||
RegatherRequired,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyReorientReason {
|
||||
MissingState,
|
||||
MissingCheckpoint,
|
||||
CheckpointReady,
|
||||
CheckpointRequestedRegather,
|
||||
CheckpointPathsDirty,
|
||||
CheckpointPathsChanged,
|
||||
FrontierChanged,
|
||||
UnanchoredCheckpointWhileStateStale,
|
||||
RetrievalFreshnessBlocked,
|
||||
GraphFreshnessBlocked,
|
||||
WatcherFreshnessBlocked,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyReorientPressureLevel {
|
||||
Unknown,
|
||||
Low,
|
||||
Medium,
|
||||
High,
|
||||
Critical,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyReorientFreshnessStatus {
|
||||
Unknown,
|
||||
Clean,
|
||||
Dirty,
|
||||
Stale,
|
||||
Changed,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct EpiphanyReorientInput<'a> {
|
||||
pub checkpoint: Option<&'a EpiphanyInvestigationCheckpoint>,
|
||||
pub state_present: bool,
|
||||
pub pressure_level: EpiphanyReorientPressureLevel,
|
||||
pub retrieval_status: EpiphanyReorientFreshnessStatus,
|
||||
pub retrieval_dirty_paths: Vec<PathBuf>,
|
||||
pub graph_status: EpiphanyReorientFreshnessStatus,
|
||||
pub graph_dirty_paths: Vec<PathBuf>,
|
||||
pub watcher_status: EpiphanyReorientFreshnessStatus,
|
||||
pub watcher_changed_paths: Vec<PathBuf>,
|
||||
pub watcher_graph_node_ids: Vec<String>,
|
||||
pub active_frontier_node_ids: Vec<String>,
|
||||
pub watched_root: Option<PathBuf>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EpiphanyReorientDecision {
|
||||
pub action: EpiphanyReorientAction,
|
||||
pub checkpoint_status: EpiphanyReorientCheckpointStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub checkpoint_id: Option<String>,
|
||||
pub pressure_level: EpiphanyReorientPressureLevel,
|
||||
pub retrieval_status: EpiphanyReorientFreshnessStatus,
|
||||
pub graph_status: EpiphanyReorientFreshnessStatus,
|
||||
pub watcher_status: EpiphanyReorientFreshnessStatus,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub reasons: Vec<EpiphanyReorientReason>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub checkpoint_dirty_paths: Vec<PathBuf>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub checkpoint_changed_paths: Vec<PathBuf>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub active_frontier_node_ids: Vec<String>,
|
||||
pub next_action: String,
|
||||
pub note: String,
|
||||
}
|
||||
|
||||
pub fn recommend_reorientation(
|
||||
input: EpiphanyReorientInput<'_>,
|
||||
) -> (EpiphanyReorientStateStatus, EpiphanyReorientDecision) {
|
||||
let build_decision = |action: EpiphanyReorientAction,
|
||||
checkpoint_status: EpiphanyReorientCheckpointStatus,
|
||||
checkpoint_id: Option<String>,
|
||||
reasons: Vec<EpiphanyReorientReason>,
|
||||
checkpoint_dirty_paths: Vec<PathBuf>,
|
||||
checkpoint_changed_paths: Vec<PathBuf>,
|
||||
active_frontier_node_ids: Vec<String>,
|
||||
next_action: String,
|
||||
note: String| EpiphanyReorientDecision {
|
||||
action,
|
||||
checkpoint_status,
|
||||
checkpoint_id,
|
||||
pressure_level: input.pressure_level,
|
||||
retrieval_status: input.retrieval_status,
|
||||
graph_status: input.graph_status,
|
||||
watcher_status: input.watcher_status,
|
||||
reasons,
|
||||
checkpoint_dirty_paths,
|
||||
checkpoint_changed_paths,
|
||||
active_frontier_node_ids,
|
||||
next_action,
|
||||
note,
|
||||
};
|
||||
|
||||
let high_pressure = matches!(
|
||||
input.pressure_level,
|
||||
EpiphanyReorientPressureLevel::High | EpiphanyReorientPressureLevel::Critical
|
||||
);
|
||||
|
||||
if !input.state_present {
|
||||
let note = if high_pressure {
|
||||
"No Epiphany state survived, and the last recorded context pressure was high; re-gather before editing."
|
||||
.to_string()
|
||||
} else {
|
||||
"No Epiphany state survived, so there is no authoritative checkpoint to resume."
|
||||
.to_string()
|
||||
};
|
||||
return (
|
||||
EpiphanyReorientStateStatus::Missing,
|
||||
build_decision(
|
||||
EpiphanyReorientAction::Regather,
|
||||
EpiphanyReorientCheckpointStatus::Missing,
|
||||
None,
|
||||
vec![
|
||||
EpiphanyReorientReason::MissingState,
|
||||
EpiphanyReorientReason::MissingCheckpoint,
|
||||
],
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
"Re-gather source context before editing.".to_string(),
|
||||
note,
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
let Some(checkpoint) = input.checkpoint else {
|
||||
let note = if high_pressure {
|
||||
"Epiphany state survived, but no durable investigation checkpoint was banked before high context pressure; re-gather before editing."
|
||||
.to_string()
|
||||
} else {
|
||||
"Epiphany state survived, but there is no durable investigation checkpoint to resume from."
|
||||
.to_string()
|
||||
};
|
||||
return (
|
||||
EpiphanyReorientStateStatus::Ready,
|
||||
build_decision(
|
||||
EpiphanyReorientAction::Regather,
|
||||
EpiphanyReorientCheckpointStatus::Missing,
|
||||
None,
|
||||
vec![EpiphanyReorientReason::MissingCheckpoint],
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
"Re-gather source context before editing.".to_string(),
|
||||
note,
|
||||
),
|
||||
);
|
||||
};
|
||||
|
||||
let checkpoint_status = match checkpoint.disposition {
|
||||
EpiphanyInvestigationDisposition::ResumeReady => {
|
||||
EpiphanyReorientCheckpointStatus::ResumeReady
|
||||
}
|
||||
EpiphanyInvestigationDisposition::RegatherRequired => {
|
||||
EpiphanyReorientCheckpointStatus::RegatherRequired
|
||||
}
|
||||
};
|
||||
let workspace_root = input.watched_root.as_deref();
|
||||
let checkpoint_dirty_paths = overlapping_checkpoint_paths(
|
||||
checkpoint,
|
||||
input
|
||||
.retrieval_dirty_paths
|
||||
.iter()
|
||||
.chain(input.graph_dirty_paths.iter()),
|
||||
workspace_root,
|
||||
);
|
||||
let checkpoint_changed_paths = overlapping_checkpoint_paths(
|
||||
checkpoint,
|
||||
input.watcher_changed_paths.iter(),
|
||||
workspace_root,
|
||||
);
|
||||
let frontier_changed = !input.active_frontier_node_ids.is_empty();
|
||||
let unanchored_checkpoint_while_state_stale = checkpoint.code_refs.is_empty()
|
||||
&& (!input.retrieval_dirty_paths.is_empty()
|
||||
|| !input.graph_dirty_paths.is_empty()
|
||||
|| !input.watcher_graph_node_ids.is_empty()
|
||||
|| frontier_changed);
|
||||
|
||||
let mut reasons = Vec::new();
|
||||
if checkpoint.disposition == EpiphanyInvestigationDisposition::RegatherRequired {
|
||||
reasons.push(EpiphanyReorientReason::CheckpointRequestedRegather);
|
||||
}
|
||||
if !checkpoint_dirty_paths.is_empty() {
|
||||
reasons.push(EpiphanyReorientReason::CheckpointPathsDirty);
|
||||
}
|
||||
if !checkpoint_changed_paths.is_empty() {
|
||||
reasons.push(EpiphanyReorientReason::CheckpointPathsChanged);
|
||||
}
|
||||
if frontier_changed {
|
||||
reasons.push(EpiphanyReorientReason::FrontierChanged);
|
||||
}
|
||||
if unanchored_checkpoint_while_state_stale {
|
||||
reasons.push(EpiphanyReorientReason::UnanchoredCheckpointWhileStateStale);
|
||||
}
|
||||
let retrieval_blocked = input.retrieval_status != EpiphanyReorientFreshnessStatus::Clean;
|
||||
let graph_blocked = input.graph_status != EpiphanyReorientFreshnessStatus::Clean;
|
||||
let watcher_blocked = matches!(
|
||||
input.watcher_status,
|
||||
EpiphanyReorientFreshnessStatus::Dirty
|
||||
| EpiphanyReorientFreshnessStatus::Stale
|
||||
| EpiphanyReorientFreshnessStatus::Changed
|
||||
);
|
||||
if retrieval_blocked {
|
||||
reasons.push(EpiphanyReorientReason::RetrievalFreshnessBlocked);
|
||||
}
|
||||
if graph_blocked {
|
||||
reasons.push(EpiphanyReorientReason::GraphFreshnessBlocked);
|
||||
}
|
||||
if watcher_blocked {
|
||||
reasons.push(EpiphanyReorientReason::WatcherFreshnessBlocked);
|
||||
}
|
||||
|
||||
let should_regather = checkpoint.disposition
|
||||
== EpiphanyInvestigationDisposition::RegatherRequired
|
||||
|| !checkpoint_dirty_paths.is_empty()
|
||||
|| !checkpoint_changed_paths.is_empty()
|
||||
|| frontier_changed
|
||||
|| unanchored_checkpoint_while_state_stale
|
||||
|| retrieval_blocked
|
||||
|| graph_blocked
|
||||
|| watcher_blocked;
|
||||
|
||||
if !should_regather {
|
||||
reasons.push(EpiphanyReorientReason::CheckpointReady);
|
||||
return (
|
||||
EpiphanyReorientStateStatus::Ready,
|
||||
build_decision(
|
||||
EpiphanyReorientAction::Resume,
|
||||
checkpoint_status,
|
||||
Some(checkpoint.checkpoint_id.clone()),
|
||||
reasons,
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
Vec::new(),
|
||||
checkpoint.next_action.clone().unwrap_or_else(|| {
|
||||
"Resume from the durable checkpoint focus and verify the seam before broad edits."
|
||||
.to_string()
|
||||
}),
|
||||
"Resume-ready checkpoint remains aligned with current freshness and watcher signals."
|
||||
.to_string(),
|
||||
),
|
||||
);
|
||||
}
|
||||
|
||||
let mut note_fragments = Vec::new();
|
||||
if checkpoint.disposition == EpiphanyInvestigationDisposition::RegatherRequired {
|
||||
note_fragments.push("the checkpoint explicitly requests re-gather".to_string());
|
||||
}
|
||||
if !checkpoint_dirty_paths.is_empty() {
|
||||
note_fragments.push(format!(
|
||||
"{} checkpoint path(s) are already marked dirty",
|
||||
checkpoint_dirty_paths.len()
|
||||
));
|
||||
}
|
||||
if !checkpoint_changed_paths.is_empty() {
|
||||
note_fragments.push(format!(
|
||||
"watcher observed {} changed checkpoint path(s)",
|
||||
checkpoint_changed_paths.len()
|
||||
));
|
||||
}
|
||||
if frontier_changed {
|
||||
note_fragments.push(format!(
|
||||
"watcher hit {} active frontier node(s)",
|
||||
input.active_frontier_node_ids.len()
|
||||
));
|
||||
}
|
||||
if unanchored_checkpoint_while_state_stale {
|
||||
note_fragments.push(
|
||||
"the checkpoint has no code refs while freshness signals already show drift"
|
||||
.to_string(),
|
||||
);
|
||||
}
|
||||
if retrieval_blocked {
|
||||
note_fragments.push(format!(
|
||||
"retrieval freshness is {:?}, not clean",
|
||||
input.retrieval_status
|
||||
));
|
||||
}
|
||||
if graph_blocked {
|
||||
note_fragments.push(format!(
|
||||
"graph freshness is {:?}, not clean",
|
||||
input.graph_status
|
||||
));
|
||||
}
|
||||
if watcher_blocked {
|
||||
note_fragments.push(format!(
|
||||
"watcher freshness is {:?} and reports invalidation pressure",
|
||||
input.watcher_status
|
||||
));
|
||||
}
|
||||
|
||||
(
|
||||
EpiphanyReorientStateStatus::Ready,
|
||||
build_decision(
|
||||
EpiphanyReorientAction::Regather,
|
||||
checkpoint_status,
|
||||
Some(checkpoint.checkpoint_id.clone()),
|
||||
reasons,
|
||||
checkpoint_dirty_paths,
|
||||
checkpoint_changed_paths,
|
||||
input.active_frontier_node_ids,
|
||||
checkpoint
|
||||
.next_action
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Re-gather source context before editing.".to_string()),
|
||||
format!("Re-gather before editing: {}.", note_fragments.join("; ")),
|
||||
),
|
||||
)
|
||||
}
|
||||
|
||||
fn overlapping_checkpoint_paths<'a>(
|
||||
checkpoint: &EpiphanyInvestigationCheckpoint,
|
||||
candidate_paths: impl IntoIterator<Item = &'a PathBuf>,
|
||||
workspace_root: Option<&Path>,
|
||||
) -> Vec<PathBuf> {
|
||||
let checkpoint_path_keys: HashSet<String> = checkpoint
|
||||
.code_refs
|
||||
.iter()
|
||||
.map(|code_ref| code_ref_path_key(code_ref.path.as_path(), workspace_root))
|
||||
.collect();
|
||||
if checkpoint_path_keys.is_empty() {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let mut overlaps = Vec::new();
|
||||
let mut seen = HashSet::new();
|
||||
for path in candidate_paths {
|
||||
let path_key = code_ref_path_key(path.as_path(), workspace_root);
|
||||
if checkpoint_path_keys.contains(&path_key) && seen.insert(path_key) {
|
||||
overlaps.push(path.clone());
|
||||
}
|
||||
}
|
||||
overlaps
|
||||
}
|
||||
|
||||
fn code_ref_path_key(path: &Path, workspace_root: Option<&Path>) -> String {
|
||||
if let Some(workspace_root) = workspace_root
|
||||
&& let Ok(relative_path) = path.strip_prefix(workspace_root)
|
||||
{
|
||||
return epiphany_path_key(relative_path);
|
||||
}
|
||||
epiphany_path_key(path)
|
||||
}
|
||||
|
||||
fn epiphany_path_key(path: &Path) -> String {
|
||||
path.to_string_lossy()
|
||||
.replace('\\', "/")
|
||||
.trim_start_matches("./")
|
||||
.to_string()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use epiphany_state_model::EpiphanyCodeRef;
|
||||
|
||||
fn checkpoint() -> EpiphanyInvestigationCheckpoint {
|
||||
EpiphanyInvestigationCheckpoint {
|
||||
checkpoint_id: "ix-1".to_string(),
|
||||
kind: "implementation".to_string(),
|
||||
disposition: EpiphanyInvestigationDisposition::ResumeReady,
|
||||
focus: "runtime seam".to_string(),
|
||||
summary: Some("resume here".to_string()),
|
||||
next_action: Some("Continue from the seam.".to_string()),
|
||||
captured_at_turn_id: Some("turn-1".to_string()),
|
||||
open_questions: Vec::new(),
|
||||
code_refs: vec![EpiphanyCodeRef {
|
||||
path: PathBuf::from("src/lib.rs"),
|
||||
start_line: None,
|
||||
end_line: None,
|
||||
symbol: None,
|
||||
note: None,
|
||||
}],
|
||||
evidence_ids: vec!["ev-1".to_string()],
|
||||
}
|
||||
}
|
||||
|
||||
fn input(checkpoint: Option<&EpiphanyInvestigationCheckpoint>) -> EpiphanyReorientInput<'_> {
|
||||
EpiphanyReorientInput {
|
||||
checkpoint,
|
||||
state_present: true,
|
||||
pressure_level: EpiphanyReorientPressureLevel::Low,
|
||||
retrieval_status: EpiphanyReorientFreshnessStatus::Clean,
|
||||
retrieval_dirty_paths: Vec::new(),
|
||||
graph_status: EpiphanyReorientFreshnessStatus::Clean,
|
||||
graph_dirty_paths: Vec::new(),
|
||||
watcher_status: EpiphanyReorientFreshnessStatus::Clean,
|
||||
watcher_changed_paths: Vec::new(),
|
||||
watcher_graph_node_ids: Vec::new(),
|
||||
active_frontier_node_ids: Vec::new(),
|
||||
watched_root: None,
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn resumes_when_checkpoint_is_clean() {
|
||||
let checkpoint = checkpoint();
|
||||
let (state_status, decision) = recommend_reorientation(input(Some(&checkpoint)));
|
||||
|
||||
assert_eq!(state_status, EpiphanyReorientStateStatus::Ready);
|
||||
assert_eq!(decision.action, EpiphanyReorientAction::Resume);
|
||||
assert_eq!(decision.checkpoint_id.as_deref(), Some("ix-1"));
|
||||
assert_eq!(
|
||||
decision.reasons,
|
||||
vec![EpiphanyReorientReason::CheckpointReady]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn regathers_when_checkpoint_path_changes() {
|
||||
let checkpoint = checkpoint();
|
||||
let mut input = input(Some(&checkpoint));
|
||||
input.watcher_status = EpiphanyReorientFreshnessStatus::Changed;
|
||||
input.watcher_changed_paths = vec![PathBuf::from("./src/lib.rs")];
|
||||
|
||||
let (_state_status, decision) = recommend_reorientation(input);
|
||||
|
||||
assert_eq!(decision.action, EpiphanyReorientAction::Regather);
|
||||
assert_eq!(
|
||||
decision.reasons,
|
||||
vec![
|
||||
EpiphanyReorientReason::CheckpointPathsChanged,
|
||||
EpiphanyReorientReason::WatcherFreshnessBlocked,
|
||||
]
|
||||
);
|
||||
assert_eq!(
|
||||
decision.checkpoint_changed_paths,
|
||||
vec![PathBuf::from("./src/lib.rs")]
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn freshness_authorities_block_resume_but_unknown_watcher_does_not() {
|
||||
let checkpoint = checkpoint();
|
||||
for (field, status, reason) in [
|
||||
(
|
||||
"retrieval",
|
||||
EpiphanyReorientFreshnessStatus::Unknown,
|
||||
EpiphanyReorientReason::RetrievalFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"retrieval",
|
||||
EpiphanyReorientFreshnessStatus::Dirty,
|
||||
EpiphanyReorientReason::RetrievalFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"retrieval",
|
||||
EpiphanyReorientFreshnessStatus::Stale,
|
||||
EpiphanyReorientReason::RetrievalFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"retrieval",
|
||||
EpiphanyReorientFreshnessStatus::Changed,
|
||||
EpiphanyReorientReason::RetrievalFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"graph",
|
||||
EpiphanyReorientFreshnessStatus::Unknown,
|
||||
EpiphanyReorientReason::GraphFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"graph",
|
||||
EpiphanyReorientFreshnessStatus::Dirty,
|
||||
EpiphanyReorientReason::GraphFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"graph",
|
||||
EpiphanyReorientFreshnessStatus::Stale,
|
||||
EpiphanyReorientReason::GraphFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"graph",
|
||||
EpiphanyReorientFreshnessStatus::Changed,
|
||||
EpiphanyReorientReason::GraphFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"watcher",
|
||||
EpiphanyReorientFreshnessStatus::Dirty,
|
||||
EpiphanyReorientReason::WatcherFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"watcher",
|
||||
EpiphanyReorientFreshnessStatus::Stale,
|
||||
EpiphanyReorientReason::WatcherFreshnessBlocked,
|
||||
),
|
||||
(
|
||||
"watcher",
|
||||
EpiphanyReorientFreshnessStatus::Changed,
|
||||
EpiphanyReorientReason::WatcherFreshnessBlocked,
|
||||
),
|
||||
] {
|
||||
let mut candidate = input(Some(&checkpoint));
|
||||
match field {
|
||||
"retrieval" => candidate.retrieval_status = status,
|
||||
"graph" => candidate.graph_status = status,
|
||||
"watcher" => candidate.watcher_status = status,
|
||||
_ => unreachable!(),
|
||||
}
|
||||
let (_, decision) = recommend_reorientation(candidate);
|
||||
assert_eq!(decision.action, EpiphanyReorientAction::Regather);
|
||||
assert!(decision.reasons.contains(&reason));
|
||||
}
|
||||
|
||||
let mut candidate = input(Some(&checkpoint));
|
||||
candidate.watcher_status = EpiphanyReorientFreshnessStatus::Unknown;
|
||||
let (_, decision) = recommend_reorientation(candidate);
|
||||
assert_eq!(decision.action, EpiphanyReorientAction::Resume);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_state_regathers() {
|
||||
let mut input = input(None);
|
||||
input.state_present = false;
|
||||
input.pressure_level = EpiphanyReorientPressureLevel::High;
|
||||
|
||||
let (state_status, decision) = recommend_reorientation(input);
|
||||
|
||||
assert_eq!(state_status, EpiphanyReorientStateStatus::Missing);
|
||||
assert_eq!(decision.action, EpiphanyReorientAction::Regather);
|
||||
assert!(
|
||||
decision
|
||||
.reasons
|
||||
.contains(&EpiphanyReorientReason::MissingState)
|
||||
);
|
||||
assert!(decision.note.contains("high"));
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,28 +1,16 @@
|
|||
use epiphany_state_model::EpiphanyChurnState;
|
||||
use epiphany_state_model::EpiphanyCodeRef;
|
||||
use epiphany_state_model::EpiphanyEvidenceRecord;
|
||||
use epiphany_state_model::EpiphanyGraphCheckpoint;
|
||||
use epiphany_state_model::EpiphanyGraphFrontier;
|
||||
use epiphany_state_model::EpiphanyGraphs;
|
||||
use epiphany_state_model::EpiphanyInvariant;
|
||||
use epiphany_state_model::EpiphanyInvestigationCheckpoint;
|
||||
use epiphany_state_model::EpiphanyInvestigationDisposition;
|
||||
use epiphany_state_model::EpiphanyJobKind;
|
||||
use epiphany_state_model::EpiphanyObservation;
|
||||
use epiphany_state_model::EpiphanyPlanningState;
|
||||
use epiphany_state_model::EpiphanyScratchPad;
|
||||
use epiphany_state_model::EpiphanySubgoal;
|
||||
use epiphany_state_model::EpiphanyThreadState;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use std::path::Path;
|
||||
|
||||
use crate::EpiphanyJobLaunchRequest;
|
||||
use crate::EpiphanyReorientAction;
|
||||
use crate::EpiphanyReorientDecision;
|
||||
use crate::EpiphanyReorientFreshnessStatus;
|
||||
use crate::EpiphanyReorientPressureLevel;
|
||||
use crate::EpiphanyReorientReason;
|
||||
|
||||
pub const ROLE_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.role_result.v3";
|
||||
pub const REORIENT_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.reorient_result.v0";
|
||||
|
|
@ -80,14 +68,14 @@ impl EpiphanyWorkerLaunchDocument {
|
|||
pub fn thread_id(&self) -> &str {
|
||||
match self {
|
||||
Self::Role(document) => &document.thread_id,
|
||||
Self::Reorient(document) => &document.thread_id,
|
||||
Self::Reorient(document) => &document.creation_thread_id,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dynamic_prompt_context(&self) -> Option<&str> {
|
||||
match self {
|
||||
Self::Role(document) => document.dynamic_prompt_context.as_deref(),
|
||||
Self::Reorient(document) => document.dynamic_prompt_context.as_deref(),
|
||||
Self::Reorient(_) => None,
|
||||
}
|
||||
.map(str::trim)
|
||||
.filter(|context| !context.is_empty())
|
||||
|
|
@ -188,62 +176,9 @@ impl From<&crate::RepoFrontierResearchRequest> for RepoFrontierResearchContextPr
|
|||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EpiphanyReorientWorkerLaunchDocument {
|
||||
pub thread_id: String,
|
||||
pub mode: String,
|
||||
pub checkpoint_id: String,
|
||||
pub checkpoint_kind: String,
|
||||
pub checkpoint_disposition: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub dynamic_prompt_context: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub checkpoint_focus: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub checkpoint_summary: Option<String>,
|
||||
pub checkpoint_next_action: String,
|
||||
#[serde(default)]
|
||||
pub checkpoint_open_questions: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub checkpoint_evidence_ids: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub checkpoint_code_refs: Vec<EpiphanyCodeRef>,
|
||||
#[serde(default)]
|
||||
pub decision_reasons: Vec<String>,
|
||||
pub decision_note: String,
|
||||
pub pressure_level: String,
|
||||
pub retrieval_status: String,
|
||||
pub graph_status: String,
|
||||
pub watcher_status: String,
|
||||
#[serde(default)]
|
||||
pub checkpoint_dirty_paths: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub checkpoint_changed_paths: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub scratch: Option<EpiphanyScratchPad>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub graphs: Option<EpiphanyGraphs>,
|
||||
#[serde(default)]
|
||||
pub recent_evidence: Vec<EpiphanyEvidenceRecord>,
|
||||
#[serde(default)]
|
||||
pub recent_observations: Vec<EpiphanyObservation>,
|
||||
#[serde(default)]
|
||||
pub active_frontier_node_ids: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub linked_subgoal_ids: Vec<String>,
|
||||
#[serde(default)]
|
||||
pub linked_graph_node_ids: Vec<String>,
|
||||
}
|
||||
|
||||
pub struct EpiphanyReorientLaunchRequestInput<'a> {
|
||||
pub thread_id: &'a str,
|
||||
pub expected_revision: Option<u64>,
|
||||
pub max_runtime_seconds: Option<u64>,
|
||||
pub binding_id: &'a str,
|
||||
pub owner_role: &'a str,
|
||||
pub instruction: String,
|
||||
pub state: &'a EpiphanyThreadState,
|
||||
pub checkpoint: &'a EpiphanyInvestigationCheckpoint,
|
||||
pub decision: &'a EpiphanyReorientDecision,
|
||||
pub dynamic_prompt_context: Option<String>,
|
||||
pub schema_version: String,
|
||||
pub request_id: String,
|
||||
pub creation_thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
@ -402,301 +337,3 @@ impl RepoFrontierPlanMindContextProjection {
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_reorient_job_launch_request(
|
||||
input: EpiphanyReorientLaunchRequestInput<'_>,
|
||||
) -> EpiphanyJobLaunchRequest {
|
||||
let linked_subgoal_ids = active_subgoal_ids(input.state);
|
||||
let linked_graph_node_ids = unique_strings(
|
||||
active_graph_node_ids(input.state)
|
||||
.into_iter()
|
||||
.chain(input.decision.active_frontier_node_ids.iter().cloned()),
|
||||
);
|
||||
let launch_document =
|
||||
EpiphanyWorkerLaunchDocument::Reorient(build_reorient_worker_launch_document(
|
||||
input.thread_id,
|
||||
input.state,
|
||||
input.checkpoint,
|
||||
input.decision,
|
||||
linked_subgoal_ids.clone(),
|
||||
linked_graph_node_ids.clone(),
|
||||
input.dynamic_prompt_context,
|
||||
));
|
||||
let output_contract_id = launch_document.output_contract_id().to_string();
|
||||
let organ_launch_contract = crate::default_launch_organ_contract(
|
||||
reorient_launch_authority_scope(input.decision.action),
|
||||
launch_document.document_kind(),
|
||||
&output_contract_id,
|
||||
);
|
||||
|
||||
EpiphanyJobLaunchRequest {
|
||||
expected_revision: input.expected_revision,
|
||||
binding_id: input.binding_id.to_string(),
|
||||
kind: EpiphanyJobKind::Specialist,
|
||||
scope: reorient_launch_scope(input.decision.action).to_string(),
|
||||
owner_role: input.owner_role.to_string(),
|
||||
authority_scope: reorient_launch_authority_scope(input.decision.action).to_string(),
|
||||
linked_subgoal_ids,
|
||||
linked_graph_node_ids,
|
||||
instruction: input.instruction,
|
||||
launch_document,
|
||||
output_contract_id,
|
||||
organ_launch_contract,
|
||||
max_runtime_seconds: input.max_runtime_seconds,
|
||||
proposal_modeling_request_id: None,
|
||||
frontier_planning_request_id: None,
|
||||
frontier_plan_mind_request_id: None,
|
||||
imagination_consideration_request_id: None,
|
||||
admitted_model_direction_consideration_request_id: None,
|
||||
repo_frontier_modeling_request_id: None,
|
||||
repo_frontier_research_request_id: None,
|
||||
repo_frontier_verification_request_id: None,
|
||||
}
|
||||
}
|
||||
|
||||
fn build_reorient_worker_launch_document(
|
||||
thread_id: &str,
|
||||
state: &EpiphanyThreadState,
|
||||
checkpoint: &EpiphanyInvestigationCheckpoint,
|
||||
decision: &EpiphanyReorientDecision,
|
||||
linked_subgoal_ids: Vec<String>,
|
||||
linked_graph_node_ids: Vec<String>,
|
||||
dynamic_prompt_context: Option<String>,
|
||||
) -> EpiphanyReorientWorkerLaunchDocument {
|
||||
EpiphanyReorientWorkerLaunchDocument {
|
||||
thread_id: thread_id.to_string(),
|
||||
mode: reorient_action_label(decision.action).to_string(),
|
||||
checkpoint_id: checkpoint.checkpoint_id.clone(),
|
||||
checkpoint_kind: checkpoint.kind.clone(),
|
||||
checkpoint_disposition: investigation_disposition_label(checkpoint.disposition).to_string(),
|
||||
dynamic_prompt_context,
|
||||
checkpoint_focus: Some(checkpoint.focus.clone()),
|
||||
checkpoint_summary: checkpoint.summary.clone(),
|
||||
checkpoint_next_action: checkpoint
|
||||
.next_action
|
||||
.clone()
|
||||
.unwrap_or_else(|| decision.next_action.clone()),
|
||||
checkpoint_open_questions: checkpoint.open_questions.clone(),
|
||||
checkpoint_evidence_ids: checkpoint.evidence_ids.clone(),
|
||||
checkpoint_code_refs: checkpoint.code_refs.clone(),
|
||||
decision_reasons: decision
|
||||
.reasons
|
||||
.iter()
|
||||
.map(|reason| reorient_reason_label(*reason).to_string())
|
||||
.collect(),
|
||||
decision_note: decision.note.clone(),
|
||||
pressure_level: reorient_pressure_level_label(decision.pressure_level).to_string(),
|
||||
retrieval_status: reorient_freshness_status_label(decision.retrieval_status).to_string(),
|
||||
graph_status: reorient_freshness_status_label(decision.graph_status).to_string(),
|
||||
watcher_status: reorient_freshness_status_label(decision.watcher_status).to_string(),
|
||||
checkpoint_dirty_paths: decision
|
||||
.checkpoint_dirty_paths
|
||||
.iter()
|
||||
.map(path_to_display_string)
|
||||
.collect(),
|
||||
checkpoint_changed_paths: decision
|
||||
.checkpoint_changed_paths
|
||||
.iter()
|
||||
.map(path_to_display_string)
|
||||
.collect(),
|
||||
scratch: state.scratch.clone(),
|
||||
graphs: Some(state.graphs.clone()),
|
||||
recent_evidence: state.recent_evidence.iter().take(8).cloned().collect(),
|
||||
recent_observations: state.observations.iter().take(8).cloned().collect(),
|
||||
active_frontier_node_ids: decision.active_frontier_node_ids.clone(),
|
||||
linked_subgoal_ids,
|
||||
linked_graph_node_ids,
|
||||
}
|
||||
}
|
||||
|
||||
fn active_subgoal_ids(state: &EpiphanyThreadState) -> Vec<String> {
|
||||
state
|
||||
.active_subgoal_id
|
||||
.clone()
|
||||
.map(|id| vec![id])
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn active_graph_node_ids(state: &EpiphanyThreadState) -> Vec<String> {
|
||||
state
|
||||
.graph_frontier
|
||||
.as_ref()
|
||||
.map(|frontier| frontier.active_node_ids.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn unique_strings(values: impl IntoIterator<Item = String>) -> Vec<String> {
|
||||
let mut unique = Vec::new();
|
||||
for value in values {
|
||||
if !unique.iter().any(|existing| existing == &value) {
|
||||
unique.push(value);
|
||||
}
|
||||
}
|
||||
unique
|
||||
}
|
||||
|
||||
fn path_to_display_string(path: impl AsRef<Path>) -> String {
|
||||
path.as_ref().to_string_lossy().to_string()
|
||||
}
|
||||
|
||||
fn reorient_launch_authority_scope(action: EpiphanyReorientAction) -> &'static str {
|
||||
match action {
|
||||
EpiphanyReorientAction::Resume => "epiphany.reorient.resume",
|
||||
EpiphanyReorientAction::Regather => "epiphany.reorient.regather",
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_launch_scope(action: EpiphanyReorientAction) -> &'static str {
|
||||
match action {
|
||||
EpiphanyReorientAction::Resume => "reorient-guided checkpoint resume",
|
||||
EpiphanyReorientAction::Regather => "reorient-guided checkpoint regather",
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_action_label(action: EpiphanyReorientAction) -> &'static str {
|
||||
match action {
|
||||
EpiphanyReorientAction::Resume => "resume",
|
||||
EpiphanyReorientAction::Regather => "regather",
|
||||
}
|
||||
}
|
||||
|
||||
fn investigation_disposition_label(disposition: EpiphanyInvestigationDisposition) -> &'static str {
|
||||
match disposition {
|
||||
EpiphanyInvestigationDisposition::ResumeReady => "resume_ready",
|
||||
EpiphanyInvestigationDisposition::RegatherRequired => "regather_required",
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_reason_label(reason: EpiphanyReorientReason) -> &'static str {
|
||||
match reason {
|
||||
EpiphanyReorientReason::MissingState => "missingState",
|
||||
EpiphanyReorientReason::MissingCheckpoint => "missingCheckpoint",
|
||||
EpiphanyReorientReason::CheckpointRequestedRegather => "checkpointRequestedRegather",
|
||||
EpiphanyReorientReason::CheckpointPathsDirty => "checkpointPathsDirty",
|
||||
EpiphanyReorientReason::CheckpointPathsChanged => "checkpointPathsChanged",
|
||||
EpiphanyReorientReason::FrontierChanged => "frontierChanged",
|
||||
EpiphanyReorientReason::UnanchoredCheckpointWhileStateStale => {
|
||||
"unanchoredCheckpointWhileStateStale"
|
||||
}
|
||||
EpiphanyReorientReason::RetrievalFreshnessBlocked => "retrievalFreshnessBlocked",
|
||||
EpiphanyReorientReason::GraphFreshnessBlocked => "graphFreshnessBlocked",
|
||||
EpiphanyReorientReason::WatcherFreshnessBlocked => "watcherFreshnessBlocked",
|
||||
EpiphanyReorientReason::CheckpointReady => "checkpointReady",
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_pressure_level_label(level: EpiphanyReorientPressureLevel) -> &'static str {
|
||||
match level {
|
||||
EpiphanyReorientPressureLevel::Unknown => "unknown",
|
||||
EpiphanyReorientPressureLevel::Low => "low",
|
||||
EpiphanyReorientPressureLevel::Medium => "medium",
|
||||
EpiphanyReorientPressureLevel::High => "high",
|
||||
EpiphanyReorientPressureLevel::Critical => "critical",
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_freshness_status_label(status: EpiphanyReorientFreshnessStatus) -> &'static str {
|
||||
match status {
|
||||
EpiphanyReorientFreshnessStatus::Unknown => "unknown",
|
||||
EpiphanyReorientFreshnessStatus::Clean => "clean",
|
||||
EpiphanyReorientFreshnessStatus::Dirty => "dirty",
|
||||
EpiphanyReorientFreshnessStatus::Stale => "stale",
|
||||
EpiphanyReorientFreshnessStatus::Changed => "changed",
|
||||
}
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use epiphany_state_model::EpiphanyCodeRef;
|
||||
use epiphany_state_model::EpiphanyGraphFrontier;
|
||||
use std::path::PathBuf;
|
||||
|
||||
#[test]
|
||||
fn reorient_launch_request_is_composed_from_typed_state() {
|
||||
let state = EpiphanyThreadState {
|
||||
revision: 7,
|
||||
active_subgoal_id: Some("sg-1".to_string()),
|
||||
graph_frontier: Some(EpiphanyGraphFrontier {
|
||||
active_node_ids: vec!["node-a".to_string()],
|
||||
active_edge_ids: Vec::new(),
|
||||
open_question_ids: Vec::new(),
|
||||
open_gap_ids: Vec::new(),
|
||||
dirty_paths: Vec::new(),
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
let checkpoint = EpiphanyInvestigationCheckpoint {
|
||||
checkpoint_id: "ix-1".to_string(),
|
||||
kind: "implementation".to_string(),
|
||||
disposition: EpiphanyInvestigationDisposition::RegatherRequired,
|
||||
focus: "runtime seam".to_string(),
|
||||
summary: Some("resume here".to_string()),
|
||||
next_action: None,
|
||||
captured_at_turn_id: Some("turn-1".to_string()),
|
||||
open_questions: Vec::new(),
|
||||
code_refs: vec![EpiphanyCodeRef {
|
||||
path: PathBuf::from("src/lib.rs"),
|
||||
start_line: None,
|
||||
end_line: None,
|
||||
symbol: None,
|
||||
note: None,
|
||||
}],
|
||||
evidence_ids: vec!["ev-1".to_string()],
|
||||
};
|
||||
let decision = EpiphanyReorientDecision {
|
||||
action: EpiphanyReorientAction::Regather,
|
||||
checkpoint_status: crate::EpiphanyReorientCheckpointStatus::RegatherRequired,
|
||||
checkpoint_id: Some("ix-1".to_string()),
|
||||
pressure_level: EpiphanyReorientPressureLevel::High,
|
||||
retrieval_status: EpiphanyReorientFreshnessStatus::Stale,
|
||||
graph_status: EpiphanyReorientFreshnessStatus::Changed,
|
||||
watcher_status: EpiphanyReorientFreshnessStatus::Dirty,
|
||||
reasons: vec![EpiphanyReorientReason::FrontierChanged],
|
||||
checkpoint_dirty_paths: vec![PathBuf::from("src/lib.rs")],
|
||||
checkpoint_changed_paths: vec![PathBuf::from("src/main.rs")],
|
||||
active_frontier_node_ids: vec!["node-b".to_string()],
|
||||
next_action: "Regather the seam.".to_string(),
|
||||
note: "continuity moved".to_string(),
|
||||
};
|
||||
|
||||
let request = build_reorient_job_launch_request(EpiphanyReorientLaunchRequestInput {
|
||||
thread_id: "thread-1",
|
||||
expected_revision: Some(state.revision),
|
||||
max_runtime_seconds: Some(60),
|
||||
binding_id: "reorient-worker",
|
||||
owner_role: "epiphany-reorient",
|
||||
instruction: "do the reorientation".to_string(),
|
||||
state: &state,
|
||||
checkpoint: &checkpoint,
|
||||
decision: &decision,
|
||||
dynamic_prompt_context: Some(
|
||||
"<epiphany_dynamic_context>\ncheckpoint weather\n</epiphany_dynamic_context>"
|
||||
.to_string(),
|
||||
),
|
||||
});
|
||||
|
||||
assert_eq!(request.binding_id, "reorient-worker");
|
||||
assert_eq!(request.scope, "reorient-guided checkpoint regather");
|
||||
assert_eq!(request.authority_scope, "epiphany.reorient.regather");
|
||||
assert_eq!(request.linked_subgoal_ids, vec!["sg-1"]);
|
||||
assert_eq!(
|
||||
request.linked_graph_node_ids,
|
||||
vec!["node-a".to_string(), "node-b".to_string()]
|
||||
);
|
||||
let EpiphanyWorkerLaunchDocument::Reorient(document) = request.launch_document else {
|
||||
panic!("expected reorient launch document");
|
||||
};
|
||||
assert_eq!(document.mode, "regather");
|
||||
assert_eq!(document.checkpoint_next_action, "Regather the seam.");
|
||||
assert_eq!(document.decision_reasons, vec!["frontierChanged"]);
|
||||
assert_eq!(document.pressure_level, "high");
|
||||
assert_eq!(document.retrieval_status, "stale");
|
||||
assert_eq!(document.graph_status, "changed");
|
||||
assert_eq!(document.watcher_status, "dirty");
|
||||
assert_eq!(
|
||||
document.dynamic_prompt_context.as_deref(),
|
||||
Some("<epiphany_dynamic_context>\ncheckpoint weather\n</epiphany_dynamic_context>")
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue