diff --git a/epiphany-core/src/bin/epiphany-hands-action.rs b/epiphany-core/src/bin/epiphany-hands-action.rs index d16899e5..7ee3f079 100644 --- a/epiphany-core/src/bin/epiphany-hands-action.rs +++ b/epiphany-core/src/bin/epiphany-hands-action.rs @@ -550,6 +550,7 @@ mod tests { use epiphany_core::runtime_hands_command_receipt; use epiphany_core::runtime_hands_commit_receipt; use epiphany_core::runtime_hands_patch_receipt; + use epiphany_core::runtime_latest_hands_receipt_chain_after; #[test] fn records_patch_command_and_commit_receipts_against_approved_gate() -> Result<()> { @@ -608,7 +609,7 @@ mod tests { }))?, )?; - record_pass( + let result = record_pass( &store, RecordPassArgs { gate: GateArgs { @@ -628,6 +629,37 @@ mod tests { }, )?; + let patch_id = result + .pointer("/patch/receiptId") + .and_then(serde_json::Value::as_str) + .expect("record-pass should emit patch receipt id"); + let command_id = result + .pointer("/command/receiptId") + .and_then(serde_json::Value::as_str) + .expect("record-pass should emit command receipt id"); + let commit_id = result + .pointer("/commit/receiptId") + .and_then(serde_json::Value::as_str) + .expect("record-pass should emit commit receipt id"); + assert!(runtime_hands_patch_receipt(&store, patch_id)?.is_some()); + assert!(runtime_hands_command_receipt(&store, command_id)?.is_some()); + assert!(runtime_hands_commit_receipt(&store, commit_id)?.is_some()); + + let chain = + runtime_latest_hands_receipt_chain_after(&store, "2026-06-02T00:00:02Z")? + .expect("record-pass should produce a complete Hands receipt chain"); + assert_eq!(chain.patch_receipt_id, patch_id); + assert_eq!(chain.command_receipt_id, command_id); + assert_eq!(chain.commit_receipt_id, commit_id); + assert_eq!(chain.intent_id, "hands-intent-test"); + assert_eq!(chain.review_id, "hands-review-test"); + assert_eq!(chain.runtime_job_id, "hands-job-test"); + assert_eq!(chain.substrate_gate_grant_receipt_id, "substrate-grant-test"); + assert_eq!(chain.command, "cargo test"); + assert_eq!(chain.exit_code, "0"); + assert_eq!(chain.commit_sha, "def456"); + assert_eq!(chain.changed_paths, vec!["src/lib.rs".to_string()]); + Ok(()) } diff --git a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs index df90fa87..bbe2a486 100644 --- a/epiphany-core/src/bin/epiphany-mvp-coordinator.rs +++ b/epiphany-core/src/bin/epiphany-mvp-coordinator.rs @@ -51,6 +51,7 @@ mod status_cli; const DEFAULT_APP_SERVER: &str = r"C:\Users\Meta\.cargo-target-codex\debug\codex-app-server.exe"; const DEFAULT_MODEL_RUNTIME_BIN: &str = "epiphany-model-runtime"; const DEFAULT_TOOL_ADAPTER_BIN: &str = "epiphany-tool-codex-mcp-spine"; +const WORKER_AUTO_TOOL_MAX_ROUNDS: usize = 12; const REORIENT_BINDING_ID: &str = "reorient-worker"; const GRAPH_NODE_ID: &str = "reorient-target"; const WATCHED_RELATIVE_PATH: &str = "src/reorient_target.rs"; @@ -1154,7 +1155,9 @@ fn launch_worker_runtime_detached( .arg("--tool-adapter-bin") .arg(tool_adapter_bin) .arg("--cwd") - .arg(cwd); + .arg(cwd) + .arg("--max-tool-rounds") + .arg(WORKER_AUTO_TOOL_MAX_ROUNDS.to_string()); } let stdout_file = fs::File::create(&stdout_path) .with_context(|| format!("failed to create {}", stdout_path.display()))?; diff --git a/epiphany-core/src/bin/epiphany-mvp-status.rs b/epiphany-core/src/bin/epiphany-mvp-status.rs index 5ffcf823..7d2fb4e8 100644 --- a/epiphany-core/src/bin/epiphany-mvp-status.rs +++ b/epiphany-core/src/bin/epiphany-mvp-status.rs @@ -120,6 +120,8 @@ struct Args { result: Option, transcript: PathBuf, stderr: PathBuf, + interrupt_binding: Option, + interrupt_reason: Option, } impl Args { @@ -145,6 +147,8 @@ impl Args { stderr: root .join(".epiphany-status") .join("epiphany-mvp-status-server.stderr.log"), + interrupt_binding: None, + interrupt_reason: None, }; while let Some(arg) = args.next() { match arg.as_str() { @@ -167,6 +171,12 @@ impl Args { "--result" => parsed.result = Some(take_path(&mut args, "--result")?), "--transcript" => parsed.transcript = take_path(&mut args, "--transcript")?, "--stderr" => parsed.stderr = take_path(&mut args, "--stderr")?, + "--interrupt-binding" => { + parsed.interrupt_binding = Some(take_string(&mut args, "--interrupt-binding")?) + } + "--interrupt-reason" => { + parsed.interrupt_reason = Some(take_string(&mut args, "--interrupt-reason")?) + } _ => return Err(anyhow!("unknown argument: {arg}")), } } @@ -175,12 +185,59 @@ impl Args { } fn run_status(args: &Args) -> Result { + if args.interrupt_binding.is_some() { + return run_codex_interrupt(args); + } match args.source { StatusSource::Native => run_native_status(args), StatusSource::Codex => run_codex_status(args), } } +fn run_codex_interrupt(args: &Args) -> Result { + if args.source != StatusSource::Codex { + return Err(anyhow!("--interrupt-binding requires Codex/app-server status source")); + } + let thread_id = args + .thread_id + .as_ref() + .ok_or_else(|| anyhow!("--interrupt-binding requires --thread-id"))?; + let binding_id = args + .interrupt_binding + .as_ref() + .ok_or_else(|| anyhow!("--interrupt-binding requires a binding id"))?; + let app_server = absolute_path(&args.app_server)?; + let codex_home = absolute_path(&args.codex_home)?; + let transcript = absolute_path(&args.transcript)?; + let stderr = absolute_path(&args.stderr)?; + let mut client = AppServerClient::start(&app_server, &codex_home, &transcript, &stderr)?; + client.send( + "initialize", + Some(json!({ + "clientInfo": { + "name": "epiphany-mvp-status", + "title": "Epiphany MVP Status", + "version": "0.1.0", + }, + "capabilities": {"experimentalApi": true}, + })), + true, + )?; + client.send("initialized", None, false)?; + if !args.ephemeral { + client.send("thread/resume", Some(json!({"threadId": thread_id})), true)?; + } + client.send( + "thread/epiphany/jobInterrupt", + Some(json!({ + "threadId": thread_id, + "bindingId": binding_id, + "reason": args.interrupt_reason, + })), + true, + ) +} + fn run_native_status(args: &Args) -> Result { let cwd = absolute_path(&args.cwd)?; let store_path = absolute_path(&args.thread_state_store)?; diff --git a/state/ledgers.msgpack b/state/ledgers.msgpack index d25d0bee..e46d8a42 100644 Binary files a/state/ledgers.msgpack and b/state/ledgers.msgpack differ