Add Epiphany freshness reflection
This commit is contained in:
parent
71ea1ed2ea
commit
bea5cbb293
12 changed files with 787 additions and 30 deletions
|
|
@ -346,6 +346,11 @@ client_request_definitions! {
|
|||
params: v2::ThreadEpiphanyJobsParams,
|
||||
response: v2::ThreadEpiphanyJobsResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/freshness")]
|
||||
ThreadEpiphanyFreshness => "thread/epiphany/freshness" {
|
||||
params: v2::ThreadEpiphanyFreshnessParams,
|
||||
response: v2::ThreadEpiphanyFreshnessResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/context")]
|
||||
ThreadEpiphanyContext => "thread/epiphany/context" {
|
||||
params: v2::ThreadEpiphanyContextParams,
|
||||
|
|
@ -1682,6 +1687,9 @@ mod tests {
|
|||
v2::ThreadEpiphanySceneAction::Index,
|
||||
v2::ThreadEpiphanySceneAction::Retrieve,
|
||||
v2::ThreadEpiphanySceneAction::Distill,
|
||||
v2::ThreadEpiphanySceneAction::Context,
|
||||
v2::ThreadEpiphanySceneAction::Jobs,
|
||||
v2::ThreadEpiphanySceneAction::Freshness,
|
||||
v2::ThreadEpiphanySceneAction::Pressure,
|
||||
v2::ThreadEpiphanySceneAction::Update,
|
||||
v2::ThreadEpiphanySceneAction::Propose,
|
||||
|
|
@ -1775,6 +1783,9 @@ mod tests {
|
|||
"index",
|
||||
"retrieve",
|
||||
"distill",
|
||||
"context",
|
||||
"jobs",
|
||||
"freshness",
|
||||
"pressure",
|
||||
"update",
|
||||
"propose",
|
||||
|
|
@ -1846,6 +1857,74 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_freshness_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyFreshness {
|
||||
request_id: RequestId::Integer(8),
|
||||
response: v2::ThreadEpiphanyFreshnessResponse {
|
||||
thread_id: "thr_123".to_string(),
|
||||
source: v2::ThreadEpiphanyFreshnessSource::Live,
|
||||
state_revision: Some(3),
|
||||
retrieval: v2::ThreadEpiphanyRetrievalFreshness {
|
||||
status: v2::ThreadEpiphanyRetrievalFreshnessStatus::Stale,
|
||||
semantic_available: Some(true),
|
||||
last_indexed_at_unix_seconds: Some(1_744_500_000),
|
||||
indexed_file_count: Some(12),
|
||||
indexed_chunk_count: Some(48),
|
||||
dirty_paths: vec![PathBuf::from("src/router.rs")],
|
||||
note: "Retrieval catalog is stale; 1 dirty path(s) need refresh."
|
||||
.to_string(),
|
||||
},
|
||||
graph: v2::ThreadEpiphanyGraphFreshness {
|
||||
status: v2::ThreadEpiphanyGraphFreshnessStatus::Stale,
|
||||
graph_freshness: Some("stale".to_string()),
|
||||
checkpoint_id: Some("ck-5".to_string()),
|
||||
dirty_path_count: 1,
|
||||
dirty_paths: vec![PathBuf::from("src/router.rs")],
|
||||
open_question_count: 1,
|
||||
open_gap_count: 0,
|
||||
note: "Graph freshness is stale; frontier has 1 dirty path(s), 1 open question id(s), and 0 open gap id(s)."
|
||||
.to_string(),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(response.id(), &RequestId::Integer(8));
|
||||
assert_eq!(response.method(), "thread/epiphany/freshness");
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/epiphany/freshness",
|
||||
"id": 8,
|
||||
"response": {
|
||||
"threadId": "thr_123",
|
||||
"source": "live",
|
||||
"stateRevision": 3,
|
||||
"retrieval": {
|
||||
"status": "stale",
|
||||
"semanticAvailable": true,
|
||||
"lastIndexedAtUnixSeconds": 1744500000,
|
||||
"indexedFileCount": 12,
|
||||
"indexedChunkCount": 48,
|
||||
"dirtyPaths": ["src/router.rs"],
|
||||
"note": "Retrieval catalog is stale; 1 dirty path(s) need refresh."
|
||||
},
|
||||
"graph": {
|
||||
"status": "stale",
|
||||
"graphFreshness": "stale",
|
||||
"checkpointId": "ck-5",
|
||||
"dirtyPathCount": 1,
|
||||
"dirtyPaths": ["src/router.rs"],
|
||||
"openQuestionCount": 1,
|
||||
"openGapCount": 0,
|
||||
"note": "Graph freshness is stale; frontier has 1 dirty path(s), 1 open question id(s), and 0 open gap id(s)."
|
||||
}
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&response)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_context_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyContext {
|
||||
|
|
@ -2911,6 +2990,18 @@ mod tests {
|
|||
assert_eq!(reason, Some("thread/epiphany/jobs"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_freshness_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyFreshness {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: v2::ThreadEpiphanyFreshnessParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
},
|
||||
};
|
||||
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
|
||||
assert_eq!(reason, Some("thread/epiphany/freshness"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_context_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyContext {
|
||||
|
|
|
|||
|
|
@ -3995,6 +3995,7 @@ pub enum ThreadEpiphanySceneAction {
|
|||
Distill,
|
||||
Context,
|
||||
Jobs,
|
||||
Freshness,
|
||||
Pressure,
|
||||
Propose,
|
||||
Promote,
|
||||
|
|
@ -4153,6 +4154,95 @@ pub enum ThreadEpiphanyJobsSource {
|
|||
Live,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyFreshnessParams {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyFreshnessResponse {
|
||||
pub thread_id: String,
|
||||
pub source: ThreadEpiphanyFreshnessSource,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub state_revision: Option<u64>,
|
||||
pub retrieval: ThreadEpiphanyRetrievalFreshness,
|
||||
pub graph: ThreadEpiphanyGraphFreshness,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadEpiphanyFreshnessSource {
|
||||
Stored,
|
||||
Live,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadEpiphanyRetrievalFreshnessStatus {
|
||||
Missing,
|
||||
Ready,
|
||||
Stale,
|
||||
Indexing,
|
||||
Unavailable,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyRetrievalFreshness {
|
||||
pub status: ThreadEpiphanyRetrievalFreshnessStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub semantic_available: Option<bool>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub last_indexed_at_unix_seconds: Option<i64>,
|
||||
#[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>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub dirty_paths: Vec<PathBuf>,
|
||||
pub note: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadEpiphanyGraphFreshnessStatus {
|
||||
Missing,
|
||||
Ready,
|
||||
Stale,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyGraphFreshness {
|
||||
pub status: ThreadEpiphanyGraphFreshnessStatus,
|
||||
#[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 checkpoint_id: Option<String>,
|
||||
pub dirty_path_count: u32,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub dirty_paths: Vec<PathBuf>,
|
||||
pub open_question_count: u32,
|
||||
pub open_gap_count: u32,
|
||||
pub note: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
|
|
|||
Reference in a new issue