Add Epiphany graph query surface
This commit is contained in:
parent
5a139accfe
commit
5c62a65052
22 changed files with 1608 additions and 19 deletions
85
vendor/codex/codex-rs/app-server-protocol/schema/json/ClientRequest.json
generated
vendored
85
vendor/codex/codex-rs/app-server-protocol/schema/json/ClientRequest.json
generated
vendored
|
|
@ -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",
|
||||
|
|
|
|||
138
vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
generated
vendored
138
vendor/codex/codex-rs/app-server-protocol/schema/json/codex_app_server_protocol.schemas.json
generated
vendored
|
|
@ -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",
|
||||
|
|
|
|||
|
|
@ -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",
|
||||
|
|
|
|||
19
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQuery.ts
generated
vendored
Normal file
19
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQuery.ts
generated
vendored
Normal 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, };
|
||||
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQueryDirection.ts
generated
vendored
Normal file
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQueryDirection.ts
generated
vendored
Normal 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";
|
||||
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQueryKind.ts
generated
vendored
Normal file
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQueryKind.ts
generated
vendored
Normal 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";
|
||||
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQueryMatched.ts
generated
vendored
Normal file
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQueryMatched.ts
generated
vendored
Normal 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>, };
|
||||
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQueryMissing.ts
generated
vendored
Normal file
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/ThreadEpiphanyGraphQueryMissing.ts
generated
vendored
Normal 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>, };
|
||||
|
|
@ -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";
|
||||
|
|
|
|||
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/index.ts
generated
vendored
5
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/index.ts
generated
vendored
|
|
@ -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";
|
||||
|
|
|
|||
|
|
@ -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/")]
|
||||
|
|
|
|||
2
vendor/codex/codex-rs/app-server/README.md
vendored
2
vendor/codex/codex-rs/app-server/README.md
vendored
|
|
@ -143,6 +143,8 @@ Experimental Epiphany retrieval:
|
|||
- `thread/epiphany/index` runs an explicit loaded-thread-only semantic indexing pass that writes a Qdrant-backed workspace index under Codex home metadata, using local Ollama embeddings by default. It is the write path for persistent semantic retrieval and keeps `thread/epiphany/retrieve` read-only.
|
||||
- `thread/epiphany/retrieve` runs a loaded-thread-only hybrid repo query that combines `codex_file_search` path hits with BM25 chunk retrieval and returns typed result metadata plus an Epiphany retrieval summary.
|
||||
- `thread/epiphany/distill` is a loaded-thread-only read surface that turns one explicit observation input into a deterministic observation/evidence patch plus the current `expectedRevision`. It does not mutate thread state; callers must pass the returned patch to `thread/epiphany/update` to promote it.
|
||||
- `thread/epiphany/context` is a targeted read-only state-shard surface. It selects graph nodes/edges, active frontier, checkpoint, observations, and evidence from authoritative typed state without mutating or notifying.
|
||||
- `thread/epiphany/graphQuery` is a read-only graph traversal surface over authoritative typed state. It can return explicit nodes, path/symbol matches, one-to-three-hop neighbors, and the current frontier neighborhood while preserving architecture/dataflow links; it does not mutate, index, schedule, or promote.
|
||||
- `thread/epiphany/promote` is an explicit loaded-thread-only promotion gate. It evaluates a patch plus verifier evidence, rejects with reasons without mutating state when policy fails, and applies the patch through the durable update path when accepted. Accepted responses include the landed `revision` and `changedFields`.
|
||||
- `thread/epiphany/update` is the explicit loaded-thread-only control-plane write path for Epiphany state. It can append observations/evidence and replace bounded typed state fields such as objective, subgoals, graph frontier/checkpoint, scratch, churn, and mode; it bumps the Epiphany revision, returns `revision` plus `changedFields`, and persists a rollout snapshot immediately.
|
||||
- `thread/epiphany/stateUpdated` is an experimental server notification emitted after successful `thread/epiphany/update` and accepted `thread/epiphany/promote`. It carries the updated typed `epiphanyState`, a `source` of `update` or `promote`, event-level `revision`, and typed `changedFields`; rejected promotions do not emit it.
|
||||
|
|
|
|||
|
|
@ -170,6 +170,13 @@ use codex_app_server_protocol::ThreadEpiphanyFreshnessSource;
|
|||
use codex_app_server_protocol::ThreadEpiphanyGraphContext;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphFreshness;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphFreshnessStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphQuery;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphQueryDirection;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphQueryKind;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphQueryMatched;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphQueryMissing;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphQueryParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyGraphQueryResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyIndexParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyIndexResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyInvalidationInput;
|
||||
|
|
@ -1126,6 +1133,10 @@ impl CodexMessageProcessor {
|
|||
self.thread_epiphany_context(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyGraphQuery { request_id, params } => {
|
||||
self.thread_epiphany_graph_query(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyPressure { request_id, params } => {
|
||||
self.thread_epiphany_pressure(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
|
|
@ -5043,6 +5054,54 @@ impl CodexMessageProcessor {
|
|||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_graph_query(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyGraphQueryParams,
|
||||
) {
|
||||
let thread_id = params.thread_id.clone();
|
||||
let thread_uuid = match ThreadId::from_string(&thread_id) {
|
||||
Ok(id) => id,
|
||||
Err(err) => {
|
||||
self.send_invalid_request_error(request_id, format!("invalid thread id: {err}"))
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let loaded = self.thread_manager.get_thread(thread_uuid).await.is_ok();
|
||||
let thread = match self.read_thread_view(thread_uuid, false).await {
|
||||
Ok(thread) => thread,
|
||||
Err(ThreadReadViewError::InvalidRequest(message)) => {
|
||||
self.send_invalid_request_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
Err(ThreadReadViewError::Internal(message)) => {
|
||||
self.send_internal_error(request_id, message).await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let (state_status, state_revision, graph, frontier, checkpoint, matched, missing) =
|
||||
map_epiphany_graph_query(thread.epiphany_state.as_ref(), ¶ms.query);
|
||||
let response = ThreadEpiphanyGraphQueryResponse {
|
||||
thread_id,
|
||||
source: if loaded {
|
||||
ThreadEpiphanyContextSource::Live
|
||||
} else {
|
||||
ThreadEpiphanyContextSource::Stored
|
||||
},
|
||||
state_status,
|
||||
state_revision,
|
||||
graph,
|
||||
frontier,
|
||||
checkpoint,
|
||||
matched,
|
||||
missing,
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_pressure(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
|
|
@ -12705,6 +12764,7 @@ fn epiphany_scene_available_actions(
|
|||
ThreadEpiphanySceneAction::Retrieve,
|
||||
ThreadEpiphanySceneAction::Distill,
|
||||
ThreadEpiphanySceneAction::Context,
|
||||
ThreadEpiphanySceneAction::GraphQuery,
|
||||
ThreadEpiphanySceneAction::Jobs,
|
||||
ThreadEpiphanySceneAction::Roles,
|
||||
ThreadEpiphanySceneAction::Coordinator,
|
||||
|
|
@ -15138,6 +15198,348 @@ fn map_epiphany_context(
|
|||
)
|
||||
}
|
||||
|
||||
fn map_epiphany_graph_query(
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
query: &ThreadEpiphanyGraphQuery,
|
||||
) -> (
|
||||
ThreadEpiphanyContextStateStatus,
|
||||
Option<u64>,
|
||||
ThreadEpiphanyGraphContext,
|
||||
Option<codex_protocol::protocol::EpiphanyGraphFrontier>,
|
||||
Option<codex_protocol::protocol::EpiphanyGraphCheckpoint>,
|
||||
ThreadEpiphanyGraphQueryMatched,
|
||||
ThreadEpiphanyGraphQueryMissing,
|
||||
) {
|
||||
let Some(state) = state else {
|
||||
return (
|
||||
ThreadEpiphanyContextStateStatus::Missing,
|
||||
None,
|
||||
ThreadEpiphanyGraphContext::default(),
|
||||
None,
|
||||
None,
|
||||
ThreadEpiphanyGraphQueryMatched::default(),
|
||||
ThreadEpiphanyGraphQueryMissing {
|
||||
node_ids: unique_strings(query.node_ids.iter().cloned()),
|
||||
edge_ids: unique_strings(query.edge_ids.iter().cloned()),
|
||||
},
|
||||
);
|
||||
};
|
||||
|
||||
let mut node_ids = unique_strings(query.node_ids.iter().cloned());
|
||||
let mut edge_ids = unique_strings(query.edge_ids.iter().cloned());
|
||||
let mut matched_paths: Vec<PathBuf> = Vec::new();
|
||||
let mut matched_symbols: Vec<String> = Vec::new();
|
||||
let mut matched_edge_kinds: Vec<String> = Vec::new();
|
||||
|
||||
match query.kind {
|
||||
ThreadEpiphanyGraphQueryKind::Node => {}
|
||||
ThreadEpiphanyGraphQueryKind::Path => {
|
||||
collect_graph_query_path_matches(
|
||||
state,
|
||||
query,
|
||||
&mut node_ids,
|
||||
&mut edge_ids,
|
||||
&mut matched_paths,
|
||||
&mut matched_symbols,
|
||||
);
|
||||
}
|
||||
ThreadEpiphanyGraphQueryKind::FrontierNeighborhood => {
|
||||
if let Some(frontier) = state.graph_frontier.as_ref() {
|
||||
extend_unique_strings(&mut node_ids, frontier.active_node_ids.iter().cloned());
|
||||
extend_unique_strings(&mut edge_ids, frontier.active_edge_ids.iter().cloned());
|
||||
}
|
||||
expand_graph_query_neighbors(state, query, &mut node_ids, &mut edge_ids);
|
||||
}
|
||||
ThreadEpiphanyGraphQueryKind::Neighbors => {
|
||||
expand_graph_query_neighbors(state, query, &mut node_ids, &mut edge_ids);
|
||||
}
|
||||
}
|
||||
|
||||
collect_graph_query_edge_kind_matches(
|
||||
state,
|
||||
query,
|
||||
&mut node_ids,
|
||||
&mut edge_ids,
|
||||
&mut matched_edge_kinds,
|
||||
);
|
||||
|
||||
if query.include_links.unwrap_or(true) {
|
||||
expand_graph_query_links(state, &mut node_ids);
|
||||
}
|
||||
|
||||
let node_id_set: HashSet<&str> = node_ids.iter().map(String::as_str).collect();
|
||||
let edge_id_set: HashSet<&str> = edge_ids.iter().map(String::as_str).collect();
|
||||
|
||||
let architecture_nodes = state
|
||||
.graphs
|
||||
.architecture
|
||||
.nodes
|
||||
.iter()
|
||||
.filter(|node| node_id_set.contains(node.id.as_str()))
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
let dataflow_nodes = state
|
||||
.graphs
|
||||
.dataflow
|
||||
.nodes
|
||||
.iter()
|
||||
.filter(|node| node_id_set.contains(node.id.as_str()))
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
let found_node_ids: HashSet<String> = architecture_nodes
|
||||
.iter()
|
||||
.chain(dataflow_nodes.iter())
|
||||
.map(|node| node.id.clone())
|
||||
.collect();
|
||||
let matched_node_ids = architecture_nodes
|
||||
.iter()
|
||||
.chain(dataflow_nodes.iter())
|
||||
.map(|node| node.id.clone())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let architecture_edges =
|
||||
select_epiphany_graph_edges(&state.graphs.architecture.edges, &node_id_set, &edge_id_set);
|
||||
let dataflow_edges =
|
||||
select_epiphany_graph_edges(&state.graphs.dataflow.edges, &node_id_set, &edge_id_set);
|
||||
let found_edge_ids: HashSet<String> = architecture_edges
|
||||
.iter()
|
||||
.chain(dataflow_edges.iter())
|
||||
.filter_map(|edge| edge.id.clone())
|
||||
.collect();
|
||||
let matched_edge_ids = architecture_edges
|
||||
.iter()
|
||||
.chain(dataflow_edges.iter())
|
||||
.filter_map(|edge| edge.id.clone())
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
let links = state
|
||||
.graphs
|
||||
.links
|
||||
.iter()
|
||||
.filter(|link| {
|
||||
node_id_set.contains(link.architecture_node_id.as_str())
|
||||
|| node_id_set.contains(link.dataflow_node_id.as_str())
|
||||
})
|
||||
.cloned()
|
||||
.collect::<Vec<_>>();
|
||||
|
||||
(
|
||||
ThreadEpiphanyContextStateStatus::Ready,
|
||||
Some(state.revision),
|
||||
ThreadEpiphanyGraphContext {
|
||||
architecture_nodes,
|
||||
architecture_edges,
|
||||
dataflow_nodes,
|
||||
dataflow_edges,
|
||||
links,
|
||||
},
|
||||
state.graph_frontier.clone(),
|
||||
state.graph_checkpoint.clone(),
|
||||
ThreadEpiphanyGraphQueryMatched {
|
||||
node_ids: matched_node_ids,
|
||||
edge_ids: matched_edge_ids,
|
||||
paths: matched_paths,
|
||||
symbols: matched_symbols,
|
||||
edge_kinds: matched_edge_kinds,
|
||||
},
|
||||
ThreadEpiphanyGraphQueryMissing {
|
||||
node_ids: node_ids
|
||||
.iter()
|
||||
.filter(|id| !found_node_ids.contains(*id))
|
||||
.cloned()
|
||||
.collect(),
|
||||
edge_ids: edge_ids
|
||||
.iter()
|
||||
.filter(|id| !found_edge_ids.contains(*id))
|
||||
.cloned()
|
||||
.collect(),
|
||||
},
|
||||
)
|
||||
}
|
||||
|
||||
fn collect_graph_query_path_matches(
|
||||
state: &EpiphanyThreadState,
|
||||
query: &ThreadEpiphanyGraphQuery,
|
||||
node_ids: &mut Vec<String>,
|
||||
edge_ids: &mut Vec<String>,
|
||||
matched_paths: &mut Vec<PathBuf>,
|
||||
matched_symbols: &mut Vec<String>,
|
||||
) {
|
||||
if query.paths.is_empty() && query.symbols.is_empty() {
|
||||
return;
|
||||
}
|
||||
for node in state
|
||||
.graphs
|
||||
.architecture
|
||||
.nodes
|
||||
.iter()
|
||||
.chain(state.graphs.dataflow.nodes.iter())
|
||||
{
|
||||
if code_refs_match_query(&node.code_refs, query, matched_paths, matched_symbols) {
|
||||
extend_unique_strings(node_ids, [node.id.clone()]);
|
||||
}
|
||||
}
|
||||
for edge in state
|
||||
.graphs
|
||||
.architecture
|
||||
.edges
|
||||
.iter()
|
||||
.chain(state.graphs.dataflow.edges.iter())
|
||||
{
|
||||
if code_refs_match_query(&edge.code_refs, query, matched_paths, matched_symbols) {
|
||||
if let Some(id) = edge.id.clone() {
|
||||
extend_unique_strings(edge_ids, [id]);
|
||||
}
|
||||
extend_unique_strings(node_ids, [edge.source_id.clone(), edge.target_id.clone()]);
|
||||
}
|
||||
}
|
||||
for link in &state.graphs.links {
|
||||
if code_refs_match_query(&link.code_refs, query, matched_paths, matched_symbols) {
|
||||
extend_unique_strings(
|
||||
node_ids,
|
||||
[
|
||||
link.dataflow_node_id.clone(),
|
||||
link.architecture_node_id.clone(),
|
||||
],
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn collect_graph_query_edge_kind_matches(
|
||||
state: &EpiphanyThreadState,
|
||||
query: &ThreadEpiphanyGraphQuery,
|
||||
node_ids: &mut Vec<String>,
|
||||
edge_ids: &mut Vec<String>,
|
||||
matched_edge_kinds: &mut Vec<String>,
|
||||
) {
|
||||
if query.edge_kinds.is_empty() {
|
||||
return;
|
||||
}
|
||||
let wanted: HashSet<&str> = query.edge_kinds.iter().map(String::as_str).collect();
|
||||
for edge in state
|
||||
.graphs
|
||||
.architecture
|
||||
.edges
|
||||
.iter()
|
||||
.chain(state.graphs.dataflow.edges.iter())
|
||||
{
|
||||
if wanted.contains(edge.kind.as_str()) {
|
||||
extend_unique_strings(matched_edge_kinds, [edge.kind.clone()]);
|
||||
if let Some(id) = edge.id.clone() {
|
||||
extend_unique_strings(edge_ids, [id]);
|
||||
}
|
||||
extend_unique_strings(node_ids, [edge.source_id.clone(), edge.target_id.clone()]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn expand_graph_query_neighbors(
|
||||
state: &EpiphanyThreadState,
|
||||
query: &ThreadEpiphanyGraphQuery,
|
||||
node_ids: &mut Vec<String>,
|
||||
edge_ids: &mut Vec<String>,
|
||||
) {
|
||||
let direction = query
|
||||
.direction
|
||||
.unwrap_or(ThreadEpiphanyGraphQueryDirection::Both);
|
||||
let depth = query.depth.unwrap_or(1).clamp(1, 3);
|
||||
for _ in 0..depth {
|
||||
let current: HashSet<String> = node_ids.iter().cloned().collect();
|
||||
let before = node_ids.len();
|
||||
for edge in state
|
||||
.graphs
|
||||
.architecture
|
||||
.edges
|
||||
.iter()
|
||||
.chain(state.graphs.dataflow.edges.iter())
|
||||
{
|
||||
let source_selected = current.contains(&edge.source_id);
|
||||
let target_selected = current.contains(&edge.target_id);
|
||||
let include_outgoing = matches!(
|
||||
direction,
|
||||
ThreadEpiphanyGraphQueryDirection::Outgoing
|
||||
| ThreadEpiphanyGraphQueryDirection::Both
|
||||
) && source_selected;
|
||||
let include_incoming = matches!(
|
||||
direction,
|
||||
ThreadEpiphanyGraphQueryDirection::Incoming
|
||||
| ThreadEpiphanyGraphQueryDirection::Both
|
||||
) && target_selected;
|
||||
if include_outgoing || include_incoming {
|
||||
if let Some(id) = edge.id.clone() {
|
||||
extend_unique_strings(edge_ids, [id]);
|
||||
}
|
||||
}
|
||||
if include_outgoing {
|
||||
extend_unique_strings(node_ids, [edge.target_id.clone()]);
|
||||
}
|
||||
if include_incoming {
|
||||
extend_unique_strings(node_ids, [edge.source_id.clone()]);
|
||||
}
|
||||
}
|
||||
if node_ids.len() == before {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn expand_graph_query_links(state: &EpiphanyThreadState, node_ids: &mut Vec<String>) {
|
||||
let current: HashSet<&str> = node_ids.iter().map(String::as_str).collect();
|
||||
let mut linked = Vec::new();
|
||||
for link in &state.graphs.links {
|
||||
if current.contains(link.dataflow_node_id.as_str()) {
|
||||
linked.push(link.architecture_node_id.clone());
|
||||
}
|
||||
if current.contains(link.architecture_node_id.as_str()) {
|
||||
linked.push(link.dataflow_node_id.clone());
|
||||
}
|
||||
}
|
||||
extend_unique_strings(node_ids, linked);
|
||||
}
|
||||
|
||||
fn code_refs_match_query(
|
||||
code_refs: &[codex_protocol::protocol::EpiphanyCodeRef],
|
||||
query: &ThreadEpiphanyGraphQuery,
|
||||
matched_paths: &mut Vec<PathBuf>,
|
||||
matched_symbols: &mut Vec<String>,
|
||||
) -> bool {
|
||||
code_refs.iter().any(|code_ref| {
|
||||
let path_matches = query.paths.is_empty()
|
||||
|| query.paths.iter().any(|path| {
|
||||
code_ref.path == *path
|
||||
|| code_ref.path.ends_with(path)
|
||||
|| path.ends_with(code_ref.path.as_path())
|
||||
});
|
||||
let symbol_matches = query.symbols.is_empty()
|
||||
|| code_ref
|
||||
.symbol
|
||||
.as_deref()
|
||||
.is_some_and(|symbol| query.symbols.iter().any(|wanted| wanted == symbol));
|
||||
if path_matches && symbol_matches {
|
||||
if !query.paths.is_empty() {
|
||||
extend_unique_paths(matched_paths, [code_ref.path.clone()]);
|
||||
}
|
||||
if let Some(symbol) = code_ref.symbol.clone()
|
||||
&& !query.symbols.is_empty()
|
||||
{
|
||||
extend_unique_strings(matched_symbols, [symbol]);
|
||||
}
|
||||
true
|
||||
} else {
|
||||
false
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
fn extend_unique_paths(target: &mut Vec<PathBuf>, values: impl IntoIterator<Item = PathBuf>) {
|
||||
for value in values {
|
||||
if !target.iter().any(|existing| existing == &value) {
|
||||
target.push(value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn select_epiphany_graph_edges(
|
||||
edges: &[codex_protocol::protocol::EpiphanyGraphEdge],
|
||||
graph_node_id_set: &HashSet<&str>,
|
||||
|
|
@ -17575,6 +17977,7 @@ mod tests {
|
|||
ThreadEpiphanySceneAction::Retrieve,
|
||||
ThreadEpiphanySceneAction::Distill,
|
||||
ThreadEpiphanySceneAction::Context,
|
||||
ThreadEpiphanySceneAction::GraphQuery,
|
||||
ThreadEpiphanySceneAction::Jobs,
|
||||
ThreadEpiphanySceneAction::Roles,
|
||||
ThreadEpiphanySceneAction::Coordinator,
|
||||
|
|
@ -19147,6 +19550,115 @@ mod tests {
|
|||
assert_eq!(missing.observation_ids, vec!["obs-1".to_string()]);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn map_epiphany_graph_query_returns_frontier_neighborhood() {
|
||||
let state = codex_protocol::protocol::EpiphanyThreadState {
|
||||
revision: 3,
|
||||
graphs: codex_protocol::protocol::EpiphanyGraphs {
|
||||
architecture: codex_protocol::protocol::EpiphanyGraph {
|
||||
nodes: vec![
|
||||
codex_protocol::protocol::EpiphanyGraphNode {
|
||||
id: "operator-console".to_string(),
|
||||
title: "Operator console".to_string(),
|
||||
purpose: "Expose bounded controls.".to_string(),
|
||||
code_refs: vec![codex_protocol::protocol::EpiphanyCodeRef {
|
||||
path: PathBuf::from("apps/epiphany-gui/src/App.tsx"),
|
||||
symbol: Some("App".to_string()),
|
||||
..Default::default()
|
||||
}],
|
||||
..Default::default()
|
||||
},
|
||||
codex_protocol::protocol::EpiphanyGraphNode {
|
||||
id: "action-bridge".to_string(),
|
||||
title: "Action bridge".to_string(),
|
||||
purpose: "Call app-server APIs.".to_string(),
|
||||
..Default::default()
|
||||
},
|
||||
],
|
||||
edges: vec![codex_protocol::protocol::EpiphanyGraphEdge {
|
||||
id: Some("edge-console-bridge".to_string()),
|
||||
source_id: "operator-console".to_string(),
|
||||
target_id: "action-bridge".to_string(),
|
||||
kind: "invokes".to_string(),
|
||||
..Default::default()
|
||||
}],
|
||||
},
|
||||
dataflow: codex_protocol::protocol::EpiphanyGraph {
|
||||
nodes: vec![codex_protocol::protocol::EpiphanyGraphNode {
|
||||
id: "operator-action-flow".to_string(),
|
||||
title: "Operator action flow".to_string(),
|
||||
purpose: "Button to Tauri to Python to app-server.".to_string(),
|
||||
..Default::default()
|
||||
}],
|
||||
edges: Vec::new(),
|
||||
},
|
||||
links: vec![codex_protocol::protocol::EpiphanyGraphLink {
|
||||
dataflow_node_id: "operator-action-flow".to_string(),
|
||||
architecture_node_id: "operator-console".to_string(),
|
||||
relationship: Some("starts-at".to_string()),
|
||||
code_refs: Vec::new(),
|
||||
}],
|
||||
},
|
||||
graph_frontier: Some(codex_protocol::protocol::EpiphanyGraphFrontier {
|
||||
active_node_ids: vec!["operator-console".to_string()],
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
};
|
||||
|
||||
let query = ThreadEpiphanyGraphQuery {
|
||||
kind: ThreadEpiphanyGraphQueryKind::FrontierNeighborhood,
|
||||
node_ids: Vec::new(),
|
||||
edge_ids: Vec::new(),
|
||||
paths: Vec::new(),
|
||||
symbols: Vec::new(),
|
||||
edge_kinds: Vec::new(),
|
||||
direction: Some(ThreadEpiphanyGraphQueryDirection::Outgoing),
|
||||
depth: Some(1),
|
||||
include_links: None,
|
||||
};
|
||||
|
||||
let (state_status, state_revision, graph, frontier, _checkpoint, matched, missing) =
|
||||
map_epiphany_graph_query(Some(&state), &query);
|
||||
|
||||
assert_eq!(state_status, ThreadEpiphanyContextStateStatus::Ready);
|
||||
assert_eq!(state_revision, Some(3));
|
||||
assert_eq!(
|
||||
graph
|
||||
.architecture_nodes
|
||||
.iter()
|
||||
.map(|node| node.id.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["operator-console", "action-bridge"]
|
||||
);
|
||||
assert_eq!(
|
||||
graph
|
||||
.dataflow_nodes
|
||||
.iter()
|
||||
.map(|node| node.id.as_str())
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["operator-action-flow"]
|
||||
);
|
||||
assert_eq!(
|
||||
graph
|
||||
.architecture_edges
|
||||
.iter()
|
||||
.filter_map(|edge| edge.id.as_deref())
|
||||
.collect::<Vec<_>>(),
|
||||
vec!["edge-console-bridge"]
|
||||
);
|
||||
assert_eq!(graph.links.len(), 1);
|
||||
assert_eq!(
|
||||
frontier
|
||||
.as_ref()
|
||||
.map(|frontier| frontier.active_node_ids.as_slice()),
|
||||
Some(&["operator-console".to_string()][..])
|
||||
);
|
||||
assert_eq!(matched.edge_ids, vec!["edge-console-bridge".to_string()]);
|
||||
assert!(missing.node_ids.is_empty());
|
||||
assert!(missing.edge_ids.is_empty());
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn map_epiphany_jobs_reflects_current_progress_without_scheduling_work() {
|
||||
let state = codex_protocol::protocol::EpiphanyThreadState {
|
||||
|
|
|
|||
Reference in a new issue