use crate::anchor::{Anchor, AnchorGraph};
use crate::error::FoldError;
use crate::objective::{Objective, ObjectiveContext};
use crate::selector::{Selector, SelectorInput, SelectorOutput, SelectorWeights};
pub struct ComposePipeline<T> {
pub anchor: Box<dyn Anchor>,
pub objective: Box<dyn Objective<T>>,
pub selector: Box<dyn Selector<T>>,
}
impl<T: Clone + Send + Sync + 'static> ComposePipeline<T> {
pub fn execute(
&self,
_graph: &AnchorGraph,
candidates: Vec<SelectorInput<T>>,
budget: usize,
weights: &SelectorWeights,
context: &ObjectiveContext,
) -> Result<SelectorOutput<T>, FoldError> {
let scored = candidates
.into_iter()
.map(|mut candidate| {
candidate.score = self.objective.score(&candidate.content, context) as f32;
candidate
})
.collect();
self.selector.select(scored, budget, weights)
}
}