Purify coordinator grounding loop
This commit is contained in:
parent
26d9f094fe
commit
f574a194e1
18 changed files with 1039 additions and 231 deletions
|
|
@ -72,6 +72,134 @@ pub fn epiphany_role_label(role_id: EpiphanyRoleResultRoleId) -> &'static str {
|
|||
}
|
||||
}
|
||||
|
||||
fn repo_frontier_item_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"required": ["id", "migration_body", "question", "gap", "recommended_next_organ", "status"],
|
||||
"properties": {
|
||||
"id": {"type": "string", "minLength": 1},
|
||||
"migration_body": {"type": "string", "minLength": 1},
|
||||
"question": {"type": "string", "minLength": 1},
|
||||
"gap": {"type": "string", "minLength": 1},
|
||||
"target_claim_ids": {"type": "array", "items": {"type": "string"}},
|
||||
"source_scope": {"type": "array", "items": {"type": "string"}},
|
||||
"recommended_next_organ": {"type": "string", "minLength": 1},
|
||||
"dependency_item_ids": {"type": "array", "items": {"type": "string"}},
|
||||
"status": {"type": "string", "enum": ["proposed", "active", "blocked", "resolved", "retired", "superseded"]},
|
||||
"evidence_refs": {"type": "array", "items": {"type": "string"}},
|
||||
"created_at": {"type": "string"},
|
||||
"updated_at": {"type": "string"}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn repo_model_node_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"required": ["id", "domain_id", "profile", "kind", "title", "claim", "question", "tension", "action_implication"],
|
||||
"properties": {
|
||||
"id": {"type": "string", "minLength": 1},
|
||||
"domain_id": {"type": "string", "minLength": 1},
|
||||
"profile": {"type": "string", "enum": ["repo_architecture", "repo_dataflow", "role_self", "short_term", "incubation", "agency_pressure", "candidate_intervention", "identity", "evidence"]},
|
||||
"kind": {"type": "string", "enum": ["domain", "module", "crate", "binary", "schema", "runtime_contract", "adapter", "test_seam", "state_store", "role_memory", "short_term_thought", "incubation_thread", "agency_pressure", "candidate_intervention", "identity", "evidence", "summary", "other"]},
|
||||
"title": {"type": "string"},
|
||||
"claim": {"type": "string"},
|
||||
"question": {"type": "string"},
|
||||
"tension": {"type": "string"},
|
||||
"action_implication": {"type": "string"},
|
||||
"anchors": {"type": "array", "items": memory_anchor_output_schema()},
|
||||
"source_hashes": {"type": "array", "items": {"type": "string"}},
|
||||
"lifecycle": {"type": "string"},
|
||||
"salience": {"type": "integer", "minimum": 0},
|
||||
"confidence": {"type": "integer", "minimum": 0},
|
||||
"created_at": {"type": "string"},
|
||||
"updated_at": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
})
|
||||
}
|
||||
|
||||
fn repo_model_edge_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"required": ["id", "source_id", "target_id", "kind", "profile", "claim"],
|
||||
"properties": {
|
||||
"id": {"type": "string", "minLength": 1},
|
||||
"source_id": {"type": "string", "minLength": 1},
|
||||
"target_id": {"type": "string", "minLength": 1},
|
||||
"kind": {"type": "string", "enum": ["owns", "reads", "writes", "derives", "adapts", "persists", "launches", "verifies", "supports", "contradicts", "distills", "revises", "retires", "grounds", "triggers", "spoken_as", "cools", "clusters_with", "resonates_with", "depends_on", "other"]},
|
||||
"profile": {"type": "string", "enum": ["repo_architecture", "repo_dataflow", "role_self", "short_term", "incubation", "agency_pressure", "candidate_intervention", "identity", "evidence"]},
|
||||
"claim": {"type": "string"},
|
||||
"anchors": {"type": "array", "items": memory_anchor_output_schema()},
|
||||
"lifecycle": {"type": "string"},
|
||||
"confidence": {"type": "integer", "minimum": 0}
|
||||
},
|
||||
"additionalProperties": false
|
||||
})
|
||||
}
|
||||
|
||||
fn code_ref_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"required": ["path"],
|
||||
"properties": {
|
||||
"path": {"type": "string", "minLength": 1},
|
||||
"start_line": {"type": "integer", "minimum": 1},
|
||||
"end_line": {"type": "integer", "minimum": 1},
|
||||
"symbol": {"type": "string"},
|
||||
"note": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
})
|
||||
}
|
||||
|
||||
fn memory_anchor_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"required": ["id", "kind", "target"],
|
||||
"properties": {
|
||||
"id": {"type": "string", "minLength": 1},
|
||||
"kind": {"type": "string", "minLength": 1},
|
||||
"target": {"type": "string", "minLength": 1},
|
||||
"code_ref": code_ref_output_schema(),
|
||||
"evidence_id": {"type": "string"},
|
||||
"source_hash": {"type": "string"}
|
||||
},
|
||||
"additionalProperties": false
|
||||
})
|
||||
}
|
||||
|
||||
fn observation_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"required": ["id", "summary", "source_kind", "status"],
|
||||
"properties": {
|
||||
"id": {"type": "string", "minLength": 1},
|
||||
"summary": {"type": "string", "minLength": 1},
|
||||
"source_kind": {"type": "string", "minLength": 1},
|
||||
"status": {"type": "string", "minLength": 1},
|
||||
"code_refs": {"type": "array", "items": code_ref_output_schema()},
|
||||
"evidence_ids": {"type": "array", "items": {"type": "string"}}
|
||||
},
|
||||
"additionalProperties": false
|
||||
})
|
||||
}
|
||||
|
||||
fn evidence_output_schema() -> serde_json::Value {
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"required": ["id", "kind", "status", "summary"],
|
||||
"properties": {
|
||||
"id": {"type": "string", "minLength": 1},
|
||||
"kind": {"type": "string", "minLength": 1},
|
||||
"status": {"type": "string", "minLength": 1},
|
||||
"summary": {"type": "string", "minLength": 1},
|
||||
"code_refs": {"type": "array", "items": code_ref_output_schema()}
|
||||
},
|
||||
"additionalProperties": false
|
||||
})
|
||||
}
|
||||
|
||||
pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) -> serde_json::Value {
|
||||
let verdict_enum = match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => {
|
||||
|
|
@ -275,6 +403,32 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
|
|||
"required": ["id", "kind", "status", "summary"],
|
||||
"additionalProperties": true
|
||||
}
|
||||
},
|
||||
"scratch": {
|
||||
"type": "object",
|
||||
"required": ["summary"],
|
||||
"properties": {
|
||||
"summary": {"type": "string", "minLength": 1}
|
||||
},
|
||||
"additionalProperties": true
|
||||
},
|
||||
"investigationCheckpoint": {
|
||||
"type": "object",
|
||||
"description": "Outer statePatch uses camelCase; this typed checkpoint payload uses its canonical snake_case field names.",
|
||||
"required": ["checkpoint_id", "kind", "disposition", "focus"],
|
||||
"properties": {
|
||||
"checkpoint_id": {"type": "string", "minLength": 1},
|
||||
"kind": {"type": "string", "minLength": 1},
|
||||
"disposition": {"type": "string", "enum": ["resume_ready", "regather_required"]},
|
||||
"focus": {"type": "string", "minLength": 1},
|
||||
"summary": {"type": "string"},
|
||||
"next_action": {"type": "string"},
|
||||
"captured_at_turn_id": {"type": "string"},
|
||||
"open_questions": {"type": "array", "items": {"type": "string"}},
|
||||
"code_refs": {"type": "array", "items": {"type": "object"}},
|
||||
"evidence_ids": {"type": "array", "items": {"type": "string"}}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
},
|
||||
"anyOf": [
|
||||
|
|
@ -349,10 +503,38 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
|
|||
"required": ["kind"],
|
||||
"properties": {"kind": {"const": "repair_claim"}},
|
||||
"additionalProperties": false
|
||||
},
|
||||
{
|
||||
"type": "object",
|
||||
"required": ["kind", "planning_request_id", "result_id", "candidate_id"],
|
||||
"properties": {
|
||||
"kind": {"const": "adopt_frontier_plan"},
|
||||
"planning_request_id": {"type": "string", "minLength": 1},
|
||||
"result_id": {"type": "string", "minLength": 1},
|
||||
"candidate_id": {"type": "string", "minLength": 1}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}
|
||||
]
|
||||
},
|
||||
"operations": {"type": "array", "minItems": 1, "items": {"type": "object"}}
|
||||
"operations": {
|
||||
"type": "array",
|
||||
"minItems": 1,
|
||||
"items": {
|
||||
"anyOf": [
|
||||
{"type": "object", "required": ["operation", "node"], "properties": {"operation": {"const": "upsert_node"}, "node": repo_model_node_output_schema()}},
|
||||
{"type": "object", "required": ["operation", "node"], "properties": {"operation": {"const": "revise_node"}, "node": repo_model_node_output_schema()}},
|
||||
{"type": "object", "required": ["operation", "node_id"], "properties": {"operation": {"const": "retire_node"}, "node_id": {"type": "string", "minLength": 1}}},
|
||||
{"type": "object", "required": ["operation", "edge"], "properties": {"operation": {"const": "upsert_edge"}, "edge": repo_model_edge_output_schema()}},
|
||||
{"type": "object", "required": ["operation", "edge"], "properties": {"operation": {"const": "revise_edge"}, "edge": repo_model_edge_output_schema()}},
|
||||
{"type": "object", "required": ["operation", "edge_id"], "properties": {"operation": {"const": "retire_edge"}, "edge_id": {"type": "string", "minLength": 1}}},
|
||||
{"type": "object", "required": ["operation", "item"], "properties": {"operation": {"const": "upsert_frontier"}, "item": repo_frontier_item_output_schema()}},
|
||||
{"type": "object", "required": ["operation", "item"], "properties": {"operation": {"const": "revise_frontier"}, "item": repo_frontier_item_output_schema()}},
|
||||
{"type": "object", "required": ["operation", "item_id"], "properties": {"operation": {"const": "retire_frontier"}, "item_id": {"type": "string", "minLength": 1}, "retired_at": {"type": "string"}, "superseded_by": {"type": "string"}}},
|
||||
{"type": "object", "required": ["operation", "frontier_item_id", "expected_frontier_item_hash", "adopted_plan"], "properties": {"operation": {"const": "adopt_frontier_plan"}, "frontier_item_id": {"type": "string", "minLength": 1}, "expected_frontier_item_hash": {"type": "string", "minLength": 1}, "adopted_plan": {"type": "object"}}}
|
||||
]
|
||||
}
|
||||
}
|
||||
},
|
||||
"additionalProperties": true
|
||||
}),
|
||||
|
|
@ -383,8 +565,8 @@ pub fn epiphany_role_launch_output_schema(role_id: EpiphanyRoleResultRoleId) ->
|
|||
"type": "object",
|
||||
"description": "Optional generic Mind-reviewable observations/evidence only. Repository anatomy belongs exclusively in repoModelPatch.",
|
||||
"properties": {
|
||||
"observations": {"type": "array"},
|
||||
"evidence": {"type": "array"}
|
||||
"observations": {"type": "array", "items": observation_output_schema()},
|
||||
"evidence": {"type": "array", "items": evidence_output_schema()}
|
||||
},
|
||||
"additionalProperties": false
|
||||
}),
|
||||
|
|
@ -1107,6 +1289,7 @@ mod tests {
|
|||
|
||||
assert!(prompt.contains("Epiphany Worker Boundary"));
|
||||
assert!(prompt.contains("Act as the Epiphany modeling/checkpoint specialist"));
|
||||
assert!(prompt.contains("node `kind` is a closed vocabulary"));
|
||||
assert!(!prompt.contains("## Epiphany Persistent Memory"));
|
||||
assert!(!prompt.contains("Heartbeat: every lane"));
|
||||
}
|
||||
|
|
@ -1164,7 +1347,7 @@ mod tests {
|
|||
let purposes = schema["properties"]["repoModelPatch"]["properties"]["purpose"]["oneOf"]
|
||||
.as_array()
|
||||
.expect("typed Modeling purpose alternatives");
|
||||
assert_eq!(purposes.len(), 3);
|
||||
assert_eq!(purposes.len(), 4);
|
||||
assert_eq!(purposes[0]["properties"]["kind"]["const"], "evolution");
|
||||
assert_eq!(
|
||||
purposes[1]["properties"]["kind"]["const"],
|
||||
|
|
@ -1182,10 +1365,23 @@ mod tests {
|
|||
"repoFrontierModelingRequestId"
|
||||
);
|
||||
assert_eq!(purposes[2]["properties"]["kind"]["const"], "repair_claim");
|
||||
assert_eq!(
|
||||
purposes[3]["properties"]["kind"]["const"],
|
||||
"adopt_frontier_plan"
|
||||
);
|
||||
assert_eq!(
|
||||
schema["allOf"][1]["then"]["required"][0],
|
||||
"claimRepairRequestId"
|
||||
);
|
||||
let operations =
|
||||
schema["properties"]["repoModelPatch"]["properties"]["operations"]["items"]["anyOf"]
|
||||
.as_array()
|
||||
.expect("typed Modeling operations");
|
||||
let node_kinds = operations[0]["properties"]["node"]["properties"]["kind"]["enum"]
|
||||
.as_array()
|
||||
.expect("typed RepoModel node kinds");
|
||||
assert!(node_kinds.iter().any(|kind| kind == "runtime_contract"));
|
||||
assert!(!node_kinds.iter().any(|kind| kind == "claim"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -69,6 +69,7 @@ struct Args {
|
|||
tool_adapter_bin: PathBuf,
|
||||
model_provider: String,
|
||||
thread_id: Option<String>,
|
||||
objective: Option<String>,
|
||||
cwd: PathBuf,
|
||||
codex_home: PathBuf,
|
||||
artifact_dir: PathBuf,
|
||||
|
|
@ -96,6 +97,7 @@ impl Args {
|
|||
tool_adapter_bin: PathBuf::from(DEFAULT_TOOL_ADAPTER_BIN),
|
||||
model_provider: "openai-codex".to_string(),
|
||||
thread_id: None,
|
||||
objective: None,
|
||||
cwd: root.clone(),
|
||||
codex_home: env::var_os("CODEX_HOME")
|
||||
.map(PathBuf::from)
|
||||
|
|
@ -136,6 +138,7 @@ impl Args {
|
|||
parsed.model_provider = take_string(&mut args, "--model-provider")?;
|
||||
}
|
||||
"--thread-id" => parsed.thread_id = Some(take_string(&mut args, "--thread-id")?),
|
||||
"--objective" => parsed.objective = Some(take_string(&mut args, "--objective")?),
|
||||
"--proposal-modeling-request-id" => {
|
||||
parsed.proposal_modeling_request_id =
|
||||
Some(take_string(&mut args, "--proposal-modeling-request-id")?);
|
||||
|
|
@ -268,6 +271,15 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
"sessionId": runtime_session.session_id,
|
||||
"eventId": runtime_event.event_id,
|
||||
}));
|
||||
if let Some(objective) = args.objective.as_deref() {
|
||||
let intake = intake_operator_objective(&runtime_store, &thread_id, objective)?;
|
||||
startup_events.push(json!({
|
||||
"type": "operatorObjectiveIntake",
|
||||
"threadId": thread_id,
|
||||
"revision": intake.state.revision,
|
||||
"changed": intake.changed,
|
||||
}));
|
||||
}
|
||||
|
||||
for index in 0..args.max_steps {
|
||||
let status = collect_coordinator_status(&runtime_store, &thread_id)?;
|
||||
|
|
@ -396,6 +408,24 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
steps.push(step);
|
||||
break;
|
||||
}
|
||||
let can_accept = args.auto_review
|
||||
&& reorient_result_auto_acceptable(&result)
|
||||
&& revision.is_some();
|
||||
if can_accept {
|
||||
let accepted = accept_reorient(
|
||||
&runtime_store,
|
||||
&thread_id,
|
||||
revision.and_then(|value| u64::try_from(value).ok()),
|
||||
)?;
|
||||
push_event(
|
||||
&mut step,
|
||||
json!({"type": "reorientAccept", "accepted": status_cli::sanitize_for_operator(accepted)}),
|
||||
);
|
||||
final_status = collect_coordinator_status(&runtime_store, &thread_id)?;
|
||||
append_operator_step_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
continue;
|
||||
}
|
||||
final_action = json!({"action": "reviewReorientResult", "reason": result["note"]});
|
||||
append_operator_step_jsonl(&steps_path, &step)?;
|
||||
steps.push(step);
|
||||
|
|
@ -424,6 +454,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
.ok_or_else(|| anyhow!("unsupported launch action {action}"))?;
|
||||
let launch = launch_role(
|
||||
&runtime_store,
|
||||
&local_verse_store,
|
||||
&thread_id,
|
||||
role_id,
|
||||
revision,
|
||||
|
|
@ -488,6 +519,7 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
"launchReorientWorker" => {
|
||||
let launch = launch_reorient(
|
||||
&runtime_store,
|
||||
&local_verse_store,
|
||||
&thread_id,
|
||||
revision,
|
||||
args.max_runtime_seconds,
|
||||
|
|
@ -662,6 +694,21 @@ fn run_coordinator(args: &Args) -> Result<Value> {
|
|||
Ok(summary)
|
||||
}
|
||||
|
||||
fn intake_operator_objective(
|
||||
runtime_store: &Path,
|
||||
thread_id: &str,
|
||||
objective: &str,
|
||||
) -> Result<epiphany_core::UserObjectiveIntakeApplied> {
|
||||
let service = epiphany_core::EpiphanyCoordinatorService::new(runtime_store);
|
||||
service.intake_user_objective(epiphany_core::UserObjectiveIntakeInput {
|
||||
thread_id: thread_id.to_string(),
|
||||
objective: objective.to_string(),
|
||||
source_actor: "operator".to_string(),
|
||||
source_ref: "cli://epiphany-mvp-coordinator".to_string(),
|
||||
submitted_at: now(),
|
||||
})
|
||||
}
|
||||
|
||||
fn assert_local_verse_brake_released(local_verse_store: &Path, runner_name: &str) -> Result<()> {
|
||||
if !local_verse_store.exists() {
|
||||
return Ok(());
|
||||
|
|
@ -850,6 +897,7 @@ fn hands_record_pass_command(runtime_store: &Path, artifact_dir: &Path) -> Value
|
|||
|
||||
fn launch_role(
|
||||
runtime_store: &Path,
|
||||
local_verse_store: &Path,
|
||||
thread_id: &str,
|
||||
role_id: &str,
|
||||
expected_revision: Option<i64>,
|
||||
|
|
@ -864,6 +912,7 @@ fn launch_role(
|
|||
let expected_revision = expected_revision.and_then(|value| u64::try_from(value).ok());
|
||||
let mut context = epiphany_core::render_launch_dynamic_prompt_context(
|
||||
runtime_store,
|
||||
local_verse_store,
|
||||
&state,
|
||||
epiphany_core::role_launch_context_focus(&state, epiphany_core::epiphany_role_label(role)),
|
||||
)
|
||||
|
|
@ -943,6 +992,55 @@ fn accept_role(
|
|||
}))
|
||||
}
|
||||
|
||||
fn accept_reorient(
|
||||
runtime_store: &Path,
|
||||
thread_id: &str,
|
||||
expected_revision: Option<u64>,
|
||||
) -> Result<Value> {
|
||||
let service = epiphany_core::EpiphanyCoordinatorService::new(runtime_store);
|
||||
let state = service
|
||||
.state()?
|
||||
.ok_or_else(|| anyhow!("cannot accept reorientation without native coordinator state"))?;
|
||||
let snapshot = service.reorient_result(epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID)?;
|
||||
if let Some(result_id) = snapshot
|
||||
.finding
|
||||
.as_ref()
|
||||
.and_then(|finding| finding.runtime_result_id.as_deref())
|
||||
&& let Some(existing) = state.acceptance_receipts.iter().find(|receipt| {
|
||||
receipt.result_id == result_id
|
||||
&& receipt.binding_id == epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID
|
||||
&& receipt.surface == "reorientAccept"
|
||||
&& receipt.status == "accepted"
|
||||
})
|
||||
{
|
||||
return Ok(json!({
|
||||
"revision": state.revision,
|
||||
"state": state,
|
||||
"acceptedReceiptId": existing.id,
|
||||
"changed": false,
|
||||
}));
|
||||
}
|
||||
let accepted = service.accept_reorient(
|
||||
thread_id,
|
||||
&state,
|
||||
epiphany_core::EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
|
||||
expected_revision,
|
||||
None,
|
||||
now(),
|
||||
&Uuid::new_v4().to_string(),
|
||||
true,
|
||||
true,
|
||||
)?;
|
||||
Ok(json!({
|
||||
"revision": accepted.state.revision,
|
||||
"state": accepted.state,
|
||||
"acceptedReceiptId": accepted.update.accepted_receipt_id,
|
||||
"acceptedObservationId": accepted.update.accepted_observation_id,
|
||||
"acceptedEvidenceId": accepted.update.accepted_evidence_id,
|
||||
"finding": accepted.finding,
|
||||
}))
|
||||
}
|
||||
|
||||
fn parse_role_id(role_id: &str) -> Result<epiphany_core::EpiphanyRoleResultRoleId> {
|
||||
match role_id {
|
||||
"imagination" => Ok(epiphany_core::EpiphanyRoleResultRoleId::Imagination),
|
||||
|
|
@ -999,11 +1097,30 @@ fn role_result_auto_acceptable(role_id: &str, result: &Value) -> bool {
|
|||
}
|
||||
match role_id {
|
||||
"verification" => true,
|
||||
"research" | "modeling" | "imagination" => finding.get("statePatch").is_some(),
|
||||
"research" | "modeling" | "imagination" => finding["statePatch"].is_object(),
|
||||
_ => false,
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_result_auto_acceptable(result: &Value) -> bool {
|
||||
if result["status"].as_str() != Some("completed") {
|
||||
return false;
|
||||
}
|
||||
let finding = &result["finding"];
|
||||
finding["runtimeResultId"]
|
||||
.as_str()
|
||||
.is_some_and(|id| !id.trim().is_empty())
|
||||
&& finding["runtimeJobId"]
|
||||
.as_str()
|
||||
.is_some_and(|id| !id.trim().is_empty())
|
||||
&& finding["summary"]
|
||||
.as_str()
|
||||
.is_some_and(|summary| !summary.trim().is_empty())
|
||||
&& finding["checkpointStillValid"].is_boolean()
|
||||
&& !finding["jobError"].is_string()
|
||||
&& !finding["itemError"].is_string()
|
||||
}
|
||||
|
||||
fn role_result_needs_supersession(role_id: &str, result: &Value) -> bool {
|
||||
match result["status"].as_str() {
|
||||
Some("failed") => true,
|
||||
|
|
@ -1029,6 +1146,35 @@ fn supersede_role_result(
|
|||
.unwrap_or_else(|| default_binding_id_for_role(role_id));
|
||||
let summary = first_string_at(result, &[&["finding", "summary"], &["note"]])
|
||||
.unwrap_or_else(|| "Role result reviewed and superseded.".to_string());
|
||||
let service = epiphany_core::EpiphanyCoordinatorService::new(runtime_store);
|
||||
if let Some(state) = service.state()?
|
||||
&& let Some(existing) = state
|
||||
.acceptance_receipts
|
||||
.iter()
|
||||
.find(|receipt| receipt.result_id == result_id)
|
||||
{
|
||||
if existing.job_id == job_id
|
||||
&& existing.binding_id == binding_id
|
||||
&& existing.surface == "roleFailureReview"
|
||||
&& existing.role_id == role_id
|
||||
&& existing.status == "superseded"
|
||||
{
|
||||
return Ok(json!({
|
||||
"revision": state.revision,
|
||||
"changedFields": [],
|
||||
"state": state,
|
||||
"receipt": existing,
|
||||
"changed": false,
|
||||
}));
|
||||
}
|
||||
return Err(anyhow!(
|
||||
"runtime result already has conflicting acceptance authority: surface={:?} role={:?} status={:?} binding={:?}",
|
||||
existing.surface,
|
||||
existing.role_id,
|
||||
existing.status,
|
||||
existing.binding_id
|
||||
));
|
||||
}
|
||||
let receipt = epiphany_state_model::EpiphanyAcceptanceReceipt {
|
||||
id: format!("role-failure-review-{}", Uuid::new_v4()),
|
||||
result_id,
|
||||
|
|
@ -1042,7 +1188,6 @@ fn supersede_role_result(
|
|||
accepted_evidence_id: None,
|
||||
summary: Some(summary),
|
||||
};
|
||||
let service = epiphany_core::EpiphanyCoordinatorService::new(runtime_store);
|
||||
let applied = service.apply_state_update(
|
||||
thread_id,
|
||||
epiphany_core::EpiphanyStateUpdate {
|
||||
|
|
@ -1072,6 +1217,7 @@ fn default_binding_id_for_role(role_id: &str) -> String {
|
|||
|
||||
fn launch_reorient(
|
||||
runtime_store: &Path,
|
||||
local_verse_store: &Path,
|
||||
thread_id: &str,
|
||||
expected_revision: Option<i64>,
|
||||
max_runtime_seconds: u64,
|
||||
|
|
@ -1090,6 +1236,7 @@ fn launch_reorient(
|
|||
.context("native reorientation status did not contain a typed decision")?;
|
||||
let context = epiphany_core::render_launch_dynamic_prompt_context(
|
||||
runtime_store,
|
||||
local_verse_store,
|
||||
&state,
|
||||
epiphany_core::reorient_launch_context_focus(&state, &decision.next_action),
|
||||
)
|
||||
|
|
@ -1507,6 +1654,25 @@ mod tests {
|
|||
assert!(!is_stop_action("continueImplementation"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn operator_objective_intake_creates_once_and_refuses_replacement() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("runtime.cc");
|
||||
|
||||
let first = intake_operator_objective(&store, "thread-1", "Map the machine")?;
|
||||
assert!(first.changed);
|
||||
assert_eq!(first.state.revision, 1);
|
||||
|
||||
let repeated = intake_operator_objective(&store, "thread-1", " Map the machine ")?;
|
||||
assert!(!repeated.changed);
|
||||
assert_eq!(repeated.state.revision, first.state.revision);
|
||||
|
||||
let error = intake_operator_objective(&store, "thread-1", "Replace the machine")
|
||||
.expect_err("objective replacement must require a typed adoption flow");
|
||||
assert!(error.to_string().contains("refusing to replace"));
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn auto_review_accepts_receipt_only_verification_findings() {
|
||||
let result = json!({
|
||||
|
|
@ -1569,8 +1735,18 @@ mod tests {
|
|||
"statePatch": {"scratch": {"summary": "mapped"}}
|
||||
}
|
||||
});
|
||||
let null_patch = json!({
|
||||
"status": "completed",
|
||||
"finding": {
|
||||
"summary": "Explicit null is still no state patch.",
|
||||
"runtimeResultId": "result-modeling-null",
|
||||
"runtimeJobId": "job-modeling-null",
|
||||
"statePatch": null
|
||||
}
|
||||
});
|
||||
|
||||
assert!(role_result_needs_supersession("modeling", &unreviewable));
|
||||
assert!(role_result_needs_supersession("modeling", &null_patch));
|
||||
assert!(!role_result_needs_supersession("modeling", &reviewable));
|
||||
assert!(!role_result_needs_supersession(
|
||||
"verification",
|
||||
|
|
|
|||
|
|
@ -36,13 +36,11 @@ use epiphany_core::derive_planning_view;
|
|||
use epiphany_core::derive_pressure_view;
|
||||
use epiphany_core::derive_role_board;
|
||||
use epiphany_core::derive_scene;
|
||||
use epiphany_core::interpret_runtime_role_worker_result;
|
||||
use epiphany_core::read_accepted_coordinator_state;
|
||||
use epiphany_core::recommend_crrc_action;
|
||||
use epiphany_core::recommend_reorientation;
|
||||
use epiphany_core::runtime_has_actionable_hands_frontier;
|
||||
use epiphany_core::runtime_job_snapshot;
|
||||
use epiphany_core::runtime_role_worker_result;
|
||||
use epiphany_state_model::EpiphanyThreadState;
|
||||
use serde_json::Value;
|
||||
use serde_json::json;
|
||||
|
|
@ -318,6 +316,13 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
};
|
||||
let result_status =
|
||||
native_reorient_result_status(state_ref, &runtime_store_path, REORIENT_BINDING_ID);
|
||||
let reorient_finding =
|
||||
native_reorient_finding(state_ref, &runtime_store_path, REORIENT_BINDING_ID);
|
||||
let reorient_finding_accepted = state_ref.is_some_and(|state| {
|
||||
reorient_finding
|
||||
.as_ref()
|
||||
.is_some_and(|finding| epiphany_core::reorient_finding_already_accepted(state, finding))
|
||||
});
|
||||
let modeling_result_status =
|
||||
native_role_result_status(state_ref, &runtime_store_path, MODELING_BINDING_ID);
|
||||
let research_result_status =
|
||||
|
|
@ -333,8 +338,8 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
checkpoint_present: state_ref
|
||||
.and_then(|state| state.investigation_checkpoint.as_ref())
|
||||
.is_some(),
|
||||
finding_present: false,
|
||||
finding_accepted: false,
|
||||
finding_present: reorient_finding.is_some(),
|
||||
finding_accepted: reorient_finding_accepted,
|
||||
});
|
||||
let role_jobs = jobs
|
||||
.iter()
|
||||
|
|
@ -407,7 +412,7 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
research_finding.as_ref(),
|
||||
modeling_finding.as_ref(),
|
||||
verification_finding.as_ref(),
|
||||
None,
|
||||
reorient_finding.as_ref(),
|
||||
);
|
||||
let hands_frontier_ready = runtime_has_actionable_hands_frontier(&runtime_store_path)
|
||||
.context("failed to derive actionable Hands frontier from runtime-spine state")?;
|
||||
|
|
@ -426,6 +431,7 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
reorient_result_status: result_status,
|
||||
research_result_accepted: finding_signals.research_result_accepted,
|
||||
research_result_reviewable: finding_signals.research_result_reviewable,
|
||||
research_result_failure_reviewed: finding_signals.research_result_failure_reviewed,
|
||||
modeling_result_requests_regather: finding_signals.modeling_result_requests_regather,
|
||||
modeling_result_accepted: finding_signals.modeling_result_accepted,
|
||||
modeling_result_reviewable: finding_signals.modeling_result_reviewable,
|
||||
|
|
@ -512,10 +518,20 @@ fn run_native_status(args: &Args) -> Result<Value> {
|
|||
},
|
||||
"planning": planning,
|
||||
"roleResults": {
|
||||
"imagination": native_role_result(state_ref, &runtime_store_path, IMAGINATION_BINDING_ID),
|
||||
"research": native_role_result(state_ref, &runtime_store_path, RESEARCH_BINDING_ID),
|
||||
"modeling": native_role_result(state_ref, &runtime_store_path, MODELING_BINDING_ID),
|
||||
"verification": native_role_result(state_ref, &runtime_store_path, VERIFICATION_BINDING_ID),
|
||||
"imagination": native_role_result(state_ref, &runtime_store_path, IMAGINATION_BINDING_ID, EpiphanyRoleResultRoleId::Imagination),
|
||||
"research": native_role_result(state_ref, &runtime_store_path, RESEARCH_BINDING_ID, EpiphanyRoleResultRoleId::Research),
|
||||
"modeling": native_role_result(state_ref, &runtime_store_path, MODELING_BINDING_ID, EpiphanyRoleResultRoleId::Modeling),
|
||||
"verification": native_role_result(state_ref, &runtime_store_path, VERIFICATION_BINDING_ID, EpiphanyRoleResultRoleId::Verification),
|
||||
},
|
||||
"findingSignals": {
|
||||
"researchResultAccepted": finding_signals.research_result_accepted,
|
||||
"researchResultReviewable": finding_signals.research_result_reviewable,
|
||||
"researchResultFailureReviewed": finding_signals.research_result_failure_reviewed,
|
||||
"modelingResultAccepted": finding_signals.modeling_result_accepted,
|
||||
"modelingResultReviewable": finding_signals.modeling_result_reviewable,
|
||||
"modelingResultFailureReviewed": finding_signals.modeling_result_failure_reviewed,
|
||||
"verificationResultAccepted": finding_signals.verification_result_accepted,
|
||||
"verificationResultFailureReviewed": finding_signals.verification_result_failure_reviewed,
|
||||
},
|
||||
"reorientResult": native_reorient_result(state_ref, &runtime_store_path, REORIENT_BINDING_ID),
|
||||
"crrc": {
|
||||
|
|
@ -731,6 +747,7 @@ fn native_role_result(
|
|||
state: Option<&EpiphanyThreadState>,
|
||||
runtime_store: &Path,
|
||||
binding_id: &str,
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
) -> Value {
|
||||
let Some(job_id) = latest_runtime_job_id_for_binding(state, binding_id) else {
|
||||
return json!({
|
||||
|
|
@ -740,50 +757,18 @@ fn native_role_result(
|
|||
"note": "No runtime-spine job is linked to this native role binding.",
|
||||
});
|
||||
};
|
||||
match runtime_job_snapshot(runtime_store, job_id) {
|
||||
Ok(Some(snapshot)) => {
|
||||
let status = map_runtime_role_result_status(&snapshot);
|
||||
let mut result = json!({
|
||||
"source": "native",
|
||||
"status": status,
|
||||
"bindingId": binding_id,
|
||||
"runtimeJobId": job_id,
|
||||
"note": native_role_result_note(status, &snapshot),
|
||||
});
|
||||
if matches!(
|
||||
status,
|
||||
EpiphanyCoordinatorRoleResultStatus::Failed
|
||||
| EpiphanyCoordinatorRoleResultStatus::Cancelled
|
||||
) && let Some(receipt) = snapshot.result
|
||||
{
|
||||
result["finding"] = json!({
|
||||
"verdict": receipt.verdict,
|
||||
"summary": receipt.summary,
|
||||
"nextSafeMove": empty_string_as_null(&receipt.next_safe_move),
|
||||
"runtimeResultId": receipt.result_id,
|
||||
"runtimeJobId": receipt.job_id,
|
||||
"evidenceIds": receipt.evidence_refs,
|
||||
"artifactRefs": receipt.artifact_refs,
|
||||
"jobError": receipt.summary,
|
||||
});
|
||||
}
|
||||
result
|
||||
}
|
||||
Ok(None) => json!({
|
||||
"source": "native",
|
||||
"status": "backendMissing",
|
||||
"bindingId": binding_id,
|
||||
"runtimeJobId": job_id,
|
||||
"note": "The linked runtime-spine job is missing.",
|
||||
}),
|
||||
Err(error) => json!({
|
||||
"source": "native",
|
||||
"status": "backendUnavailable",
|
||||
"bindingId": binding_id,
|
||||
"runtimeJobId": job_id,
|
||||
"note": format!("Failed to read linked runtime-spine job: {error}"),
|
||||
}),
|
||||
let snapshot = epiphany_core::read_runtime_role_result(Some(runtime_store), job_id, role_id);
|
||||
let mut result = json!({
|
||||
"source": "native",
|
||||
"status": snapshot.status,
|
||||
"bindingId": binding_id,
|
||||
"runtimeJobId": job_id,
|
||||
"note": snapshot.note,
|
||||
});
|
||||
if let Some(finding) = snapshot.finding {
|
||||
result["finding"] = json!(finding);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn native_reorient_result(
|
||||
|
|
@ -799,48 +784,18 @@ fn native_reorient_result(
|
|||
"note": "No runtime-spine job is linked to this native reorientation binding.",
|
||||
});
|
||||
};
|
||||
match runtime_job_snapshot(runtime_store, job_id) {
|
||||
Ok(Some(snapshot)) => {
|
||||
let status = map_runtime_reorient_result_status(&snapshot);
|
||||
let mut result = json!({
|
||||
"source": "native",
|
||||
"status": status,
|
||||
"bindingId": binding_id,
|
||||
"runtimeJobId": job_id,
|
||||
"note": native_reorient_result_note(status, &snapshot),
|
||||
});
|
||||
if matches!(
|
||||
status,
|
||||
EpiphanyCrrcResultStatus::Failed | EpiphanyCrrcResultStatus::Cancelled
|
||||
) && let Some(receipt) = snapshot.result
|
||||
{
|
||||
result["finding"] = json!({
|
||||
"summary": receipt.summary,
|
||||
"nextSafeMove": empty_string_as_null(&receipt.next_safe_move),
|
||||
"runtimeResultId": receipt.result_id,
|
||||
"runtimeJobId": receipt.job_id,
|
||||
"evidenceIds": receipt.evidence_refs,
|
||||
"artifactRefs": receipt.artifact_refs,
|
||||
"jobError": receipt.summary,
|
||||
});
|
||||
}
|
||||
result
|
||||
}
|
||||
Ok(None) => json!({
|
||||
"source": "native",
|
||||
"status": "backendMissing",
|
||||
"bindingId": binding_id,
|
||||
"runtimeJobId": job_id,
|
||||
"note": "The linked runtime-spine job is missing.",
|
||||
}),
|
||||
Err(error) => json!({
|
||||
"source": "native",
|
||||
"status": "backendUnavailable",
|
||||
"bindingId": binding_id,
|
||||
"runtimeJobId": job_id,
|
||||
"note": format!("Failed to read linked runtime-spine job: {error}"),
|
||||
}),
|
||||
let snapshot = epiphany_core::read_runtime_reorient_result(Some(runtime_store), job_id);
|
||||
let mut result = json!({
|
||||
"source": "native",
|
||||
"status": snapshot.status,
|
||||
"bindingId": binding_id,
|
||||
"runtimeJobId": job_id,
|
||||
"note": snapshot.note,
|
||||
});
|
||||
if let Some(finding) = snapshot.finding {
|
||||
result["finding"] = json!(finding);
|
||||
}
|
||||
result
|
||||
}
|
||||
|
||||
fn native_role_result_status(
|
||||
|
|
@ -865,10 +820,16 @@ fn native_role_finding(
|
|||
role_id: EpiphanyRoleResultRoleId,
|
||||
) -> Option<EpiphanyRoleFindingInterpretation> {
|
||||
let job_id = latest_runtime_job_id_for_binding(state, binding_id)?;
|
||||
runtime_role_worker_result(runtime_store, job_id)
|
||||
.ok()
|
||||
.flatten()
|
||||
.map(|result| interpret_runtime_role_worker_result(role_id, &result))
|
||||
epiphany_core::read_runtime_role_result(Some(runtime_store), job_id, role_id).finding
|
||||
}
|
||||
|
||||
fn native_reorient_finding(
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
runtime_store: &Path,
|
||||
binding_id: &str,
|
||||
) -> Option<epiphany_core::EpiphanyReorientFindingInterpretation> {
|
||||
let job_id = latest_runtime_job_id_for_binding(state, binding_id)?;
|
||||
epiphany_core::read_runtime_reorient_result(Some(runtime_store), job_id).finding
|
||||
}
|
||||
|
||||
fn native_reorient_result_status(
|
||||
|
|
@ -998,84 +959,6 @@ fn map_runtime_job_status(status: EpiphanyRuntimeJobStatus) -> EpiphanyJobStatus
|
|||
}
|
||||
}
|
||||
|
||||
fn native_role_result_note(
|
||||
status: EpiphanyCoordinatorRoleResultStatus,
|
||||
snapshot: &EpiphanyRuntimeJobSnapshot,
|
||||
) -> String {
|
||||
match status {
|
||||
EpiphanyCoordinatorRoleResultStatus::Failed => {
|
||||
format!("Role runtime job failed: {}", snapshot.job.summary)
|
||||
}
|
||||
EpiphanyCoordinatorRoleResultStatus::Cancelled => {
|
||||
format!("Role runtime job was cancelled: {}", snapshot.job.summary)
|
||||
}
|
||||
EpiphanyCoordinatorRoleResultStatus::Completed => {
|
||||
"Role runtime job has a terminal lifecycle receipt; use typed worker results for reviewable findings.".to_string()
|
||||
}
|
||||
EpiphanyCoordinatorRoleResultStatus::Running => {
|
||||
"Role runtime job is still running.".to_string()
|
||||
}
|
||||
EpiphanyCoordinatorRoleResultStatus::Pending => {
|
||||
"Role runtime job has not produced a terminal receipt yet.".to_string()
|
||||
}
|
||||
EpiphanyCoordinatorRoleResultStatus::BackendUnavailable => {
|
||||
"The bound runtime backend is unavailable.".to_string()
|
||||
}
|
||||
EpiphanyCoordinatorRoleResultStatus::BackendMissing => {
|
||||
"The bound runtime backend job or item is missing.".to_string()
|
||||
}
|
||||
EpiphanyCoordinatorRoleResultStatus::MissingState => {
|
||||
"No authoritative Epiphany state exists for this thread.".to_string()
|
||||
}
|
||||
EpiphanyCoordinatorRoleResultStatus::MissingBinding => {
|
||||
"No matching Epiphany role specialist binding exists.".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn native_reorient_result_note(
|
||||
status: EpiphanyCrrcResultStatus,
|
||||
snapshot: &EpiphanyRuntimeJobSnapshot,
|
||||
) -> String {
|
||||
match status {
|
||||
EpiphanyCrrcResultStatus::Failed => {
|
||||
format!("Reorientation runtime job failed: {}", snapshot.job.summary)
|
||||
}
|
||||
EpiphanyCrrcResultStatus::Cancelled => {
|
||||
format!("Reorientation runtime job was cancelled: {}", snapshot.job.summary)
|
||||
}
|
||||
EpiphanyCrrcResultStatus::Completed => {
|
||||
"Reorientation runtime job has a terminal lifecycle receipt; use typed worker results for reviewable findings.".to_string()
|
||||
}
|
||||
EpiphanyCrrcResultStatus::Running => {
|
||||
"Reorientation runtime job is still running.".to_string()
|
||||
}
|
||||
EpiphanyCrrcResultStatus::Pending => {
|
||||
"Reorientation runtime job has not produced a terminal receipt yet.".to_string()
|
||||
}
|
||||
EpiphanyCrrcResultStatus::BackendUnavailable => {
|
||||
"The bound runtime backend is unavailable.".to_string()
|
||||
}
|
||||
EpiphanyCrrcResultStatus::BackendMissing => {
|
||||
"The bound runtime backend job or item is missing.".to_string()
|
||||
}
|
||||
EpiphanyCrrcResultStatus::MissingState => {
|
||||
"No authoritative Epiphany state exists for this thread.".to_string()
|
||||
}
|
||||
EpiphanyCrrcResultStatus::MissingBinding => {
|
||||
"No matching Epiphany reorientation binding exists.".to_string()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn empty_string_as_null(value: &str) -> Value {
|
||||
if value.trim().is_empty() {
|
||||
Value::Null
|
||||
} else {
|
||||
json!(value)
|
||||
}
|
||||
}
|
||||
|
||||
fn native_tool_invocation_surface(runtime_store: &Path) -> Result<Value> {
|
||||
let spine_status = epiphany_core::runtime_spine_status(runtime_store)?;
|
||||
let invocations = epiphany_core::runtime_tool_invocation_statuses(runtime_store)?;
|
||||
|
|
|
|||
|
|
@ -68,11 +68,11 @@ pub fn reorient_launch_context_focus(state: &EpiphanyThreadState, next_action: &
|
|||
|
||||
pub fn render_launch_dynamic_prompt_context(
|
||||
runtime_store_path: &Path,
|
||||
local_verse_store: &Path,
|
||||
state: &EpiphanyThreadState,
|
||||
focus: String,
|
||||
) -> Result<String, String> {
|
||||
let local_verse_store = local_verse_store_path(runtime_store_path);
|
||||
load_epiphany_cultmesh_status(&local_verse_store, EPIPHANY_LOCAL_VERSE_RUNTIME_ID)
|
||||
load_epiphany_cultmesh_status(local_verse_store, EPIPHANY_LOCAL_VERSE_RUNTIME_ID)
|
||||
.map_err(|error| {
|
||||
format!(
|
||||
"failed to inspect local Verse context store {}: {error}",
|
||||
|
|
@ -85,16 +85,14 @@ pub fn render_launch_dynamic_prompt_context(
|
|||
local_verse_store.display()
|
||||
)
|
||||
})?;
|
||||
let topology = load_epiphany_cultmesh_cluster_topology(
|
||||
&local_verse_store,
|
||||
EPIPHANY_LOCAL_VERSE_RUNTIME_ID,
|
||||
)
|
||||
.map_err(|error| {
|
||||
format!(
|
||||
"failed to inspect local Verse topology store {}: {error}",
|
||||
local_verse_store.display()
|
||||
)
|
||||
})?;
|
||||
let topology =
|
||||
load_epiphany_cultmesh_cluster_topology(local_verse_store, EPIPHANY_LOCAL_VERSE_RUNTIME_ID)
|
||||
.map_err(|error| {
|
||||
format!(
|
||||
"failed to inspect local Verse topology store {}: {error}",
|
||||
local_verse_store.display()
|
||||
)
|
||||
})?;
|
||||
if topology.is_empty() {
|
||||
return Err(format!(
|
||||
"local Verse has no persisted cluster topology at {}; initialize it before building worker launch context",
|
||||
|
|
@ -102,7 +100,7 @@ pub fn render_launch_dynamic_prompt_context(
|
|||
));
|
||||
}
|
||||
let local_verse =
|
||||
query_epiphany_local_verse_context(&local_verse_store, EPIPHANY_LOCAL_VERSE_RUNTIME_ID)
|
||||
query_epiphany_local_verse_context(local_verse_store, EPIPHANY_LOCAL_VERSE_RUNTIME_ID)
|
||||
.map_err(|error| {
|
||||
format!(
|
||||
"failed to query local Verse context store {}: {error}",
|
||||
|
|
@ -1151,6 +1149,7 @@ mod tests {
|
|||
|
||||
let rendered = render_launch_dynamic_prompt_context(
|
||||
&runtime_store,
|
||||
&local_verse_store_path(&runtime_store),
|
||||
&state,
|
||||
role_launch_context_focus(&state, "modeling"),
|
||||
)
|
||||
|
|
@ -1235,6 +1234,7 @@ mod tests {
|
|||
|
||||
let error = render_launch_dynamic_prompt_context(
|
||||
&runtime_store,
|
||||
&local_verse_store,
|
||||
&state,
|
||||
role_launch_context_focus(&state, "modeling"),
|
||||
)
|
||||
|
|
|
|||
179
epiphany-core/src/coordinator_objective_intake.rs
Normal file
179
epiphany-core/src/coordinator_objective_intake.rs
Normal file
|
|
@ -0,0 +1,179 @@
|
|||
use crate::coordinator_state_transaction::{
|
||||
commit_coordinator_state_transaction, open_coordinator_state_transaction,
|
||||
};
|
||||
use crate::{
|
||||
EpiphanyCoordinatorStateApplied, EpiphanyStateUpdate, EpiphanyStateUpdatedField,
|
||||
apply_coordinator_state_update_to_state, coordinator_acceptance_cache, read_coordinator_state,
|
||||
};
|
||||
use anyhow::{Result, anyhow};
|
||||
use cultcache_rs::DatabaseEntry;
|
||||
use epiphany_state_model::EpiphanyThreadState;
|
||||
use sha2::{Digest, Sha256};
|
||||
use std::path::Path;
|
||||
|
||||
pub const USER_OBJECTIVE_INTAKE_SCHEMA_VERSION: &str = "gamecult.epiphany.user_objective_intake.v0";
|
||||
pub const USER_OBJECTIVE_INTAKE_TYPE: &str = "epiphany.coordinator.user_objective_intake";
|
||||
pub const USER_OBJECTIVE_INTAKE_CONTRACT: &str = "The human supplies the initial objective. Self records that assertion and the first canonical thread state in one CAS. Repeated identical intake is read-idempotent; replacement requires a separate reviewed adoption flow.";
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct UserObjectiveIntakeInput {
|
||||
pub thread_id: String,
|
||||
pub objective: String,
|
||||
pub source_actor: String,
|
||||
pub source_ref: String,
|
||||
pub submitted_at: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq, DatabaseEntry)]
|
||||
#[cultcache(
|
||||
type = "epiphany.coordinator.user_objective_intake",
|
||||
schema = "UserObjectiveIntake"
|
||||
)]
|
||||
pub struct UserObjectiveIntake {
|
||||
#[cultcache(key = 0)]
|
||||
pub schema_version: String,
|
||||
#[cultcache(key = 1)]
|
||||
pub intake_id: String,
|
||||
#[cultcache(key = 2)]
|
||||
pub thread_id: String,
|
||||
#[cultcache(key = 3)]
|
||||
pub objective: String,
|
||||
#[cultcache(key = 4)]
|
||||
pub objective_sha256: String,
|
||||
#[cultcache(key = 5)]
|
||||
pub source_actor: String,
|
||||
#[cultcache(key = 6)]
|
||||
pub source_ref: String,
|
||||
#[cultcache(key = 7)]
|
||||
pub submitted_at: String,
|
||||
#[cultcache(key = 8)]
|
||||
pub contract: String,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct UserObjectiveIntakeApplied {
|
||||
pub intake: UserObjectiveIntake,
|
||||
pub state: EpiphanyCoordinatorStateApplied,
|
||||
pub changed: bool,
|
||||
}
|
||||
|
||||
pub fn intake_user_objective(
|
||||
store: &Path,
|
||||
input: UserObjectiveIntakeInput,
|
||||
) -> Result<UserObjectiveIntakeApplied> {
|
||||
let thread_id = input.thread_id.trim();
|
||||
let objective = input.objective.trim();
|
||||
let source_actor = input.source_actor.trim();
|
||||
let source_ref = input.source_ref.trim();
|
||||
if thread_id.is_empty()
|
||||
|| objective.is_empty()
|
||||
|| source_actor.is_empty()
|
||||
|| source_ref.is_empty()
|
||||
|| chrono::DateTime::parse_from_rfc3339(input.submitted_at.trim()).is_err()
|
||||
{
|
||||
return Err(anyhow!("invalid typed user-objective intake"));
|
||||
}
|
||||
let objective_sha256 = format!("{:x}", Sha256::digest(objective.as_bytes()));
|
||||
let intake_id = format!("user-objective-{:x}", Sha256::digest(thread_id.as_bytes()));
|
||||
|
||||
if let Some(state) = read_coordinator_state(store)? {
|
||||
let cache = coordinator_acceptance_cache(store)?;
|
||||
let existing = cache
|
||||
.get::<UserObjectiveIntake>(&intake_id)?
|
||||
.ok_or_else(|| anyhow!("authoritative state has no typed user-objective intake"))?;
|
||||
if existing.thread_id != thread_id
|
||||
|| existing.objective != objective
|
||||
|| existing.objective_sha256 != objective_sha256
|
||||
|| existing.source_actor != source_actor
|
||||
|| existing.source_ref != source_ref
|
||||
|| state.objective.as_deref().map(str::trim) != Some(objective)
|
||||
{
|
||||
return Err(anyhow!(
|
||||
"refusing to replace the authoritative coordinator objective; use a typed objective-adoption flow"
|
||||
));
|
||||
}
|
||||
return Ok(UserObjectiveIntakeApplied {
|
||||
intake: existing,
|
||||
state: EpiphanyCoordinatorStateApplied {
|
||||
revision: state.revision,
|
||||
changed_fields: Vec::new(),
|
||||
state,
|
||||
},
|
||||
changed: false,
|
||||
});
|
||||
}
|
||||
|
||||
let current = EpiphanyThreadState::default();
|
||||
let update = EpiphanyStateUpdate {
|
||||
expected_revision: Some(0),
|
||||
objective: Some(objective.to_string()),
|
||||
..Default::default()
|
||||
};
|
||||
let next = apply_coordinator_state_update_to_state(¤t, update, None)?;
|
||||
let intake = UserObjectiveIntake {
|
||||
schema_version: USER_OBJECTIVE_INTAKE_SCHEMA_VERSION.into(),
|
||||
intake_id: intake_id.clone(),
|
||||
thread_id: thread_id.to_string(),
|
||||
objective: objective.to_string(),
|
||||
objective_sha256,
|
||||
source_actor: source_actor.to_string(),
|
||||
source_ref: source_ref.to_string(),
|
||||
submitted_at: input.submitted_at,
|
||||
contract: USER_OBJECTIVE_INTAKE_CONTRACT.into(),
|
||||
};
|
||||
let mut transaction = open_coordinator_state_transaction(store, ¤t)?;
|
||||
let envelope = transaction.prepare_entry(&intake_id, &intake)?.0;
|
||||
commit_coordinator_state_transaction(
|
||||
&mut transaction,
|
||||
thread_id,
|
||||
&next,
|
||||
vec![envelope],
|
||||
Vec::new(),
|
||||
)?;
|
||||
Ok(UserObjectiveIntakeApplied {
|
||||
intake,
|
||||
state: EpiphanyCoordinatorStateApplied {
|
||||
revision: next.revision,
|
||||
changed_fields: vec![EpiphanyStateUpdatedField::Objective],
|
||||
state: next,
|
||||
},
|
||||
changed: true,
|
||||
})
|
||||
}
|
||||
|
||||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
|
||||
fn input(objective: &str) -> UserObjectiveIntakeInput {
|
||||
UserObjectiveIntakeInput {
|
||||
thread_id: "thread-1".into(),
|
||||
objective: objective.into(),
|
||||
source_actor: "operator".into(),
|
||||
source_ref: "cli://epiphany-mvp-coordinator".into(),
|
||||
submitted_at: "2026-07-16T14:00:00Z".into(),
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn intake_is_atomic_idempotent_and_seed_only() -> Result<()> {
|
||||
let temp = tempfile::tempdir()?;
|
||||
let store = temp.path().join("runtime.cc");
|
||||
let first = intake_user_objective(&store, input("Map the machine"))?;
|
||||
assert!(first.changed);
|
||||
assert_eq!(first.state.revision, 1);
|
||||
assert_eq!(
|
||||
first.state.state.objective.as_deref(),
|
||||
Some("Map the machine")
|
||||
);
|
||||
|
||||
let repeated = intake_user_objective(&store, input(" Map the machine "))?;
|
||||
assert!(!repeated.changed);
|
||||
assert_eq!(repeated.intake, first.intake);
|
||||
|
||||
let error = intake_user_objective(&store, input("Replace the machine"))
|
||||
.expect_err("objective replacement must be refused");
|
||||
assert!(error.to_string().contains("refusing to replace"));
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
|
@ -46,6 +46,13 @@ impl EpiphanyCoordinatorService {
|
|||
crate::intake_user_repo_frontier_proposal(&self.store, input)
|
||||
}
|
||||
|
||||
pub fn intake_user_objective(
|
||||
&self,
|
||||
input: crate::UserObjectiveIntakeInput,
|
||||
) -> Result<crate::UserObjectiveIntakeApplied> {
|
||||
crate::intake_user_objective(&self.store, input)
|
||||
}
|
||||
|
||||
pub fn select_repo_frontier_proposal_for_modeling(
|
||||
&self,
|
||||
proposal_id: &str,
|
||||
|
|
|
|||
|
|
@ -6,6 +6,7 @@ mod coordinator_acceptance;
|
|||
mod coordinator_interrupt;
|
||||
mod coordinator_launch;
|
||||
mod coordinator_launch_context;
|
||||
mod coordinator_objective_intake;
|
||||
mod coordinator_results;
|
||||
mod coordinator_service;
|
||||
mod coordinator_state;
|
||||
|
|
@ -188,6 +189,13 @@ pub use coordinator_launch_context::memory_graph_store_path;
|
|||
pub use coordinator_launch_context::render_launch_dynamic_prompt_context;
|
||||
pub use coordinator_launch_context::reorient_launch_context_focus;
|
||||
pub use coordinator_launch_context::role_launch_context_focus;
|
||||
pub use coordinator_objective_intake::USER_OBJECTIVE_INTAKE_CONTRACT;
|
||||
pub use coordinator_objective_intake::USER_OBJECTIVE_INTAKE_SCHEMA_VERSION;
|
||||
pub use coordinator_objective_intake::USER_OBJECTIVE_INTAKE_TYPE;
|
||||
pub use coordinator_objective_intake::UserObjectiveIntake;
|
||||
pub use coordinator_objective_intake::UserObjectiveIntakeApplied;
|
||||
pub use coordinator_objective_intake::UserObjectiveIntakeInput;
|
||||
pub use coordinator_objective_intake::intake_user_objective;
|
||||
pub use coordinator_results::EpiphanyCoordinatorReorientResultSnapshot;
|
||||
pub use coordinator_results::EpiphanyCoordinatorRoleResultSnapshot;
|
||||
pub use coordinator_results::read_reorient_result_snapshot;
|
||||
|
|
|
|||
|
|
@ -95,6 +95,9 @@ Inspect source before you trust the model; when the map feels warm but the sourc
|
|||
Name the living seam, the open wound, and the next safe modeling move in plain language.
|
||||
Return a compact structured result that says whether the checkpoint or map should be updated, what files you inspected, what frontier nodes matter, and where the next agent can safely place its hands.
|
||||
`repoModelPatch` is required. Return the typed patch against the canonical repository model revision/hash supplied in context. Use explicit node, edge, and frontier operations; preserve exact source-grounded claim ids and dependency ids. This artifact is only a proposal for later Modeling review/admission: do not claim it has been applied.
|
||||
RepoModel node `kind` is a closed vocabulary: `domain`, `module`, `crate`, `binary`, `schema`, `runtime_contract`, `adapter`, `test_seam`, `state_store`, `role_memory`, `short_term_thought`, `incubation_thread`, `agency_pressure`, `candidate_intervention`, `identity`, `evidence`, `summary`, or `other`. A node's factual statement belongs in its `claim` field; do not invent kind names such as `claim` or `anatomy`. Use `other` only when no specific canonical kind fits. Edge kinds and memory profiles are likewise closed vocabularies supplied by the output schema.
|
||||
Every upserted or revised node must include all canonical identity and judgment fields: `id`, `domain_id`, `profile`, `kind`, `title`, `claim`, `question`, `tension`, and `action_implication`. Every upserted or revised edge must include `id`, `source_id`, `target_id`, `kind`, `profile`, and `claim`. Do not emit shorthand nodes or edges; omitted empty judgment fields are still contract violations. `profile` is exactly one of `repo_architecture`, `repo_dataflow`, `role_self`, `short_term`, `incubation`, `agency_pressure`, `candidate_intervention`, `identity`, or `evidence`; there is no `repo` shorthand. Edge `kind` is exactly one of `owns`, `reads`, `writes`, `derives`, `adapts`, `persists`, `launches`, `verifies`, `supports`, `contradicts`, `distills`, `revises`, `retires`, `grounds`, `triggers`, `spoken_as`, `cools`, `clusters_with`, `resonates_with`, `depends_on`, or `other`.
|
||||
If you emit an `anchor`, it must include its own stable `id`, `kind`, and `target`; a nested `code_ref` must include `path`. Do not use a bare path-shaped object as an anchor. Omitting anchors is safer than inventing malformed provenance.
|
||||
When `<repo_frontier_modeling_request>` is present, echo its exact `modelingRequestId` as `repoFrontierModelingRequestId`, use `purpose.kind=incorporate_frontier_verdict` with its exact `frontierRouteId` and `soulVerdictReceiptId`, and revise only its routed frontier item to its allowed disposition. The typed request is authority; nearby telemetry, timestamps, and prose are not substitutes. When that request is absent, use `purpose.kind=evolution` and do not invent verdict-incorporation authority.
|
||||
When the typed launch document contains `proposalModelingContext`, echo its exact `requestId` as `proposalModelingRequestId`. Read only that immutable typed projection against its exact canonical `modelRevision` and `modelHash`. The proposal is evidence, not campaign truth: contribute one source-grounded interpretation to shared typed state, where another organ may later challenge or revise it through another typed artifact. Do not substitute adjacent proposals, infer service intake, parse proposal authority from prose, manufacture Hands work, or claim admission or execution authority.
|
||||
Generic `statePatch` is optional and has been stripped of repository-anatomy authority. If present, it may contain only coherent `observations` and `evidence`. Never put graphs, graph frontier, graph checkpoint, scratch, investigation checkpoint, planning, objectives, jobs, or other anatomy in `statePatch`; those old paths are demoted and will be rejected.
|
||||
|
|
|
|||
|
|
@ -818,6 +818,7 @@ pub fn runtime_spine_cache(store_path: impl AsRef<Path>) -> Result<CultCache> {
|
|||
let store_path = store_path.as_ref();
|
||||
let mut cache = CultCache::new();
|
||||
cache.register_entry_type::<crate::EpiphanyThreadStateEntry>()?;
|
||||
cache.register_entry_type::<crate::UserObjectiveIntake>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeIdentity>()?;
|
||||
cache.register_entry_type::<EpiphanyRuntimeSwarmBinding>()?;
|
||||
cache.register_entry_type::<crate::MemorySemanticProjectionObligation>()?;
|
||||
|
|
@ -6660,6 +6661,21 @@ fn mutation_contract(
|
|||
|
||||
fn epiphany_mutation_contracts() -> Vec<CultNetDocumentMutationContract> {
|
||||
vec![
|
||||
mutation_contract(
|
||||
crate::USER_OBJECTIVE_INTAKE_TYPE,
|
||||
crate::USER_OBJECTIVE_INTAKE_SCHEMA_VERSION,
|
||||
vec![
|
||||
CultNetDocumentOperation::Snapshot,
|
||||
CultNetDocumentOperation::IntentSubmit,
|
||||
],
|
||||
CultNetMutationAuthority::Coordinator,
|
||||
vec![crate::USER_OBJECTIVE_INTAKE_TYPE],
|
||||
vec![crate::THREAD_STATE_TYPE],
|
||||
vec![
|
||||
"The human owns the initial objective assertion; Self atomically records it with the first canonical thread state.",
|
||||
"Objective replacement requires a separate reviewed adoption flow.",
|
||||
],
|
||||
),
|
||||
mutation_contract(
|
||||
RUNTIME_IDENTITY_TYPE,
|
||||
RUNTIME_SPINE_SCHEMA_VERSION,
|
||||
|
|
|
|||
|
|
@ -133,6 +133,7 @@ pub struct EpiphanyCoordinatorInput {
|
|||
pub signals: EpiphanyCoordinatorSignals,
|
||||
pub research_result_accepted: bool,
|
||||
pub research_result_reviewable: bool,
|
||||
pub research_result_failure_reviewed: bool,
|
||||
pub modeling_result_requests_regather: bool,
|
||||
pub modeling_result_accepted: bool,
|
||||
pub modeling_result_reviewable: bool,
|
||||
|
|
@ -176,6 +177,7 @@ pub struct EpiphanyCoordinatorStatusInput {
|
|||
pub reorient_result_status: super::EpiphanyCrrcResultStatus,
|
||||
pub research_result_accepted: bool,
|
||||
pub research_result_reviewable: bool,
|
||||
pub research_result_failure_reviewed: bool,
|
||||
pub modeling_result_requests_regather: bool,
|
||||
pub modeling_result_accepted: bool,
|
||||
pub modeling_result_reviewable: bool,
|
||||
|
|
@ -204,6 +206,7 @@ pub struct EpiphanyCoordinatorStatus {
|
|||
pub struct EpiphanyCoordinatorFindingSignals {
|
||||
pub research_result_accepted: bool,
|
||||
pub research_result_reviewable: bool,
|
||||
pub research_result_failure_reviewed: bool,
|
||||
pub modeling_result_requests_regather: bool,
|
||||
pub modeling_result_accepted: bool,
|
||||
pub modeling_result_reviewable: bool,
|
||||
|
|
@ -268,6 +271,7 @@ pub fn derive_coordinator_status(
|
|||
},
|
||||
research_result_accepted: input.research_result_accepted,
|
||||
research_result_reviewable: input.research_result_reviewable,
|
||||
research_result_failure_reviewed: input.research_result_failure_reviewed,
|
||||
modeling_result_requests_regather: input.modeling_result_requests_regather,
|
||||
modeling_result_accepted: input.modeling_result_accepted,
|
||||
modeling_result_reviewable: input.modeling_result_reviewable,
|
||||
|
|
@ -308,6 +312,11 @@ pub fn derive_coordinator_finding_signals(
|
|||
});
|
||||
let research_result_reviewable =
|
||||
research_finding.is_some_and(research_finding_has_reviewable_state_patch);
|
||||
let research_result_failure_reviewed = research_finding.as_ref().is_some_and(|finding| {
|
||||
state.is_some_and(|state| {
|
||||
role_finding_failure_reviewed(state, EpiphanyCoordinatorRoleId::Research, finding)
|
||||
})
|
||||
});
|
||||
let modeling_result_accepted = modeling_finding.as_ref().is_some_and(|finding| {
|
||||
state.is_some_and(|state| {
|
||||
role_finding_already_accepted(state, EpiphanyCoordinatorRoleId::Modeling, finding)
|
||||
|
|
@ -375,6 +384,7 @@ pub fn derive_coordinator_finding_signals(
|
|||
EpiphanyCoordinatorFindingSignals {
|
||||
research_result_accepted,
|
||||
research_result_reviewable,
|
||||
research_result_failure_reviewed,
|
||||
modeling_result_requests_regather,
|
||||
modeling_result_accepted,
|
||||
modeling_result_reviewable,
|
||||
|
|
@ -683,14 +693,14 @@ pub fn recommend_coordinator_action(
|
|||
reason: reason.to_string(),
|
||||
};
|
||||
|
||||
if input.state_status == EpiphanyCrrcStateStatus::Missing || !input.checkpoint_present {
|
||||
if input.state_status == EpiphanyCrrcStateStatus::Missing {
|
||||
return build(
|
||||
EpiphanyCoordinatorAction::PrepareCheckpoint,
|
||||
Some(EpiphanyCoordinatorRoleId::Modeling),
|
||||
Some(EpiphanyCoordinatorSceneAction::Update),
|
||||
false,
|
||||
false,
|
||||
"Authoritative state or investigation checkpoint is missing; prepare a checkpoint before coordination can continue.",
|
||||
"Authoritative state is missing; accept an explicit operator objective before coordination can continue.",
|
||||
);
|
||||
}
|
||||
|
||||
|
|
@ -749,6 +759,16 @@ pub fn recommend_coordinator_action(
|
|||
if input.signals.research_result_status == EpiphanyCoordinatorRoleResultStatus::Completed
|
||||
&& !input.research_result_accepted
|
||||
{
|
||||
if !input.research_result_reviewable && input.research_result_failure_reviewed {
|
||||
return build(
|
||||
EpiphanyCoordinatorAction::LaunchResearch,
|
||||
Some(EpiphanyCoordinatorRoleId::Research),
|
||||
Some(EpiphanyCoordinatorSceneAction::RoleLaunch),
|
||||
false,
|
||||
true,
|
||||
"The unreviewable Eyes result has a supersession receipt; relaunch Research against the current source contract.",
|
||||
);
|
||||
}
|
||||
return build(
|
||||
EpiphanyCoordinatorAction::ReviewResearchResult,
|
||||
Some(EpiphanyCoordinatorRoleId::Research),
|
||||
|
|
@ -762,6 +782,16 @@ pub fn recommend_coordinator_action(
|
|||
if input.signals.research_result_status == EpiphanyCoordinatorRoleResultStatus::Failed
|
||||
&& !input.research_result_accepted
|
||||
{
|
||||
if input.research_result_failure_reviewed {
|
||||
return build(
|
||||
EpiphanyCoordinatorAction::LaunchResearch,
|
||||
Some(EpiphanyCoordinatorRoleId::Research),
|
||||
Some(EpiphanyCoordinatorSceneAction::RoleLaunch),
|
||||
false,
|
||||
true,
|
||||
"The failed Eyes result has a supersession receipt; relaunch Research against the current source contract.",
|
||||
);
|
||||
}
|
||||
return build(
|
||||
EpiphanyCoordinatorAction::ReviewResearchResult,
|
||||
Some(EpiphanyCoordinatorRoleId::Research),
|
||||
|
|
@ -1276,6 +1306,7 @@ mod tests {
|
|||
},
|
||||
research_result_accepted: false,
|
||||
research_result_reviewable: false,
|
||||
research_result_failure_reviewed: false,
|
||||
modeling_result_requests_regather: false,
|
||||
modeling_result_accepted: false,
|
||||
modeling_result_reviewable: false,
|
||||
|
|
@ -1441,21 +1472,66 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn prepares_missing_checkpoint() {
|
||||
fn reviewed_failed_research_relaunches_eyes() {
|
||||
let mut state = EpiphanyThreadState::default();
|
||||
state.acceptance_receipts.push(EpiphanyAcceptanceReceipt {
|
||||
id: "failure-review-research".to_string(),
|
||||
result_id: "result-research".to_string(),
|
||||
job_id: "job-research".to_string(),
|
||||
binding_id: "research-source-gather-worker".to_string(),
|
||||
surface: "roleFailureReview".to_string(),
|
||||
role_id: "research".to_string(),
|
||||
status: "superseded".to_string(),
|
||||
accepted_at: "2026-07-16T00:00:00Z".to_string(),
|
||||
accepted_observation_id: None,
|
||||
accepted_evidence_id: None,
|
||||
summary: Some("Malformed Eyes result reviewed.".to_string()),
|
||||
});
|
||||
let research = finding("result-research", "job-research", Vec::new());
|
||||
let signals =
|
||||
derive_coordinator_finding_signals(Some(&state), Some(&research), None, None, None);
|
||||
assert!(signals.research_result_failure_reviewed);
|
||||
|
||||
let base = input();
|
||||
let decision = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
signals: EpiphanyCoordinatorSignals {
|
||||
research_result_status: EpiphanyCoordinatorRoleResultStatus::Failed,
|
||||
..base.signals
|
||||
},
|
||||
research_result_failure_reviewed: true,
|
||||
..base
|
||||
});
|
||||
assert_eq!(decision.action, EpiphanyCoordinatorAction::LaunchResearch);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn routes_missing_checkpoint_to_modeling_owner() {
|
||||
let decision = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
checkpoint_present: false,
|
||||
recommendation: recommendation(EpiphanyCrrcAction::PrepareCheckpoint),
|
||||
..input()
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
decision.action,
|
||||
EpiphanyCoordinatorAction::PrepareCheckpoint
|
||||
);
|
||||
assert_eq!(decision.action, EpiphanyCoordinatorAction::LaunchModeling);
|
||||
assert_eq!(
|
||||
decision.target_role,
|
||||
Some(EpiphanyCoordinatorRoleId::Modeling)
|
||||
);
|
||||
assert!(decision.can_auto_run);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn missing_state_still_requires_explicit_intake() {
|
||||
let decision = recommend_coordinator_action(EpiphanyCoordinatorInput {
|
||||
state_status: EpiphanyCrrcStateStatus::Missing,
|
||||
checkpoint_present: false,
|
||||
..input()
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
decision.action,
|
||||
EpiphanyCoordinatorAction::PrepareCheckpoint
|
||||
);
|
||||
assert!(!decision.can_auto_run);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -115,17 +115,10 @@ pub fn recommend_crrc_action(input: EpiphanyCrrcInput) -> EpiphanyCrrcRecommenda
|
|||
if input.finding_accepted
|
||||
&& input.reorient_action == EpiphanyCrrcReorientAction::Regather
|
||||
{
|
||||
if input.loaded {
|
||||
return build(
|
||||
EpiphanyCrrcAction::LaunchReorientWorker,
|
||||
Some(EpiphanyCrrcSceneAction::ReorientLaunch),
|
||||
"The accepted reorientation finding is stale against the current regather checkpoint; launch a fresh bounded worker before implementation continues.",
|
||||
);
|
||||
}
|
||||
return build(
|
||||
EpiphanyCrrcAction::RegatherManually,
|
||||
Some(EpiphanyCrrcSceneAction::Reorient),
|
||||
"The accepted reorientation finding is stale against the current regather checkpoint, but the thread is not loaded.",
|
||||
"The accepted reorientation finding requires source regather; hand off to Eyes rather than relaunching the continuity judge.",
|
||||
);
|
||||
}
|
||||
if input.finding_accepted {
|
||||
|
|
@ -251,7 +244,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
fn relaunches_stale_accepted_regather() {
|
||||
fn hands_accepted_regather_to_eyes() {
|
||||
let recommendation = recommend_crrc_action(EpiphanyCrrcInput {
|
||||
reorient_action: EpiphanyCrrcReorientAction::Regather,
|
||||
result_status: EpiphanyCrrcResultStatus::Completed,
|
||||
|
|
@ -260,9 +253,10 @@ mod tests {
|
|||
..input()
|
||||
});
|
||||
|
||||
assert_eq!(recommendation.action, EpiphanyCrrcAction::RegatherManually);
|
||||
assert_eq!(
|
||||
recommendation.action,
|
||||
EpiphanyCrrcAction::LaunchReorientWorker
|
||||
recommendation.recommended_scene_action,
|
||||
Some(EpiphanyCrrcSceneAction::Reorient)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -213,6 +213,11 @@ pub fn responses_body_from_epiphany(
|
|||
.input
|
||||
.iter()
|
||||
.any(|item| matches!(item, EpiphanyOpenAiInputItem::ToolResult { .. }));
|
||||
let text = responses_text_format(
|
||||
request.output_contract_id.as_deref(),
|
||||
request.output_schema_json.as_deref(),
|
||||
&request.request_id,
|
||||
)?;
|
||||
let body = EpiphanyResponsesBody {
|
||||
model: request.model,
|
||||
instructions: request.instructions,
|
||||
|
|
@ -226,7 +231,12 @@ pub fn responses_body_from_epiphany(
|
|||
.into_iter()
|
||||
.map(openai_tool_from_epiphany_tool)
|
||||
.collect::<Result<Vec<_>>>()?,
|
||||
tool_choice: if requires_initial_tool { "required" } else { "auto" }.to_string(),
|
||||
tool_choice: if requires_initial_tool {
|
||||
"required"
|
||||
} else {
|
||||
"auto"
|
||||
}
|
||||
.to_string(),
|
||||
parallel_tool_calls: false,
|
||||
reasoning: Some(EpiphanyResponsesReasoning {
|
||||
effort: parse_reasoning_effort(request.reasoning_effort.as_deref())?,
|
||||
|
|
@ -238,12 +248,73 @@ pub fn responses_body_from_epiphany(
|
|||
service_tier: parse_service_tier(request.service_tier.as_deref())?,
|
||||
previous_response_id: request.previous_response_id,
|
||||
prompt_cache_key: None,
|
||||
text: None,
|
||||
text,
|
||||
client_metadata: None,
|
||||
};
|
||||
serde_json::to_value(body).context("failed to encode typed Epiphany Responses body")
|
||||
}
|
||||
|
||||
fn responses_text_format(
|
||||
output_contract_id: Option<&str>,
|
||||
output_schema_json: Option<&str>,
|
||||
request_id: &str,
|
||||
) -> Result<Option<serde_json::Value>> {
|
||||
let Some(schema_json) = output_schema_json else {
|
||||
return Ok(None);
|
||||
};
|
||||
let mut schema: serde_json::Value =
|
||||
serde_json::from_str(schema_json).context("output_schema_json is not valid JSON Schema")?;
|
||||
lower_schema_for_responses_format(&mut schema);
|
||||
let raw_name = output_contract_id.unwrap_or(request_id);
|
||||
let mut name = raw_name
|
||||
.chars()
|
||||
.map(|ch| {
|
||||
if ch.is_ascii_alphanumeric() || ch == '_' || ch == '-' {
|
||||
ch
|
||||
} else {
|
||||
'_'
|
||||
}
|
||||
})
|
||||
.take(64)
|
||||
.collect::<String>();
|
||||
if name.is_empty() {
|
||||
name = "epiphany_worker_result".to_string();
|
||||
}
|
||||
Ok(Some(serde_json::json!({
|
||||
"format": {
|
||||
"type": "json_schema",
|
||||
"name": name,
|
||||
"strict": false,
|
||||
"schema": schema
|
||||
}
|
||||
})))
|
||||
}
|
||||
|
||||
fn lower_schema_for_responses_format(schema: &mut serde_json::Value) {
|
||||
match schema {
|
||||
serde_json::Value::Object(map) => {
|
||||
// Responses structured output accepts only a JSON-Schema subset.
|
||||
// Canonical conditional authority remains enforced by Epiphany ingress
|
||||
// and Mind admission; this projection owns formatting only.
|
||||
for unsupported in ["allOf", "if", "then", "else"] {
|
||||
map.remove(unsupported);
|
||||
}
|
||||
if let Some(one_of) = map.remove("oneOf") {
|
||||
map.insert("anyOf".to_string(), one_of);
|
||||
}
|
||||
for value in map.values_mut() {
|
||||
lower_schema_for_responses_format(value);
|
||||
}
|
||||
}
|
||||
serde_json::Value::Array(values) => {
|
||||
for value in values {
|
||||
lower_schema_for_responses_format(value);
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
fn openai_tool_from_epiphany_tool(
|
||||
tool: epiphany_openai_adapter::EpiphanyOpenAiToolDefinition,
|
||||
) -> Result<serde_json::Value> {
|
||||
|
|
@ -850,6 +921,71 @@ mod tests {
|
|||
assert_eq!(responses["tool_choice"], "required");
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn declared_output_schema_reaches_responses_text_format() {
|
||||
let mut request = EpiphanyOpenAiModelRequest::new(
|
||||
"req-schema",
|
||||
"conversation-schema",
|
||||
"gpt-5.4",
|
||||
"Return the typed result.",
|
||||
);
|
||||
request.output_contract_id = Some("epiphany.role_worker_output.v3".to_string());
|
||||
request.output_schema_json = Some(
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
"properties": {"summary": {"type": "string"}},
|
||||
"required": ["summary"]
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
let responses = responses_body_from_epiphany(request).expect("request should map");
|
||||
|
||||
assert_eq!(responses["text"]["format"]["type"], "json_schema");
|
||||
assert_eq!(
|
||||
responses["text"]["format"]["name"],
|
||||
"epiphany_role_worker_output_v3"
|
||||
);
|
||||
assert_eq!(responses["text"]["format"]["strict"], false);
|
||||
assert_eq!(
|
||||
responses["text"]["format"]["schema"]["required"][0],
|
||||
"summary"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn provider_schema_projection_drops_conditional_authority_only() {
|
||||
let mut request = EpiphanyOpenAiModelRequest::new(
|
||||
"req-conditional",
|
||||
"conversation-conditional",
|
||||
"gpt-5.4",
|
||||
"Return the typed result.",
|
||||
);
|
||||
request.output_contract_id = Some("epiphany.worker".to_string());
|
||||
request.output_schema_json = Some(
|
||||
serde_json::json!({
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"purpose": {
|
||||
"oneOf": [
|
||||
{"type": "string", "const": "evolution"},
|
||||
{"type": "string", "const": "repair"}
|
||||
]
|
||||
}
|
||||
},
|
||||
"allOf": [{"if": {"properties": {"purpose": {"const": "repair"}}}, "then": {"required": ["receipt"]}}]
|
||||
})
|
||||
.to_string(),
|
||||
);
|
||||
|
||||
let responses = responses_body_from_epiphany(request).expect("request should map");
|
||||
let schema = &responses["text"]["format"]["schema"];
|
||||
assert!(schema.get("allOf").is_none());
|
||||
assert!(schema["properties"]["purpose"].get("oneOf").is_none());
|
||||
assert!(schema["properties"]["purpose"]["anyOf"].is_array());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn parses_function_call_output_item_done_as_complete_tool_call() {
|
||||
let mut state = EpiphanyResponsesStreamState::new("req-tools", "gpt-5.4");
|
||||
|
|
|
|||
|
|
@ -572,6 +572,10 @@ pub fn build_worker_model_request(
|
|||
worker_instructions(launch_request, &launch_document, &output_schema_json);
|
||||
if launch_request.binding_id == epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID {
|
||||
instructions.push_str("\n\nTool mandate: before returning `needs-evidence` because source files, command artifacts, commit diffs, or Hands receipt bodies are not inspectable, call the read-only source tools available on this request. Use `mcp__epiphany_source__read_file` for cited source/artifact paths, `mcp__epiphany_source__git_show` for commit diffs, and `mcp__epiphany_source__read_hands_receipt` for Hands patch/command/commit receipts. If a tool fails, cite that failed tool result and the exact remaining blocker.");
|
||||
} else if launch_request.binding_id == epiphany_core::EPIPHANY_RESEARCH_ROLE_BINDING_ID {
|
||||
instructions.push_str("\n\nTool mandate: Eyes must inspect current repository sources before emitting evidence. Call the bounded read-only file or Git tools, cite the exact inspected paths/revisions in filesInspected and evidence, and report a source gap if the required body cannot be observed.");
|
||||
} else if launch_request.binding_id == epiphany_core::EPIPHANY_MODELING_ROLE_BINDING_ID {
|
||||
instructions.push_str("\n\nTool mandate: Modeling must inspect current repository sources before proposing repository anatomy. Call the bounded read-only file or Git tools, cite the exact inspected paths/revisions in filesInspected and evidence, and emit regather-needed instead of inventing unobserved structure.");
|
||||
}
|
||||
let mut request = EpiphanyModelRequest::new(
|
||||
request_id,
|
||||
|
|
@ -589,8 +593,13 @@ pub fn build_worker_model_request(
|
|||
request.reasoning_summary = Some("concise".to_string());
|
||||
request.output_contract_id = Some(launch_request.output_contract_id.clone());
|
||||
request.output_schema_json = Some(output_schema_json);
|
||||
if launch_request.binding_id == epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID {
|
||||
request.tools = verification_source_tools();
|
||||
if matches!(
|
||||
launch_request.binding_id.as_str(),
|
||||
epiphany_core::EPIPHANY_RESEARCH_ROLE_BINDING_ID
|
||||
| epiphany_core::EPIPHANY_MODELING_ROLE_BINDING_ID
|
||||
| epiphany_core::EPIPHANY_VERIFICATION_ROLE_BINDING_ID
|
||||
) {
|
||||
request.tools = repository_source_tools();
|
||||
}
|
||||
Ok(request)
|
||||
}
|
||||
|
|
@ -603,9 +612,15 @@ pub fn complete_worker_job_from_assistant_text(
|
|||
assistant_text: &str,
|
||||
) -> Result<epiphany_core::EpiphanyRuntimeJobResult> {
|
||||
let launch_document = launch_request.launch_document()?;
|
||||
let parsed = parse_worker_result_ingress(&launch_document, assistant_text).ok();
|
||||
let parsed_result = parse_worker_result_ingress(&launch_document, assistant_text);
|
||||
let parse_error = parsed_result
|
||||
.as_ref()
|
||||
.err()
|
||||
.map(|error| format!("{error:#}"));
|
||||
let parsed = parsed_result.ok();
|
||||
let openai_failed = openai_summary.verdict != "pass";
|
||||
let verdict = if openai_failed {
|
||||
let contract_failed = !openai_failed && parsed.is_none();
|
||||
let verdict = if openai_failed || contract_failed {
|
||||
"failed".to_string()
|
||||
} else {
|
||||
parsed
|
||||
|
|
@ -615,18 +630,28 @@ pub fn complete_worker_job_from_assistant_text(
|
|||
};
|
||||
let summary = if openai_failed {
|
||||
format!("Worker model request {openai_request_id} failed before producing usable output.")
|
||||
} else if let Some(error) = parse_error.as_deref() {
|
||||
format!(
|
||||
"Worker model response failed declared output contract {}: {error}",
|
||||
launch_request.output_contract_id
|
||||
)
|
||||
} else {
|
||||
parsed
|
||||
.as_ref()
|
||||
.and_then(WorkerResultIngress::summary)
|
||||
.unwrap_or_else(|| "Worker completed without a structured summary.".to_string())
|
||||
};
|
||||
let next_safe_move = parsed
|
||||
.as_ref()
|
||||
.and_then(WorkerResultIngress::next_safe_move)
|
||||
.unwrap_or_else(|| {
|
||||
"Review the typed worker runtime result before accepting state.".to_string()
|
||||
});
|
||||
let next_safe_move = if contract_failed {
|
||||
"Repair the worker prompt/output-schema boundary before relaunching; no typed role result was admitted."
|
||||
.to_string()
|
||||
} else {
|
||||
parsed
|
||||
.as_ref()
|
||||
.and_then(WorkerResultIngress::next_safe_move)
|
||||
.unwrap_or_else(|| {
|
||||
"Review the typed worker runtime result before accepting state.".to_string()
|
||||
})
|
||||
};
|
||||
let mut evidence_refs = parsed
|
||||
.as_ref()
|
||||
.map(WorkerResultIngress::evidence_ids)
|
||||
|
|
@ -1034,11 +1059,11 @@ pub fn openai_request_from_model_request(
|
|||
}
|
||||
}
|
||||
|
||||
fn verification_source_tools() -> Vec<EpiphanyModelToolDefinition> {
|
||||
fn repository_source_tools() -> Vec<EpiphanyModelToolDefinition> {
|
||||
vec![
|
||||
EpiphanyModelToolDefinition {
|
||||
name: "mcp__epiphany_source__read_file".to_string(),
|
||||
description: "Read a bounded UTF-8 text slice from the current workspace for Soul verification. Use only for source files and operator-safe artifacts named in the launch packet.".to_string(),
|
||||
description: "Read a bounded UTF-8 text slice from the current workspace for source-grounded Eyes, Modeling, or Soul work. Use only for repository sources and operator-safe artifacts in scope.".to_string(),
|
||||
parameters_json: serde_json::json!({
|
||||
"type": "object",
|
||||
"additionalProperties": false,
|
||||
|
|
@ -2075,6 +2100,19 @@ mod tests {
|
|||
fn completes_worker_job_from_model_json_without_codex_worker_runtime() -> Result<()> {
|
||||
let temp = tempdir()?;
|
||||
let store = temp.path().join("runtime.msgpack");
|
||||
let body_basis = epiphany_core::RepositoryBodyObservationBasis {
|
||||
schema_version: "epiphany.repository_body.observation_basis.v0".to_string(),
|
||||
workspace_id: "workspace-test".to_string(),
|
||||
swarm_id: "swarm-test".to_string(),
|
||||
runtime_id: "epiphany-test".to_string(),
|
||||
scope: "whole_repository".to_string(),
|
||||
body_binding_sha256: "body-binding".to_string(),
|
||||
observation_id: "body-observation-1".to_string(),
|
||||
generation: 1,
|
||||
manifest_root_sha256: "manifest-root".to_string(),
|
||||
scan_started_at: "2026-07-13T00:00:00Z".to_string(),
|
||||
scan_finished_at: "2026-07-13T00:00:01Z".to_string(),
|
||||
};
|
||||
open_runtime_spine_heartbeat_job(
|
||||
&store,
|
||||
RuntimeSpineHeartbeatJobOptions {
|
||||
|
|
@ -2084,7 +2122,7 @@ mod tests {
|
|||
objective: "Run typed worker.".to_string(),
|
||||
coordinator_note: "test".to_string(),
|
||||
job_id: "worker-job-1".to_string(),
|
||||
role: "modeling".to_string(),
|
||||
role: epiphany_core::EPIPHANY_MODELING_OWNER_ROLE.to_string(),
|
||||
binding_id: "modeling-checkpoint-worker".to_string(),
|
||||
authority_scope: "epiphany.role.modeling".to_string(),
|
||||
instruction: "Return the required role-result JSON.".to_string(),
|
||||
|
|
@ -2098,7 +2136,7 @@ mod tests {
|
|||
"<epiphany_dynamic_context>\nlocal Verse: bounded\n</epiphany_dynamic_context>"
|
||||
.to_string(),
|
||||
),
|
||||
repository_body_observation_basis: None,
|
||||
repository_body_observation_basis: Some(body_basis.clone()),
|
||||
proposal_modeling_context: None,
|
||||
claim_repair_context: None,
|
||||
frontier_planning_context: None,
|
||||
|
|
@ -2154,7 +2192,13 @@ mod tests {
|
|||
.contains("<epiphany_dynamic_context>")
|
||||
);
|
||||
assert!(model_request.instructions.contains("local Verse: bounded"));
|
||||
assert!(model_request.tools.is_empty());
|
||||
assert!(
|
||||
model_request
|
||||
.tools
|
||||
.iter()
|
||||
.any(|tool| tool.name == "mcp__epiphany_source__read_file")
|
||||
);
|
||||
assert!(model_request.instructions.contains("Modeling must inspect"));
|
||||
let openai_summary = EpiphanyOpenAiRuntimeRunSummary {
|
||||
store: store.display().to_string(),
|
||||
session_id: "openai-worker-session-modeling-checkpoint-worker".to_string(),
|
||||
|
|
@ -2167,12 +2211,34 @@ mod tests {
|
|||
receipt_id: Some(model_request.request_id.clone()),
|
||||
tool_intent_ids: Vec::new(),
|
||||
};
|
||||
let assistant_text = serde_json::json!({
|
||||
"roleId": "modeling",
|
||||
"verdict": "checkpoint-ready",
|
||||
"summary": "Mapped.",
|
||||
"nextSafeMove": "Review the patch.",
|
||||
"filesInspected": ["src/lib.rs"],
|
||||
"frontierNodeIds": ["old"],
|
||||
"evidenceIds": ["ev-1"],
|
||||
"artifactRefs": ["artifact:model"],
|
||||
"repositoryBodyObservationBasis": body_basis,
|
||||
"repoModelPatch": {
|
||||
"patch_id": "modeling-runtime-test",
|
||||
"base_revision": 0,
|
||||
"base_hash": "legacy-hash",
|
||||
"applied_at": "2026-07-13T00:00:00Z",
|
||||
"purpose": {"kind": "evolution"},
|
||||
"operations": [{"operation": "retire_node", "node_id": "old"}]
|
||||
},
|
||||
"statePatch": {"observations": [], "evidence": []},
|
||||
"selfPatch": {"reason": "typed nested document"}
|
||||
})
|
||||
.to_string();
|
||||
let result = complete_worker_job_from_assistant_text(
|
||||
&store,
|
||||
&launch_request,
|
||||
&model_request.request_id,
|
||||
&openai_summary,
|
||||
r#"{"roleId":"modeling","verdict":"checkpoint-ready","summary":"Mapped.","nextSafeMove":"Review the patch.","filesInspected":["src/lib.rs"],"frontierNodeIds":["old"],"evidenceIds":["ev-1"],"artifactRefs":["artifact:model"],"repoModelPatch":{"patch_id":"modeling-runtime-test","base_revision":0,"base_hash":"legacy-hash","applied_at":"2026-07-13T00:00:00Z","purpose":{"kind":"evolution"},"operations":[{"operation":"retire_node","node_id":"old"}]},"statePatch":{"observations":[],"evidence":[]},"selfPatch":{"reason":"typed nested document"}} "#,
|
||||
&assistant_text,
|
||||
)?;
|
||||
|
||||
assert_eq!(result.job_id, "worker-job-1");
|
||||
|
|
|
|||
7
epiphany-tool-codex-mcp-spine/Cargo.lock
generated
7
epiphany-tool-codex-mcp-spine/Cargo.lock
generated
|
|
@ -1212,7 +1212,6 @@ dependencies = [
|
|||
"codex-utils-string",
|
||||
"codex-utils-template",
|
||||
"encoding_rs",
|
||||
"epiphany-state-model",
|
||||
"globset",
|
||||
"icu_decimal",
|
||||
"icu_locale_core",
|
||||
|
|
@ -2242,20 +2241,26 @@ dependencies = [
|
|||
"cultcache-rs",
|
||||
"cultmesh-rs",
|
||||
"cultnet-rs",
|
||||
"ed25519-dalek",
|
||||
"epiphany-model-adapter",
|
||||
"epiphany-openai-adapter",
|
||||
"epiphany-state-model",
|
||||
"epiphany-tool-adapter",
|
||||
"ignore",
|
||||
"libc",
|
||||
"postgres",
|
||||
"rand_core 0.6.4",
|
||||
"reqwest",
|
||||
"rmp-serde",
|
||||
"serde",
|
||||
"serde_json",
|
||||
"sha1",
|
||||
"sha2 0.10.9",
|
||||
"toml",
|
||||
"tracing",
|
||||
"uuid",
|
||||
"windows-sys 0.59.0",
|
||||
"zeroize",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
|
|
|
|||
|
|
@ -1,5 +1,31 @@
|
|||
# Epiphany Current Algorithmic Map
|
||||
|
||||
## Coordinator cold start and source-regather ownership (2026-07-16)
|
||||
|
||||
- Owner: typed `UserObjectiveIntake` owns first objective/state creation. It is
|
||||
seed-only, atomic, idempotent for identical input, and refuses replacement.
|
||||
- Eyes owns source gathering. An accepted CRRC `Regather` judgment becomes
|
||||
`RegatherManually`, which Self maps to Research; the continuity judge does not
|
||||
recursively relaunch itself after its judgment is accepted.
|
||||
- Modeling owns Body mapping only after source inspection. Research, Modeling,
|
||||
and Verification share bounded repository read/Git tools; tool receipts are
|
||||
operator-safe evidence while direct thought stays sealed.
|
||||
- Mind owns admission. Provider JSON Schema is a formatting projection, not
|
||||
authority. Canonical worker-result parsing, exact launch Body-basis replay,
|
||||
and Mind review/admission decide whether a RepoModel patch exists.
|
||||
- Derived state: status, role boards, and coordinator decisions read one
|
||||
canonical typed role/reorient result path. Display synthesis cannot remember
|
||||
a finding that coordinator signals forget, or vice versa.
|
||||
- Forbidden writers cut: sibling-path local-Verse inference, fake checkpoint
|
||||
preparation, recursive reorientation after accepted regather, duplicate
|
||||
display/coordinator result readers, and JSON null treated as a state patch.
|
||||
- Failure lifecycle: failed and completed-unreviewable results require an
|
||||
explicit supersession receipt before relaunch. Exact repeat is idempotent;
|
||||
conflicting acceptance authority is refused.
|
||||
- Current live evidence: Eyes produced and Mind accepted a code-grounded result.
|
||||
Modeling has not yet produced a current admissible Body-grounded result; its
|
||||
latest eleven-tool run ended at the provider request boundary.
|
||||
|
||||
## Observation and bootstrap authority correction (2026-07-12)
|
||||
|
||||
- Owner: diagnostics only project persisted CultMesh state; they never initialize it.
|
||||
|
|
|
|||
|
|
@ -1,5 +1,41 @@
|
|||
# Fresh Workspace Handoff
|
||||
|
||||
## Live Body-grounded admission rite — 2026-07-16
|
||||
|
||||
Thread `readiness-grounding-20260716` now has a typed, immutable user objective
|
||||
and an accepted code-grounded Eyes result. Cold-start objective intake, explicit
|
||||
local-Verse path ownership, source tools for Eyes/Modeling, canonical result
|
||||
readers, failed-result supersession, reorient auto-acceptance, and the
|
||||
CRRC-regather handoff to Eyes are implemented in the current worktree.
|
||||
|
||||
The live rite exposed output-contract wounds one at a time. Modeling operations,
|
||||
frontier items, nodes, edges, profiles, anchors, code refs, observations, and
|
||||
evidence now have provider-facing typed shapes matching canonical ingress;
|
||||
explicit null no longer impersonates a reviewable state patch. Failed worker
|
||||
output is terminally sealed with a bounded diagnostic rather than marked
|
||||
complete. The stale OpenAI-runtime Modeling fixture now carries and echoes a
|
||||
Body basis and passes again.
|
||||
|
||||
No current Modeling admission exists yet. The most recent worker inspected
|
||||
source through eleven tool rounds, then the provider request failed before a
|
||||
typed result was published. Do not inspect its sealed transcript. Rebuild the
|
||||
coordinator after any final edits, supersede that failed result with
|
||||
`--supersede-failed-results`, and relaunch in `--mode run` with the existing
|
||||
accepted Eyes basis. Make no source edits between the final Body observation
|
||||
and Mind admission. Only after Mind accepts an exact Body-basis RepoModel patch
|
||||
should `epiphany-memory-semantic repository-readiness` be run with local Ollama
|
||||
`qwen3-embedding:0.6b`, 1024 dimensions, and the runtime spine.
|
||||
|
||||
Exact remaining sequence:
|
||||
|
||||
1. finish tests/format/docs and commit so the Body is stable;
|
||||
2. relaunch Modeling against thread `readiness-grounding-20260716`;
|
||||
3. inspect only the operator-safe role finding, then auto-accept if its Body
|
||||
basis, RepoModel patch, and state patch are typed and current;
|
||||
4. run the live repository-readiness join and preserve its projection;
|
||||
5. investigate the provider failure only through typed request/receipt
|
||||
diagnostics if it repeats; raw worker thought remains sealed.
|
||||
|
||||
## Counterfeit planning writers cut - 2026-07-15
|
||||
|
||||
Modeling and Eyes traced the repo-frontier planning family and found a typed but
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -5,6 +5,7 @@ experiment:
|
|||
workspace_retrieval_coverage: "The production-unwired retrieval.rs oracle is deleted. Legacy EpiphanyRetrievalState is presentation-only: clean Ready projects Missing and its indexing job is unavailable/unowned. Native coverage binds an authenticated Repository Body manifest, exhaustive versioned inclusion policy, deterministic chunks/point payloads, immutable Ollama tag+artifact digest identity, vector dimensions, exact Qdrant point/payload/vector observations, and one terminal-CAS receipt/head. A read-only live evidence reader now re-scrolls the exact compatible collection, recomputes payload/vector bindings, and byte-revalidates the entire authority chain after the external read. Coverage success proves only this exact Body projection; Mind alone may join it with the other repository authorities."
|
||||
workspace_coverage_projector: "The dedicated workspace-coverage projector is the only coverage writer. Its reserved supervisor/CultMesh policy fixes the packaged sibling binary and exact runtime/Verse/Qdrant/Ollama args; generic policy, arbitrary command, workspace, Body-store, collection, and dimension inputs are forbidden. The binary authenticates current policy-bound launch receipt, PID, executable hash, runtime id, and host singleton before the service derives the immutable Body route. One persisted Body basis plus one authenticated read session prepares verified UTF-8 chunks; an exact Current fast path reads no worktree files. Claims/attempts bind exact managed-process launch and executor incarnation. Every pulse re-resolves the mutable Ollama tag to its installed artifact digest, probes dimensions, embeds only after claim acquisition, writes an epoch-fenced managed Qdrant collection, whole-scrolls typed payloads and unnamed vectors, rejects cyclic offsets and duplicate/extra/missing/substituted/nonfinite/wrong-dimension/wrong-vector points, then terminal-CASes receipt/head against exact Body/plan/claim/prior-head authority. Body history owns bounded retirement of terminal non-current collections; running/current collections are preserved and deletion requires exact managed metadata. Idunn recovery uses specialized process authority only: immutable exact predecessor termination must exist before a host-signed replacement launch can claim the one replacement slot; the replacement's latest signed heartbeat must be ready; one Body CAS then terminalizes the abandoned claim/attempt, advances the fencing epoch, and persists an immutable recovery receipt binding old claim, termination, replacement launch, ready heartbeat, and successor claim. Query admission remains absent."
|
||||
repository_readiness_join: "Mind owns the implemented race-bounded RepositoryReadinessProjection operation. It freshly observes Body R1; derives canonical RepoModel, the unique current v5 Body-grounded admission, and the complete succeeded Modeling semantic chain from one raw opening CultCache snapshot; authenticates live semantic vectors and live workspace coverage bound to R1; observes Body R2 and requires the same content identity/root; repeats both live reads; derives the closing authority from one raw full snapshot; and atomically appends a historical observed-ready-at projection only if that complete snapshot is unchanged. Stored projections never grant current readiness. A→B→A is acceptable only as equal content-addressed endpoints. CultCache now fences full-snapshot cardinality with tuple (type,key) identity. Legacy retrieval Ready, timestamps, watcher silence, Git OIDs, collection existence/counts, Hands receipts, Eve/Gjallar, and prior readiness projections are forbidden substitutes."
|
||||
coordinator_grounding_loop: "Cold start is owned by one typed UserObjectiveIntake that atomically seeds thread state and refuses objective replacement; a missing checkpoint routes to Modeling rather than a fictional prepareCheckpoint actuator. Explicit local-Verse path authority flows into launch context without sibling-path inference. Eyes and Modeling receive bounded source tools. Accepted CRRC regather findings hand source gathering to Eyes instead of recursively relaunching the continuity judge. Runtime/display/coordinator reads share the canonical typed role and reorient result readers. Failed or completed-unreviewable role outputs may be explicitly superseded by a typed review receipt; JSON null is not a state patch. Provider output schema is formatting guidance only, while canonical typed ingress and Mind remain admission authority. Modeling's provider schema now describes tagged patch operations, closed node/edge/profile vocabularies, canonical node/edge fields, anchors, code refs, observations, evidence, frontier items, and Body-basis echo. Live dogfood has accepted one code-grounded Eyes result, but no current Body-grounded Modeling admission yet: the latest Modeling run used eleven source-tool rounds then failed at the provider request boundary before publishing typed output."
|
||||
status: active
|
||||
phase: phase_6_reflection_boundary
|
||||
premise: >
|
||||
|
|
|
|||
Reference in a new issue