Extract Epiphany reorient finding interpretation

This commit is contained in:
Meta Vens 2026-05-12 22:05:16 +01:00
commit e0a8c42ee0
7 changed files with 94 additions and 37 deletions

View file

@ -184,6 +184,7 @@ pub use surfaces::EpiphanyReorientAcceptanceFinding;
pub use surfaces::EpiphanyReorientAction;
pub use surfaces::EpiphanyReorientCheckpointStatus;
pub use surfaces::EpiphanyReorientDecision;
pub use surfaces::EpiphanyReorientFindingInterpretation;
pub use surfaces::EpiphanyReorientFreshnessStatus;
pub use surfaces::EpiphanyReorientInput;
pub use surfaces::EpiphanyReorientPressureLevel;
@ -228,6 +229,7 @@ pub use surfaces::derive_pressure_view;
pub use surfaces::derive_role_board;
pub use surfaces::derive_scene;
pub use surfaces::imagination_role_state_patch_policy_errors;
pub use surfaces::interpret_reorient_finding;
pub use surfaces::interpret_role_finding;
pub use surfaces::modeling_role_state_patch_policy_errors;
pub use surfaces::recommend_coordinator_action;

View file

@ -92,6 +92,7 @@ pub use role_board::role_board_job_status_to_role_status;
pub use role_result::EpiphanyAcceptanceBundle;
pub use role_result::EpiphanyReorientAcceptanceBundle;
pub use role_result::EpiphanyReorientAcceptanceFinding;
pub use role_result::EpiphanyReorientFindingInterpretation;
pub use role_result::EpiphanyRoleAcceptanceFinding;
pub use role_result::EpiphanyRoleFindingInterpretation;
pub use role_result::EpiphanyRoleResultRoleId;
@ -100,6 +101,7 @@ pub use role_result::EpiphanyRoleSelfPersistenceStatus;
pub use role_result::build_reorient_acceptance_bundle;
pub use role_result::build_role_acceptance_bundle;
pub use role_result::imagination_role_state_patch_policy_errors;
pub use role_result::interpret_reorient_finding;
pub use role_result::interpret_role_finding;
pub use role_result::modeling_role_state_patch_policy_errors;
pub use role_result::review_role_self_patch;

View file

@ -68,6 +68,22 @@ pub struct EpiphanyReorientAcceptanceFinding {
pub runtime_job_id: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyReorientFindingInterpretation {
pub mode: Option<String>,
pub summary: Option<String>,
pub next_safe_move: Option<String>,
pub checkpoint_still_valid: Option<bool>,
pub files_inspected: Vec<String>,
pub frontier_node_ids: Vec<String>,
pub evidence_ids: Vec<String>,
pub artifact_refs: Vec<String>,
pub runtime_result_id: Option<String>,
pub runtime_job_id: Option<String>,
pub job_error: Option<String>,
pub item_error: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyAcceptanceBundle {
pub accepted_receipt_id: String,
@ -147,6 +163,29 @@ pub fn interpret_role_finding(
}
}
pub fn interpret_reorient_finding(
raw_result: &serde_json::Value,
job_error: Option<String>,
item_error: Option<String>,
) -> EpiphanyReorientFindingInterpretation {
EpiphanyReorientFindingInterpretation {
mode: json_string_field(raw_result, "mode"),
summary: json_string_field(raw_result, "summary"),
next_safe_move: json_string_field(raw_result, "nextSafeMove"),
checkpoint_still_valid: raw_result
.get("checkpointStillValid")
.and_then(serde_json::Value::as_bool),
files_inspected: json_string_array_field(raw_result, "filesInspected"),
frontier_node_ids: json_string_array_field(raw_result, "frontierNodeIds"),
evidence_ids: json_string_array_field(raw_result, "evidenceIds"),
artifact_refs: json_string_array_field(raw_result, "artifactRefs"),
runtime_result_id: json_string_field(raw_result, "runtimeResultId"),
runtime_job_id: json_string_field(raw_result, "runtimeJobId"),
job_error,
item_error,
}
}
pub fn build_role_acceptance_bundle(
binding_id: &str,
role: EpiphanyRoleAcceptanceFinding,
@ -1074,6 +1113,31 @@ mod tests {
assert_eq!(finding.runtime_result_id.as_deref(), Some("result-1"));
}
#[test]
fn projects_reorient_structured_output() {
let finding = interpret_reorient_finding(
&serde_json::json!({
"mode": "resume",
"summary": "Checkpoint is still warm.",
"nextSafeMove": "Continue the bounded cut.",
"checkpointStillValid": true,
"filesInspected": ["state/map.yaml"],
"frontierNodeIds": ["node-1"],
"evidenceIds": ["ev-1"],
"artifactRefs": ["artifact:reorient"],
"runtimeResultId": "result-1",
"runtimeJobId": "job-1"
}),
None,
None,
);
assert_eq!(finding.mode.as_deref(), Some("resume"));
assert_eq!(finding.checkpoint_still_valid, Some(true));
assert_eq!(finding.frontier_node_ids, vec!["node-1"]);
assert_eq!(finding.runtime_job_id.as_deref(), Some("job-1"));
}
#[test]
fn reviews_acceptable_self_patch() {
let finding = interpret_role_finding(