fix: face group name read consistency, sync_file_status fix, cleanup ghost records, identity_agent replaced with face_dedup

- get_face_groups_handler: COALESCE(tp.name, tn.label) for name consistency
- sync_file_status: compare JSON vs pre_chunks (not chunk table)
- face consistency: compare frames.len() not total_faces
- cleanup 2 ghost records with NULL file_name/file_path
- replace identity_agent with face_dedup in pipeline stages
- remove identity_agent_api.rs and all references
- update required_processors to match actual processors
- update AGENTS.md with team responsibilities
- add Studio pipeline changes documentation
This commit is contained in:
Accusys
2026-07-27 02:15:51 +08:00
parent fcdeab82e6
commit 39a2cbc65b
118 changed files with 19386 additions and 2964 deletions
+75 -5
View File
@@ -195,10 +195,16 @@ pub enum VideoStatus {
Registered,
Pending,
Queued,
Scanning,
Processing,
Processed,
Indexed,
CheckedOut,
KeywordReady,
SemanticReady,
PeopleReady,
FaceMgmtReady,
AgentReady,
Completed,
Failed,
}
@@ -210,10 +216,21 @@ impl VideoStatus {
VideoStatus::Registered => "registered",
VideoStatus::Pending => "pending",
VideoStatus::Queued => "queued",
VideoStatus::Scanning => "scanning",
VideoStatus::Processing => "processing",
VideoStatus::Processed => "processed",
VideoStatus::Indexed => "indexed",
VideoStatus::CheckedOut => "checked_out",
VideoStatus::KeywordReady => "keyword_ready",
VideoStatus::SemanticReady => "semantic_ready",
VideoStatus::PeopleReady => "people_ready",
VideoStatus::FaceMgmtReady => "face_mgmt_ready",
VideoStatus::AgentReady => "agent_ready",
VideoStatus::Completed => "completed",
VideoStatus::Failed => "failed",
VideoStatus::Processed => "processed",
VideoStatus::Indexed => "indexed",
VideoStatus::CheckedOut => "checked_out",
VideoStatus::Completed => "completed",
VideoStatus::Failed => "failed",
}
@@ -225,10 +242,21 @@ impl VideoStatus {
"registered" => Some(VideoStatus::Registered),
"pending" => Some(VideoStatus::Pending),
"queued" => Some(VideoStatus::Queued),
"scanning" => Some(VideoStatus::Scanning),
"processing" => Some(VideoStatus::Processing),
"processed" => Some(VideoStatus::Processed),
"indexed" => Some(VideoStatus::Indexed),
"checked_out" => Some(VideoStatus::CheckedOut),
"keyword_ready" => Some(VideoStatus::KeywordReady),
"semantic_ready" => Some(VideoStatus::SemanticReady),
"people_ready" => Some(VideoStatus::FaceMgmtReady),
"face_mgmt_ready" => Some(VideoStatus::FaceMgmtReady),
"agent_ready" => Some(VideoStatus::AgentReady),
"completed" => Some(VideoStatus::Completed),
"failed" => Some(VideoStatus::Failed),
"processed" => Some(VideoStatus::Processed),
"indexed" => Some(VideoStatus::Indexed),
"checked_out" => Some(VideoStatus::CheckedOut),
"completed" => Some(VideoStatus::Completed),
"failed" => Some(VideoStatus::Failed),
_ => None,
@@ -264,6 +292,8 @@ pub struct VideoRow {
pub registration_time: Option<String>,
pub total_frames: Option<i64>,
pub parent_uuid: Option<String>,
pub proxy_path: Option<String>,
pub audio_track: Option<String>,
}
impl From<VideoRow> for VideoRecord {
@@ -302,6 +332,8 @@ impl From<VideoRow> for VideoRecord {
cut_max_duration: 0.0,
scene_done: false,
audio_tracks: None,
proxy_path: row.proxy_path,
audio_track: row.audio_track,
}
}
}
@@ -333,6 +365,8 @@ pub struct VideoRecord {
pub cut_max_duration: f64,
pub scene_done: bool,
pub audio_tracks: Option<serde_json::Value>,
pub proxy_path: Option<String>,
pub audio_track: Option<String>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -963,6 +997,8 @@ impl PostgresDb {
"cut_count INTEGER DEFAULT 0",
"cut_max_duration DOUBLE PRECISION DEFAULT 0",
"content_hash TEXT",
"proxy_path TEXT",
"audio_track TEXT",
];
for col in &video_cols {
let (col_name, col_def) = col.split_once(' ').unwrap_or((col, ""));
@@ -1196,6 +1232,12 @@ impl PostgresDb {
// ── Strangers ──
sqlx::query("CREATE TABLE IF NOT EXISTS strangers (id SERIAL PRIMARY KEY, file_uuid TEXT, trace_id INTEGER, metadata JSONB DEFAULT '{}', created_at TIMESTAMPTZ DEFAULT NOW(), UNIQUE(file_uuid, trace_id))").execute(pool).await?;
// ── Trace Profiles (VLM metadata for face traces) ──
sqlx::query("CREATE TABLE IF NOT EXISTS trace_profiles (id SERIAL PRIMARY KEY, file_uuid VARCHAR(32) NOT NULL, trace_id INTEGER NOT NULL, name VARCHAR(255), start_frame BIGINT, end_frame BIGINT, frame_count INTEGER, key_frame VARCHAR(255), key_face VARCHAR(255), status VARCHAR(50) DEFAULT 'pending', avg_confidence DOUBLE PRECISION, vlm_description TEXT, vlm_clothing TEXT, vlm_tags TEXT[], vlm_location VARCHAR(255), vlm_setting VARCHAR(255), vlm_lighting VARCHAR(100), vlm_weather VARCHAR(100), vlm_hand_objects TEXT, vlm_has_plants BOOLEAN, vlm_has_animals BOOLEAN, vlm_background TEXT, vlm_bg_tags TEXT[], vlm_model VARCHAR(64), metadata JSONB DEFAULT '{}', created_at TIMESTAMPTZ DEFAULT NOW(), updated_at TIMESTAMPTZ DEFAULT NOW(), UNIQUE(file_uuid, trace_id))").execute(pool).await?;
sqlx::query("CREATE INDEX IF NOT EXISTS idx_trace_profiles_file_uuid ON trace_profiles(file_uuid)").execute(pool).await?;
sqlx::query("CREATE INDEX IF NOT EXISTS idx_trace_profiles_name ON trace_profiles(name)").execute(pool).await?;
sqlx::query("CREATE INDEX IF NOT EXISTS idx_trace_profiles_tags ON trace_profiles USING GIN(vlm_tags)").execute(pool).await?;
// ── Cuts ──
sqlx::query("CREATE TABLE IF NOT EXISTS cuts (id SERIAL PRIMARY KEY, file_uuid VARCHAR(32) NOT NULL, cut_number INTEGER NOT NULL, start_frame BIGINT NOT NULL, end_frame BIGINT NOT NULL, start_time DOUBLE PRECISION, end_time DOUBLE PRECISION, fps DOUBLE PRECISION, metadata JSONB DEFAULT '{}', created_at TIMESTAMPTZ DEFAULT NOW(), UNIQUE(file_uuid, cut_number))").execute(pool).await?;
sqlx::query("CREATE INDEX IF NOT EXISTS idx_cuts_file_uuid ON cuts(file_uuid)")
@@ -1477,7 +1519,7 @@ impl PostgresDb {
let table = schema::table_name("videos");
let result = sqlx::query_as::<_, VideoRow>(
&format!(
"SELECT id, file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, fs_video, fs_json, psql_chunk, pobject_chunk, mobject_chunk, pvector_chunk, qvector_chunk, status, processing_status, birth_registration, user_id, job_id, created_at::text AS created_at, registration_time::text AS registration_time, total_frames, parent_uuid FROM {} WHERE file_uuid = $1",
"SELECT id, file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, fs_video, fs_json, psql_chunk, pobject_chunk, mobject_chunk, pvector_chunk, qvector_chunk, status, processing_status, birth_registration, user_id, job_id, created_at::text AS created_at, registration_time::text AS registration_time, total_frames, parent_uuid, proxy_path, audio_track FROM {} WHERE file_uuid = $1",
table
)
)
@@ -1503,7 +1545,7 @@ impl PostgresDb {
let table = schema::table_name("videos");
let result = sqlx::query_as::<_, VideoRow>(
&format!(
"SELECT id, file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, fs_video, fs_json, psql_chunk, pobject_chunk, mobject_chunk, pvector_chunk, qvector_chunk, status, processing_status, birth_registration, user_id, job_id, created_at::text AS created_at, registration_time::text AS registration_time, total_frames, parent_uuid FROM {} WHERE file_name = $1 AND registration_time IS NOT NULL ORDER BY registration_time ASC LIMIT 1",
"SELECT id, file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, fs_video, fs_json, psql_chunk, pobject_chunk, mobject_chunk, pvector_chunk, qvector_chunk, status, processing_status, birth_registration, user_id, job_id, created_at::text AS created_at, registration_time::text AS registration_time, total_frames, parent_uuid, proxy_path, audio_track FROM {} WHERE file_name = $1 AND registration_time IS NOT NULL ORDER BY registration_time ASC LIMIT 1",
table
)
)
@@ -1587,7 +1629,7 @@ impl PostgresDb {
.collect();
let table = schema::table_name("videos");
let sql = format!(
"SELECT id, file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, fs_video, fs_json, psql_chunk, pobject_chunk, mobject_chunk, pvector_chunk, qvector_chunk, status, processing_status, birth_registration, user_id, job_id, created_at::text AS created_at, registration_time::text AS registration_time, parent_uuid FROM {} WHERE file_uuid = ANY($1)",
"SELECT id, file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, fs_video, fs_json, psql_chunk, pobject_chunk, mobject_chunk, pvector_chunk, qvector_chunk, status, processing_status, birth_registration, user_id, job_id, created_at::text AS created_at, registration_time::text AS registration_time, parent_uuid, proxy_path, audio_track FROM {} WHERE file_uuid = ANY($1)",
table
);
@@ -1669,7 +1711,7 @@ impl PostgresDb {
// 2. Select Query
// Cast created_at and registration_time to text
let columns = "id, file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, fs_video, fs_json, psql_chunk, pobject_chunk, mobject_chunk, pvector_chunk, qvector_chunk, status, processing_status, birth_registration, user_id, job_id, created_at::text AS created_at, registration_time::text AS registration_time, total_frames, parent_uuid";
let columns = "id, file_uuid, file_path, file_name, file_type, duration, width, height, fps, probe_json, fs_video, fs_json, psql_chunk, pobject_chunk, mobject_chunk, pvector_chunk, qvector_chunk, status, processing_status, birth_registration, user_id, job_id, created_at::text AS created_at, registration_time::text AS registration_time, total_frames, parent_uuid, proxy_path, audio_track";
// Determine parameter order for LIMIT/OFFSET
// If search is present, pattern is $1. Limit is $2. Offset is $3.
@@ -1910,7 +1952,7 @@ impl PostgresDb {
&format!(
r#"
INSERT INTO {} (uuid, video_path, status, video_id, processors)
VALUES ($1, $2, 'pending', $3, ARRAY['cut','asr','face','ocr','asrx','pose','appearance'])
VALUES ($1, $2, 'pending', $3, ARRAY['cut','asr','face','ocr','asrx','pose'])
RETURNING id, uuid, video_path, status, current_processor, progress_total, progress_current, error_count, last_error, started_at::TEXT, updated_at::TEXT, created_at::TEXT, processors, completed_processors, failed_processors, video_id
"#,
jobs_table
@@ -2721,6 +2763,32 @@ impl PostgresDb {
Ok(())
}
pub async fn update_proxy_path(&self, uuid: &str, proxy_path: &str) -> Result<()> {
let table = schema::table_name("videos");
sqlx::query(&format!(
"UPDATE {} SET proxy_path = $1, updated_at = CURRENT_TIMESTAMP WHERE file_uuid = $2",
table
))
.bind(proxy_path)
.bind(uuid)
.execute(&self.pool)
.await?;
Ok(())
}
pub async fn update_audio_track(&self, uuid: &str, audio_track: &str) -> Result<()> {
let table = schema::table_name("videos");
sqlx::query(&format!(
"UPDATE {} SET audio_track = $1, updated_at = CURRENT_TIMESTAMP WHERE file_uuid = $2",
table
))
.bind(audio_track)
.bind(uuid)
.execute(&self.pool)
.await?;
Ok(())
}
pub async fn update_processing_status_completed(
&self,
uuid: &str,
@@ -4648,6 +4716,8 @@ mod tests {
cut_max_duration: 0.0,
scene_done: false,
audio_tracks: None,
proxy_path: None,
audio_track: None,
};
let json = serde_json::to_string(&record).unwrap();
+3 -12
View File
@@ -913,15 +913,8 @@ impl QdrantDb {
Ok(all_points)
}
pub async fn count_points(
&self,
collection: &str,
filter: serde_json::Value,
) -> Result<i64> {
let url = format!(
"{}/collections/{}/points/count",
self.base_url, collection
);
pub async fn count_points(&self, collection: &str, filter: serde_json::Value) -> Result<i64> {
let url = format!("{}/collections/{}/points/count", self.base_url, collection);
let body = serde_json::json!({
"filter": filter,
@@ -942,9 +935,7 @@ impl QdrantDb {
}
let result: serde_json::Value = resp.json().await?;
let count = result["result"]["count"]
.as_i64()
.unwrap_or(0);
let count = result["result"]["count"].as_i64().unwrap_or(0);
Ok(count)
}