Move result projection to protocol edge
This commit is contained in:
parent
37791c3fc0
commit
d6d3d38375
9 changed files with 150 additions and 164 deletions
|
|
@ -1,7 +1,6 @@
|
|||
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedField;
|
||||
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedNotification;
|
||||
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource;
|
||||
use codex_app_server_protocol::ThreadEpiphanyUpdatePatch;
|
||||
use epiphany_core::EpiphanyReorientAcceptanceFinding;
|
||||
use epiphany_core::EpiphanyReorientFindingInterpretation as CoreEpiphanyReorientFinding;
|
||||
use epiphany_core::EpiphanyRoleAcceptanceFinding;
|
||||
|
|
@ -42,30 +41,6 @@ pub fn parse_core_role_finding_state_patch(
|
|||
.ok_or_else(|| "completed role finding did not include a reviewable statePatch".to_string())
|
||||
}
|
||||
|
||||
pub fn protocol_patch_from_core(
|
||||
patch: EpiphanyRoleStatePatchDocument,
|
||||
) -> ThreadEpiphanyUpdatePatch {
|
||||
ThreadEpiphanyUpdatePatch {
|
||||
objective: patch.objective,
|
||||
active_subgoal_id: patch.active_subgoal_id,
|
||||
subgoals: patch.subgoals,
|
||||
invariants: patch.invariants,
|
||||
graphs: patch.graphs,
|
||||
graph_frontier: patch.graph_frontier,
|
||||
graph_checkpoint: patch.graph_checkpoint,
|
||||
scratch: patch.scratch,
|
||||
investigation_checkpoint: patch.investigation_checkpoint,
|
||||
job_bindings: patch.job_bindings,
|
||||
acceptance_receipts: patch.acceptance_receipts,
|
||||
runtime_links: patch.runtime_links,
|
||||
observations: patch.observations,
|
||||
evidence: patch.evidence,
|
||||
churn: patch.churn,
|
||||
mode: patch.mode,
|
||||
planning: patch.planning,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn state_update_from_core_patch(
|
||||
expected_revision: Option<u64>,
|
||||
patch: EpiphanyRoleStatePatchDocument,
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ use codex_app_server_protocol::ThreadEpiphanyPressureStatus;
|
|||
use codex_app_server_protocol::ThreadEpiphanyReorientAction;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientCheckpointStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientDecision;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientFinding;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientReason;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientSource;
|
||||
|
|
@ -41,7 +42,11 @@ use codex_app_server_protocol::ThreadEpiphanyReorientStateStatus;
|
|||
use codex_app_server_protocol::ThreadEpiphanyReorientWorkerLaunchDocument;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRetrievalFreshness;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRetrievalFreshnessStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleFinding;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleId;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleResultStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleSelfPersistenceReview;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleSelfPersistenceStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleWorkerLaunchDocument;
|
||||
use codex_app_server_protocol::ThreadEpiphanyUpdatePatch;
|
||||
use codex_app_server_protocol::ThreadEpiphanyViewLens;
|
||||
|
|
@ -57,7 +62,12 @@ use epiphany_core::EpiphanyPressure;
|
|||
use epiphany_core::EpiphanyPressureBasis;
|
||||
use epiphany_core::EpiphanyPressureLevel;
|
||||
use epiphany_core::EpiphanyPressureStatus;
|
||||
use epiphany_core::EpiphanyReorientFindingInterpretation;
|
||||
use epiphany_core::EpiphanyReorientWorkerLaunchDocument;
|
||||
use epiphany_core::EpiphanyRoleFindingInterpretation;
|
||||
use epiphany_core::EpiphanyRoleResultRoleId;
|
||||
use epiphany_core::EpiphanyRoleSelfPersistenceReview;
|
||||
use epiphany_core::EpiphanyRoleSelfPersistenceStatus;
|
||||
use epiphany_core::EpiphanyRoleStatePatchDocument;
|
||||
use epiphany_core::EpiphanyRoleWorkerLaunchDocument;
|
||||
use epiphany_core::EpiphanyViewLens;
|
||||
|
|
@ -180,6 +190,103 @@ pub fn protocol_update_patch_to_core(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn protocol_patch_from_core(
|
||||
patch: EpiphanyRoleStatePatchDocument,
|
||||
) -> ThreadEpiphanyUpdatePatch {
|
||||
ThreadEpiphanyUpdatePatch {
|
||||
objective: patch.objective,
|
||||
active_subgoal_id: patch.active_subgoal_id,
|
||||
subgoals: patch.subgoals,
|
||||
invariants: patch.invariants,
|
||||
graphs: patch.graphs,
|
||||
graph_frontier: patch.graph_frontier,
|
||||
graph_checkpoint: patch.graph_checkpoint,
|
||||
scratch: patch.scratch,
|
||||
investigation_checkpoint: patch.investigation_checkpoint,
|
||||
job_bindings: patch.job_bindings,
|
||||
acceptance_receipts: patch.acceptance_receipts,
|
||||
runtime_links: patch.runtime_links,
|
||||
observations: patch.observations,
|
||||
evidence: patch.evidence,
|
||||
churn: patch.churn,
|
||||
mode: patch.mode,
|
||||
planning: patch.planning,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn protocol_role_id_to_core(role_id: ThreadEpiphanyRoleId) -> EpiphanyRoleResultRoleId {
|
||||
match role_id {
|
||||
ThreadEpiphanyRoleId::Implementation => EpiphanyRoleResultRoleId::Implementation,
|
||||
ThreadEpiphanyRoleId::Imagination => EpiphanyRoleResultRoleId::Imagination,
|
||||
ThreadEpiphanyRoleId::Modeling => EpiphanyRoleResultRoleId::Modeling,
|
||||
ThreadEpiphanyRoleId::Verification => EpiphanyRoleResultRoleId::Verification,
|
||||
ThreadEpiphanyRoleId::Reorientation => EpiphanyRoleResultRoleId::Reorientation,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn protocol_role_id_from_core(role_id: EpiphanyRoleResultRoleId) -> ThreadEpiphanyRoleId {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Implementation => ThreadEpiphanyRoleId::Implementation,
|
||||
EpiphanyRoleResultRoleId::Imagination => ThreadEpiphanyRoleId::Imagination,
|
||||
EpiphanyRoleResultRoleId::Modeling => ThreadEpiphanyRoleId::Modeling,
|
||||
EpiphanyRoleResultRoleId::Verification => ThreadEpiphanyRoleId::Verification,
|
||||
EpiphanyRoleResultRoleId::Reorientation => ThreadEpiphanyRoleId::Reorientation,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn protocol_reorient_finding(
|
||||
finding: EpiphanyReorientFindingInterpretation,
|
||||
) -> ThreadEpiphanyReorientFinding {
|
||||
ThreadEpiphanyReorientFinding {
|
||||
mode: finding.mode,
|
||||
summary: finding.summary,
|
||||
next_safe_move: finding.next_safe_move,
|
||||
checkpoint_still_valid: finding.checkpoint_still_valid,
|
||||
files_inspected: finding.files_inspected,
|
||||
frontier_node_ids: finding.frontier_node_ids,
|
||||
evidence_ids: finding.evidence_ids,
|
||||
artifact_refs: finding.artifact_refs,
|
||||
runtime_result_id: finding.runtime_result_id,
|
||||
runtime_job_id: finding.runtime_job_id,
|
||||
job_error: finding.job_error,
|
||||
item_error: finding.item_error,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn protocol_role_finding(
|
||||
role_id: ThreadEpiphanyRoleId,
|
||||
finding: EpiphanyRoleFindingInterpretation,
|
||||
) -> ThreadEpiphanyRoleFinding {
|
||||
let state_patch = finding.state_patch.map(protocol_patch_from_core);
|
||||
ThreadEpiphanyRoleFinding {
|
||||
role_id,
|
||||
verdict: finding.verdict,
|
||||
summary: finding.summary,
|
||||
next_safe_move: finding.next_safe_move,
|
||||
checkpoint_summary: finding.checkpoint_summary,
|
||||
scratch_summary: finding.scratch_summary,
|
||||
files_inspected: finding.files_inspected,
|
||||
frontier_node_ids: finding.frontier_node_ids,
|
||||
evidence_ids: finding.evidence_ids,
|
||||
artifact_refs: finding.artifact_refs,
|
||||
runtime_result_id: finding.runtime_result_id,
|
||||
runtime_job_id: finding.runtime_job_id,
|
||||
open_questions: finding.open_questions,
|
||||
evidence_gaps: finding.evidence_gaps,
|
||||
risks: finding.risks,
|
||||
state_patch,
|
||||
self_patch: finding.self_patch.map(|patch| {
|
||||
serde_json::to_value(patch)
|
||||
.expect("AgentSelfPatch is a serializable protocol projection")
|
||||
}),
|
||||
self_persistence: finding
|
||||
.self_persistence
|
||||
.map(protocol_self_persistence_review),
|
||||
job_error: finding.job_error,
|
||||
item_error: finding.item_error,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn protocol_freshness_response_from_surface(
|
||||
surface: EpiphanyFreshnessSurface,
|
||||
) -> ThreadEpiphanyFreshnessResponse {
|
||||
|
|
@ -581,3 +688,24 @@ fn protocol_reorient_reason(reason: EpiphanyReorientReason) -> ThreadEpiphanyReo
|
|||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn protocol_self_persistence_review(
|
||||
review: EpiphanyRoleSelfPersistenceReview,
|
||||
) -> ThreadEpiphanyRoleSelfPersistenceReview {
|
||||
ThreadEpiphanyRoleSelfPersistenceReview {
|
||||
status: match review.status {
|
||||
EpiphanyRoleSelfPersistenceStatus::Missing => {
|
||||
ThreadEpiphanyRoleSelfPersistenceStatus::Missing
|
||||
}
|
||||
EpiphanyRoleSelfPersistenceStatus::Accepted => {
|
||||
ThreadEpiphanyRoleSelfPersistenceStatus::Accepted
|
||||
}
|
||||
EpiphanyRoleSelfPersistenceStatus::Rejected => {
|
||||
ThreadEpiphanyRoleSelfPersistenceStatus::Rejected
|
||||
}
|
||||
},
|
||||
target_agent_id: review.target_agent_id,
|
||||
target_path: review.target_path,
|
||||
reasons: review.reasons,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,9 +1,3 @@
|
|||
use codex_app_server_protocol::ThreadEpiphanyReorientFinding;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleFinding;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleId;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleSelfPersistenceReview;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRoleSelfPersistenceStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyUpdatePatch;
|
||||
use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus;
|
||||
use epiphany_core::EpiphanyCrrcResultStatus as CoreEpiphanyCrrcResultStatus;
|
||||
use epiphany_core::EpiphanyReorientFindingInterpretation;
|
||||
|
|
@ -11,123 +5,6 @@ use epiphany_core::EpiphanyRoleFindingInterpretation;
|
|||
use epiphany_core::EpiphanyRoleResultRoleId;
|
||||
use epiphany_core::EpiphanyRoleSelfPersistenceReview as CoreEpiphanyRoleSelfPersistenceReview;
|
||||
use epiphany_core::EpiphanyRoleSelfPersistenceStatus as CoreEpiphanyRoleSelfPersistenceStatus;
|
||||
use epiphany_core::EpiphanyRoleStatePatchDocument;
|
||||
|
||||
pub fn map_protocol_reorient_finding(
|
||||
finding: EpiphanyReorientFindingInterpretation,
|
||||
) -> ThreadEpiphanyReorientFinding {
|
||||
ThreadEpiphanyReorientFinding {
|
||||
mode: finding.mode,
|
||||
summary: finding.summary,
|
||||
next_safe_move: finding.next_safe_move,
|
||||
checkpoint_still_valid: finding.checkpoint_still_valid,
|
||||
files_inspected: finding.files_inspected,
|
||||
frontier_node_ids: finding.frontier_node_ids,
|
||||
evidence_ids: finding.evidence_ids,
|
||||
artifact_refs: finding.artifact_refs,
|
||||
runtime_result_id: finding.runtime_result_id,
|
||||
runtime_job_id: finding.runtime_job_id,
|
||||
job_error: finding.job_error,
|
||||
item_error: finding.item_error,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_protocol_role_finding(
|
||||
role_id: ThreadEpiphanyRoleId,
|
||||
finding: EpiphanyRoleFindingInterpretation,
|
||||
) -> ThreadEpiphanyRoleFinding {
|
||||
let state_patch = finding.state_patch.map(map_protocol_update_patch);
|
||||
ThreadEpiphanyRoleFinding {
|
||||
role_id,
|
||||
verdict: finding.verdict,
|
||||
summary: finding.summary,
|
||||
next_safe_move: finding.next_safe_move,
|
||||
checkpoint_summary: finding.checkpoint_summary,
|
||||
scratch_summary: finding.scratch_summary,
|
||||
files_inspected: finding.files_inspected,
|
||||
frontier_node_ids: finding.frontier_node_ids,
|
||||
evidence_ids: finding.evidence_ids,
|
||||
artifact_refs: finding.artifact_refs,
|
||||
runtime_result_id: finding.runtime_result_id,
|
||||
runtime_job_id: finding.runtime_job_id,
|
||||
open_questions: finding.open_questions,
|
||||
evidence_gaps: finding.evidence_gaps,
|
||||
risks: finding.risks,
|
||||
state_patch,
|
||||
self_patch: finding.self_patch.map(|patch| {
|
||||
serde_json::to_value(patch)
|
||||
.expect("AgentSelfPatch is a serializable protocol projection")
|
||||
}),
|
||||
self_persistence: finding
|
||||
.self_persistence
|
||||
.map(map_protocol_role_self_persistence_review),
|
||||
job_error: finding.job_error,
|
||||
item_error: finding.item_error,
|
||||
}
|
||||
}
|
||||
|
||||
fn map_protocol_update_patch(patch: EpiphanyRoleStatePatchDocument) -> ThreadEpiphanyUpdatePatch {
|
||||
ThreadEpiphanyUpdatePatch {
|
||||
objective: patch.objective,
|
||||
active_subgoal_id: patch.active_subgoal_id,
|
||||
subgoals: patch.subgoals,
|
||||
invariants: patch.invariants,
|
||||
graphs: patch.graphs,
|
||||
graph_frontier: patch.graph_frontier,
|
||||
graph_checkpoint: patch.graph_checkpoint,
|
||||
scratch: patch.scratch,
|
||||
investigation_checkpoint: patch.investigation_checkpoint,
|
||||
job_bindings: patch.job_bindings,
|
||||
acceptance_receipts: patch.acceptance_receipts,
|
||||
runtime_links: patch.runtime_links,
|
||||
observations: patch.observations,
|
||||
evidence: patch.evidence,
|
||||
churn: patch.churn,
|
||||
mode: patch.mode,
|
||||
planning: patch.planning,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_core_role_result_role_id(role_id: ThreadEpiphanyRoleId) -> EpiphanyRoleResultRoleId {
|
||||
match role_id {
|
||||
ThreadEpiphanyRoleId::Implementation => EpiphanyRoleResultRoleId::Implementation,
|
||||
ThreadEpiphanyRoleId::Imagination => EpiphanyRoleResultRoleId::Imagination,
|
||||
ThreadEpiphanyRoleId::Modeling => EpiphanyRoleResultRoleId::Modeling,
|
||||
ThreadEpiphanyRoleId::Verification => EpiphanyRoleResultRoleId::Verification,
|
||||
ThreadEpiphanyRoleId::Reorientation => EpiphanyRoleResultRoleId::Reorientation,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_protocol_role_result_role_id(role_id: EpiphanyRoleResultRoleId) -> ThreadEpiphanyRoleId {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Implementation => ThreadEpiphanyRoleId::Implementation,
|
||||
EpiphanyRoleResultRoleId::Imagination => ThreadEpiphanyRoleId::Imagination,
|
||||
EpiphanyRoleResultRoleId::Modeling => ThreadEpiphanyRoleId::Modeling,
|
||||
EpiphanyRoleResultRoleId::Verification => ThreadEpiphanyRoleId::Verification,
|
||||
EpiphanyRoleResultRoleId::Reorientation => ThreadEpiphanyRoleId::Reorientation,
|
||||
}
|
||||
}
|
||||
|
||||
fn map_protocol_role_self_persistence_review(
|
||||
review: CoreEpiphanyRoleSelfPersistenceReview,
|
||||
) -> ThreadEpiphanyRoleSelfPersistenceReview {
|
||||
ThreadEpiphanyRoleSelfPersistenceReview {
|
||||
status: match review.status {
|
||||
CoreEpiphanyRoleSelfPersistenceStatus::Missing => {
|
||||
ThreadEpiphanyRoleSelfPersistenceStatus::Missing
|
||||
}
|
||||
CoreEpiphanyRoleSelfPersistenceStatus::Accepted => {
|
||||
ThreadEpiphanyRoleSelfPersistenceStatus::Accepted
|
||||
}
|
||||
CoreEpiphanyRoleSelfPersistenceStatus::Rejected => {
|
||||
ThreadEpiphanyRoleSelfPersistenceStatus::Rejected
|
||||
}
|
||||
},
|
||||
target_agent_id: review.target_agent_id,
|
||||
target_path: review.target_path,
|
||||
reasons: review.reasons,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_core_role_result_note(
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
|
|
|
|||
|
|
@ -37,14 +37,15 @@ use crate::pressure::derive_epiphany_pressure;
|
|||
use crate::pressure::map_epiphany_pressure;
|
||||
use crate::protocol_edge::protocol_job_from_surface;
|
||||
use crate::protocol_edge::protocol_reorient_decision;
|
||||
use crate::protocol_edge::protocol_reorient_finding;
|
||||
use crate::protocol_edge::protocol_reorient_result_status;
|
||||
use crate::protocol_edge::protocol_reorient_state_status;
|
||||
use crate::protocol_edge::protocol_role_finding;
|
||||
use crate::protocol_edge::protocol_role_id_from_core;
|
||||
use crate::protocol_edge::protocol_role_result_status;
|
||||
use crate::reorient::EpiphanyFreshnessWatcherSnapshot;
|
||||
use crate::reorient::derive_epiphany_freshness_view;
|
||||
use crate::reorient::derive_epiphany_reorient;
|
||||
use crate::results::map_protocol_reorient_finding;
|
||||
use crate::results::map_protocol_role_result_role_id;
|
||||
use crate::runtime_results::load_core_epiphany_reorient_result_snapshot;
|
||||
use crate::runtime_results::load_core_epiphany_role_result_snapshot;
|
||||
use crate::scene::map_core_epiphany_scene_action;
|
||||
|
|
@ -224,7 +225,7 @@ pub async fn map_epiphany_view_response(
|
|||
let reorient_finding = reorient_result
|
||||
.finding
|
||||
.clone()
|
||||
.map(map_protocol_reorient_finding);
|
||||
.map(protocol_reorient_finding);
|
||||
let reorient_result_note = reorient_result.note.clone();
|
||||
let checkpoint_present = state
|
||||
.and_then(|state| state.investigation_checkpoint.as_ref())
|
||||
|
|
@ -450,7 +451,7 @@ pub async fn map_epiphany_role_result_response(
|
|||
state,
|
||||
runtime_store_path,
|
||||
} = input;
|
||||
let protocol_role_id = map_protocol_role_result_role_id(role_id);
|
||||
let protocol_role_id = protocol_role_id_from_core(role_id);
|
||||
let protocol_source = map_protocol_roles_source(source);
|
||||
let Some(state) = state else {
|
||||
return ThreadEpiphanyRoleResultResponse {
|
||||
|
|
@ -486,7 +487,7 @@ pub async fn map_epiphany_role_result_response(
|
|||
job,
|
||||
finding: result
|
||||
.finding
|
||||
.map(|finding| crate::results::map_protocol_role_finding(protocol_role_id, finding)),
|
||||
.map(|finding| protocol_role_finding(protocol_role_id, finding)),
|
||||
note: result.note,
|
||||
}
|
||||
}
|
||||
|
|
@ -540,7 +541,7 @@ pub async fn map_epiphany_reorient_result_response(
|
|||
binding_id,
|
||||
status: protocol_reorient_result_status(result.status),
|
||||
job,
|
||||
finding: result.finding.map(map_protocol_reorient_finding),
|
||||
finding: result.finding.map(protocol_reorient_finding),
|
||||
note: result.note,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue