Skip to main content

MAX_SEARCH_LIMIT

Constant MAX_SEARCH_LIMIT 

Source
pub const MAX_SEARCH_LIMIT: usize = 100;
Expand description

Upper bound clamped onto every caller-supplied limit/top_k search parameter inside this crate (issue #6553).

embedding_store::EmbeddingStore::search, embedding_store::EmbeddingStore::search_collection, embedding_registry::EmbeddingRegistry::search_raw, and reasoning::ReasoningMemory::retrieve_by_embedding all enforce this bound directly, so the safety guarantee does not depend on every external caller (MCP tools, plugins, future call sites) remembering to clamp before forwarding a value here.

100 bounds the Qdrant result set Zeph will allocate/deserialize in a single call. Note this can clamp a legitimate config-driven candidate pool: memory.retrieval.depth and memory.session.recall_limit have no upper-bound validation today, and retrieval.depth’s own doc actively recommends raising it (“higher for better MMR diversity”) with no ceiling — an operator who does so past 100 gets a silently smaller ANN pool than configured. Each clamping call site logs a tracing::warn! the first time this happens so the degradation is observable rather than silent; there is deliberately no config knob to raise this ceiling, since doing so would reopen the oversized-result-set DoS this constant exists to close.

§Examples

use zeph_memory::MAX_SEARCH_LIMIT;

let requested = 5_000_usize;
assert_eq!(requested.clamp(1, MAX_SEARCH_LIMIT), MAX_SEARCH_LIMIT);