Type Epiphany worker launch cargo

This commit is contained in:
Meta Vens 2026-05-12 23:06:58 +01:00
commit 71d14ba245
9 changed files with 335 additions and 136 deletions

View file

@ -190,6 +190,7 @@ pub use surfaces::EpiphanyReorientInput;
pub use surfaces::EpiphanyReorientPressureLevel;
pub use surfaces::EpiphanyReorientReason;
pub use surfaces::EpiphanyReorientStateStatus;
pub use surfaces::EpiphanyReorientWorkerLaunchDocument;
pub use surfaces::EpiphanyRetrievalFreshness;
pub use surfaces::EpiphanyRetrievalFreshnessStatus;
pub use surfaces::EpiphanyRoleAcceptanceFinding;
@ -203,6 +204,7 @@ pub use surfaces::EpiphanyRoleFindingInterpretation;
pub use surfaces::EpiphanyRoleResultRoleId;
pub use surfaces::EpiphanyRoleSelfPersistenceReview;
pub use surfaces::EpiphanyRoleSelfPersistenceStatus;
pub use surfaces::EpiphanyRoleWorkerLaunchDocument;
pub use surfaces::EpiphanyScene;
pub use surfaces::EpiphanySceneAction;
pub use surfaces::EpiphanySceneChurn;
@ -216,6 +218,9 @@ pub use surfaces::EpiphanySceneSource;
pub use surfaces::EpiphanySceneStateStatus;
pub use surfaces::EpiphanySceneStatusCount;
pub use surfaces::EpiphanySceneSubgoal;
pub use surfaces::EpiphanyWorkerLaunchDocument;
pub use surfaces::REORIENT_WORKER_OUTPUT_CONTRACT_ID;
pub use surfaces::ROLE_WORKER_OUTPUT_CONTRACT_ID;
pub use surfaces::build_reorient_acceptance_bundle;
pub use surfaces::build_role_acceptance_bundle;
pub use surfaces::coordinator_automation_action;

View file

@ -9,6 +9,7 @@ mod reorient;
mod role_board;
mod role_result;
mod scene;
mod worker_launch;
pub use coordinator::EpiphanyCoordinatorAction;
pub use coordinator::EpiphanyCoordinatorAutomationAction;
@ -120,3 +121,8 @@ pub use scene::EpiphanySceneStateStatus;
pub use scene::EpiphanySceneStatusCount;
pub use scene::EpiphanySceneSubgoal;
pub use scene::derive_scene;
pub use worker_launch::EpiphanyReorientWorkerLaunchDocument;
pub use worker_launch::EpiphanyRoleWorkerLaunchDocument;
pub use worker_launch::EpiphanyWorkerLaunchDocument;
pub use worker_launch::REORIENT_WORKER_OUTPUT_CONTRACT_ID;
pub use worker_launch::ROLE_WORKER_OUTPUT_CONTRACT_ID;

View file

@ -0,0 +1,122 @@
use codex_protocol::protocol::EpiphanyChurnState;
use codex_protocol::protocol::EpiphanyCodeRef;
use codex_protocol::protocol::EpiphanyEvidenceRecord;
use codex_protocol::protocol::EpiphanyGraphCheckpoint;
use codex_protocol::protocol::EpiphanyGraphFrontier;
use codex_protocol::protocol::EpiphanyGraphs;
use codex_protocol::protocol::EpiphanyInvariant;
use codex_protocol::protocol::EpiphanyInvestigationCheckpoint;
use codex_protocol::protocol::EpiphanyObservation;
use codex_protocol::protocol::EpiphanyPlanningState;
use codex_protocol::protocol::EpiphanyScratchPad;
use codex_protocol::protocol::EpiphanySubgoal;
use serde::Deserialize;
use serde::Serialize;
pub const ROLE_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.role_result.v0";
pub const REORIENT_WORKER_OUTPUT_CONTRACT_ID: &str = "epiphany.worker.reorient_result.v0";
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase", tag = "documentKind")]
pub enum EpiphanyWorkerLaunchDocument {
Role(EpiphanyRoleWorkerLaunchDocument),
Reorient(EpiphanyReorientWorkerLaunchDocument),
}
impl EpiphanyWorkerLaunchDocument {
pub fn output_contract_id(&self) -> &'static str {
match self {
Self::Role(_) => ROLE_WORKER_OUTPUT_CONTRACT_ID,
Self::Reorient(_) => REORIENT_WORKER_OUTPUT_CONTRACT_ID,
}
}
pub fn thread_id(&self) -> &str {
match self {
Self::Role(document) => &document.thread_id,
Self::Reorient(document) => &document.thread_id,
}
}
}
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyRoleWorkerLaunchDocument {
pub thread_id: String,
pub role_id: String,
pub state_revision: u64,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub objective: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub active_subgoal_id: Option<String>,
#[serde(default)]
pub active_subgoals: Vec<EpiphanySubgoal>,
#[serde(default)]
pub active_graph_node_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub investigation_checkpoint: Option<EpiphanyInvestigationCheckpoint>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub scratch: Option<EpiphanyScratchPad>,
#[serde(default)]
pub invariants: Vec<EpiphanyInvariant>,
#[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, skip_serializing_if = "Option::is_none")]
pub graph_frontier: Option<EpiphanyGraphFrontier>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub graph_checkpoint: Option<EpiphanyGraphCheckpoint>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub planning: Option<EpiphanyPlanningState>,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub churn: Option<EpiphanyChurnState>,
}
#[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 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>,
}