diff --git a/docs_v1.0/DESIGN/FACE_FILTER_FILE_STORAGE.md b/docs_v1.0/DESIGN/FACE_FILTER_FILE_STORAGE.md index 0995c961..9802e336 100644 --- a/docs_v1.0/DESIGN/FACE_FILTER_FILE_STORAGE.md +++ b/docs_v1.0/DESIGN/FACE_FILTER_FILE_STORAGE.md @@ -1,3 +1,5 @@ +> ⚠️ **DEPRECATED** - This document has been superseded by [Face Operations Complete](../REFERENCE/Face_Operations_Complete.md). See the new document for the complete and updated reference. +> # FaceFilterSettings 文件存储架构 **日期**: 2026-10-09 diff --git a/docs_v1.0/DESIGN/Face_Pipeline.md b/docs_v1.0/DESIGN/Face_Pipeline.md index 7da9abc3..8c4fdf29 100644 --- a/docs_v1.0/DESIGN/Face_Pipeline.md +++ b/docs_v1.0/DESIGN/Face_Pipeline.md @@ -1,3 +1,5 @@ +> ⚠️ **DEPRECATED** - This document has been superseded by [Face Operations Complete](../REFERENCE/Face_Operations_Complete.md). See the new document for the complete and updated reference. +> # Face Pipeline: Detection → Clustering → Trace **Date**: 2026-05-16 diff --git a/docs_v1.0/DESIGN/Rust_Store_Traced_Faces_Design.md b/docs_v1.0/DESIGN/Rust_Store_Traced_Faces_Design.md index c9da3e2f..665301c3 100644 --- a/docs_v1.0/DESIGN/Rust_Store_Traced_Faces_Design.md +++ b/docs_v1.0/DESIGN/Rust_Store_Traced_Faces_Design.md @@ -1,3 +1,5 @@ +> ⚠️ **DEPRECATED** - This document has been superseded by [Face Operations Complete](../REFERENCE/Face_Operations_Complete.md). See the new document for the complete and updated reference. +> --- title: Rust Store Traced Faces 設計文檔 version: 1.0 diff --git a/docs_v1.0/DESIGN/Swift_Face_Trace_Design.md b/docs_v1.0/DESIGN/Swift_Face_Trace_Design.md index 6e98b666..69e0bf57 100644 --- a/docs_v1.0/DESIGN/Swift_Face_Trace_Design.md +++ b/docs_v1.0/DESIGN/Swift_Face_Trace_Design.md @@ -1,3 +1,5 @@ +> ⚠️ **DEPRECATED** - This document has been superseded by [Face Operations Complete](../REFERENCE/Face_Operations_Complete.md). See the new document for the complete and updated reference. +> --- title: Swift Face Trace Design version: 1.0 diff --git a/docs_v1.0/DESIGN/Trace_Inheritance_Rules.md b/docs_v1.0/DESIGN/Trace_Inheritance_Rules.md index 628aa3bc..1b11b970 100644 --- a/docs_v1.0/DESIGN/Trace_Inheritance_Rules.md +++ b/docs_v1.0/DESIGN/Trace_Inheritance_Rules.md @@ -1,3 +1,5 @@ +> ⚠️ **DEPRECATED** - This document has been superseded by [Face Operations Complete](../REFERENCE/Face_Operations_Complete.md). See the new document for the complete and updated reference. +> # Trace ID Inheritance & Expansion Rules **Date**: 2026-07-19 diff --git a/docs_v1.0/REFERENCE/Face_Pipeline.md b/docs_v1.0/REFERENCE/Face_Pipeline.md index 7da9abc3..8c4fdf29 100644 --- a/docs_v1.0/REFERENCE/Face_Pipeline.md +++ b/docs_v1.0/REFERENCE/Face_Pipeline.md @@ -1,3 +1,5 @@ +> ⚠️ **DEPRECATED** - This document has been superseded by [Face Operations Complete](../REFERENCE/Face_Operations_Complete.md). See the new document for the complete and updated reference. +> # Face Pipeline: Detection → Clustering → Trace **Date**: 2026-05-16 diff --git a/src/api/trace_agent_api.rs b/src/api/trace_agent_api.rs index 6c57a6ea..83de4b90 100644 --- a/src/api/trace_agent_api.rs +++ b/src/api/trace_agent_api.rs @@ -74,6 +74,10 @@ pub fn trace_agent_routes() -> Router { "/api/v1/trace-profile-file", get(get_trace_profile_file), ) + .route( + "/api/v1/file/:file_uuid/data-consistency", + get(check_data_consistency), + ) } #[derive(Debug, Deserialize)] @@ -2811,3 +2815,104 @@ async fn get_trace_profile_file( None => (StatusCode::NOT_FOUND, Json(serde_json::json!({"error": "Trace profile file not found", "file_uuid": file_uuid, "trace_id": trace_id}))), } } + +/// GET /api/v1/file/:file_uuid/data-consistency +/// Checks consistency across tkg_nodes, trace_profiles, FS trace dirs, and Qdrant points. +async fn check_data_consistency( + State(state): State, + Path(file_uuid): Path, +) -> Json { + let tkg_table = crate::core::db::schema::table_name("tkg_nodes"); + let tp_table = crate::core::db::schema::table_name("trace_profiles"); + + // 1. Count tkg_nodes face_track + let tkg_count: i64 = sqlx::query_scalar(&format!( + "SELECT COUNT(*) FROM {} WHERE file_uuid = $1 AND node_type = 'face_track'", + tkg_table + )) + .bind(&file_uuid) + .fetch_one(state.db.pool()) + .await + .unwrap_or(0); + + // 2. Count trace_profiles + let tp_count: i64 = sqlx::query_scalar(&format!( + "SELECT COUNT(*) FROM {} WHERE file_uuid = $1", + tp_table + )) + .bind(&file_uuid) + .fetch_one(state.db.pool()) + .await + .unwrap_or(0); + + // 3. Count FS trace directories + let output_dir = crate::core::config::OUTPUT_DIR.as_str(); + let trace_base_dir = std::path::Path::new(output_dir).join(&file_uuid); + let fs_count = if let Ok(entries) = std::fs::read_dir(&trace_base_dir) { + entries + .filter_map(|e| e.ok()) + .filter(|e| e.file_name().to_string_lossy().starts_with("trace_")) + .count() as i64 + } else { + 0 + }; + + // 4. Count Qdrant points for this file + let qdrant = crate::core::db::qdrant_db::QdrantDb::new(); + let qdrant_filter = serde_json::json!({ + "must": [{"key": "file_uuid", "match": {"value": &file_uuid}}] + }); + let qdrant_count = qdrant + .count_points("_faces", qdrant_filter) + .await + .unwrap_or(0) as i64; + + // 5. Check for mismatches + let mut mismatches = Vec::new(); + if tkg_count != tp_count { + mismatches.push(format!("tkg_nodes ({}) != trace_profiles ({})", tkg_count, tp_count)); + } + if tkg_count != fs_count { + mismatches.push(format!("tkg_nodes ({}) != trace_dirs ({})", tkg_count, fs_count)); + } + + // 6. Check unique trace_ids in Qdrant + let qdrant_unique_traces = qdrant + .scroll_all_points( + "_faces", + serde_json::json!({ + "must": [ + {"key": "file_uuid", "match": {"value": &file_uuid}}, + {"key": "trace_id", "is_null": false} + ] + }), + 1000, + ) + .await + .map(|pts| { + use std::collections::HashSet; + pts.iter() + .filter_map(|p| p["payload"]["trace_id"].as_i64()) + .collect::>() + .len() as i64 + }) + .unwrap_or(0); + + if qdrant_unique_traces != tkg_count && tkg_count > 0 { + mismatches.push(format!( + "tkg_nodes ({}) != Qdrant unique traces ({})", + tkg_count, qdrant_unique_traces + )); + } + + Json(serde_json::json!({ + "file_uuid": file_uuid, + "tkg_nodes": tkg_count, + "trace_profiles": tp_count, + "trace_dirs": fs_count, + "qdrant_points": qdrant_count, + "qdrant_unique_traces": qdrant_unique_traces, + "is_consistent": mismatches.is_empty(), + "mismatches": mismatches + })) +}