Require typed runtime worker results

This commit is contained in:
Meta Vens 2026-05-14 06:15:33 +01:00
commit c27c1dcb9f
7 changed files with 173 additions and 87 deletions

View file

@ -12,8 +12,6 @@ use codex_protocol::protocol::EpiphanyRuntimeLink;
use codex_protocol::protocol::EpiphanyThreadState;
use epiphany_core::EpiphanyRuntimeJobSnapshot;
use epiphany_core::EpiphanyRuntimeJobStatus;
use epiphany_core::interpret_reorient_runtime_job_result;
use epiphany_core::interpret_role_runtime_job_result;
use epiphany_core::interpret_runtime_reorient_worker_result;
use epiphany_core::interpret_runtime_role_worker_result;
use epiphany_core::runtime_job_snapshot;
@ -94,24 +92,26 @@ pub fn load_epiphany_role_result_from_runtime_spine_job(
&result,
),
)),
Ok(None) => snapshot.result.as_ref().map(|result| {
map_protocol_role_finding(
role_id,
interpret_role_runtime_job_result(
map_core_role_result_role_id(role_id),
result,
Ok(None) => {
return (
ThreadEpiphanyRoleResultStatus::BackendUnavailable,
None,
format!(
"Heartbeat runtime job {:?} completed without an EpiphanyRuntimeRoleWorkerResult typed document; generic lifecycle receipts are not reviewable findings.",
job_id
),
)
}),
Err(_) => snapshot.result.as_ref().map(|result| {
map_protocol_role_finding(
role_id,
interpret_role_runtime_job_result(
map_core_role_result_role_id(role_id),
result,
);
}
Err(err) => {
return (
ThreadEpiphanyRoleResultStatus::BackendUnavailable,
None,
format!(
"Failed to read typed role worker result for heartbeat runtime job {:?}: {err}",
job_id
),
)
}),
);
}
}
} else {
None
@ -165,12 +165,26 @@ pub fn load_epiphany_reorient_result_from_runtime_spine_job(
Ok(Some(result)) => Some(map_protocol_reorient_finding(
interpret_runtime_reorient_worker_result(&result),
)),
Ok(None) => snapshot.result.as_ref().map(|result| {
map_protocol_reorient_finding(interpret_reorient_runtime_job_result(result))
}),
Err(_) => snapshot.result.as_ref().map(|result| {
map_protocol_reorient_finding(interpret_reorient_runtime_job_result(result))
}),
Ok(None) => {
return (
ThreadEpiphanyReorientResultStatus::BackendUnavailable,
None,
format!(
"Heartbeat runtime job {:?} completed without an EpiphanyRuntimeReorientWorkerResult typed document; generic lifecycle receipts are not reviewable findings.",
job_id
),
);
}
Err(err) => {
return (
ThreadEpiphanyReorientResultStatus::BackendUnavailable,
None,
format!(
"Failed to read typed reorientation worker result for heartbeat runtime job {:?}: {err}",
job_id
),
);
}
}
} else {
None
@ -391,3 +405,119 @@ pub fn latest_epiphany_runtime_link_for_binding<'a>(
.iter()
.find(|link| link.binding_id == binding_id && !link.runtime_job_id.trim().is_empty())
}
#[cfg(test)]
mod tests {
use std::fs;
use std::path::Path;
use std::path::PathBuf;
use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus;
use codex_app_server_protocol::ThreadEpiphanyRoleId;
use codex_app_server_protocol::ThreadEpiphanyRoleResultStatus;
use epiphany_core::RuntimeSpineInitOptions;
use epiphany_core::RuntimeSpineJobOptions;
use epiphany_core::RuntimeSpineJobResultOptions;
use epiphany_core::RuntimeSpineSessionOptions;
use epiphany_core::complete_runtime_job;
use epiphany_core::create_runtime_job;
use epiphany_core::create_runtime_session;
use epiphany_core::initialize_runtime_spine;
use super::*;
const NOW: &str = "2026-05-13T00:00:00Z";
#[test]
fn role_result_requires_typed_worker_document() {
let store = temp_store_path();
seed_completed_lifecycle_result(&store, "role-job", "modeling");
let (status, finding, note) = load_epiphany_role_result_from_runtime_spine_job(
"role-job",
Some(store.as_path()),
ThreadEpiphanyRoleId::Modeling,
);
assert_eq!(status, ThreadEpiphanyRoleResultStatus::BackendUnavailable);
assert!(finding.is_none());
assert!(note.contains("EpiphanyRuntimeRoleWorkerResult typed document"));
let _ = fs::remove_file(store);
}
#[test]
fn reorient_result_requires_typed_worker_document() {
let store = temp_store_path();
seed_completed_lifecycle_result(&store, "reorient-job", "reorientation");
let (status, finding, note) = load_epiphany_reorient_result_from_runtime_spine_job(
"reorient-job",
Some(store.as_path()),
);
assert_eq!(
status,
ThreadEpiphanyReorientResultStatus::BackendUnavailable
);
assert!(finding.is_none());
assert!(note.contains("EpiphanyRuntimeReorientWorkerResult typed document"));
let _ = fs::remove_file(store);
}
fn temp_store_path() -> PathBuf {
std::env::temp_dir().join(format!(
"epiphany-runtime-results-{}.msgpack",
uuid::Uuid::new_v4()
))
}
fn seed_completed_lifecycle_result(store: &Path, job_id: &str, role: &str) {
initialize_runtime_spine(
store,
RuntimeSpineInitOptions {
runtime_id: "test-runtime".to_string(),
display_name: "Test Runtime".to_string(),
created_at: NOW.to_string(),
},
)
.expect("initialize runtime");
create_runtime_session(
store,
RuntimeSpineSessionOptions {
session_id: "session-1".to_string(),
objective: "test typed result boundary".to_string(),
created_at: NOW.to_string(),
coordinator_note: "test".to_string(),
},
)
.expect("create session");
create_runtime_job(
store,
RuntimeSpineJobOptions {
job_id: job_id.to_string(),
session_id: "session-1".to_string(),
role: role.to_string(),
created_at: NOW.to_string(),
summary: "generic lifecycle job".to_string(),
artifact_refs: Vec::new(),
},
)
.expect("create job");
complete_runtime_job(
store,
RuntimeSpineJobResultOptions {
result_id: format!("result-{job_id}"),
job_id: job_id.to_string(),
completed_at: NOW.to_string(),
verdict: "completed".to_string(),
summary: "generic lifecycle result".to_string(),
next_safe_move: "do not review generic lifecycle receipts".to_string(),
evidence_refs: Vec::new(),
artifact_refs: Vec::new(),
},
)
.expect("complete job");
}
}

