Delete counterfeit job projection
This commit is contained in:
parent
59c5e3a633
commit
7c9b0cf385
5 changed files with 3 additions and 341 deletions
|
|
@ -2,12 +2,11 @@ use anyhow::{Context, Result, anyhow};
|
|||
use epiphany_core::{
|
||||
EpiphanyAgentPassContinuationAction, EpiphanyCoordinatorStatus, EpiphanyCoordinatorStatusInput,
|
||||
EpiphanyCrrcAction, EpiphanyCrrcRecommendation, EpiphanyCrrcResultStatus,
|
||||
EpiphanyCrrcSceneAction, EpiphanyCurrentWorkProjection, EpiphanyJobsInput,
|
||||
EpiphanyReorientAction, EpiphanyRoleBoardInput, EpiphanyRoleBoardJob,
|
||||
EpiphanyRoleBoardJobStatus, EpiphanyRoleResultRoleId, EpiphanyRuntimeJobStatus,
|
||||
EpiphanyCrrcSceneAction, EpiphanyCurrentWorkProjection, EpiphanyReorientAction,
|
||||
EpiphanyRoleBoardInput, EpiphanyRoleResultRoleId, EpiphanyRuntimeJobStatus,
|
||||
EpiphanySceneInput, EpiphanyTokenUsageSnapshot, RepoFrontierPlanningLifecycle,
|
||||
RepoFrontierPlanningLifecycleStage, RepoFrontierResearchLifecycle,
|
||||
RepoFrontierResearchLifecycleStage, derive_jobs, derive_planning_view, derive_pressure_view,
|
||||
RepoFrontierResearchLifecycleStage, derive_planning_view, derive_pressure_view,
|
||||
derive_role_board, derive_scene, runtime_job_snapshot,
|
||||
};
|
||||
use epiphany_self_policy::derive_coordinator_status;
|
||||
|
|
@ -148,23 +147,9 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
reorientation_work_present: reorientation_work.is_some(),
|
||||
});
|
||||
let planning = derive_planning_view(mind.as_ref());
|
||||
let jobs = derive_jobs(EpiphanyJobsInput {
|
||||
mind: mind.as_ref(),
|
||||
});
|
||||
let role_jobs = jobs
|
||||
.iter()
|
||||
.map(|job| EpiphanyRoleBoardJob {
|
||||
id: job.id.clone(),
|
||||
owner_role: job.owner_role.clone(),
|
||||
status: role_job_status(job.status),
|
||||
progress_note: job.progress_note.clone(),
|
||||
blocking_reason: job.blocking_reason.clone(),
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
let roles = derive_role_board(EpiphanyRoleBoardInput {
|
||||
mind_present: mind.is_some(),
|
||||
current_work: current_work.clone(),
|
||||
jobs: role_jobs,
|
||||
});
|
||||
let coordinator = derive_coordinator_status(EpiphanyCoordinatorStatusInput {
|
||||
mind_present: mind.is_some(),
|
||||
|
|
@ -260,7 +245,6 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
"authority": "keyedMindCurrentWork",
|
||||
},
|
||||
},
|
||||
"jobs": {"threadId": thread_id, "source": "native", "jobs": jobs},
|
||||
"roles": {"threadId": thread_id, "source": "native", "roles": roles},
|
||||
"planning": planning,
|
||||
"currentWork": current_work,
|
||||
|
|
@ -458,20 +442,6 @@ fn coordinator_status_json(status: &EpiphanyCoordinatorStatus) -> Result<Value>
|
|||
Ok(value)
|
||||
}
|
||||
|
||||
fn role_job_status(status: epiphany_core::EpiphanyJobStatus) -> EpiphanyRoleBoardJobStatus {
|
||||
match status {
|
||||
epiphany_core::EpiphanyJobStatus::Idle => EpiphanyRoleBoardJobStatus::Idle,
|
||||
epiphany_core::EpiphanyJobStatus::Needed => EpiphanyRoleBoardJobStatus::Needed,
|
||||
epiphany_core::EpiphanyJobStatus::Pending => EpiphanyRoleBoardJobStatus::Pending,
|
||||
epiphany_core::EpiphanyJobStatus::Running => EpiphanyRoleBoardJobStatus::Running,
|
||||
epiphany_core::EpiphanyJobStatus::Completed => EpiphanyRoleBoardJobStatus::Completed,
|
||||
epiphany_core::EpiphanyJobStatus::Failed => EpiphanyRoleBoardJobStatus::Failed,
|
||||
epiphany_core::EpiphanyJobStatus::Cancelled => EpiphanyRoleBoardJobStatus::Cancelled,
|
||||
epiphany_core::EpiphanyJobStatus::Blocked => EpiphanyRoleBoardJobStatus::Blocked,
|
||||
epiphany_core::EpiphanyJobStatus::Unavailable => EpiphanyRoleBoardJobStatus::Unavailable,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_status(status: &Value) -> String {
|
||||
let read = &status["read"];
|
||||
let coordinator = &status["coordinator"];
|
||||
|
|
|
|||
|
|
@ -672,9 +672,6 @@ pub use surfaces::EpiphanyCrrcReorientAction;
|
|||
pub use surfaces::EpiphanyCrrcResultStatus;
|
||||
pub use surfaces::EpiphanyCrrcSceneAction;
|
||||
pub use surfaces::EpiphanyCrrcStateStatus;
|
||||
pub use surfaces::EpiphanyJobStatus;
|
||||
pub use surfaces::EpiphanyJobView;
|
||||
pub use surfaces::EpiphanyJobsInput;
|
||||
pub use surfaces::EpiphanyPlanningStateStatus;
|
||||
pub use surfaces::EpiphanyPlanningSummary;
|
||||
pub use surfaces::EpiphanyPlanningView;
|
||||
|
|
@ -687,8 +684,6 @@ pub use surfaces::EpiphanyReorientFindingInterpretation;
|
|||
pub use surfaces::EpiphanyReorientWorkerLaunchDocument;
|
||||
pub use surfaces::EpiphanyResearchDecision;
|
||||
pub use surfaces::EpiphanyRoleBoardInput;
|
||||
pub use surfaces::EpiphanyRoleBoardJob;
|
||||
pub use surfaces::EpiphanyRoleBoardJobStatus;
|
||||
pub use surfaces::EpiphanyRoleBoardLane;
|
||||
pub use surfaces::EpiphanyRoleFindingInterpretation;
|
||||
pub use surfaces::EpiphanyRoleResultRoleId;
|
||||
|
|
@ -726,7 +721,6 @@ pub use surfaces::RepoFrontierPlanningContextProjection;
|
|||
pub use surfaces::RepoFrontierProposalModelingContextProjection;
|
||||
pub use surfaces::RepoFrontierResearchContextProjection;
|
||||
pub use surfaces::RepoFrontierVerificationContextProjection;
|
||||
pub use surfaces::derive_jobs;
|
||||
pub use surfaces::derive_planning_view;
|
||||
pub use surfaces::derive_pressure_view;
|
||||
pub use surfaces::derive_role_board;
|
||||
|
|
@ -734,8 +728,6 @@ pub use surfaces::derive_scene;
|
|||
pub use surfaces::interpret_runtime_reorient_worker_result;
|
||||
pub use surfaces::interpret_runtime_role_worker_result;
|
||||
pub use surfaces::recommend_coordinator_action;
|
||||
pub use surfaces::render_role_board_note;
|
||||
pub use surfaces::role_board_job_status_to_role_status;
|
||||
pub use weksa_interlingua::WEKSA_INTERLINGUA_PACKET_SCHEMA_VERSION;
|
||||
pub use weksa_interlingua::WEKSA_TARGET_LOWERING_RECEIPT_SCHEMA_VERSION;
|
||||
pub use weksa_interlingua::WEKSA_TARGET_LOWERING_REQUEST_SCHEMA_VERSION;
|
||||
|
|
|
|||
|
|
@ -1,223 +0,0 @@
|
|||
use epiphany_state_model::EpiphanyJobKind;
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyJobStatus {
|
||||
Idle,
|
||||
Needed,
|
||||
Pending,
|
||||
Running,
|
||||
Completed,
|
||||
Failed,
|
||||
Cancelled,
|
||||
Blocked,
|
||||
Unavailable,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EpiphanyJobView {
|
||||
pub id: String,
|
||||
pub kind: EpiphanyJobKind,
|
||||
pub scope: String,
|
||||
pub owner_role: String,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub authority_scope: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub runtime_job_id: Option<String>,
|
||||
pub status: EpiphanyJobStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub items_processed: Option<u32>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub items_total: Option<u32>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub progress_note: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub last_checkpoint_at_unix_seconds: Option<i64>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub blocking_reason: Option<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub active_thread_ids: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub linked_subgoal_ids: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub linked_graph_node_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Copy)]
|
||||
pub struct EpiphanyJobsInput<'a> {
|
||||
pub mind: Option<&'a crate::EpiphanyMindView>,
|
||||
}
|
||||
|
||||
pub fn derive_jobs(input: EpiphanyJobsInput<'_>) -> Vec<EpiphanyJobView> {
|
||||
vec![
|
||||
body_observation_job(input.mind),
|
||||
repo_model_job(input.mind),
|
||||
verification_job(input.mind),
|
||||
]
|
||||
}
|
||||
|
||||
fn base_job(
|
||||
id: &str,
|
||||
kind: EpiphanyJobKind,
|
||||
scope: &str,
|
||||
owner_role: &str,
|
||||
status: EpiphanyJobStatus,
|
||||
) -> EpiphanyJobView {
|
||||
EpiphanyJobView {
|
||||
id: id.into(),
|
||||
kind,
|
||||
scope: scope.into(),
|
||||
owner_role: owner_role.into(),
|
||||
authority_scope: None,
|
||||
runtime_job_id: None,
|
||||
status,
|
||||
items_processed: None,
|
||||
items_total: None,
|
||||
progress_note: None,
|
||||
last_checkpoint_at_unix_seconds: None,
|
||||
blocking_reason: None,
|
||||
active_thread_ids: Vec::new(),
|
||||
linked_subgoal_ids: Vec::new(),
|
||||
linked_graph_node_ids: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
fn body_observation_job(mind: Option<&crate::EpiphanyMindView>) -> EpiphanyJobView {
|
||||
let body = mind.and_then(|mind| mind.repository_body_observation.as_ref());
|
||||
let mut job = base_job(
|
||||
"repository-body-observation",
|
||||
EpiphanyJobKind::Indexing,
|
||||
"repository Body",
|
||||
"epiphany-body-observer",
|
||||
if body.is_some() {
|
||||
EpiphanyJobStatus::Completed
|
||||
} else {
|
||||
EpiphanyJobStatus::Needed
|
||||
},
|
||||
);
|
||||
job.linked_subgoal_ids = active_subgoal_ids(mind);
|
||||
job.progress_note = Some(match body {
|
||||
Some(body) => format!(
|
||||
"Mind contains exact Body observation {} at generation {}.",
|
||||
body.observation_id, body.generation
|
||||
),
|
||||
None => "Mind has no admitted repository Body observation.".into(),
|
||||
});
|
||||
job
|
||||
}
|
||||
|
||||
fn repo_model_job(mind: Option<&crate::EpiphanyMindView>) -> EpiphanyJobView {
|
||||
let model = mind.and_then(|mind| mind.repo_model.as_ref());
|
||||
let mut job = base_job(
|
||||
"repo-model",
|
||||
EpiphanyJobKind::Remap,
|
||||
"keyed RepoModel",
|
||||
"epiphany-modeling",
|
||||
if model.is_some() {
|
||||
EpiphanyJobStatus::Idle
|
||||
} else {
|
||||
EpiphanyJobStatus::Blocked
|
||||
},
|
||||
);
|
||||
job.linked_subgoal_ids = active_subgoal_ids(mind);
|
||||
job.linked_graph_node_ids = active_graph_node_ids(mind);
|
||||
job.progress_note = model.map(|model| {
|
||||
format!(
|
||||
"Keyed RepoModel projects {} node(s), {} edge(s), and {} frontier item(s).",
|
||||
model.nodes.len(),
|
||||
model.edges.len(),
|
||||
model.frontier.len()
|
||||
)
|
||||
});
|
||||
if model.is_none() {
|
||||
job.blocking_reason = Some("Mind has no keyed RepoModel identity.".into());
|
||||
}
|
||||
job
|
||||
}
|
||||
|
||||
fn verification_job(mind: Option<&crate::EpiphanyMindView>) -> EpiphanyJobView {
|
||||
let Some(mind) = mind else {
|
||||
let mut job = base_job(
|
||||
"verification",
|
||||
EpiphanyJobKind::Verification,
|
||||
"invariants/evidence",
|
||||
"epiphany-soul",
|
||||
EpiphanyJobStatus::Blocked,
|
||||
);
|
||||
job.blocking_reason = Some("Mind is missing.".into());
|
||||
return job;
|
||||
};
|
||||
let total = mind.invariants.len() as u32;
|
||||
let verified = mind
|
||||
.invariants
|
||||
.iter()
|
||||
.filter(|invariant| invariant_status_is_accepting(&invariant.status))
|
||||
.count() as u32;
|
||||
let mut job = base_job(
|
||||
"verification",
|
||||
EpiphanyJobKind::Verification,
|
||||
"invariants/evidence",
|
||||
"epiphany-soul",
|
||||
if total > verified {
|
||||
EpiphanyJobStatus::Needed
|
||||
} else {
|
||||
EpiphanyJobStatus::Idle
|
||||
},
|
||||
);
|
||||
job.items_processed = Some(verified);
|
||||
job.items_total = Some(total);
|
||||
job.linked_subgoal_ids = active_subgoal_ids(Some(mind));
|
||||
job.linked_graph_node_ids = active_graph_node_ids(Some(mind));
|
||||
job.progress_note = Some(format!("{verified} of {total} invariant(s) are accepting."));
|
||||
job
|
||||
}
|
||||
|
||||
fn active_subgoal_ids(mind: Option<&crate::EpiphanyMindView>) -> Vec<String> {
|
||||
mind.and_then(|mind| mind.active_subgoal_id.clone())
|
||||
.map(|id| vec![id])
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn active_graph_node_ids(mind: Option<&crate::EpiphanyMindView>) -> Vec<String> {
|
||||
let mut ids = mind
|
||||
.and_then(|mind| mind.repo_model.as_ref())
|
||||
.into_iter()
|
||||
.flat_map(|model| model.frontier.iter())
|
||||
.filter(|item| {
|
||||
matches!(
|
||||
item.status,
|
||||
epiphany_state_model::RepoFrontierStatus::Proposed
|
||||
| epiphany_state_model::RepoFrontierStatus::Active
|
||||
| epiphany_state_model::RepoFrontierStatus::Blocked
|
||||
)
|
||||
})
|
||||
.flat_map(|item| item.target_claim_ids.iter().cloned())
|
||||
.collect::<Vec<_>>();
|
||||
ids.sort();
|
||||
ids.dedup();
|
||||
ids
|
||||
}
|
||||
|
||||
fn invariant_status_is_accepting(status: &str) -> bool {
|
||||
matches!(
|
||||
status,
|
||||
"ok" | "ready" | "accepted" | "verified" | "pass" | "passed"
|
||||
)
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn missing_mind_has_only_derived_blocked_or_needed_jobs() {
|
||||
let jobs = derive_jobs(EpiphanyJobsInput { mind: None });
|
||||
assert_eq!(jobs.len(), 3);
|
||||
assert_eq!(jobs[0].status, EpiphanyJobStatus::Needed);
|
||||
assert_eq!(jobs[1].status, EpiphanyJobStatus::Blocked);
|
||||
assert_eq!(jobs[2].status, EpiphanyJobStatus::Blocked);
|
||||
assert!(jobs.iter().all(|job| job.runtime_job_id.is_none()));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,7 +1,6 @@
|
|||
mod coordinator_contract;
|
||||
mod coordinator_decision;
|
||||
mod crrc;
|
||||
mod jobs;
|
||||
mod planning;
|
||||
mod pressure;
|
||||
mod reorient;
|
||||
|
|
@ -19,10 +18,6 @@ pub use crrc::EpiphanyCrrcReorientAction;
|
|||
pub use crrc::EpiphanyCrrcResultStatus;
|
||||
pub use crrc::EpiphanyCrrcSceneAction;
|
||||
pub use crrc::EpiphanyCrrcStateStatus;
|
||||
pub use jobs::EpiphanyJobStatus;
|
||||
pub use jobs::EpiphanyJobView;
|
||||
pub use jobs::EpiphanyJobsInput;
|
||||
pub use jobs::derive_jobs;
|
||||
pub use planning::EpiphanyPlanningStateStatus;
|
||||
pub use planning::EpiphanyPlanningSummary;
|
||||
pub use planning::EpiphanyPlanningView;
|
||||
|
|
@ -36,12 +31,8 @@ pub use pressure::derive_pressure_view;
|
|||
pub use reorient::EpiphanyReorientAction;
|
||||
pub use research_decision::EpiphanyResearchDecision;
|
||||
pub use role_board::EpiphanyRoleBoardInput;
|
||||
pub use role_board::EpiphanyRoleBoardJob;
|
||||
pub use role_board::EpiphanyRoleBoardJobStatus;
|
||||
pub use role_board::EpiphanyRoleBoardLane;
|
||||
pub use role_board::derive_role_board;
|
||||
pub use role_board::render_role_board_note;
|
||||
pub use role_board::role_board_job_status_to_role_status;
|
||||
pub use role_result::EpiphanyReorientFindingInterpretation;
|
||||
pub use role_result::EpiphanyRoleFindingInterpretation;
|
||||
pub use role_result::EpiphanyRoleResultRoleId;
|
||||
|
|
|
|||
|
|
@ -7,35 +7,10 @@ use crate::{
|
|||
};
|
||||
use serde::{Deserialize, Serialize};
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub enum EpiphanyRoleBoardJobStatus {
|
||||
Idle,
|
||||
Needed,
|
||||
Pending,
|
||||
Running,
|
||||
Completed,
|
||||
Failed,
|
||||
Cancelled,
|
||||
Blocked,
|
||||
Unavailable,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
pub struct EpiphanyRoleBoardJob {
|
||||
pub id: String,
|
||||
pub owner_role: String,
|
||||
pub status: EpiphanyRoleBoardJobStatus,
|
||||
pub progress_note: Option<String>,
|
||||
pub blocking_reason: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct EpiphanyRoleBoardInput {
|
||||
pub mind_present: bool,
|
||||
pub current_work: EpiphanyCurrentWorkProjection,
|
||||
pub jobs: Vec<EpiphanyRoleBoardJob>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
|
|
@ -46,7 +21,6 @@ pub struct EpiphanyRoleBoardLane {
|
|||
pub owner_role: String,
|
||||
pub status: EpiphanyCoordinatorRoleStatus,
|
||||
pub note: String,
|
||||
pub jobs: Vec<EpiphanyRoleBoardJob>,
|
||||
pub authority_scopes: Vec<String>,
|
||||
pub recommended_action: Option<EpiphanyCoordinatorSceneAction>,
|
||||
}
|
||||
|
|
@ -69,12 +43,6 @@ pub fn derive_role_board(input: EpiphanyRoleBoardInput) -> Vec<EpiphanyRoleBoard
|
|||
} else {
|
||||
note.into()
|
||||
},
|
||||
jobs: input
|
||||
.jobs
|
||||
.iter()
|
||||
.filter(|job| job.owner_role == owner_role)
|
||||
.cloned()
|
||||
.collect(),
|
||||
authority_scopes: vec![scope.into()],
|
||||
recommended_action,
|
||||
}
|
||||
|
|
@ -278,39 +246,3 @@ fn planning_or_consideration_status(
|
|||
}
|
||||
continuation_status(consideration)
|
||||
}
|
||||
|
||||
pub fn role_board_job_status_to_role_status(
|
||||
status: EpiphanyRoleBoardJobStatus,
|
||||
) -> EpiphanyCoordinatorRoleStatus {
|
||||
match status {
|
||||
EpiphanyRoleBoardJobStatus::Idle => EpiphanyCoordinatorRoleStatus::Ready,
|
||||
EpiphanyRoleBoardJobStatus::Needed => EpiphanyCoordinatorRoleStatus::Needed,
|
||||
EpiphanyRoleBoardJobStatus::Pending | EpiphanyRoleBoardJobStatus::Running => {
|
||||
EpiphanyCoordinatorRoleStatus::Running
|
||||
}
|
||||
EpiphanyRoleBoardJobStatus::Completed => EpiphanyCoordinatorRoleStatus::Completed,
|
||||
EpiphanyRoleBoardJobStatus::Failed
|
||||
| EpiphanyRoleBoardJobStatus::Cancelled
|
||||
| EpiphanyRoleBoardJobStatus::Blocked => EpiphanyCoordinatorRoleStatus::Blocked,
|
||||
EpiphanyRoleBoardJobStatus::Unavailable => EpiphanyCoordinatorRoleStatus::Unavailable,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_role_board_note(
|
||||
roles: &[EpiphanyRoleBoardLane],
|
||||
state_status: &str,
|
||||
recommendation: crate::EpiphanyCrrcAction,
|
||||
) -> String {
|
||||
let active = roles
|
||||
.iter()
|
||||
.filter(|lane| {
|
||||
!matches!(
|
||||
lane.status,
|
||||
EpiphanyCoordinatorRoleStatus::Ready | EpiphanyCoordinatorRoleStatus::Completed
|
||||
)
|
||||
})
|
||||
.count();
|
||||
format!(
|
||||
"Mind {state_status}; {active} role lane(s) carry current work; continuity recommendation {recommendation:?}."
|
||||
)
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue