x_pipe_rs/lib.rs
1//! Composable recommendation and feed pipeline framework.
2//!
3//! `x-pipe-rs` provides a typed, composable pipeline for assembling
4//! ranked feeds, inspired by the X algorithm's candidate-pipeline
5//! architecture. Every pipeline stage is a Kleisli arrow in the
6//! [`Io`] monad from [`comp_cat_rs`]; composition is Kleisli
7//! composition, which by `comp-cat-rs`'s collapse hierarchy is
8//! a Kan extension.
9//!
10//! # Architecture
11//!
12//! A pipeline assembles six kinds of stages:
13//!
14//! 1. **[`Source`]** -- produce candidate items from backends
15//! 2. **[`Hydrator`]** -- enrich candidates with additional data
16//! 3. **[`Filter`]** -- remove candidates that fail criteria
17//! 4. **[`Scorer`]** -- assign relevance scores
18//! 5. **[`Selector`]** -- choose final candidates (dedup, diversity, budget)
19//! 6. **[`SideEffect`]** -- observe without modifying (logging, metrics)
20//!
21//! Each trait converts to a [`Stage`], the universal Kleisli arrow
22//! type. Stages compose via [`Stage::then`] (Kleisli composition).
23//! The final [`Pipeline`] is itself a single `Stage` from query to
24//! scored results.
25//!
26//! # Categorical justification
27//!
28//! [`Stage`] forms a category whose morphisms are Kleisli arrows
29//! `A -> Io<E, B>`. Composition is associative with identity, and
30//! by `collapse::monad_is_kan` every such composition is a pair of
31//! Kan extensions. [`Score`] implements [`JoinSemilattice`], making
32//! score merging a colimit (left Kan extension).
33//!
34//! [`Io`]: comp_cat_rs::effect::io::Io
35//! [`JoinSemilattice`]: comp_cat_rs::foundation::semilattice::JoinSemilattice
36
37pub mod error;
38pub mod filter;
39pub mod hydrator;
40pub mod pipeline;
41pub mod score;
42pub mod scorer;
43pub mod selector;
44pub mod side_effect;
45pub mod source;
46pub mod stage;
47
48pub use error::PipelineError;
49pub use filter::Filter;
50pub use hydrator::Hydrator;
51pub use pipeline::Pipeline;
52pub use score::{Score, ScoredCandidate};
53pub use scorer::Scorer;
54pub use selector::{Budget, MaxItems, Selector};
55pub use side_effect::SideEffect;
56pub use source::Source;
57pub use stage::Stage;