Collapse Epiphany CRRC reads into view
This commit is contained in:
parent
53bdea881b
commit
32d6eed2d8
14 changed files with 117 additions and 1169 deletions
|
|
@ -16435,13 +16435,6 @@
|
|||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ThreadEpiphanyPressureSource": {
|
||||
"enum": [
|
||||
"stored",
|
||||
"live"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ThreadEpiphanyPressureStatus": {
|
||||
"enum": [
|
||||
"unknown",
|
||||
|
|
|
|||
|
|
@ -14322,13 +14322,6 @@
|
|||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ThreadEpiphanyPressureSource": {
|
||||
"enum": [
|
||||
"stored",
|
||||
"live"
|
||||
],
|
||||
"type": "string"
|
||||
},
|
||||
"ThreadEpiphanyPressureStatus": {
|
||||
"enum": [
|
||||
"unknown",
|
||||
|
|
|
|||
|
|
@ -1,5 +0,0 @@
|
|||
// 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 ThreadEpiphanyPressureSource = "stored" | "live";
|
||||
1
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/index.ts
generated
vendored
1
vendor/codex/codex-rs/app-server-protocol/schema/typescript/v2/index.ts
generated
vendored
|
|
@ -346,7 +346,6 @@ export type { ThreadEpiphanyPlanningSummary } from "./ThreadEpiphanyPlanningSumm
|
|||
export type { ThreadEpiphanyPressure } from "./ThreadEpiphanyPressure";
|
||||
export type { ThreadEpiphanyPressureBasis } from "./ThreadEpiphanyPressureBasis";
|
||||
export type { ThreadEpiphanyPressureLevel } from "./ThreadEpiphanyPressureLevel";
|
||||
export type { ThreadEpiphanyPressureSource } from "./ThreadEpiphanyPressureSource";
|
||||
export type { ThreadEpiphanyPressureStatus } from "./ThreadEpiphanyPressureStatus";
|
||||
export type { ThreadEpiphanyReorientAction } from "./ThreadEpiphanyReorientAction";
|
||||
export type { ThreadEpiphanyReorientCheckpointStatus } from "./ThreadEpiphanyReorientCheckpointStatus";
|
||||
|
|
|
|||
|
|
@ -356,11 +356,6 @@ client_request_definitions! {
|
|||
params: v2::ThreadEpiphanyRolesParams,
|
||||
response: v2::ThreadEpiphanyRolesResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/coordinator")]
|
||||
ThreadEpiphanyCoordinator => "thread/epiphany/coordinator" {
|
||||
params: v2::ThreadEpiphanyCoordinatorParams,
|
||||
response: v2::ThreadEpiphanyCoordinatorResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/roleLaunch")]
|
||||
ThreadEpiphanyRoleLaunch => "thread/epiphany/roleLaunch" {
|
||||
params: v2::ThreadEpiphanyRoleLaunchParams,
|
||||
|
|
@ -396,21 +391,6 @@ client_request_definitions! {
|
|||
params: v2::ThreadEpiphanyGraphQueryParams,
|
||||
response: v2::ThreadEpiphanyGraphQueryResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/pressure")]
|
||||
ThreadEpiphanyPressure => "thread/epiphany/pressure" {
|
||||
params: v2::ThreadEpiphanyPressureParams,
|
||||
response: v2::ThreadEpiphanyPressureResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/reorient")]
|
||||
ThreadEpiphanyReorient => "thread/epiphany/reorient" {
|
||||
params: v2::ThreadEpiphanyReorientParams,
|
||||
response: v2::ThreadEpiphanyReorientResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/crrc")]
|
||||
ThreadEpiphanyCrrc => "thread/epiphany/crrc" {
|
||||
params: v2::ThreadEpiphanyCrrcParams,
|
||||
response: v2::ThreadEpiphanyCrrcResponse,
|
||||
},
|
||||
#[experimental("thread/epiphany/reorientLaunch")]
|
||||
ThreadEpiphanyReorientLaunch => "thread/epiphany/reorientLaunch" {
|
||||
params: v2::ThreadEpiphanyReorientLaunchParams,
|
||||
|
|
@ -2104,89 +2084,6 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_coordinator_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyCoordinator {
|
||||
request_id: RequestId::Integer(8),
|
||||
response: v2::ThreadEpiphanyCoordinatorResponse {
|
||||
thread_id: "thr_123".to_string(),
|
||||
source: v2::ThreadEpiphanyRolesSource::Live,
|
||||
state_status: v2::ThreadEpiphanyReorientStateStatus::Ready,
|
||||
state_revision: Some(4),
|
||||
action: v2::ThreadEpiphanyCoordinatorAction::LaunchModeling,
|
||||
target_role: Some(v2::ThreadEpiphanyRoleId::Modeling),
|
||||
recommended_scene_action: Some(v2::ThreadEpiphanySceneAction::RoleLaunch),
|
||||
requires_review: false,
|
||||
can_auto_run: true,
|
||||
reason: "The modeling/checkpoint lane is ready.".to_string(),
|
||||
source_signals: v2::ThreadEpiphanyCoordinatorSignals {
|
||||
pressure_level: v2::ThreadEpiphanyPressureLevel::Low,
|
||||
should_prepare_compaction: false,
|
||||
reorient_action: v2::ThreadEpiphanyReorientAction::Resume,
|
||||
crrc_action: v2::ThreadEpiphanyCrrcAction::Continue,
|
||||
modeling_result_status: v2::ThreadEpiphanyRoleResultStatus::MissingBinding,
|
||||
verification_result_status: v2::ThreadEpiphanyRoleResultStatus::MissingBinding,
|
||||
reorient_result_status: v2::ThreadEpiphanyReorientResultStatus::MissingBinding,
|
||||
},
|
||||
roles: vec![v2::ThreadEpiphanyRoleLane {
|
||||
id: v2::ThreadEpiphanyRoleId::Modeling,
|
||||
title: "Modeling / Checkpoint".to_string(),
|
||||
owner_role: "epiphany-modeler".to_string(),
|
||||
status: v2::ThreadEpiphanyRoleStatus::Ready,
|
||||
note: "Checkpoint ready.".to_string(),
|
||||
jobs: Vec::new(),
|
||||
authority_scopes: vec!["thread/epiphany/roleLaunch".to_string()],
|
||||
recommended_action: Some(v2::ThreadEpiphanySceneAction::RoleLaunch),
|
||||
}],
|
||||
note: "Coordinator is read-only.".to_string(),
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(response.id(), &RequestId::Integer(8));
|
||||
assert_eq!(response.method(), "thread/epiphany/coordinator");
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/epiphany/coordinator",
|
||||
"id": 8,
|
||||
"response": {
|
||||
"threadId": "thr_123",
|
||||
"source": "live",
|
||||
"stateStatus": "ready",
|
||||
"stateRevision": 4,
|
||||
"action": "launchModeling",
|
||||
"targetRole": "modeling",
|
||||
"recommendedSceneAction": "roleLaunch",
|
||||
"requiresReview": false,
|
||||
"canAutoRun": true,
|
||||
"reason": "The modeling/checkpoint lane is ready.",
|
||||
"sourceSignals": {
|
||||
"pressureLevel": "low",
|
||||
"shouldPrepareCompaction": false,
|
||||
"reorientAction": "resume",
|
||||
"crrcAction": "continue",
|
||||
"modelingResultStatus": "missingBinding",
|
||||
"verificationResultStatus": "missingBinding",
|
||||
"reorientResultStatus": "missingBinding"
|
||||
},
|
||||
"roles": [
|
||||
{
|
||||
"id": "modeling",
|
||||
"title": "Modeling / Checkpoint",
|
||||
"ownerRole": "epiphany-modeler",
|
||||
"status": "ready",
|
||||
"note": "Checkpoint ready.",
|
||||
"authorityScopes": ["thread/epiphany/roleLaunch"],
|
||||
"recommendedAction": "roleLaunch"
|
||||
}
|
||||
],
|
||||
"note": "Coordinator is read-only."
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&response)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_role_launch_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyRoleLaunch {
|
||||
|
|
@ -2981,235 +2878,6 @@ mod tests {
|
|||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_pressure_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyPressure {
|
||||
request_id: RequestId::Integer(8),
|
||||
response: v2::ThreadEpiphanyPressureResponse {
|
||||
thread_id: "thr_123".to_string(),
|
||||
source: v2::ThreadEpiphanyPressureSource::Live,
|
||||
pressure: v2::ThreadEpiphanyPressure {
|
||||
status: v2::ThreadEpiphanyPressureStatus::Ready,
|
||||
level: v2::ThreadEpiphanyPressureLevel::High,
|
||||
basis: v2::ThreadEpiphanyPressureBasis::AutoCompactLimit,
|
||||
used_tokens: Some(92_000),
|
||||
model_context_window: Some(128_000),
|
||||
model_auto_compact_token_limit: Some(100_000),
|
||||
remaining_tokens: Some(8_000),
|
||||
ratio_per_mille: Some(920),
|
||||
should_prepare_compaction: true,
|
||||
note: "Pressure is derived from the model auto-compact token limit."
|
||||
.to_string(),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(response.id(), &RequestId::Integer(8));
|
||||
assert_eq!(response.method(), "thread/epiphany/pressure");
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/epiphany/pressure",
|
||||
"id": 8,
|
||||
"response": {
|
||||
"threadId": "thr_123",
|
||||
"source": "live",
|
||||
"pressure": {
|
||||
"status": "ready",
|
||||
"level": "high",
|
||||
"basis": "autoCompactLimit",
|
||||
"usedTokens": 92000,
|
||||
"modelContextWindow": 128000,
|
||||
"modelAutoCompactTokenLimit": 100000,
|
||||
"remainingTokens": 8000,
|
||||
"ratioPerMille": 920,
|
||||
"shouldPrepareCompaction": true,
|
||||
"note": "Pressure is derived from the model auto-compact token limit."
|
||||
}
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&response)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_reorient_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyReorient {
|
||||
request_id: RequestId::Integer(8),
|
||||
response: v2::ThreadEpiphanyReorientResponse {
|
||||
thread_id: "thr_123".to_string(),
|
||||
source: v2::ThreadEpiphanyReorientSource::Live,
|
||||
state_status: v2::ThreadEpiphanyReorientStateStatus::Ready,
|
||||
state_revision: Some(4),
|
||||
decision: v2::ThreadEpiphanyReorientDecision {
|
||||
action: v2::ThreadEpiphanyReorientAction::Regather,
|
||||
checkpoint_status: v2::ThreadEpiphanyReorientCheckpointStatus::ResumeReady,
|
||||
checkpoint_id: Some("ix-1".to_string()),
|
||||
pressure_level: v2::ThreadEpiphanyPressureLevel::High,
|
||||
retrieval_status: v2::ThreadEpiphanyRetrievalFreshnessStatus::Stale,
|
||||
graph_status: v2::ThreadEpiphanyGraphFreshnessStatus::Ready,
|
||||
watcher_status: v2::ThreadEpiphanyInvalidationStatus::Changed,
|
||||
reasons: vec![
|
||||
v2::ThreadEpiphanyReorientReason::CheckpointPathsChanged,
|
||||
v2::ThreadEpiphanyReorientReason::FrontierChanged,
|
||||
],
|
||||
checkpoint_dirty_paths: vec![PathBuf::from("src/lib.rs")],
|
||||
checkpoint_changed_paths: vec![PathBuf::from("src/lib.rs")],
|
||||
active_frontier_node_ids: vec!["state-spine".to_string()],
|
||||
next_action: "Re-gather source before editing.".to_string(),
|
||||
note: "Resume-ready checkpoint was invalidated by watcher/frontier drift."
|
||||
.to_string(),
|
||||
},
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(response.id(), &RequestId::Integer(8));
|
||||
assert_eq!(response.method(), "thread/epiphany/reorient");
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/epiphany/reorient",
|
||||
"id": 8,
|
||||
"response": {
|
||||
"threadId": "thr_123",
|
||||
"source": "live",
|
||||
"stateStatus": "ready",
|
||||
"stateRevision": 4,
|
||||
"decision": {
|
||||
"action": "regather",
|
||||
"checkpointStatus": "resumeReady",
|
||||
"checkpointId": "ix-1",
|
||||
"pressureLevel": "high",
|
||||
"retrievalStatus": "stale",
|
||||
"graphStatus": "ready",
|
||||
"watcherStatus": "changed",
|
||||
"reasons": [
|
||||
"checkpointPathsChanged",
|
||||
"frontierChanged"
|
||||
],
|
||||
"checkpointDirtyPaths": ["src/lib.rs"],
|
||||
"checkpointChangedPaths": ["src/lib.rs"],
|
||||
"activeFrontierNodeIds": ["state-spine"],
|
||||
"nextAction": "Re-gather source before editing.",
|
||||
"note": "Resume-ready checkpoint was invalidated by watcher/frontier drift."
|
||||
}
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&response)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_crrc_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyCrrc {
|
||||
request_id: RequestId::Integer(9),
|
||||
response: v2::ThreadEpiphanyCrrcResponse {
|
||||
thread_id: "thr_123".to_string(),
|
||||
source: v2::ThreadEpiphanyReorientSource::Live,
|
||||
state_status: v2::ThreadEpiphanyReorientStateStatus::Ready,
|
||||
state_revision: Some(4),
|
||||
pressure: v2::ThreadEpiphanyPressure {
|
||||
status: v2::ThreadEpiphanyPressureStatus::Ready,
|
||||
level: v2::ThreadEpiphanyPressureLevel::High,
|
||||
basis: v2::ThreadEpiphanyPressureBasis::AutoCompactLimit,
|
||||
used_tokens: Some(92_000),
|
||||
model_context_window: Some(128_000),
|
||||
model_auto_compact_token_limit: Some(100_000),
|
||||
remaining_tokens: Some(8_000),
|
||||
ratio_per_mille: Some(920),
|
||||
should_prepare_compaction: true,
|
||||
note: "Pressure is derived from the model auto-compact token limit."
|
||||
.to_string(),
|
||||
},
|
||||
decision: v2::ThreadEpiphanyReorientDecision {
|
||||
action: v2::ThreadEpiphanyReorientAction::Regather,
|
||||
checkpoint_status: v2::ThreadEpiphanyReorientCheckpointStatus::ResumeReady,
|
||||
checkpoint_id: Some("ix-1".to_string()),
|
||||
pressure_level: v2::ThreadEpiphanyPressureLevel::High,
|
||||
retrieval_status: v2::ThreadEpiphanyRetrievalFreshnessStatus::Stale,
|
||||
graph_status: v2::ThreadEpiphanyGraphFreshnessStatus::Ready,
|
||||
watcher_status: v2::ThreadEpiphanyInvalidationStatus::Changed,
|
||||
reasons: vec![v2::ThreadEpiphanyReorientReason::CheckpointPathsChanged],
|
||||
checkpoint_dirty_paths: Vec::new(),
|
||||
checkpoint_changed_paths: vec![PathBuf::from("src/lib.rs")],
|
||||
active_frontier_node_ids: vec!["state-spine".to_string()],
|
||||
next_action: "Re-gather source before editing.".to_string(),
|
||||
note: "Resume-ready checkpoint was invalidated by watcher/frontier drift."
|
||||
.to_string(),
|
||||
},
|
||||
recommendation: v2::ThreadEpiphanyCrrcRecommendation {
|
||||
action: v2::ThreadEpiphanyCrrcAction::LaunchReorientWorker,
|
||||
recommended_scene_action: Some(v2::ThreadEpiphanySceneAction::ReorientLaunch),
|
||||
reason: "The current pressure/reorientation verdict needs a bounded worker before safe continuation."
|
||||
.to_string(),
|
||||
},
|
||||
reorient_binding_id: "reorient-worker".to_string(),
|
||||
reorient_result_status: v2::ThreadEpiphanyReorientResultStatus::MissingBinding,
|
||||
reorient_job: None,
|
||||
reorient_finding: None,
|
||||
available_actions: vec![
|
||||
v2::ThreadEpiphanySceneAction::Reorient,
|
||||
v2::ThreadEpiphanySceneAction::Crrc,
|
||||
v2::ThreadEpiphanySceneAction::ReorientLaunch,
|
||||
],
|
||||
note: "The current pressure/reorientation verdict needs a bounded worker before safe continuation. Result status: MissingBinding. No matching Epiphany reorientation worker binding exists."
|
||||
.to_string(),
|
||||
},
|
||||
};
|
||||
|
||||
assert_eq!(response.id(), &RequestId::Integer(9));
|
||||
assert_eq!(response.method(), "thread/epiphany/crrc");
|
||||
assert_eq!(
|
||||
json!({
|
||||
"method": "thread/epiphany/crrc",
|
||||
"id": 9,
|
||||
"response": {
|
||||
"threadId": "thr_123",
|
||||
"source": "live",
|
||||
"stateStatus": "ready",
|
||||
"stateRevision": 4,
|
||||
"pressure": {
|
||||
"status": "ready",
|
||||
"level": "high",
|
||||
"basis": "autoCompactLimit",
|
||||
"usedTokens": 92000,
|
||||
"modelContextWindow": 128000,
|
||||
"modelAutoCompactTokenLimit": 100000,
|
||||
"remainingTokens": 8000,
|
||||
"ratioPerMille": 920,
|
||||
"shouldPrepareCompaction": true,
|
||||
"note": "Pressure is derived from the model auto-compact token limit."
|
||||
},
|
||||
"decision": {
|
||||
"action": "regather",
|
||||
"checkpointStatus": "resumeReady",
|
||||
"checkpointId": "ix-1",
|
||||
"pressureLevel": "high",
|
||||
"retrievalStatus": "stale",
|
||||
"graphStatus": "ready",
|
||||
"watcherStatus": "changed",
|
||||
"reasons": ["checkpointPathsChanged"],
|
||||
"checkpointChangedPaths": ["src/lib.rs"],
|
||||
"activeFrontierNodeIds": ["state-spine"],
|
||||
"nextAction": "Re-gather source before editing.",
|
||||
"note": "Resume-ready checkpoint was invalidated by watcher/frontier drift."
|
||||
},
|
||||
"recommendation": {
|
||||
"action": "launchReorientWorker",
|
||||
"recommendedSceneAction": "reorientLaunch",
|
||||
"reason": "The current pressure/reorientation verdict needs a bounded worker before safe continuation."
|
||||
},
|
||||
"reorientBindingId": "reorient-worker",
|
||||
"reorientResultStatus": "missingBinding",
|
||||
"availableActions": ["reorient", "crrc", "reorientLaunch"],
|
||||
"note": "The current pressure/reorientation verdict needs a bounded worker before safe continuation. Result status: MissingBinding. No matching Epiphany reorientation worker binding exists."
|
||||
}
|
||||
}),
|
||||
serde_json::to_value(&response)?,
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn serialize_thread_epiphany_reorient_launch_response() -> Result<()> {
|
||||
let response = ClientResponse::ThreadEpiphanyReorientLaunch {
|
||||
|
|
@ -4719,18 +4387,6 @@ mod tests {
|
|||
assert_eq!(reason, Some("thread/epiphany/roles"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_coordinator_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyCoordinator {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: v2::ThreadEpiphanyCoordinatorParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
},
|
||||
};
|
||||
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
|
||||
assert_eq!(reason, Some("thread/epiphany/coordinator"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_role_launch_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyRoleLaunch {
|
||||
|
|
@ -4817,42 +4473,6 @@ mod tests {
|
|||
assert_eq!(reason, Some("thread/epiphany/planning"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_pressure_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyPressure {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: v2::ThreadEpiphanyPressureParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
},
|
||||
};
|
||||
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
|
||||
assert_eq!(reason, Some("thread/epiphany/pressure"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_reorient_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyReorient {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: v2::ThreadEpiphanyReorientParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
},
|
||||
};
|
||||
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
|
||||
assert_eq!(reason, Some("thread/epiphany/reorient"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_crrc_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyCrrc {
|
||||
request_id: RequestId::Integer(1),
|
||||
params: v2::ThreadEpiphanyCrrcParams {
|
||||
thread_id: "thr_123".to_string(),
|
||||
},
|
||||
};
|
||||
let reason = crate::experimental_api::ExperimentalApi::experimental_reason(&request);
|
||||
assert_eq!(reason, Some("thread/epiphany/crrc"));
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn thread_epiphany_reorient_launch_is_marked_experimental() {
|
||||
let request = ClientRequest::ThreadEpiphanyReorientLaunch {
|
||||
|
|
|
|||
|
|
@ -4364,38 +4364,6 @@ pub enum ThreadEpiphanyRoleResultStatus {
|
|||
Cancelled,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyCoordinatorParams {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyCoordinatorResponse {
|
||||
pub thread_id: String,
|
||||
pub source: ThreadEpiphanyRolesSource,
|
||||
pub state_status: ThreadEpiphanyReorientStateStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub state_revision: Option<u64>,
|
||||
pub action: ThreadEpiphanyCoordinatorAction,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub target_role: Option<ThreadEpiphanyRoleId>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub recommended_scene_action: Option<ThreadEpiphanySceneAction>,
|
||||
pub requires_review: bool,
|
||||
pub can_auto_run: bool,
|
||||
pub reason: String,
|
||||
pub source_signals: ThreadEpiphanyCoordinatorSignals,
|
||||
pub roles: Vec<ThreadEpiphanyRoleLane>,
|
||||
pub note: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
|
@ -4947,30 +4915,6 @@ pub struct ThreadEpiphanyGraphQueryMissing {
|
|||
pub edge_ids: Vec<String>,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyPressureParams {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyPressureResponse {
|
||||
pub thread_id: String,
|
||||
pub source: ThreadEpiphanyPressureSource,
|
||||
pub pressure: ThreadEpiphanyPressure,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, Copy, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub enum ThreadEpiphanyPressureSource {
|
||||
Stored,
|
||||
Live,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
|
@ -5025,26 +4969,6 @@ pub enum ThreadEpiphanyPressureBasis {
|
|||
ModelContextWindow,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyReorientParams {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyReorientResponse {
|
||||
pub thread_id: String,
|
||||
pub source: ThreadEpiphanyReorientSource,
|
||||
pub state_status: ThreadEpiphanyReorientStateStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub state_revision: Option<u64>,
|
||||
pub decision: ThreadEpiphanyReorientDecision,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
|
@ -5137,39 +5061,6 @@ pub struct ThreadEpiphanyReorientAcceptResponse {
|
|||
pub finding: ThreadEpiphanyReorientFinding,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyCrrcParams {
|
||||
pub thread_id: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
pub struct ThreadEpiphanyCrrcResponse {
|
||||
pub thread_id: String,
|
||||
pub source: ThreadEpiphanyReorientSource,
|
||||
pub state_status: ThreadEpiphanyReorientStateStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub state_revision: Option<u64>,
|
||||
pub pressure: ThreadEpiphanyPressure,
|
||||
pub decision: ThreadEpiphanyReorientDecision,
|
||||
pub recommendation: ThreadEpiphanyCrrcRecommendation,
|
||||
pub reorient_binding_id: String,
|
||||
pub reorient_result_status: ThreadEpiphanyReorientResultStatus,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub reorient_job: Option<ThreadEpiphanyJob>,
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
#[ts(optional = nullable)]
|
||||
pub reorient_finding: Option<ThreadEpiphanyReorientFinding>,
|
||||
#[serde(default, skip_serializing_if = "Vec::is_empty")]
|
||||
pub available_actions: Vec<ThreadEpiphanySceneAction>,
|
||||
pub note: String,
|
||||
}
|
||||
|
||||
#[derive(Serialize, Deserialize, Debug, Clone, PartialEq, Eq, JsonSchema, TS)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
#[ts(export_to = "v2/")]
|
||||
|
|
|
|||
|
|
@ -155,13 +155,9 @@ use codex_app_server_protocol::ThreadEpiphanyContextResponse;
|
|||
use codex_app_server_protocol::ThreadEpiphanyContextSource;
|
||||
use codex_app_server_protocol::ThreadEpiphanyContextStateStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCoordinatorAction;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCoordinatorParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCoordinatorResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCoordinatorSignals;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCrrcAction;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCrrcParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCrrcRecommendation;
|
||||
use codex_app_server_protocol::ThreadEpiphanyCrrcResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyDistillParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyDistillResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyFreshnessParams;
|
||||
|
|
@ -197,9 +193,6 @@ use codex_app_server_protocol::ThreadEpiphanyPlanningSummary;
|
|||
use codex_app_server_protocol::ThreadEpiphanyPressure;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureBasis;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureLevel;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureSource;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPressureStatus;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPromoteParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyPromoteResponse;
|
||||
|
|
@ -213,9 +206,7 @@ use codex_app_server_protocol::ThreadEpiphanyReorientDecision;
|
|||
use codex_app_server_protocol::ThreadEpiphanyReorientFinding;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientLaunchParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientLaunchResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientReason;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResultParams;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResultResponse;
|
||||
use codex_app_server_protocol::ThreadEpiphanyReorientResultStatus;
|
||||
|
|
@ -1138,10 +1129,6 @@ impl CodexMessageProcessor {
|
|||
self.thread_epiphany_roles(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyCoordinator { request_id, params } => {
|
||||
self.thread_epiphany_coordinator(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyRoleLaunch { request_id, params } => {
|
||||
self.thread_epiphany_role_launch(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
|
|
@ -1170,18 +1157,6 @@ impl CodexMessageProcessor {
|
|||
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;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyReorient { request_id, params } => {
|
||||
self.thread_epiphany_reorient(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyCrrc { request_id, params } => {
|
||||
self.thread_epiphany_crrc(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
}
|
||||
ClientRequest::ThreadEpiphanyReorientLaunch { request_id, params } => {
|
||||
self.thread_epiphany_reorient_launch(to_connection_request_id(request_id), params)
|
||||
.await;
|
||||
|
|
@ -4965,266 +4940,6 @@ impl CodexMessageProcessor {
|
|||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_coordinator(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyCoordinatorParams,
|
||||
) {
|
||||
let ThreadEpiphanyCoordinatorParams { thread_id } = 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 loaded_thread = self.thread_manager.get_thread(thread_uuid).await.ok();
|
||||
let loaded = loaded_thread.is_some();
|
||||
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 retrieval_override = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_retrieval_state().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let watcher_snapshot = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
let config_snapshot = loaded_thread.config_snapshot().await;
|
||||
self.epiphany_invalidation_manager
|
||||
.ensure_thread_watch(&thread_id, &config_snapshot.cwd)
|
||||
.await;
|
||||
Some(
|
||||
self.epiphany_invalidation_manager
|
||||
.snapshot(&thread_id)
|
||||
.await,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (source, token_usage_info) = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
(
|
||||
ThreadEpiphanyRolesSource::Live,
|
||||
loaded_thread.token_usage_info().await,
|
||||
)
|
||||
} else {
|
||||
let token_usage_info = match thread.path.as_deref() {
|
||||
Some(path) => latest_token_usage_info_from_rollout_path(path).await,
|
||||
None => None,
|
||||
};
|
||||
(ThreadEpiphanyRolesSource::Stored, token_usage_info)
|
||||
};
|
||||
|
||||
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
|
||||
thread.epiphany_state.as_ref(),
|
||||
retrieval_override.as_ref(),
|
||||
watcher_snapshot.as_ref(),
|
||||
);
|
||||
let pressure = map_epiphany_pressure(token_usage_info.as_ref());
|
||||
let (state_status, decision) = map_epiphany_reorient(
|
||||
thread.epiphany_state.as_ref(),
|
||||
&pressure,
|
||||
&retrieval,
|
||||
&graph,
|
||||
&watcher,
|
||||
);
|
||||
|
||||
let runtime_store_path = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_runtime_spine_store_path().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let jobs = map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref());
|
||||
let reorient_job = jobs
|
||||
.iter()
|
||||
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
|
||||
.cloned();
|
||||
let (reorient_result_status, reorient_finding, _) = load_epiphany_reorient_result_snapshot(
|
||||
thread.epiphany_state.as_ref(),
|
||||
runtime_store_path.as_deref(),
|
||||
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
|
||||
)
|
||||
.await;
|
||||
let checkpoint_present = thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.and_then(|state| state.investigation_checkpoint.as_ref())
|
||||
.is_some();
|
||||
let reorient_finding_accepted = reorient_finding.as_ref().is_some_and(|finding| {
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.is_some_and(|state| epiphany_reorient_finding_already_accepted(state, finding))
|
||||
});
|
||||
let recommendation = map_epiphany_crrc_recommendation(
|
||||
loaded,
|
||||
state_status,
|
||||
&pressure,
|
||||
&decision,
|
||||
reorient_result_status,
|
||||
checkpoint_present,
|
||||
reorient_finding.is_some(),
|
||||
reorient_finding_accepted,
|
||||
);
|
||||
let roles = map_epiphany_roles(
|
||||
thread.epiphany_state.as_ref(),
|
||||
&jobs,
|
||||
&decision,
|
||||
&pressure,
|
||||
&recommendation,
|
||||
reorient_result_status,
|
||||
reorient_job.as_ref(),
|
||||
);
|
||||
|
||||
let (modeling_result_status, modeling_finding, _) =
|
||||
if let Some(state) = thread.epiphany_state.as_ref() {
|
||||
load_epiphany_role_result_snapshot(
|
||||
state,
|
||||
runtime_store_path.as_deref(),
|
||||
ThreadEpiphanyRoleId::Modeling,
|
||||
EPIPHANY_MODELING_ROLE_BINDING_ID,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
(
|
||||
ThreadEpiphanyRoleResultStatus::MissingState,
|
||||
None,
|
||||
"No authoritative Epiphany state exists for this thread.".to_string(),
|
||||
)
|
||||
};
|
||||
let modeling_result_accepted = modeling_finding.as_ref().is_some_and(|finding| {
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.is_some_and(|state| epiphany_role_finding_already_accepted(state, finding))
|
||||
});
|
||||
let modeling_result_reviewable = modeling_finding
|
||||
.as_ref()
|
||||
.is_some_and(epiphany_modeling_finding_has_reviewable_state_patch);
|
||||
let (verification_result_status, verification_finding, _) =
|
||||
if let Some(state) = thread.epiphany_state.as_ref() {
|
||||
load_epiphany_role_result_snapshot(
|
||||
state,
|
||||
runtime_store_path.as_deref(),
|
||||
ThreadEpiphanyRoleId::Verification,
|
||||
EPIPHANY_VERIFICATION_ROLE_BINDING_ID,
|
||||
)
|
||||
.await
|
||||
} else {
|
||||
(
|
||||
ThreadEpiphanyRoleResultStatus::MissingState,
|
||||
None,
|
||||
"No authoritative Epiphany state exists for this thread.".to_string(),
|
||||
)
|
||||
};
|
||||
let verification_result_accepted = verification_finding.as_ref().is_some_and(|finding| {
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.is_some_and(|state| epiphany_role_finding_already_accepted(state, finding))
|
||||
});
|
||||
let verification_result_covers_current_modeling =
|
||||
thread.epiphany_state.as_ref().is_none_or(|state| {
|
||||
epiphany_verification_finding_covers_current_modeling(
|
||||
state,
|
||||
modeling_result_accepted,
|
||||
modeling_finding.as_ref(),
|
||||
verification_finding.as_ref(),
|
||||
)
|
||||
});
|
||||
let modeling_result_accepted_after_verification =
|
||||
thread.epiphany_state.as_ref().is_some_and(|state| {
|
||||
role_finding_accepted_after(
|
||||
state,
|
||||
modeling_finding.as_ref(),
|
||||
verification_finding.as_ref(),
|
||||
)
|
||||
});
|
||||
let implementation_evidence_after_verification =
|
||||
thread.epiphany_state.as_ref().is_some_and(|state| {
|
||||
implementation_evidence_after_role_finding(state, verification_finding.as_ref())
|
||||
});
|
||||
let verification_result_cites_implementation_evidence =
|
||||
thread.epiphany_state.as_ref().is_some_and(|state| {
|
||||
epiphany_role_finding_cites_implementation_evidence(
|
||||
state,
|
||||
verification_finding.as_ref(),
|
||||
)
|
||||
});
|
||||
let verification_result_allows_implementation = verification_result_accepted
|
||||
&& verification_finding
|
||||
.as_ref()
|
||||
.is_some_and(epiphany_verification_finding_allows_implementation);
|
||||
let verification_result_needs_evidence = verification_result_accepted
|
||||
&& verification_finding
|
||||
.as_ref()
|
||||
.is_some_and(epiphany_verification_finding_needs_evidence);
|
||||
|
||||
let source_signals = ThreadEpiphanyCoordinatorSignals {
|
||||
pressure_level: pressure.level,
|
||||
should_prepare_compaction: pressure.should_prepare_compaction,
|
||||
reorient_action: decision.action,
|
||||
crrc_action: recommendation.action,
|
||||
modeling_result_status,
|
||||
verification_result_status,
|
||||
reorient_result_status,
|
||||
};
|
||||
let coordinator = map_epiphany_coordinator(
|
||||
state_status,
|
||||
checkpoint_present,
|
||||
&pressure,
|
||||
&recommendation,
|
||||
&roles,
|
||||
&source_signals,
|
||||
modeling_result_accepted,
|
||||
modeling_result_reviewable,
|
||||
modeling_result_accepted_after_verification,
|
||||
implementation_evidence_after_verification,
|
||||
verification_result_cites_implementation_evidence,
|
||||
verification_result_covers_current_modeling,
|
||||
verification_result_accepted,
|
||||
verification_result_allows_implementation,
|
||||
verification_result_needs_evidence,
|
||||
reorient_finding_accepted,
|
||||
);
|
||||
let note = render_epiphany_coordinator_note(
|
||||
recommendation.action,
|
||||
pressure.level,
|
||||
modeling_result_status,
|
||||
verification_result_status,
|
||||
reorient_result_status,
|
||||
coordinator.action,
|
||||
);
|
||||
|
||||
let response = ThreadEpiphanyCoordinatorResponse {
|
||||
thread_id,
|
||||
source,
|
||||
state_status,
|
||||
state_revision,
|
||||
action: coordinator.action,
|
||||
target_role: coordinator.target_role,
|
||||
recommended_scene_action: coordinator.recommended_scene_action,
|
||||
requires_review: coordinator.requires_review,
|
||||
can_auto_run: coordinator.can_auto_run,
|
||||
reason: coordinator.reason,
|
||||
source_signals,
|
||||
roles,
|
||||
note,
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_role_launch(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
|
|
@ -5949,282 +5664,6 @@ impl CodexMessageProcessor {
|
|||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_pressure(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyPressureParams,
|
||||
) {
|
||||
let ThreadEpiphanyPressureParams { thread_id } = 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 loaded_thread = self.thread_manager.get_thread(thread_uuid).await.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 (source, token_usage_info) = if let Some(loaded_thread) = loaded_thread {
|
||||
(
|
||||
ThreadEpiphanyPressureSource::Live,
|
||||
loaded_thread.token_usage_info().await,
|
||||
)
|
||||
} else {
|
||||
let token_usage_info = match thread.path.as_deref() {
|
||||
Some(path) => latest_token_usage_info_from_rollout_path(path).await,
|
||||
None => None,
|
||||
};
|
||||
(ThreadEpiphanyPressureSource::Stored, token_usage_info)
|
||||
};
|
||||
|
||||
let response = ThreadEpiphanyPressureResponse {
|
||||
thread_id,
|
||||
source,
|
||||
pressure: map_epiphany_pressure(token_usage_info.as_ref()),
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_reorient(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyReorientParams,
|
||||
) {
|
||||
let ThreadEpiphanyReorientParams { thread_id } = 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 loaded_thread = self.thread_manager.get_thread(thread_uuid).await.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 retrieval_override = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_retrieval_state().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let watcher_snapshot = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
let config_snapshot = loaded_thread.config_snapshot().await;
|
||||
self.epiphany_invalidation_manager
|
||||
.ensure_thread_watch(&thread_id, &config_snapshot.cwd)
|
||||
.await;
|
||||
Some(
|
||||
self.epiphany_invalidation_manager
|
||||
.snapshot(&thread_id)
|
||||
.await,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (pressure_source, token_usage_info) = if let Some(loaded_thread) = loaded_thread {
|
||||
(
|
||||
ThreadEpiphanyReorientSource::Live,
|
||||
loaded_thread.token_usage_info().await,
|
||||
)
|
||||
} else {
|
||||
let token_usage_info = match thread.path.as_deref() {
|
||||
Some(path) => latest_token_usage_info_from_rollout_path(path).await,
|
||||
None => None,
|
||||
};
|
||||
(ThreadEpiphanyReorientSource::Stored, token_usage_info)
|
||||
};
|
||||
|
||||
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
|
||||
thread.epiphany_state.as_ref(),
|
||||
retrieval_override.as_ref(),
|
||||
watcher_snapshot.as_ref(),
|
||||
);
|
||||
let pressure = map_epiphany_pressure(token_usage_info.as_ref());
|
||||
let (state_status, decision) = map_epiphany_reorient(
|
||||
thread.epiphany_state.as_ref(),
|
||||
&pressure,
|
||||
&retrieval,
|
||||
&graph,
|
||||
&watcher,
|
||||
);
|
||||
let response = ThreadEpiphanyReorientResponse {
|
||||
thread_id,
|
||||
source: pressure_source,
|
||||
state_status,
|
||||
state_revision,
|
||||
decision,
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_crrc(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
params: ThreadEpiphanyCrrcParams,
|
||||
) {
|
||||
let ThreadEpiphanyCrrcParams { thread_id } = 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 loaded_thread = self.thread_manager.get_thread(thread_uuid).await.ok();
|
||||
let loaded = loaded_thread.is_some();
|
||||
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 retrieval_override = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_retrieval_state().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let watcher_snapshot = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
let config_snapshot = loaded_thread.config_snapshot().await;
|
||||
self.epiphany_invalidation_manager
|
||||
.ensure_thread_watch(&thread_id, &config_snapshot.cwd)
|
||||
.await;
|
||||
Some(
|
||||
self.epiphany_invalidation_manager
|
||||
.snapshot(&thread_id)
|
||||
.await,
|
||||
)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let (source, token_usage_info) = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
(
|
||||
ThreadEpiphanyReorientSource::Live,
|
||||
loaded_thread.token_usage_info().await,
|
||||
)
|
||||
} else {
|
||||
let token_usage_info = match thread.path.as_deref() {
|
||||
Some(path) => latest_token_usage_info_from_rollout_path(path).await,
|
||||
None => None,
|
||||
};
|
||||
(ThreadEpiphanyReorientSource::Stored, token_usage_info)
|
||||
};
|
||||
|
||||
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
|
||||
thread.epiphany_state.as_ref(),
|
||||
retrieval_override.as_ref(),
|
||||
watcher_snapshot.as_ref(),
|
||||
);
|
||||
let pressure = map_epiphany_pressure(token_usage_info.as_ref());
|
||||
let (state_status, decision) = map_epiphany_reorient(
|
||||
thread.epiphany_state.as_ref(),
|
||||
&pressure,
|
||||
&retrieval,
|
||||
&graph,
|
||||
&watcher,
|
||||
);
|
||||
|
||||
let runtime_store_path = if let Some(loaded_thread) = loaded_thread.as_ref() {
|
||||
Some(loaded_thread.epiphany_runtime_spine_store_path().await)
|
||||
} else {
|
||||
None
|
||||
};
|
||||
let jobs = map_epiphany_jobs(thread.epiphany_state.as_ref(), retrieval_override.as_ref());
|
||||
let reorient_job = jobs
|
||||
.iter()
|
||||
.find(|job| job.id == EPIPHANY_REORIENT_LAUNCH_BINDING_ID)
|
||||
.cloned();
|
||||
let (result_status, finding, result_note) = load_epiphany_reorient_result_snapshot(
|
||||
thread.epiphany_state.as_ref(),
|
||||
runtime_store_path.as_deref(),
|
||||
EPIPHANY_REORIENT_LAUNCH_BINDING_ID,
|
||||
)
|
||||
.await;
|
||||
let available_actions = epiphany_scene_available_actions(
|
||||
loaded,
|
||||
thread.epiphany_state.is_some(),
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.and_then(|state| state.investigation_checkpoint.as_ref())
|
||||
.is_some(),
|
||||
reorient_job.is_some(),
|
||||
);
|
||||
let recommendation = map_epiphany_crrc_recommendation(
|
||||
loaded,
|
||||
state_status,
|
||||
&pressure,
|
||||
&decision,
|
||||
result_status,
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.and_then(|state| state.investigation_checkpoint.as_ref())
|
||||
.is_some(),
|
||||
finding.is_some(),
|
||||
finding.as_ref().is_some_and(|finding| {
|
||||
thread
|
||||
.epiphany_state
|
||||
.as_ref()
|
||||
.is_some_and(|state| epiphany_reorient_finding_already_accepted(state, finding))
|
||||
}),
|
||||
);
|
||||
let note = format!(
|
||||
"{} Result status: {:?}. {}",
|
||||
recommendation.reason, result_status, result_note
|
||||
);
|
||||
|
||||
let response = ThreadEpiphanyCrrcResponse {
|
||||
thread_id,
|
||||
source,
|
||||
state_status,
|
||||
state_revision,
|
||||
pressure,
|
||||
decision,
|
||||
recommendation,
|
||||
reorient_binding_id: EPIPHANY_REORIENT_LAUNCH_BINDING_ID.to_string(),
|
||||
reorient_result_status: result_status,
|
||||
reorient_job,
|
||||
reorient_finding: finding,
|
||||
available_actions,
|
||||
note,
|
||||
};
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
async fn thread_epiphany_reorient_launch(
|
||||
&self,
|
||||
request_id: ConnectionRequestId,
|
||||
|
|
|
|||
Reference in a new issue