feat: Phase 2.7 identity resolution for gaze/lip trace nodes

Implementation:
- gaze_trace nodes: Query face_trace identity_id, add to properties
- lip_trace nodes: Query face_trace identity_id, add to properties
- Rule2: Extend identity resolution to support gaze_trace/lip_trace node types

Architecture:
- All face-related nodes now have identity_id in TKG properties
- Rule2 unified identity resolution for face_trace/gaze_trace/lip_trace
- TKG-only approach (no face_detections dependency for identity)

Code Changes:
- src/core/processor/tkg.rs: Add identity_id query in gaze/lip builders
- src/core/chunk/rule2_ingest.rs: Extend node_type condition

Docs:
- docs_v1.0/DESIGN/TKG_PHASE2_7_IDENTITY_RESOLUTION.md

Status: Implementation complete, pending test with valid file
This commit is contained in:
Accusys
2026-06-21 05:12:13 +08:00
parent 2cfcfdd1af
commit e214106d48
4 changed files with 265 additions and 11 deletions
+7 -5
View File
@@ -99,15 +99,16 @@ pub async fn ingest_rule2(pool: &PgPool, file_uuid: &str) -> Result<usize> {
let (src_type, src_ext_id, src_label, _src_props) = source_node.unwrap();
let (tgt_type, tgt_ext_id, tgt_label, tgt_props) = target_node.unwrap();
// Resolve identity names for face_trace nodes (Phase 2.3: TKG-only)
let src_identity: Option<String> = if src_type == "face_trace" {
// Resolve identity names for face_trace/gaze_trace/lip_trace nodes (Phase 2.7)
let src_identity: Option<String> = if src_type == "face_trace" || src_type == "gaze_trace" || src_type == "lip_trace" {
sqlx::query_scalar(&format!(
"SELECT i.name FROM {} n \
JOIN {} i ON i.id = (n.properties->>'identity_id')::bigint \
WHERE n.file_uuid = $1 AND n.node_type = 'face_trace' AND n.external_id = $2 AND n.properties->>'identity_id' IS NOT NULL",
WHERE n.file_uuid = $1 AND n.node_type = $2 AND n.external_id = $3 AND n.properties->>'identity_id' IS NOT NULL",
nodes_table, id_table
))
.bind(file_uuid)
.bind(&src_type)
.bind(&src_ext_id)
.fetch_optional(&mut *tx)
.await?
@@ -115,14 +116,15 @@ pub async fn ingest_rule2(pool: &PgPool, file_uuid: &str) -> Result<usize> {
None
};
let tgt_identity: Option<String> = if tgt_type == "face_trace" {
let tgt_identity: Option<String> = if tgt_type == "face_trace" || tgt_type == "gaze_trace" || tgt_type == "lip_trace" {
sqlx::query_scalar(&format!(
"SELECT i.name FROM {} n \
JOIN {} i ON i.id = (n.properties->>'identity_id')::bigint \
WHERE n.file_uuid = $1 AND n.node_type = 'face_trace' AND n.external_id = $2 AND n.properties->>'identity_id' IS NOT NULL",
WHERE n.file_uuid = $1 AND n.node_type = $2 AND n.external_id = $3 AND n.properties->>'identity_id' IS NOT NULL",
nodes_table, id_table
))
.bind(file_uuid)
.bind(&tgt_type)
.bind(&tgt_ext_id)
.fetch_optional(&mut *tx)
.await?