Move state notification projection to protocol edge

This commit is contained in:
Meta Vens 2026-05-20 14:25:29 +01:00
commit 2bf0506167
7 changed files with 84 additions and 81 deletions

View file

@ -1,7 +1,6 @@
use std::sync::Arc;
use codex_app_server_protocol::ServerNotification;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedNotification;
use codex_app_server_protocol::ThreadEpiphanyStateUpdatedSource;
use codex_core::CodexThread;
use codex_core::SteerInputError;
@ -15,11 +14,11 @@ use epiphany_codex_bridge::coordinator::select_epiphany_coordinator_automation;
use epiphany_codex_bridge::invalidation::EpiphanyInvalidationManager;
use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot;
use epiphany_codex_bridge::mutation::epiphany_job_launch_changed_fields;
use epiphany_codex_bridge::mutation::map_protocol_state_updated_fields;
use epiphany_codex_bridge::mutation_service::launch_epiphany_job_on_thread;
use epiphany_codex_bridge::pressure::derive_epiphany_pressure;
use epiphany_codex_bridge::pressure::render_epiphany_pre_compaction_checkpoint_intervention;
use epiphany_codex_bridge::pressure::should_run_epiphany_pre_compaction_checkpoint_intervention;
use epiphany_codex_bridge::protocol_edge::protocol_state_updated_notification;
use epiphany_codex_bridge::retrieve::epiphany_retrieval_state_for_paths;
use tokio::sync::Mutex;
use tracing::warn;
@ -95,15 +94,13 @@ pub(crate) async fn maybe_run_epiphany_coordinator_automation_for_turn_boundary(
.await;
outgoing
.send_server_notification(ServerNotification::ThreadEpiphanyStateUpdated(
ThreadEpiphanyStateUpdatedNotification {
thread_id: thread_id_text,
source: ThreadEpiphanyStateUpdatedSource::JobLaunch,
revision: epiphany_state.revision,
changed_fields: map_protocol_state_updated_fields(
epiphany_job_launch_changed_fields(),
),
protocol_state_updated_notification(
thread_id_text,
ThreadEpiphanyStateUpdatedSource::JobLaunch,
epiphany_state.revision,
epiphany_job_launch_changed_fields(),
epiphany_state,
},
),
))
.await;
}

View file

@ -9,8 +9,6 @@ use epiphany_codex_bridge::invalidation::epiphany_freshness_watcher_snapshot;
use epiphany_codex_bridge::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
use epiphany_codex_bridge::launch::build_epiphany_job_launch_request;
use epiphany_codex_bridge::launch::epiphany_role_binding_id;
use epiphany_codex_bridge::mutation::epiphany_state_updated_notification;
use epiphany_codex_bridge::mutation::map_protocol_state_updated_fields;
use epiphany_codex_bridge::mutation_service::EpiphanyThreadPromoteApplied;
use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_promote;
use epiphany_codex_bridge::mutation_service::apply_thread_epiphany_reorient_accept;
@ -28,6 +26,8 @@ use epiphany_codex_bridge::protocol_edge::protocol_reorient_source;
use epiphany_codex_bridge::protocol_edge::protocol_reorient_state_status;
use epiphany_codex_bridge::protocol_edge::protocol_role_finding;
use epiphany_codex_bridge::protocol_edge::protocol_role_id_to_core;
use epiphany_codex_bridge::protocol_edge::protocol_state_updated_fields;
use epiphany_codex_bridge::protocol_edge::protocol_state_updated_notification;
use epiphany_codex_bridge::protocol_edge::protocol_update_patch_to_core;
use epiphany_codex_bridge::protocol_edge::protocol_worker_launch_document_to_core;
use epiphany_codex_bridge::retrieve::epiphany_retrieval_state_for_paths;
@ -82,7 +82,7 @@ impl CodexMessageProcessor {
) {
self.outgoing
.send_server_notification(ServerNotification::ThreadEpiphanyStateUpdated(
epiphany_state_updated_notification(
protocol_state_updated_notification(
thread_uuid.to_string(),
source,
epiphany_state.revision,
@ -136,7 +136,7 @@ impl CodexMessageProcessor {
}
};
let changed_fields = applied.changed_fields;
let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone());
let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone());
let epiphany_state = applied.epiphany_state;
self.outgoing
@ -216,7 +216,7 @@ impl CodexMessageProcessor {
}
};
let changed_fields = applied.changed_fields;
let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone());
let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone());
let epiphany_state = applied.epiphany_state;
self.outgoing
@ -314,7 +314,7 @@ impl CodexMessageProcessor {
}
};
let changed_fields = applied.changed_fields;
let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone());
let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone());
let epiphany_state = applied.epiphany_state;
self.outgoing
@ -390,7 +390,7 @@ impl CodexMessageProcessor {
}
};
let changed_fields = applied.changed_fields;
let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone());
let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone());
let epiphany_state = applied.epiphany_state;
self.outgoing
@ -516,7 +516,7 @@ impl CodexMessageProcessor {
}
};
let changed_fields = applied.changed_fields;
let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone());
let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone());
let epiphany_state = applied.epiphany_state;
let response = ThreadEpiphanyPromoteResponse {
accepted: true,
@ -571,7 +571,7 @@ impl CodexMessageProcessor {
}
};
let changed_fields = applied.changed_fields;
let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone());
let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone());
let epiphany_state = applied.epiphany_state;
let response = ThreadEpiphanyUpdateResponse {
revision: applied.revision,
@ -653,7 +653,7 @@ impl CodexMessageProcessor {
}
};
let changed_fields = applied.changed_fields;
let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone());
let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone());
let epiphany_state = applied.epiphany_state;
self.outgoing
@ -721,7 +721,7 @@ impl CodexMessageProcessor {
}
};
let changed_fields = applied.changed_fields;
let protocol_changed_fields = map_protocol_state_updated_fields(changed_fields.clone());
let protocol_changed_fields = protocol_state_updated_fields(changed_fields.clone());
let epiphany_state = applied.epiphany_state;
self.outgoing