Extract Epiphany acceptance bundles into core
This commit is contained in:
parent
1429141b5b
commit
6b5a02bff7
8 changed files with 559 additions and 203 deletions
|
|
@ -131,6 +131,7 @@ pub use state_ledger::append_state_evidence;
|
|||
pub use state_ledger::close_state_branch;
|
||||
pub use state_ledger::load_state_ledger;
|
||||
pub use state_ledger::state_ledger_status;
|
||||
pub use surfaces::EpiphanyAcceptanceBundle;
|
||||
pub use surfaces::EpiphanyCoordinatorAction;
|
||||
pub use surfaces::EpiphanyCoordinatorAutomationAction;
|
||||
pub use surfaces::EpiphanyCoordinatorCrrcRecommendation;
|
||||
|
|
@ -153,6 +154,9 @@ pub use surfaces::EpiphanyPressure;
|
|||
pub use surfaces::EpiphanyPressureBasis;
|
||||
pub use surfaces::EpiphanyPressureLevel;
|
||||
pub use surfaces::EpiphanyPressureStatus;
|
||||
pub use surfaces::EpiphanyReorientAcceptanceBundle;
|
||||
pub use surfaces::EpiphanyReorientAcceptanceFinding;
|
||||
pub use surfaces::EpiphanyRoleAcceptanceFinding;
|
||||
pub use surfaces::EpiphanyRoleBoardCheckpointSummary;
|
||||
pub use surfaces::EpiphanyRoleBoardInput;
|
||||
pub use surfaces::EpiphanyRoleBoardJob;
|
||||
|
|
@ -166,6 +170,8 @@ pub use surfaces::EpiphanyRoleSelfPersistenceStatus;
|
|||
pub use surfaces::EpiphanyViewInput;
|
||||
pub use surfaces::EpiphanyViewLens;
|
||||
pub use surfaces::EpiphanyViewOutput;
|
||||
pub use surfaces::build_reorient_acceptance_bundle;
|
||||
pub use surfaces::build_role_acceptance_bundle;
|
||||
pub use surfaces::coordinator_automation_action;
|
||||
pub use surfaces::crrc_scene_action_to_coordinator_scene_action;
|
||||
pub use surfaces::derive_pressure_view;
|
||||
|
|
|
|||
|
|
@ -42,10 +42,16 @@ pub use role_board::derive_role_board;
|
|||
pub use role_board::render_role_board_note;
|
||||
pub use role_board::reorientation_role_status;
|
||||
pub use role_board::role_board_job_status_to_role_status;
|
||||
pub use role_result::EpiphanyAcceptanceBundle;
|
||||
pub use role_result::EpiphanyReorientAcceptanceBundle;
|
||||
pub use role_result::EpiphanyReorientAcceptanceFinding;
|
||||
pub use role_result::EpiphanyRoleAcceptanceFinding;
|
||||
pub use role_result::EpiphanyRoleFindingInterpretation;
|
||||
pub use role_result::EpiphanyRoleResultRoleId;
|
||||
pub use role_result::EpiphanyRoleSelfPersistenceReview;
|
||||
pub use role_result::EpiphanyRoleSelfPersistenceStatus;
|
||||
pub use role_result::build_reorient_acceptance_bundle;
|
||||
pub use role_result::build_role_acceptance_bundle;
|
||||
pub use role_result::imagination_role_state_patch_policy_errors;
|
||||
pub use role_result::interpret_role_finding;
|
||||
pub use role_result::modeling_role_state_patch_policy_errors;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,51 @@ pub struct EpiphanyRoleFindingInterpretation {
|
|||
pub item_error: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct EpiphanyRoleAcceptanceFinding {
|
||||
pub role_id: EpiphanyRoleResultRoleId,
|
||||
pub verdict: Option<String>,
|
||||
pub summary: Option<String>,
|
||||
pub next_safe_move: Option<String>,
|
||||
pub files_inspected: Vec<String>,
|
||||
pub runtime_result_id: Option<String>,
|
||||
pub runtime_job_id: Option<String>,
|
||||
pub projected_fields: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct EpiphanyReorientAcceptanceFinding {
|
||||
pub mode: Option<String>,
|
||||
pub summary: Option<String>,
|
||||
pub next_safe_move: Option<String>,
|
||||
pub checkpoint_still_valid: Option<bool>,
|
||||
pub files_inspected: Vec<String>,
|
||||
pub runtime_result_id: Option<String>,
|
||||
pub runtime_job_id: Option<String>,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct EpiphanyAcceptanceBundle {
|
||||
pub accepted_receipt_id: String,
|
||||
pub accepted_observation_id: String,
|
||||
pub accepted_evidence_id: String,
|
||||
pub evidence: EpiphanyEvidenceRecord,
|
||||
pub observation: EpiphanyObservation,
|
||||
pub receipt: EpiphanyAcceptanceReceipt,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Eq)]
|
||||
pub struct EpiphanyReorientAcceptanceBundle {
|
||||
pub accepted_receipt_id: String,
|
||||
pub accepted_observation_id: String,
|
||||
pub accepted_evidence_id: String,
|
||||
pub evidence: EpiphanyEvidenceRecord,
|
||||
pub observation: EpiphanyObservation,
|
||||
pub receipt: EpiphanyAcceptanceReceipt,
|
||||
pub scratch: Option<EpiphanyScratchPad>,
|
||||
pub investigation_checkpoint: Option<EpiphanyInvestigationCheckpoint>,
|
||||
}
|
||||
|
||||
pub fn interpret_role_finding(
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
raw_result: &serde_json::Value,
|
||||
|
|
@ -102,6 +147,130 @@ pub fn interpret_role_finding(
|
|||
}
|
||||
}
|
||||
|
||||
pub fn build_role_acceptance_bundle(
|
||||
binding_id: &str,
|
||||
role: EpiphanyRoleAcceptanceFinding,
|
||||
accepted_evidence_id: String,
|
||||
accepted_observation_id: String,
|
||||
accepted_at: String,
|
||||
) -> Result<EpiphanyAcceptanceBundle, String> {
|
||||
let accepted_kind = role_accepted_kind(role.role_id)?;
|
||||
let accepted_prefix = role_label(role.role_id)?;
|
||||
let runtime_result_id = role
|
||||
.runtime_result_id
|
||||
.clone()
|
||||
.ok_or_else(|| "cannot accept role finding without a runtimeResultId".to_string())?;
|
||||
let runtime_job_id = role
|
||||
.runtime_job_id
|
||||
.clone()
|
||||
.ok_or_else(|| "cannot accept role finding without a runtimeJobId".to_string())?;
|
||||
let accepted_receipt_id = format!("accept-{accepted_prefix}-{runtime_result_id}");
|
||||
let code_refs = role_finding_code_refs(role.role_id, &role.files_inspected);
|
||||
let evidence = EpiphanyEvidenceRecord {
|
||||
id: accepted_evidence_id.clone(),
|
||||
kind: accepted_kind.to_string(),
|
||||
status: "accepted".to_string(),
|
||||
summary: role_finding_summary(&role),
|
||||
code_refs: code_refs.clone(),
|
||||
};
|
||||
let observation = EpiphanyObservation {
|
||||
id: accepted_observation_id.clone(),
|
||||
summary: role_finding_observation_summary(&role),
|
||||
source_kind: accepted_kind.to_string(),
|
||||
status: "accepted".to_string(),
|
||||
code_refs,
|
||||
evidence_ids: vec![accepted_evidence_id.clone()],
|
||||
};
|
||||
let receipt = EpiphanyAcceptanceReceipt {
|
||||
id: accepted_receipt_id.clone(),
|
||||
result_id: runtime_result_id,
|
||||
job_id: runtime_job_id,
|
||||
binding_id: binding_id.to_string(),
|
||||
surface: "roleAccept".to_string(),
|
||||
role_id: accepted_prefix.to_string(),
|
||||
status: "accepted".to_string(),
|
||||
accepted_at,
|
||||
accepted_observation_id: Some(accepted_observation_id.clone()),
|
||||
accepted_evidence_id: Some(accepted_evidence_id.clone()),
|
||||
summary: role.summary.clone(),
|
||||
};
|
||||
Ok(EpiphanyAcceptanceBundle {
|
||||
accepted_receipt_id,
|
||||
accepted_observation_id,
|
||||
accepted_evidence_id,
|
||||
evidence,
|
||||
observation,
|
||||
receipt,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn build_reorient_acceptance_bundle(
|
||||
binding_id: &str,
|
||||
finding: EpiphanyReorientAcceptanceFinding,
|
||||
accepted_evidence_id: String,
|
||||
accepted_observation_id: String,
|
||||
accepted_at: String,
|
||||
update_scratch: bool,
|
||||
investigation_checkpoint: Option<EpiphanyInvestigationCheckpoint>,
|
||||
) -> Result<EpiphanyReorientAcceptanceBundle, String> {
|
||||
let runtime_result_id = finding.runtime_result_id.clone().ok_or_else(|| {
|
||||
"cannot accept reorientation finding without a runtimeResultId".to_string()
|
||||
})?;
|
||||
let runtime_job_id = finding
|
||||
.runtime_job_id
|
||||
.clone()
|
||||
.ok_or_else(|| "cannot accept reorientation finding without a runtimeJobId".to_string())?;
|
||||
let accepted_receipt_id = format!("accept-reorient-{runtime_result_id}");
|
||||
let code_refs = reorient_finding_code_refs(&finding.files_inspected);
|
||||
let evidence = EpiphanyEvidenceRecord {
|
||||
id: accepted_evidence_id.clone(),
|
||||
kind: "reorient_result".to_string(),
|
||||
status: "accepted".to_string(),
|
||||
summary: reorient_finding_summary(&finding),
|
||||
code_refs: code_refs.clone(),
|
||||
};
|
||||
let observation = EpiphanyObservation {
|
||||
id: accepted_observation_id.clone(),
|
||||
summary: reorient_finding_observation_summary(&finding),
|
||||
source_kind: "reorient_result".to_string(),
|
||||
status: "accepted".to_string(),
|
||||
code_refs: code_refs.clone(),
|
||||
evidence_ids: vec![accepted_evidence_id.clone()],
|
||||
};
|
||||
let scratch = update_scratch.then(|| reorient_finding_scratch(binding_id, &finding));
|
||||
let investigation_checkpoint = investigation_checkpoint.map(|checkpoint| {
|
||||
reorient_finding_investigation_checkpoint(
|
||||
checkpoint,
|
||||
accepted_evidence_id.as_str(),
|
||||
code_refs.as_slice(),
|
||||
&finding,
|
||||
)
|
||||
});
|
||||
let receipt = EpiphanyAcceptanceReceipt {
|
||||
id: accepted_receipt_id.clone(),
|
||||
result_id: runtime_result_id,
|
||||
job_id: runtime_job_id,
|
||||
binding_id: binding_id.to_string(),
|
||||
surface: "reorientAccept".to_string(),
|
||||
role_id: "reorientation".to_string(),
|
||||
status: "accepted".to_string(),
|
||||
accepted_at,
|
||||
accepted_observation_id: Some(accepted_observation_id.clone()),
|
||||
accepted_evidence_id: Some(accepted_evidence_id.clone()),
|
||||
summary: finding.summary.clone(),
|
||||
};
|
||||
Ok(EpiphanyReorientAcceptanceBundle {
|
||||
accepted_receipt_id,
|
||||
accepted_observation_id,
|
||||
accepted_evidence_id,
|
||||
evidence,
|
||||
observation,
|
||||
receipt,
|
||||
scratch,
|
||||
investigation_checkpoint,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn role_self_memory_target(role_id: EpiphanyRoleResultRoleId) -> (&'static str, &'static str) {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => (
|
||||
|
|
@ -123,6 +292,28 @@ pub fn role_self_memory_target(role_id: EpiphanyRoleResultRoleId) -> (&'static s
|
|||
}
|
||||
}
|
||||
|
||||
pub fn role_accepted_kind(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => Ok("planning_synthesis"),
|
||||
EpiphanyRoleResultRoleId::Modeling => Ok("modeling_result"),
|
||||
EpiphanyRoleResultRoleId::Verification => Ok("verification_result"),
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => Err(
|
||||
format!("role {role_id:?} cannot be accepted through roleAccept"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn role_label(role_id: EpiphanyRoleResultRoleId) -> Result<&'static str, String> {
|
||||
match role_id {
|
||||
EpiphanyRoleResultRoleId::Imagination => Ok("imagination"),
|
||||
EpiphanyRoleResultRoleId::Modeling => Ok("modeling"),
|
||||
EpiphanyRoleResultRoleId::Verification => Ok("verification"),
|
||||
EpiphanyRoleResultRoleId::Implementation | EpiphanyRoleResultRoleId::Reorientation => Err(
|
||||
format!("role {role_id:?} cannot be accepted through roleAccept"),
|
||||
),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn review_role_self_patch(
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
patch: &serde_json::Value,
|
||||
|
|
@ -446,6 +637,143 @@ fn merge_item_error(item_error: Option<String>, extra_error: Option<String>) ->
|
|||
}
|
||||
}
|
||||
|
||||
fn role_finding_summary(finding: &EpiphanyRoleAcceptanceFinding) -> String {
|
||||
let summary = finding
|
||||
.summary
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Role worker returned a structured finding.".to_string());
|
||||
if let Some(next_safe_move) = finding.next_safe_move.as_deref() {
|
||||
format!("{summary} Next safe move: {next_safe_move}")
|
||||
} else {
|
||||
summary
|
||||
}
|
||||
}
|
||||
|
||||
fn role_finding_observation_summary(finding: &EpiphanyRoleAcceptanceFinding) -> String {
|
||||
let verdict = finding.verdict.as_deref().unwrap_or("unknown");
|
||||
let changed = if finding.projected_fields.is_empty() {
|
||||
"no typed state fields projected".to_string()
|
||||
} else {
|
||||
finding.projected_fields.join(", ")
|
||||
};
|
||||
format!(
|
||||
"Accepted {:?} role result with verdict {verdict}; projected fields: {changed}. {}",
|
||||
finding.role_id,
|
||||
role_finding_summary(finding)
|
||||
)
|
||||
}
|
||||
|
||||
fn role_finding_code_refs(
|
||||
role_id: EpiphanyRoleResultRoleId,
|
||||
files_inspected: &[String],
|
||||
) -> Vec<EpiphanyCodeRef> {
|
||||
files_inspected
|
||||
.iter()
|
||||
.filter(|path| !path.trim().is_empty())
|
||||
.map(|path| EpiphanyCodeRef {
|
||||
path: PathBuf::from(path),
|
||||
start_line: None,
|
||||
end_line: None,
|
||||
symbol: None,
|
||||
note: Some(format!("Inspected by accepted {role_id:?} role worker.")),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn reorient_finding_summary(finding: &EpiphanyReorientAcceptanceFinding) -> String {
|
||||
let summary = finding
|
||||
.summary
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Reorientation worker returned a structured finding.".to_string());
|
||||
if let Some(next_safe_move) = finding.next_safe_move.as_deref() {
|
||||
format!("{summary} Next safe move: {next_safe_move}")
|
||||
} else {
|
||||
summary
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_finding_observation_summary(finding: &EpiphanyReorientAcceptanceFinding) -> String {
|
||||
let mode = finding.mode.as_deref().unwrap_or("unknown");
|
||||
let validity = match finding.checkpoint_still_valid {
|
||||
Some(true) => "checkpoint still valid",
|
||||
Some(false) => "checkpoint requires regather",
|
||||
None => "checkpoint validity not reported",
|
||||
};
|
||||
format!(
|
||||
"Accepted {mode} reorientation result: {validity}. {}",
|
||||
reorient_finding_summary(finding)
|
||||
)
|
||||
}
|
||||
|
||||
fn reorient_finding_code_refs(files_inspected: &[String]) -> Vec<EpiphanyCodeRef> {
|
||||
files_inspected
|
||||
.iter()
|
||||
.filter(|path| !path.trim().is_empty())
|
||||
.map(|path| EpiphanyCodeRef {
|
||||
path: PathBuf::from(path),
|
||||
start_line: None,
|
||||
end_line: None,
|
||||
symbol: None,
|
||||
note: Some("Inspected by accepted reorientation worker.".to_string()),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn reorient_finding_scratch(
|
||||
binding_id: &str,
|
||||
finding: &EpiphanyReorientAcceptanceFinding,
|
||||
) -> EpiphanyScratchPad {
|
||||
let mode = finding.mode.as_deref().unwrap_or("unknown");
|
||||
let checkpoint_validity = match finding.checkpoint_still_valid {
|
||||
Some(true) => "valid",
|
||||
Some(false) => "invalid",
|
||||
None => "unknown",
|
||||
};
|
||||
EpiphanyScratchPad {
|
||||
summary: finding.summary.clone(),
|
||||
hypothesis: Some(format!(
|
||||
"Accepted {mode} reorientation finding from {binding_id}; checkpoint validity is {checkpoint_validity}."
|
||||
)),
|
||||
next_probe: finding.next_safe_move.clone(),
|
||||
notes: vec![format!(
|
||||
"Files inspected: {}",
|
||||
if finding.files_inspected.is_empty() {
|
||||
"none reported".to_string()
|
||||
} else {
|
||||
finding.files_inspected.join(", ")
|
||||
}
|
||||
)],
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_finding_investigation_checkpoint(
|
||||
mut checkpoint: EpiphanyInvestigationCheckpoint,
|
||||
evidence_id: &str,
|
||||
code_refs: &[EpiphanyCodeRef],
|
||||
finding: &EpiphanyReorientAcceptanceFinding,
|
||||
) -> EpiphanyInvestigationCheckpoint {
|
||||
checkpoint.summary = finding.summary.clone().or(checkpoint.summary);
|
||||
checkpoint.next_action = finding.next_safe_move.clone().or(checkpoint.next_action);
|
||||
checkpoint.disposition = EpiphanyInvestigationDisposition::ResumeReady;
|
||||
if !checkpoint
|
||||
.evidence_ids
|
||||
.iter()
|
||||
.any(|existing| existing == evidence_id)
|
||||
{
|
||||
checkpoint.evidence_ids.push(evidence_id.to_string());
|
||||
}
|
||||
for code_ref in code_refs {
|
||||
if !checkpoint
|
||||
.code_refs
|
||||
.iter()
|
||||
.any(|existing| existing.path == code_ref.path)
|
||||
{
|
||||
checkpoint.code_refs.push(code_ref.clone());
|
||||
}
|
||||
}
|
||||
checkpoint
|
||||
}
|
||||
|
||||
fn json_string_field(value: &serde_json::Value, key: &str) -> Option<String> {
|
||||
value
|
||||
.get(key)
|
||||
|
|
@ -877,4 +1205,145 @@ mod tests {
|
|||
|
||||
assert!(reviewable.item_error.is_none());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builds_role_acceptance_bundle_from_runtime_identity() {
|
||||
let bundle = build_role_acceptance_bundle(
|
||||
"binding-modeling",
|
||||
EpiphanyRoleAcceptanceFinding {
|
||||
role_id: EpiphanyRoleResultRoleId::Modeling,
|
||||
verdict: Some("checkpoint-ready".to_string()),
|
||||
summary: Some("The map is source-grounded.".to_string()),
|
||||
next_safe_move: Some("Run verification.".to_string()),
|
||||
files_inspected: vec!["src/lib.rs".to_string(), "".to_string()],
|
||||
runtime_result_id: Some("result-123".to_string()),
|
||||
runtime_job_id: Some("job-123".to_string()),
|
||||
projected_fields: vec!["Graphs".to_string(), "InvestigationCheckpoint".to_string()],
|
||||
},
|
||||
"ev-modeling-test".to_string(),
|
||||
"obs-modeling-test".to_string(),
|
||||
"2026-05-12T00:00:00Z".to_string(),
|
||||
)
|
||||
.expect("role acceptance bundle should build");
|
||||
|
||||
assert_eq!(bundle.accepted_receipt_id, "accept-modeling-result-123");
|
||||
assert_eq!(bundle.evidence.kind, "modeling_result");
|
||||
assert_eq!(bundle.observation.source_kind, "modeling_result");
|
||||
assert_eq!(bundle.receipt.result_id, "result-123");
|
||||
assert_eq!(bundle.receipt.job_id, "job-123");
|
||||
assert_eq!(bundle.receipt.surface, "roleAccept");
|
||||
assert_eq!(bundle.receipt.role_id, "modeling");
|
||||
assert!(
|
||||
bundle
|
||||
.observation
|
||||
.summary
|
||||
.contains("Graphs, InvestigationCheckpoint")
|
||||
);
|
||||
assert_eq!(bundle.evidence.code_refs.len(), 1);
|
||||
assert_eq!(
|
||||
bundle.evidence.code_refs[0].path,
|
||||
PathBuf::from("src/lib.rs")
|
||||
);
|
||||
assert!(
|
||||
bundle.evidence.code_refs[0]
|
||||
.note
|
||||
.as_deref()
|
||||
.is_some_and(|note| note.contains("Modeling role worker"))
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn builds_reorient_acceptance_bundle_with_scratch_and_checkpoint() {
|
||||
let checkpoint = EpiphanyInvestigationCheckpoint {
|
||||
checkpoint_id: "checkpoint-1".to_string(),
|
||||
kind: "implementation".to_string(),
|
||||
disposition: EpiphanyInvestigationDisposition::RegatherRequired,
|
||||
focus: "runtime acceptance".to_string(),
|
||||
summary: Some("Old summary".to_string()),
|
||||
next_action: Some("Old move".to_string()),
|
||||
captured_at_turn_id: Some("turn-1".to_string()),
|
||||
open_questions: vec!["Which result owns acceptance?".to_string()],
|
||||
code_refs: vec![EpiphanyCodeRef {
|
||||
path: PathBuf::from("src/old.rs"),
|
||||
start_line: None,
|
||||
end_line: None,
|
||||
symbol: None,
|
||||
note: None,
|
||||
}],
|
||||
evidence_ids: vec!["ev-old".to_string()],
|
||||
};
|
||||
|
||||
let bundle = build_reorient_acceptance_bundle(
|
||||
"reorient-worker",
|
||||
EpiphanyReorientAcceptanceFinding {
|
||||
mode: Some("resume".to_string()),
|
||||
summary: Some("The checkpoint can resume.".to_string()),
|
||||
next_safe_move: Some("Continue the migration.".to_string()),
|
||||
checkpoint_still_valid: Some(true),
|
||||
files_inspected: vec!["src/new.rs".to_string()],
|
||||
runtime_result_id: Some("result-reorient".to_string()),
|
||||
runtime_job_id: Some("job-reorient".to_string()),
|
||||
},
|
||||
"ev-reorient-test".to_string(),
|
||||
"obs-reorient-test".to_string(),
|
||||
"2026-05-12T00:00:00Z".to_string(),
|
||||
true,
|
||||
Some(checkpoint),
|
||||
)
|
||||
.expect("reorient acceptance bundle should build");
|
||||
|
||||
assert_eq!(
|
||||
bundle.accepted_receipt_id,
|
||||
"accept-reorient-result-reorient"
|
||||
);
|
||||
assert_eq!(bundle.receipt.surface, "reorientAccept");
|
||||
assert_eq!(bundle.evidence.kind, "reorient_result");
|
||||
assert!(
|
||||
bundle
|
||||
.observation
|
||||
.summary
|
||||
.contains("checkpoint still valid")
|
||||
);
|
||||
let scratch = bundle.scratch.expect("scratch should be updated");
|
||||
assert_eq!(
|
||||
scratch.summary.as_deref(),
|
||||
Some("The checkpoint can resume.")
|
||||
);
|
||||
assert_eq!(
|
||||
scratch.next_probe.as_deref(),
|
||||
Some("Continue the migration.")
|
||||
);
|
||||
let checkpoint = bundle
|
||||
.investigation_checkpoint
|
||||
.expect("checkpoint should be updated");
|
||||
assert_eq!(
|
||||
checkpoint.disposition,
|
||||
EpiphanyInvestigationDisposition::ResumeReady
|
||||
);
|
||||
assert_eq!(
|
||||
checkpoint.summary.as_deref(),
|
||||
Some("The checkpoint can resume.")
|
||||
);
|
||||
assert!(
|
||||
checkpoint
|
||||
.evidence_ids
|
||||
.iter()
|
||||
.any(|id| id == "ev-reorient-test")
|
||||
);
|
||||
assert!(checkpoint.code_refs.iter().any(|code_ref| {
|
||||
code_ref.path == PathBuf::from("src/new.rs")
|
||||
&& code_ref
|
||||
.note
|
||||
.as_deref()
|
||||
.is_some_and(|note| note.contains("reorientation worker"))
|
||||
}));
|
||||
}
|
||||
}
|
||||
use codex_protocol::protocol::EpiphanyAcceptanceReceipt;
|
||||
use codex_protocol::protocol::EpiphanyCodeRef;
|
||||
use codex_protocol::protocol::EpiphanyEvidenceRecord;
|
||||
use codex_protocol::protocol::EpiphanyInvestigationCheckpoint;
|
||||
use codex_protocol::protocol::EpiphanyInvestigationDisposition;
|
||||
use codex_protocol::protocol::EpiphanyObservation;
|
||||
use codex_protocol::protocol::EpiphanyScratchPad;
|
||||
use std::path::PathBuf;
|
||||
|
|
|
|||
|
|
@ -36,7 +36,7 @@ The spine exists in more than twenty-five live paths:
|
|||
- reorientation policy: the `reorient` view lens reuses the same live/stored thread view plus mapped pressure/freshness/watcher signals, and derives a bounded `resume`/`regather` verdict with checkpoint-path/frontier reasons without mutating, compacting, scheduling, notifying, or continuing work in [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4514), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4394), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:11424).
|
||||
- CRRC coordinator recommendation: the `crrc` view lens reuses pressure/freshness/watcher/reorientation mapping plus the fixed `reorient-worker` binding and result read-back helper, recognizes already accepted reorientation findings so an accepted result is not recommended for acceptance again, and calls pure `epiphany-core` CRRC policy to return one bounded recommendation such as continue, prepare checkpoint, launch worker, wait, review, accept, or regather manually without mutating, launching, accepting, compacting, notifying, scheduling, or silently continuing work in [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4661), [crrc.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/crrc.rs:60), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4546).
|
||||
- role ownership projection: the `roles` view lens reuses the same state/jobs/pressure/reorient/result/CRRC signals as the coordinator loop, and projects implementation, Imagination/planning, modeling/checkpoint, verification/review, and reorientation lanes with owner roles, status, linked jobs, authority scopes, and recommended scene actions without launching, scheduling, accepting, compacting, notifying, or mutating state. App-server adapts concrete protocol jobs and thread state, while the pure role-board projection policy now lives in [role_board.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/role_board.rs:70).
|
||||
- role specialist launch/read-back/acceptance: app-server declares experimental `thread/epiphany/roleLaunch`, read-only `thread/epiphany/roleResult`, and write-gated `thread/epiphany/roleAccept`. `roleLaunch` accepts fixed Imagination/planning, modeling/checkpoint, and verification/review role ids, builds bounded specialist payloads from authoritative Epiphany state, routes them through the heartbeat-backed `epiphany_launch_job` seam, opens a typed runtime-spine job receipt, and emits the normal `jobLaunch` state update for `jobBindings` only. `roleResult` resolves heartbeat bindings through typed runtime-spine job results and seals legacy `agent_jobs` bindings, then adapts worker JSON through core role-result interpretation in [role_result.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/role_result.rs:45), projecting structured output as a reviewable finding with verdict, summary, next safe move, inspected files, frontier/evidence ids, optional `statePatch`, optional `selfPatch`, coordinator `selfPersistence` review, and errors without mutation, promotion, scheduling, or hidden continuation. `selfPatch` is a Ghostlight-shaped lane-memory request, not project truth: core accepts only role-matched, bounded, evidence-grounded memory/goal/value/private-note mutations and refuses objectives, graphs, checkpoints, scratch, planning, jobs, authority, code edits, or raw transcripts with reasons. `roleAccept` accepts completed heartbeat findings from typed runtime-spine results, accepts completed Imagination findings only when they contain a valid planning-only patch with draft Objective Draft review gates, accepts completed modeling/checkpoint findings only with a modeling-safe `statePatch`, applies accepted project patches through the existing Epiphany state validator, appends audit observation/evidence, and carries the same `selfPersistence` review. GUI/coordinator accept paths then apply accepted `selfPatch` requests to typed CultCache role dossiers in `state/agents.msgpack` through the native `epiphany-agent-memory-store` binary. Implementation stays owned by the main coding agent, verification output remains review-only, and reorientation stays on the CRRC-specific `reorientLaunch` / `reorientResult` / `reorientAccept` path.
|
||||
- role specialist launch/read-back/acceptance: app-server declares experimental `thread/epiphany/roleLaunch`, read-only `thread/epiphany/roleResult`, and write-gated `thread/epiphany/roleAccept`. `roleLaunch` accepts fixed Imagination/planning, modeling/checkpoint, and verification/review role ids, builds bounded specialist payloads from authoritative Epiphany state, routes them through the heartbeat-backed `epiphany_launch_job` seam, opens a typed runtime-spine job receipt, and emits the normal `jobLaunch` state update for `jobBindings` only. `roleResult` resolves heartbeat bindings through typed runtime-spine job results and seals legacy `agent_jobs` bindings, then adapts worker JSON through core role-result interpretation in [role_result.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/role_result.rs:45), projecting structured output as a reviewable finding with verdict, summary, next safe move, inspected files, frontier/evidence ids, optional `statePatch`, optional `selfPatch`, coordinator `selfPersistence` review, and errors without mutation, promotion, scheduling, or hidden continuation. `selfPatch` is a Ghostlight-shaped lane-memory request, not project truth: core accepts only role-matched, bounded, evidence-grounded memory/goal/value/private-note mutations and refuses objectives, graphs, checkpoints, scratch, planning, jobs, authority, code edits, or raw transcripts with reasons. `roleAccept` accepts completed heartbeat findings from typed runtime-spine results, accepts completed Imagination findings only when they contain a valid planning-only patch with draft Objective Draft review gates, accepts completed modeling/checkpoint findings only with a modeling-safe `statePatch`, applies accepted project patches through the existing Epiphany state validator, and uses core acceptance bundle policy to build the audit observation, evidence, and typed receipt. GUI/coordinator accept paths then apply accepted `selfPatch` requests to typed CultCache role dossiers in `state/agents.msgpack` through the native `epiphany-agent-memory-store` binary. Implementation stays owned by the main coding agent, verification output remains review-only, and reorientation stays on the CRRC-specific `reorientLaunch` / `reorientResult` / `reorientAccept` path.
|
||||
- shared prompt memory projection and role dossiers: the prompt config now carries `[shared].persistent_memory` in [epiphany_specialists.toml](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/prompts/epiphany_specialists.toml:2). App-server parses that block, prepends it through `epiphany_agent_prompt_with_memory`, and therefore projects the same Ghostlight-derived memory into fixed role specialist instructions, reorientation-worker instructions, coordinator notes, and CRRC checkpoint steering. The base `<epiphany_state>` doctrine reinforces the Perfect Machine rule through [prompt.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/prompt.rs:31) and [epiphany_doctrine.md](E:/Projects/EpiphanyAgent/epiphany-core/src/prompts/epiphany_doctrine.md:1). Individual Ghostlight-shaped role dossiers now live in typed CultCache `state/agents.msgpack`, and the native `epiphany-agent-memory-store` binary validates, reviews, and applies bounded self-memory patches through the Rust store.
|
||||
- fixed-lane coordinator: the `coordinator` view lens composes role, pressure, reorient, CRRC, role result, and reorient result signals, and returns one current action without mutation. App-server assembles host/protocol inputs, but the pure fixed-lane decision ladder now lives in `epiphany-core` in [coordinator.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/coordinator.rs:132). Review acceptance and implementation clearance are intentionally different: an accepted verification finding clears implementation only when the verifier verdict is `pass`; accepted `needs-evidence`, `needs-review`, or `fail` findings route back toward modeling/checkpoint strengthening before code work resumes. `regatherManually` is now fallback, not a supervisor-puppeteering excuse: completed unaccepted modeling findings stop at `reviewModelingResult`, modeling acceptance precedes verification, and fixed lane actions are considered before manual regather.
|
||||
- MVP operator view: native `epiphany-mvp-status` launches app-server over stdio, starts or reads one thread, gathers scene, planning, pressure, reorient, jobs, roles, Imagination/modeling/verification role results, reorient result, CRRC responses, heartbeat, and Face bubble artifacts, and renders them as text or JSON so the loop can be dogfooded without Python owning the product surface.
|
||||
|
|
@ -44,7 +44,7 @@ The spine exists in more than twenty-five live paths:
|
|||
- Agent function/API telemetry: native `epiphany-agent-telemetry` mechanically parses sealed AppServerClient JSONL transcripts into operator-safe telemetry with method counts, request shape, job/status/path fields, and visible function/tool names while sealing text, turn items, raw results, and direct agent messages.
|
||||
- reorientation launch: app-server now declares experimental `thread/epiphany/reorientLaunch`, requires a loaded thread plus durable investigation checkpoint, consumes the live reorientation verdict, and launches one fixed `reorient-worker` binding through the existing job-control seam with explicit resume-versus-regather scope, checkpoint-derived payload, and structured-output expectations instead of pretending CRRC suddenly grew a scheduler in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:370), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4575), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4519).
|
||||
- reorientation result read-back: app-server now declares experimental read-only `thread/epiphany/reorientResult`, defaults to the fixed `reorient-worker` binding, resolves heartbeat bindings through typed runtime-spine job results, seals legacy `agent_jobs` bindings, and projects a reviewable finding with mode, summary, next safe move, checkpoint-validity flag, inspected files, frontier ids, evidence ids, raw result, and any errors without mutating state, promoting evidence, or scheduling follow-up work.
|
||||
- reorientation finding acceptance: app-server now declares experimental `thread/epiphany/reorientAccept`, requires a loaded thread and a completed `reorient-worker` result, accepts heartbeat-backed results from typed runtime-spine receipts before falling back to old bindings, appends accepted observation/evidence records, optionally banks the finding into scratch and the durable investigation checkpoint, persists through the normal typed update path, and emits `thread/epiphany/stateUpdated` with source `reorientAccept` without accepting pending work, auto-promoting arbitrary worker output, launching follow-up work, or silently continuing implementation in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:378), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4635), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4885).
|
||||
- reorientation finding acceptance: app-server now declares experimental `thread/epiphany/reorientAccept`, requires a loaded thread and a completed `reorient-worker` result, accepts heartbeat-backed results from typed runtime-spine receipts before falling back to old bindings, uses core acceptance bundle policy to build accepted observation/evidence/receipt payloads plus optional scratch and durable investigation-checkpoint updates, persists through the normal typed update path, and emits `thread/epiphany/stateUpdated` with source `reorientAccept` without accepting pending work, auto-promoting arbitrary worker output, launching follow-up work, or silently continuing implementation in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:378), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4635), [role_result.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/role_result.rs:150), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4885).
|
||||
- retrieval/indexing: app-server routes `thread/epiphany/retrieve` and `thread/epiphany/index` through loaded `CodexThread` host methods into `epiphany-core` in [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4356), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4432), [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:467), and [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:449).
|
||||
|
||||
The thick Epiphany-owned implementation is mostly outside vendored Codex now:
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ remembers doctrine; the branch remembers the blade.
|
|||
## Current Orientation
|
||||
|
||||
- Do not copy exact branch or HEAD from this note. Run `git status --short --branch` and `git log --oneline -5`.
|
||||
- Top priority is still foundation cleanup, not outward feature work. Read `notes/epiphany-architectural-teardown.md` before touching Epiphany control-plane code. The May 2026 suspicion pass found that the app-server Epiphany control plane had become architectural Jenga: too much policy, projection, lifecycle glue, prompt packet assembly, coordinator sequencing, and test authority lives in `vendor/codex/codex-rs/app-server/src/codex_message_processor.rs`. The rebuild has begun: pressure policy, pure CRRC recommendation policy, fixed-lane coordinator decision policy, role-board projection policy, and role-result interpretation/self-persistence review policy moved into `epiphany-core`, typed acceptance receipts replaced summary-string identity for live accept paths, runtime links are dual-written on launch, and result read-back now prefers runtime links.
|
||||
- Top priority is still foundation cleanup, not outward feature work. Read `notes/epiphany-architectural-teardown.md` before touching Epiphany control-plane code. The May 2026 suspicion pass found that the app-server Epiphany control plane had become architectural Jenga: too much policy, projection, lifecycle glue, prompt packet assembly, coordinator sequencing, and test authority lives in `vendor/codex/codex-rs/app-server/src/codex_message_processor.rs`. The rebuild has begun: pressure policy, pure CRRC recommendation policy, fixed-lane coordinator decision policy, role-board projection policy, role-result interpretation/self-persistence review policy, and role/reorient acceptance bundle policy moved into `epiphany-core`, typed acceptance receipts replaced summary-string identity for live accept paths, runtime links are dual-written on launch, and result read-back now prefers runtime links.
|
||||
- Read `notes/epiphany-ideal-architecture-rebuild-plan.md` immediately after the teardown. It defines the smallest coherent replacement architecture: durable `EpiphanyState`, runtime-spine-owned `RuntimeState`, separate role memory/heartbeat state, `epiphany-core` as policy owner, app-server as adapter, Aquarium as reflector, typed acceptance receipts, and derived view lenses instead of a protocol verb zoo.
|
||||
- Do not continue Aquarium UI, bridge, Face, or dogfood expansion until the teardown has a source-grounded cleanup slice plan. Epiphany is the foundation; patches on patches are not a purification rite, they are how the altar becomes load-bearing garbage.
|
||||
- Phase 1 through Phase 5 are complete enough.
|
||||
|
|
@ -368,14 +368,16 @@ The next real move is still foundation cleanup. Start from
|
|||
Phase 6 bridge/UI trail. Landed rebuild cuts: `epiphany-core/src/surfaces/`
|
||||
exists, pressure view derivation/tests, pure CRRC recommendation policy/tests,
|
||||
fixed-lane coordinator decision policy/tests, role-board projection policy/tests,
|
||||
and role-result interpretation/self-persistence review policy/tests live in core, live acceptance writes typed receipts keyed by runtime result id,
|
||||
role-result interpretation/self-persistence review policy/tests, and role/reorient
|
||||
acceptance bundle policy/tests live in core, live acceptance writes typed receipts keyed by runtime result id,
|
||||
summary-string acceptance identity is gone for live paths, launches dual-write
|
||||
runtime links, result read-back prefers those runtime links, normal public
|
||||
`raw_result` is sealed, MVP consumers use `thread/epiphany/view`, heartbeat
|
||||
cognition is quarantined, and the old scene/jobs/roles/planning/pressure/reorient/
|
||||
CRRC/coordinator read wrappers are deleted. The next cut is acceptance/application
|
||||
policy extraction into `epiphany-core`, followed by runtime/job lifecycle mirror
|
||||
cleanup. No Agile confetti. No new balcony on the swaying tower.
|
||||
CRRC/coordinator read wrappers are deleted. The next cut is runtime/job lifecycle
|
||||
mirror cleanup: reassess whether `jobBindings` can shrink further or be deleted
|
||||
now that `runtime_links` and runtime-spine read-back own live result lookup. No
|
||||
Agile confetti. No new balcony on the swaying tower.
|
||||
|
||||
The Phase 6 freshness slice is landed. It exposes read-only
|
||||
`thread/epiphany/freshness` from live retrieval summaries plus graph
|
||||
|
|
|
|||
Binary file not shown.
|
|
@ -140,10 +140,10 @@ accepted_design:
|
|||
- Native `epiphany-mvp-status` is the first dogfood operator view: it starts or reads a thread through app-server and renders scene, planning, pressure, reorient, jobs, role result read-backs, reorient result, CRRC recommendation, heartbeat, Face bubbles, and MVP role lanes as text or machine output without becoming a state store. The old Python status module has been cut; native Rust/CultCache/CultNet surfaces are the product path.
|
||||
- The `roles` view lens is the harness-native role ownership surface: it projects implementation, Imagination/planning, modeling/checkpoint, verification/review, and reorientation lanes from authoritative typed state, bound jobs, pressure/reorient/CRRC, and worker result status without launching, scheduling, accepting, compacting, or mutating state.
|
||||
- `thread/epiphany/roleLaunch` and `thread/epiphany/roleResult` are the first explicit role-scoped specialist templates: Imagination/planning, modeling/checkpoint, and verification/review launch through fixed heartbeat-backed bindings with typed runtime-spine receipts and can be read back as reviewable findings from typed runtime-spine job results, while implementation stays owned by the main coding agent and reorientation stays on the CRRC-specific launch/result path.
|
||||
- `thread/epiphany/roleAccept` is the first review-gated role finding acceptance path: it accepts completed heartbeat-backed findings from typed runtime-spine results, accepts Imagination/planning findings only when they return a valid planning-only `statePatch` with draft Objective Draft review gates, accepts completed modeling/checkpoint findings only with a modeling-safe `statePatch`, appends audit observation/evidence, and rejects verification, implementation, reorientation, job binding, objective adoption, or broad authority fields.
|
||||
- `thread/epiphany/roleAccept` is the first review-gated role finding acceptance path: it accepts completed heartbeat-backed findings from typed runtime-spine results, accepts Imagination/planning findings only when they return a valid planning-only `statePatch` with draft Objective Draft review gates, accepts completed modeling/checkpoint findings only with a modeling-safe `statePatch`, builds accepted evidence/observation/receipt bundles through `epiphany-core`, and rejects verification, implementation, reorientation, job binding, objective adoption, or broad authority fields.
|
||||
- `thread/epiphany/reorientLaunch` is the first bounded runtime consumer over the reorientation verdict: it launches one fixed `reorient-worker` heartbeat binding with explicit resume-versus-regather scope, authority, and checkpoint-derived payload, without making the `reorient` view lens a writer or turning CRRC into an ambient scheduler.
|
||||
- `thread/epiphany/reorientResult` is the first bounded read-back surface for that worker: heartbeat-backed bindings read typed runtime-spine job results when present and otherwise report pending.
|
||||
- `thread/epiphany/reorientAccept` is the first explicit acceptance write for completed reorient-worker findings: it accepts completed heartbeat-backed findings from typed runtime-spine results, appends accepted observation/evidence records, can optionally update scratch and investigation checkpoint state, and emits `stateUpdated` with source `reorientAccept` without accepting pending work or launching follow-up work.
|
||||
- `thread/epiphany/reorientAccept` is the first explicit acceptance write for completed reorient-worker findings: it accepts completed heartbeat-backed findings from typed runtime-spine results, builds accepted evidence/observation/receipt/scratch/checkpoint bundles through `epiphany-core`, can optionally update scratch and investigation checkpoint state, and emits `stateUpdated` with source `reorientAccept` without accepting pending work or launching follow-up work.
|
||||
- After `thread/epiphany/reorientAccept`, CRRC recognizes the accepted reorientation finding and does not recommend accepting the same completed result again.
|
||||
- The old Python MVP dogfood runner has been cut. Auditable dogfood must use native coordinator/status/runtime-spine tools or a new typed Rust runner that completes heartbeat-owned runtime-spine job results.
|
||||
- Epiphany safety doctrine is to separate cognition from actuation, keep authority explicit, make interruption sacred, stage capability release, and treat operator misuse as a normal design input rather than a rude hypothetical. The machine must have brakes before it receives larger engines.
|
||||
|
|
@ -272,5 +272,5 @@ rejected_paths:
|
|||
reason: persistent state that accumulates every local truth becomes memory cruft and weakens rehydration
|
||||
|
||||
current_status:
|
||||
summary: Phase 1 durable state through Phase 6 coordinator/specialist/CRRC/backend organs are landed, and the May 2026 rebuild has started cutting the app-server control-plane tumor. Pressure policy now lives in `epiphany-core`; role/reorient acceptance writes typed `acceptance_receipts`; live duplicate-acceptance checks use runtime result receipt identity instead of summary strings; launch writes durable `runtime_links`; and role/reorient result read-back follows runtime links before falling back to legacy bindings.
|
||||
next_action: Continue the teardown/rebuild migration from `notes/epiphany-ideal-architecture-rebuild-plan.md`. Landed cuts now shrink `jobBindings`, remove normal public `raw_result`, add the canonical `thread/epiphany/view` lens wrapper, migrate MVP consumers, quarantine heartbeat cognition blobs, delete the old scene/jobs/roles/planning/pressure/reorient/CRRC/coordinator read wrappers, and move pure CRRC, fixed-lane coordinator decision policy, role-board projection policy, and role-result interpretation/self-persistence review policy into `epiphany-core`. The next bounded cut is to finish extracting acceptance/application policy from app-server into `epiphany-core`, then reassess runtime/job lifecycle mirror cleanup. Do not resume outward Aquarium/bridge/Face/dogfood expansion until this foundation cleanup is materially farther along.
|
||||
summary: Phase 1 durable state through Phase 6 coordinator/specialist/CRRC/backend organs are landed, and the May 2026 rebuild has started cutting the app-server control-plane tumor. Pressure, CRRC, coordinator, role-board, role-result interpretation/self-persistence review, and role/reorient acceptance bundle policy now live in `epiphany-core`; live duplicate-acceptance checks use runtime result receipt identity instead of summary strings; launch writes durable `runtime_links`; and role/reorient result read-back follows runtime links before falling back to legacy bindings.
|
||||
next_action: Continue the teardown/rebuild migration from `notes/epiphany-ideal-architecture-rebuild-plan.md`. Landed cuts now shrink `jobBindings`, remove normal public `raw_result`, add the canonical `thread/epiphany/view` lens wrapper, migrate MVP consumers, quarantine heartbeat cognition blobs, delete the old scene/jobs/roles/planning/pressure/reorient/CRRC/coordinator read wrappers, and move pure CRRC, fixed-lane coordinator decision policy, role-board projection policy, role-result interpretation/self-persistence review policy, and role/reorient acceptance bundle policy into `epiphany-core`. The next bounded cut is runtime/job lifecycle mirror cleanup: reassess `jobBindings` now that `runtime_links` and runtime-spine result read-back own the live lifecycle. Do not resume outward Aquarium/bridge/Face/dogfood expansion until this foundation cleanup is materially farther along.
|
||||
|
|
|
|||
|
|
@ -446,7 +446,6 @@ use codex_protocol::protocol::EpiphanyInvestigationCheckpoint;
|
|||
use codex_protocol::protocol::EpiphanyInvestigationDisposition;
|
||||
use codex_protocol::protocol::EpiphanyJobBinding;
|
||||
use codex_protocol::protocol::EpiphanyJobKind as CoreEpiphanyJobKind;
|
||||
use codex_protocol::protocol::EpiphanyObservation;
|
||||
use codex_protocol::protocol::EpiphanyPlanningState;
|
||||
use codex_protocol::protocol::EpiphanyRetrievalState;
|
||||
use codex_protocol::protocol::EpiphanyRetrievalStatus;
|
||||
|
|
@ -517,6 +516,8 @@ use epiphany_core::EpiphanyPressure;
|
|||
use epiphany_core::EpiphanyPressureBasis as CoreEpiphanyPressureBasis;
|
||||
use epiphany_core::EpiphanyPressureLevel as CoreEpiphanyPressureLevel;
|
||||
use epiphany_core::EpiphanyPressureStatus as CoreEpiphanyPressureStatus;
|
||||
use epiphany_core::EpiphanyReorientAcceptanceFinding;
|
||||
use epiphany_core::EpiphanyRoleAcceptanceFinding;
|
||||
use epiphany_core::EpiphanyRoleBoardCheckpointSummary;
|
||||
use epiphany_core::EpiphanyRoleBoardInput;
|
||||
use epiphany_core::EpiphanyRoleBoardJob;
|
||||
|
|
@ -530,6 +531,8 @@ use epiphany_core::EpiphanyRoleSelfPersistenceStatus as CoreEpiphanyRoleSelfPers
|
|||
use epiphany_core::EpiphanyRuntimeJobResult;
|
||||
use epiphany_core::EpiphanyRuntimeJobSnapshot;
|
||||
use epiphany_core::EpiphanyRuntimeJobStatus;
|
||||
use epiphany_core::build_reorient_acceptance_bundle;
|
||||
use epiphany_core::build_role_acceptance_bundle;
|
||||
use epiphany_core::coordinator_automation_action;
|
||||
use epiphany_core::derive_pressure_view;
|
||||
use epiphany_core::derive_role_board;
|
||||
|
|
@ -5104,71 +5107,41 @@ impl CodexMessageProcessor {
|
|||
}
|
||||
};
|
||||
|
||||
let accepted_kind = match role_id {
|
||||
ThreadEpiphanyRoleId::Imagination => "planning_synthesis",
|
||||
ThreadEpiphanyRoleId::Modeling => "modeling_result",
|
||||
ThreadEpiphanyRoleId::Verification => "verification_result",
|
||||
ThreadEpiphanyRoleId::Implementation | ThreadEpiphanyRoleId::Reorientation => {
|
||||
unreachable!("unsupported roles returned above")
|
||||
}
|
||||
};
|
||||
let accepted_prefix = epiphany_role_label(role_id);
|
||||
let runtime_result_id = match role_finding_runtime_result_id(&finding) {
|
||||
Some(result_id) => result_id,
|
||||
None => {
|
||||
self.send_invalid_request_error(
|
||||
request_id,
|
||||
"cannot accept role finding without a runtimeResultId".to_string(),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let runtime_job_id = match role_finding_runtime_job_id(&finding) {
|
||||
Some(job_id) => job_id,
|
||||
None => {
|
||||
self.send_invalid_request_error(
|
||||
request_id,
|
||||
"cannot accept role finding without a runtimeJobId".to_string(),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let accepted_receipt_id = format!("accept-{accepted_prefix}-{runtime_result_id}");
|
||||
let accepted_evidence_id = format!("ev-{accepted_prefix}-{}", Uuid::new_v4());
|
||||
let accepted_observation_id = format!("obs-{accepted_prefix}-{}", Uuid::new_v4());
|
||||
let code_refs = role_finding_code_refs(&finding);
|
||||
let evidence = EpiphanyEvidenceRecord {
|
||||
id: accepted_evidence_id.clone(),
|
||||
kind: accepted_kind.to_string(),
|
||||
status: "accepted".to_string(),
|
||||
summary: role_finding_summary(&finding),
|
||||
code_refs: code_refs.clone(),
|
||||
let projected_fields = epiphany_update_patch_changed_fields(&patch)
|
||||
.into_iter()
|
||||
.map(|field| format!("{field:?}"))
|
||||
.collect();
|
||||
let acceptance_bundle = match build_role_acceptance_bundle(
|
||||
&binding_id,
|
||||
EpiphanyRoleAcceptanceFinding {
|
||||
role_id: map_core_role_result_role_id(role_id),
|
||||
verdict: finding.verdict.clone(),
|
||||
summary: finding.summary.clone(),
|
||||
next_safe_move: finding.next_safe_move.clone(),
|
||||
files_inspected: finding.files_inspected.clone(),
|
||||
runtime_result_id: role_finding_runtime_result_id(&finding),
|
||||
runtime_job_id: role_finding_runtime_job_id(&finding),
|
||||
projected_fields,
|
||||
},
|
||||
accepted_evidence_id,
|
||||
accepted_observation_id,
|
||||
Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true),
|
||||
) {
|
||||
Ok(bundle) => bundle,
|
||||
Err(message) => {
|
||||
self.send_invalid_request_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let observation = EpiphanyObservation {
|
||||
id: accepted_observation_id.clone(),
|
||||
summary: role_finding_observation_summary(&finding),
|
||||
source_kind: accepted_kind.to_string(),
|
||||
status: "accepted".to_string(),
|
||||
code_refs,
|
||||
evidence_ids: vec![accepted_evidence_id.clone()],
|
||||
};
|
||||
patch.evidence.push(evidence);
|
||||
patch.observations.push(observation);
|
||||
patch.acceptance_receipts.push(EpiphanyAcceptanceReceipt {
|
||||
id: accepted_receipt_id.clone(),
|
||||
result_id: runtime_result_id,
|
||||
job_id: runtime_job_id,
|
||||
binding_id: binding_id.clone(),
|
||||
surface: "roleAccept".to_string(),
|
||||
role_id: accepted_prefix.to_string(),
|
||||
status: "accepted".to_string(),
|
||||
accepted_at: Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true),
|
||||
accepted_observation_id: Some(accepted_observation_id.clone()),
|
||||
accepted_evidence_id: Some(accepted_evidence_id.clone()),
|
||||
summary: finding.summary.clone(),
|
||||
});
|
||||
let accepted_receipt_id = acceptance_bundle.accepted_receipt_id.clone();
|
||||
let accepted_observation_id = acceptance_bundle.accepted_observation_id.clone();
|
||||
let accepted_evidence_id = acceptance_bundle.accepted_evidence_id.clone();
|
||||
patch.evidence.push(acceptance_bundle.evidence);
|
||||
patch.observations.push(acceptance_bundle.observation);
|
||||
patch.acceptance_receipts.push(acceptance_bundle.receipt);
|
||||
let changed_fields = epiphany_update_patch_changed_fields(&patch);
|
||||
let applied_patch = patch.clone();
|
||||
|
||||
|
|
@ -5749,59 +5722,36 @@ impl CodexMessageProcessor {
|
|||
|
||||
let accepted_evidence_id = format!("ev-reorient-{}", Uuid::new_v4());
|
||||
let accepted_observation_id = format!("obs-reorient-{}", Uuid::new_v4());
|
||||
let runtime_result_id = match reorient_finding_runtime_result_id(&finding) {
|
||||
Some(result_id) => result_id,
|
||||
None => {
|
||||
self.send_invalid_request_error(
|
||||
request_id,
|
||||
"cannot accept reorientation finding without a runtimeResultId".to_string(),
|
||||
)
|
||||
.await;
|
||||
let acceptance_bundle = match build_reorient_acceptance_bundle(
|
||||
&binding_id,
|
||||
EpiphanyReorientAcceptanceFinding {
|
||||
mode: finding.mode.clone(),
|
||||
summary: finding.summary.clone(),
|
||||
next_safe_move: finding.next_safe_move.clone(),
|
||||
checkpoint_still_valid: finding.checkpoint_still_valid,
|
||||
files_inspected: finding.files_inspected.clone(),
|
||||
runtime_result_id: reorient_finding_runtime_result_id(&finding),
|
||||
runtime_job_id: reorient_finding_runtime_job_id(&finding),
|
||||
},
|
||||
accepted_evidence_id,
|
||||
accepted_observation_id,
|
||||
Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true),
|
||||
update_scratch,
|
||||
update_investigation_checkpoint
|
||||
.then(|| state.investigation_checkpoint.clone())
|
||||
.flatten(),
|
||||
) {
|
||||
Ok(bundle) => bundle,
|
||||
Err(message) => {
|
||||
self.send_invalid_request_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let runtime_job_id = match reorient_finding_runtime_job_id(&finding) {
|
||||
Some(job_id) => job_id,
|
||||
None => {
|
||||
self.send_invalid_request_error(
|
||||
request_id,
|
||||
"cannot accept reorientation finding without a runtimeJobId".to_string(),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let accepted_receipt_id = format!("accept-reorient-{runtime_result_id}");
|
||||
let code_refs = reorient_finding_code_refs(&finding);
|
||||
let evidence = EpiphanyEvidenceRecord {
|
||||
id: accepted_evidence_id.clone(),
|
||||
kind: "reorient_result".to_string(),
|
||||
status: "accepted".to_string(),
|
||||
summary: reorient_finding_summary(&finding),
|
||||
code_refs: code_refs.clone(),
|
||||
};
|
||||
let observation = EpiphanyObservation {
|
||||
id: accepted_observation_id.clone(),
|
||||
summary: reorient_finding_observation_summary(&finding),
|
||||
source_kind: "reorient_result".to_string(),
|
||||
status: "accepted".to_string(),
|
||||
code_refs: code_refs.clone(),
|
||||
evidence_ids: vec![accepted_evidence_id.clone()],
|
||||
};
|
||||
|
||||
let scratch = update_scratch.then(|| reorient_finding_scratch(&binding_id, &finding));
|
||||
let investigation_checkpoint = if update_investigation_checkpoint {
|
||||
state.investigation_checkpoint.as_ref().map(|checkpoint| {
|
||||
reorient_finding_investigation_checkpoint(
|
||||
checkpoint,
|
||||
accepted_evidence_id.as_str(),
|
||||
code_refs.as_slice(),
|
||||
&finding,
|
||||
)
|
||||
})
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let accepted_receipt_id = acceptance_bundle.accepted_receipt_id.clone();
|
||||
let accepted_observation_id = acceptance_bundle.accepted_observation_id.clone();
|
||||
let accepted_evidence_id = acceptance_bundle.accepted_evidence_id.clone();
|
||||
let scratch = acceptance_bundle.scratch;
|
||||
let investigation_checkpoint = acceptance_bundle.investigation_checkpoint;
|
||||
|
||||
let mut changed_fields = vec![
|
||||
ThreadEpiphanyStateUpdatedField::AcceptanceReceipts,
|
||||
|
|
@ -5820,21 +5770,9 @@ impl CodexMessageProcessor {
|
|||
expected_revision,
|
||||
scratch,
|
||||
investigation_checkpoint,
|
||||
acceptance_receipts: vec![EpiphanyAcceptanceReceipt {
|
||||
id: accepted_receipt_id.clone(),
|
||||
result_id: runtime_result_id,
|
||||
job_id: runtime_job_id,
|
||||
binding_id: binding_id.clone(),
|
||||
surface: "reorientAccept".to_string(),
|
||||
role_id: "reorientation".to_string(),
|
||||
status: "accepted".to_string(),
|
||||
accepted_at: Utc::now().to_rfc3339_opts(SecondsFormat::Secs, true),
|
||||
accepted_observation_id: Some(accepted_observation_id.clone()),
|
||||
accepted_evidence_id: Some(accepted_evidence_id.clone()),
|
||||
summary: finding.summary.clone(),
|
||||
}],
|
||||
observations: vec![observation],
|
||||
evidence: vec![evidence],
|
||||
acceptance_receipts: vec![acceptance_bundle.receipt],
|
||||
observations: vec![acceptance_bundle.observation],
|
||||
evidence: vec![acceptance_bundle.evidence],
|
||||
..Default::default()
|
||||
})
|
||||
.await
|
||||
|
|
@ -14881,71 +14819,6 @@ fn role_finding_summary(finding: &ThreadEpiphanyRoleFinding) -> String {
|
|||
}
|
||||
}
|
||||
|
||||
fn role_finding_observation_summary(finding: &ThreadEpiphanyRoleFinding) -> String {
|
||||
let verdict = finding.verdict.as_deref().unwrap_or("unknown");
|
||||
let changed_fields = finding
|
||||
.state_patch
|
||||
.as_ref()
|
||||
.map(epiphany_update_patch_changed_fields)
|
||||
.unwrap_or_default()
|
||||
.into_iter()
|
||||
.map(|field| format!("{field:?}"))
|
||||
.collect::<Vec<_>>();
|
||||
let changed = if changed_fields.is_empty() {
|
||||
"no typed state fields projected".to_string()
|
||||
} else {
|
||||
changed_fields.join(", ")
|
||||
};
|
||||
format!(
|
||||
"Accepted {:?} role result with verdict {verdict}; projected fields: {changed}. {}",
|
||||
finding.role_id,
|
||||
role_finding_summary(finding)
|
||||
)
|
||||
}
|
||||
|
||||
fn role_finding_code_refs(finding: &ThreadEpiphanyRoleFinding) -> Vec<EpiphanyCodeRef> {
|
||||
finding
|
||||
.files_inspected
|
||||
.iter()
|
||||
.filter(|path| !path.trim().is_empty())
|
||||
.map(|path| EpiphanyCodeRef {
|
||||
path: PathBuf::from(path),
|
||||
start_line: None,
|
||||
end_line: None,
|
||||
symbol: None,
|
||||
note: Some(format!(
|
||||
"Inspected by accepted {:?} role worker.",
|
||||
finding.role_id
|
||||
)),
|
||||
})
|
||||
.collect()
|
||||
}
|
||||
|
||||
fn reorient_finding_summary(finding: &ThreadEpiphanyReorientFinding) -> String {
|
||||
let summary = finding
|
||||
.summary
|
||||
.clone()
|
||||
.unwrap_or_else(|| "Reorientation worker returned a structured finding.".to_string());
|
||||
if let Some(next_safe_move) = finding.next_safe_move.as_deref() {
|
||||
format!("{summary} Next safe move: {next_safe_move}")
|
||||
} else {
|
||||
summary
|
||||
}
|
||||
}
|
||||
|
||||
fn reorient_finding_observation_summary(finding: &ThreadEpiphanyReorientFinding) -> String {
|
||||
let mode = finding.mode.as_deref().unwrap_or("unknown");
|
||||
let validity = match finding.checkpoint_still_valid {
|
||||
Some(true) => "checkpoint still valid",
|
||||
Some(false) => "checkpoint requires regather",
|
||||
None => "checkpoint validity not reported",
|
||||
};
|
||||
format!(
|
||||
"Accepted {mode} reorientation result: {validity}. {}",
|
||||
reorient_finding_summary(finding)
|
||||
)
|
||||
}
|
||||
|
||||
fn reorient_finding_code_refs(finding: &ThreadEpiphanyReorientFinding) -> Vec<EpiphanyCodeRef> {
|
||||
finding
|
||||
.files_inspected
|
||||
|
|
|
|||
Reference in a new issue