Detach MVP worker runtime
This commit is contained in:
parent
ce2a23a2af
commit
f7a2f6b5b1
8 changed files with 301 additions and 131 deletions
|
|
@ -21,7 +21,17 @@ use std::fs;
|
|||
use std::path::{Path, PathBuf};
|
||||
use std::process::{Command, Stdio};
|
||||
use std::thread;
|
||||
use std::time::{Duration, Instant};
|
||||
use std::time::Duration;
|
||||
|
||||
#[cfg(windows)]
|
||||
use std::os::windows::process::CommandExt;
|
||||
|
||||
#[cfg(windows)]
|
||||
const CREATE_NEW_PROCESS_GROUP: u32 = 0x0000_0200;
|
||||
#[cfg(windows)]
|
||||
const CREATE_NO_WINDOW: u32 = 0x0800_0000;
|
||||
#[cfg(windows)]
|
||||
const DETACHED_PROCESS: u32 = 0x0000_0008;
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[path = "epiphany-mvp-status.rs"]
|
||||
|
|
@ -348,7 +358,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
steps.push(step);
|
||||
break;
|
||||
}
|
||||
if is_stop_action(&action) && !args.auto_review {
|
||||
if is_stop_action(&action) && !args.auto_review && !is_result_review_action(&action) {
|
||||
append_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
break;
|
||||
|
|
@ -356,29 +366,48 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
|
||||
let revision = state_revision(&status);
|
||||
match action.as_str() {
|
||||
"reviewModelingResult" => {
|
||||
"reviewModelingResult" | "reviewVerificationResult" => {
|
||||
let role_id = if action == "reviewModelingResult" {
|
||||
"modeling"
|
||||
} else {
|
||||
"verification"
|
||||
};
|
||||
let result = client.send(
|
||||
"thread/epiphany/roleResult",
|
||||
Some(json!({"threadId": thread_id, "roleId": "modeling"})),
|
||||
Some(json!({"threadId": thread_id, "roleId": role_id})),
|
||||
true,
|
||||
)?;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "roleResult", "roleId": "modeling", "result": status_cli::sanitize_for_operator(result.clone())}),
|
||||
json!({"type": "roleResult", "roleId": role_id, "result": status_cli::sanitize_for_operator(result.clone())}),
|
||||
);
|
||||
if !matches!(
|
||||
result["status"].as_str(),
|
||||
Some("completed" | "failed" | "cancelled")
|
||||
) {
|
||||
final_action = json!({
|
||||
"action": if role_id == "modeling" { "waitForModelingResult" } else { "waitForVerificationResult" },
|
||||
"reason": result["note"],
|
||||
});
|
||||
append_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
break;
|
||||
}
|
||||
let can_accept = args.auto_review
|
||||
&& result.pointer("/finding/statePatch").is_some()
|
||||
&& revision.is_some();
|
||||
if !can_accept {
|
||||
final_action =
|
||||
json!({"action": "reviewModelingResult", "reason": result["note"]});
|
||||
final_action = json!({
|
||||
"action": if role_id == "modeling" { "reviewModelingResult" } else { "reviewVerificationResult" },
|
||||
"reason": result["note"]
|
||||
});
|
||||
append_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
break;
|
||||
}
|
||||
let accepted = client.send(
|
||||
"thread/epiphany/roleAccept",
|
||||
Some(json!({"threadId": thread_id, "roleId": "modeling", "expectedRevision": revision})),
|
||||
Some(json!({"threadId": thread_id, "roleId": role_id, "expectedRevision": revision})),
|
||||
true,
|
||||
)?;
|
||||
if let Some(memory) = maybe_apply_role_self_patch(&accepted, &agent_memory_dir)? {
|
||||
|
|
@ -386,16 +415,37 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
accepted_with_memory["selfMemoryApply"] = memory;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "roleAccept", "roleId": "modeling", "accepted": status_cli::sanitize_for_operator(accepted_with_memory)}),
|
||||
json!({"type": "roleAccept", "roleId": role_id, "accepted": status_cli::sanitize_for_operator(accepted_with_memory)}),
|
||||
);
|
||||
} else {
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "roleAccept", "roleId": "modeling", "accepted": status_cli::sanitize_for_operator(accepted)}),
|
||||
json!({"type": "roleAccept", "roleId": role_id, "accepted": status_cli::sanitize_for_operator(accepted)}),
|
||||
);
|
||||
}
|
||||
final_status = collect_coordinator_status(&mut client, &thread_id)?;
|
||||
}
|
||||
"reviewReorientResult" => {
|
||||
let result = read_reorient_result(&mut client, &thread_id)?;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "reorientResult", "result": status_cli::sanitize_for_operator(result.clone())}),
|
||||
);
|
||||
if !matches!(
|
||||
result["status"].as_str(),
|
||||
Some("completed" | "failed" | "cancelled")
|
||||
) {
|
||||
final_action =
|
||||
json!({"action": "waitForReorientResult", "reason": result["note"]});
|
||||
append_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
break;
|
||||
}
|
||||
final_action = json!({"action": "reviewReorientResult", "reason": result["note"]});
|
||||
append_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
break;
|
||||
}
|
||||
"launchModeling" | "launchVerification" => {
|
||||
let role_id = if action == "launchModeling" {
|
||||
"modeling"
|
||||
|
|
@ -414,7 +464,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
&mut step,
|
||||
json!({"type": "roleLaunch", "roleId": role_id, "launch": status_cli::sanitize_for_operator(launch.clone()), "runtimeJobId": worker_job_id}),
|
||||
);
|
||||
let worker_run = run_worker_runtime(
|
||||
let worker_run = launch_worker_runtime_detached(
|
||||
&model_runtime_bin,
|
||||
&tool_adapter_bin,
|
||||
&args.model_provider,
|
||||
|
|
@ -425,19 +475,31 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
role_id,
|
||||
index,
|
||||
&artifact_dir,
|
||||
args.timeout_seconds,
|
||||
args.max_runtime_seconds,
|
||||
args.auto_tools,
|
||||
)?;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "workerRuntime", "roleId": role_id, "run": worker_run}),
|
||||
);
|
||||
let result = wait_for_role_result(&mut client, &thread_id, role_id, args)?;
|
||||
let result = read_role_result(&mut client, &thread_id, role_id)?;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "roleResult", "roleId": role_id, "result": status_cli::sanitize_for_operator(result.clone())}),
|
||||
);
|
||||
final_status = collect_coordinator_status(&mut client, &thread_id)?;
|
||||
if !matches!(
|
||||
result["status"].as_str(),
|
||||
Some("completed" | "failed" | "cancelled")
|
||||
) {
|
||||
final_action = json!({
|
||||
"action": if role_id == "modeling" { "waitForModelingResult" } else { "waitForVerificationResult" },
|
||||
"reason": result["note"],
|
||||
});
|
||||
append_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
break;
|
||||
}
|
||||
if !args.auto_review {
|
||||
final_action = json!({
|
||||
"action": if role_id == "modeling" { "reviewModelingResult" } else { "reviewVerificationResult" },
|
||||
|
|
@ -456,7 +518,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
&mut step,
|
||||
json!({"type": "reorientLaunch", "launch": status_cli::sanitize_for_operator(launch.clone()), "runtimeJobId": worker_job_id}),
|
||||
);
|
||||
let worker_run = run_worker_runtime(
|
||||
let worker_run = launch_worker_runtime_detached(
|
||||
&model_runtime_bin,
|
||||
&tool_adapter_bin,
|
||||
&args.model_provider,
|
||||
|
|
@ -467,19 +529,29 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
"reorient-worker",
|
||||
index,
|
||||
&artifact_dir,
|
||||
args.timeout_seconds,
|
||||
args.max_runtime_seconds,
|
||||
args.auto_tools,
|
||||
)?;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "workerRuntime", "roleId": "reorient-worker", "run": worker_run}),
|
||||
);
|
||||
let result = wait_for_reorient_result(&mut client, &thread_id, args)?;
|
||||
let result = read_reorient_result(&mut client, &thread_id)?;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "reorientResult", "result": status_cli::sanitize_for_operator(result.clone())}),
|
||||
);
|
||||
final_status = collect_coordinator_status(&mut client, &thread_id)?;
|
||||
if !matches!(
|
||||
result["status"].as_str(),
|
||||
Some("completed" | "failed" | "cancelled")
|
||||
) {
|
||||
final_action =
|
||||
json!({"action": "waitForReorientResult", "reason": result["note"]});
|
||||
append_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
break;
|
||||
}
|
||||
if !args.auto_review {
|
||||
final_action =
|
||||
json!({"action": "reviewReorientResult", "reason": result["note"]});
|
||||
|
|
@ -783,7 +855,7 @@ fn worker_job_id_from_launch(launch: &Value) -> Result<String> {
|
|||
.ok_or_else(|| anyhow!("launch response did not include a runtime worker job id"))
|
||||
}
|
||||
|
||||
fn run_worker_runtime(
|
||||
fn launch_worker_runtime_detached(
|
||||
model_runtime_bin: &Path,
|
||||
tool_adapter_bin: &Path,
|
||||
model_provider: &str,
|
||||
|
|
@ -794,7 +866,7 @@ fn run_worker_runtime(
|
|||
role_id: &str,
|
||||
step_index: usize,
|
||||
artifact_dir: &Path,
|
||||
timeout_seconds: u64,
|
||||
max_runtime_seconds: u64,
|
||||
auto_tools: bool,
|
||||
) -> Result<Value> {
|
||||
let stdout_path = artifact_dir.join(format!(
|
||||
|
|
@ -815,7 +887,9 @@ fn run_worker_runtime(
|
|||
.arg("--codex-home")
|
||||
.arg(codex_home)
|
||||
.arg("--job-id")
|
||||
.arg(job_id);
|
||||
.arg(job_id)
|
||||
.arg("--max-runtime-seconds")
|
||||
.arg(max_runtime_seconds.to_string());
|
||||
if auto_tools {
|
||||
command
|
||||
.arg("--auto-tools")
|
||||
|
|
@ -824,93 +898,50 @@ fn run_worker_runtime(
|
|||
.arg("--cwd")
|
||||
.arg(cwd);
|
||||
}
|
||||
command.stdout(Stdio::piped()).stderr(Stdio::piped());
|
||||
let mut child = command
|
||||
let stdout_file = fs::File::create(&stdout_path)
|
||||
.with_context(|| format!("failed to create {}", stdout_path.display()))?;
|
||||
let stderr_file = fs::File::create(&stderr_path)
|
||||
.with_context(|| format!("failed to create {}", stderr_path.display()))?;
|
||||
command
|
||||
.stdin(Stdio::null())
|
||||
.stdout(Stdio::from(stdout_file))
|
||||
.stderr(Stdio::from(stderr_file));
|
||||
#[cfg(windows)]
|
||||
command.creation_flags(DETACHED_PROCESS | CREATE_NEW_PROCESS_GROUP | CREATE_NO_WINDOW);
|
||||
let child = command
|
||||
.spawn()
|
||||
.with_context(|| format!("failed to spawn {}", model_runtime_bin.display()))?;
|
||||
let deadline = Instant::now() + Duration::from_secs(timeout_seconds);
|
||||
loop {
|
||||
if let Some(status) = child.try_wait()? {
|
||||
let output = child.wait_with_output()?;
|
||||
fs::write(&stdout_path, &output.stdout)?;
|
||||
fs::write(&stderr_path, &output.stderr)?;
|
||||
if !status.success() {
|
||||
return Err(anyhow!(
|
||||
"worker runtime failed for {job_id}: {}{}",
|
||||
String::from_utf8_lossy(&output.stderr),
|
||||
String::from_utf8_lossy(&output.stdout)
|
||||
));
|
||||
}
|
||||
let parsed: Value = serde_json::from_slice(&output.stdout)
|
||||
.context("worker runtime returned invalid JSON")?;
|
||||
return Ok(json!({
|
||||
"status": "completed",
|
||||
"jobId": job_id,
|
||||
"stdout": stdout_path,
|
||||
"stderr": stderr_path,
|
||||
"summary": parsed,
|
||||
}));
|
||||
}
|
||||
if Instant::now() >= deadline {
|
||||
let _ = child.kill();
|
||||
let output = child.wait_with_output()?;
|
||||
fs::write(&stdout_path, &output.stdout)?;
|
||||
fs::write(&stderr_path, &output.stderr)?;
|
||||
return Err(anyhow!(
|
||||
"worker runtime timed out for {job_id} after {timeout_seconds}s"
|
||||
));
|
||||
}
|
||||
thread::sleep(Duration::from_millis(250));
|
||||
}
|
||||
Ok(json!({
|
||||
"status": "launched",
|
||||
"jobId": job_id,
|
||||
"pid": child.id(),
|
||||
"stdout": stdout_path,
|
||||
"stderr": stderr_path,
|
||||
"note": "Worker runtime is detached; coordinator observes completion through runtime-spine role/reorient result polling.",
|
||||
}))
|
||||
}
|
||||
|
||||
fn wait_for_role_result(
|
||||
fn read_role_result(
|
||||
client: &mut status_cli::AppServerClient,
|
||||
thread_id: &str,
|
||||
role_id: &str,
|
||||
args: &Args,
|
||||
) -> Result<Value> {
|
||||
let deadline = Instant::now() + Duration::from_secs(args.timeout_seconds);
|
||||
let mut latest = Value::Null;
|
||||
while Instant::now() < deadline {
|
||||
latest = client.send(
|
||||
"thread/epiphany/roleResult",
|
||||
Some(json!({"threadId": thread_id, "roleId": role_id})),
|
||||
true,
|
||||
)?;
|
||||
if matches!(
|
||||
latest["status"].as_str(),
|
||||
Some("completed" | "failed" | "cancelled")
|
||||
) {
|
||||
return Ok(latest);
|
||||
}
|
||||
thread::sleep(Duration::from_secs_f64(args.poll_seconds));
|
||||
}
|
||||
Ok(latest)
|
||||
client.send(
|
||||
"thread/epiphany/roleResult",
|
||||
Some(json!({"threadId": thread_id, "roleId": role_id})),
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
fn wait_for_reorient_result(
|
||||
fn read_reorient_result(
|
||||
client: &mut status_cli::AppServerClient,
|
||||
thread_id: &str,
|
||||
args: &Args,
|
||||
) -> Result<Value> {
|
||||
let deadline = Instant::now() + Duration::from_secs(args.timeout_seconds);
|
||||
let mut latest = Value::Null;
|
||||
while Instant::now() < deadline {
|
||||
latest = client.send(
|
||||
"thread/epiphany/reorientResult",
|
||||
Some(json!({"threadId": thread_id, "bindingId": REORIENT_BINDING_ID})),
|
||||
true,
|
||||
)?;
|
||||
if matches!(
|
||||
latest["status"].as_str(),
|
||||
Some("completed" | "failed" | "cancelled")
|
||||
) {
|
||||
return Ok(latest);
|
||||
}
|
||||
thread::sleep(Duration::from_secs_f64(args.poll_seconds));
|
||||
}
|
||||
Ok(latest)
|
||||
client.send(
|
||||
"thread/epiphany/reorientResult",
|
||||
Some(json!({"threadId": thread_id, "bindingId": REORIENT_BINDING_ID})),
|
||||
true,
|
||||
)
|
||||
}
|
||||
|
||||
fn maybe_apply_role_self_patch(accepted: &Value, agent_memory_dir: &Path) -> Result<Option<Value>> {
|
||||
|
|
@ -1324,6 +1355,13 @@ fn is_stop_action(action: &str) -> bool {
|
|||
)
|
||||
}
|
||||
|
||||
fn is_result_review_action(action: &str) -> bool {
|
||||
matches!(
|
||||
action,
|
||||
"reviewModelingResult" | "reviewVerificationResult" | "reviewReorientResult"
|
||||
)
|
||||
}
|
||||
|
||||
fn write_json(path: &Path, value: &Value) -> Result<()> {
|
||||
if let Some(parent) = path.parent() {
|
||||
fs::create_dir_all(parent)?;
|
||||
|
|
|
|||
|
|
@ -652,6 +652,19 @@ pub fn recommend_coordinator_action(
|
|||
);
|
||||
}
|
||||
|
||||
if input.signals.modeling_result_status == EpiphanyCoordinatorRoleResultStatus::Failed
|
||||
&& !input.modeling_result_accepted
|
||||
{
|
||||
return build(
|
||||
EpiphanyCoordinatorAction::ReviewModelingResult,
|
||||
Some(EpiphanyCoordinatorRoleId::Modeling),
|
||||
Some(EpiphanyCoordinatorSceneAction::RoleResult),
|
||||
false,
|
||||
false,
|
||||
"The modeling/checkpoint worker failed; inspect the failed result before verification or implementation continues.",
|
||||
);
|
||||
}
|
||||
|
||||
if matches!(
|
||||
input.signals.modeling_result_status,
|
||||
EpiphanyCoordinatorRoleResultStatus::Pending | EpiphanyCoordinatorRoleResultStatus::Running
|
||||
|
|
@ -1161,6 +1174,19 @@ mod tests {
|
|||
);
|
||||
assert!(wait_for_modeling.reason.contains("stale verification"));
|
||||
|
||||
let review_failed_modeling = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
signals: EpiphanyCoordinatorSignals {
|
||||
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Failed,
|
||||
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
|
||||
},
|
||||
..input()
|
||||
});
|
||||
assert_eq!(
|
||||
review_failed_modeling.action,
|
||||
EpiphanyCoordinatorAction::ReviewModelingResult
|
||||
);
|
||||
assert!(!review_failed_modeling.can_auto_run);
|
||||
|
||||
let relaunch_unreviewable_modeling =
|
||||
recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
signals: EpiphanyCoordinatorSignals {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use epiphany_openai_runtime::complete_worker_job_from_assistant_text;
|
|||
use epiphany_openai_runtime::default_codex_home;
|
||||
use epiphany_openai_runtime::default_options;
|
||||
use epiphany_openai_runtime::ensure_openai_runtime_ready;
|
||||
use epiphany_openai_runtime::fail_worker_job;
|
||||
use epiphany_openai_runtime::load_worker_launch_request;
|
||||
use epiphany_openai_runtime::record_openai_events;
|
||||
use epiphany_openai_runtime::run_model_turn;
|
||||
|
|
@ -73,19 +74,38 @@ async fn main() -> Result<()> {
|
|||
"run-worker" => {
|
||||
let options = parse_run_worker_options(args.collect())?;
|
||||
require_supported_provider(&options.provider)?;
|
||||
let summary = if options.auto_tools {
|
||||
run_worker_launch_with_tool_continuation(options).await?
|
||||
let timeout_seconds = options.max_runtime_seconds;
|
||||
let timeout_store = options.store_path.clone();
|
||||
let timeout_job_id = options.job_id.clone();
|
||||
let summary = if let Some(seconds) = timeout_seconds {
|
||||
match tokio::time::timeout(
|
||||
std::time::Duration::from_secs(seconds),
|
||||
run_worker_options(options),
|
||||
)
|
||||
.await
|
||||
{
|
||||
Ok(result) => result?,
|
||||
Err(_) => {
|
||||
let summary = format!("Worker runtime timed out after {seconds} seconds.");
|
||||
let result = fail_worker_job(
|
||||
&timeout_store,
|
||||
&timeout_job_id,
|
||||
summary.clone(),
|
||||
"Inspect provider/tool transport before relaunching the worker."
|
||||
.to_string(),
|
||||
)?;
|
||||
json!({
|
||||
"status": "timeout",
|
||||
"jobId": timeout_job_id,
|
||||
"workerResultId": result.result_id,
|
||||
"verdict": result.verdict,
|
||||
"summary": summary,
|
||||
"nextSafeMove": result.next_safe_move,
|
||||
})
|
||||
}
|
||||
}
|
||||
} else {
|
||||
serde_json::to_value(
|
||||
run_worker_launch(EpiphanyWorkerRuntimeOptions {
|
||||
store_path: options.store_path,
|
||||
codex_home: options.codex_home,
|
||||
provider: options.provider,
|
||||
job_id: options.job_id,
|
||||
model: options.model,
|
||||
})
|
||||
.await?,
|
||||
)?
|
||||
run_worker_options(options).await?
|
||||
};
|
||||
print_json(&summary)?;
|
||||
}
|
||||
|
|
@ -265,6 +285,7 @@ struct SmokeCliOptions {
|
|||
codex_home: PathBuf,
|
||||
}
|
||||
|
||||
#[derive(Clone)]
|
||||
struct RunWorkerCliOptions {
|
||||
provider: String,
|
||||
store_path: PathBuf,
|
||||
|
|
@ -275,6 +296,7 @@ struct RunWorkerCliOptions {
|
|||
tool_adapter_bin: Option<PathBuf>,
|
||||
cwd: Option<PathBuf>,
|
||||
max_tool_rounds: usize,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
}
|
||||
|
||||
struct ToolFollowupCliOptions {
|
||||
|
|
@ -373,6 +395,7 @@ fn parse_run_worker_options(args: Vec<String>) -> Result<RunWorkerCliOptions> {
|
|||
let mut tool_adapter_bin = None;
|
||||
let mut cwd = None;
|
||||
let mut max_tool_rounds = 4usize;
|
||||
let mut max_runtime_seconds = None;
|
||||
let mut iter = args.into_iter();
|
||||
while let Some(arg) = iter.next() {
|
||||
match arg.as_str() {
|
||||
|
|
@ -389,6 +412,9 @@ fn parse_run_worker_options(args: Vec<String>) -> Result<RunWorkerCliOptions> {
|
|||
"--max-tool-rounds" => {
|
||||
max_tool_rounds = next_value(&mut iter, "--max-tool-rounds")?.parse()?
|
||||
}
|
||||
"--max-runtime-seconds" => {
|
||||
max_runtime_seconds = Some(next_value(&mut iter, "--max-runtime-seconds")?.parse()?)
|
||||
}
|
||||
other => return Err(anyhow!("unknown run-worker argument: {other}")),
|
||||
}
|
||||
}
|
||||
|
|
@ -402,6 +428,7 @@ fn parse_run_worker_options(args: Vec<String>) -> Result<RunWorkerCliOptions> {
|
|||
tool_adapter_bin,
|
||||
cwd,
|
||||
max_tool_rounds,
|
||||
max_runtime_seconds,
|
||||
})
|
||||
}
|
||||
|
||||
|
|
@ -535,6 +562,23 @@ async fn run_worker_launch_with_tool_continuation(
|
|||
}))
|
||||
}
|
||||
|
||||
async fn run_worker_options(options: RunWorkerCliOptions) -> Result<serde_json::Value> {
|
||||
if options.auto_tools {
|
||||
run_worker_launch_with_tool_continuation(options).await
|
||||
} else {
|
||||
Ok(serde_json::to_value(
|
||||
run_worker_launch(EpiphanyWorkerRuntimeOptions {
|
||||
store_path: options.store_path,
|
||||
codex_home: options.codex_home,
|
||||
provider: options.provider,
|
||||
job_id: options.job_id,
|
||||
model: options.model,
|
||||
})
|
||||
.await?,
|
||||
)?)
|
||||
}
|
||||
}
|
||||
|
||||
fn run_tool_adapter(
|
||||
tool_adapter_bin: &PathBuf,
|
||||
store_path: &PathBuf,
|
||||
|
|
|
|||
|
|
@ -490,6 +490,27 @@ pub fn complete_worker_job_from_assistant_text(
|
|||
)
|
||||
}
|
||||
|
||||
pub fn fail_worker_job(
|
||||
store_path: impl AsRef<Path>,
|
||||
job_id: &str,
|
||||
summary: String,
|
||||
next_safe_move: String,
|
||||
) -> Result<epiphany_core::EpiphanyRuntimeJobResult> {
|
||||
complete_runtime_job(
|
||||
store_path,
|
||||
RuntimeSpineJobResultOptions {
|
||||
result_id: format!("result-worker-{job_id}"),
|
||||
job_id: job_id.to_string(),
|
||||
completed_at: now(),
|
||||
verdict: "failed".to_string(),
|
||||
summary,
|
||||
next_safe_move,
|
||||
evidence_refs: Vec::new(),
|
||||
artifact_refs: Vec::new(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
pub fn ensure_openai_runtime_ready(options: &EpiphanyOpenAiRuntimeOptions) -> Result<()> {
|
||||
let status = runtime_spine_status(&options.store_path)?;
|
||||
if status.present {
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
## Current Orientation
|
||||
|
||||
- Do not copy exact branch or HEAD from this note. Run `git status --short --branch` and `git log --oneline -5`.
|
||||
- The repo now has a one-command local operator path: `.\tools\epiphany_local_run.ps1`. Default mode is `smoke`; it builds the retained Codex app-server compatibility edge, builds native Epiphany operator binaries, runs the coordinator smoke, and writes launcher artifacts under `.epiphany-run/` plus coordinator artifacts under `.epiphany-dogfood/`. `-Mode status` is now Epiphany-native: it builds only Epiphany operator binaries, reads `state/thread-state.msgpack` when present, derives status through `epiphany-core`, and does not start or require `codex-app-server`. Use `-Mode plan` or `-Mode run -MaxSteps 4` for the raw bridge-equipped coordinator entrypoints; use `-Mode mvp -FaceInput "<operator request>" -MaxSteps 4` for the local product cycle that projects Face's character turn, writes a Face/Aquarium bubble, bootstraps a minimal local checkpoint for fresh threads, runs the coordinator with auto-tools, then runs heartbeat sleep/dream maintenance. Live plan/run/mvp modes use the workspace `state/runtime-spine.msgpack`, because CodexThread launch writes worker requests there; the run bundle remains artifact evidence, not runtime lifecycle authority. Add `-ThreadId <id>` and `-Workspace <path>` to inspect or continue an existing thread. `status`, `plan`, and `smoke` do not spend model calls; `run` and `mvp` build and use `epiphany-openai-runtime`. Current live blocker: coordinator-run still waits synchronously for model-worker stdout; one `gpt-5.4` worker completed through the direct Codex/OpenAI spine, but later live MVP runs timed out with empty worker stdout/stderr even at 600 seconds. Next cut should detach/poll workers through runtime-spine progress receipts instead of inflating the timeout again.
|
||||
- The repo now has a one-command local operator path: `.\tools\epiphany_local_run.ps1`. Default mode is `smoke`; it builds the retained Codex app-server compatibility edge, builds native Epiphany operator binaries, runs the coordinator smoke, and writes launcher artifacts under `.epiphany-run/` plus coordinator artifacts under `.epiphany-dogfood/`. `-Mode status` is now Epiphany-native: it builds only Epiphany operator binaries, reads `state/thread-state.msgpack` when present, derives status through `epiphany-core`, and does not start or require `codex-app-server`. Use `-Mode plan` or `-Mode run -MaxSteps 4` for the raw bridge-equipped coordinator entrypoints; use `-Mode mvp -FaceInput "<operator request>" -MaxSteps 4` for the local product cycle that projects Face's character turn, writes a Face/Aquarium bubble, bootstraps a minimal local checkpoint for fresh threads, runs the coordinator with auto-tools, then runs heartbeat sleep/dream maintenance. Live plan/run/mvp modes use the workspace `state/runtime-spine.msgpack`, because CodexThread launch writes worker requests there; the run bundle remains artifact evidence, not runtime lifecycle authority. Add `-ThreadId <id>` and `-Workspace <path>` to inspect or continue an existing thread. `status`, `plan`, and `smoke` do not spend model calls; `run` and `mvp` build and use `epiphany-openai-runtime`. Coordinator workers now launch detached and are polled through runtime-spine instead of blocking the coordinator. MVP runs are non-ephemeral by default so `-ThreadId <id>` can resume and poll later. `-MaxRuntimeSeconds <n>` is passed into worker runtime; timeout writes a failed worker receipt and exits. Failed modeling now blocks downstream verification until the failed result is reviewed.
|
||||
- Local operator runs now write typed CultMesh intent/receipt documents to `.epiphany-run/cultmesh/operator-runs.ccmp` through `epiphany-operator-run`. The wrapper writes intent before acting and a completion receipt after success; this is the local consent/trace rail, not a hidden scheduler queue.
|
||||
- Status-mode local runs now also write a native CultMesh operator snapshot to `.epiphany-run/cultmesh/operator-snapshots.ccmp` through `epiphany-operator-snapshot`. That snapshot distills the operator-safe MVP status artifact into typed fields such as thread id, state status, coordinator action, CRRC action, reorient action, available actions, and artifact refs; it does not preserve the raw JSON status blob as internal state.
|
||||
- `epiphany-mvp-status --source native` is the current provider-neutral status boundary. It projects scene, pressure, jobs, roles, planning, reorient, CRRC, and coordinator status from native core surfaces and returns provider/runtime worker results as `backendMissing` placeholders instead of asking Codex for model-worker state. Keep future pluggable model-provider work behind launch/result/runtime documents; do not let provider choice leak into status, prompt authority, scheduler policy, or durable `EpiphanyThreadState`.
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -568,4 +568,4 @@ current_status:
|
|||
materializes complete MCP-shaped model tool calls as typed tool invocation
|
||||
intents, and the Codex MCP spine can consume those intents from the mixed
|
||||
runtime-spine store and emit typed success/failure receipts.
|
||||
next_action: Cut the synchronous worker-runtime wait out of `epiphany-mvp-coordinator`: launch model workers as detached runtime-spine jobs with pollable progress/timeout receipts, because live `gpt-5.4` Codex transport can complete but later MVP runs timed out with empty stdout/stderr while the coordinator waited on the child process.
|
||||
next_action: Exercise a normal-timeout live MVP worker pass and harden the next receipt edge that fails: coordinator workers now launch detached, local MVP threads are resumable, worker runtime enforces max-runtime timeout receipts, and failed modeling blocks downstream verification until reviewed.
|
||||
|
|
|
|||
|
|
@ -8,6 +8,7 @@ param(
|
|||
[string]$TargetDir = "C:\Users\Meta\.cargo-target-codex",
|
||||
[int]$MaxSteps = 4,
|
||||
[int]$TimeoutSeconds = 600,
|
||||
[int]$MaxRuntimeSeconds = 180,
|
||||
[string]$FaceInput = "",
|
||||
[switch]$SkipBuild,
|
||||
[switch]$AutoReview,
|
||||
|
|
@ -17,6 +18,42 @@ param(
|
|||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function ConvertTo-NativeArgument {
|
||||
param([string]$Argument)
|
||||
|
||||
if ($Argument.Length -eq 0) {
|
||||
return '""'
|
||||
}
|
||||
if ($Argument -notmatch '[\s"]') {
|
||||
return $Argument
|
||||
}
|
||||
|
||||
$quoted = '"'
|
||||
$backslashes = 0
|
||||
foreach ($character in $Argument.ToCharArray()) {
|
||||
if ($character -eq '\') {
|
||||
$backslashes += 1
|
||||
continue
|
||||
}
|
||||
if ($character -eq '"') {
|
||||
$quoted += ('\' * (($backslashes * 2) + 1))
|
||||
$quoted += '"'
|
||||
$backslashes = 0
|
||||
continue
|
||||
}
|
||||
if ($backslashes -gt 0) {
|
||||
$quoted += ('\' * $backslashes)
|
||||
$backslashes = 0
|
||||
}
|
||||
$quoted += $character
|
||||
}
|
||||
if ($backslashes -gt 0) {
|
||||
$quoted += ('\' * ($backslashes * 2))
|
||||
}
|
||||
$quoted += '"'
|
||||
return $quoted
|
||||
}
|
||||
|
||||
function Invoke-Checked {
|
||||
param(
|
||||
[string]$Label,
|
||||
|
|
@ -28,24 +65,28 @@ function Invoke-Checked {
|
|||
)
|
||||
|
||||
Write-Host "==> $Label"
|
||||
Push-Location -LiteralPath $WorkingDirectory
|
||||
$previousErrorActionPreference = $ErrorActionPreference
|
||||
try {
|
||||
$ErrorActionPreference = "Continue"
|
||||
if ($StdoutPath -ne "" -and $StderrPath -ne "") {
|
||||
& $FilePath @Arguments 1> $StdoutPath 2> $StderrPath
|
||||
} elseif ($StdoutPath -ne "") {
|
||||
& $FilePath @Arguments 1> $StdoutPath
|
||||
} elseif ($StderrPath -ne "") {
|
||||
& $FilePath @Arguments 2> $StderrPath
|
||||
} else {
|
||||
& $FilePath @Arguments
|
||||
}
|
||||
$exitCode = $LASTEXITCODE
|
||||
} finally {
|
||||
$ErrorActionPreference = $previousErrorActionPreference
|
||||
Pop-Location
|
||||
$commandLine = ConvertTo-NativeArgument $FilePath
|
||||
if ($Arguments.Count -gt 0) {
|
||||
$commandLine += " "
|
||||
$commandLine += (($Arguments | ForEach-Object { ConvertTo-NativeArgument $_ }) -join " ")
|
||||
}
|
||||
if ($StdoutPath -ne "") {
|
||||
$commandLine += " 1>"
|
||||
$commandLine += ConvertTo-NativeArgument $StdoutPath
|
||||
}
|
||||
if ($StderrPath -ne "") {
|
||||
$commandLine += " 2>"
|
||||
$commandLine += ConvertTo-NativeArgument $StderrPath
|
||||
}
|
||||
$processInfo = [System.Diagnostics.ProcessStartInfo]::new()
|
||||
$processInfo.FileName = $env:ComSpec
|
||||
$processInfo.Arguments = "/d /c " + $commandLine
|
||||
$processInfo.WorkingDirectory = $WorkingDirectory
|
||||
$processInfo.UseShellExecute = $false
|
||||
$processInfo.CreateNoWindow = $true
|
||||
$process = [System.Diagnostics.Process]::Start($processInfo)
|
||||
$process.WaitForExit()
|
||||
$exitCode = $process.ExitCode
|
||||
if ($exitCode -ne 0) {
|
||||
throw "$Label failed with exit code $exitCode"
|
||||
}
|
||||
|
|
@ -160,14 +201,10 @@ foreach ($required in $requiredBinaries) {
|
|||
}
|
||||
}
|
||||
|
||||
$ephemeralArg = "--ephemeral"
|
||||
if ($NoEphemeral) {
|
||||
$ephemeralArg = "--no-ephemeral"
|
||||
}
|
||||
|
||||
$resultPath = ""
|
||||
$autoReviewValue = $AutoReview.IsPresent.ToString().ToLowerInvariant()
|
||||
$noEphemeralValue = $NoEphemeral.IsPresent.ToString().ToLowerInvariant()
|
||||
$effectiveNoEphemeral = $NoEphemeral.IsPresent -or ($Mode -eq "mvp")
|
||||
$noEphemeralValue = $effectiveNoEphemeral.ToString().ToLowerInvariant()
|
||||
$operatorRunIntentArgs = @(
|
||||
"intent",
|
||||
"--store", $operatorRunStore,
|
||||
|
|
@ -329,7 +366,8 @@ if ($liveRuntimeMode) {
|
|||
"--runtime-store", $runtimeStore,
|
||||
"--mode", "run",
|
||||
"--max-steps", "$MaxSteps",
|
||||
"--timeout-seconds", "$TimeoutSeconds"
|
||||
"--timeout-seconds", "$TimeoutSeconds",
|
||||
"--max-runtime-seconds", "$MaxRuntimeSeconds"
|
||||
)
|
||||
if ($AutoReview) {
|
||||
$runArgs += "--auto-review"
|
||||
|
|
@ -337,6 +375,9 @@ if ($liveRuntimeMode) {
|
|||
if ($Mode -eq "mvp" -and $ThreadId -eq "") {
|
||||
$runArgs += @("--bootstrap-local-state", "--bootstrap-objective", $FaceInput)
|
||||
}
|
||||
if ($Mode -eq "mvp" -or $NoEphemeral) {
|
||||
$runArgs += "--no-ephemeral"
|
||||
}
|
||||
if ($ThreadId -ne "") {
|
||||
$runArgs += @("--thread-id", $ThreadId, "--no-ephemeral")
|
||||
}
|
||||
|
|
|
|||
Reference in a new issue