Extract Epiphany scene projection into core

This commit is contained in:
Meta Vens 2026-05-12 21:43:33 +01:00
commit 8ad676017a
8 changed files with 687 additions and 226 deletions

View file

@ -190,6 +190,19 @@ pub use surfaces::EpiphanyRoleFindingInterpretation;
pub use surfaces::EpiphanyRoleResultRoleId;
pub use surfaces::EpiphanyRoleSelfPersistenceReview;
pub use surfaces::EpiphanyRoleSelfPersistenceStatus;
pub use surfaces::EpiphanyScene;
pub use surfaces::EpiphanySceneAction;
pub use surfaces::EpiphanySceneChurn;
pub use surfaces::EpiphanySceneGraph;
pub use surfaces::EpiphanySceneInput;
pub use surfaces::EpiphanySceneInvestigationCheckpoint;
pub use surfaces::EpiphanySceneRecord;
pub use surfaces::EpiphanySceneRecords;
pub use surfaces::EpiphanySceneRetrieval;
pub use surfaces::EpiphanySceneSource;
pub use surfaces::EpiphanySceneStateStatus;
pub use surfaces::EpiphanySceneStatusCount;
pub use surfaces::EpiphanySceneSubgoal;
pub use surfaces::EpiphanyViewInput;
pub use surfaces::EpiphanyViewLens;
pub use surfaces::EpiphanyViewOutput;
@ -202,6 +215,7 @@ pub use surfaces::derive_jobs;
pub use surfaces::derive_planning_view;
pub use surfaces::derive_pressure_view;
pub use surfaces::derive_role_board;
pub use surfaces::derive_scene;
pub use surfaces::imagination_role_state_patch_policy_errors;
pub use surfaces::interpret_role_finding;
pub use surfaces::modeling_role_state_patch_policy_errors;

View file

