Add Epiphany map proposal surface
This commit is contained in:
parent
cecf0c676c
commit
7eb449b0a9
13 changed files with 701 additions and 27 deletions
|
|
@ -346,6 +346,11 @@ client_request_definitions! {
|
|||
params: v2::ThreadEpiphanyDistillParams,
|
||||
response: v2::ThreadEpiphanyDistillResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/propose")]
|
||||
ThreadEpiphanyPropose => "thread/epiphany/propose" {
|
||||
params: v2::ThreadEpiphanyProposeParams,
|
||||
response: v2::ThreadEpiphanyProposeResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/promote")]
|
||||
ThreadEpiphanyPromote => "thread/epiphany/promote" {
|
||||
params: v2::ThreadEpiphanyPromoteParams,
|
||||
|
|
@ -1777,6 +1782,46 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_propose_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyPropose {
|
||||
request_id: RequestId::Integer(12),
|
||||
response: v2::ThreadEpiphanyProposeResponse {
|
||||
expected_revision: 7,
|
||||
patch: v2::ThreadEpiphanyUpdatePatch {
|
||||
churn: Some(codex_protocol::protocol::EpiphanyChurnState {
|
||||
understanding_status: "proposal_ready".to_string(),
|
||||
diff_pressure: "low".to_string(),
|
||||
graph_freshness: Some("proposal".to_string()),
|
||||
..Default::default()
|
||||
}),
|
||||
..Default::default()
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(response.id(), &RequestId::Integer(12));
|
||||
assert_eq!(response.method(), "thread/epiphany/propose");
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/epiphany/propose",
|
||||
"id": 12,
|
||||
"response": {
|
||||
"expectedRevision": 7,
|
||||
"patch": {
|
||||
"churn": {
|
||||
"understanding_status": "proposal_ready",
|
||||
"diff_pressure": "low",
|
||||
"graph_freshness": "proposal"
|
||||
}
|
||||
}
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&response)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_promote_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyPromote {
|
||||
|
|
@ -2378,6 +2423,19 @@ mod tests {
|
|||
assert_eq!(reason, Some("thread/epiphany/distill"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_propose_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyPropose {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: v2::ThreadEpiphanyProposeParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
observation_ids: vec!["obs-123".to_string()],
|
||||
},
|
||||
};
|
||||
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
|
||||
assert_eq!(reason, Some("thread/epiphany/propose"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_promote_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyPromote {
|
||||
|
|
|
|||
|
|
@ -3957,6 +3957,23 @@ pub struct ThreadEpiphanyDistillResponse {
|
|||
pub patch: ThreadEpiphanyUpdatePatch,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyProposeParams {
|
||||
pub thread_id: String,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub observation_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyProposeResponse {
|
||||
pub expected_revision: u64,
|
||||
pub patch: ThreadEpiphanyUpdatePatch,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
|
|
|||
|
|
@ -152,6 +152,8 @@ use codex_app_server_protocol::ThreadEpiphanyIndexParams;
|
|||
use codex_app_server_protocol::ThreadEpiphanyIndexResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPromoteParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPromoteResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyProposeParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyProposeResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRetrieveIndexSummary;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRetrieveParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyRetrieveResponse;
|
||||
|
|
@ -238,6 +240,7 @@ use codex_core::CodexThreadTurnContextOverrides;
|
|||
use codex_core::EPIPHANY_RETRIEVAL_DEFAULT_LIMIT;
|
||||
use codex_core::EPIPHANY_RETRIEVAL_MAX_LIMIT;
|
||||
use codex_core::EpiphanyDistillInput;
|
||||
use codex_core::EpiphanyMapProposalInput;
|
||||
use codex_core::EpiphanyPromotionInput;
|
||||
use codex_core::EpiphanyRetrieveQuery;
|
||||
use codex_core::EpiphanyRetrieveResponse as CoreEpiphanyRetrieveResponse;
|
||||
|
|
@ -986,6 +989,10 @@ impl CodexMessageProcessor {
|
|||
self.thread_epiphany_distill(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyPropose { request_id, params } => {
|
||||
self.thread_epiphany_propose(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyPromote { request_id, params } => {
|
||||
self.thread_epiphany_promote(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
|
|
@ -4234,6 +4241,78 @@ impl CodexMessageProcessor {
|
|||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_propose(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyProposeParams,
|
||||
) {
|
||||
let ThreadEpiphanyProposeParams {
|
||||
thread_id,
|
||||
observation_ids,
|
||||
} = params;
|
||||
|
||||
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 thread = match self.thread_manager.get_thread(thread_uuid).await {
|
||||
Ok(thread) => thread,
|
||||
Err(_) => {
|
||||
self.send_invalid_request_error(
|
||||
request_id,
|
||||
format!("thread not loaded: {thread_uuid}"),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
let state = match thread.epiphany_state().await {
|
||||
Some(state) => state,
|
||||
None => {
|
||||
self.send_invalid_request_error(
|
||||
request_id,
|
||||
format!("thread has no Epiphany state: {thread_uuid}"),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let expected_revision = state.revision;
|
||||
let proposal = match codex_core::propose_map_update(EpiphanyMapProposalInput {
|
||||
state,
|
||||
observation_ids,
|
||||
}) {
|
||||
Ok(proposal) => proposal,
|
||||
Err(err) => {
|
||||
self.send_invalid_request_error(
|
||||
request_id,
|
||||
format!("failed to propose Epiphany map update: {err}"),
|
||||
)
|
||||
.await;
|
||||
return;
|
||||
}
|
||||
};
|
||||
let response = ThreadEpiphanyProposeResponse {
|
||||
expected_revision,
|
||||
patch: ThreadEpiphanyUpdatePatch {
|
||||
observations: vec![proposal.observation],
|
||||
evidence: vec![proposal.evidence],
|
||||
graphs: Some(proposal.graphs),
|
||||
graph_frontier: Some(proposal.graph_frontier),
|
||||
churn: Some(proposal.churn),
|
||||
..Default::default()
|
||||
},
|
||||
};
|
||||
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_promote(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
|
|
|
|||
3
vendor/codex/codex-rs/core/src/epiphany_proposal.rs
vendored
Normal file
3
vendor/codex/codex-rs/core/src/epiphany_proposal.rs
vendored
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
pub use epiphany_core::EpiphanyMapProposal;
|
||||
pub use epiphany_core::EpiphanyMapProposalInput;
|
||||
pub use epiphany_core::propose_map_update;
|
||||
4
vendor/codex/codex-rs/core/src/lib.rs
vendored
4
vendor/codex/codex-rs/core/src/lib.rs
vendored
|
|
@ -19,6 +19,7 @@ mod codex_thread;
|
|||
mod compact_remote;
|
||||
mod epiphany_distillation;
|
||||
mod epiphany_promotion;
|
||||
mod epiphany_proposal;
|
||||
mod epiphany_retrieval;
|
||||
mod epiphany_rollout;
|
||||
pub use codex_thread::CodexThread;
|
||||
|
|
@ -31,6 +32,9 @@ pub use epiphany_distillation::distill_observation;
|
|||
pub use epiphany_promotion::EpiphanyPromotionDecision;
|
||||
pub use epiphany_promotion::EpiphanyPromotionInput;
|
||||
pub use epiphany_promotion::evaluate_promotion;
|
||||
pub use epiphany_proposal::EpiphanyMapProposal;
|
||||
pub use epiphany_proposal::EpiphanyMapProposalInput;
|
||||
pub use epiphany_proposal::propose_map_update;
|
||||
pub use epiphany_retrieval::EPIPHANY_RETRIEVAL_DEFAULT_LIMIT;
|
||||
pub use epiphany_retrieval::EPIPHANY_RETRIEVAL_MAX_LIMIT;
|
||||
pub use epiphany_retrieval::EpiphanyRetrieveQuery;
|
||||
|
|
|
|||
Reference in a new issue