Skip to main content

khive_fold/
lib.rs

1//! Fold, Anchor, Objective, and Selector primitives with deterministic ordering and composition.
2
3// ── Core fold ───────────────────────────────────────────────────────────
4
5mod compose;
6mod context;
7mod error;
8mod fold;
9mod result;
10
11// ── Checkpoint protocol ─────────────────────────────────────────────────
12
13pub mod checkpoint;
14
15pub use compose::{filter, map, DualFold, FilterFold, MapFold, SequentialFold};
16pub use context::{FoldContext, SharedJson};
17pub use error::{FoldError, FoldResult, FoldResult as FoldResultType};
18pub use fold::{
19    fold_fn, AnyFold, BoxedFold, CommonFold, CommonFoldState, CountFold, FilterCountFold, FnFold,
20    Fold, FoldFailure, SumI64Fold, TryFold,
21};
22pub use result::FoldOutcome;
23
24// ── Checkpoint re-exports ────────────────────────────────────────────────
25
26pub use checkpoint::{Checkpoint, CheckpointStore, InMemoryCheckpointStore};
27
28// ── Anchor primitive ────────────────────────────────────────────────────
29
30pub mod anchor;
31
32pub use anchor::{Anchor, AnchorGraph, AnchorRef, BfsAnchor};
33
34// ── Selector primitive ──────────────────────────────────────────────────
35
36pub mod selector;
37
38pub use selector::{GreedySelector, Selector, SelectorInput, SelectorOutput, SelectorWeights};
39
40// ── Objective primitive ─────────────────────────────────────────────────
41
42pub mod objective;
43pub mod ordering;
44
45pub use khive_score::{cmp_asc_then_id, cmp_desc_then_id, DeterministicScore};
46pub use objective::builtin::{
47    FirstMatchObjective, HasSalience, HasTimestamp, MaxScoreObjective, RecencyObjective,
48    RelevanceObjective, SalienceObjective, ThresholdObjective,
49};
50pub use objective::compose::{
51    ConsensusObjective, NegateObjective, PriorityObjective, ScaleObjective, UnionObjective,
52    WeightedObjective,
53};
54pub use objective::error::{ObjectiveError, ObjectiveResult};
55pub use objective::{objective_fn, DeterministicObjective, Objective, ObjectiveContext, Selection};
56pub use ordering::{
57    canonical_f32, canonical_f64, cmp_asc_score_then_id, cmp_desc_score_then_id, HasId, Ranked,
58    ScoredEntry,
59};
60
61// ── ComposePipeline ─────────────────────────────────────────────────────
62
63mod pipeline;
64pub use pipeline::ComposePipeline;