@ -7,6 +7,7 @@ mod pressure;
mod reorient;
mod role_board;
mod role_result;
mod scene;
pub use coordinator::EpiphanyCoordinatorAction;
pub use coordinator::EpiphanyCoordinatorAutomationAction;
@ -88,6 +89,20 @@ pub use role_result::interpret_role_finding;
pub use role_result::modeling_role_state_patch_policy_errors;
pub use role_result::review_role_self_patch;
pub use role_result::role_self_memory_target;
pub use scene::EpiphanyScene;
pub use scene::EpiphanySceneAction;
pub use scene::EpiphanySceneChurn;
pub use scene::EpiphanySceneGraph;
pub use scene::EpiphanySceneInput;
pub use scene::EpiphanySceneInvestigationCheckpoint;
pub use scene::EpiphanySceneRecord;
pub use scene::EpiphanySceneRecords;
pub use scene::EpiphanySceneRetrieval;
pub use scene::EpiphanySceneSource;
pub use scene::EpiphanySceneStateStatus;
pub use scene::EpiphanySceneStatusCount;
pub use scene::EpiphanySceneSubgoal;
pub use scene::derive_scene;
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyViewInput {

View file

@ -0,0 +1,460 @@
use codex_protocol::protocol::EpiphanyInvestigationDisposition;
use codex_protocol::protocol::EpiphanyRetrievalStatus;
use codex_protocol::protocol::EpiphanyThreadState;
use std::collections::BTreeMap;
use std::path::PathBuf;
pub const EPIPHANY_SCENE_RECORD_LIMIT: usize = 5;
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EpiphanySceneStateStatus {
Missing,
Ready,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EpiphanySceneSource {
Stored,
Live,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
pub enum EpiphanySceneAction {
Index,
Retrieve,
Distill,
Context,
Planning,
GraphQuery,
Jobs,
Roles,
Coordinator,
RoleLaunch,
RoleResult,
RoleAccept,
JobLaunch,
JobInterrupt,
Freshness,
Pressure,
Reorient,
Crrc,
ReorientLaunch,
ReorientResult,
ReorientAccept,
Propose,
Promote,
Update,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanySceneSubgoal {
pub id: String,
pub title: String,
pub status: String,
pub summary: Option<String>,
pub active: bool,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanySceneStatusCount {
pub status: String,
pub count: u32,
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct EpiphanySceneGraph {
pub architecture_node_count: u32,
pub architecture_edge_count: u32,
pub dataflow_node_count: u32,
pub dataflow_edge_count: u32,
pub link_count: u32,
pub active_node_ids: Vec<String>,
pub active_edge_ids: Vec<String>,
pub open_question_count: u32,
pub open_gap_count: u32,
pub dirty_paths: Vec<PathBuf>,
pub checkpoint_id: Option<String>,
pub checkpoint_summary: Option<String>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanySceneRetrieval {
pub workspace_root: PathBuf,
pub status: EpiphanyRetrievalStatus,
pub semantic_available: bool,
pub index_revision: Option<String>,
pub indexed_file_count: Option<u32>,
pub indexed_chunk_count: Option<u32>,
pub shard_count: u32,
pub dirty_path_count: u32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanySceneInvestigationCheckpoint {
pub checkpoint_id: String,
pub kind: String,
pub disposition: EpiphanyInvestigationDisposition,
pub focus: String,
pub summary: Option<String>,
pub next_action: Option<String>,
pub captured_at_turn_id: Option<String>,
pub open_question_count: u32,
pub code_ref_count: u32,
pub evidence_count: u32,
}
#[derive(Debug, Clone, PartialEq, Eq, Default)]
pub struct EpiphanySceneRecords {
pub total_count: u32,
pub latest: Vec<EpiphanySceneRecord>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanySceneRecord {
pub id: String,
pub kind: String,
pub status: String,
pub summary: String,
pub code_ref_count: u32,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanySceneChurn {
pub understanding_status: String,
pub diff_pressure: String,
pub graph_freshness: Option<String>,
pub warning: Option<String>,
pub unexplained_writes: Option<u32>,
}
#[derive(Debug, Clone, PartialEq, Eq)]
pub struct EpiphanyScene {
pub state_status: EpiphanySceneStateStatus,
pub source: EpiphanySceneSource,
pub revision: Option<u64>,
pub objective: Option<String>,
pub active_subgoal: Option<EpiphanySceneSubgoal>,
pub subgoals: Vec<EpiphanySceneSubgoal>,
pub invariant_status_counts: Vec<EpiphanySceneStatusCount>,
pub graph: EpiphanySceneGraph,
pub retrieval: Option<EpiphanySceneRetrieval>,
pub investigation_checkpoint: Option<EpiphanySceneInvestigationCheckpoint>,
pub observations: EpiphanySceneRecords,
pub evidence: EpiphanySceneRecords,
pub churn: Option<EpiphanySceneChurn>,
pub available_actions: Vec<EpiphanySceneAction>,
}
#[derive(Debug, Clone, Copy)]
pub struct EpiphanySceneInput<'a> {
pub state: Option<&'a EpiphanyThreadState>,
pub loaded: bool,
pub reorient_binding_id: &'a str,
}
pub fn derive_scene(input: EpiphanySceneInput<'_>) -> EpiphanyScene {
let source = if input.loaded {
EpiphanySceneSource::Live
} else {
EpiphanySceneSource::Stored
};
let state = input.state;
let available_actions = scene_available_actions(
input.loaded,
state.is_some(),
state
.and_then(|state| state.investigation_checkpoint.as_ref())
.is_some(),
state.is_some_and(|state| {
state
.job_bindings
.iter()
.any(|binding| binding.id == input.reorient_binding_id)
}),
);
let Some(state) = state else {
return EpiphanyScene {
state_status: EpiphanySceneStateStatus::Missing,
source,
revision: None,
objective: None,
active_subgoal: None,
subgoals: Vec::new(),
invariant_status_counts: Vec::new(),
graph: EpiphanySceneGraph::default(),
retrieval: None,
investigation_checkpoint: None,
observations: EpiphanySceneRecords::default(),
evidence: EpiphanySceneRecords::default(),
churn: None,
available_actions,
};
};
let subgoals = scene_subgoals(state);
let active_subgoal = subgoals.iter().find(|subgoal| subgoal.active).cloned();
EpiphanyScene {
state_status: EpiphanySceneStateStatus::Ready,
source,
revision: Some(state.revision),
objective: state.objective.clone(),
active_subgoal,
subgoals,
invariant_status_counts: status_counts(
state.invariants.iter().map(|item| item.status.as_str()),
),
graph: scene_graph(state),
retrieval: state
.retrieval
.as_ref()
.map(|retrieval| EpiphanySceneRetrieval {
workspace_root: retrieval.workspace_root.clone(),
status: retrieval.status,
semantic_available: retrieval.semantic_available,
index_revision: retrieval.index_revision.clone(),
indexed_file_count: retrieval.indexed_file_count,
indexed_chunk_count: retrieval.indexed_chunk_count,
shard_count: retrieval.shards.len() as u32,
dirty_path_count: retrieval.dirty_paths.len() as u32,
}),
investigation_checkpoint: state.investigation_checkpoint.as_ref().map(|checkpoint| {
EpiphanySceneInvestigationCheckpoint {
checkpoint_id: checkpoint.checkpoint_id.clone(),
kind: checkpoint.kind.clone(),
disposition: checkpoint.disposition,
focus: checkpoint.focus.clone(),
summary: checkpoint.summary.clone(),
next_action: checkpoint.next_action.clone(),
captured_at_turn_id: checkpoint.captured_at_turn_id.clone(),
open_question_count: checkpoint.open_questions.len() as u32,
code_ref_count: checkpoint.code_refs.len() as u32,
evidence_count: checkpoint.evidence_ids.len() as u32,
}
}),
observations: EpiphanySceneRecords {
total_count: state.observations.len() as u32,
latest: state
.observations
.iter()
.take(EPIPHANY_SCENE_RECORD_LIMIT)
.map(|observation| EpiphanySceneRecord {
id: observation.id.clone(),
kind: observation.source_kind.clone(),
status: observation.status.clone(),
summary: observation.summary.clone(),
code_ref_count: observation.code_refs.len() as u32,
})
.collect(),
},
evidence: EpiphanySceneRecords {
total_count: state.recent_evidence.len() as u32,
latest: state
.recent_evidence
.iter()
.take(EPIPHANY_SCENE_RECORD_LIMIT)
.map(|evidence| EpiphanySceneRecord {
id: evidence.id.clone(),
kind: evidence.kind.clone(),
status: evidence.status.clone(),
summary: evidence.summary.clone(),
code_ref_count: evidence.code_refs.len() as u32,
})
.collect(),
},
churn: state.churn.as_ref().map(|churn| EpiphanySceneChurn {
understanding_status: churn.understanding_status.clone(),
diff_pressure: churn.diff_pressure.clone(),
graph_freshness: churn.graph_freshness.clone(),
warning: churn.warning.clone(),
unexplained_writes: churn.unexplained_writes,
}),
available_actions,
}
}
fn scene_available_actions(
loaded: bool,
state_present: bool,
checkpoint_present: bool,
reorient_binding_present: bool,
) -> Vec<EpiphanySceneAction> {
if !loaded {
return Vec::new();
}
let mut actions = vec![
EpiphanySceneAction::Index,
EpiphanySceneAction::Retrieve,
EpiphanySceneAction::Distill,
EpiphanySceneAction::Context,
EpiphanySceneAction::Planning,
EpiphanySceneAction::GraphQuery,
EpiphanySceneAction::Jobs,
EpiphanySceneAction::Roles,
EpiphanySceneAction::Coordinator,
EpiphanySceneAction::RoleLaunch,
EpiphanySceneAction::RoleResult,
EpiphanySceneAction::RoleAccept,
EpiphanySceneAction::JobLaunch,
EpiphanySceneAction::Freshness,
EpiphanySceneAction::Pressure,
EpiphanySceneAction::Reorient,
EpiphanySceneAction::Crrc,
];
if checkpoint_present {
actions.push(EpiphanySceneAction::ReorientLaunch);
}
if reorient_binding_present {
actions.push(EpiphanySceneAction::ReorientResult);
actions.push(EpiphanySceneAction::ReorientAccept);
}
actions.push(EpiphanySceneAction::Update);
if state_present {
actions.push(EpiphanySceneAction::JobInterrupt);
actions.push(EpiphanySceneAction::Propose);
actions.push(EpiphanySceneAction::Promote);
}
actions
}
fn scene_subgoals(state: &EpiphanyThreadState) -> Vec<EpiphanySceneSubgoal> {
let active_id = state.active_subgoal_id.as_deref();
state
.subgoals
.iter()
.map(|subgoal| EpiphanySceneSubgoal {
id: subgoal.id.clone(),
title: subgoal.title.clone(),
status: subgoal.status.clone(),
summary: subgoal.summary.clone(),
active: active_id == Some(subgoal.id.as_str()),
})
.collect()
}
fn scene_graph(state: &EpiphanyThreadState) -> EpiphanySceneGraph {
let frontier = state.graph_frontier.as_ref();
let checkpoint = state.graph_checkpoint.as_ref();
EpiphanySceneGraph {
architecture_node_count: state.graphs.architecture.nodes.len() as u32,
architecture_edge_count: state.graphs.architecture.edges.len() as u32,
dataflow_node_count: state.graphs.dataflow.nodes.len() as u32,
dataflow_edge_count: state.graphs.dataflow.edges.len() as u32,
link_count: state.graphs.links.len() as u32,
active_node_ids: frontier
.map(|frontier| frontier.active_node_ids.clone())
.unwrap_or_default(),
active_edge_ids: frontier
.map(|frontier| frontier.active_edge_ids.clone())
.unwrap_or_default(),
open_question_count: frontier
.map(|frontier| frontier.open_question_ids.len() as u32)
.unwrap_or_default(),
open_gap_count: frontier
.map(|frontier| frontier.open_gap_ids.len() as u32)
.unwrap_or_default(),
dirty_paths: frontier
.map(|frontier| frontier.dirty_paths.clone())
.unwrap_or_default(),
checkpoint_id: checkpoint.map(|checkpoint| checkpoint.checkpoint_id.clone()),
checkpoint_summary: checkpoint.and_then(|checkpoint| checkpoint.summary.clone()),
}
}
fn status_counts<'a>(statuses: impl Iterator<Item = &'a str>) -> Vec<EpiphanySceneStatusCount> {
let mut counts = BTreeMap::<String, u32>::new();
for status in statuses {
*counts.entry(status.to_string()).or_default() += 1;
}
counts
.into_iter()
.map(|(status, count)| EpiphanySceneStatusCount { status, count })
.collect()
}
#[cfg(test)]
mod tests {
use super::*;
use codex_protocol::protocol::EpiphanyInvariant;
use codex_protocol::protocol::EpiphanyJobBinding;
use codex_protocol::protocol::EpiphanyJobKind;
use codex_protocol::protocol::EpiphanySubgoal;
#[test]
fn missing_stored_scene_has_no_actions() {
let scene = derive_scene(EpiphanySceneInput {
state: None,
loaded: false,
reorient_binding_id: "reorient-worker",
});
assert_eq!(scene.state_status, EpiphanySceneStateStatus::Missing);
assert_eq!(scene.source, EpiphanySceneSource::Stored);
assert!(scene.available_actions.is_empty());
}
#[test]
fn live_scene_projects_state_and_actions() {
let state = EpiphanyThreadState {
revision: 4,
objective: Some("purify".to_string()),
active_subgoal_id: Some("subgoal-1".to_string()),
subgoals: vec![EpiphanySubgoal {
id: "subgoal-1".to_string(),
title: "cut".to_string(),
status: "active".to_string(),
summary: Some("current cut".to_string()),
}],
invariants: vec![
EpiphanyInvariant {
id: "inv-1".to_string(),
description: "ready".to_string(),
status: "ready".to_string(),
rationale: None,
},
EpiphanyInvariant {
id: "inv-2".to_string(),
description: "ready".to_string(),
status: "ready".to_string(),
rationale: None,
},
],
job_bindings: vec![EpiphanyJobBinding {
id: "reorient-worker".to_string(),
kind: EpiphanyJobKind::Specialist,
scope: "reorient".to_string(),
owner_role: "life".to_string(),
authority_scope: None,
linked_subgoal_ids: Vec::new(),
linked_graph_node_ids: Vec::new(),
blocking_reason: None,
}],
..Default::default()
};
let scene = derive_scene(EpiphanySceneInput {
state: Some(&state),
loaded: true,
reorient_binding_id: "reorient-worker",
});
assert_eq!(scene.state_status, EpiphanySceneStateStatus::Ready);
assert_eq!(scene.revision, Some(4));
assert_eq!(
scene.active_subgoal.as_ref().map(|item| item.active),
Some(true)
);
assert_eq!(scene.invariant_status_counts[0].count, 2);
assert!(
scene
.available_actions
.contains(&EpiphanySceneAction::ReorientResult)
);
assert!(
scene
.available_actions
.contains(&EpiphanySceneAction::Promote)
);
}
}

View file

@ -22,7 +22,7 @@ The spine exists in more than twenty-five live paths:
- explicit promotion gates: app-server routes `thread/epiphany/promote` through a loaded-thread handler into `epiphany-core` policy evaluation, rejects failed verifier evidence without mutation, applies accepted candidates through the same durable update path, and now treats medium/high/expanded/broadening/semantic churn deltas as needing explicit rationale plus stronger verifier evidence whose kind is token-matched rather than substring-matched; the same gate also validates durable investigation-checkpoint packets, including linked evidence ids, before they can be inked into state in [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4501) and [promotion.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/promotion.rs:33).
- explicit state updates: app-server routes `thread/epiphany/update` through a loaded `CodexThread` update method that rejects malformed appended observation/evidence graph records and structurally invalid replacement fields, including investigation checkpoints that cite missing evidence and planning records with broken ids/source refs/backlog links/draft acceptance criteria, mutates live `SessionState` only after validation, bumps the revision, and persists an immediate `RolloutItem::EpiphanyState` snapshot in [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4620), [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:376), [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:552), [codex_thread.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/core/src/codex_thread.rs:1294), and [promotion.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/promotion.rs:44).
- live state notifications and write responses: app-server declares experimental `thread/epiphany/stateUpdated` and emits it with the updated typed state, typed `source`, event-level `revision`, and typed `changedFields` after successful direct updates and accepted promotions, but not after rejected promotions; direct `thread/epiphany/update` and accepted `thread/epiphany/promote` responses expose the same revision/change metadata, accepted promotions always report `Evidence` because verifier evidence is appended even when the patch evidence list is empty, and successful write response/notification states now use the same client-visible live projection as `thread/read`, including retrieval-summary backfill when durable state has no persisted retrieval metadata, in [common.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/common.rs:1113), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4354), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4419), [v2.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server-protocol/src/protocol/v2.rs:4428), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4555), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4608), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4652), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:4693), [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:11327), and [codex_message_processor.rs](E:/Projects/EpiphanyAgent/vendor/codex/codex-rs/app-server/src/codex_message_processor.rs:11370).
- scene projection: the `scene` view lens reads the same live/stored Epiphany state view used by `thread/read` and derives a compact client scene with objective, active subgoal, invariant status counts, graph focus/counts, retrieval status, investigation-checkpoint summary counts, observation/evidence summaries, churn, live/stored source, and available control-plane actions without mutating or persisting state.
- scene projection: the `scene` view lens reads the same live/stored Epiphany state view used by `thread/read` and adapts the core scene projection. `epiphany-core` derives the compact client scene with objective, active subgoal, invariant status counts, graph focus/counts, retrieval status, investigation-checkpoint summary counts, observation/evidence summaries, churn, live/stored source, and available control-plane actions without mutating or persisting state in [scene.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/scene.rs:1).
- job/progress reflection: the `jobs` view lens reads the same thread view as scene, optionally fills retrieval state for loaded threads with no Epiphany state, and adapts core-derived non-authoritative progress slots for retrieval indexing, graph remap, invariant verification, and bound specialist work. Durable `job_bindings` now act as thin Epiphany-owned authority slots with binding id, kind, scope, owner role, authority scope, linked ids, and optional blocking reason only. Runtime job ids project from `runtime_links` through core job view policy; old `agent_jobs` bindings are sealed instead of live-crawled in [jobs.rs](E:/Projects/EpiphanyAgent/epiphany-core/src/surfaces/jobs.rs:1).
- bound-job progress notifications: app-server still declares experimental `thread/epiphany/jobsUpdated` as sealed legacy Codex evacuation telemetry, but the handler no longer emits Epiphany updates from old `agent_job_progress:{json}` background events. Heartbeat-owned activation and typed runtime-spine receipts are now the live Epiphany path.
- explicit job control: app-server declares experimental `thread/epiphany/jobLaunch` and `thread/epiphany/jobInterrupt`, routes them through core launch/interrupt handlers that persist heartbeat-backed durable `job_bindings` revisions through the authoritative Epiphany state path, and emit `thread/epiphany/stateUpdated` with source `jobLaunch` or `jobInterrupt` instead of creating SQLite `agent_jobs` rows or pretending jobs reflection is the scheduler.

View file

@ -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: freshness derivation, pressure policy, job/progress view derivation, planning view derivation, reorientation resume/regather verdict 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.
- 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: scene projection, freshness derivation, pressure policy, job/progress view derivation, planning view derivation, reorientation resume/regather verdict 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.
@ -369,7 +369,7 @@ 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,
role-result interpretation/self-persistence review policy/tests, and role/reorient
acceptance bundle policy/tests, freshness derivation/tests, planning view derivation/tests, reorientation resume/regather verdict policy/tests, and job/progress view derivation/tests live in core, live acceptance writes typed receipts keyed by runtime result id,
acceptance bundle policy/tests, scene projection/tests, freshness derivation/tests, planning view derivation/tests, reorientation resume/regather verdict policy/tests, and job/progress view derivation/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

Binary file not shown.

View file

@ -100,7 +100,7 @@ accepted_design:
- `thread/epiphany/retrieve`, `thread/epiphany/distill`, `thread/epiphany/propose`, `thread/epiphany/freshness`, `thread/epiphany/context`, `thread/epiphany/graphQuery`, and `thread/epiphany/view` stay read-only.
- `thread/epiphany/index` writes the retrieval catalog, not durable Epiphany understanding; catalog is auspex output, not doctrine.
- Qdrant is the preferred persistent semantic backend; BM25 remains the bootstrap/fallback/control path.
- `epiphany-core` owns prompt rendering, rollout replay helpers, retrieval/indexing, distillation, proposal, promotion policy, freshness derivation, pressure derivation, job/progress view derivation, planning view derivation, reorientation resume/regather verdict policy, pure CRRC recommendation policy, fixed-lane coordinator decision policy, role-board projection policy, and role-result interpretation/self-persistence review policy where possible.
- `epiphany-core` owns prompt rendering, rollout replay helpers, retrieval/indexing, distillation, proposal, promotion policy, scene projection, freshness derivation, pressure derivation, job/progress view derivation, planning view derivation, reorientation resume/regather verdict policy, pure CRRC recommendation policy, fixed-lane coordinator decision policy, role-board projection policy, and role-result interpretation/self-persistence review policy where possible.
- Vendored Codex keeps the thin typed host seam: protocol types, thread bridges, app-server protocol, request routing, and rollout integration.
- The current algorithmic map is the source-grounded description of live control flow.
- Compact-Rehydrate-Reorient-Continue is an architecture primitive; automatic runtime coordination is not landed yet.
@ -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. Freshness derivation, pressure, job/progress view derivation, planning view derivation, reorientation resume/regather verdicts, 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`; role/reorient result read-back follows runtime links; and `jobBindings` no longer store launcher/backend/progress lifecycle fields.
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 freshness derivation, pure CRRC, fixed-lane coordinator decision policy, job/progress view derivation, planning view derivation, reorientation resume/regather verdict policy, role-board projection policy, role-result interpretation/self-persistence review policy, and role/reorient acceptance bundle policy into `epiphany-core`. The next pass is to audit the plan's remaining success criteria and cut whatever still makes app-server more than routing/adaptation. Do not resume outward Aquarium/bridge/Face/dogfood expansion until this foundation cleanup is complete enough to defend.
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. Scene projection, freshness derivation, pressure, job/progress view derivation, planning view derivation, reorientation resume/regather verdicts, 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`; role/reorient result read-back follows runtime links; and `jobBindings` no longer store launcher/backend/progress lifecycle fields.
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 scene projection, freshness derivation, pure CRRC, fixed-lane coordinator decision policy, job/progress view derivation, planning view derivation, reorientation resume/regather verdict policy, role-board projection policy, role-result interpretation/self-persistence review policy, and role/reorient acceptance bundle policy into `epiphany-core`. The next pass is to audit the plan's remaining success criteria and cut whatever still makes app-server more than routing/adaptation. Do not resume outward Aquarium/bridge/Face/dogfood expansion until this foundation cleanup is complete enough to defend.

View file

@ -552,6 +552,19 @@ use epiphany_core::EpiphanyRoleSelfPersistenceStatus as CoreEpiphanyRoleSelfPers
use epiphany_core::EpiphanyRuntimeJobResult;
use epiphany_core::EpiphanyRuntimeJobSnapshot;
use epiphany_core::EpiphanyRuntimeJobStatus;
use epiphany_core::EpiphanyScene as CoreEpiphanyScene;
use epiphany_core::EpiphanySceneAction as CoreEpiphanySceneAction;
use epiphany_core::EpiphanySceneChurn as CoreEpiphanySceneChurn;
use epiphany_core::EpiphanySceneGraph as CoreEpiphanySceneGraph;
use epiphany_core::EpiphanySceneInput;
use epiphany_core::EpiphanySceneInvestigationCheckpoint as CoreEpiphanySceneInvestigationCheckpoint;
use epiphany_core::EpiphanySceneRecord as CoreEpiphanySceneRecord;
use epiphany_core::EpiphanySceneRecords as CoreEpiphanySceneRecords;
use epiphany_core::EpiphanySceneRetrieval as CoreEpiphanySceneRetrieval;
use epiphany_core::EpiphanySceneSource as CoreEpiphanySceneSource;
use epiphany_core::EpiphanySceneStateStatus as CoreEpiphanySceneStateStatus;
use epiphany_core::EpiphanySceneStatusCount as CoreEpiphanySceneStatusCount;
use epiphany_core::EpiphanySceneSubgoal as CoreEpiphanySceneSubgoal;
use epiphany_core::build_reorient_acceptance_bundle;
use epiphany_core::build_role_acceptance_bundle;
use epiphany_core::coordinator_automation_action;
@ -560,6 +573,7 @@ use epiphany_core::derive_jobs;
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::imagination_role_state_patch_policy_errors;
use epiphany_core::interpret_role_finding;
use epiphany_core::modeling_role_state_patch_policy_errors;
@ -569,7 +583,6 @@ use epiphany_core::recommend_reorientation;
use epiphany_core::render_role_board_note;
use epiphany_core::runtime_job_snapshot;
use epiphany_core::select_coordinator_automation_action;
use std::collections::BTreeMap;
use std::collections::HashMap;
use std::collections::HashSet;
use std::io::Error as IoError;
@ -4714,12 +4727,15 @@ impl CodexMessageProcessor {
let pressure = pressure.clone()?;
let decision = reorient_decision.clone()?;
let recommendation = recommendation.clone()?;
let available_actions = epiphany_scene_available_actions(
let available_actions = derive_scene(EpiphanySceneInput {
state: thread.epiphany_state.as_ref(),
loaded,
thread.epiphany_state.is_some(),
checkpoint_present,
reorient_job.is_some(),
);
reorient_binding_id: EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
})
.available_actions
.into_iter()
.map(map_core_epiphany_scene_action)
.collect();
let note = format!(
"{} Result status: {:?}. {}",
recommendation.reason, reorient_result_status, reorient_result_note
@ -12495,126 +12511,184 @@ async fn client_visible_live_thread_epiphany_state(
}
fn map_epiphany_scene(state: Option<&EpiphanyThreadState>, loaded: bool) -> ThreadEpiphanyScene {
let source = if loaded {
ThreadEpiphanySceneSource::Live
} else {
ThreadEpiphanySceneSource::Stored
};
let available_actions = epiphany_scene_available_actions(
map_core_epiphany_scene(derive_scene(EpiphanySceneInput {
state,
loaded,
state.is_some(),
state
.and_then(|state| state.investigation_checkpoint.as_ref())
.is_some(),
state.is_some_and(|state| {
state
.job_bindings
.iter()
.any(|binding| binding.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
}),
);
let Some(state) = state else {
return ThreadEpiphanyScene {
state_status: ThreadEpiphanySceneStateStatus::Missing,
source,
revision: None,
objective: None,
active_subgoal: None,
subgoals: Vec::new(),
invariant_status_counts: Vec::new(),
graph: ThreadEpiphanySceneGraph::default(),
retrieval: None,
investigation_checkpoint: None,
observations: ThreadEpiphanySceneRecords::default(),
evidence: ThreadEpiphanySceneRecords::default(),
churn: None,
available_actions,
};
};
let subgoals = map_epiphany_scene_subgoals(state);
let active_subgoal = subgoals.iter().find(|subgoal| subgoal.active).cloned();
reorient_binding_id: EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
}))
}
fn map_core_epiphany_scene(scene: CoreEpiphanyScene) -> ThreadEpiphanyScene {
ThreadEpiphanyScene {
state_status: ThreadEpiphanySceneStateStatus::Ready,
source,
revision: Some(state.revision),
objective: state.objective.clone(),
active_subgoal,
subgoals,
invariant_status_counts: status_counts(
state.invariants.iter().map(|item| item.status.as_str()),
),
graph: map_epiphany_scene_graph(state),
retrieval: state
.retrieval
.as_ref()
.map(|retrieval| ThreadEpiphanySceneRetrieval {
workspace_root: retrieval.workspace_root.clone(),
status: retrieval.status,
semantic_available: retrieval.semantic_available,
index_revision: retrieval.index_revision.clone(),
indexed_file_count: retrieval.indexed_file_count,
indexed_chunk_count: retrieval.indexed_chunk_count,
shard_count: retrieval.shards.len() as u32,
dirty_path_count: retrieval.dirty_paths.len() as u32,
}),
investigation_checkpoint: state.investigation_checkpoint.as_ref().map(|checkpoint| {
ThreadEpiphanySceneInvestigationCheckpoint {
checkpoint_id: checkpoint.checkpoint_id.clone(),
kind: checkpoint.kind.clone(),
disposition: checkpoint.disposition,
focus: checkpoint.focus.clone(),
summary: checkpoint.summary.clone(),
next_action: checkpoint.next_action.clone(),
captured_at_turn_id: checkpoint.captured_at_turn_id.clone(),
open_question_count: checkpoint.open_questions.len() as u32,
code_ref_count: checkpoint.code_refs.len() as u32,
evidence_count: checkpoint.evidence_ids.len() as u32,
}
}),
observations: ThreadEpiphanySceneRecords {
total_count: state.observations.len() as u32,
latest: state
.observations
.iter()
.take(EPIPHANY_SCENE_RECORD_LIMIT)
.map(|observation| ThreadEpiphanySceneRecord {
id: observation.id.clone(),
kind: observation.source_kind.clone(),
status: observation.status.clone(),
summary: observation.summary.clone(),
code_ref_count: observation.code_refs.len() as u32,
})
.collect(),
state_status: match scene.state_status {
CoreEpiphanySceneStateStatus::Missing => ThreadEpiphanySceneStateStatus::Missing,
CoreEpiphanySceneStateStatus::Ready => ThreadEpiphanySceneStateStatus::Ready,
},
evidence: ThreadEpiphanySceneRecords {
total_count: state.recent_evidence.len() as u32,
latest: state
.recent_evidence
.iter()
.take(EPIPHANY_SCENE_RECORD_LIMIT)
.map(|evidence| ThreadEpiphanySceneRecord {
id: evidence.id.clone(),
kind: evidence.kind.clone(),
status: evidence.status.clone(),
summary: evidence.summary.clone(),
code_ref_count: evidence.code_refs.len() as u32,
})
.collect(),
source: match scene.source {
CoreEpiphanySceneSource::Stored => ThreadEpiphanySceneSource::Stored,
CoreEpiphanySceneSource::Live => ThreadEpiphanySceneSource::Live,
},
churn: state.churn.as_ref().map(|churn| ThreadEpiphanySceneChurn {
understanding_status: churn.understanding_status.clone(),
diff_pressure: churn.diff_pressure.clone(),
graph_freshness: churn.graph_freshness.clone(),
warning: churn.warning.clone(),
unexplained_writes: churn.unexplained_writes,
}),
available_actions,
revision: scene.revision,
objective: scene.objective,
active_subgoal: scene.active_subgoal.map(map_core_epiphany_scene_subgoal),
subgoals: scene
.subgoals
.into_iter()
.map(map_core_epiphany_scene_subgoal)
.collect(),
invariant_status_counts: scene
.invariant_status_counts
.into_iter()
.map(map_core_epiphany_scene_status_count)
.collect(),
graph: map_core_epiphany_scene_graph(scene.graph),
retrieval: scene.retrieval.map(map_core_epiphany_scene_retrieval),
investigation_checkpoint: scene
.investigation_checkpoint
.map(map_core_epiphany_scene_investigation_checkpoint),
observations: map_core_epiphany_scene_records(scene.observations),
evidence: map_core_epiphany_scene_records(scene.evidence),
churn: scene.churn.map(map_core_epiphany_scene_churn),
available_actions: scene
.available_actions
.into_iter()
.map(map_core_epiphany_scene_action)
.collect(),
}
}
fn map_core_epiphany_scene_action(action: CoreEpiphanySceneAction) -> ThreadEpiphanySceneAction {
match action {
CoreEpiphanySceneAction::Index => ThreadEpiphanySceneAction::Index,
CoreEpiphanySceneAction::Retrieve => ThreadEpiphanySceneAction::Retrieve,
CoreEpiphanySceneAction::Distill => ThreadEpiphanySceneAction::Distill,
CoreEpiphanySceneAction::Context => ThreadEpiphanySceneAction::Context,
CoreEpiphanySceneAction::Planning => ThreadEpiphanySceneAction::Planning,
CoreEpiphanySceneAction::GraphQuery => ThreadEpiphanySceneAction::GraphQuery,
CoreEpiphanySceneAction::Jobs => ThreadEpiphanySceneAction::Jobs,
CoreEpiphanySceneAction::Roles => ThreadEpiphanySceneAction::Roles,
CoreEpiphanySceneAction::Coordinator => ThreadEpiphanySceneAction::Coordinator,
CoreEpiphanySceneAction::RoleLaunch => ThreadEpiphanySceneAction::RoleLaunch,
CoreEpiphanySceneAction::RoleResult => ThreadEpiphanySceneAction::RoleResult,
CoreEpiphanySceneAction::RoleAccept => ThreadEpiphanySceneAction::RoleAccept,
CoreEpiphanySceneAction::JobLaunch => ThreadEpiphanySceneAction::JobLaunch,
CoreEpiphanySceneAction::JobInterrupt => ThreadEpiphanySceneAction::JobInterrupt,
CoreEpiphanySceneAction::Freshness => ThreadEpiphanySceneAction::Freshness,
CoreEpiphanySceneAction::Pressure => ThreadEpiphanySceneAction::Pressure,
CoreEpiphanySceneAction::Reorient => ThreadEpiphanySceneAction::Reorient,
CoreEpiphanySceneAction::Crrc => ThreadEpiphanySceneAction::Crrc,
CoreEpiphanySceneAction::ReorientLaunch => ThreadEpiphanySceneAction::ReorientLaunch,
CoreEpiphanySceneAction::ReorientResult => ThreadEpiphanySceneAction::ReorientResult,
CoreEpiphanySceneAction::ReorientAccept => ThreadEpiphanySceneAction::ReorientAccept,
CoreEpiphanySceneAction::Propose => ThreadEpiphanySceneAction::Propose,
CoreEpiphanySceneAction::Promote => ThreadEpiphanySceneAction::Promote,
CoreEpiphanySceneAction::Update => ThreadEpiphanySceneAction::Update,
}
}
fn map_core_epiphany_scene_subgoal(
subgoal: CoreEpiphanySceneSubgoal,
) -> ThreadEpiphanySceneSubgoal {
ThreadEpiphanySceneSubgoal {
id: subgoal.id,
title: subgoal.title,
status: subgoal.status,
summary: subgoal.summary,
active: subgoal.active,
}
}
fn map_core_epiphany_scene_status_count(
count: CoreEpiphanySceneStatusCount,
) -> ThreadEpiphanySceneStatusCount {
ThreadEpiphanySceneStatusCount {
status: count.status,
count: count.count,
}
}
fn map_core_epiphany_scene_graph(graph: CoreEpiphanySceneGraph) -> ThreadEpiphanySceneGraph {
ThreadEpiphanySceneGraph {
architecture_node_count: graph.architecture_node_count,
architecture_edge_count: graph.architecture_edge_count,
dataflow_node_count: graph.dataflow_node_count,
dataflow_edge_count: graph.dataflow_edge_count,
link_count: graph.link_count,
active_node_ids: graph.active_node_ids,
active_edge_ids: graph.active_edge_ids,
open_question_count: graph.open_question_count,
open_gap_count: graph.open_gap_count,
dirty_paths: graph.dirty_paths,
checkpoint_id: graph.checkpoint_id,
checkpoint_summary: graph.checkpoint_summary,
}
}
fn map_core_epiphany_scene_retrieval(
retrieval: CoreEpiphanySceneRetrieval,
) -> ThreadEpiphanySceneRetrieval {
ThreadEpiphanySceneRetrieval {
workspace_root: retrieval.workspace_root,
status: retrieval.status,
semantic_available: retrieval.semantic_available,
index_revision: retrieval.index_revision,
indexed_file_count: retrieval.indexed_file_count,
indexed_chunk_count: retrieval.indexed_chunk_count,
shard_count: retrieval.shard_count,
dirty_path_count: retrieval.dirty_path_count,
}
}
fn map_core_epiphany_scene_investigation_checkpoint(
checkpoint: CoreEpiphanySceneInvestigationCheckpoint,
) -> ThreadEpiphanySceneInvestigationCheckpoint {
ThreadEpiphanySceneInvestigationCheckpoint {
checkpoint_id: checkpoint.checkpoint_id,
kind: checkpoint.kind,
disposition: checkpoint.disposition,
focus: checkpoint.focus,
summary: checkpoint.summary,
next_action: checkpoint.next_action,
captured_at_turn_id: checkpoint.captured_at_turn_id,
open_question_count: checkpoint.open_question_count,
code_ref_count: checkpoint.code_ref_count,
evidence_count: checkpoint.evidence_count,
}
}
fn map_core_epiphany_scene_records(
records: CoreEpiphanySceneRecords,
) -> ThreadEpiphanySceneRecords {
ThreadEpiphanySceneRecords {
total_count: records.total_count,
latest: records
.latest
.into_iter()
.map(map_core_epiphany_scene_record)
.collect(),
}
}
fn map_core_epiphany_scene_record(record: CoreEpiphanySceneRecord) -> ThreadEpiphanySceneRecord {
ThreadEpiphanySceneRecord {
id: record.id,
kind: record.kind,
status: record.status,
summary: record.summary,
code_ref_count: record.code_ref_count,
}
}
fn map_core_epiphany_scene_churn(churn: CoreEpiphanySceneChurn) -> ThreadEpiphanySceneChurn {
ThreadEpiphanySceneChurn {
understanding_status: churn.understanding_status,
diff_pressure: churn.diff_pressure,
graph_freshness: churn.graph_freshness,
warning: churn.warning,
unexplained_writes: churn.unexplained_writes,
}
}
const EPIPHANY_SCENE_RECORD_LIMIT: usize = 5;
const EPIPHANY_IMAGINATION_ROLE_BINDING_ID: &str = "planning-synthesis-worker";
const EPIPHANY_IMAGINATION_OWNER_ROLE: &str = "epiphany-imagination";
const EPIPHANY_MODELING_ROLE_BINDING_ID: &str = "modeling-checkpoint-worker";
@ -12624,51 +12698,6 @@ const EPIPHANY_VERIFICATION_OWNER_ROLE: &str = "epiphany-verifier";
const EPIPHANY_REORIENT_LAUNCH_BINDING_ID: &str = "reorient-worker";
const EPIPHANY_REORIENT_OWNER_ROLE: &str = "epiphany-reorient";
fn epiphany_scene_available_actions(
loaded: bool,
state_present: bool,
checkpoint_present: bool,
reorient_binding_present: bool,
) -> Vec<ThreadEpiphanySceneAction> {
if !loaded {
return Vec::new();
}
let mut actions = vec![
ThreadEpiphanySceneAction::Index,
ThreadEpiphanySceneAction::Retrieve,
ThreadEpiphanySceneAction::Distill,
ThreadEpiphanySceneAction::Context,
ThreadEpiphanySceneAction::Planning,
ThreadEpiphanySceneAction::GraphQuery,
ThreadEpiphanySceneAction::Jobs,
ThreadEpiphanySceneAction::Roles,
ThreadEpiphanySceneAction::Coordinator,
ThreadEpiphanySceneAction::RoleLaunch,
ThreadEpiphanySceneAction::RoleResult,
ThreadEpiphanySceneAction::RoleAccept,
ThreadEpiphanySceneAction::JobLaunch,
ThreadEpiphanySceneAction::Freshness,
ThreadEpiphanySceneAction::Pressure,
ThreadEpiphanySceneAction::Reorient,
ThreadEpiphanySceneAction::Crrc,
];
if checkpoint_present {
actions.push(ThreadEpiphanySceneAction::ReorientLaunch);
}
if reorient_binding_present {
actions.push(ThreadEpiphanySceneAction::ReorientResult);
actions.push(ThreadEpiphanySceneAction::ReorientAccept);
}
actions.push(ThreadEpiphanySceneAction::Update);
if state_present {
actions.push(ThreadEpiphanySceneAction::JobInterrupt);
actions.push(ThreadEpiphanySceneAction::Propose);
actions.push(ThreadEpiphanySceneAction::Promote);
}
actions
}
fn epiphany_role_binding_id(role_id: ThreadEpiphanyRoleId) -> Result<&'static str, String> {
match role_id {
ThreadEpiphanyRoleId::Imagination => Ok(EPIPHANY_IMAGINATION_ROLE_BINDING_ID),
@ -15325,50 +15354,6 @@ fn map_protocol_reorient_reason(
}
}
fn map_epiphany_scene_subgoals(state: &EpiphanyThreadState) -> Vec<ThreadEpiphanySceneSubgoal> {
let active_id = state.active_subgoal_id.as_deref();
state
.subgoals
.iter()
.map(|subgoal| ThreadEpiphanySceneSubgoal {
id: subgoal.id.clone(),
title: subgoal.title.clone(),
status: subgoal.status.clone(),
summary: subgoal.summary.clone(),
active: active_id == Some(subgoal.id.as_str()),
})
.collect()
}
fn map_epiphany_scene_graph(state: &EpiphanyThreadState) -> ThreadEpiphanySceneGraph {
let frontier = state.graph_frontier.as_ref();
let checkpoint = state.graph_checkpoint.as_ref();
ThreadEpiphanySceneGraph {
architecture_node_count: state.graphs.architecture.nodes.len() as u32,
architecture_edge_count: state.graphs.architecture.edges.len() as u32,
dataflow_node_count: state.graphs.dataflow.nodes.len() as u32,
dataflow_edge_count: state.graphs.dataflow.edges.len() as u32,
link_count: state.graphs.links.len() as u32,
active_node_ids: frontier
.map(|frontier| frontier.active_node_ids.clone())
.unwrap_or_default(),
active_edge_ids: frontier
.map(|frontier| frontier.active_edge_ids.clone())
.unwrap_or_default(),
open_question_count: frontier
.map(|frontier| frontier.open_question_ids.len() as u32)
.unwrap_or_default(),
open_gap_count: frontier
.map(|frontier| frontier.open_gap_ids.len() as u32)
.unwrap_or_default(),
dirty_paths: frontier
.map(|frontier| frontier.dirty_paths.clone())
.unwrap_or_default(),
checkpoint_id: checkpoint.map(|checkpoint| checkpoint.checkpoint_id.clone()),
checkpoint_summary: checkpoint.and_then(|checkpoint| checkpoint.summary.clone()),
}
}
fn map_epiphany_context(
state: Option<&EpiphanyThreadState>,
params: &ThreadEpiphanyContextParams,
@ -16309,19 +16294,6 @@ fn epiphany_active_graph_node_ids(state: Option<&EpiphanyThreadState>) -> Vec<St
.unwrap_or_default()
}
fn status_counts<'a>(
statuses: impl Iterator<Item = &'a str>,
) -> Vec<ThreadEpiphanySceneStatusCount> {
let mut counts = BTreeMap::<String, u32>::new();
for status in statuses {
*counts.entry(status.to_string()).or_default() += 1;
}
counts
.into_iter()
.map(|(status, count)| ThreadEpiphanySceneStatusCount { status, count })
.collect()
}
fn thread_epiphany_patch_has_state_replacements(patch: &ThreadEpiphanyUpdatePatch) -> bool {
patch.objective.is_some()
|| patch.active_subgoal_id.is_some()