feat: only run identity agent if file has seed identities

Identity agent now checks Qdrant _seeds collection for the file's
seed identity photos before running. If no seeds exist, the agent
is skipped to avoid unnecessary processing.

Flow:
1. Job completes (Face + ASRX done)
2. Check Qdrant _seeds for file_uuid
3. If seeds exist → run identity agent
4. If no seeds → skip identity agent
This commit is contained in:
Accusys
2026-07-05 22:22:22 +08:00
parent 0b82aa875c
commit 5a3f791ecd

View File

@@ -1786,23 +1786,49 @@ impl JobWorker {
}); });
} }
// 🚀 P3 Trigger: Identity Agent (Face + ASRX) // 🚀 P3 Trigger: Identity Agent (Face + ASRX + has seed identities)
if has_face && has_asrx { if has_face && has_asrx {
info!("📝 Prerequisites met for Identity Agent. Starting analysis..."); // Check if file has seed identity photos in Qdrant _seeds collection
let db_clone = self.db.clone(); let has_seeds = {
let redis_clone = self.redis.clone(); use crate::core::db::qdrant_db::QdrantDb;
let uuid_clone = uuid.to_string(); let qdrant = QdrantDb::new();
tokio::spawn(async move { let schema = std::env::var("DATABASE_SCHEMA").unwrap_or_else(|_| "dev".to_string());
match run_identity_agent(&db_clone, &uuid_clone, Some(redis_clone.clone())).await { let seeds_collection = if schema == "public" {
Ok(()) => { "momentry_public_seeds"
info!("✅ Identity Agent completed for {}", uuid_clone); } else {
let mut pp = PipelineProgress::new(&uuid_clone); &format!("momentry_{}_seeds", schema)
pp.update_stage("identity_agent", 1.0, "completed", None); };
publish_pipeline_progress(redis_clone.as_ref(), &uuid_clone, &pp).await; let filter = serde_json::json!({
"must": [{"key": "file_uuid", "match": {"value": uuid}}]
});
match qdrant.scroll_all_points("_seeds", filter, 1).await {
Ok(points) => !points.is_empty(),
Err(e) => {
warn!("Failed to check _seeds for {}: {}", uuid, e);
false
} }
Err(e) => error!("❌ Identity Agent failed for {}: {}", uuid_clone, e),
} }
}); };
if has_seeds {
info!("📝 Prerequisites met for Identity Agent (has seeds). Starting analysis...");
let db_clone = self.db.clone();
let redis_clone = self.redis.clone();
let uuid_clone = uuid.to_string();
tokio::spawn(async move {
match run_identity_agent(&db_clone, &uuid_clone, Some(redis_clone.clone())).await {
Ok(()) => {
info!("✅ Identity Agent completed for {}", uuid_clone);
let mut pp = PipelineProgress::new(&uuid_clone);
pp.update_stage("identity_agent", 1.0, "completed", None);
publish_pipeline_progress(redis_clone.as_ref(), &uuid_clone, &pp).await;
}
Err(e) => error!("❌ Identity Agent failed for {}: {}", uuid_clone, e),
}
});
} else {
info!("📝 Skipping Identity Agent for {} (no seed identities)", uuid);
}
} }
// 🚀 P4 Trigger: TKG Build (Face + ASRX) → then Rule2 ingestion // 🚀 P4 Trigger: TKG Build (Face + ASRX) → then Rule2 ingestion