Move read response projections into bridge
This commit is contained in:
parent
17489f4664
commit
3c96fdee4d
5 changed files with 107 additions and 50 deletions
|
|
@ -7,6 +7,8 @@ use codex_protocol::protocol::TokenUsageInfo as CoreTokenUsageInfo;
|
|||
use epiphany_core::EpiphanySceneInput;
|
||||
use epiphany_core::derive_scene;
|
||||
|
||||
use crate::context::map_epiphany_context;
|
||||
use crate::context::map_epiphany_graph_query;
|
||||
use crate::context::map_epiphany_planning;
|
||||
use crate::coordinator::derive_epiphany_coordinator_status;
|
||||
use crate::coordinator::epiphany_reorient_finding_already_accepted;
|
||||
|
|
@ -63,6 +65,82 @@ pub fn epiphany_view_needs_runtime_store(lenses: &[ThreadEpiphanyViewLens]) -> b
|
|||
|| lenses.contains(&ThreadEpiphanyViewLens::Coordinator)
|
||||
}
|
||||
|
||||
pub struct EpiphanyFreshnessResponseInput<'a> {
|
||||
pub thread_id: String,
|
||||
pub loaded: bool,
|
||||
pub state: Option<&'a EpiphanyThreadState>,
|
||||
pub retrieval_override: Option<&'a EpiphanyRetrievalState>,
|
||||
pub watcher_snapshot: Option<EpiphanyFreshnessWatcherSnapshot<'a>>,
|
||||
}
|
||||
|
||||
pub fn map_epiphany_freshness_response(
|
||||
input: EpiphanyFreshnessResponseInput<'_>,
|
||||
) -> ThreadEpiphanyFreshnessResponse {
|
||||
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
|
||||
input.state,
|
||||
input.retrieval_override,
|
||||
input.watcher_snapshot,
|
||||
);
|
||||
ThreadEpiphanyFreshnessResponse {
|
||||
thread_id: input.thread_id,
|
||||
source: if input.loaded {
|
||||
ThreadEpiphanyFreshnessSource::Live
|
||||
} else {
|
||||
ThreadEpiphanyFreshnessSource::Stored
|
||||
},
|
||||
state_revision,
|
||||
retrieval,
|
||||
graph,
|
||||
watcher,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_epiphany_context_response(
|
||||
thread_id: String,
|
||||
loaded: bool,
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
params: &ThreadEpiphanyContextParams,
|
||||
) -> ThreadEpiphanyContextResponse {
|
||||
let (state_status, state_revision, context, missing) = map_epiphany_context(state, params);
|
||||
ThreadEpiphanyContextResponse {
|
||||
thread_id,
|
||||
source: if loaded {
|
||||
ThreadEpiphanyContextSource::Live
|
||||
} else {
|
||||
ThreadEpiphanyContextSource::Stored
|
||||
},
|
||||
state_status,
|
||||
state_revision,
|
||||
context,
|
||||
missing,
|
||||
}
|
||||
}
|
||||
|
||||
pub fn map_epiphany_graph_query_response(
|
||||
thread_id: String,
|
||||
loaded: bool,
|
||||
state: Option<&EpiphanyThreadState>,
|
||||
query: &ThreadEpiphanyGraphQuery,
|
||||
) -> ThreadEpiphanyGraphQueryResponse {
|
||||
let (state_status, state_revision, graph, frontier, checkpoint, matched, missing) =
|
||||
map_epiphany_graph_query(state, query);
|
||||
ThreadEpiphanyGraphQueryResponse {
|
||||
thread_id,
|
||||
source: if loaded {
|
||||
ThreadEpiphanyContextSource::Live
|
||||
} else {
|
||||
ThreadEpiphanyContextSource::Stored
|
||||
},
|
||||
state_status,
|
||||
state_revision,
|
||||
graph,
|
||||
frontier,
|
||||
checkpoint,
|
||||
matched,
|
||||
missing,
|
||||
}
|
||||
}
|
||||
|
||||
pub struct EpiphanyViewResponseInput<'a> {
|
||||
pub thread_id: String,
|
||||
pub lenses: Vec<ThreadEpiphanyViewLens>,
|
||||
|
|
|
|||
|
|
@ -715,6 +715,13 @@ legacy read verbs (`roleResult`, `freshness`, `context`, `graphQuery`,
|
|||
`reorientResult`, `retrieve`, `distill`, `propose`) plus host loading and
|
||||
response/error shaping.
|
||||
|
||||
Freshness/context/graph-query response construction is also bridge-owned now.
|
||||
`epiphany-codex-bridge::view` builds `ThreadEpiphanyFreshnessResponse`,
|
||||
`ThreadEpiphanyContextResponse`, and `ThreadEpiphanyGraphQueryResponse` from
|
||||
typed state plus host-supplied watcher/retrieval inputs. App-server still owns
|
||||
loading and watcher registration because those are host lifecycle seams.
|
||||
`epiphany_read_routes.rs` is about 620 lines after this cut.
|
||||
|
||||
Also: MCP itself is allowed to be JSON. The target is not "replace MCP JSON";
|
||||
the target is an Epiphany-owned boundary that speaks typed Epiphany
|
||||
intent/result/receipt documents internally and normal MCP JSON-RPC externally.
|
||||
|
|
|
|||
Binary file not shown.
File diff suppressed because one or more lines are too long
|
|
@ -6,12 +6,10 @@ use codex_core::EpiphanyMapProposalInput;
|
|||
use codex_core::EpiphanyRetrieveQuery;
|
||||
use codex_core::distill_observation;
|
||||
use codex_protocol::ThreadId;
|
||||
use epiphany_codex_bridge::context::map_epiphany_context;
|
||||
use epiphany_codex_bridge::context::map_epiphany_graph_query;
|
||||
use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
|
||||
use epiphany_codex_bridge::launch::epiphany_role_binding_id;
|
||||
use epiphany_codex_bridge::reorient::map_epiphany_freshness;
|
||||
use epiphany_codex_bridge::retrieve::map_epiphany_retrieve_response;
|
||||
use epiphany_codex_bridge::view::EpiphanyFreshnessResponseInput;
|
||||
use epiphany_codex_bridge::view::EpiphanyReorientResultResponseInput;
|
||||
use epiphany_codex_bridge::view::EpiphanyRoleResultResponseInput;
|
||||
use epiphany_codex_bridge::view::EpiphanyViewResponseInput;
|
||||
|
|
@ -20,6 +18,9 @@ use epiphany_codex_bridge::view::epiphany_view_needs_jobs;
|
|||
use epiphany_codex_bridge::view::epiphany_view_needs_pressure;
|
||||
use epiphany_codex_bridge::view::epiphany_view_needs_reorientation_inputs;
|
||||
use epiphany_codex_bridge::view::epiphany_view_needs_runtime_store;
|
||||
use epiphany_codex_bridge::view::map_epiphany_context_response;
|
||||
use epiphany_codex_bridge::view::map_epiphany_freshness_response;
|
||||
use epiphany_codex_bridge::view::map_epiphany_graph_query_response;
|
||||
use epiphany_codex_bridge::view::map_epiphany_reorient_result_response;
|
||||
use epiphany_codex_bridge::view::map_epiphany_role_result_response;
|
||||
use epiphany_codex_bridge::view::map_epiphany_view_response;
|
||||
|
|
@ -257,25 +258,15 @@ impl CodexMessageProcessor {
|
|||
} else {
|
||||
None
|
||||
};
|
||||
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
|
||||
thread.epiphany_state.as_ref(),
|
||||
retrieval_override.as_ref(),
|
||||
watcher_snapshot
|
||||
let response = map_epiphany_freshness_response(EpiphanyFreshnessResponseInput {
|
||||
thread_id,
|
||||
loaded: loaded_thread.is_some(),
|
||||
state: thread.epiphany_state.as_ref(),
|
||||
retrieval_override: retrieval_override.as_ref(),
|
||||
watcher_snapshot: watcher_snapshot
|
||||
.as_ref()
|
||||
.map(epiphany_freshness_watcher_snapshot),
|
||||
);
|
||||
let response = ThreadEpiphanyFreshnessResponse {
|
||||
thread_id,
|
||||
source: if loaded_thread.is_some() {
|
||||
ThreadEpiphanyFreshnessSource::Live
|
||||
} else {
|
||||
ThreadEpiphanyFreshnessSource::Stored
|
||||
},
|
||||
state_revision,
|
||||
retrieval,
|
||||
graph,
|
||||
watcher,
|
||||
};
|
||||
});
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
|
|
@ -307,20 +298,12 @@ impl CodexMessageProcessor {
|
|||
}
|
||||
};
|
||||
|
||||
let (state_status, state_revision, context, missing) =
|
||||
map_epiphany_context(thread.epiphany_state.as_ref(), ¶ms);
|
||||
let response = ThreadEpiphanyContextResponse {
|
||||
let response = map_epiphany_context_response(
|
||||
thread_id,
|
||||
source: if loaded {
|
||||
ThreadEpiphanyContextSource::Live
|
||||
} else {
|
||||
ThreadEpiphanyContextSource::Stored
|
||||
},
|
||||
state_status,
|
||||
state_revision,
|
||||
context,
|
||||
missing,
|
||||
};
|
||||
loaded,
|
||||
thread.epiphany_state.as_ref(),
|
||||
¶ms,
|
||||
);
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
|
|
@ -352,23 +335,12 @@ impl CodexMessageProcessor {
|
|||
}
|
||||
};
|
||||
|
||||
let (state_status, state_revision, graph, frontier, checkpoint, matched, missing) =
|
||||
map_epiphany_graph_query(thread.epiphany_state.as_ref(), ¶ms.query);
|
||||
let response = ThreadEpiphanyGraphQueryResponse {
|
||||
let response = map_epiphany_graph_query_response(
|
||||
thread_id,
|
||||
source: if loaded {
|
||||
ThreadEpiphanyContextSource::Live
|
||||
} else {
|
||||
ThreadEpiphanyContextSource::Stored
|
||||
},
|
||||
state_status,
|
||||
state_revision,
|
||||
graph,
|
||||
frontier,
|
||||
checkpoint,
|
||||
matched,
|
||||
missing,
|
||||
};
|
||||
loaded,
|
||||
thread.epiphany_state.as_ref(),
|
||||
¶ms.query,
|
||||
);
|
||||
self.outgoing.send_response(request_id, response).await;
|
||||
}
|
||||
|
||||
|
|
|
|||
Reference in a new issue