Skip to main content

Crate khive_fold

Crate khive_fold 

Source
Expand description

Fold, Anchor, Objective, and Selector primitives with deterministic ordering and composition.

Re-exports§

pub use checkpoint::Checkpoint;
pub use checkpoint::CheckpointStore;
pub use checkpoint::InMemoryCheckpointStore;
pub use anchor::Anchor;
pub use anchor::AnchorGraph;
pub use anchor::AnchorRef;
pub use anchor::BfsAnchor;
pub use selector::GreedySelector;
pub use selector::Selector;
pub use selector::SelectorInput;
pub use selector::SelectorOutput;
pub use selector::SelectorWeights;
pub use objective::builtin::FirstMatchObjective;
pub use objective::builtin::HasSalience;
pub use objective::builtin::HasTimestamp;
pub use objective::builtin::MaxScoreObjective;
pub use objective::builtin::RecencyObjective;
pub use objective::builtin::RelevanceObjective;
pub use objective::builtin::SalienceObjective;
pub use objective::builtin::ThresholdObjective;
pub use objective::compose::ConsensusObjective;
pub use objective::compose::NegateObjective;
pub use objective::compose::PriorityObjective;
pub use objective::compose::ScaleObjective;
pub use objective::compose::UnionObjective;
pub use objective::compose::WeightedObjective;
pub use objective::error::ObjectiveError;
pub use objective::error::ObjectiveResult;
pub use objective::objective_fn;
pub use objective::DeterministicObjective;
pub use objective::Objective;
pub use objective::ObjectiveContext;
pub use objective::Selection;
pub use ordering::canonical_f32;
pub use ordering::canonical_f64;
pub use ordering::cmp_asc_score_then_id;
pub use ordering::cmp_desc_score_then_id;
pub use ordering::HasId;
pub use ordering::ScoredEntry;

Modules§

anchor
Anchor and AnchorGraph: in-memory causal provenance chains for credit assignment.
checkpoint
Generic checkpoint envelope and in-memory store for fold-managed indexes.
objective
Objective function framework — scoring, selection, composition.
ordering
Deterministic ordering primitives: HasId, ScoredEntry, canonical f32/f64, UUID tie-breaking.
selector
Selector: many → subset under budget.

Structs§

AnyFold
A zero-allocation existential fold with a function-pointer predicate.
ComposePipeline
Pipeline that scores candidates with an objective then packs to budget via a selector.
CountFold
A zero-allocation count fold.
DeterministicScore
Fixed-point score wrapping an i64 scaled by 2^32.
DualFold
Dual fold — run two independent folds over the same entries sequentially.
FilterCountFold
A zero-allocation count fold with a function-pointer predicate.
FilterFold
Filter fold — only process entries matching a predicate.
FnFold
Helper to create a fold from closures.
FoldContext
Context for fold operations; as_of defaults to Unix epoch.
FoldOutcome
Outcome of a fold operation.
MapFold
Map fold — transform entries before folding.
Ranked
Scored item implementing max-heap Ord: higher score wins, lower ID breaks ties.
SequentialFold
Sequential fold — run one fold, then use its output to inform another.
SharedJson
Arc-backed shared JSON value; cheap to clone in hot paths.
SumI64Fold
A zero-allocation i64 summation fold with a function-pointer projection.

Enums§

CommonFold
Enum-dispatch fold for common allocation-free patterns without vtable overhead.
CommonFoldState
Unified state returned by CommonFold.
FoldError
Errors that can occur in fold operations
FoldFailure
Failure returned by fallible fold operations.

Traits§

Fold
Core fold trait: collapses a sequence of entries into deterministic derived state.
TryFold
Fallible fold step API for reducers that can reject invalid state shapes.

Functions§

cmp_asc_then_id
Compare scores ascending, lower ID wins ties.
cmp_desc_then_id
Compare scores descending, lower ID wins ties.
filter
Helper to create a filter fold.
fold_fn
Create a fold from just initial and step functions (no finalize).
map
Helper to create a map fold.

Type Aliases§

BoxedFold
A boxed fold for dynamic dispatch.
FoldResult
Result type for fold operations
FoldResultType
Result type for fold operations