Add Epiphany graph query surface

This commit is contained in:
Meta Vens 2026-04-29 21:49:47 +01:00
commit 5c62a65052
22 changed files with 1608 additions and 19 deletions

View file

@ -3872,6 +3872,91 @@
],
"type": "object"
},
"ThreadEpiphanyGraphQuery": {
"properties": {
"depth": {
"description": "Defaults to 1 and is capped by the server.",
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"direction": {
"anyOf": [
{
"$ref": "#/definitions/ThreadEpiphanyGraphQueryDirection"
},
{
"type": "null"
}
],
"description": "Defaults to `both`."
},
"edgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"edgeKinds": {
"items": {
"type": "string"
},
"type": "array"
},
"includeLinks": {
"description": "Defaults to true so neighborhood queries preserve dataflow/architecture joins.",
"type": [
"boolean",
"null"
]
},
"kind": {
"$ref": "#/definitions/ThreadEpiphanyGraphQueryKind"
},
"nodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"paths": {
"items": {
"type": "string"
},
"type": "array"
},
"symbols": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"kind"
],
"type": "object"
},
"ThreadEpiphanyGraphQueryDirection": {
"enum": [
"incoming",
"outgoing",
"both"
],
"type": "string"
},
"ThreadEpiphanyGraphQueryKind": {
"enum": [
"node",
"path",
"frontierNeighborhood",
"neighbors"
],
"type": "string"
},
"ThreadEpiphanyRoleId": {
"enum": [
"implementation",

View file

@ -15294,6 +15294,143 @@
],
"type": "string"
},
"ThreadEpiphanyGraphQuery": {
"properties": {
"depth": {
"description": "Defaults to 1 and is capped by the server.",
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"direction": {
"anyOf": [
{
"$ref": "#/definitions/v2/ThreadEpiphanyGraphQueryDirection"
},
{
"type": "null"
}
],
"description": "Defaults to `both`."
},
"edgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"edgeKinds": {
"items": {
"type": "string"
},
"type": "array"
},
"includeLinks": {
"description": "Defaults to true so neighborhood queries preserve dataflow/architecture joins.",
"type": [
"boolean",
"null"
]
},
"kind": {
"$ref": "#/definitions/v2/ThreadEpiphanyGraphQueryKind"
},
"nodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"paths": {
"items": {
"type": "string"
},
"type": "array"
},
"symbols": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"kind"
],
"type": "object"
},
"ThreadEpiphanyGraphQueryDirection": {
"enum": [
"incoming",
"outgoing",
"both"
],
"type": "string"
},
"ThreadEpiphanyGraphQueryKind": {
"enum": [
"node",
"path",
"frontierNeighborhood",
"neighbors"
],
"type": "string"
},
"ThreadEpiphanyGraphQueryMatched": {
"properties": {
"edgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"edgeKinds": {
"items": {
"type": "string"
},
"type": "array"
},
"nodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"paths": {
"items": {
"type": "string"
},
"type": "array"
},
"symbols": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"ThreadEpiphanyGraphQueryMissing": {
"properties": {
"edgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"nodeIds": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"ThreadEpiphanyInvalidationInput": {
"properties": {
"activeFrontierNodeIds": {
@ -16309,6 +16446,7 @@
"retrieve",
"distill",
"context",
"graphQuery",
"jobs",
"roles",
"coordinator",

View file

@ -13181,6 +13181,143 @@
],
"type": "string"
},
"ThreadEpiphanyGraphQuery": {
"properties": {
"depth": {
"description": "Defaults to 1 and is capped by the server.",
"format": "uint32",
"minimum": 0.0,
"type": [
"integer",
"null"
]
},
"direction": {
"anyOf": [
{
"$ref": "#/definitions/ThreadEpiphanyGraphQueryDirection"
},
{
"type": "null"
}
],
"description": "Defaults to `both`."
},
"edgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"edgeKinds": {
"items": {
"type": "string"
},
"type": "array"
},
"includeLinks": {
"description": "Defaults to true so neighborhood queries preserve dataflow/architecture joins.",
"type": [
"boolean",
"null"
]
},
"kind": {
"$ref": "#/definitions/ThreadEpiphanyGraphQueryKind"
},
"nodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"paths": {
"items": {
"type": "string"
},
"type": "array"
},
"symbols": {
"items": {
"type": "string"
},
"type": "array"
}
},
"required": [
"kind"
],
"type": "object"
},
"ThreadEpiphanyGraphQueryDirection": {
"enum": [
"incoming",
"outgoing",
"both"
],
"type": "string"
},
"ThreadEpiphanyGraphQueryKind": {
"enum": [
"node",
"path",
"frontierNeighborhood",
"neighbors"
],
"type": "string"
},
"ThreadEpiphanyGraphQueryMatched": {
"properties": {
"edgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"edgeKinds": {
"items": {
"type": "string"
},
"type": "array"
},
"nodeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"paths": {
"items": {
"type": "string"
},
"type": "array"
},
"symbols": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"ThreadEpiphanyGraphQueryMissing": {
"properties": {
"edgeIds": {
"items": {
"type": "string"
},
"type": "array"
},
"nodeIds": {
"items": {
"type": "string"
},
"type": "array"
}
},
"type": "object"
},
"ThreadEpiphanyInvalidationInput": {
"properties": {
"activeFrontierNodeIds": {
@ -14196,6 +14333,7 @@
"retrieve",
"distill",
"context",
"graphQuery",
"jobs",
"roles",
"coordinator",

View file

@ -0,0 +1,19 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
import type { ThreadEpiphanyGraphQueryDirection } from "./ThreadEpiphanyGraphQueryDirection";
import type { ThreadEpiphanyGraphQueryKind } from "./ThreadEpiphanyGraphQueryKind";
export type ThreadEpiphanyGraphQuery = { kind: ThreadEpiphanyGraphQueryKind, nodeIds?: Array<string>, edgeIds?: Array<string>, paths?: Array<string>, symbols?: Array<string>, edgeKinds?: Array<string>,
/**
* Defaults to `both`.
*/
direction?: ThreadEpiphanyGraphQueryDirection | null,
/**
* Defaults to 1 and is capped by the server.
*/
depth?: number | null,
/**
* Defaults to true so neighborhood queries preserve dataflow/architecture joins.
*/
includeLinks?: boolean | null, };

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanyGraphQueryDirection = "incoming" | "outgoing" | "both";

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanyGraphQueryKind = "node" | "path" | "frontierNeighborhood" | "neighbors";

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanyGraphQueryMatched = { nodeIds?: Array<string>, edgeIds?: Array<string>, paths?: Array<string>, symbols?: Array<string>, edgeKinds?: Array<string>, };

View file

@ -0,0 +1,5 @@
// GENERATED CODE! DO NOT MODIFY BY HAND!
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanyGraphQueryMissing = { nodeIds?: Array<string>, edgeIds?: Array<string>, };

View file

@ -2,4 +2,4 @@
// This file was generated by [ts-rs](https://github.com/Aleph-Alpha/ts-rs). Do not edit this file manually.
export type ThreadEpiphanySceneAction = "index" | "retrieve" | "distill" | "context" | "jobs" | "roles" | "coordinator" | "roleLaunch" | "roleResult" | "jobLaunch" | "jobInterrupt" | "freshness" | "pressure" | "reorient" | "crrc" | "reorientLaunch" | "reorientResult" | "reorientAccept" | "propose" | "promote" | "update";
export type ThreadEpiphanySceneAction = "index" | "retrieve" | "distill" | "context" | "graphQuery" | "jobs" | "roles" | "coordinator" | "roleLaunch" | "roleResult" | "jobLaunch" | "jobInterrupt" | "freshness" | "pressure" | "reorient" | "crrc" | "reorientLaunch" | "reorientResult" | "reorientAccept" | "propose" | "promote" | "update";

View file

@ -329,6 +329,11 @@ export type { ThreadEpiphanyFreshnessSource } from "./ThreadEpiphanyFreshnessSou
export type { ThreadEpiphanyGraphContext } from "./ThreadEpiphanyGraphContext";
export type { ThreadEpiphanyGraphFreshness } from "./ThreadEpiphanyGraphFreshness";
export type { ThreadEpiphanyGraphFreshnessStatus } from "./ThreadEpiphanyGraphFreshnessStatus";
export type { ThreadEpiphanyGraphQuery } from "./ThreadEpiphanyGraphQuery";
export type { ThreadEpiphanyGraphQueryDirection } from "./ThreadEpiphanyGraphQueryDirection";
export type { ThreadEpiphanyGraphQueryKind } from "./ThreadEpiphanyGraphQueryKind";
export type { ThreadEpiphanyGraphQueryMatched } from "./ThreadEpiphanyGraphQueryMatched";
export type { ThreadEpiphanyGraphQueryMissing } from "./ThreadEpiphanyGraphQueryMissing";
export type { ThreadEpiphanyInvalidationInput } from "./ThreadEpiphanyInvalidationInput";
export type { ThreadEpiphanyInvalidationStatus } from "./ThreadEpiphanyInvalidationStatus";
export type { ThreadEpiphanyJob } from "./ThreadEpiphanyJob";

View file

@ -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 {

View file

@ -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/")]