From 40e7ba92541ece4afe1d33f16ae93bf3c5a330e1 Mon Sep 17 00:00:00 2001 From: Neeraj Sathish Kumar Date: Mon, 4 May 2026 17:13:04 +0530 Subject: [PATCH] fix: enforce trusted floor for ingestion write thresholds --- src/runtime/ingestion.rs | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/runtime/ingestion.rs b/src/runtime/ingestion.rs index ba17467..400a289 100644 --- a/src/runtime/ingestion.rs +++ b/src/runtime/ingestion.rs @@ -11,6 +11,9 @@ use crate::{ }; use serde::{Deserialize, Serialize}; +const MIN_IMPORTANCE_SCORE: f32 = 0.2; +const MIN_CONFIDENCE_SCORE: f32 = 0.2; + #[derive(Debug, Clone, Serialize, Deserialize, PartialEq)] pub struct IngestMemoryRequest { pub id: Option, @@ -115,10 +118,12 @@ where if request.content.trim().is_empty() { errors.push("content cannot be empty".to_string()); } - if request.importance_score < request.policy.min_importance_score { + let min_importance_score = request.policy.min_importance_score.max(MIN_IMPORTANCE_SCORE); + let min_confidence_score = request.policy.min_confidence_score.max(MIN_CONFIDENCE_SCORE); + if request.importance_score < min_importance_score { errors.push("importance_score is below write threshold".to_string()); } - if request.confidence_score.unwrap_or(0.0) < request.policy.min_confidence_score { + if request.confidence_score.unwrap_or(0.0) < min_confidence_score { errors.push("confidence_score is below write threshold".to_string()); } if !errors.is_empty() {