Add Epiphany scene projection

This commit is contained in:
Meta Vens 2026-04-25 16:07:41 +01:00
commit 8507b3c491
22 changed files with 1683 additions and 17 deletions

View file

@ -336,6 +336,11 @@ client_request_definitions! {
params: v2::ThreadReadParams,
response: v2::ThreadReadResponse,
},
#[experimental("thread/epiphany/scene")]
ThreadEpiphanyScene => "thread/epiphany/scene" {
params: v2::ThreadEpiphanySceneParams,
response: v2::ThreadEpiphanySceneResponse,
},
#[experimental("thread/epiphany/index")]
ThreadEpiphanyIndex => "thread/epiphany/index" {
params: v2::ThreadEpiphanyIndexParams,
@ -1579,6 +1584,167 @@ mod tests {
Ok(())
}
#[test]
fn serialize_thread_epiphany_scene_response() -> Result<()> {
let response = ClientResponse::ThreadEpiphanyScene {
request_id: RequestId::Integer(8),
response: v2::ThreadEpiphanySceneResponse {
thread_id: "thr_123".to_string(),
scene: v2::ThreadEpiphanyScene {
state_status: v2::ThreadEpiphanySceneStateStatus::Ready,
source: v2::ThreadEpiphanySceneSource::Live,
revision: Some(3),
objective: Some("Keep the map visible".to_string()),
active_subgoal: Some(v2::ThreadEpiphanySceneSubgoal {
id: "phase-6".to_string(),
title: "Reflect typed state".to_string(),
status: "active".to_string(),
summary: None,
active: true,
}),
subgoals: Vec::new(),
invariant_status_counts: vec![v2::ThreadEpiphanySceneStatusCount {
status: "ok".to_string(),
count: 2,
}],
graph: v2::ThreadEpiphanySceneGraph {
architecture_node_count: 4,
architecture_edge_count: 3,
dataflow_node_count: 2,
dataflow_edge_count: 1,
link_count: 2,
active_node_ids: vec!["state-spine".to_string()],
active_edge_ids: Vec::new(),
open_question_count: 1,
open_gap_count: 0,
dirty_paths: vec![PathBuf::from("notes/scene.md")],
checkpoint_id: Some("ck-1".to_string()),
checkpoint_summary: None,
},
retrieval: Some(v2::ThreadEpiphanySceneRetrieval {
workspace_root: PathBuf::from("/workspace"),
status: codex_protocol::protocol::EpiphanyRetrievalStatus::Ready,
semantic_available: true,
index_revision: Some("qdrant-v1".to_string()),
indexed_file_count: Some(12),
indexed_chunk_count: Some(34),
shard_count: 1,
dirty_path_count: 0,
}),
observations: v2::ThreadEpiphanySceneRecords {
total_count: 1,
latest: vec![v2::ThreadEpiphanySceneRecord {
id: "obs-1".to_string(),
kind: "smoke".to_string(),
status: "ok".to_string(),
summary: "Scene projected".to_string(),
code_ref_count: 1,
}],
},
evidence: v2::ThreadEpiphanySceneRecords::default(),
churn: Some(v2::ThreadEpiphanySceneChurn {
understanding_status: "ready".to_string(),
diff_pressure: "low".to_string(),
graph_freshness: Some("fresh".to_string()),
warning: None,
unexplained_writes: Some(0),
}),
available_actions: vec![
v2::ThreadEpiphanySceneAction::Index,
v2::ThreadEpiphanySceneAction::Retrieve,
v2::ThreadEpiphanySceneAction::Distill,
v2::ThreadEpiphanySceneAction::Update,
v2::ThreadEpiphanySceneAction::Propose,
v2::ThreadEpiphanySceneAction::Promote,
],
},
},
};
assert_eq!(response.id(), &RequestId::Integer(8));
assert_eq!(response.method(), "thread/epiphany/scene");
assert_eq!(
json!({
"method": "thread/epiphany/scene",
"id": 8,
"response": {
"threadId": "thr_123",
"scene": {
"stateStatus": "ready",
"source": "live",
"revision": 3,
"objective": "Keep the map visible",
"activeSubgoal": {
"id": "phase-6",
"title": "Reflect typed state",
"status": "active",
"active": true
},
"invariantStatusCounts": [
{
"status": "ok",
"count": 2
}
],
"graph": {
"architectureNodeCount": 4,
"architectureEdgeCount": 3,
"dataflowNodeCount": 2,
"dataflowEdgeCount": 1,
"linkCount": 2,
"activeNodeIds": ["state-spine"],
"openQuestionCount": 1,
"openGapCount": 0,
"dirtyPaths": ["notes/scene.md"],
"checkpointId": "ck-1"
},
"retrieval": {
"workspaceRoot": "/workspace",
"status": "ready",
"semanticAvailable": true,
"indexRevision": "qdrant-v1",
"indexedFileCount": 12,
"indexedChunkCount": 34,
"shardCount": 1,
"dirtyPathCount": 0
},
"observations": {
"totalCount": 1,
"latest": [
{
"id": "obs-1",
"kind": "smoke",
"status": "ok",
"summary": "Scene projected",
"codeRefCount": 1
}
]
},
"evidence": {
"totalCount": 0
},
"churn": {
"understandingStatus": "ready",
"diffPressure": "low",
"graphFreshness": "fresh",
"unexplainedWrites": 0
},
"availableActions": [
"index",
"retrieve",
"distill",
"update",
"propose",
"promote"
]
}
}
}),
serde_json::to_value(&response)?,
);
Ok(())
}
#[test]
fn serialize_thread_epiphany_retrieve_response() -> Result<()> {
let response = ClientResponse::ThreadEpiphanyRetrieve {
@ -2437,6 +2603,18 @@ mod tests {
assert_eq!(reason, Some("thread/epiphany/retrieve"));
}
#[test]
fn thread_epiphany_scene_is_marked_experimental() {
let request = ClientRequest::ThreadEpiphanyScene {
request_id: RequestId::Integer(1),
params: v2::ThreadEpiphanySceneParams {
thread_id: "thr_123".to_string(),
},
};
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
assert_eq!(reason, Some("thread/epiphany/scene"));
}
#[test]
fn thread_epiphany_index_is_marked_experimental() {
let request = ClientRequest::ThreadEpiphanyIndex {

View file

@ -3915,6 +3915,184 @@ pub struct ThreadReadResponse {
pub thread: Thread,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneParams {
pub thread_id: String,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneResponse {
pub thread_id: String,
pub scene: ThreadEpiphanyScene,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanyScene {
pub state_status: ThreadEpiphanySceneStateStatus,
pub source: ThreadEpiphanySceneSource,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub revision: Option<u64>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub objective: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub active_subgoal: Option<ThreadEpiphanySceneSubgoal>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub subgoals: Vec<ThreadEpiphanySceneSubgoal>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub invariant_status_counts: Vec<ThreadEpiphanySceneStatusCount>,
pub graph: ThreadEpiphanySceneGraph,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub retrieval: Option<ThreadEpiphanySceneRetrieval>,
pub observations: ThreadEpiphanySceneRecords,
pub evidence: ThreadEpiphanySceneRecords,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub churn: Option<ThreadEpiphanySceneChurn>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub available_actions: Vec<ThreadEpiphanySceneAction>,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanySceneStateStatus {
Missing,
Ready,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanySceneSource {
Stored,
Live,
}
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub enum ThreadEpiphanySceneAction {
Index,
Retrieve,
Distill,
Propose,
Promote,
Update,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneSubgoal {
pub id: String,
pub title: String,
pub status: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub summary: Option<String>,
pub active: bool,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneStatusCount {
pub status: String,
pub count: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneGraph {
pub architecture_node_count: u32,
pub architecture_edge_count: u32,
pub dataflow_node_count: u32,
pub dataflow_edge_count: u32,
pub link_count: u32,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub active_node_ids: Vec<String>,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub active_edge_ids: Vec<String>,
pub open_question_count: u32,
pub open_gap_count: u32,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub dirty_paths: Vec<PathBuf>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub checkpoint_id: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub checkpoint_summary: Option<String>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneRetrieval {
pub workspace_root: PathBuf,
pub status: CoreEpiphanyRetrievalStatus,
pub semantic_available: bool,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub index_revision: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub indexed_file_count: Option<u32>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub indexed_chunk_count: Option<u32>,
pub shard_count: u32,
pub dirty_path_count: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneRecords {
pub total_count: u32,
#[serde(default, skip_serializing_if = "Vec::is_empty")]
pub latest: Vec<ThreadEpiphanySceneRecord>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneRecord {
pub id: String,
pub kind: String,
pub status: String,
pub summary: String,
pub code_ref_count: u32,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]
pub struct ThreadEpiphanySceneChurn {
pub understanding_status: String,
pub diff_pressure: String,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub graph_freshness: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub warning: Option<String>,
#[serde(default, skip_serializing_if = "Option::is_none")]
#[ts(optional = nullable)]
pub unexplained_writes: Option<u32>,
}
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
#[serde(rename_all = "camelCase")]
#[ts(export_to = "v2/")]