Move freshness surface to CultNet types

This commit is contained in:
Meta Vens 2026-05-19 16:35:58 +01:00
commit 37ea4ff2c3
6 changed files with 168 additions and 22 deletions

View file

@ -0,0 +1,27 @@
use epiphany_core::EpiphanyGraphFreshness;
use epiphany_core::EpiphanyInvalidationInput;
use epiphany_core::EpiphanyRetrievalFreshness;
pub use epiphany_core::EpiphanyGraphFreshnessStatus;
pub use epiphany_core::EpiphanyInvalidationStatus;
pub use epiphany_core::EpiphanyRetrievalFreshnessStatus;
use serde::Deserialize;
use serde::Serialize;
#[derive(Debug, Clone, Copy, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub enum EpiphanySurfaceSource {
Stored,
Live,
}
#[derive(Debug, Clone, PartialEq, Eq, Serialize, Deserialize)]
#[serde(rename_all = "camelCase")]
pub struct EpiphanyFreshnessSurface {
pub thread_id: String,
pub source: EpiphanySurfaceSource,
#[serde(default, skip_serializing_if = "Option::is_none")]
pub state_revision: Option<u64>,
pub retrieval: EpiphanyRetrievalFreshness,
pub graph: EpiphanyGraphFreshness,
pub watcher: EpiphanyInvalidationInput,
}

View file

@ -1,6 +1,7 @@
pub mod checkpoint;
pub mod context;
pub mod coordinator;
pub mod cultnet;
pub mod error;
pub mod invalidation;
pub mod jobs;

View file

@ -51,18 +51,26 @@ pub fn map_epiphany_freshness(
ThreadEpiphanyGraphFreshness,
ThreadEpiphanyInvalidationInput,
) {
let freshness = derive_epiphany_freshness_view(state, retrieval_override, watcher_snapshot);
map_core_epiphany_freshness(freshness)
}
pub fn derive_epiphany_freshness_view(
state: Option<&EpiphanyThreadState>,
retrieval_override: Option<&EpiphanyRetrievalState>,
watcher_snapshot: Option<EpiphanyFreshnessWatcherSnapshot<'_>>,
) -> EpiphanyFreshnessView {
let watcher = watcher_snapshot.map(|snapshot| EpiphanyFreshnessWatcherInput {
available: snapshot.available,
workspace_root: snapshot.workspace_root,
observed_at_unix_seconds: snapshot.observed_at_unix_seconds,
changed_paths: snapshot.changed_paths,
});
let freshness = derive_freshness(EpiphanyFreshnessInput {
derive_freshness(EpiphanyFreshnessInput {
state,
retrieval_override,
watcher,
});
map_core_epiphany_freshness(freshness)
})
}
fn map_core_epiphany_freshness(

View file

@ -20,10 +20,13 @@ use crate::coordinator::map_epiphany_coordinator_view;
use crate::coordinator::map_epiphany_crrc_recommendation;
use crate::coordinator::map_epiphany_roles;
use crate::coordinator::render_epiphany_roles_note;
use crate::cultnet::EpiphanyFreshnessSurface;
use crate::cultnet::EpiphanySurfaceSource;
use crate::jobs::map_epiphany_jobs;
use crate::launch::EPIPHANY_REORIENT_LAUNCH_BINDING_ID;
use crate::pressure::map_epiphany_pressure;
use crate::reorient::EpiphanyFreshnessWatcherSnapshot;
use crate::reorient::derive_epiphany_freshness_view;
use crate::reorient::map_epiphany_freshness;
use crate::reorient::map_epiphany_reorient;
use crate::runtime_results::load_epiphany_reorient_result_snapshot;
@ -77,25 +80,25 @@ pub struct EpiphanyFreshnessResponseInput<'a> {
pub watcher_snapshot: Option<EpiphanyFreshnessWatcherSnapshot<'a>>,
}
pub fn map_epiphany_freshness_response(
pub fn derive_epiphany_freshness_surface(
input: EpiphanyFreshnessResponseInput<'_>,
) -> ThreadEpiphanyFreshnessResponse {
let (state_revision, retrieval, graph, watcher) = map_epiphany_freshness(
) -> EpiphanyFreshnessSurface {
let freshness = derive_epiphany_freshness_view(
input.state,
input.retrieval_override,
input.watcher_snapshot,
);
ThreadEpiphanyFreshnessResponse {
EpiphanyFreshnessSurface {
thread_id: input.thread_id,
source: if input.loaded {
ThreadEpiphanyFreshnessSource::Live
EpiphanySurfaceSource::Live
} else {
ThreadEpiphanyFreshnessSource::Stored
EpiphanySurfaceSource::Stored
},
state_revision,
retrieval,
graph,
watcher,
state_revision: freshness.state_revision,
retrieval: freshness.retrieval,
graph: freshness.graph,
watcher: freshness.watcher,
}
}