View file

@ -257,9 +257,7 @@ 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_reorient_runtime_job_result;
pub use surfaces::interpret_role_finding;
pub use surfaces::interpret_role_runtime_job_result;
pub use surfaces::interpret_runtime_reorient_worker_result;
pub use surfaces::interpret_runtime_role_worker_result;
pub use surfaces::modeling_role_state_patch_policy_errors;

View file

@ -105,9 +105,7 @@ 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_reorient_runtime_job_result;
pub use role_result::interpret_role_finding;
pub use role_result::interpret_role_runtime_job_result;
pub use role_result::interpret_runtime_reorient_worker_result;
pub use role_result::interpret_runtime_role_worker_result;
pub use role_result::modeling_role_state_patch_policy_errors;

View file

@ -195,33 +195,6 @@ pub fn interpret_reorient_finding(
}
}
pub fn interpret_role_runtime_job_result(
_role_id: EpiphanyRoleResultRoleId,
result: &EpiphanyRuntimeJobResult,
) -> EpiphanyRoleFindingInterpretation {
EpiphanyRoleFindingInterpretation {
verdict: Some(result.verdict.clone()),
summary: Some(result.summary.clone()),
next_safe_move: empty_string_as_none(&result.next_safe_move),
checkpoint_summary: None,
scratch_summary: None,
files_inspected: Vec::new(),
frontier_node_ids: Vec::new(),
evidence_ids: result.evidence_refs.clone(),
artifact_refs: result.artifact_refs.clone(),
runtime_result_id: Some(result.result_id.clone()),
runtime_job_id: Some(result.job_id.clone()),
open_questions: Vec::new(),
evidence_gaps: Vec::new(),
risks: Vec::new(),
state_patch: None,
self_patch: None,
self_persistence: None,
job_error: None,
item_error: None,
}
}
pub fn interpret_runtime_role_worker_result(
role_id: EpiphanyRoleResultRoleId,
result: &crate::EpiphanyRuntimeRoleWorkerResult,
@ -287,25 +260,6 @@ pub fn interpret_runtime_role_worker_result(
}
}
pub fn interpret_reorient_runtime_job_result(
result: &EpiphanyRuntimeJobResult,
) -> EpiphanyReorientFindingInterpretation {
EpiphanyReorientFindingInterpretation {
mode: Some(result.role.clone()),
summary: Some(result.summary.clone()),
next_safe_move: empty_string_as_none(&result.next_safe_move),
checkpoint_still_valid: Some(result.verdict != "fail"),
files_inspected: Vec::new(),
frontier_node_ids: Vec::new(),
evidence_ids: result.evidence_refs.clone(),
artifact_refs: result.artifact_refs.clone(),
runtime_result_id: Some(result.result_id.clone()),
runtime_job_id: Some(result.job_id.clone()),
job_error: None,
item_error: None,
}
}
pub fn interpret_runtime_reorient_worker_result(
result: &crate::EpiphanyRuntimeReorientWorkerResult,
) -> EpiphanyReorientFindingInterpretation {
@ -1227,7 +1181,6 @@ use super::state_patch::EpiphanyRoleStatePatchDocument;
use crate::agent_memory::AgentSelfPatch;
use crate::agent_memory::decode_agent_self_patch;
use crate::agent_memory::review_agent_self_patch_contract;
use crate::runtime_spine::EpiphanyRuntimeJobResult;
use epiphany_state_model::EpiphanyAcceptanceReceipt;
use epiphany_state_model::EpiphanyCodeRef;
use epiphany_state_model::EpiphanyEvidenceRecord;

View file

@ -598,8 +598,9 @@ storage route without network. Its `run-worker` command now reads a durable
model request, calls the native runtime route, persists typed
`EpiphanyRuntimeRoleWorkerResult` or `EpiphanyRuntimeReorientWorkerResult`
documents, and completes the original heartbeat/specialist runtime job without
Codex worker execution. `roleResult` and `reorientResult` now prefer those typed
worker result documents and use generic job summaries only as legacy fallback.
Codex worker execution. `roleResult` and `reorientResult` now require those
typed worker result documents; generic runtime job summaries are lifecycle
receipts, not reviewable findings.
The next cut is wiring coordinator/heartbeat automation to invoke `run-worker`
for launched runtime job ids, then carving down the `codex-api` dependency
weight.
@ -962,6 +963,14 @@ absolute-path, and template tests. A vendored-wide search for product-shaped
test names now returns only external URLs, generic URL examples, and real
package names such as `eslint-plugin`; not live Codex product machinery.
The typed worker-result boundary is now stricter. `roleResult` and
`reorientResult` read-back no longer falls back from
`EpiphanyRuntimeRoleWorkerResult` / `EpiphanyRuntimeReorientWorkerResult`
CultCache documents to generic `EpiphanyRuntimeJobResult` lifecycle receipts.
If a job completed without the typed worker-result document, the bridge reports
backend-unavailable and names the missing document instead of laundering summary
strings into a reviewable finding.
That husk has now been cut from `codex-core`. The root core crate no longer
exports `plugins`, no longer depends on `codex-core-plugins` or `codex-plugin`,
and the core plugin manager / marketplace add-remove-sync modules and tests

Binary file not shown.

File diff suppressed because one or more lines are too long