Add Epiphany graph query surface
This commit is contained in:
parent
5a139accfe
commit
5c62a65052
22 changed files with 1608 additions and 19 deletions
|
|
@ -376,6 +376,11 @@ client_request_definitions! {
|
|||
params: v2::ThreadEpiphanyContextParams,
|
||||
response: v2::ThreadEpiphanyContextResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/graphQuery")]
|
||||
ThreadEpiphanyGraphQuery => "thread/epiphany/graphQuery" {
|
||||
params: v2::ThreadEpiphanyGraphQueryParams,
|
||||
response: v2::ThreadEpiphanyGraphQueryResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/pressure")]
|
||||
ThreadEpiphanyPressure => "thread/epiphany/pressure" {
|
||||
params: v2::ThreadEpiphanyPressureParams,
|
||||
|
|
@ -2540,6 +2545,104 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_graph_query_request_and_response() -> Result<()> {
|
||||
let request = ClientRequest::ThreadEpiphanyGraphQuery {
|
||||
request_id: RequestId::Integer(24),
|
||||
params: v2::ThreadEpiphanyGraphQueryParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
query: v2::ThreadEpiphanyGraphQuery {
|
||||
kind: v2::ThreadEpiphanyGraphQueryKind::FrontierNeighborhood,
|
||||
node_ids: vec!["state-spine".to_string()],
|
||||
edge_ids: Vec::new(),
|
||||
paths: vec![PathBuf::from("src/lib.rs")],
|
||||
symbols: Vec::new(),
|
||||
edge_kinds: vec!["calls".to_string()],
|
||||
direction: Some(v2::ThreadEpiphanyGraphQueryDirection::Both),
|
||||
depth: Some(1),
|
||||
include_links: Some(true),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(request.method(), "thread/epiphany/graphQuery");
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/epiphany/graphQuery",
|
||||
"id": 24,
|
||||
"params": {
|
||||
"threadId": "thr_123",
|
||||
"query": {
|
||||
"kind": "frontierNeighborhood",
|
||||
"nodeIds": ["state-spine"],
|
||||
"paths": ["src/lib.rs"],
|
||||
"edgeKinds": ["calls"],
|
||||
"direction": "both",
|
||||
"depth": 1,
|
||||
"includeLinks": true
|
||||
}
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&request)?,
|
||||
);
|
||||
|
||||
let response = ClientResponse::ThreadEpiphanyGraphQuery {
|
||||
request_id: RequestId::Integer(24),
|
||||
response: v2::ThreadEpiphanyGraphQueryResponse {
|
||||
thread_id: "thr_123".to_string(),
|
||||
source: v2::ThreadEpiphanyContextSource::Live,
|
||||
state_status: v2::ThreadEpiphanyContextStateStatus::Ready,
|
||||
state_revision: Some(2),
|
||||
graph: v2::ThreadEpiphanyGraphContext {
|
||||
architecture_nodes: vec![codex_protocol::protocol::EpiphanyGraphNode {
|
||||
id: "state-spine".to_string(),
|
||||
title: "State spine".to_string(),
|
||||
purpose: "Persist Epiphany state.".to_string(),
|
||||
..Default::default()
|
||||
}],
|
||||
..Default::default()
|
||||
},
|
||||
frontier: None,
|
||||
checkpoint: None,
|
||||
matched: v2::ThreadEpiphanyGraphQueryMatched {
|
||||
node_ids: vec!["state-spine".to_string()],
|
||||
edge_ids: Vec::new(),
|
||||
paths: Vec::new(),
|
||||
symbols: Vec::new(),
|
||||
edge_kinds: Vec::new(),
|
||||
},
|
||||
missing: v2::ThreadEpiphanyGraphQueryMissing::default(),
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(response.method(), "thread/epiphany/graphQuery");
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/epiphany/graphQuery",
|
||||
"id": 24,
|
||||
"response": {
|
||||
"threadId": "thr_123",
|
||||
"source": "live",
|
||||
"stateStatus": "ready",
|
||||
"stateRevision": 2,
|
||||
"graph": {
|
||||
"architectureNodes": [{
|
||||
"id": "state-spine",
|
||||
"title": "State spine",
|
||||
"purpose": "Persist Epiphany state."
|
||||
}]
|
||||
},
|
||||
"matched": {
|
||||
"nodeIds": ["state-spine"]
|
||||
},
|
||||
"missing": {}
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&response)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_pressure_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyPressure {
|
||||
|
|
|
|||
|
|
@ -3996,6 +3996,7 @@ pub enum ThreadEpiphanySceneAction {
|
|||
Retrieve,
|
||||
Distill,
|
||||
Context,
|
||||
GraphQuery,
|
||||
Jobs,
|
||||
Roles,
|
||||
Coordinator,
|
||||
|
|
@ -4713,6 +4714,109 @@ pub struct ThreadEpiphanyContextMissing {
|
|||
pub evidence_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyGraphQueryParams {
|
||||
pub thread_id: String,
|
||||
pub query: ThreadEpiphanyGraphQuery,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyGraphQuery {
|
||||
pub kind: ThreadEpiphanyGraphQueryKind,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub node_ids: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub edge_ids: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub paths: Vec<PathBuf>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub symbols: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub edge_kinds: Vec<String>,
|
||||
/// Defaults to `both`.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub direction: Option<ThreadEpiphanyGraphQueryDirection>,
|
||||
/// Defaults to 1 and is capped by the server.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub depth: Option<u32>,
|
||||
/// Defaults to true so neighborhood queries preserve dataflow/architecture joins.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub include_links: Option<bool>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadEpiphanyGraphQueryKind {
|
||||
Node,
|
||||
Path,
|
||||
FrontierNeighborhood,
|
||||
Neighbors,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadEpiphanyGraphQueryDirection {
|
||||
Incoming,
|
||||
Outgoing,
|
||||
Both,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyGraphQueryResponse {
|
||||
pub thread_id: String,
|
||||
pub source: ThreadEpiphanyContextSource,
|
||||
pub state_status: ThreadEpiphanyContextStateStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub state_revision: Option<u64>,
|
||||
pub graph: ThreadEpiphanyGraphContext,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub frontier: Option<CoreEpiphanyGraphFrontier>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub checkpoint: Option<CoreEpiphanyGraphCheckpoint>,
|
||||
pub matched: ThreadEpiphanyGraphQueryMatched,
|
||||
pub missing: ThreadEpiphanyGraphQueryMissing,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyGraphQueryMatched {
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub node_ids: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub edge_ids: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub paths: Vec<PathBuf>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub symbols: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub edge_kinds: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS, Default)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyGraphQueryMissing {
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub node_ids: Vec<String>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub edge_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
|
|
|||
Reference in a new issue