Move Epiphany prompt launch authority into core
This commit is contained in:
parent
f996274a29
commit
3e19a6aa2a
15 changed files with 834 additions and 808 deletions
|
|
@ -20,7 +20,6 @@ notify = "8.2.0"
|
|||
serde_json = "1"
|
||||
serde = { version = "1", features = ["derive"] }
|
||||
tokio = { version = "1", features = ["rt", "sync"] }
|
||||
toml = "0.9"
|
||||
tracing = "0.1"
|
||||
uuid = { version = "1", features = ["v4"] }
|
||||
|
||||
|
|
|
|||
|
|
@ -1,3 +1,9 @@
|
|||
use epiphany_core::EPIPHANY_IMAGINATION_OWNER_ROLE;
|
||||
use epiphany_core::EPIPHANY_IMAGINATION_ROLE_BINDING_ID;
|
||||
use epiphany_core::EPIPHANY_MODELING_ROLE_BINDING_ID;
|
||||
use epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
use epiphany_core::EPIPHANY_REORIENT_OWNER_ROLE;
|
||||
use epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID;
|
||||
use epiphany_core::EpiphanyCoordinatorAutomationAction as CoreEpiphanyCoordinatorAutomationAction;
|
||||
use epiphany_core::EpiphanyCoordinatorDecision as CoreEpiphanyCoordinatorDecision;
|
||||
use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus;
|
||||
|
|
@ -24,24 +30,18 @@ use epiphany_core::EpiphanyRoleBoardLane;
|
|||
use epiphany_core::EpiphanyRoleBoardPlanningSummary;
|
||||
use epiphany_core::EpiphanyRoleResultRoleId;
|
||||
use epiphany_core::EpiphanyTokenUsageSnapshot;
|
||||
use epiphany_core::build_epiphany_reorient_launch_request;
|
||||
use epiphany_core::derive_coordinator_finding_signals;
|
||||
use epiphany_core::derive_coordinator_status;
|
||||
use epiphany_core::derive_role_board;
|
||||
use epiphany_core::recommend_crrc_action;
|
||||
use epiphany_core::render_epiphany_coordinator_note;
|
||||
use epiphany_core::render_role_board_note;
|
||||
use epiphany_core::reorient_finding_already_accepted;
|
||||
use epiphany_core::select_coordinator_automation_action;
|
||||
use epiphany_state_model::EpiphanyRetrievalState;
|
||||
use epiphany_state_model::EpiphanyThreadState;
|
||||
|
||||
use crate::launch::EPIPHANY_IMAGINATION_OWNER_ROLE;
|
||||
use crate::launch::EPIPHANY_IMAGINATION_ROLE_BINDING_ID;
|
||||
use crate::launch::EPIPHANY_MODELING_ROLE_BINDING_ID;
|
||||
use crate::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
use crate::launch::EPIPHANY_REORIENT_OWNER_ROLE;
|
||||
use crate::launch::EPIPHANY_VERIFICATION_ROLE_BINDING_ID;
|
||||
use crate::launch::build_epiphany_reorient_launch_request;
|
||||
use crate::launch::render_epiphany_coordinator_note;
|
||||
use crate::pressure::derive_epiphany_pressure;
|
||||
use crate::reorient::EpiphanyFreshnessWatcherSnapshot;
|
||||
use crate::reorient::derive_epiphany_freshness_view;
|
||||
|
|
|
|||
|
|
@ -1,692 +1,36 @@
|
|||
use std::sync::OnceLock;
|
||||
//! Compatibility facade for older bridge callers.
|
||||
//!
|
||||
//! Epiphany prompt doctrine, worker launch policy, role binding ids, and output
|
||||
//! schemas live in `epiphany-core`. The bridge may translate those typed launch
|
||||
//! requests to Codex JSON-RPC, but it does not own the agent instructions.
|
||||
|
||||
use epiphany_core::EpiphanyCoordinatorAction as CoreEpiphanyCoordinatorAction;
|
||||
use epiphany_core::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus;
|
||||
use epiphany_core::EpiphanyCrrcAction as CoreEpiphanyCrrcAction;
|
||||
use epiphany_core::EpiphanyCrrcResultStatus as CoreEpiphanyCrrcResultStatus;
|
||||
use epiphany_core::EpiphanyJobLaunchRequest;
|
||||
use epiphany_core::EpiphanyPressureLevel as CoreEpiphanyPressureLevel;
|
||||
use epiphany_core::EpiphanyReorientAction as CoreEpiphanyReorientAction;
|
||||
use epiphany_core::EpiphanyReorientDecision as CoreEpiphanyReorientDecision;
|
||||
use epiphany_core::EpiphanyReorientLaunchRequestInput;
|
||||
use epiphany_core::EpiphanyRoleResultRoleId;
|
||||
use epiphany_core::EpiphanyRoleWorkerLaunchDocument;
|
||||
use epiphany_core::EpiphanyWorkerLaunchDocument;
|
||||
use epiphany_core::build_reorient_job_launch_request;
|
||||
use epiphany_core::default_launch_organ_contract;
|
||||
use epiphany_state_model::EpiphanyInvestigationCheckpoint;
|
||||
use epiphany_state_model::EpiphanyJobKind as CoreEpiphanyJobKind;
|
||||
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_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";
|
||||
pub const EPIPHANY_VERIFICATION_OWNER_ROLE: &str = "epiphany-verifier";
|
||||
pub const EPIPHANY_REORIENT_LAUNCH_BINDING_ID: &str = "reorient-worker";
|
||||
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::Modeling => Ok(EPIPHANY_MODELING_ROLE_BINDING_ID),
|
||||
EpiphanyRoleResultRoleId::Verification => Ok(EPIPHANY_VERIFICATION_ROLE_BINDING_ID),
|
||||
EpiphanyRoleResultRoleId::Implementation => Err(
|
||||
"implementation is owned by the main coding agent; no role specialist launch template exists"
|
||||
.to_string(),
|
||||
),
|
||||
EpiphanyRoleResultRoleId::Reorientation => Err(
|
||||
"reorientation uses thread/epiphany/reorientLaunch and thread/epiphany/reorientResult"
|
||||
.to_string(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_role_owner(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_OWNER_ROLE),
|
||||
EpiphanyRoleResultRoleId::Modeling => Ok(EPIPHANY_MODELING_OWNER_ROLE),
|
||||
EpiphanyRoleResultRoleId::Verification => Ok(EPIPHANY_VERIFICATION_OWNER_ROLE),
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
|
||||
Err(epiphany_role_binding_id(role_id).unwrap_err())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_role_label(role_id: EpiphanyRoleResultRoleId) -> &'static str {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Implementation => "implementation",
|
||||
EpiphanyRoleResultRoleId::Imagination => "imagination",
|
||||
EpiphanyRoleResultRoleId::Modeling => "modeling",
|
||||
EpiphanyRoleResultRoleId::Verification => "verification",
|
||||
EpiphanyRoleResultRoleId::Reorientation => "reorientation",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) -> serde_json::Value {
|
||||
let verdict_enum = match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => {
|
||||
vec!["draft-ready", "planning-update-needed", "blocked"]
|
||||
}
|
||||
EpiphanyRoleResultRoleId::Modeling => {
|
||||
vec![
|
||||
"checkpoint-ready",
|
||||
"checkpoint-update-needed",
|
||||
"regather-needed",
|
||||
]
|
||||
}
|
||||
EpiphanyRoleResultRoleId::Verification => {
|
||||
vec!["pass", "needs-review", "needs-evidence", "fail"]
|
||||
}
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
|
||||
vec![]
|
||||
}
|
||||
};
|
||||
let mut properties = serde_json::json!({
|
||||
"roleId": {
|
||||
"type": "string",
|
||||
"enum": [epiphany_role_label(role_id)]
|
||||
},
|
||||
"verdict": {
|
||||
"type": "string",
|
||||
"enum": verdict_enum
|
||||
},
|
||||
"summary": {"type": "string"},
|
||||
"nextSafeMove": {"type": "string"},
|
||||
"checkpointSummary": {"type": "string"},
|
||||
"scratchSummary": {"type": "string"},
|
||||
"filesInspected": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"frontierNodeIds": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"evidenceIds": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"openQuestions": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"evidenceGaps": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"risks": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"selfPatch": {
|
||||
"type": "object",
|
||||
"description": "Optional bounded request to update this role's Ghostlight-shaped persistent memory file. This is for lane habits, durable lessons, personality pressure, goals, or values only. It must not contain project truth, code edits, job authority, graph/frontier/checkpoint/planning changes, or objective changes.",
|
||||
"required": ["agentId", "reason"],
|
||||
"properties": {
|
||||
"agentId": {
|
||||
"type": "string",
|
||||
"description": "Expected target persistent agent id for this lane, such as epiphany.body or epiphany.soul."
|
||||
},
|
||||
"reason": {
|
||||
"type": "string",
|
||||
"description": "Why this memory mutation makes the lane sharper for future work."
|
||||
},
|
||||
"evidenceIds": {
|
||||
"type": "array",
|
||||
"description": "Optional accepted/project evidence ids that ground the memory request. These do not count as a memory mutation by themselves.",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"semanticMemories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["memoryId", "summary", "salience", "confidence"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"episodicMemories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["memoryId", "summary", "salience", "confidence"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"relationshipMemories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["memoryId", "summary", "salience", "confidence"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"goals": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["goalId", "description", "scope", "priority", "emotionalStake", "status"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["valueId", "label", "priority", "unforgivableIfBetrayed"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"privateNotes": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
});
|
||||
let mut required = vec![
|
||||
"roleId",
|
||||
"verdict",
|
||||
"summary",
|
||||
"nextSafeMove",
|
||||
"filesInspected",
|
||||
];
|
||||
if role_id == EpiphanyRoleResultRoleId::Imagination {
|
||||
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 Imagination. Use only planning plus optional observations/evidence. planning is a full replacement object and must include at least one objective_drafts entry with status draft.",
|
||||
"required": ["planning"],
|
||||
"properties": {
|
||||
"planning": {
|
||||
"type": "object",
|
||||
"required": ["objective_drafts"],
|
||||
"properties": {
|
||||
"objective_drafts": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["id", "title", "summary", "acceptance_criteria", "status"],
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["draft"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}),
|
||||
);
|
||||
}
|
||||
required.push("statePatch");
|
||||
} else if role_id == EpiphanyRoleResultRoleId::Modeling {
|
||||
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 modeling. Use only graphs, graphFrontier, graphCheckpoint, scratch, investigationCheckpoint, observations, and evidence. The patch must include at least one durable modeling field, not observations/evidence alone.",
|
||||
"anyOf": [
|
||||
{"required": ["graphs"]},
|
||||
{"required": ["graphFrontier"]},
|
||||
{"required": ["graphCheckpoint"]},
|
||||
{"required": ["scratch"]},
|
||||
{"required": ["investigationCheckpoint"]}
|
||||
],
|
||||
"properties": {
|
||||
"investigationCheckpoint": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"disposition": {
|
||||
"type": "string",
|
||||
"enum": ["resume_ready", "regather_required"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}),
|
||||
);
|
||||
}
|
||||
required.push("frontierNodeIds");
|
||||
required.push("statePatch");
|
||||
}
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": properties,
|
||||
"required": required,
|
||||
"additionalProperties": true
|
||||
})
|
||||
}
|
||||
|
||||
pub fn epiphany_reorient_launch_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": ["resume", "regather"]
|
||||
},
|
||||
"summary": {"type": "string"},
|
||||
"nextSafeMove": {"type": "string"},
|
||||
"checkpointStillValid": {"type": "boolean"},
|
||||
"filesInspected": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"frontierNodeIds": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"evidenceIds": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"openQuestions": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"continuityRisks": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"required": ["mode", "summary", "nextSafeMove"],
|
||||
"additionalProperties": true
|
||||
})
|
||||
}
|
||||
|
||||
const EPIPHANY_SPECIALIST_PROMPTS_TOML: &str = include_str!("prompts/epiphany_specialists.toml");
|
||||
const EPIPHANY_WORKER_BOUNDARY_PROMPT: &str = r#"## Epiphany Worker Boundary
|
||||
You are one bounded Epiphany worker for this launch only. Your authority comes from the typed launch document, the role-local instruction, and the declared output contract.
|
||||
Do the role, name uncertainty, and return the required JSON object. Do not become the coordinator, do not accept or promote your own output, do not invent durable state outside an allowed statePatch, and do not treat model transport or Codex machinery as prompt authority.
|
||||
If you learned a durable role-local habit, you may include a bounded selfPatch. Project truth belongs in statePatch or evidence, not memory."#;
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanySpecialistPromptConfig {
|
||||
pub shared: EpiphanySharedPromptConfig,
|
||||
pub roles: EpiphanyRolePromptConfig,
|
||||
// Parsed here so the bundled prompt config fails fast even though the GUI runner consumes it.
|
||||
#[allow(dead_code)]
|
||||
pub implementation: EpiphanyImplementationPromptConfig,
|
||||
pub reorientation: EpiphanyReorientationPromptConfig,
|
||||
pub coordinator: EpiphanyCoordinatorPromptConfig,
|
||||
pub crrc: EpiphanyCrrcPromptConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanySharedPromptConfig {
|
||||
pub persistent_memory: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyRolePromptConfig {
|
||||
pub imagination: String,
|
||||
pub modeling: String,
|
||||
pub verification: String,
|
||||
#[allow(dead_code)]
|
||||
pub research: String,
|
||||
#[allow(dead_code)]
|
||||
pub repo_personality: String,
|
||||
#[allow(dead_code)]
|
||||
pub repo_memory: String,
|
||||
#[allow(dead_code)]
|
||||
pub face: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyImplementationPromptConfig {
|
||||
#[allow(dead_code)]
|
||||
pub continue_template: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyReorientationPromptConfig {
|
||||
pub resume: String,
|
||||
pub regather: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyCoordinatorPromptConfig {
|
||||
pub note_template: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyCrrcPromptConfig {
|
||||
pub pre_compaction_checkpoint_intervention: String,
|
||||
}
|
||||
|
||||
pub fn epiphany_specialist_prompt_config() -> &'static EpiphanySpecialistPromptConfig {
|
||||
static CONFIG: OnceLock<EpiphanySpecialistPromptConfig> = OnceLock::new();
|
||||
CONFIG.get_or_init(|| {
|
||||
toml::from_str(EPIPHANY_SPECIALIST_PROMPTS_TOML)
|
||||
.expect("bundled Epiphany specialist prompt config must parse")
|
||||
})
|
||||
}
|
||||
|
||||
pub fn epiphany_agent_prompt_with_memory(body: &str) -> String {
|
||||
let memory = epiphany_specialist_prompt_config()
|
||||
.shared
|
||||
.persistent_memory
|
||||
.trim();
|
||||
let body = body.trim();
|
||||
if memory.is_empty() {
|
||||
body.to_string()
|
||||
} else if body.is_empty() {
|
||||
memory.to_string()
|
||||
} else {
|
||||
format!("{memory}\n\n{body}")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_worker_prompt(body: &str) -> String {
|
||||
let body = body.trim();
|
||||
if body.is_empty() {
|
||||
EPIPHANY_WORKER_BOUNDARY_PROMPT.to_string()
|
||||
} else {
|
||||
format!("{}\n\n{}", EPIPHANY_WORKER_BOUNDARY_PROMPT, body)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_epiphany_role_launch_request(
|
||||
thread_id: &str,
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
expected_revision: Option<u64>,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
state: &EpiphanyThreadState,
|
||||
) -> Result<EpiphanyJobLaunchRequest, String> {
|
||||
let binding_id = epiphany_role_binding_id(role_id)?;
|
||||
let owner_role = epiphany_role_owner(role_id)?;
|
||||
let linked_subgoal_ids = epiphany_active_subgoal_ids(Some(state));
|
||||
let linked_graph_node_ids = epiphany_active_graph_node_ids(Some(state));
|
||||
let (scope, authority_scope, instruction) = match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => (
|
||||
"role-scoped planning synthesis",
|
||||
"epiphany.role.imagination",
|
||||
build_epiphany_role_launch_instruction(role_id),
|
||||
),
|
||||
EpiphanyRoleResultRoleId::Modeling => (
|
||||
"role-scoped modeling/checkpoint maintenance",
|
||||
"epiphany.role.modeling",
|
||||
build_epiphany_role_launch_instruction(role_id),
|
||||
),
|
||||
EpiphanyRoleResultRoleId::Verification => (
|
||||
"role-scoped verification/review",
|
||||
"epiphany.role.verification",
|
||||
build_epiphany_role_launch_instruction(role_id),
|
||||
),
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
|
||||
return Err(epiphany_role_binding_id(role_id).unwrap_err());
|
||||
}
|
||||
};
|
||||
let launch_document = EpiphanyWorkerLaunchDocument::Role(EpiphanyRoleWorkerLaunchDocument {
|
||||
thread_id: thread_id.to_string(),
|
||||
role_id: epiphany_role_label(role_id).to_string(),
|
||||
state_revision: state.revision,
|
||||
objective: state.objective.clone(),
|
||||
active_subgoal_id: state.active_subgoal_id.clone(),
|
||||
active_subgoals: state
|
||||
.subgoals
|
||||
.iter()
|
||||
.filter(|subgoal| Some(subgoal.id.as_str()) == state.active_subgoal_id.as_deref())
|
||||
.cloned()
|
||||
.collect(),
|
||||
active_graph_node_ids: linked_graph_node_ids.clone(),
|
||||
investigation_checkpoint: state.investigation_checkpoint.clone(),
|
||||
scratch: state.scratch.clone(),
|
||||
invariants: state.invariants.clone(),
|
||||
graphs: Some(state.graphs.clone()),
|
||||
recent_evidence: state.recent_evidence.iter().take(8).cloned().collect(),
|
||||
recent_observations: state.observations.iter().take(8).cloned().collect(),
|
||||
graph_frontier: state.graph_frontier.clone(),
|
||||
graph_checkpoint: state.graph_checkpoint.clone(),
|
||||
planning: Some(state.planning.clone()),
|
||||
churn: state.churn.clone(),
|
||||
});
|
||||
let output_contract_id = launch_document.output_contract_id().to_string();
|
||||
let organ_launch_contract = default_launch_organ_contract(
|
||||
authority_scope,
|
||||
launch_document.document_kind(),
|
||||
&output_contract_id,
|
||||
);
|
||||
|
||||
Ok(EpiphanyJobLaunchRequest {
|
||||
expected_revision,
|
||||
binding_id: binding_id.to_string(),
|
||||
kind: CoreEpiphanyJobKind::Specialist,
|
||||
scope: scope.to_string(),
|
||||
owner_role: owner_role.to_string(),
|
||||
authority_scope: authority_scope.to_string(),
|
||||
linked_subgoal_ids,
|
||||
linked_graph_node_ids: epiphany_active_graph_node_ids(Some(state)),
|
||||
instruction,
|
||||
launch_document,
|
||||
output_contract_id,
|
||||
organ_launch_contract,
|
||||
max_runtime_seconds,
|
||||
})
|
||||
}
|
||||
|
||||
fn build_epiphany_role_launch_instruction(role_id: EpiphanyRoleResultRoleId) -> String {
|
||||
let prompts = &epiphany_specialist_prompt_config().roles;
|
||||
let body = match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => prompts.imagination.as_str(),
|
||||
EpiphanyRoleResultRoleId::Modeling => prompts.modeling.as_str(),
|
||||
EpiphanyRoleResultRoleId::Verification => prompts.verification.as_str(),
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
|
||||
"Unsupported Epiphany role specialist template."
|
||||
}
|
||||
};
|
||||
epiphany_worker_prompt(body)
|
||||
}
|
||||
|
||||
pub fn build_epiphany_reorient_launch_request(
|
||||
thread_id: &str,
|
||||
expected_revision: Option<u64>,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
state: &EpiphanyThreadState,
|
||||
checkpoint: &EpiphanyInvestigationCheckpoint,
|
||||
decision: &CoreEpiphanyReorientDecision,
|
||||
) -> EpiphanyJobLaunchRequest {
|
||||
let instruction = build_epiphany_reorient_launch_instruction(decision.action);
|
||||
build_reorient_job_launch_request(EpiphanyReorientLaunchRequestInput {
|
||||
thread_id,
|
||||
expected_revision,
|
||||
max_runtime_seconds,
|
||||
binding_id: EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
|
||||
owner_role: EPIPHANY_REORIENT_OWNER_ROLE,
|
||||
instruction,
|
||||
state,
|
||||
checkpoint,
|
||||
decision,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn build_epiphany_reorient_launch_instruction(action: CoreEpiphanyReorientAction) -> String {
|
||||
let prompts = &epiphany_specialist_prompt_config().reorientation;
|
||||
let body = match action {
|
||||
CoreEpiphanyReorientAction::Resume => prompts.resume.as_str(),
|
||||
CoreEpiphanyReorientAction::Regather => prompts.regather.as_str(),
|
||||
};
|
||||
epiphany_worker_prompt(body)
|
||||
}
|
||||
|
||||
pub fn build_epiphany_job_launch_request(
|
||||
expected_revision: Option<u64>,
|
||||
binding_id: String,
|
||||
kind: CoreEpiphanyJobKind,
|
||||
scope: String,
|
||||
owner_role: String,
|
||||
authority_scope: String,
|
||||
linked_subgoal_ids: Vec<String>,
|
||||
linked_graph_node_ids: Vec<String>,
|
||||
instruction: String,
|
||||
launch_document: EpiphanyWorkerLaunchDocument,
|
||||
output_contract_id: String,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
) -> EpiphanyJobLaunchRequest {
|
||||
let organ_launch_contract = default_launch_organ_contract(
|
||||
&authority_scope,
|
||||
launch_document.document_kind(),
|
||||
&output_contract_id,
|
||||
);
|
||||
EpiphanyJobLaunchRequest {
|
||||
expected_revision,
|
||||
binding_id,
|
||||
kind,
|
||||
scope,
|
||||
owner_role,
|
||||
authority_scope,
|
||||
linked_subgoal_ids,
|
||||
linked_graph_node_ids,
|
||||
instruction,
|
||||
launch_document,
|
||||
output_contract_id,
|
||||
organ_launch_contract,
|
||||
max_runtime_seconds,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_epiphany_coordinator_note(
|
||||
crrc_action: CoreEpiphanyCrrcAction,
|
||||
pressure_level: CoreEpiphanyPressureLevel,
|
||||
modeling_result_status: CoreEpiphanyCoordinatorRoleResultStatus,
|
||||
verification_result_status: CoreEpiphanyCoordinatorRoleResultStatus,
|
||||
reorient_result_status: CoreEpiphanyCrrcResultStatus,
|
||||
coordinator_action: CoreEpiphanyCoordinatorAction,
|
||||
) -> String {
|
||||
let template = epiphany_agent_prompt_with_memory(
|
||||
&epiphany_specialist_prompt_config()
|
||||
.coordinator
|
||||
.note_template,
|
||||
);
|
||||
template
|
||||
.trim()
|
||||
.replace("{crrc_action}", &format!("{crrc_action:?}"))
|
||||
.replace("{pressure_level}", &format!("{pressure_level:?}"))
|
||||
.replace(
|
||||
"{modeling_result_status}",
|
||||
&format!("{modeling_result_status:?}"),
|
||||
)
|
||||
.replace(
|
||||
"{verification_result_status}",
|
||||
&format!("{verification_result_status:?}"),
|
||||
)
|
||||
.replace(
|
||||
"{reorient_result_status}",
|
||||
&format!("{reorient_result_status:?}"),
|
||||
)
|
||||
.replace("{coordinator_action}", &format!("{coordinator_action:?}"))
|
||||
}
|
||||
|
||||
pub fn unique_strings(values: impl IntoIterator<Item = String>) -> Vec<String> {
|
||||
let mut unique = Vec::new();
|
||||
extend_unique_strings(&mut unique, values);
|
||||
unique
|
||||
}
|
||||
|
||||
fn extend_unique_strings(target: &mut Vec<String>, values: impl IntoIterator<Item = String>) {
|
||||
for value in values {
|
||||
if !target.iter().any(|existing| existing == &value) {
|
||||
target.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn epiphany_active_subgoal_ids(state: Option<&EpiphanyThreadState>) -> Vec<String> {
|
||||
state
|
||||
.and_then(|state| state.active_subgoal_id.clone())
|
||||
.map(|id| vec![id])
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn epiphany_active_graph_node_ids(state: Option<&EpiphanyThreadState>) -> Vec<String> {
|
||||
state
|
||||
.and_then(|state| state.graph_frontier.as_ref())
|
||||
.map(|frontier| frontier.active_node_ids.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn bundled_epiphany_agent_prompts_do_not_name_codex_as_prompt_authority() {
|
||||
let prompts = epiphany_specialist_prompt_config();
|
||||
let rendered = [
|
||||
(
|
||||
"shared.persistent_memory",
|
||||
prompts.shared.persistent_memory.as_str(),
|
||||
),
|
||||
("roles.imagination", prompts.roles.imagination.as_str()),
|
||||
("roles.modeling", prompts.roles.modeling.as_str()),
|
||||
("roles.verification", prompts.roles.verification.as_str()),
|
||||
("roles.research", prompts.roles.research.as_str()),
|
||||
(
|
||||
"roles.repo_personality",
|
||||
prompts.roles.repo_personality.as_str(),
|
||||
),
|
||||
("roles.repo_memory", prompts.roles.repo_memory.as_str()),
|
||||
("roles.face", prompts.roles.face.as_str()),
|
||||
(
|
||||
"implementation.continue_template",
|
||||
prompts.implementation.continue_template.as_str(),
|
||||
),
|
||||
(
|
||||
"reorientation.resume",
|
||||
prompts.reorientation.resume.as_str(),
|
||||
),
|
||||
(
|
||||
"reorientation.regather",
|
||||
prompts.reorientation.regather.as_str(),
|
||||
),
|
||||
(
|
||||
"coordinator.note_template",
|
||||
prompts.coordinator.note_template.as_str(),
|
||||
),
|
||||
(
|
||||
"crrc.pre_compaction_checkpoint_intervention",
|
||||
prompts.crrc.pre_compaction_checkpoint_intervention.as_str(),
|
||||
),
|
||||
];
|
||||
|
||||
for (name, prompt) in rendered {
|
||||
assert!(
|
||||
!prompt.contains("Codex"),
|
||||
"{name} must stay Epiphany-owned and Codex-free"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn role_worker_prompt_is_bounded_not_full_persistent_memory() {
|
||||
let prompt = build_epiphany_role_launch_instruction(EpiphanyRoleResultRoleId::Modeling);
|
||||
|
||||
assert!(prompt.contains("Epiphany Worker Boundary"));
|
||||
assert!(prompt.contains("Act as the Epiphany modeling/checkpoint specialist"));
|
||||
assert!(!prompt.contains("## Epiphany Persistent Memory"));
|
||||
assert!(!prompt.contains("Heartbeat: every lane"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reorient_worker_prompt_is_bounded_not_full_persistent_memory() {
|
||||
let prompt = build_epiphany_reorient_launch_instruction(CoreEpiphanyReorientAction::Resume);
|
||||
|
||||
assert!(prompt.contains("Epiphany Worker Boundary"));
|
||||
assert!(!prompt.contains("## Epiphany Persistent Memory"));
|
||||
assert!(!prompt.contains("Heartbeat: every lane"));
|
||||
}
|
||||
}
|
||||
pub use epiphany_core::EPIPHANY_IMAGINATION_OWNER_ROLE;
|
||||
pub use epiphany_core::EPIPHANY_IMAGINATION_ROLE_BINDING_ID;
|
||||
pub use epiphany_core::EPIPHANY_MODELING_OWNER_ROLE;
|
||||
pub use epiphany_core::EPIPHANY_MODELING_ROLE_BINDING_ID;
|
||||
pub use epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
pub use epiphany_core::EPIPHANY_REORIENT_OWNER_ROLE;
|
||||
pub use epiphany_core::EPIPHANY_VERIFICATION_OWNER_ROLE;
|
||||
pub use epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID;
|
||||
pub use epiphany_core::EpiphanyCoordinatorPromptConfig;
|
||||
pub use epiphany_core::EpiphanyCrrcPromptConfig;
|
||||
pub use epiphany_core::EpiphanyImplementationPromptConfig;
|
||||
pub use epiphany_core::EpiphanyReorientationPromptConfig;
|
||||
pub use epiphany_core::EpiphanyRolePromptConfig;
|
||||
pub use epiphany_core::EpiphanySharedPromptConfig;
|
||||
pub use epiphany_core::EpiphanySpecialistPromptConfig;
|
||||
pub use epiphany_core::build_epiphany_job_launch_request;
|
||||
pub use epiphany_core::build_epiphany_reorient_launch_instruction;
|
||||
pub use epiphany_core::build_epiphany_reorient_launch_request;
|
||||
pub use epiphany_core::build_epiphany_role_launch_request;
|
||||
pub use epiphany_core::epiphany_agent_prompt_with_memory;
|
||||
pub use epiphany_core::epiphany_reorient_launch_output_schema;
|
||||
pub use epiphany_core::epiphany_role_binding_id;
|
||||
pub use epiphany_core::epiphany_role_label;
|
||||
pub use epiphany_core::epiphany_role_launch_output_schema;
|
||||
pub use epiphany_core::epiphany_role_owner;
|
||||
pub use epiphany_core::epiphany_specialist_prompt_config;
|
||||
pub use epiphany_core::epiphany_worker_prompt;
|
||||
pub use epiphany_core::render_epiphany_coordinator_note;
|
||||
pub use epiphany_core::render_epiphany_pre_compaction_checkpoint_intervention;
|
||||
pub use epiphany_core::unique_strings;
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ use chrono::Utc;
|
|||
use std::path::Path;
|
||||
use std::path::PathBuf;
|
||||
|
||||
use epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
use epiphany_core::EpiphanyJobInterruptRequest;
|
||||
use epiphany_core::EpiphanyJobInterruptResult;
|
||||
use epiphany_core::EpiphanyJobLaunchRequest;
|
||||
|
|
@ -21,7 +22,10 @@ use epiphany_core::EpiphanyTokenUsageSnapshot;
|
|||
use epiphany_core::RuntimeSpineHeartbeatJobOptions;
|
||||
use epiphany_core::RuntimeSpineHeartbeatLaunchPlanOptions;
|
||||
use epiphany_core::apply_epiphany_state_update;
|
||||
use epiphany_core::build_epiphany_reorient_launch_request;
|
||||
use epiphany_core::build_epiphany_role_launch_request;
|
||||
use epiphany_core::clear_epiphany_job_binding_backend;
|
||||
use epiphany_core::epiphany_role_label;
|
||||
use epiphany_core::epiphany_state_update_validation_errors;
|
||||
use epiphany_core::evaluate_promotion;
|
||||
use epiphany_core::open_runtime_spine_heartbeat_job;
|
||||
|
|
@ -41,10 +45,6 @@ use crate::jobs::derive_epiphany_jobs;
|
|||
use crate::jobs::epiphany_blocked_state_job;
|
||||
use crate::jobs::map_interrupted_epiphany_job;
|
||||
use crate::jobs::map_launched_epiphany_job;
|
||||
use crate::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
use crate::launch::build_epiphany_reorient_launch_request;
|
||||
use crate::launch::build_epiphany_role_launch_request;
|
||||
use crate::launch::epiphany_role_label;
|
||||
use crate::mutation::build_reorient_acceptance_update;
|
||||
use crate::mutation::build_role_acceptance_update;
|
||||
use crate::mutation::epiphany_job_launch_changed_fields;
|
||||
|
|
|
|||
|
|
@ -1,12 +1,8 @@
|
|||
use epiphany_core::EpiphanyPressure;
|
||||
use epiphany_core::EpiphanyPressureLevel as CoreEpiphanyPressureLevel;
|
||||
use epiphany_core::EpiphanyPressureStatus as CoreEpiphanyPressureStatus;
|
||||
pub use epiphany_core::EpiphanyTokenUsageSnapshot;
|
||||
use epiphany_core::derive_pressure_view;
|
||||
|
||||
use crate::launch::epiphany_agent_prompt_with_memory;
|
||||
use crate::launch::epiphany_specialist_prompt_config;
|
||||
|
||||
pub fn derive_epiphany_pressure(snapshot: Option<&EpiphanyTokenUsageSnapshot>) -> EpiphanyPressure {
|
||||
derive_pressure_view(snapshot)
|
||||
}
|
||||
|
|
@ -20,39 +16,5 @@ pub fn should_run_epiphany_pre_compaction_checkpoint_intervention(
|
|||
pub fn render_epiphany_pre_compaction_checkpoint_intervention(
|
||||
pressure: &EpiphanyPressure,
|
||||
) -> String {
|
||||
let usage = match (
|
||||
pressure.used_tokens,
|
||||
pressure.remaining_tokens,
|
||||
pressure.ratio_per_mille,
|
||||
) {
|
||||
(Some(used), Some(remaining), Some(ratio)) => format!(
|
||||
"{used} tokens used, {remaining} remaining, {}.{}% of the selected limit",
|
||||
ratio / 10,
|
||||
ratio % 10
|
||||
),
|
||||
(Some(used), _, _) => format!("{used} tokens used"),
|
||||
_ => "token usage known only as a pressure threshold crossing".to_string(),
|
||||
};
|
||||
let template = epiphany_agent_prompt_with_memory(
|
||||
&epiphany_specialist_prompt_config()
|
||||
.crrc
|
||||
.pre_compaction_checkpoint_intervention,
|
||||
);
|
||||
template
|
||||
.trim()
|
||||
.replace(
|
||||
"{pressure_level}",
|
||||
core_pressure_level_label(pressure.level),
|
||||
)
|
||||
.replace("{usage}", &usage)
|
||||
}
|
||||
|
||||
fn core_pressure_level_label(level: CoreEpiphanyPressureLevel) -> &'static str {
|
||||
match level {
|
||||
CoreEpiphanyPressureLevel::Unknown => "unknown",
|
||||
CoreEpiphanyPressureLevel::Low => "low",
|
||||
CoreEpiphanyPressureLevel::Elevated => "elevated",
|
||||
CoreEpiphanyPressureLevel::High => "high",
|
||||
CoreEpiphanyPressureLevel::Critical => "critical",
|
||||
}
|
||||
epiphany_core::render_epiphany_pre_compaction_checkpoint_intervention(pressure)
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
use std::path::Path;
|
||||
|
||||
use codex_app_server_protocol::*;
|
||||
use epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
use epiphany_core::EpiphanyContextParams;
|
||||
use epiphany_core::EpiphanyDistillInput;
|
||||
use epiphany_core::EpiphanyGraphQuery;
|
||||
|
|
@ -35,7 +36,6 @@ use crate::coordinator_protocol::protocol_role_board_lanes;
|
|||
use crate::cultnet::EpiphanyFreshnessSurface;
|
||||
use crate::cultnet::EpiphanySurfaceSource;
|
||||
use crate::jobs::map_epiphany_jobs;
|
||||
use crate::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
use crate::pressure::derive_epiphany_pressure;
|
||||
use crate::protocol_edge::protocol_job_from_surface;
|
||||
use crate::protocol_edge::protocol_pressure_from_core;
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@ rmp-serde = "1"
|
|||
serde = { version = "1", features = ["derive"] }
|
||||
serde_json = "1"
|
||||
sha1 = "0.10.6"
|
||||
toml = "0.9"
|
||||
tracing = "0.1.44"
|
||||
uuid = { version = "1", features = ["v4", "v5"] }
|
||||
|
||||
|
|
|
|||
733
epiphany-core/src/agent_launch.rs
Normal file
733
epiphany-core/src/agent_launch.rs
Normal file
|
|
@ -0,0 +1,733 @@
|
|||
use std::sync::OnceLock;
|
||||
|
||||
use crate::EpiphanyCoordinatorAction as CoreEpiphanyCoordinatorAction;
|
||||
use crate::EpiphanyCoordinatorRoleResultStatus as CoreEpiphanyCoordinatorRoleResultStatus;
|
||||
use crate::EpiphanyCrrcAction as CoreEpiphanyCrrcAction;
|
||||
use crate::EpiphanyCrrcResultStatus as CoreEpiphanyCrrcResultStatus;
|
||||
use crate::EpiphanyJobLaunchRequest;
|
||||
use crate::EpiphanyPressure;
|
||||
use crate::EpiphanyPressureLevel as CoreEpiphanyPressureLevel;
|
||||
use crate::EpiphanyReorientAction as CoreEpiphanyReorientAction;
|
||||
use crate::EpiphanyReorientDecision as CoreEpiphanyReorientDecision;
|
||||
use crate::EpiphanyReorientLaunchRequestInput;
|
||||
use crate::EpiphanyRoleResultRoleId;
|
||||
use crate::EpiphanyRoleWorkerLaunchDocument;
|
||||
use crate::EpiphanyWorkerLaunchDocument;
|
||||
use crate::build_reorient_job_launch_request;
|
||||
use crate::default_launch_organ_contract;
|
||||
use epiphany_state_model::EpiphanyInvestigationCheckpoint;
|
||||
use epiphany_state_model::EpiphanyJobKind as CoreEpiphanyJobKind;
|
||||
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_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";
|
||||
pub const EPIPHANY_VERIFICATION_OWNER_ROLE: &str = "epiphany-verifier";
|
||||
pub const EPIPHANY_REORIENT_LAUNCH_BINDING_ID: &str = "reorient-worker";
|
||||
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::Modeling => Ok(EPIPHANY_MODELING_ROLE_BINDING_ID),
|
||||
EpiphanyRoleResultRoleId::Verification => Ok(EPIPHANY_VERIFICATION_ROLE_BINDING_ID),
|
||||
EpiphanyRoleResultRoleId::Implementation => Err(
|
||||
"implementation is owned by the main coding agent; no role specialist launch template exists"
|
||||
.to_string(),
|
||||
),
|
||||
EpiphanyRoleResultRoleId::Reorientation => Err(
|
||||
"reorientation uses thread/epiphany/reorientLaunch and thread/epiphany/reorientResult"
|
||||
.to_string(),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_role_owner(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_OWNER_ROLE),
|
||||
EpiphanyRoleResultRoleId::Modeling => Ok(EPIPHANY_MODELING_OWNER_ROLE),
|
||||
EpiphanyRoleResultRoleId::Verification => Ok(EPIPHANY_VERIFICATION_OWNER_ROLE),
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
|
||||
Err(epiphany_role_binding_id(role_id).unwrap_err())
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_role_label(role_id: EpiphanyRoleResultRoleId) -> &'static str {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Implementation => "implementation",
|
||||
EpiphanyRoleResultRoleId::Imagination => "imagination",
|
||||
EpiphanyRoleResultRoleId::Modeling => "modeling",
|
||||
EpiphanyRoleResultRoleId::Verification => "verification",
|
||||
EpiphanyRoleResultRoleId::Reorientation => "reorientation",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) -> serde_json::Value {
|
||||
let verdict_enum = match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => {
|
||||
vec!["draft-ready", "planning-update-needed", "blocked"]
|
||||
}
|
||||
EpiphanyRoleResultRoleId::Modeling => {
|
||||
vec![
|
||||
"checkpoint-ready",
|
||||
"checkpoint-update-needed",
|
||||
"regather-needed",
|
||||
]
|
||||
}
|
||||
EpiphanyRoleResultRoleId::Verification => {
|
||||
vec!["pass", "needs-review", "needs-evidence", "fail"]
|
||||
}
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
|
||||
vec![]
|
||||
}
|
||||
};
|
||||
let mut properties = serde_json::json!({
|
||||
"roleId": {
|
||||
"type": "string",
|
||||
"enum": [epiphany_role_label(role_id)]
|
||||
},
|
||||
"verdict": {
|
||||
"type": "string",
|
||||
"enum": verdict_enum
|
||||
},
|
||||
"summary": {"type": "string"},
|
||||
"nextSafeMove": {"type": "string"},
|
||||
"checkpointSummary": {"type": "string"},
|
||||
"scratchSummary": {"type": "string"},
|
||||
"filesInspected": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"frontierNodeIds": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"evidenceIds": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"openQuestions": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"evidenceGaps": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"risks": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"selfPatch": {
|
||||
"type": "object",
|
||||
"description": "Optional bounded request to update this role's Ghostlight-shaped persistent memory file. This is for lane habits, durable lessons, personality pressure, goals, or values only. It must not contain project truth, code edits, job authority, graph/frontier/checkpoint/planning changes, or objective changes.",
|
||||
"required": ["agentId", "reason"],
|
||||
"properties": {
|
||||
"agentId": {
|
||||
"type": "string",
|
||||
"description": "Expected target persistent agent id for this lane, such as epiphany.body or epiphany.soul."
|
||||
},
|
||||
"reason": {
|
||||
"type": "string",
|
||||
"description": "Why this memory mutation makes the lane sharper for future work."
|
||||
},
|
||||
"evidenceIds": {
|
||||
"type": "array",
|
||||
"description": "Optional accepted/project evidence ids that ground the memory request. These do not count as a memory mutation by themselves.",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"semanticMemories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["memoryId", "summary", "salience", "confidence"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"episodicMemories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["memoryId", "summary", "salience", "confidence"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"relationshipMemories": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["memoryId", "summary", "salience", "confidence"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"goals": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["goalId", "description", "scope", "priority", "emotionalStake", "status"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"values": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["valueId", "label", "priority", "unforgivableIfBetrayed"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"privateNotes": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
});
|
||||
let mut required = vec![
|
||||
"roleId",
|
||||
"verdict",
|
||||
"summary",
|
||||
"nextSafeMove",
|
||||
"filesInspected",
|
||||
];
|
||||
if role_id == EpiphanyRoleResultRoleId::Imagination {
|
||||
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 Imagination. Use only planning plus optional observations/evidence. planning is a full replacement object and must include at least one objective_drafts entry with status draft.",
|
||||
"required": ["planning"],
|
||||
"properties": {
|
||||
"planning": {
|
||||
"type": "object",
|
||||
"required": ["objective_drafts"],
|
||||
"properties": {
|
||||
"objective_drafts": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"type": "object",
|
||||
"required": ["id", "title", "summary", "acceptance_criteria", "status"],
|
||||
"properties": {
|
||||
"status": {
|
||||
"type": "string",
|
||||
"enum": ["draft"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}),
|
||||
);
|
||||
}
|
||||
required.push("statePatch");
|
||||
} else if role_id == EpiphanyRoleResultRoleId::Modeling {
|
||||
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 modeling. Use only graphs, graphFrontier, graphCheckpoint, scratch, investigationCheckpoint, observations, and evidence. The patch must include at least one durable modeling field, not observations/evidence alone.",
|
||||
"anyOf": [
|
||||
{"required": ["graphs"]},
|
||||
{"required": ["graphFrontier"]},
|
||||
{"required": ["graphCheckpoint"]},
|
||||
{"required": ["scratch"]},
|
||||
{"required": ["investigationCheckpoint"]}
|
||||
],
|
||||
"properties": {
|
||||
"investigationCheckpoint": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"disposition": {
|
||||
"type": "string",
|
||||
"enum": ["resume_ready", "regather_required"]
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}),
|
||||
);
|
||||
}
|
||||
required.push("frontierNodeIds");
|
||||
required.push("statePatch");
|
||||
}
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": properties,
|
||||
"required": required,
|
||||
"additionalProperties": true
|
||||
})
|
||||
}
|
||||
|
||||
pub fn epiphany_reorient_launch_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"mode": {
|
||||
"type": "string",
|
||||
"enum": ["resume", "regather"]
|
||||
},
|
||||
"summary": {"type": "string"},
|
||||
"nextSafeMove": {"type": "string"},
|
||||
"checkpointStillValid": {"type": "boolean"},
|
||||
"filesInspected": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"frontierNodeIds": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"evidenceIds": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"openQuestions": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
},
|
||||
"continuityRisks": {
|
||||
"type": "array",
|
||||
"items": {"type": "string"}
|
||||
}
|
||||
},
|
||||
"required": ["mode", "summary", "nextSafeMove"],
|
||||
"additionalProperties": true
|
||||
})
|
||||
}
|
||||
|
||||
const EPIPHANY_SPECIALIST_PROMPTS_TOML: &str = include_str!("prompts/epiphany_specialists.toml");
|
||||
const EPIPHANY_WORKER_BOUNDARY_PROMPT: &str = r#"## Epiphany Worker Boundary
|
||||
You are one bounded Epiphany worker for this launch only. Your authority comes from the typed launch document, the role-local instruction, and the declared output contract.
|
||||
Do the role, name uncertainty, and return the required JSON object. Do not become the coordinator, do not accept or promote your own output, do not invent durable state outside an allowed statePatch, and do not treat model transport or Codex machinery as prompt authority.
|
||||
If you learned a durable role-local habit, you may include a bounded selfPatch. Project truth belongs in statePatch or evidence, not memory."#;
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanySpecialistPromptConfig {
|
||||
pub shared: EpiphanySharedPromptConfig,
|
||||
pub roles: EpiphanyRolePromptConfig,
|
||||
// Parsed here so the bundled prompt config fails fast even though the GUI runner consumes it.
|
||||
#[allow(dead_code)]
|
||||
pub implementation: EpiphanyImplementationPromptConfig,
|
||||
pub reorientation: EpiphanyReorientationPromptConfig,
|
||||
pub coordinator: EpiphanyCoordinatorPromptConfig,
|
||||
pub crrc: EpiphanyCrrcPromptConfig,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanySharedPromptConfig {
|
||||
pub persistent_memory: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyRolePromptConfig {
|
||||
pub imagination: String,
|
||||
pub modeling: String,
|
||||
pub verification: String,
|
||||
#[allow(dead_code)]
|
||||
pub research: String,
|
||||
#[allow(dead_code)]
|
||||
pub repo_personality: String,
|
||||
#[allow(dead_code)]
|
||||
pub repo_memory: String,
|
||||
#[allow(dead_code)]
|
||||
pub face: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyImplementationPromptConfig {
|
||||
#[allow(dead_code)]
|
||||
pub continue_template: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyReorientationPromptConfig {
|
||||
pub resume: String,
|
||||
pub regather: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyCoordinatorPromptConfig {
|
||||
pub note_template: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, serde::Deserialize)]
|
||||
pub struct EpiphanyCrrcPromptConfig {
|
||||
pub pre_compaction_checkpoint_intervention: String,
|
||||
}
|
||||
|
||||
pub fn epiphany_specialist_prompt_config() -> &'static EpiphanySpecialistPromptConfig {
|
||||
static CONFIG: OnceLock<EpiphanySpecialistPromptConfig> = OnceLock::new();
|
||||
CONFIG.get_or_init(|| {
|
||||
toml::from_str(EPIPHANY_SPECIALIST_PROMPTS_TOML)
|
||||
.expect("bundled Epiphany specialist prompt config must parse")
|
||||
})
|
||||
}
|
||||
|
||||
pub fn epiphany_agent_prompt_with_memory(body: &str) -> String {
|
||||
let memory = epiphany_specialist_prompt_config()
|
||||
.shared
|
||||
.persistent_memory
|
||||
.trim();
|
||||
let body = body.trim();
|
||||
if memory.is_empty() {
|
||||
body.to_string()
|
||||
} else if body.is_empty() {
|
||||
memory.to_string()
|
||||
} else {
|
||||
format!("{memory}\n\n{body}")
|
||||
}
|
||||
}
|
||||
|
||||
pub fn epiphany_worker_prompt(body: &str) -> String {
|
||||
let body = body.trim();
|
||||
if body.is_empty() {
|
||||
EPIPHANY_WORKER_BOUNDARY_PROMPT.to_string()
|
||||
} else {
|
||||
format!("{}\n\n{}", EPIPHANY_WORKER_BOUNDARY_PROMPT, body)
|
||||
}
|
||||
}
|
||||
|
||||
pub fn build_epiphany_role_launch_request(
|
||||
thread_id: &str,
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
expected_revision: Option<u64>,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
state: &EpiphanyThreadState,
|
||||
) -> Result<EpiphanyJobLaunchRequest, String> {
|
||||
let binding_id = epiphany_role_binding_id(role_id)?;
|
||||
let owner_role = epiphany_role_owner(role_id)?;
|
||||
let linked_subgoal_ids = epiphany_active_subgoal_ids(Some(state));
|
||||
let linked_graph_node_ids = epiphany_active_graph_node_ids(Some(state));
|
||||
let (scope, authority_scope, instruction) = match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => (
|
||||
"role-scoped planning synthesis",
|
||||
"epiphany.role.imagination",
|
||||
build_epiphany_role_launch_instruction(role_id),
|
||||
),
|
||||
EpiphanyRoleResultRoleId::Modeling => (
|
||||
"role-scoped modeling/checkpoint maintenance",
|
||||
"epiphany.role.modeling",
|
||||
build_epiphany_role_launch_instruction(role_id),
|
||||
),
|
||||
EpiphanyRoleResultRoleId::Verification => (
|
||||
"role-scoped verification/review",
|
||||
"epiphany.role.verification",
|
||||
build_epiphany_role_launch_instruction(role_id),
|
||||
),
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
|
||||
return Err(epiphany_role_binding_id(role_id).unwrap_err());
|
||||
}
|
||||
};
|
||||
let launch_document = EpiphanyWorkerLaunchDocument::Role(EpiphanyRoleWorkerLaunchDocument {
|
||||
thread_id: thread_id.to_string(),
|
||||
role_id: epiphany_role_label(role_id).to_string(),
|
||||
state_revision: state.revision,
|
||||
objective: state.objective.clone(),
|
||||
active_subgoal_id: state.active_subgoal_id.clone(),
|
||||
active_subgoals: state
|
||||
.subgoals
|
||||
.iter()
|
||||
.filter(|subgoal| Some(subgoal.id.as_str()) == state.active_subgoal_id.as_deref())
|
||||
.cloned()
|
||||
.collect(),
|
||||
active_graph_node_ids: linked_graph_node_ids.clone(),
|
||||
investigation_checkpoint: state.investigation_checkpoint.clone(),
|
||||
scratch: state.scratch.clone(),
|
||||
invariants: state.invariants.clone(),
|
||||
graphs: Some(state.graphs.clone()),
|
||||
recent_evidence: state.recent_evidence.iter().take(8).cloned().collect(),
|
||||
recent_observations: state.observations.iter().take(8).cloned().collect(),
|
||||
graph_frontier: state.graph_frontier.clone(),
|
||||
graph_checkpoint: state.graph_checkpoint.clone(),
|
||||
planning: Some(state.planning.clone()),
|
||||
churn: state.churn.clone(),
|
||||
});
|
||||
let output_contract_id = launch_document.output_contract_id().to_string();
|
||||
let organ_launch_contract = default_launch_organ_contract(
|
||||
authority_scope,
|
||||
launch_document.document_kind(),
|
||||
&output_contract_id,
|
||||
);
|
||||
|
||||
Ok(EpiphanyJobLaunchRequest {
|
||||
expected_revision,
|
||||
binding_id: binding_id.to_string(),
|
||||
kind: CoreEpiphanyJobKind::Specialist,
|
||||
scope: scope.to_string(),
|
||||
owner_role: owner_role.to_string(),
|
||||
authority_scope: authority_scope.to_string(),
|
||||
linked_subgoal_ids,
|
||||
linked_graph_node_ids: epiphany_active_graph_node_ids(Some(state)),
|
||||
instruction,
|
||||
launch_document,
|
||||
output_contract_id,
|
||||
organ_launch_contract,
|
||||
max_runtime_seconds,
|
||||
})
|
||||
}
|
||||
|
||||
fn build_epiphany_role_launch_instruction(role_id: EpiphanyRoleResultRoleId) -> String {
|
||||
let prompts = &epiphany_specialist_prompt_config().roles;
|
||||
let body = match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => prompts.imagination.as_str(),
|
||||
EpiphanyRoleResultRoleId::Modeling => prompts.modeling.as_str(),
|
||||
EpiphanyRoleResultRoleId::Verification => prompts.verification.as_str(),
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => {
|
||||
"Unsupported Epiphany role specialist template."
|
||||
}
|
||||
};
|
||||
epiphany_worker_prompt(body)
|
||||
}
|
||||
|
||||
pub fn build_epiphany_reorient_launch_request(
|
||||
thread_id: &str,
|
||||
expected_revision: Option<u64>,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
state: &EpiphanyThreadState,
|
||||
checkpoint: &EpiphanyInvestigationCheckpoint,
|
||||
decision: &CoreEpiphanyReorientDecision,
|
||||
) -> EpiphanyJobLaunchRequest {
|
||||
let instruction = build_epiphany_reorient_launch_instruction(decision.action);
|
||||
build_reorient_job_launch_request(EpiphanyReorientLaunchRequestInput {
|
||||
thread_id,
|
||||
expected_revision,
|
||||
max_runtime_seconds,
|
||||
binding_id: EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
|
||||
owner_role: EPIPHANY_REORIENT_OWNER_ROLE,
|
||||
instruction,
|
||||
state,
|
||||
checkpoint,
|
||||
decision,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn build_epiphany_reorient_launch_instruction(action: CoreEpiphanyReorientAction) -> String {
|
||||
let prompts = &epiphany_specialist_prompt_config().reorientation;
|
||||
let body = match action {
|
||||
CoreEpiphanyReorientAction::Resume => prompts.resume.as_str(),
|
||||
CoreEpiphanyReorientAction::Regather => prompts.regather.as_str(),
|
||||
};
|
||||
epiphany_worker_prompt(body)
|
||||
}
|
||||
|
||||
pub fn build_epiphany_job_launch_request(
|
||||
expected_revision: Option<u64>,
|
||||
binding_id: String,
|
||||
kind: CoreEpiphanyJobKind,
|
||||
scope: String,
|
||||
owner_role: String,
|
||||
authority_scope: String,
|
||||
linked_subgoal_ids: Vec<String>,
|
||||
linked_graph_node_ids: Vec<String>,
|
||||
instruction: String,
|
||||
launch_document: EpiphanyWorkerLaunchDocument,
|
||||
output_contract_id: String,
|
||||
max_runtime_seconds: Option<u64>,
|
||||
) -> EpiphanyJobLaunchRequest {
|
||||
let organ_launch_contract = default_launch_organ_contract(
|
||||
&authority_scope,
|
||||
launch_document.document_kind(),
|
||||
&output_contract_id,
|
||||
);
|
||||
EpiphanyJobLaunchRequest {
|
||||
expected_revision,
|
||||
binding_id,
|
||||
kind,
|
||||
scope,
|
||||
owner_role,
|
||||
authority_scope,
|
||||
linked_subgoal_ids,
|
||||
linked_graph_node_ids,
|
||||
instruction,
|
||||
launch_document,
|
||||
output_contract_id,
|
||||
organ_launch_contract,
|
||||
max_runtime_seconds,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn render_epiphany_coordinator_note(
|
||||
crrc_action: CoreEpiphanyCrrcAction,
|
||||
pressure_level: CoreEpiphanyPressureLevel,
|
||||
modeling_result_status: CoreEpiphanyCoordinatorRoleResultStatus,
|
||||
verification_result_status: CoreEpiphanyCoordinatorRoleResultStatus,
|
||||
reorient_result_status: CoreEpiphanyCrrcResultStatus,
|
||||
coordinator_action: CoreEpiphanyCoordinatorAction,
|
||||
) -> String {
|
||||
let template = epiphany_agent_prompt_with_memory(
|
||||
&epiphany_specialist_prompt_config()
|
||||
.coordinator
|
||||
.note_template,
|
||||
);
|
||||
template
|
||||
.trim()
|
||||
.replace("{crrc_action}", &format!("{crrc_action:?}"))
|
||||
.replace("{pressure_level}", &format!("{pressure_level:?}"))
|
||||
.replace(
|
||||
"{modeling_result_status}",
|
||||
&format!("{modeling_result_status:?}"),
|
||||
)
|
||||
.replace(
|
||||
"{verification_result_status}",
|
||||
&format!("{verification_result_status:?}"),
|
||||
)
|
||||
.replace(
|
||||
"{reorient_result_status}",
|
||||
&format!("{reorient_result_status:?}"),
|
||||
)
|
||||
.replace("{coordinator_action}", &format!("{coordinator_action:?}"))
|
||||
}
|
||||
|
||||
pub fn render_epiphany_pre_compaction_checkpoint_intervention(
|
||||
pressure: &EpiphanyPressure,
|
||||
) -> String {
|
||||
let usage = match (
|
||||
pressure.used_tokens,
|
||||
pressure.remaining_tokens,
|
||||
pressure.ratio_per_mille,
|
||||
) {
|
||||
(Some(used), Some(remaining), Some(ratio)) => format!(
|
||||
"{used} tokens used, {remaining} remaining, {}.{}% of the selected limit",
|
||||
ratio / 10,
|
||||
ratio % 10
|
||||
),
|
||||
(Some(used), _, _) => format!("{used} tokens used"),
|
||||
_ => "token usage known only as a pressure threshold crossing".to_string(),
|
||||
};
|
||||
let template = epiphany_agent_prompt_with_memory(
|
||||
&epiphany_specialist_prompt_config()
|
||||
.crrc
|
||||
.pre_compaction_checkpoint_intervention,
|
||||
);
|
||||
template
|
||||
.trim()
|
||||
.replace(
|
||||
"{pressure_level}",
|
||||
core_pressure_level_label(pressure.level),
|
||||
)
|
||||
.replace("{usage}", &usage)
|
||||
}
|
||||
|
||||
fn core_pressure_level_label(level: CoreEpiphanyPressureLevel) -> &'static str {
|
||||
match level {
|
||||
CoreEpiphanyPressureLevel::Unknown => "unknown",
|
||||
CoreEpiphanyPressureLevel::Low => "low",
|
||||
CoreEpiphanyPressureLevel::Elevated => "elevated",
|
||||
CoreEpiphanyPressureLevel::High => "high",
|
||||
CoreEpiphanyPressureLevel::Critical => "critical",
|
||||
}
|
||||
}
|
||||
|
||||
pub fn unique_strings(values: impl IntoIterator<Item = String>) -> Vec<String> {
|
||||
let mut unique = Vec::new();
|
||||
extend_unique_strings(&mut unique, values);
|
||||
unique
|
||||
}
|
||||
|
||||
fn extend_unique_strings(target: &mut Vec<String>, values: impl IntoIterator<Item = String>) {
|
||||
for value in values {
|
||||
if !target.iter().any(|existing| existing == &value) {
|
||||
target.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn epiphany_active_subgoal_ids(state: Option<&EpiphanyThreadState>) -> Vec<String> {
|
||||
state
|
||||
.and_then(|state| state.active_subgoal_id.clone())
|
||||
.map(|id| vec![id])
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
fn epiphany_active_graph_node_ids(state: Option<&EpiphanyThreadState>) -> Vec<String> {
|
||||
state
|
||||
.and_then(|state| state.graph_frontier.as_ref())
|
||||
.map(|frontier| frontier.active_node_ids.clone())
|
||||
.unwrap_or_default()
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
#[test]
|
||||
fn bundled_epiphany_agent_prompts_do_not_name_codex_as_prompt_authority() {
|
||||
let prompts = epiphany_specialist_prompt_config();
|
||||
let rendered = [
|
||||
(
|
||||
"shared.persistent_memory",
|
||||
prompts.shared.persistent_memory.as_str(),
|
||||
),
|
||||
("roles.imagination", prompts.roles.imagination.as_str()),
|
||||
("roles.modeling", prompts.roles.modeling.as_str()),
|
||||
("roles.verification", prompts.roles.verification.as_str()),
|
||||
("roles.research", prompts.roles.research.as_str()),
|
||||
(
|
||||
"roles.repo_personality",
|
||||
prompts.roles.repo_personality.as_str(),
|
||||
),
|
||||
("roles.repo_memory", prompts.roles.repo_memory.as_str()),
|
||||
("roles.face", prompts.roles.face.as_str()),
|
||||
(
|
||||
"implementation.continue_template",
|
||||
prompts.implementation.continue_template.as_str(),
|
||||
),
|
||||
(
|
||||
"reorientation.resume",
|
||||
prompts.reorientation.resume.as_str(),
|
||||
),
|
||||
(
|
||||
"reorientation.regather",
|
||||
prompts.reorientation.regather.as_str(),
|
||||
),
|
||||
(
|
||||
"coordinator.note_template",
|
||||
prompts.coordinator.note_template.as_str(),
|
||||
),
|
||||
(
|
||||
"crrc.pre_compaction_checkpoint_intervention",
|
||||
prompts.crrc.pre_compaction_checkpoint_intervention.as_str(),
|
||||
),
|
||||
];
|
||||
|
||||
for (name, prompt) in rendered {
|
||||
assert!(
|
||||
!prompt.contains("Codex"),
|
||||
"{name} must stay Epiphany-owned and Codex-free"
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn role_worker_prompt_is_bounded_not_full_persistent_memory() {
|
||||
let prompt = build_epiphany_role_launch_instruction(EpiphanyRoleResultRoleId::Modeling);
|
||||
|
||||
assert!(prompt.contains("Epiphany Worker Boundary"));
|
||||
assert!(prompt.contains("Act as the Epiphany modeling/checkpoint specialist"));
|
||||
assert!(!prompt.contains("## Epiphany Persistent Memory"));
|
||||
assert!(!prompt.contains("Heartbeat: every lane"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn reorient_worker_prompt_is_bounded_not_full_persistent_memory() {
|
||||
let prompt = build_epiphany_reorient_launch_instruction(CoreEpiphanyReorientAction::Resume);
|
||||
|
||||
assert!(prompt.contains("Epiphany Worker Boundary"));
|
||||
assert!(!prompt.contains("## Epiphany Persistent Memory"));
|
||||
assert!(!prompt.contains("Heartbeat: every lane"));
|
||||
}
|
||||
}
|
||||
|
|
@ -1,3 +1,4 @@
|
|||
mod agent_launch;
|
||||
mod agent_memory;
|
||||
mod agent_utterance_state;
|
||||
mod body_gateway;
|
||||
|
|
@ -21,6 +22,36 @@ mod state_update;
|
|||
mod surfaces;
|
||||
mod thread_state_store;
|
||||
|
||||
pub use agent_launch::EPIPHANY_IMAGINATION_OWNER_ROLE;
|
||||
pub use agent_launch::EPIPHANY_IMAGINATION_ROLE_BINDING_ID;
|
||||
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_VERIFICATION_OWNER_ROLE;
|
||||
pub use agent_launch::EPIPHANY_VERIFICATION_ROLE_BINDING_ID;
|
||||
pub use agent_launch::EpiphanyCoordinatorPromptConfig;
|
||||
pub use agent_launch::EpiphanyCrrcPromptConfig;
|
||||
pub use agent_launch::EpiphanyImplementationPromptConfig;
|
||||
pub use agent_launch::EpiphanyReorientationPromptConfig;
|
||||
pub use agent_launch::EpiphanyRolePromptConfig;
|
||||
pub use agent_launch::EpiphanySharedPromptConfig;
|
||||
pub use agent_launch::EpiphanySpecialistPromptConfig;
|
||||
pub use agent_launch::build_epiphany_job_launch_request;
|
||||
pub use agent_launch::build_epiphany_reorient_launch_instruction;
|
||||
pub use agent_launch::build_epiphany_reorient_launch_request;
|
||||
pub use agent_launch::build_epiphany_role_launch_request;
|
||||
pub use agent_launch::epiphany_agent_prompt_with_memory;
|
||||
pub use agent_launch::epiphany_reorient_launch_output_schema;
|
||||
pub use agent_launch::epiphany_role_binding_id;
|
||||
pub use agent_launch::epiphany_role_label;
|
||||
pub use agent_launch::epiphany_role_launch_output_schema;
|
||||
pub use agent_launch::epiphany_role_owner;
|
||||
pub use agent_launch::epiphany_specialist_prompt_config;
|
||||
pub use agent_launch::epiphany_worker_prompt;
|
||||
pub use agent_launch::render_epiphany_coordinator_note;
|
||||
pub use agent_launch::render_epiphany_pre_compaction_checkpoint_intervention;
|
||||
pub use agent_launch::unique_strings;
|
||||
pub use agent_memory::AgentCanonicalTraitSeed;
|
||||
pub use agent_memory::AgentMemoryReview;
|
||||
pub use agent_memory::AgentSelfPatch;
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
- Status-mode local runs now also write a native CultMesh operator snapshot to `.epiphany-run/cultmesh/operator-snapshots.ccmp` through `epiphany-operator-snapshot`. That snapshot distills the operator-safe MVP status artifact into typed fields such as thread id, state status, coordinator action, CRRC action, reorient action, available actions, and artifact refs; it does not preserve the raw JSON status blob as internal state.
|
||||
- `epiphany-mvp-status --source native` is the current provider-neutral status boundary. It projects scene, pressure, jobs, roles, planning, reorient, CRRC, coordinator status, and runtime-linked worker lifecycle from native core surfaces. It reads runtime-spine job/result receipts for linked jobs so failed workers show as failed in role results, jobs, roles, and coordinator source signals, while successful semantic findings still require typed role/reorient worker result documents. Keep future pluggable model-provider work behind launch/result/runtime documents; do not let provider choice leak into status, prompt authority, scheduler policy, or durable `EpiphanyThreadState`.
|
||||
- `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. Bundled specialist prompts live in `epiphany-codex-bridge/src/prompts/epiphany_specialists.toml`, the app-server boundary has a regression test that fails if any bundled Epiphany agent prompt contains `Codex`, 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.
|
||||
- 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.
|
||||
- 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.
|
||||
|
|
@ -152,7 +152,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
- The old Python dogfood/live-specialist runners were cut because they encoded the obsolete completion path. The replacement must be native Rust/CultCache/CultNet and complete heartbeat-owned runtime-spine job results with auditable artifacts.
|
||||
- The Aquarium operator UI now lives in sibling repo `E:\Projects\EpiphanyAquarium`, not under `apps/epiphany-gui`. It is a Tauri v2 + React/WebGL interface organism over the existing status bridge, dogfood artifacts, and GUI action artifacts, not a new throne of truth. It has its own `AGENTS.md`, persistent `state/map.yaml`, `state/memory.json`, scratch/evidence files, and interface doctrine. EpiphanyAgent remains the authoritative harness/backend forge.
|
||||
- Durable in-flight investigation checkpointing is now landed in authoritative typed state, writable through `thread/epiphany/update` or accepted `thread/epiphany/promote`, rendered into the prompt, and reflected through scene/context.
|
||||
- The prompt doctrine pass is landed. Shared Epiphany prompts now carry distilled memory/evidence discipline. Rendered state intro/doctrine text lives in `epiphany-state-model/src/prompts/`, and lane/control prompt text lives in `epiphany-codex-bridge/src/prompts/epiphany_specialists.toml`: modeling is the Body, implementation is the Hands and GUI-launched main coding lane, verification is the Soul, reorientation is Life, coordinator remains the read-only Self, and CRRC owns the pre-compaction intervention template.
|
||||
- The prompt doctrine pass is landed. Shared Epiphany prompts now carry distilled memory/evidence discipline. Rendered state intro/doctrine text lives in `epiphany-state-model/src/prompts/`, and lane/control prompt text now lives in `epiphany-core/src/prompts/epiphany_specialists.toml` under the core `agent_launch` owner: modeling is the Body, implementation is the Hands and GUI-launched main coding lane, verification is the Soul, reorientation is Life, coordinator remains the read-only Self, and CRRC owns the pre-compaction intervention template.
|
||||
- The machine-priest voice now says the quiet part plainly: crusade/heresy/purity language is aimed at technical rot, hidden state, duplicate truth, drift, and lying structures, not at humans. Future Epiphany swarms should inherit severity toward systems and curiosity toward people.
|
||||
- The Ghostlight memory pass is landed. `epiphany_specialists.toml` now has a shared persistent-memory projection prepended by the harness to fixed role specialists, reorientation workers, coordinator notes, and CRRC checkpoint interventions. The rendered base doctrine also states the Perfect Machine rule directly: prompt is projection, durable typed state is the mind, every lane must improve its own memory/model/prompt/evidence habit or name the repair, and each lane phrases that duty in its own organ language so the salience sticks.
|
||||
- The role self-memory persistence pass is native now. Each lane has a Ghostlight-shaped typed dossier in `state/agents.msgpack`, and specialists may return optional `selfPatch` requests beside their normal role result. Relationship, event, scene, and perceived-overlay arrays are typed dossier documents, not JSON cargo, and the durable structs do not keep unknown `extra` maps. `roleResult`/`roleAccept` project coordinator review as `selfPersistence`: accepted requests are role-matched, bounded lane memory/goal/value/private-note mutations; refused requests explain wrong role, project-truth smuggling, authority grabs, bloat, missing reason, or malformed records. GUI/coordinator accept paths apply accepted `selfPatch` requests through the native `epiphany-agent-memory-store` binary; project truth still belongs only in `EpiphanyThreadState`.
|
||||
|
|
@ -568,10 +568,11 @@ The eighteenth cut stopped pretending that "less code in the processor" was the
|
|||
same as "less Epiphany in vendored Codex." A new outside-vendor crate,
|
||||
`epiphany-codex-bridge`, now owns the Codex-facing Epiphany adapters for scene,
|
||||
jobs, context/planning/graph query, retrieval, result projection,
|
||||
launch/prompt doctrine, pressure/pre-compaction rendering,
|
||||
Codex-facing launch compatibility, pressure/pre-compaction bridge delegation,
|
||||
freshness/reorientation projection, CRRC/coordinator/role-board projection, and
|
||||
acceptance/evidence signal helpers. The specialist prompt TOML moved with the
|
||||
launch spine. Vendored app-server now retains only `epiphany_invalidation.rs`
|
||||
launch spine at the time and has since moved again into `epiphany-core`.
|
||||
Vendored app-server now retains only `epiphany_invalidation.rs`
|
||||
as a root Epiphany module because watcher lifecycle is still app-server
|
||||
machinery. This pass removed roughly 3.3k lines of Epiphany-owned adapter/prompt
|
||||
code from `vendor/codex`, but `codex_message_processor.rs` is still about
|
||||
|
|
@ -1296,7 +1297,7 @@ sane parts into the shared base prompt, rendered Epiphany state, and fixed lane
|
|||
templates. Major prompt text now lives in prompt files instead of Rust/Python
|
||||
string slabs: rendered state intro/doctrine lives under `epiphany-state-model/src/prompts/`,
|
||||
and lane/control templates live in
|
||||
`epiphany-codex-bridge/src/prompts/epiphany_specialists.toml`.
|
||||
`epiphany-core/src/prompts/epiphany_specialists.toml`.
|
||||
Implementation is not a `roleLaunch` specialist; it is the GUI-launched main
|
||||
coding lane, and its `continue_template` now lives in the same TOML for audit.
|
||||
The latest live-specialist run again produced `.epiphany-dogfood/live-specialist`
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -193,8 +193,8 @@ accepted_design:
|
|||
- A machine is perfect when every remaining part visibly deserves to exist; this applies to persistent memory too.
|
||||
- Evidence is not an activity feed; repeated "I just did this" entries should be cut or distilled when git already proves the work.
|
||||
- Language, tone, ritual, and emotional salience are real control surfaces for a language-model harness; they are not supernatural, but they shape attention, role, permission, and behavior. The rite is a steering wheel, not decoration.
|
||||
- Major Epiphany prompt surfaces live in prompt files rather than Rust/Python string slabs: rendered state intro/doctrine under `epiphany-state-model/src/prompts/`, and modeling/Body, research/Eyes, implementation/Hands, verification/Soul, reorientation/Life, coordinator/Self, Face/public-surface, and CRRC intervention templates in `epiphany-codex-bridge/src/prompts/epiphany_specialists.toml`.
|
||||
- Specialist prompts are role-distilled instead of generic and their live text is config-backed in app-server: modeling/checkpoint is the Body of code, dataflow, seams, and frontier; research/scout is the Eyes prompt surface for existing work, vendor guidance, libraries, papers, and anti-Greenspun source selection; implementation is the Hands, the main coding lane and actuator rather than a `roleLaunch` specialist; verification/review is the Soul of promise, invariants, evidence, and user truth; reorientation is Life across compaction and source drift; coordinator is the read-only Self that routes attention without implementing, verifying, promoting, or accepting; Face is the public Discord #aquarium surface that translates agent thought-weather without moderating or leaking sealed thought.
|
||||
- Major Epiphany prompt surfaces live in prompt files rather than Rust/Python string slabs: rendered state intro/doctrine under `epiphany-state-model/src/prompts/`, and modeling/Body, research/Eyes, implementation/Hands, verification/Soul, reorientation/Life, coordinator/Self, Face/public-surface, and CRRC intervention templates in `epiphany-core/src/prompts/epiphany_specialists.toml`.
|
||||
- Specialist prompts are role-distilled instead of generic and their live text is config-backed in `epiphany-core`: modeling/checkpoint is the Body of code, dataflow, seams, and frontier; research/scout is the Eyes prompt surface for existing work, vendor guidance, libraries, papers, and anti-Greenspun source selection; implementation is the Hands, the main coding lane and actuator rather than a `roleLaunch` specialist; verification/review is the Soul of promise, invariants, evidence, and user truth; reorientation is Life across compaction and source drift; coordinator is the read-only Self that routes attention without implementing, verifying, promoting, or accepting; Face is the public Discord #aquarium surface that translates agent thought-weather without moderating or leaking sealed thought.
|
||||
- Epiphany prompt surfaces now carry a shared Ghostlight-derived persistent memory projection before lane-specific text: prompt is not memory, durable typed state is the mind, personality and protected values are first-class salience handles, and every lane is explicitly responsible for making its own memory/model/prompt/evidence habit sharper or naming the needed repair. Each lane states self-improvement in its own rite-language: Imagination selects futures, Body clarifies anatomy, Eyes sees earlier, Hands touches source more precisely, Soul becomes harder to fool, Life loses less continuity, Self routes repair, and Face becomes clearer at turning inner weather into useful social presence.
|
||||
- Specialist self-memory now has a bounded Ghostlight-shaped CultCache persistence surface in `state/agents.msgpack`: Imagination, Body, Eyes, Hands, Soul, Life, Self, and Face each have an individual typed role dossier for identity, personality, semantic/episodic/relationship memory, goals, and values. These entries are lane memory only; project truth remains in authoritative `EpiphanyThreadState`.
|
||||
- `state/agent-heartbeats.msgpack`, `epiphany-core::EpiphanyHeartbeatStateEntry`, and the native `epiphany-heartbeat-store` binary are the Ghostlight-derived heartbeat initiative seam. The harness sets a target heartbeat rate; participants carry arena, participant kind, initiative speed, next-ready time, reaction bias, interrupt threshold, current load, status, constraints, personality cooldown, mood cooldown, initiative heat, active-turn freeze state, and effective cooldown; pending coordinator work can pull its owning lane through a reaction window; otherwise the earliest ready active participant wins the slot. Role dossiers set the personality baseline, appraisals bend it with mood/anxiety signals such as urgency, arousal, thought pressure, guardedness, and reaction intensity, and lower effective cooldown means the lane recovers sooner and gets the floor more often. `HeartbeatMoodTiming` now also owns the 32-axis current affect vector used by utterance state: anger, despair, sadness, fear, contempt, annoyance, dismissal, flippancy, tenderness, warmth, shame, pride, fatigue, secrecy, hesitation, emotional containment, and related speech pressures are heartbeat physiology, not decorative prompt adjectives. Initiative heat is typed heartbeat policy, not a side flag: `epiphany-heartbeat-store heat` and the CultNet `epiphany.heartbeat_heat_intent.v0` contract can set or clear global, all, agent, role, arena, participant-kind, group, and constraint multipliers, with optional scene-clock expiry. Active thinking freezes initiative explicitly: running pending turns project `initiativeFrozen` / `initiative_frozen`, are ineligible for reaction, cannot be selected again, and start cooldown only after completion. The native `pump` command computes adaptive swarm pressure from external urgency, mood/anxiety, reaction intensity, thought pressure, and current pending load; relaxed pressure can launch nothing and run at crawl tempo, while alarm pressure can fill most or all active lanes up to a configured concurrency cap without waking any lane already running. If the winner has no routeable maintenance work, it ruminates on role quality and prepares bounded selfPatch pressure rather than pretending rumination has already consolidated doctrine. Sleep/dream cycle passes are the intended distillation window for reviewed self-memory and doctrine. Face can win `surfaceAgentThoughts` or `discordAquariumChat` work slots. Epiphany also owns native character-loop projection through `epiphany-character-loop`, so role dossiers can respond to visible stimuli without importing Ghostlight as runtime. The same heartbeat store now owns the Void-derived routine fields typed `sleep_cycle`, typed `memory_resonance`, `incubation`, `thought_lanes`, `bridge`, `candidate_interventions`, typed `appraisals`, and typed `reactions` through the native `epiphany-heartbeat-store routine` command.
|
||||
|
|
@ -209,7 +209,7 @@ accepted_design:
|
|||
- The native `epiphany-face-discord bubble`, the `face` block in native `epiphany-mvp-status`, and GUI action `faceBubble` are the first Aquarium bubble surface. Face can open a local chat bubble artifact even when Discord channel id/token configuration is absent.
|
||||
- `thread/epiphany/roleResult` and `thread/epiphany/roleAccept` now project optional specialist `selfPatch` requests with coordinator review through `selfPersistence`: good mutations are role-matched, bounded, evidence-grounded lane memory/goal/value/private-note updates; project truth, authority, code edits, graphs, checkpoints, planning, scratch, jobs, and raw transcripts are refused with reasons. GUI/coordinator acceptance paths apply accepted `selfPatch` requests through the native `epiphany-agent-memory-store` binary.
|
||||
- Epiphany prompt doctrine is Epiphany-owned. Local instruction scope, concise progress updates, plan discipline, scoped edits, non-destructive filesystem/git behavior, focused validation, and concise honest finals remain first-class Epiphany harness discipline rather than Codex authority or prompt machinery. Good old scars are holy only after they are grafted into the right body.
|
||||
- Bundled Epiphany agent prompts are guarded against Codex-named prompt authority at the app-server boundary, and repo-birth specialist execution no longer accepts the old `codex-exec` path. Codex may provide compatible auth/model transport and quarantined app-server affordances; it must not wrap Epiphany agents in its own role, developer, collaboration-mode, or harness prompts.
|
||||
- Bundled Epiphany agent prompts are parsed, rendered, and guarded against Codex-named prompt authority inside `epiphany-core`; bridge `launch.rs` is only a compatibility re-export for Codex-facing callers. Repo-birth specialist execution no longer accepts the old `codex-exec` path. Codex may provide compatible auth/model transport and quarantined app-server affordances; it must not wrap Epiphany agents in its own role, developer, collaboration-mode, or harness prompts.
|
||||
- Greenspun-shaped invention is now a named prompt-level guardrail. Before building a parser, scheduler, renderer, protocol, storage layer, security mechanism, workflow engine, or algorithm, agents must perform or request a bounded Eyes/research scout rite and record why existing work does or does not fit.
|
||||
- Repetitive operator work must be externalized as a visible queue before the harness treats it as complete. Batch rendering, tile generation, migrations, imports, or other finite loops need item counts, terminal states, blockers, and validation; a narratable partial run is progress, not completion.
|
||||
- Epiphany must resist pattern completion bias: the implementor should relentlessly chase the stated objective, while the coordinator critically asks whether implementation satisfied the objective with evidence or merely produced a plausible turn, shortcut, or decorative diff. Pretty motion without objective movement is scrap-code theater.
|
||||
|
|
@ -314,7 +314,7 @@ rejected_paths:
|
|||
reason: making Epiphany cleaner inside Codex still preserves the wrong organ; Codex must be starved down to OpenAI subscription auth/model transport, while Epiphany data and subsystem communication move to typed CultCache/CultNet.
|
||||
|
||||
current_status:
|
||||
summary: The Codex starvation pass has five typing receipts, sixty-plus processor/foundation cuts, a real physical extraction in `epiphany-codex-bridge`, a root `epiphany-state-model` crate for durable Epiphany state plus prompt-state rendering, a source-grounded Codex auth spine inventory, the native `epiphany-openai-adapter` document boundary, a buildable Codex auth/model wrapper in `epiphany-openai-codex-spine`, the first native runtime caller in `epiphany-openai-runtime`, native heartbeat launch planning/job opening in `epiphany-core`, native state-update contract/validation/application in `epiphany-core`, native exact retrieval path matching in `epiphany-core`, and the route-facing mutation/view/coordinator projection services in `epiphany-codex-bridge`. `codex-protocol` no longer defines durable `Epiphany*` state structs; it re-exports the native model and renderer for legacy rollout/API compatibility. `epiphany-core` and `epiphany-codex-bridge` have no direct `codex-core` dependency, and `codex-core` no longer depends on `epiphany-core`: pressure derives from native `EpiphanyTokenUsageSnapshot`, Codex rollout replay stays in the real Codex rollout adapter, prompt rendering lives in `epiphany-state-model`, and app-server owns the thin `EpiphanyCodexThreadHost` wrapper for host state/path/persistence facts. The bridge owns Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval/indexing execution and projection, result projection, runtime-spine result adaptation, launch/prompt doctrine, mutation document mechanics, state update/promote/role-accept/reorient-accept/role-launch/reorient-launch/job-launch/job-interrupt application through `EpiphanyMutationHost`, pressure/pre-compaction rendering, freshness/reorientation projection, CRRC/coordinator/role-board projection, native watcher invalidation, full `thread/epiphany/view` response construction, freshness/context/graph-query response construction, role/reorient result response construction, distill/propose patch-response construction, coordinator status/view construction, and acceptance/evidence signal helpers. Vendored app-server no longer retains root Epiphany modules; `codex_message_processor.rs` still contains route dispatch, JSON-RPC response shaping, host wrapper construction, and notification emission. Codex product surfaces for apps, skills, plugins, marketplace, external agent config import, SDK scaffolding, connectors, ChatGPT app discovery, plugin provenance, and skill mention plumbing have been cut from the live path. `codex_thread.rs` is now about 449 lines and owns Codex thread hosting, not Epiphany policy. `epiphany-openai-codex-spine` owns the native OpenAI model transport path while intentionally reaching retained vendored `codex-login` only through `epiphany-openai-auth-spine`; auth identity, credential storage, and ChatGPT token refresh remain owned by the Codex-compatible auth organ. `epiphany-openai-runtime` writes typed OpenAI/runtime documents, loads durable worker launch requests, persists typed role/reorient worker result documents, and completes heartbeat/specialist runtime jobs without Codex worker execution. MCP itself is correctly JSON at its protocol edge; the target remains typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON.
|
||||
summary: The Codex starvation pass has five typing receipts, sixty-plus processor/foundation cuts, a real physical extraction in `epiphany-codex-bridge`, a root `epiphany-state-model` crate for durable Epiphany state plus prompt-state rendering, a source-grounded Codex auth spine inventory, the native `epiphany-openai-adapter` document boundary, a buildable Codex auth/model wrapper in `epiphany-openai-codex-spine`, the first native runtime caller in `epiphany-openai-runtime`, native heartbeat launch planning/job opening in `epiphany-core`, native state-update contract/validation/application in `epiphany-core`, native exact retrieval path matching in `epiphany-core`, core-owned Epiphany agent launch/prompt doctrine, and the route-facing mutation/view/coordinator projection services in `epiphany-codex-bridge`. `codex-protocol` no longer defines durable `Epiphany*` state structs; it re-exports the native model and renderer for legacy rollout/API compatibility. `epiphany-core` and `epiphany-codex-bridge` have no direct `codex-core` dependency, and `codex-core` no longer depends on `epiphany-core`: pressure derives from native `EpiphanyTokenUsageSnapshot`, Codex rollout replay stays in the real Codex rollout adapter, prompt rendering lives in `epiphany-state-model`, bundled specialist prompt rendering lives in `epiphany-core`, and app-server owns the thin `EpiphanyCodexThreadHost` wrapper for host state/path/persistence facts. The bridge owns Codex-facing Epiphany adapters for scene, jobs, context/planning/graph query, retrieval/indexing execution and projection, result projection, runtime-spine result adaptation, Codex-facing launch compatibility, mutation document mechanics, state update/promote/role-accept/reorient-accept/role-launch/reorient-launch/job-launch/job-interrupt application through `EpiphanyMutationHost`, pressure/pre-compaction bridge delegation, freshness/reorientation projection, CRRC/coordinator/role-board projection, native watcher invalidation, full `thread/epiphany/view` response construction, freshness/context/graph-query response construction, role/reorient result response construction, distill/propose patch-response construction, coordinator status/view construction, and acceptance/evidence signal helpers. Vendored app-server no longer retains root Epiphany modules; `codex_message_processor.rs` still contains route dispatch, JSON-RPC response shaping, host wrapper construction, and notification emission. Codex product surfaces for apps, skills, plugins, marketplace, external agent config import, SDK scaffolding, connectors, ChatGPT app discovery, plugin provenance, and skill mention plumbing have been cut from the live path. `codex_thread.rs` is now about 449 lines and owns Codex thread hosting, not Epiphany policy. `epiphany-openai-codex-spine` owns the native OpenAI model transport path while intentionally reaching retained vendored `codex-login` only through `epiphany-openai-auth-spine`; auth identity, credential storage, and ChatGPT token refresh remain owned by the Codex-compatible auth organ. `epiphany-openai-runtime` writes typed OpenAI/runtime documents, loads durable worker launch requests, persists typed role/reorient worker result documents, and completes heartbeat/specialist runtime jobs without Codex worker execution. MCP itself is correctly JSON at its protocol edge; the target remains typed Epiphany intent/result/receipt wrappers around MCP, not replacing MCP JSON.
|
||||
latest_cut: >
|
||||
The bridge host seam has been cut down: target-specific Hands prompt scar
|
||||
tissue was purged, bridge manifests carry the retained Codex websocket fork
|
||||
|
|
@ -569,4 +569,12 @@ current_status:
|
|||
materializes complete MCP-shaped model tool calls as typed tool invocation
|
||||
intents, and the Codex MCP spine can consume those intents from the mixed
|
||||
runtime-spine store and emit typed success/failure receipts.
|
||||
Epiphany agent launch/prompt authority has now been pulled out of the
|
||||
bridge as well: `epiphany-core::agent_launch` owns specialist prompt
|
||||
parsing/rendering, role/reorient launch instructions, role binding ids,
|
||||
output schemas, coordinator note rendering, and CRRC pre-compaction prompt
|
||||
rendering. The bridge `launch.rs` is a compatibility facade, and bridge
|
||||
pressure rendering delegates back to core. Vendored app-server no longer
|
||||
carries the bundled prompt regression test; that guard lives beside the
|
||||
core prompt owner.
|
||||
next_action: Decide and implement the Eyes/source-gathering fork before another MVP automation pass: either add a real research/Eyes specialist lane that can gather the missing stream-storage source and return a reviewable statePatch, or route regather-needed modeling findings to the main implementation agent for supervised source inspection and manual statePatch banking. Do not relaunch modeling as a substitute for source access.
|
||||
|
|
|
|||
2
vendor/codex/codex-rs/Cargo.lock
generated
vendored
2
vendor/codex/codex-rs/Cargo.lock
generated
vendored
|
|
@ -5102,7 +5102,6 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"tokio",
|
||||
"toml 0.9.11+spec-1.1.0",
|
||||
"tracing",
|
||||
"uuid",
|
||||
]
|
||||
|
|
@ -5128,6 +5127,7 @@ dependencies = [
|
|||
"serde",
|
||||
"serde_json",
|
||||
"sha1",
|
||||
"toml 0.9.11+spec-1.1.0",
|
||||
"tracing",
|
||||
"uuid",
|
||||
]
|
||||
|
|
|
|||
53
vendor/codex/codex-rs/app-server/src/lib.rs
vendored
53
vendor/codex/codex-rs/app-server/src/lib.rs
vendored
|
|
@ -130,59 +130,6 @@ enum OutboundControlEvent {
|
|||
DisconnectAll,
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod epiphany_prompt_tests {
|
||||
use epiphany_codex_bridge::launch::epiphany_specialist_prompt_config;
|
||||
|
||||
#[test]
|
||||
fn bundled_epiphany_agent_prompts_do_not_name_codex_as_prompt_authority() {
|
||||
let prompts = epiphany_specialist_prompt_config();
|
||||
let rendered = [
|
||||
(
|
||||
"shared.persistent_memory",
|
||||
prompts.shared.persistent_memory.as_str(),
|
||||
),
|
||||
("roles.imagination", prompts.roles.imagination.as_str()),
|
||||
("roles.modeling", prompts.roles.modeling.as_str()),
|
||||
("roles.verification", prompts.roles.verification.as_str()),
|
||||
("roles.research", prompts.roles.research.as_str()),
|
||||
(
|
||||
"roles.repo_personality",
|
||||
prompts.roles.repo_personality.as_str(),
|
||||
),
|
||||
("roles.repo_memory", prompts.roles.repo_memory.as_str()),
|
||||
("roles.face", prompts.roles.face.as_str()),
|
||||
(
|
||||
"implementation.continue_template",
|
||||
prompts.implementation.continue_template.as_str(),
|
||||
),
|
||||
(
|
||||
"reorientation.resume",
|
||||
prompts.reorientation.resume.as_str(),
|
||||
),
|
||||
(
|
||||
"reorientation.regather",
|
||||
prompts.reorientation.regather.as_str(),
|
||||
),
|
||||
(
|
||||
"coordinator.note_template",
|
||||
prompts.coordinator.note_template.as_str(),
|
||||
),
|
||||
(
|
||||
"crrc.pre_compaction_checkpoint_intervention",
|
||||
prompts.crrc.pre_compaction_checkpoint_intervention.as_str(),
|
||||
),
|
||||
];
|
||||
|
||||
for (name, prompt) in rendered {
|
||||
assert!(
|
||||
!prompt.contains("Codex"),
|
||||
"{name} must stay Epiphany-owned and Codex-free"
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Default)]
|
||||
struct ShutdownState {
|
||||
requested: bool,
|
||||
|
|
|
|||
Reference in a new issue