Give Soul read-only source tools
This commit is contained in:
parent
6c1fb3bb50
commit
660f61f9a6
9 changed files with 476 additions and 5 deletions
|
|
@ -99,6 +99,7 @@ Act as the Epiphany verification/review specialist for one bounded pass.
|
|||
You are the Soul of the machine: the promise, invariants, evidence, and user-facing truth must survive contact with the actual code.
|
||||
The Soul improves itself by becoming harder to fool. Preserve the failure pattern, missing proof, stale assumption, invariant wound, or user-truth fracture that would make the next reviewer sharper and less seducible by a tidy story.
|
||||
In the work loop, Soul follows Hands and precedes Proprioception: verify the concrete Hands receipts, source diff, command artifacts, and user-facing claim before Proprioception updates the body map.
|
||||
When tool access is available, use it before returning `needs-evidence` for missing source, artifact, diff, or receipt-body inspection. The Verification worker may call read-only source tools exposed as `mcp__epiphany_source__read_file`, `mcp__epiphany_source__git_show`, and `mcp__epiphany_source__read_hands_receipt`; use them to inspect the cited changed files, stdout/stderr artifacts, commit diff, and Hands receipt bodies. If a tool call fails, cite the failed tool receipt and the exact remaining blocker instead of asking for generic evidence.
|
||||
Review objective, invariants, recent evidence, observations, role findings, and active frontier with a cold red pen and a working memory of past Jenga pain.
|
||||
Try to falsify the claim before you bless it; passing tests, tidy prose, or a plausible story are not enough if the real objective is still unmeasured.
|
||||
Treat Greenspun-shaped invention as a review risk. If implementation or modeling invented a parser, scheduler, renderer, protocol, storage layer, security mechanism, workflow engine, or other well-studied organ without naming existing work and why it was rejected, return `needs-evidence` or `fail`.
|
||||
|
|
|
|||
|
|
@ -54,6 +54,8 @@ pub struct EpiphanyModelRequest {
|
|||
pub output_contract_id: Option<String>,
|
||||
#[cultcache(key = 11, default)]
|
||||
pub previous_response_id: Option<String>,
|
||||
#[cultcache(key = 12, default)]
|
||||
pub tools: Vec<EpiphanyModelToolDefinition>,
|
||||
}
|
||||
|
||||
impl EpiphanyModelRequest {
|
||||
|
|
@ -77,10 +79,18 @@ impl EpiphanyModelRequest {
|
|||
service_tier: None,
|
||||
output_contract_id: None,
|
||||
previous_response_id: None,
|
||||
tools: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct EpiphanyModelToolDefinition {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub parameters_json: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum EpiphanyModelInputItem {
|
||||
UserText { text: String },
|
||||
|
|
|
|||
|
|
@ -67,6 +67,8 @@ pub struct EpiphanyOpenAiModelRequest {
|
|||
pub output_contract_id: Option<String>,
|
||||
#[cultcache(key = 10, default)]
|
||||
pub previous_response_id: Option<String>,
|
||||
#[cultcache(key = 11, default)]
|
||||
pub tools: Vec<EpiphanyOpenAiToolDefinition>,
|
||||
}
|
||||
|
||||
impl EpiphanyOpenAiModelRequest {
|
||||
|
|
@ -88,10 +90,18 @@ impl EpiphanyOpenAiModelRequest {
|
|||
service_tier: None,
|
||||
output_contract_id: None,
|
||||
previous_response_id: None,
|
||||
tools: Vec::new(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
|
||||
pub struct EpiphanyOpenAiToolDefinition {
|
||||
pub name: String,
|
||||
pub description: String,
|
||||
pub parameters_json: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Serialize, Deserialize)]
|
||||
pub enum EpiphanyOpenAiInputItem {
|
||||
UserText { text: String },
|
||||
|
|
|
|||
|
|
@ -215,7 +215,11 @@ pub fn responses_body_from_epiphany(
|
|||
.into_iter()
|
||||
.map(openai_input_item_from_epiphany_input)
|
||||
.collect(),
|
||||
tools: Vec::new(),
|
||||
tools: request
|
||||
.tools
|
||||
.into_iter()
|
||||
.map(openai_tool_from_epiphany_tool)
|
||||
.collect::<Result<Vec<_>>>()?,
|
||||
tool_choice: "auto".to_string(),
|
||||
parallel_tool_calls: false,
|
||||
reasoning: Some(EpiphanyResponsesReasoning {
|
||||
|
|
@ -234,6 +238,20 @@ pub fn responses_body_from_epiphany(
|
|||
serde_json::to_value(body).context("failed to encode typed Epiphany Responses body")
|
||||
}
|
||||
|
||||
fn openai_tool_from_epiphany_tool(
|
||||
tool: epiphany_openai_adapter::EpiphanyOpenAiToolDefinition,
|
||||
) -> Result<serde_json::Value> {
|
||||
let parameters: serde_json::Value = serde_json::from_str(&tool.parameters_json)
|
||||
.with_context(|| format!("tool {} parameters_json is not valid JSON", tool.name))?;
|
||||
Ok(serde_json::json!({
|
||||
"type": "function",
|
||||
"name": tool.name,
|
||||
"description": tool.description,
|
||||
"parameters": parameters,
|
||||
"strict": false
|
||||
}))
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, Serialize)]
|
||||
struct EpiphanyResponsesBody {
|
||||
model: String,
|
||||
|
|
@ -615,6 +633,18 @@ mod tests {
|
|||
request.reasoning_summary = Some("concise".to_string());
|
||||
request.service_tier = Some("flex".to_string());
|
||||
request.previous_response_id = Some("resp-1".to_string());
|
||||
request
|
||||
.tools
|
||||
.push(epiphany_openai_adapter::EpiphanyOpenAiToolDefinition {
|
||||
name: "mcp__epiphany_source__read_file".to_string(),
|
||||
description: "Read a bounded file slice.".to_string(),
|
||||
parameters_json: serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {"path": {"type": "string"}},
|
||||
"required": ["path"]
|
||||
})
|
||||
.to_string(),
|
||||
});
|
||||
|
||||
let responses = responses_body_from_epiphany(request).expect("request should map");
|
||||
|
||||
|
|
@ -625,6 +655,10 @@ mod tests {
|
|||
assert_eq!(responses["stream"], true);
|
||||
assert_eq!(responses["store"], false);
|
||||
assert_eq!(responses["service_tier"], "flex");
|
||||
assert_eq!(responses["tools"].as_array().expect("tools").len(), 0);
|
||||
assert_eq!(responses["tools"].as_array().expect("tools").len(), 1);
|
||||
assert_eq!(
|
||||
responses["tools"][0]["name"],
|
||||
"mcp__epiphany_source__read_file"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -28,11 +28,13 @@ use epiphany_model_adapter::EpiphanyModelReceipt;
|
|||
use epiphany_model_adapter::EpiphanyModelRequest;
|
||||
use epiphany_model_adapter::EpiphanyModelStreamEvent;
|
||||
use epiphany_model_adapter::EpiphanyModelStreamPayload;
|
||||
use epiphany_model_adapter::EpiphanyModelToolDefinition;
|
||||
use epiphany_openai_adapter::EpiphanyOpenAiAdapterStatus;
|
||||
use epiphany_openai_adapter::EpiphanyOpenAiInputItem;
|
||||
use epiphany_openai_adapter::EpiphanyOpenAiModelRequest;
|
||||
use epiphany_openai_adapter::EpiphanyOpenAiStreamEvent;
|
||||
use epiphany_openai_adapter::EpiphanyOpenAiStreamPayload;
|
||||
use epiphany_openai_adapter::EpiphanyOpenAiToolDefinition;
|
||||
use epiphany_openai_codex_spine::EpiphanyCodexOpenAiTransport;
|
||||
use epiphany_openai_codex_spine::EpiphanyResponsesFrameObservation;
|
||||
use epiphany_openai_codex_spine::auth_manager;
|
||||
|
|
@ -560,12 +562,16 @@ pub fn build_worker_model_request(
|
|||
);
|
||||
let launch_document_text = serde_json::to_string_pretty(&launch_document)
|
||||
.context("failed to render worker launch document for model input")?;
|
||||
let mut instructions = worker_instructions(launch_request, &launch_document);
|
||||
if launch_request.binding_id == epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID {
|
||||
instructions.push_str("\n\nTool mandate: before returning `needs-evidence` because source files, command artifacts, commit diffs, or Hands receipt bodies are not inspectable, call the read-only source tools available on this request. Use `mcp__epiphany_source__read_file` for cited source/artifact paths, `mcp__epiphany_source__git_show` for commit diffs, and `mcp__epiphany_source__read_hands_receipt` for Hands patch/command/commit receipts. If a tool fails, cite that failed tool result and the exact remaining blocker.");
|
||||
}
|
||||
let mut request = EpiphanyModelRequest::new(
|
||||
request_id,
|
||||
format!("worker-{}", launch_request.binding_id),
|
||||
provider,
|
||||
model.to_string(),
|
||||
worker_instructions(launch_request, &launch_document),
|
||||
instructions,
|
||||
);
|
||||
request.input.push(EpiphanyModelInputItem::UserText {
|
||||
text: format!(
|
||||
|
|
@ -575,6 +581,9 @@ pub fn build_worker_model_request(
|
|||
request.reasoning_effort = Some("low".to_string());
|
||||
request.reasoning_summary = Some("concise".to_string());
|
||||
request.output_contract_id = Some(launch_request.output_contract_id.clone());
|
||||
if launch_request.binding_id == epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID {
|
||||
request.tools = verification_source_tools();
|
||||
}
|
||||
Ok(request)
|
||||
}
|
||||
|
||||
|
|
@ -974,6 +983,15 @@ pub fn model_request_from_openai_request(
|
|||
service_tier: request.service_tier.clone(),
|
||||
output_contract_id: request.output_contract_id.clone(),
|
||||
previous_response_id: request.previous_response_id.clone(),
|
||||
tools: request
|
||||
.tools
|
||||
.iter()
|
||||
.map(|tool| EpiphanyModelToolDefinition {
|
||||
name: tool.name.clone(),
|
||||
description: tool.description.clone(),
|
||||
parameters_json: tool.parameters_json.clone(),
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -996,9 +1014,67 @@ pub fn openai_request_from_model_request(
|
|||
service_tier: request.service_tier.clone(),
|
||||
output_contract_id: request.output_contract_id.clone(),
|
||||
previous_response_id: request.previous_response_id.clone(),
|
||||
tools: request
|
||||
.tools
|
||||
.iter()
|
||||
.map(|tool| EpiphanyOpenAiToolDefinition {
|
||||
name: tool.name.clone(),
|
||||
description: tool.description.clone(),
|
||||
parameters_json: tool.parameters_json.clone(),
|
||||
})
|
||||
.collect(),
|
||||
}
|
||||
}
|
||||
|
||||
fn verification_source_tools() -> Vec<EpiphanyModelToolDefinition> {
|
||||
vec![
|
||||
EpiphanyModelToolDefinition {
|
||||
name: "mcp__epiphany_source__read_file".to_string(),
|
||||
description: "Read a bounded UTF-8 text slice from the current workspace for Soul verification. Use only for source files and operator-safe artifacts named in the launch packet.".to_string(),
|
||||
parameters_json: serde_json::json!({
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"path": {"type": "string"},
|
||||
"startLine": {"type": "integer", "minimum": 1},
|
||||
"maxLines": {"type": "integer", "minimum": 1, "maximum": 240}
|
||||
},
|
||||
"required": ["path"]
|
||||
})
|
||||
.to_string(),
|
||||
},
|
||||
EpiphanyModelToolDefinition {
|
||||
name: "mcp__epiphany_source__git_show".to_string(),
|
||||
description: "Read a bounded git show/diff preview for a commit or revision in the current workspace.".to_string(),
|
||||
parameters_json: serde_json::json!({
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"revision": {"type": "string"},
|
||||
"paths": {"type": "array", "items": {"type": "string"}},
|
||||
"maxBytes": {"type": "integer", "minimum": 512, "maximum": 24000}
|
||||
},
|
||||
"required": ["revision"]
|
||||
})
|
||||
.to_string(),
|
||||
},
|
||||
EpiphanyModelToolDefinition {
|
||||
name: "mcp__epiphany_source__read_hands_receipt".to_string(),
|
||||
description: "Read a typed Hands patch, command, or commit receipt body from the runtime-spine store for Soul verification.".to_string(),
|
||||
parameters_json: serde_json::json!({
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {
|
||||
"receiptId": {"type": "string"},
|
||||
"kind": {"type": "string", "enum": ["patch", "command", "commit"]}
|
||||
},
|
||||
"required": ["receiptId", "kind"]
|
||||
})
|
||||
.to_string(),
|
||||
},
|
||||
]
|
||||
}
|
||||
|
||||
fn model_input_from_openai_input(input: &EpiphanyOpenAiInputItem) -> EpiphanyModelInputItem {
|
||||
match input {
|
||||
EpiphanyOpenAiInputItem::UserText { text } => {
|
||||
|
|
@ -1665,6 +1741,7 @@ mod tests {
|
|||
.contains("<epiphany_dynamic_context>")
|
||||
);
|
||||
assert!(model_request.instructions.contains("local Verse: bounded"));
|
||||
assert!(model_request.tools.is_empty());
|
||||
let openai_summary = EpiphanyOpenAiRuntimeRunSummary {
|
||||
store: store.display().to_string(),
|
||||
session_id: "openai-worker-session-modeling-checkpoint-worker".to_string(),
|
||||
|
|
@ -1712,6 +1789,77 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn verification_worker_request_advertises_read_only_source_tools() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
let store = temp.path().join("runtime.msgpack");
|
||||
open_runtime_spine_heartbeat_job(
|
||||
&store,
|
||||
RuntimeSpineHeartbeatJobOptions {
|
||||
runtime_id: "epiphany-test".to_string(),
|
||||
display_name: "Epiphany Test".to_string(),
|
||||
session_id: "epiphany-main".to_string(),
|
||||
objective: "Verify the machine.".to_string(),
|
||||
coordinator_note: "test".to_string(),
|
||||
job_id: "verification-job-1".to_string(),
|
||||
role: "verification".to_string(),
|
||||
binding_id: epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID.to_string(),
|
||||
authority_scope: "epiphany.role.verification".to_string(),
|
||||
instruction: "Return the required verification-result JSON.".to_string(),
|
||||
launch_document: EpiphanyWorkerLaunchDocument::Role(
|
||||
epiphany_core::EpiphanyRoleWorkerLaunchDocument {
|
||||
thread_id: "thread-1".to_string(),
|
||||
role_id: "verification".to_string(),
|
||||
state_revision: 1,
|
||||
objective: Some("Verify Hands receipts.".to_string()),
|
||||
dynamic_prompt_context: Some(
|
||||
"<verification_work_loop_telemetry>hands receipts</verification_work_loop_telemetry>"
|
||||
.to_string(),
|
||||
),
|
||||
active_subgoal_id: None,
|
||||
active_subgoals: Vec::new(),
|
||||
active_graph_node_ids: Vec::new(),
|
||||
investigation_checkpoint: None,
|
||||
scratch: None,
|
||||
invariants: Vec::new(),
|
||||
graphs: None,
|
||||
recent_evidence: Vec::new(),
|
||||
recent_observations: Vec::new(),
|
||||
graph_frontier: None,
|
||||
graph_checkpoint: None,
|
||||
planning: None,
|
||||
churn: None,
|
||||
},
|
||||
),
|
||||
output_contract_id: epiphany_core::ROLE_WORKER_OUTPUT_CONTRACT_ID.to_string(),
|
||||
organ_launch_contract: epiphany_core::default_launch_organ_contract(
|
||||
"epiphany.role.verification",
|
||||
"role",
|
||||
epiphany_core::ROLE_WORKER_OUTPUT_CONTRACT_ID,
|
||||
),
|
||||
created_at: now(),
|
||||
},
|
||||
)?;
|
||||
let launch_request = load_worker_launch_request(&store, "verification-job-1")?;
|
||||
let model_request =
|
||||
build_worker_model_request(&launch_request, DEFAULT_MODEL_PROVIDER, "gpt-5.4")?;
|
||||
let tool_names = model_request
|
||||
.tools
|
||||
.iter()
|
||||
.map(|tool| tool.name.as_str())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
assert!(tool_names.contains(&"mcp__epiphany_source__read_file"));
|
||||
assert!(tool_names.contains(&"mcp__epiphany_source__git_show"));
|
||||
assert!(tool_names.contains(&"mcp__epiphany_source__read_hands_receipt"));
|
||||
assert!(
|
||||
model_request
|
||||
.instructions
|
||||
.contains("mcp__epiphany_source__read_file")
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn mcp_model_tool_call_becomes_typed_invocation_intent() -> Result<()> {
|
||||
let event = EpiphanyModelStreamEvent {
|
||||
|
|
|
|||
|
|
@ -22,6 +22,7 @@ use epiphany_tool_adapter::tool_invocation_intent_key;
|
|||
use epiphany_tool_adapter::tool_invocation_receipt_key;
|
||||
use serde::Serialize;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::fs;
|
||||
|
|
@ -189,6 +190,9 @@ async fn execute_codex_mcp(
|
|||
.cwd
|
||||
.clone()
|
||||
.unwrap_or(std::env::current_dir().context("failed to resolve current directory")?);
|
||||
if intent.server == "epiphany_source" {
|
||||
return execute_builtin_epiphany_source(intent, options, &cwd);
|
||||
}
|
||||
let codex_home = resolve_codex_home(options.codex_home.clone())?;
|
||||
let mcp_config = load_mcp_config(&codex_home).await?;
|
||||
let mut mcp_servers = effective_mcp_servers(&mcp_config, None);
|
||||
|
|
@ -235,6 +239,189 @@ async fn execute_codex_mcp(
|
|||
Ok(serde_json::to_value(result?)?)
|
||||
}
|
||||
|
||||
fn execute_builtin_epiphany_source(
|
||||
intent: &EpiphanyToolInvocationIntent,
|
||||
options: &RunOptions,
|
||||
cwd: &Path,
|
||||
) -> Result<Value> {
|
||||
let arguments = parse_arguments(&intent.arguments_json)?.unwrap_or(Value::Null);
|
||||
match intent.tool_name.as_str() {
|
||||
"read_file" => builtin_read_file(cwd, &arguments),
|
||||
"git_show" => builtin_git_show(cwd, &arguments),
|
||||
"read_hands_receipt" => builtin_read_hands_receipt(&options.store, &arguments),
|
||||
other => Err(anyhow!("unknown built-in epiphany_source tool {:?}", other)),
|
||||
}
|
||||
}
|
||||
|
||||
fn builtin_read_file(cwd: &Path, arguments: &Value) -> Result<Value> {
|
||||
let path = required_arg_string(arguments, "path")?;
|
||||
let start_line = optional_arg_u64(arguments, "startLine")?
|
||||
.unwrap_or(1)
|
||||
.max(1) as usize;
|
||||
let max_lines = optional_arg_u64(arguments, "maxLines")?
|
||||
.unwrap_or(120)
|
||||
.clamp(1, 240) as usize;
|
||||
let path = resolve_read_path(cwd, path)?;
|
||||
let text =
|
||||
fs::read_to_string(&path).with_context(|| format!("failed to read {}", path.display()))?;
|
||||
let lines = text
|
||||
.lines()
|
||||
.enumerate()
|
||||
.skip(start_line.saturating_sub(1))
|
||||
.take(max_lines)
|
||||
.map(|(index, line)| format!("{}: {}", index + 1, line))
|
||||
.collect::<Vec<_>>();
|
||||
Ok(json!({
|
||||
"path": path.display().to_string(),
|
||||
"startLine": start_line,
|
||||
"maxLines": max_lines,
|
||||
"lineCount": text.lines().count(),
|
||||
"content": lines.join("\n")
|
||||
}))
|
||||
}
|
||||
|
||||
fn builtin_git_show(cwd: &Path, arguments: &Value) -> Result<Value> {
|
||||
let revision = required_arg_string(arguments, "revision")?;
|
||||
let max_bytes = optional_arg_u64(arguments, "maxBytes")?
|
||||
.unwrap_or(16_000)
|
||||
.clamp(512, 24_000) as usize;
|
||||
let mut command = std::process::Command::new("git");
|
||||
command
|
||||
.current_dir(cwd)
|
||||
.arg("show")
|
||||
.arg("--stat")
|
||||
.arg("--patch")
|
||||
.arg("--format=medium")
|
||||
.arg(revision)
|
||||
.arg("--");
|
||||
if let Some(paths) = arguments.get("paths").and_then(Value::as_array) {
|
||||
for path in paths.iter().filter_map(Value::as_str) {
|
||||
command.arg(path);
|
||||
}
|
||||
}
|
||||
let output = command.output().context("failed to run git show")?;
|
||||
let stdout = String::from_utf8_lossy(&output.stdout);
|
||||
let stderr = String::from_utf8_lossy(&output.stderr);
|
||||
Ok(json!({
|
||||
"revision": revision,
|
||||
"status": output.status.code(),
|
||||
"success": output.status.success(),
|
||||
"stdout": truncate_chars(&stdout, max_bytes),
|
||||
"stderr": truncate_chars(&stderr, 4000)
|
||||
}))
|
||||
}
|
||||
|
||||
fn builtin_read_hands_receipt(store: &Path, arguments: &Value) -> Result<Value> {
|
||||
let receipt_id = required_arg_string(arguments, "receiptId")?;
|
||||
let kind = required_arg_string(arguments, "kind")?;
|
||||
match kind {
|
||||
"patch" => {
|
||||
let receipt = epiphany_core::runtime_hands_patch_receipt(store, receipt_id)?
|
||||
.ok_or_else(|| anyhow!("Hands patch receipt {:?} not found", receipt_id))?;
|
||||
Ok(json!({
|
||||
"kind": "patch",
|
||||
"schemaVersion": receipt.schema_version,
|
||||
"receiptId": receipt.receipt_id,
|
||||
"intentId": receipt.intent_id,
|
||||
"reviewId": receipt.review_id,
|
||||
"runtimeJobId": receipt.runtime_job_id,
|
||||
"changedPaths": receipt.changed_paths,
|
||||
"summary": receipt.summary,
|
||||
"emittedAt": receipt.emitted_at,
|
||||
"contract": receipt.contract
|
||||
}))
|
||||
}
|
||||
"command" => {
|
||||
let receipt = epiphany_core::runtime_hands_command_receipt(store, receipt_id)?
|
||||
.ok_or_else(|| anyhow!("Hands command receipt {:?} not found", receipt_id))?;
|
||||
Ok(json!({
|
||||
"kind": "command",
|
||||
"schemaVersion": receipt.schema_version,
|
||||
"receiptId": receipt.receipt_id,
|
||||
"intentId": receipt.intent_id,
|
||||
"reviewId": receipt.review_id,
|
||||
"runtimeJobId": receipt.runtime_job_id,
|
||||
"command": receipt.command,
|
||||
"exitCode": receipt.exit_code,
|
||||
"stdoutArtifact": receipt.stdout_artifact,
|
||||
"stderrArtifact": receipt.stderr_artifact,
|
||||
"summary": receipt.summary,
|
||||
"emittedAt": receipt.emitted_at,
|
||||
"contract": receipt.contract
|
||||
}))
|
||||
}
|
||||
"commit" => {
|
||||
let receipt = epiphany_core::runtime_hands_commit_receipt(store, receipt_id)?
|
||||
.ok_or_else(|| anyhow!("Hands commit receipt {:?} not found", receipt_id))?;
|
||||
Ok(json!({
|
||||
"kind": "commit",
|
||||
"schemaVersion": receipt.schema_version,
|
||||
"receiptId": receipt.receipt_id,
|
||||
"intentId": receipt.intent_id,
|
||||
"reviewId": receipt.review_id,
|
||||
"runtimeJobId": receipt.runtime_job_id,
|
||||
"commitSha": receipt.commit_sha,
|
||||
"branch": receipt.branch,
|
||||
"changedPaths": receipt.changed_paths,
|
||||
"summary": receipt.summary,
|
||||
"emittedAt": receipt.emitted_at,
|
||||
"contract": receipt.contract
|
||||
}))
|
||||
}
|
||||
other => Err(anyhow!("unsupported Hands receipt kind {:?}", other)),
|
||||
}
|
||||
}
|
||||
|
||||
fn resolve_read_path(cwd: &Path, path: &str) -> Result<PathBuf> {
|
||||
let requested = PathBuf::from(path);
|
||||
let candidate = if requested.is_absolute() {
|
||||
requested
|
||||
} else {
|
||||
cwd.join(requested)
|
||||
};
|
||||
let cwd = cwd
|
||||
.canonicalize()
|
||||
.with_context(|| format!("failed to canonicalize cwd {}", cwd.display()))?;
|
||||
let candidate = candidate
|
||||
.canonicalize()
|
||||
.with_context(|| format!("failed to canonicalize requested path {}", path))?;
|
||||
if !candidate.starts_with(&cwd) {
|
||||
return Err(anyhow!(
|
||||
"read path {} escapes workspace {}",
|
||||
candidate.display(),
|
||||
cwd.display()
|
||||
));
|
||||
}
|
||||
Ok(candidate)
|
||||
}
|
||||
|
||||
fn required_arg_string<'a>(arguments: &'a Value, name: &str) -> Result<&'a str> {
|
||||
arguments
|
||||
.get(name)
|
||||
.and_then(Value::as_str)
|
||||
.filter(|value| !value.trim().is_empty())
|
||||
.ok_or_else(|| anyhow!("missing required string argument {name:?}"))
|
||||
}
|
||||
|
||||
fn optional_arg_u64(arguments: &Value, name: &str) -> Result<Option<u64>> {
|
||||
match arguments.get(name) {
|
||||
None | Some(Value::Null) => Ok(None),
|
||||
Some(value) => value
|
||||
.as_u64()
|
||||
.map(Some)
|
||||
.ok_or_else(|| anyhow!("argument {name:?} must be an unsigned integer")),
|
||||
}
|
||||
}
|
||||
|
||||
fn truncate_chars(text: &str, max_chars: usize) -> String {
|
||||
if text.chars().count() <= max_chars {
|
||||
return text.to_string();
|
||||
}
|
||||
let mut truncated = text.chars().take(max_chars).collect::<String>();
|
||||
truncated.push_str("\n...<truncated>");
|
||||
truncated
|
||||
}
|
||||
|
||||
async fn load_mcp_config(codex_home: &Path) -> Result<McpConfig> {
|
||||
let config_toml = read_codex_config_toml(codex_home)?;
|
||||
let mcp_servers = load_global_mcp_servers(codex_home).await.with_context(|| {
|
||||
|
|
@ -441,6 +628,12 @@ struct SmokeSummary {
|
|||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn unique_temp_dir(label: &str) -> Result<PathBuf> {
|
||||
let path = std::env::temp_dir().join(format!("{label}-{}", unix_millis()));
|
||||
fs::create_dir_all(&path)?;
|
||||
Ok(path)
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_object_or_null_arguments_only() -> Result<()> {
|
||||
assert_eq!(parse_arguments("")?, None);
|
||||
|
|
@ -464,4 +657,79 @@ mod tests {
|
|||
);
|
||||
assert!(validate_intent(&intent).is_err());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builtin_epiphany_source_reads_bounded_file_slice() -> Result<()> {
|
||||
let temp = unique_temp_dir("epiphany-source-read-file")?;
|
||||
let source = temp.join("src.txt");
|
||||
fs::write(&source, "one\ntwo\nthree\nfour\n")?;
|
||||
let result = builtin_read_file(
|
||||
&temp,
|
||||
&json!({"path": "src.txt", "startLine": 2, "maxLines": 2}),
|
||||
)?;
|
||||
|
||||
assert_eq!(result["startLine"], 2);
|
||||
assert!(result["content"].as_str().unwrap().contains("2: two"));
|
||||
assert!(result["content"].as_str().unwrap().contains("3: three"));
|
||||
assert!(!result["content"].as_str().unwrap().contains("4: four"));
|
||||
fs::remove_dir_all(&temp)?;
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builtin_epiphany_source_reads_hands_receipt_body() -> Result<()> {
|
||||
let temp = unique_temp_dir("epiphany-source-read-receipt")?;
|
||||
let store = temp.join("runtime-spine.msgpack");
|
||||
epiphany_core::initialize_runtime_spine(
|
||||
&store,
|
||||
epiphany_core::RuntimeSpineInitOptions {
|
||||
runtime_id: "epiphany-source-test".to_string(),
|
||||
display_name: "Epiphany Source Test".to_string(),
|
||||
created_at: "2026-06-12T00:00:00Z".to_string(),
|
||||
},
|
||||
)?;
|
||||
let intent = epiphany_core::HandsActionIntent {
|
||||
schema_version: epiphany_core::HANDS_ACTION_INTENT_SCHEMA_VERSION.to_string(),
|
||||
intent_id: "hands-intent-test".to_string(),
|
||||
runtime_job_id: "hands-job-test".to_string(),
|
||||
binding_id: "implementation-worker".to_string(),
|
||||
role: "epiphany-hands".to_string(),
|
||||
authority_scope: "epiphany.role.implementation".to_string(),
|
||||
requested_action: "continueImplementation".to_string(),
|
||||
requested_paths: vec![".".to_string()],
|
||||
substrate_gate_grant_receipt_id: "substrate-grant-test".to_string(),
|
||||
requested_at: "2026-06-12T00:00:00Z".to_string(),
|
||||
contract: "test intent".to_string(),
|
||||
};
|
||||
epiphany_core::put_hands_action_intent(&store, &intent)?;
|
||||
let review = epiphany_core::hands_action_review_for_intent(
|
||||
"hands-review-test".to_string(),
|
||||
&intent,
|
||||
"approved".to_string(),
|
||||
vec!["patch".to_string()],
|
||||
vec!["test".to_string()],
|
||||
"2026-06-12T00:00:01Z".to_string(),
|
||||
);
|
||||
epiphany_core::put_hands_action_review(&store, &review)?;
|
||||
let patch = epiphany_core::hands_patch_receipt_for_review(
|
||||
"hands-patch-test".to_string(),
|
||||
&intent,
|
||||
&review,
|
||||
vec!["epiphany-core/src/lib.rs".to_string()],
|
||||
"patch summary".to_string(),
|
||||
"2026-06-12T00:00:02Z".to_string(),
|
||||
);
|
||||
epiphany_core::put_hands_patch_receipt(&store, &patch)?;
|
||||
|
||||
let result = builtin_read_hands_receipt(
|
||||
&store,
|
||||
&json!({"kind": "patch", "receiptId": "hands-patch-test"}),
|
||||
)?;
|
||||
|
||||
assert_eq!(result["kind"], "patch");
|
||||
assert_eq!(result["receiptId"], "hands-patch-test");
|
||||
assert_eq!(result["changedPaths"][0], "epiphany-core/src/lib.rs");
|
||||
fs::remove_dir_all(&temp)?;
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,7 +44,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
- `epiphany-model-runtime` is the current provider-neutral executable boundary. It is built by the `epiphany-openai-runtime` crate for now and accepts `--provider openai-codex`; the old `epiphany-openai-runtime` binary, `--openai-runtime-bin`, and `openai-runtime` executor name survive only as compatibility aliases. Coordinator run mode, local wrapper run mode, and repo birth runner should call `--model-runtime-bin` plus `--model-provider`. The runtime default model is `gpt-5.4`, with `EPIPHANY_MODEL` / `CODEX_MODEL` as overrides; `gpt-5.5` was rejected by this Codex-compatible transport as requiring a newer Codex. The typed request/event/receipt contract is now provider-neutral in `epiphany-model-adapter` as `epiphany.model_request.v0`, `epiphany.model_stream_event.v0`, `epiphany.model_receipt.v0`, and `epiphany.model_adapter_status.v0`; OpenAI/Codex documents are adapter evidence behind that boundary, not scheduler/status/state authority.
|
||||
- Epiphany prompt authority is now explicitly Codex-free and core-owned. Bundled specialist prompts live in `epiphany-core/src/prompts/epiphany_specialists.toml`; `epiphany-core::agent_launch` owns prompt parsing/rendering, role/reorient launch instructions, role binding ids, output schemas, coordinator note rendering, and CRRC pre-compaction prompt rendering. `epiphany-codex-bridge/src/launch.rs` is only a compatibility facade for Codex-facing callers, and bridge pressure rendering delegates back to core. The no-Codex prompt authority regression test lives beside that core owner, and `epiphany-repo-birth-runner` no longer accepts `codex-exec` or `--codex-bin`. Use `epiphany-model-runtime` for startup-only birth specialists so Codex cannot wrap Epiphany agents in its own prompt machinery.
|
||||
- Coordinator plan/run passes now emit `epiphany.coordinator_run_receipt.v0` into runtime-spine. `coordinator-summary.json` and `coordinator-steps.jsonl` remain useful operator artifacts, but the durable receipt of what the coordinator decided is typed CultCache/CultNet state.
|
||||
- The first tool/MCP contract surface exists in `epiphany-tool-adapter`: `epiphany.tool_capability.v0`, `epiphany.tool_invocation_intent.v0`, and `epiphany.tool_invocation_receipt.v0`. Runtime-spine advertises these as the Epiphany-facing tool boundary. `epiphany-model-runtime` now materializes complete MCP-shaped model tool calls as typed invocation intents, and `epiphany-tool-codex-mcp-spine` is the quarantined executing adapter: it consumes one typed invocation intent from the mixed runtime-spine CultCache store, calls user-declared Codex MCP through `codex-mcp`, and emits a typed invocation receipt. Raw MCP JSON remains protocol-edge cargo; Codex MCP is transport scaffolding, not Epiphany state, prompt, scheduler, or policy authority.
|
||||
- The first tool/MCP contract surface exists in `epiphany-tool-adapter`: `epiphany.tool_capability.v0`, `epiphany.tool_invocation_intent.v0`, and `epiphany.tool_invocation_receipt.v0`. Runtime-spine advertises these as the Epiphany-facing tool boundary. `epiphany-model-runtime` now materializes complete MCP-shaped model tool calls as typed invocation intents, and `epiphany-tool-codex-mcp-spine` is the quarantined executing adapter: it consumes one typed invocation intent from the mixed runtime-spine CultCache store, executes the built-in read-only `epiphany_source` server for bounded file reads, git diff/show previews, and Hands receipt body readback, or calls user-declared Codex MCP through `codex-mcp`, then emits a typed invocation receipt. Raw MCP JSON remains protocol-edge cargo; Codex MCP is transport scaffolding, not Epiphany state, prompt, scheduler, or policy authority. Verification/Soul worker requests now advertise `mcp__epiphany_source__read_file`, `mcp__epiphany_source__git_show`, and `mcp__epiphany_source__read_hands_receipt`; Soul is instructed to use those tools before returning `needs-evidence` for missing source/artifact/diff/receipt inspectability.
|
||||
- Native status now exposes that quarantined bridge spine without granting it authority. `runtime_spine_status` counts tool invocation intents, receipts, and pending calls; `runtime_tool_invocation_statuses` derives read-only intent/receipt status rows; `epiphany-runtime-spine status` reports the counts; and `epiphany-mvp-status --runtime-store <path>` renders the latest tool calls under `tools`. This is operator visibility only. The model-runtime feedback seam is also now typed: MCP-shaped model tool calls preserve the original provider `call_id` plus source model request id; `epiphany-model-runtime tool-followup` builds a provider-neutral follow-up `EpiphanyModelRequest` from completed typed tool receipts using the previous provider response id; and `epiphany-model-runtime tool-followup-turn` derives and runs that continuation through the selected provider in one runtime-owned operation. `epiphany-model-runtime run-worker --auto-tools --tool-adapter-bin <path>` now lets a launched worker automatically execute typed MCP intents through the quarantined Codex MCP adapter, feed receipts back through follow-up model turns, and only then parse/complete the worker result. Codex still executes the quarantined MCP edge; Epiphany owns the continuation request shape and invocation boundary.
|
||||
- The active foundation directive is now `notes/codex-starvation-and-cultnet-liberation-plan.md`. The previous Codex app-server control-plane rebuild made Epiphany less rotten inside Codex, but that is not the destination. Epiphany must become a native CultCache/CultMesh/CultNet runtime while remaining an honest modified Codex-derived backend for subscription auth/model use. Codex should remain relatively vanilla and keep doing Codex things, including useful app-server and streaming bridge affordances, but it must not own Epiphany state, processes, prompts, scheduler decisions, or policy. The bridge handles interop; Codex and Epiphany do not get to rummage around in each other's organs.
|
||||
- `notes/epiphany-cultmesh-dreaming-roadmap.md` is the new concrete design for distributed Epiphany dreaming. The invariant is hard: private state stays local; public dreams are separately authored typed documents distributed through CultMesh/CultNet; foreign dreams are thought weather until a reviewed local adoption receipt digests them. The first code slice should be dream schemas plus a local CultMesh-backed store, not public fanout.
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -182,7 +182,7 @@ accepted_design:
|
|||
- Limited native CRRC automation is now wired only at turn-complete safe boundaries: it can submit a compact operation when the read-only coordinator recommends `compactRehydrateReorient` or when a successful pre-compaction checkpoint intervention left a pending compact handoff for the completed turn, and it can launch the fixed `reorient-worker` when the coordinator recommends `launchReorientWorker`. It does not auto-launch modeling or verification, auto-accept findings, promote evidence, edit implementation code, or continue after reviewable semantic results; the rite may carry the stretcher, not declare the patient healed.
|
||||
- Pre-compaction checkpoint intervention is now wired at token-count boundaries: when a loaded Epiphany thread crosses the existing `shouldPrepareCompaction` pressure threshold during an active turn, the harness steers the active agent once for that turn with a bounded CRRC directive to bank scratch/checkpoint/map/evidence before compaction/reorientation. A successful steer marks a turn-scoped pending compact handoff consumed at clean turn completion; this is banking the fire before the dark, not semantic acceptance, broad scheduling, or automatic implementation continuation.
|
||||
- Native `epiphany-mvp-status` is the first dogfood operator view: it starts or reads a thread through app-server and renders scene, planning, pressure, reorient, jobs, role result read-backs, reorient result, CRRC recommendation, heartbeat, Face bubbles, and MVP role lanes as text or machine output without becoming a state store. The old Python status module has been cut; native Rust/CultCache/CultNet surfaces are the product path.
|
||||
- Native status now exposes the quarantined tool/MCP spine as operator-visible read-only state. Runtime-spine counts typed tool invocation intents, receipts, and pending calls; `runtime_tool_invocation_statuses` derives intent/receipt status rows; `epiphany-runtime-spine status` prints the counts; and `epiphany-mvp-status --runtime-store <path>` renders a `tools` section without executing calls, accepting results, or letting Codex prompt machinery steer Epiphany agents.
|
||||
- Native status now exposes the quarantined tool/MCP spine as operator-visible read-only state. Runtime-spine counts typed tool invocation intents, receipts, and pending calls; `runtime_tool_invocation_statuses` derives intent/receipt status rows; `epiphany-runtime-spine status` prints the counts; and `epiphany-mvp-status --runtime-store <path>` renders a `tools` section without executing calls, accepting results, or letting Codex prompt machinery steer Epiphany agents. Verification/Soul workers now receive provider-neutral tool definitions on their model request for bounded read-only inspection: `mcp__epiphany_source__read_file`, `mcp__epiphany_source__git_show`, and `mcp__epiphany_source__read_hands_receipt`. The OpenAI/Codex spine lowers those definitions to Responses tools, model tool calls become typed `epiphany.tool_invocation_intent.v0` documents, and the quarantined tool adapter resolves the built-in `epiphany_source` server directly under workspace-bounded read rules before falling back to Codex MCP. Soul should inspect source/artifacts/diffs/Hands receipt bodies through those tool receipts before returning `needs-evidence` for missing inspectability.
|
||||
- Model-tool feedback now has a typed continuation seam. `EpiphanyToolInvocationIntent` preserves the exact model `call_id` plus source model request id; provider-neutral and OpenAI request documents carry optional `previous_response_id`; the OpenAI Responses mapper emits that id as `previous_response_id`; `epiphany-model-runtime tool-followup` builds a provider-neutral follow-up request from typed tool receipts; `epiphany-model-runtime tool-followup-turn` derives and runs that continuation through the selected provider in one runtime-owned call; and `epiphany-model-runtime run-worker --auto-tools --tool-adapter-bin <path>` now loops tool execution plus follow-up model turns before completing the worker result.
|
||||
- The `roles` view lens is the harness-native role ownership surface: it projects implementation, Imagination/planning, modeling/checkpoint, verification/review, and reorientation lanes from authoritative typed state, bound jobs, pressure/reorient/CRRC, and worker result status without launching, scheduling, accepting, compacting, or mutating state.
|
||||
- `thread/epiphany/roleLaunch` and `thread/epiphany/roleResult` are the first explicit role-scoped specialist templates: Imagination/planning, modeling/checkpoint, and verification/review launch through fixed heartbeat-backed bindings with typed runtime-spine receipts and can be read back as reviewable findings from typed runtime-spine job results, while implementation stays owned by the main coding agent and reorientation stays on the CRRC-specific launch/result path.
|
||||
|
|
|
|||
Reference in a new issue