Route Epiphany app-server DTOs through bridge

This commit is contained in:
Meta Vens 2026-05-18 07:23:12 +01:00
commit 38c1573166
7 changed files with 77 additions and 56 deletions

View file

@ -2,6 +2,7 @@ use chrono::SecondsFormat;
use chrono::Utc;
use codex_app_server_protocol::ThreadEpiphanyJob;
use codex_app_server_protocol::ThreadEpiphanyJobKind;
use codex_app_server_protocol::ThreadEpiphanyJobLaunchParams;
use codex_app_server_protocol::ThreadEpiphanyReorientDecision;
use codex_app_server_protocol::ThreadEpiphanyReorientFinding;
use codex_app_server_protocol::ThreadEpiphanyReorientSource;
@ -46,6 +47,7 @@ use crate::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
use crate::launch::build_epiphany_reorient_launch_request;
use crate::launch::build_epiphany_role_launch_request;
use crate::launch::epiphany_role_label;
use crate::launch::map_core_worker_launch_document;
use crate::mutation::build_reorient_acceptance_update;
use crate::mutation::build_role_acceptance_update;
use crate::mutation::epiphany_job_launch_changed_fields;
@ -510,6 +512,48 @@ pub async fn launch_thread_epiphany_job(
})
}
pub async fn launch_thread_epiphany_job_from_route_params(
thread: &CodexThread,
params: ThreadEpiphanyJobLaunchParams,
) -> Result<EpiphanyJobLaunchApplied, CodexErr> {
let ThreadEpiphanyJobLaunchParams {
thread_id: _,
expected_revision,
binding_id,
kind,
scope,
owner_role,
authority_scope,
linked_subgoal_ids,
linked_graph_node_ids,
instruction,
launch_document,
output_contract_id,
max_runtime_seconds,
} = params;
let launch_document = map_core_worker_launch_document(launch_document);
launch_thread_epiphany_job(
thread,
EpiphanyJobLaunchRequest {
expected_revision,
binding_id,
kind,
scope,
owner_role,
authority_scope,
linked_subgoal_ids,
linked_graph_node_ids,
instruction,
launch_document,
output_contract_id,
max_runtime_seconds,
},
kind,
"missing launched job projection",
)
.await
}
fn open_epiphany_runtime_spine_job(
store_path: &std::path::Path,
state: &EpiphanyThreadState,

View file

@ -11,6 +11,15 @@ use epiphany_core::EpiphanyRetrieveQuery;
use epiphany_core::EpiphanyRetrieveResponse as CoreEpiphanyRetrieveResponse;
use epiphany_core::EpiphanyRetrieveResult as CoreEpiphanyRetrieveResult;
use epiphany_core::EpiphanyRetrieveResultKind as CoreEpiphanyRetrieveResultKind;
use std::path::PathBuf;
pub fn normalize_thread_epiphany_retrieve_query(
query: String,
limit: Option<u32>,
path_prefixes: Vec<PathBuf>,
) -> std::result::Result<EpiphanyRetrieveQuery, &'static str> {
epiphany_core::normalize_epiphany_retrieve_query(query, limit, path_prefixes)
}
pub async fn thread_epiphany_retrieval_state(thread: &CodexThread) -> EpiphanyRetrievalState {
let config = thread.config_snapshot().await;

View file

@ -62,6 +62,7 @@ remembers doctrine; the branch remembers the blade.
- Epiphany memory graph loading and runtime-spine path derivation now belong to `epiphany-codex-bridge::state`. Vendored app-server read routes may decide whether a loaded thread exists, but they no longer own memory graph or runtime-spine store path/load mechanics.
- Epiphany job launch/interrupt policy and state-update application now belong to `epiphany-codex-bridge::mutation_service`: heartbeat launch planning, runtime-spine job opening, binding/runtime-link mutation, interrupt binding cleanup, and typed patch apply are out of vendored `CodexThread`. `CodexThread` now exposes only the narrow Codex-session host seam for reading current Epiphany state/reference turn and persisting an already-mutated snapshot into rollout/session storage.
- Epiphany retrieval status, indexing, and retrieval execution now belong to `epiphany-codex-bridge::retrieve`; vendored `CodexThread` only exposes cwd/codex-home host facts for that path.
- Vendored app-server no longer imports `epiphany_core` directly. Retrieval query normalization and raw route job-launch DTO construction are bridge-owned adapters; the remaining direct native render call is in Codex core's model-context prompt fragment host seam.
- Heartbeat durable document/schema types now live in `epiphany-core/src/heartbeat_state/heartbeat_documents.rs`, role/default construction lives in `epiphany-core/src/heartbeat_state/heartbeat_roles.rs`, persistence/validation lives in `epiphany-core/src/heartbeat_state/heartbeat_store.rs`, and status/artifact JSON projection lives in `epiphany-core/src/heartbeat_state/heartbeat_projection.rs`. The root `heartbeat_state.rs` keeps scheduling and Void cognition orchestration for the next cuts. Focused heartbeat tests and `epiphany-core` check pass after the splits.
- Heartbeat role/default and store seams now have module-local unit tests: fixed lane catalog, Ghostlight scene role projection, and typed state/cognition CultCache round-trip. Keep future heartbeat cuts aligned to those seam tests instead of growing root integration-only coverage.
- Heartbeat adaptive pacing now lives in `epiphany-core/src/heartbeat_state/heartbeat_pacing.rs`, including running-turn count and effective cooldown multipliers. It has a module-local unit test for pending-turn counting; root scheduling calls the pacing seam instead of owning pressure/concurrency math directly.

Binary file not shown.

View file

@ -34,6 +34,9 @@ objective:
Retrieval status, indexing, and retrieval execution now live in
`epiphany-codex-bridge::retrieve`; vendored Codex supplies cwd/codex-home
host facts rather than owning Epiphany retrieval behavior.
Vendored app-server no longer imports `epiphany_core` directly; retrieval
query normalization and route job-launch DTO construction are bridge-owned
adapters.
constraints:
- No frontier-scale training tithe.

View file

@ -6,7 +6,6 @@ use codex_protocol::protocol::EpiphanyThreadState;
use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot;
use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
use epiphany_codex_bridge::launch::epiphany_role_binding_id;
use epiphany_codex_bridge::launch::map_core_worker_launch_document;
use epiphany_codex_bridge::mutation::epiphany_state_updated_notification;
use epiphany_codex_bridge::mutation_service::EpiphanyThreadPromoteApplied;
use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_promote;
@ -14,12 +13,11 @@ use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_reorient_acce
use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_role_accept;
use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_update;
use epiphany_codex_bridge::mutation_service::interrupt_thread_epiphany_job;
use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_job;
use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_job_from_route_params;
use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_reorient;
use epiphany_codex_bridge::mutation_service::launch_thread_epiphany_role;
use epiphany_codex_bridge::retrieve::index_thread_epiphany_retrieval;
use epiphany_codex_bridge::retrieve::thread_epiphany_retrieval_state;
use epiphany_core::EpiphanyJobLaunchRequest;
use std::sync::Arc;
use super::CodexMessageProcessor;
@ -550,63 +548,29 @@ impl CodexMessageProcessor {
request_id: ConnectionRequestId,
params: ThreadEpiphanyJobLaunchParams,
) {
let ThreadEpiphanyJobLaunchParams {
thread_id,
expected_revision,
binding_id,
kind,
scope,
owner_role,
authority_scope,
linked_subgoal_ids,
linked_graph_node_ids,
instruction,
launch_document,
output_contract_id,
max_runtime_seconds,
} = params;
let thread_id = params.thread_id.clone();
let (thread_uuid, thread) = match self.load_epiphany_thread(&request_id, &thread_id).await {
Some(thread) => thread,
None => return,
};
let launch_document = map_core_worker_launch_document(launch_document);
let applied = match launch_thread_epiphany_job(
thread.as_ref(),
EpiphanyJobLaunchRequest {
expected_revision,
binding_id: binding_id.clone(),
kind,
scope,
owner_role,
authority_scope,
linked_subgoal_ids,
linked_graph_node_ids,
instruction,
launch_document,
output_contract_id,
max_runtime_seconds,
},
kind,
"missing launched job projection",
)
.await
{
Ok(applied) => applied,
Err(CodexErr::InvalidRequest(message)) => {
self.send_invalid_request_error(request_id, message).await;
return;
}
Err(err) => {
self.send_internal_error(
request_id,
format!("failed to launch Epiphany job for {thread_uuid}: {err}"),
)
.await;
return;
}
};
let applied =
match launch_thread_epiphany_job_from_route_params(thread.as_ref(), params).await {
Ok(applied) => applied,
Err(CodexErr::InvalidRequest(message)) => {
self.send_invalid_request_error(request_id, message).await;
return;
}
Err(err) => {
self.send_internal_error(
request_id,
format!("failed to launch Epiphany job for {thread_uuid}: {err}"),
)
.await;
return;
}
};
let changed_fields = applied.changed_fields;
let epiphany_state = applied.epiphany_state;

View file

@ -4,6 +4,7 @@ use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot;
use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
use epiphany_codex_bridge::launch::epiphany_role_binding_id;
use epiphany_codex_bridge::retrieve::map_epiphany_retrieve_response;
use epiphany_codex_bridge::retrieve::normalize_thread_epiphany_retrieve_query;
use epiphany_codex_bridge::retrieve::retrieve_thread_epiphany;
use epiphany_codex_bridge::retrieve::thread_epiphany_retrieval_state;
use epiphany_codex_bridge::state::load_optional_thread_memory_graph_snapshot;
@ -25,7 +26,6 @@ use epiphany_codex_bridge::view::map_epiphany_propose_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;
use epiphany_core::normalize_epiphany_retrieve_query;
use super::CodexMessageProcessor;
use super::ConnectionRequestId;
@ -463,7 +463,7 @@ impl CodexMessageProcessor {
}
};
let query = match normalize_epiphany_retrieve_query(query, limit, path_prefixes) {
let query = match normalize_thread_epiphany_retrieve_query(query, limit, path_prefixes) {
Ok(query) => query,
Err(message) => {
self.send_invalid_request_error(request_id, message.to_string())