pub struct DeduplicationConfig {
pub enabled: bool,
pub similarity_thresholds: HashMap<Namespace, f32>,
pub default_threshold: f32,
pub recent_window: Duration,
pub cache_capacity: usize,
pub min_semantic_length: usize,
}Expand description
Configuration for the deduplication service.
§Environment Variables
| Variable | Type | Default | Description |
|---|---|---|---|
SUBCOG_DEDUP_ENABLED | bool | true | Enable deduplication |
SUBCOG_DEDUP_THRESHOLD_DECISIONS | f32 | 0.92 | Threshold for decisions namespace |
SUBCOG_DEDUP_THRESHOLD_PATTERNS | f32 | 0.90 | Threshold for patterns namespace |
SUBCOG_DEDUP_THRESHOLD_LEARNINGS | f32 | 0.88 | Threshold for learnings namespace |
SUBCOG_DEDUP_THRESHOLD_DEFAULT | f32 | 0.90 | Default threshold |
SUBCOG_DEDUP_TIME_WINDOW_SECS | u64 | 300 | Recent capture window |
SUBCOG_DEDUP_CACHE_CAPACITY | usize | 1000 | LRU cache size |
SUBCOG_DEDUP_MIN_SEMANTIC_LENGTH | usize | 50 | Min content length for semantic check |
§Example
use subcog::services::deduplication::DeduplicationConfig;
use subcog::models::Namespace;
let config = DeduplicationConfig::default();
assert!(config.enabled);
assert_eq!(config.default_threshold, 0.90);
assert_eq!(config.get_threshold(Namespace::Decisions), 0.92);Fields§
§enabled: boolEnable/disable entire deduplication.
similarity_thresholds: HashMap<Namespace, f32>Per-namespace similarity thresholds.
default_threshold: f32Default threshold when namespace not configured.
recent_window: DurationRecent capture time window.
cache_capacity: usizeRecent capture cache capacity.
min_semantic_length: usizeMinimum content length for semantic check.
Content shorter than this will skip semantic similarity checking and rely only on exact match and recent capture detection.
Implementations§
Source§impl DeduplicationConfig
impl DeduplicationConfig
Sourcepub fn from_env() -> Self
pub fn from_env() -> Self
Creates a new configuration from environment variables.
Falls back to defaults for any unset variables.
§Example
use subcog::services::deduplication::DeduplicationConfig;
let config = DeduplicationConfig::from_env();
// Config is populated from environment with defaultsSourcepub fn get_threshold(&self, namespace: Namespace) -> f32
pub fn get_threshold(&self, namespace: Namespace) -> f32
Gets the similarity threshold for a namespace.
Returns the namespace-specific threshold if configured, otherwise returns the default threshold.
§Arguments
namespace- The namespace to get the threshold for
§Example
use subcog::services::deduplication::DeduplicationConfig;
use subcog::models::Namespace;
let config = DeduplicationConfig::default();
assert_eq!(config.get_threshold(Namespace::Decisions), 0.92);
assert_eq!(config.get_threshold(Namespace::Patterns), 0.90);Sourcepub const fn with_enabled(self, enabled: bool) -> Self
pub const fn with_enabled(self, enabled: bool) -> Self
Builder method to set enabled state.
Sourcepub fn with_threshold(self, namespace: Namespace, threshold: f32) -> Self
pub fn with_threshold(self, namespace: Namespace, threshold: f32) -> Self
Builder method to set a namespace threshold.
Sourcepub const fn with_default_threshold(self, threshold: f32) -> Self
pub const fn with_default_threshold(self, threshold: f32) -> Self
Builder method to set the default threshold.
Sourcepub const fn with_recent_window(self, duration: Duration) -> Self
pub const fn with_recent_window(self, duration: Duration) -> Self
Builder method to set the recent window duration.
Sourcepub const fn with_cache_capacity(self, capacity: usize) -> Self
pub const fn with_cache_capacity(self, capacity: usize) -> Self
Builder method to set the cache capacity.
Sourcepub const fn with_min_semantic_length(self, length: usize) -> Self
pub const fn with_min_semantic_length(self, length: usize) -> Self
Builder method to set the minimum semantic length.
Trait Implementations§
Source§impl Clone for DeduplicationConfig
impl Clone for DeduplicationConfig
Source§fn clone(&self) -> DeduplicationConfig
fn clone(&self) -> DeduplicationConfig
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for DeduplicationConfig
impl Debug for DeduplicationConfig
Auto Trait Implementations§
impl Freeze for DeduplicationConfig
impl RefUnwindSafe for DeduplicationConfig
impl Send for DeduplicationConfig
impl Sync for DeduplicationConfig
impl Unpin for DeduplicationConfig
impl UnwindSafe for DeduplicationConfig
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<T> FutureExt for T
impl<T> FutureExt for T
§fn with_context(self, otel_cx: Context) -> WithContext<Self>
fn with_context(self, otel_cx: Context) -> WithContext<Self>
§fn with_current_context(self) -> WithContext<Self>
fn with_current_context(self) -> WithContext<Self>
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more§impl<T> IntoRequest<T> for T
impl<T> IntoRequest<T> for T
§fn into_request(self) -> Request<T>
fn into_request(self) -> Request<T>
T in a tonic::Request§impl<L> LayerExt<L> for L
impl<L> LayerExt<L> for L
§fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
fn named_layer<S>(&self, service: S) -> Layered<<L as Layer<S>>::Service, S>where
L: Layer<S>,
Layered].