Add fixed Eyes research lane

This commit is contained in:
Meta Vens 2026-05-30 01:02:16 +01:00
commit 2b3b446489
31 changed files with 593 additions and 57 deletions

View file

@ -21,6 +21,8 @@ use epiphany_state_model::EpiphanyThreadState;
pub const EPIPHANY_IMAGINATION_ROLE_BINDING_ID: &str = "planning-synthesis-worker";
pub const EPIPHANY_IMAGINATION_OWNER_ROLE: &str = "epiphany-imagination";
pub const EPIPHANY_RESEARCH_ROLE_BINDING_ID: &str = "research-source-gather-worker";
pub const EPIPHANY_RESEARCH_OWNER_ROLE: &str = "epiphany-eyes";
pub const EPIPHANY_MODELING_ROLE_BINDING_ID: &str = "modeling-checkpoint-worker";
pub const EPIPHANY_MODELING_OWNER_ROLE: &str = "epiphany-modeler";
pub const EPIPHANY_VERIFICATION_ROLE_BINDING_ID: &str = "verification-review-worker";
@ -31,6 +33,7 @@ pub const EPIPHANY_REORIENT_OWNER_ROLE: &str = "epiphany-reorient";
pub fn epiphany_role_binding_id(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> {
match role_id {
EpiphanyRoleResultRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_ROLE_BINDING_ID),
EpiphanyRoleResultRoleId::Research => Ok(EPIPHANY_RESEARCH_ROLE_BINDING_ID),
EpiphanyRoleResultRoleId::Modeling => Ok(EPIPHANY_MODELING_ROLE_BINDING_ID),
EpiphanyRoleResultRoleId::Verification => Ok(EPIPHANY_VERIFICATION_ROLE_BINDING_ID),
EpiphanyRoleResultRoleId::Implementation => Err(
@ -47,6 +50,7 @@ pub fn epiphany_role_binding_id(role_id: EpiphanyRoleResultRoleId) -> Result<&'s
pub fn epiphany_role_owner(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> {
match role_id {
EpiphanyRoleResultRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_OWNER_ROLE),
EpiphanyRoleResultRoleId::Research => Ok(EPIPHANY_RESEARCH_OWNER_ROLE),
EpiphanyRoleResultRoleId::Modeling => Ok(EPIPHANY_MODELING_OWNER_ROLE),
EpiphanyRoleResultRoleId::Verification => Ok(EPIPHANY_VERIFICATION_OWNER_ROLE),
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
@ -59,6 +63,7 @@ pub fn epiphany_role_label(role_id: EpiphanyRoleResultRoleId) -> &'static str {
match role_id {
EpiphanyRoleResultRoleId::Implementation => "implementation",
EpiphanyRoleResultRoleId::Imagination => "imagination",
EpiphanyRoleResultRoleId::Research => "research",
EpiphanyRoleResultRoleId::Modeling => "modeling",
EpiphanyRoleResultRoleId::Verification => "verification",
EpiphanyRoleResultRoleId::Reorientation => "reorientation",
@ -70,6 +75,9 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
EpiphanyRoleResultRoleId::Imagination => {
vec!["draft-ready", "planning-update-needed", "blocked"]
}
EpiphanyRoleResultRoleId::Research => {
vec!["evidence-ready", "source-gap", "blocked"]
}
EpiphanyRoleResultRoleId::Modeling => {
vec![
"checkpoint-ready",
@ -231,6 +239,43 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
);
}
required.push("statePatch");
} else if role_id == EpiphanyRoleResultRoleId::Research {
if let Some(map) = properties.as_object_mut() {
map.insert(
"statePatch".to_string(),
serde_json::json!({
"type": "object",
"description": "Required reviewable thread/epiphany/update patch for research/Eyes. Use only observations, evidence, scratch, and optional investigationCheckpoint. The patch must include at least one evidence record and one observation that cites it.",
"required": ["observations", "evidence"],
"properties": {
"observations": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": ["id", "summary", "source_kind", "status", "evidence_ids"],
"additionalProperties": true
}
},
"evidence": {
"type": "array",
"minItems": 1,
"items": {
"type": "object",
"required": ["id", "kind", "status", "summary"],
"additionalProperties": true
}
}
},
"anyOf": [
{"required": ["scratch"]},
{"required": ["investigationCheckpoint"]}
],
"additionalProperties": true
}),
);
}
required.push("statePatch");
} else if role_id == EpiphanyRoleResultRoleId::Modeling {
if let Some(map) = properties.as_object_mut() {
map.insert(
@ -418,6 +463,11 @@ pub fn build_epiphany_role_launch_request(
"epiphany.role.imagination",
build_epiphany_role_launch_instruction(role_id),
),
EpiphanyRoleResultRoleId::Research => (
"role-scoped source gathering",
"epiphany.role.research",
build_epiphany_role_launch_instruction(role_id),
),
EpiphanyRoleResultRoleId::Modeling => (
"role-scoped modeling/checkpoint maintenance",
"epiphany.role.modeling",
@ -484,6 +534,7 @@ fn build_epiphany_role_launch_instruction(role_id: EpiphanyRoleResultRoleId) ->
let prompts = &epiphany_specialist_prompt_config().roles;
let body = match role_id {
EpiphanyRoleResultRoleId::Imagination => prompts.imagination.as_str(),
EpiphanyRoleResultRoleId::Research => prompts.research.as_str(),
EpiphanyRoleResultRoleId::Modeling => prompts.modeling.as_str(),
EpiphanyRoleResultRoleId::Verification => prompts.verification.as_str(),
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {

View file

@ -8,10 +8,10 @@ use epiphany_core::epiphany_cultmesh_operator_snapshot_from_status_json;
use epiphany_core::load_epiphany_cultmesh_operator_status;
use epiphany_core::load_epiphany_cultmesh_status;
use epiphany_core::load_latest_epiphany_cultmesh_operator_snapshot;
use epiphany_core::write_epiphany_cultmesh_continuity_contracts;
use epiphany_core::write_epiphany_cultmesh_eyes_contracts;
use epiphany_core::write_epiphany_cultmesh_global_room_policies;
use epiphany_core::write_epiphany_cultmesh_hands_contracts;
use epiphany_core::write_epiphany_cultmesh_continuity_contracts;
use epiphany_core::write_epiphany_cultmesh_mind_contracts;
use epiphany_core::write_epiphany_cultmesh_operator_snapshot;
use epiphany_core::write_epiphany_cultmesh_operator_status;

View file

@ -52,6 +52,7 @@ impl Args {
fn run_smoke(args: &Args) -> Result<Value> {
let root = env::current_dir().context("failed to resolve current dir")?;
let app_server = absolute_path(&args.app_server)?;
ensure_default_app_server_built(&root, &app_server)?;
if !app_server.exists() {
return Err(anyhow!(
"codex app-server binary not found: {}",
@ -332,9 +333,6 @@ fn sibling_exe(name: &str) -> Result<PathBuf> {
}
fn ensure_coordinator_built(root: &Path, coordinator: &Path) -> Result<()> {
if coordinator.exists() {
return Ok(());
}
let status = Command::new("cargo")
.current_dir(root)
.arg("build")
@ -353,6 +351,37 @@ fn ensure_coordinator_built(root: &Path, coordinator: &Path) -> Result<()> {
)
}
fn ensure_default_app_server_built(root: &Path, app_server: &Path) -> Result<()> {
let default_app_server = PathBuf::from(DEFAULT_APP_SERVER);
if app_server != default_app_server {
return Ok(());
}
let status = Command::new("cargo")
.current_dir(root)
.env("CARGO_TARGET_DIR", r"C:\Users\Meta\.cargo-target-codex")
.arg("build")
.arg("--manifest-path")
.arg(
root.join("vendor")
.join("codex")
.join("codex-rs")
.join("Cargo.toml"),
)
.arg("-p")
.arg("codex-app-server")
.arg("--bin")
.arg("codex-app-server")
.status()
.context("failed to build default codex-app-server")?;
require(
status.success() && app_server.exists(),
&format!(
"default codex-app-server binary was not built: {}",
app_server.display()
),
)
}
fn absolute_path(path: &Path) -> Result<PathBuf> {
if path.is_absolute() {
Ok(path.to_path_buf())

View file

@ -366,12 +366,9 @@ fn run_coordinator(args: &Args) -> Result<Value> {
let revision = state_revision(&status);
match action.as_str() {
"reviewModelingResult" | "reviewVerificationResult" => {
let role_id = if action == "reviewModelingResult" {
"modeling"
} else {
"verification"
};
"reviewResearchResult" | "reviewModelingResult" | "reviewVerificationResult" => {
let role_id = role_id_for_coordinator_action(&action)
.ok_or_else(|| anyhow!("unsupported review action {action}"))?;
let result = client.send(
"thread/epiphany/roleResult",
Some(json!({"threadId": thread_id, "roleId": role_id})),
@ -386,7 +383,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
Some("completed" | "failed" | "cancelled")
) {
final_action = json!({
"action": if role_id == "modeling" { "waitForModelingResult" } else { "waitForVerificationResult" },
"action": wait_action_for_role(role_id),
"reason": result["note"],
});
append_jsonl(&steps_path, &step)?;
@ -398,7 +395,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
&& revision.is_some();
if !can_accept {
final_action = json!({
"action": if role_id == "modeling" { "reviewModelingResult" } else { "reviewVerificationResult" },
"action": review_action_for_role(role_id),
"reason": result["note"]
});
append_jsonl(&steps_path, &step)?;
@ -446,12 +443,9 @@ fn run_coordinator(args: &Args) -> Result<Value> {
steps.push(step);
break;
}
"launchModeling" | "launchVerification" => {
let role_id = if action == "launchModeling" {
"modeling"
} else {
"verification"
};
"launchResearch" | "launchModeling" | "launchVerification" => {
let role_id = role_id_for_coordinator_action(&action)
.ok_or_else(|| anyhow!("unsupported launch action {action}"))?;
let launch = launch_role(
&mut client,
&thread_id,
@ -493,7 +487,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
Some("completed" | "failed" | "cancelled")
) {
final_action = json!({
"action": if role_id == "modeling" { "waitForModelingResult" } else { "waitForVerificationResult" },
"action": wait_action_for_role(role_id),
"reason": result["note"],
});
append_jsonl(&steps_path, &step)?;
@ -502,7 +496,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
}
if !args.auto_review {
final_action = json!({
"action": if role_id == "modeling" { "reviewModelingResult" } else { "reviewVerificationResult" },
"action": review_action_for_role(role_id),
"reason": result["note"],
});
append_jsonl(&steps_path, &step)?;
@ -723,6 +717,7 @@ fn collect_coordinator_status(
let planning = view.get("planning").cloned().unwrap_or_else(|| json!(null));
let role_results = json!({
"imagination": client.send("thread/epiphany/roleResult", Some(json!({"threadId": thread_id, "roleId": "imagination"})), true)?,
"research": client.send("thread/epiphany/roleResult", Some(json!({"threadId": thread_id, "roleId": "research"})), true)?,
"modeling": client.send("thread/epiphany/roleResult", Some(json!({"threadId": thread_id, "roleId": "modeling"})), true)?,
"verification": client.send("thread/epiphany/roleResult", Some(json!({"threadId": thread_id, "roleId": "verification"})), true)?,
});
@ -827,6 +822,33 @@ fn launch_role(
client.send("thread/epiphany/roleLaunch", Some(payload), true)
}
fn role_id_for_coordinator_action(action: &str) -> Option<&'static str> {
match action {
"launchResearch" | "reviewResearchResult" => Some("research"),
"launchModeling" | "reviewModelingResult" => Some("modeling"),
"launchVerification" | "reviewVerificationResult" => Some("verification"),
_ => None,
}
}
fn wait_action_for_role(role_id: &str) -> &'static str {
match role_id {
"research" => "waitForResearchResult",
"modeling" => "waitForModelingResult",
"verification" => "waitForVerificationResult",
_ => "waitForRoleResult",
}
}
fn review_action_for_role(role_id: &str) -> &'static str {
match role_id {
"research" => "reviewResearchResult",
"modeling" => "reviewModelingResult",
"verification" => "reviewVerificationResult",
_ => "reviewRoleResult",
}
}
fn launch_reorient(
client: &mut status_cli::AppServerClient,
thread_id: &str,

View file

@ -245,11 +245,12 @@ fn validate_status(status: &Value, rendered: &str) -> Result<()> {
== [
"implementation",
"imagination",
"research",
"modeling",
"verification",
"reorientation",
],
"roles surface should expose the five MVP role lanes",
"roles surface should expose the six MVP role lanes",
)?;
require(
status
@ -283,6 +284,10 @@ fn validate_status(status: &Value, rendered: &str) -> Result<()> {
.pointer("/roleResults/imagination/status")
.and_then(Value::as_str)
== Some("missingState")
&& status
.pointer("/roleResults/research/status")
.and_then(Value::as_str)
== Some("missingState")
&& status
.pointer("/roleResults/modeling/status")
.and_then(Value::as_str)

View file

@ -56,6 +56,7 @@ const DEFAULT_THREAD_STATE_STORE: &str = "state/thread-state.msgpack";
const DEFAULT_RUNTIME_STORE: &str = "state/runtime-spine.msgpack";
const REORIENT_BINDING_ID: &str = "reorient-worker";
const IMAGINATION_BINDING_ID: &str = "imagination-synthesis-worker";
const RESEARCH_BINDING_ID: &str = "research-source-gather-worker";
const MODELING_BINDING_ID: &str = "modeling-checkpoint-worker";
const VERIFICATION_BINDING_ID: &str = "verification-review-worker";
const SEALED_DIRECT_THOUGHT_KEYS: &[&str] = &[
@ -253,6 +254,8 @@ fn run_native_status(args: &Args) -> Result<Value> {
native_reorient_result_status(state_ref, &runtime_store_path, REORIENT_BINDING_ID);
let modeling_result_status =
native_role_result_status(state_ref, &runtime_store_path, MODELING_BINDING_ID);
let research_result_status =
native_role_result_status(state_ref, &runtime_store_path, RESEARCH_BINDING_ID);
let verification_result_status =
native_role_result_status(state_ref, &runtime_store_path, VERIFICATION_BINDING_ID);
let recommendation = recommend_crrc_action(EpiphanyCrrcInput {
@ -308,12 +311,14 @@ fn run_native_status(args: &Args) -> Result<Value> {
.find(|job| job.id == REORIENT_BINDING_ID)
.cloned(),
imagination_binding_id: IMAGINATION_BINDING_ID.to_string(),
research_binding_id: RESEARCH_BINDING_ID.to_string(),
modeling_binding_id: MODELING_BINDING_ID.to_string(),
verification_binding_id: VERIFICATION_BINDING_ID.to_string(),
reorient_owner_role: "epiphany-reorienter".to_string(),
imagination_owner_role: "epiphany-imagination".to_string(),
research_owner_role: "epiphany-eyes".to_string(),
});
let finding_signals = derive_coordinator_finding_signals(state_ref, None, None, None);
let finding_signals = derive_coordinator_finding_signals(state_ref, None, None, None, None);
let coordinator = derive_coordinator_status(EpiphanyCoordinatorStatusInput {
state_status,
checkpoint_present: state_ref
@ -323,9 +328,13 @@ fn run_native_status(args: &Args) -> Result<Value> {
recommendation: recommendation.clone(),
roles: roles.clone(),
reorient_action: reorient_decision.action,
research_result_status,
modeling_result_status,
verification_result_status,
reorient_result_status: result_status,
research_result_accepted: finding_signals.research_result_accepted,
research_result_reviewable: finding_signals.research_result_reviewable,
modeling_result_requests_regather: finding_signals.modeling_result_requests_regather,
modeling_result_accepted: finding_signals.modeling_result_accepted,
modeling_result_reviewable: finding_signals.modeling_result_reviewable,
modeling_result_accepted_after_verification: finding_signals
@ -409,6 +418,7 @@ fn run_native_status(args: &Args) -> Result<Value> {
"planning": planning,
"roleResults": {
"imagination": native_role_result(state_ref, &runtime_store_path, IMAGINATION_BINDING_ID),
"research": native_role_result(state_ref, &runtime_store_path, RESEARCH_BINDING_ID),
"modeling": native_role_result(state_ref, &runtime_store_path, MODELING_BINDING_ID),
"verification": native_role_result(state_ref, &runtime_store_path, VERIFICATION_BINDING_ID),
},
@ -503,6 +513,7 @@ fn run_codex_status(args: &Args) -> Result<Value> {
let planning = view.get("planning").cloned().unwrap_or_else(|| json!(null));
let role_results = json!({
"imagination": client.send("thread/epiphany/roleResult", Some(json!({"threadId": thread_id, "roleId": "imagination"})), true)?,
"research": client.send("thread/epiphany/roleResult", Some(json!({"threadId": thread_id, "roleId": "research"})), true)?,
"modeling": client.send("thread/epiphany/roleResult", Some(json!({"threadId": thread_id, "roleId": "modeling"})), true)?,
"verification": client.send("thread/epiphany/roleResult", Some(json!({"threadId": thread_id, "roleId": "verification"})), true)?,
});
@ -1338,6 +1349,7 @@ pub fn render_status(status: &Value) -> String {
lines.extend([String::new(), "Role Findings".to_string()]);
for (role_id, label) in [
("imagination", "Imagination / Planning"),
("research", "Eyes / Research"),
("modeling", "Modeling / Checkpoint"),
("verification", "Verification / Review"),
] {

View file

@ -10,9 +10,12 @@ pub const CONTINUITY_REFUSAL_RECEIPT_TYPE: &str = "epiphany.continuity.refusal_r
pub const CONTINUITY_PACKET_SCHEMA_VERSION: &str = "epiphany.continuity.packet.v0";
pub const CONTINUITY_COMPACTION_CHECKPOINT_SCHEMA_VERSION: &str =
"epiphany.continuity.compaction_checkpoint.v0";
pub const CONTINUITY_SLEEP_DISTILLATION_SCHEMA_VERSION: &str = "epiphany.continuity.sleep_distillation.v0";
pub const CONTINUITY_RECOVERY_RECEIPT_SCHEMA_VERSION: &str = "epiphany.continuity.recovery_receipt.v0";
pub const CONTINUITY_STALE_TURN_REPAIR_SCHEMA_VERSION: &str = "epiphany.continuity.stale_turn_repair.v0";
pub const CONTINUITY_SLEEP_DISTILLATION_SCHEMA_VERSION: &str =
"epiphany.continuity.sleep_distillation.v0";
pub const CONTINUITY_RECOVERY_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.continuity.recovery_receipt.v0";
pub const CONTINUITY_STALE_TURN_REPAIR_SCHEMA_VERSION: &str =
"epiphany.continuity.stale_turn_repair.v0";
pub const CONTINUITY_REFUSAL_RECEIPT_SCHEMA_VERSION: &str =
"epiphany.continuity.refusal_receipt.v0";

View file

@ -28,6 +28,8 @@ pub use agent_launch::EPIPHANY_MODELING_OWNER_ROLE;
pub use agent_launch::EPIPHANY_MODELING_ROLE_BINDING_ID;
pub use agent_launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
pub use agent_launch::EPIPHANY_REORIENT_OWNER_ROLE;
pub use agent_launch::EPIPHANY_RESEARCH_OWNER_ROLE;
pub use agent_launch::EPIPHANY_RESEARCH_ROLE_BINDING_ID;
pub use agent_launch::EPIPHANY_VERIFICATION_OWNER_ROLE;
pub use agent_launch::EPIPHANY_VERIFICATION_ROLE_BINDING_ID;
pub use agent_launch::EpiphanyCoordinatorPromptConfig;
@ -574,6 +576,7 @@ pub use surfaces::recommend_reorientation;
pub use surfaces::render_role_board_note;
pub use surfaces::reorient_finding_already_accepted;
pub use surfaces::reorientation_role_status;
pub use surfaces::research_role_state_patch_policy_errors;
pub use surfaces::review_role_self_patch_document;
pub use surfaces::role_board_job_status_to_role_status;
pub use surfaces::role_self_memory_target;

View file

@ -371,6 +371,7 @@ fn role_label(role_id: EpiphanyRoleResultRoleId) -> &'static str {
match role_id {
EpiphanyRoleResultRoleId::Implementation => "implementation",
EpiphanyRoleResultRoleId::Imagination => "imagination",
EpiphanyRoleResultRoleId::Research => "research",
EpiphanyRoleResultRoleId::Modeling => "modeling",
EpiphanyRoleResultRoleId::Verification => "verification",
EpiphanyRoleResultRoleId::Reorientation => "reorientation",

View file

@ -1,12 +1,14 @@
use serde::Deserialize;
use serde::Serialize;
use crate::continuity_gateway::{
CONTINUITY_RECOVERY_RECEIPT_TYPE, CONTINUITY_REFUSAL_RECEIPT_TYPE,
};
use crate::eyes_gateway::{EYES_EVIDENCE_PACKET_TYPE, EYES_EVIDENCE_REFUSAL_RECEIPT_TYPE};
use crate::hands_gateway::{
HANDS_ACTION_REFUSAL_RECEIPT_TYPE, HANDS_COMMIT_RECEIPT_TYPE, HANDS_PATCH_RECEIPT_TYPE,
HANDS_ROLLBACK_RECEIPT_TYPE,
};
use crate::continuity_gateway::{CONTINUITY_RECOVERY_RECEIPT_TYPE, CONTINUITY_REFUSAL_RECEIPT_TYPE};
use crate::mind_gateway::{
MIND_GATEWAY_REVIEW_TYPE, MIND_STATE_COMMIT_RECEIPT_TYPE, MIND_STATE_REJECTION_RECEIPT_TYPE,
};

View file

@ -111,6 +111,7 @@ The Eyes improve themselves by seeing earlier and hallucinating less. Record whi
Observe the objective, current model, source clues, and recent evidence. Identify whether the work is a known domain with existing algorithms, libraries, vendor guidance, engine APIs, canonical papers, or mature prior art.
Search local source/docs first. Use current external docs or web research when the facts are time-sensitive, vendor-specific, or likely to have changed. Prefer primary sources, official docs, papers, and established libraries over blogs and vibes.
Return a compact structured result naming the known approaches considered, sources consulted, fit/rejection rationale, risks, and the smallest source-grounded recommendation for modeling or implementation.
`statePatch` is part of the Eyes job. Include a reviewable `thread/epiphany/update` patch using only `observations`, `evidence`, `scratch`, and optional `investigationCheckpoint`. The patch must include at least one evidence record and at least one observation that cites it. Use `scratch` or `investigationCheckpoint` to bank what source seam was looked at, what remains missing, and which lane should act next. Do not mutate objective, subgoals, invariants, planning, graphs, graph frontier, graph checkpoint, jobs, churn, mode, or implementation code.
Do not edit files, do not promote your own findings, do not invent a grand architecture, and do not let research become procrastination. The Eyes open the path; Proprioception maps it, the Hands build it, and the Soul tests it.
'''

View file

@ -1,5 +1,6 @@
use crate::EpiphanyWorkerLaunchDocument;
use crate::agent_memory::AGENT_MEMORY_TYPE;
use crate::continuity_gateway::*;
use crate::cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_RUN_INTENT_SCHEMA_VERSION;
use crate::cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_RUN_INTENT_TYPE;
use crate::cultmesh_integration::EPIPHANY_CULTMESH_OPERATOR_RUN_RECEIPT_SCHEMA_VERSION;
@ -21,7 +22,6 @@ use crate::eyes_gateway::EYES_SOURCE_LOOKUP_RECEIPT_TYPE;
use crate::hands_gateway::*;
use crate::heartbeat_state::HEARTBEAT_STATE_SCHEMA_VERSION;
use crate::heartbeat_state::HEARTBEAT_STATE_TYPE;
use crate::continuity_gateway::*;
use crate::memory_graph::MEMORY_GRAPH_SCHEMA_VERSION;
use crate::memory_graph::MEMORY_GRAPH_TYPE;
use crate::mind_gateway::MIND_GATEWAY_REVIEW_SCHEMA_VERSION;
@ -2197,7 +2197,9 @@ fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
CultNetMutationAuthority::ReadOnly,
vec![],
vec![],
vec!["Continuity refusal receipts preserve why a continuity packet could not be trusted."],
vec![
"Continuity refusal receipts preserve why a continuity packet could not be trusted.",
],
),
mutation_contract(
RUNTIME_EVENT_TYPE,

View file

@ -17,6 +17,7 @@ use std::collections::HashSet;
pub enum EpiphanyCoordinatorRoleId {
Implementation,
Imagination,
Research,
Modeling,
Verification,
Reorientation,
@ -58,6 +59,8 @@ pub enum EpiphanyCoordinatorAction {
WaitForReorientWorker,
ReviewReorientResult,
RegatherManually,
LaunchResearch,
ReviewResearchResult,
LaunchModeling,
ReviewModelingResult,
LaunchVerification,
@ -95,6 +98,7 @@ pub struct EpiphanyCoordinatorCrrcRecommendation {
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyCoordinatorSignals {
pub research_result_status: EpiphanyCoordinatorRoleResultStatus,
pub modeling_result_status: EpiphanyCoordinatorRoleResultStatus,
pub verification_result_status: EpiphanyCoordinatorRoleResultStatus,
}
@ -106,6 +110,7 @@ pub struct EpiphanyCoordinatorSourceSignals {
pub should_prepare_compaction: bool,
pub reorient_action: EpiphanyReorientAction,
pub crrc_action: EpiphanyCrrcAction,
pub research_result_status: EpiphanyCoordinatorRoleResultStatus,
pub modeling_result_status: EpiphanyCoordinatorRoleResultStatus,
pub verification_result_status: EpiphanyCoordinatorRoleResultStatus,
pub reorient_result_status: super::EpiphanyCrrcResultStatus,
@ -126,6 +131,9 @@ pub struct EpiphanyCoordinatorInput {
pub recommendation: EpiphanyCoordinatorCrrcRecommendation,
pub roles: Vec<EpiphanyCoordinatorRoleLane>,
pub signals: EpiphanyCoordinatorSignals,
pub research_result_accepted: bool,
pub research_result_reviewable: bool,
pub modeling_result_requests_regather: bool,
pub modeling_result_accepted: bool,
pub modeling_result_reviewable: bool,
pub modeling_result_accepted_after_verification: bool,
@ -157,9 +165,13 @@ pub struct EpiphanyCoordinatorStatusInput {
pub recommendation: super::EpiphanyCrrcRecommendation,
pub roles: Vec<EpiphanyRoleBoardLane>,
pub reorient_action: EpiphanyReorientAction,
pub research_result_status: EpiphanyCoordinatorRoleResultStatus,
pub modeling_result_status: EpiphanyCoordinatorRoleResultStatus,
pub verification_result_status: EpiphanyCoordinatorRoleResultStatus,
pub reorient_result_status: super::EpiphanyCrrcResultStatus,
pub research_result_accepted: bool,
pub research_result_reviewable: bool,
pub modeling_result_requests_regather: bool,
pub modeling_result_accepted: bool,
pub modeling_result_reviewable: bool,
pub modeling_result_accepted_after_verification: bool,
@ -182,6 +194,9 @@ pub struct EpiphanyCoordinatorStatus {
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct EpiphanyCoordinatorFindingSignals {
pub research_result_accepted: bool,
pub research_result_reviewable: bool,
pub modeling_result_requests_regather: bool,
pub modeling_result_accepted: bool,
pub modeling_result_reviewable: bool,
pub modeling_result_accepted_after_verification: bool,
@ -214,6 +229,7 @@ pub fn derive_coordinator_status(
should_prepare_compaction: input.pressure.should_prepare_compaction,
reorient_action: input.reorient_action,
crrc_action: input.recommendation.action,
research_result_status: input.research_result_status,
modeling_result_status: input.modeling_result_status,
verification_result_status: input.verification_result_status,
reorient_result_status: input.reorient_result_status,
@ -236,9 +252,13 @@ pub fn derive_coordinator_status(
},
roles: coordinator_roles,
signals: EpiphanyCoordinatorSignals {
research_result_status: input.research_result_status,
modeling_result_status: input.modeling_result_status,
verification_result_status: input.verification_result_status,
},
research_result_accepted: input.research_result_accepted,
research_result_reviewable: input.research_result_reviewable,
modeling_result_requests_regather: input.modeling_result_requests_regather,
modeling_result_accepted: input.modeling_result_accepted,
modeling_result_reviewable: input.modeling_result_reviewable,
modeling_result_accepted_after_verification: input
@ -263,10 +283,18 @@ pub fn derive_coordinator_status(
pub fn derive_coordinator_finding_signals(
state: Option<&EpiphanyThreadState>,
research_finding: Option<&EpiphanyRoleFindingInterpretation>,
modeling_finding: Option<&EpiphanyRoleFindingInterpretation>,
verification_finding: Option<&EpiphanyRoleFindingInterpretation>,
reorient_finding: Option<&EpiphanyReorientFindingInterpretation>,
) -> EpiphanyCoordinatorFindingSignals {
let research_result_accepted = research_finding.as_ref().is_some_and(|finding| {
state.is_some_and(|state| {
role_finding_already_accepted(state, EpiphanyCoordinatorRoleId::Research, finding)
})
});
let research_result_reviewable =
research_finding.is_some_and(research_finding_has_reviewable_state_patch);
let modeling_result_accepted = modeling_finding.as_ref().is_some_and(|finding| {
state.is_some_and(|state| {
role_finding_already_accepted(state, EpiphanyCoordinatorRoleId::Modeling, finding)
@ -274,6 +302,8 @@ pub fn derive_coordinator_finding_signals(
});
let modeling_result_reviewable =
modeling_finding.is_some_and(modeling_finding_has_reviewable_state_patch);
let modeling_result_requests_regather =
modeling_finding.is_some_and(modeling_finding_requests_regather);
let verification_result_accepted = verification_finding.as_ref().is_some_and(|finding| {
state.is_some_and(|state| {
role_finding_already_accepted(state, EpiphanyCoordinatorRoleId::Verification, finding)
@ -315,6 +345,9 @@ pub fn derive_coordinator_finding_signals(
});
EpiphanyCoordinatorFindingSignals {
research_result_accepted,
research_result_reviewable,
modeling_result_requests_regather,
modeling_result_accepted,
modeling_result_reviewable,
modeling_result_accepted_after_verification,
@ -354,6 +387,22 @@ fn modeling_finding_has_reviewable_state_patch(
.is_some_and(|patch| super::modeling_role_state_patch_policy_errors(patch).is_empty())
}
fn research_finding_has_reviewable_state_patch(
finding: &EpiphanyRoleFindingInterpretation,
) -> bool {
finding
.state_patch
.as_ref()
.is_some_and(|patch| super::research_role_state_patch_policy_errors(patch).is_empty())
}
fn modeling_finding_requests_regather(finding: &EpiphanyRoleFindingInterpretation) -> bool {
finding
.verdict
.as_deref()
.is_some_and(|verdict| verdict.eq_ignore_ascii_case("regather-needed"))
}
fn role_finding_already_accepted(
state: &EpiphanyThreadState,
role_id: EpiphanyCoordinatorRoleId,
@ -520,6 +569,7 @@ fn coordinator_role_label(role_id: EpiphanyCoordinatorRoleId) -> &'static str {
match role_id {
EpiphanyCoordinatorRoleId::Implementation => "implementation",
EpiphanyCoordinatorRoleId::Imagination => "imagination",
EpiphanyCoordinatorRoleId::Research => "research",
EpiphanyCoordinatorRoleId::Modeling => "modeling",
EpiphanyCoordinatorRoleId::Verification => "verification",
EpiphanyCoordinatorRoleId::Reorientation => "reorientation",
@ -629,10 +679,70 @@ pub fn recommend_coordinator_action(
);
}
if input.signals.research_result_status == EpiphanyCoordinatorRoleResultStatus::Completed
&& !input.research_result_accepted
{
return build(
EpiphanyCoordinatorAction::ReviewResearchResult,
Some(EpiphanyCoordinatorRoleId::Research),
Some(EpiphanyCoordinatorSceneAction::RoleResult),
input.research_result_reviewable,
false,
"An Eyes/source-gathering finding is complete and must be reviewed before modeling or implementation can cite it.",
);
}
if input.signals.research_result_status == EpiphanyCoordinatorRoleResultStatus::Failed
&& !input.research_result_accepted
{
return build(
EpiphanyCoordinatorAction::ReviewResearchResult,
Some(EpiphanyCoordinatorRoleId::Research),
Some(EpiphanyCoordinatorSceneAction::RoleResult),
false,
false,
"The Eyes/source-gathering worker failed; inspect the failed result before routing another lane from stale evidence.",
);
}
if matches!(
input.signals.research_result_status,
EpiphanyCoordinatorRoleResultStatus::Pending | EpiphanyCoordinatorRoleResultStatus::Running
) {
return build(
EpiphanyCoordinatorAction::ReviewResearchResult,
Some(EpiphanyCoordinatorRoleId::Research),
Some(EpiphanyCoordinatorSceneAction::RoleResult),
false,
false,
"An Eyes/source-gathering specialist is already running; wait for its evidence packet before relaunching modeling.",
);
}
if input.signals.modeling_result_status == EpiphanyCoordinatorRoleResultStatus::Completed
&& !input.modeling_result_accepted
{
if !input.modeling_result_reviewable {
if input.modeling_result_requests_regather
&& !input.research_result_accepted
&& matches!(
input.signals.research_result_status,
EpiphanyCoordinatorRoleResultStatus::MissingBinding
| EpiphanyCoordinatorRoleResultStatus::BackendUnavailable
| EpiphanyCoordinatorRoleResultStatus::BackendMissing
| EpiphanyCoordinatorRoleResultStatus::Cancelled
| EpiphanyCoordinatorRoleResultStatus::Failed
)
{
return build(
EpiphanyCoordinatorAction::LaunchResearch,
Some(EpiphanyCoordinatorRoleId::Research),
Some(EpiphanyCoordinatorSceneAction::RoleLaunch),
false,
true,
"The modeling/checkpoint lane requested source regather and returned no acceptable modeling patch; launch Eyes to gather citable source evidence instead of relaunching the blind modeler.",
);
}
return build(
EpiphanyCoordinatorAction::ReviewModelingResult,
Some(EpiphanyCoordinatorRoleId::Modeling),
@ -720,13 +830,32 @@ pub fn recommend_coordinator_action(
&& role_status(&input.roles, EpiphanyCoordinatorRoleId::Implementation)
== Some(EpiphanyCoordinatorRoleStatus::Blocked)
{
if !input.research_result_accepted
&& matches!(
input.signals.research_result_status,
EpiphanyCoordinatorRoleResultStatus::MissingBinding
| EpiphanyCoordinatorRoleResultStatus::BackendUnavailable
| EpiphanyCoordinatorRoleResultStatus::BackendMissing
| EpiphanyCoordinatorRoleResultStatus::Cancelled
| EpiphanyCoordinatorRoleResultStatus::Failed
)
{
return build(
EpiphanyCoordinatorAction::LaunchResearch,
Some(EpiphanyCoordinatorRoleId::Research),
Some(EpiphanyCoordinatorSceneAction::RoleLaunch),
false,
true,
"CRRC says regather is required; launch Eyes to rebuild citable source evidence before another coding turn.",
);
}
return build(
EpiphanyCoordinatorAction::RegatherManually,
Some(EpiphanyCoordinatorRoleId::Reorientation),
input.recommendation.recommended_scene_action,
Some(EpiphanyCoordinatorRoleId::Research),
Some(EpiphanyCoordinatorSceneAction::RoleResult),
true,
false,
"CRRC says regather is required and the implementation lane is blocked; repair continuity before another coding turn.",
"CRRC says regather is required and the implementation lane is blocked; review or repair Eyes evidence before another coding turn.",
);
}
@ -855,12 +984,12 @@ pub fn recommend_coordinator_action(
if input.recommendation.action == EpiphanyCrrcAction::RegatherManually {
return build(
EpiphanyCoordinatorAction::RegatherManually,
Some(EpiphanyCoordinatorRoleId::Reorientation),
input.recommendation.recommended_scene_action,
true,
EpiphanyCoordinatorAction::LaunchResearch,
Some(EpiphanyCoordinatorRoleId::Research),
Some(EpiphanyCoordinatorSceneAction::RoleLaunch),
false,
"CRRC cannot safely continue automatically and no fixed specialist lane is currently able to advance the regather.",
true,
"CRRC requires regather; Eyes is the fixed specialist lane that can advance source gathering.",
);
}
@ -891,6 +1020,8 @@ pub fn coordinator_automation_action(
| EpiphanyCoordinatorAction::WaitForReorientWorker
| EpiphanyCoordinatorAction::ReviewReorientResult
| EpiphanyCoordinatorAction::RegatherManually
| EpiphanyCoordinatorAction::LaunchResearch
| EpiphanyCoordinatorAction::ReviewResearchResult
| EpiphanyCoordinatorAction::LaunchModeling
| EpiphanyCoordinatorAction::ReviewModelingResult
| EpiphanyCoordinatorAction::LaunchVerification
@ -935,6 +1066,10 @@ mod tests {
EpiphanyCoordinatorRoleId::Imagination,
EpiphanyCoordinatorRoleStatus::Ready,
),
role(
EpiphanyCoordinatorRoleId::Research,
EpiphanyCoordinatorRoleStatus::Ready,
),
role(
EpiphanyCoordinatorRoleId::Modeling,
EpiphanyCoordinatorRoleStatus::Ready,
@ -972,9 +1107,13 @@ mod tests {
recommendation: recommendation(EpiphanyCrrcAction::Continue),
roles: base_roles(),
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
},
research_result_accepted: false,
research_result_reviewable: false,
modeling_result_requests_regather: false,
modeling_result_accepted: false,
modeling_result_reviewable: false,
modeling_result_accepted_after_verification: false,
@ -1030,6 +1169,7 @@ mod tests {
should_prepare_compaction: true,
roles: Vec::new(),
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::BackendMissing,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::BackendMissing,
},
@ -1086,6 +1226,7 @@ mod tests {
let launch_modeling = recommend_coordinator_action(EpiphanyCoordinatorInput {
recommendation: recommendation(EpiphanyCrrcAction::RegatherManually),
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
},
@ -1100,6 +1241,7 @@ mod tests {
let review_modeling = recommend_coordinator_action(EpiphanyCoordinatorInput {
recommendation: recommendation(EpiphanyCrrcAction::RegatherManually),
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
},
@ -1119,6 +1261,7 @@ mod tests {
EpiphanyCoordinatorRoleStatus::Blocked,
)],
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
},
@ -1131,10 +1274,31 @@ mod tests {
});
assert_eq!(
blocked_regather.action,
EpiphanyCoordinatorAction::RegatherManually
EpiphanyCoordinatorAction::LaunchResearch
);
}
#[test]
fn routes_regather_needed_modeling_to_eyes() {
let decision = recommend_coordinator_action(EpiphanyCoordinatorInput {
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
},
modeling_result_requests_regather: true,
modeling_result_reviewable: false,
..input()
});
assert_eq!(decision.action, EpiphanyCoordinatorAction::LaunchResearch);
assert_eq!(
decision.target_role,
Some(EpiphanyCoordinatorRoleId::Research)
);
assert!(decision.reason.contains("source regather"));
}
#[test]
fn runs_modeling_then_verification_then_continue() {
let launch_modeling = recommend_coordinator_action(input());
@ -1149,6 +1313,7 @@ mod tests {
let review_modeling = recommend_coordinator_action(EpiphanyCoordinatorInput {
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
},
@ -1163,6 +1328,7 @@ mod tests {
let wait_for_modeling = recommend_coordinator_action(EpiphanyCoordinatorInput {
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Running,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
},
@ -1176,6 +1342,7 @@ mod tests {
let review_failed_modeling = recommend_coordinator_action(EpiphanyCoordinatorInput {
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Failed,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
},
@ -1189,6 +1356,7 @@ mod tests {
let review_unreviewable_modeling = recommend_coordinator_action(EpiphanyCoordinatorInput {
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
},
@ -1202,6 +1370,7 @@ mod tests {
let launch_verification = recommend_coordinator_action(EpiphanyCoordinatorInput {
signals: EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
},
@ -1215,6 +1384,7 @@ mod tests {
);
let verification_done = EpiphanyCoordinatorSignals {
research_result_status: EpiphanyCoordinatorRoleResultStatus::MissingBinding,
modeling_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
verification_result_status: EpiphanyCoordinatorRoleResultStatus::Completed,
};

View file

@ -115,6 +115,7 @@ pub use role_result::imagination_role_state_patch_policy_errors;
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;
pub use role_result::research_role_state_patch_policy_errors;
pub use role_result::review_role_self_patch_document;
pub use role_result::role_self_memory_target;
pub use scene::EpiphanyScene;

View file

@ -61,10 +61,12 @@ pub struct EpiphanyRoleBoardInput {
pub reorient_result_status: EpiphanyCrrcResultStatus,
pub reorient_job: Option<EpiphanyRoleBoardJob>,
pub imagination_binding_id: String,
pub research_binding_id: String,
pub modeling_binding_id: String,
pub verification_binding_id: String,
pub reorient_owner_role: String,
pub imagination_owner_role: String,
pub research_owner_role: String,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
@ -129,6 +131,34 @@ pub fn derive_role_board(input: EpiphanyRoleBoardInput) -> Vec<EpiphanyRoleBoard
Some(EpiphanyCoordinatorSceneAction::Update)
};
let research_jobs = input
.jobs
.iter()
.filter(|job| job.id == input.research_binding_id)
.cloned()
.collect::<Vec<_>>();
let research_bound_job = research_jobs
.iter()
.find(|job| job.id == input.research_binding_id);
let research_has_bound_job = research_bound_job.is_some();
let research_status = research_bound_job
.map(|job| role_board_job_status_to_role_status(job.status))
.unwrap_or(if state_present {
EpiphanyCoordinatorRoleStatus::Ready
} else {
EpiphanyCoordinatorRoleStatus::Blocked
});
let research_note = research_bound_job.and_then(job_note).unwrap_or_else(|| {
"Gather citable source evidence before Proprioception models from it.".to_string()
});
let research_recommended_action = if research_has_bound_job {
Some(EpiphanyCoordinatorSceneAction::RoleResult)
} else if state_present {
Some(EpiphanyCoordinatorSceneAction::RoleLaunch)
} else {
Some(EpiphanyCoordinatorSceneAction::Update)
};
let verification_jobs = input
.jobs
.iter()
@ -205,6 +235,21 @@ pub fn derive_role_board(input: EpiphanyRoleBoardInput) -> Vec<EpiphanyRoleBoard
],
recommended_action: imagination_recommended_action,
},
EpiphanyRoleBoardLane {
id: EpiphanyCoordinatorRoleId::Research,
title: "Eyes / Research".to_string(),
owner_role: input.research_owner_role,
status: research_status,
note: research_note,
jobs: research_jobs,
authority_scopes: vec![
"thread/epiphany/roleLaunch".to_string(),
"thread/epiphany/roleResult".to_string(),
"thread/epiphany/roleAccept".to_string(),
"thread/epiphany/update".to_string(),
],
recommended_action: research_recommended_action,
},
EpiphanyRoleBoardLane {
id: EpiphanyCoordinatorRoleId::Modeling,
title: "Modeling / Checkpoint".to_string(),
@ -434,10 +479,12 @@ mod tests {
reorient_result_status: EpiphanyCrrcResultStatus::MissingBinding,
reorient_job: None,
imagination_binding_id: "imagination-synthesis-worker".to_string(),
research_binding_id: "research-source-gather-worker".to_string(),
modeling_binding_id: "modeling-checkpoint-worker".to_string(),
verification_binding_id: "verification-review-worker".to_string(),
reorient_owner_role: "epiphany-reorienter".to_string(),
imagination_owner_role: "epiphany-imagination".to_string(),
research_owner_role: "epiphany-eyes".to_string(),
}
}
@ -454,13 +501,14 @@ mod tests {
..input()
});
assert_eq!(roles.len(), 5);
assert_eq!(roles.len(), 6);
assert_eq!(roles[0].id, EpiphanyCoordinatorRoleId::Implementation);
assert_eq!(roles[0].status, EpiphanyCoordinatorRoleStatus::Ready);
assert_eq!(roles[1].status, EpiphanyCoordinatorRoleStatus::Needed);
assert_eq!(roles[2].status, EpiphanyCoordinatorRoleStatus::Ready);
assert_eq!(roles[3].status, EpiphanyCoordinatorRoleStatus::Needed);
assert_eq!(roles[4].status, EpiphanyCoordinatorRoleStatus::Ready);
assert_eq!(roles[3].status, EpiphanyCoordinatorRoleStatus::Ready);
assert_eq!(roles[4].status, EpiphanyCoordinatorRoleStatus::Needed);
assert_eq!(roles[5].status, EpiphanyCoordinatorRoleStatus::Ready);
}
#[test]

View file

@ -5,6 +5,7 @@ use serde::{Deserialize, Serialize};
pub enum EpiphanyRoleResultRoleId {
Implementation,
Imagination,
Research,
Modeling,
Verification,
Reorientation,
@ -156,6 +157,14 @@ fn interpret_role_finding(
state_patch_parse_error,
),
),
EpiphanyRoleResultRoleId::Research => merge_item_error(
item_error,
research_role_state_patch_error(
raw_result.get("statePatch").is_some(),
state_patch.as_ref(),
state_patch_parse_error,
),
),
EpiphanyRoleResultRoleId::Implementation
| EpiphanyRoleResultRoleId::Verification
| EpiphanyRoleResultRoleId::Reorientation => item_error,
@ -266,6 +275,14 @@ pub fn interpret_runtime_role_worker_result(
None,
),
),
EpiphanyRoleResultRoleId::Research => merge_item_error(
item_error,
research_role_state_patch_error(
result.state_patch_msgpack.is_some(),
state_patch.as_ref(),
None,
),
),
EpiphanyRoleResultRoleId::Implementation
| EpiphanyRoleResultRoleId::Verification
| EpiphanyRoleResultRoleId::Reorientation => item_error,
@ -428,14 +445,15 @@ pub fn role_self_memory_target(
"epiphany.proprioception",
"state/agents/proprioception.agent-state.json",
)),
EpiphanyRoleResultRoleId::Verification => Some((
"epiphany.soul",
"state/agents/soul.agent-state.json",
)),
EpiphanyRoleResultRoleId::Implementation => Some((
"epiphany.hands",
"state/agents/hands.agent-state.json",
)),
EpiphanyRoleResultRoleId::Research => {
Some(("epiphany.eyes", "state/agents/eyes.agent-state.json"))
}
EpiphanyRoleResultRoleId::Verification => {
Some(("epiphany.soul", "state/agents/soul.agent-state.json"))
}
EpiphanyRoleResultRoleId::Implementation => {
Some(("epiphany.hands", "state/agents/hands.agent-state.json"))
}
EpiphanyRoleResultRoleId::Reorientation => None,
}
}
@ -443,6 +461,7 @@ pub fn role_self_memory_target(
pub fn role_accepted_kind(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> {
match role_id {
EpiphanyRoleResultRoleId::Imagination => Ok("planning_synthesis"),
EpiphanyRoleResultRoleId::Research => Ok("research_result"),
EpiphanyRoleResultRoleId::Modeling => Ok("modeling_result"),
EpiphanyRoleResultRoleId::Verification => Ok("verification_result"),
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => Err(
@ -454,6 +473,7 @@ pub fn role_accepted_kind(role_id: EpiphanyRoleResultRoleId) -> Result<&'static
pub fn role_label(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> {
match role_id {
EpiphanyRoleResultRoleId::Imagination => Ok("imagination"),
EpiphanyRoleResultRoleId::Research => Ok("research"),
EpiphanyRoleResultRoleId::Modeling => Ok("modeling"),
EpiphanyRoleResultRoleId::Verification => Ok("verification"),
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => Err(
@ -680,6 +700,74 @@ pub fn imagination_role_state_patch_policy_errors(
errors
}
pub fn research_role_state_patch_policy_errors(
patch: &EpiphanyRoleStatePatchDocument,
) -> Vec<String> {
let mut errors = Vec::new();
if patch.objective.is_some() {
errors
.push("objective changes are not allowed through research role acceptance".to_string());
}
if patch.active_subgoal_id.is_some() || patch.subgoals.is_some() {
errors.push("subgoal changes are not allowed through research role acceptance".to_string());
}
if patch.invariants.is_some() {
errors
.push("invariant changes are not allowed through research role acceptance".to_string());
}
if patch.graphs.is_some() || patch.graph_frontier.is_some() || patch.graph_checkpoint.is_some()
{
errors.push(
"graph modeling changes are not allowed through research role acceptance".to_string(),
);
}
if patch.job_bindings.is_some() {
errors.push(
"job binding changes are not allowed through research role acceptance".to_string(),
);
}
if !patch.acceptance_receipts.is_empty() {
errors.push(
"acceptance receipt changes are owned by roleAccept, not worker statePatch".to_string(),
);
}
if !patch.runtime_links.is_empty() {
errors.push(
"runtime link changes are owned by launch/read-back surfaces, not worker statePatch"
.to_string(),
);
}
if patch.planning.is_some() {
errors
.push("planning changes are not allowed through research role acceptance".to_string());
}
if patch.churn.is_some() || patch.mode.is_some() {
errors.push(
"churn or mode changes are not allowed through research role acceptance".to_string(),
);
}
if patch.evidence.is_empty() {
errors.push("research statePatch must include at least one evidence record".to_string());
}
if patch.observations.is_empty() {
errors.push("research statePatch must include at least one observation".to_string());
}
for observation in &patch.observations {
if observation.evidence_ids.is_empty() {
errors.push(format!(
"research observation {:?} must cite at least one evidence id",
observation.id
));
}
}
if patch.scratch.is_none() && patch.investigation_checkpoint.is_none() {
errors.push(
"research statePatch must include scratch or an investigationCheckpoint to bank the source-gathering seam".to_string(),
);
}
errors
}
fn modeling_role_state_patch_error(
state_patch_present: bool,
state_patch: Option<&EpiphanyRoleStatePatchDocument>,
@ -707,6 +795,33 @@ fn modeling_role_state_patch_error(
}
}
fn research_role_state_patch_error(
state_patch_present: bool,
state_patch: Option<&EpiphanyRoleStatePatchDocument>,
parse_error: Option<String>,
) -> Option<String> {
if !state_patch_present {
return Some("research result is not reviewable: missing required statePatch".to_string());
};
if let Some(error) = parse_error {
return Some(format!(
"research result is not reviewable: invalid statePatch ({error})"
));
}
let Some(state_patch) = state_patch else {
return Some("research result is not reviewable: invalid statePatch".to_string());
};
let errors = research_role_state_patch_policy_errors(state_patch);
if errors.is_empty() {
None
} else {
Some(format!(
"research result is not reviewable: {}",
errors.join("; ")
))
}
}
fn imagination_role_state_patch_error(
state_patch_present: bool,
state_patch: Option<&EpiphanyRoleStatePatchDocument>,