diff --git a/src/worker/job_worker.rs b/src/worker/job_worker.rs index 00215d06..a503af48 100644 --- a/src/worker/job_worker.rs +++ b/src/worker/job_worker.rs @@ -1860,8 +1860,30 @@ impl JobWorker { } } - // VLM summary: non-blocking — log progress but don't block job completion - let vlm_done_bool: bool = true; + // VLM summary: blocking — wait for all traces to have VLM description + let tp_table_vlm = schema::table_name("trace_profiles"); + let vlm_total: i64 = sqlx::query_scalar(&format!( + "SELECT COUNT(*) FROM {tp_table_vlm} WHERE file_uuid = $1" + )) + .bind(uuid) + .fetch_one(pool) + .await + .unwrap_or(0); + let vlm_done_count: i64 = sqlx::query_scalar(&format!( + "SELECT COUNT(*) FROM {tp_table_vlm} WHERE file_uuid = $1 AND vlm_description IS NOT NULL AND vlm_description != ''" + )) + .bind(uuid) + .fetch_one(pool) + .await + .unwrap_or(0); + let vlm_done_bool: bool = if vlm_total > 0 { vlm_done_count >= vlm_total } else { true }; + + if vlm_total > 0 { + tracing::info!( + "[Ingestion] vlm_summary={}/{} for uuid={}", + vlm_done_count, vlm_total, uuid + ); + } let all_ok = asr_done && trace_done && tkg_done && face_cluster_done && qdrant_face_done && vlm_done_bool;