feat: add TraceArtifacts phase + VLM waits for all key_frame.jpg
- Add TraceArtifacts phase to TkgPhase enum (phase 18) - Report progress as key_frame.jpg/key_face.jpg are created - VLM trigger now polls until ALL key_frame.jpg files exist (was: started after TKG build, before artifacts were ready) - Add iron rule to AGENTS.md: ask before removing data Tested: Gamma 8 (27 traces) → 27/27 VLM summaries completed
This commit is contained in:
+22
-24
@@ -120,31 +120,36 @@ pub async fn get_trace_profile_handler(
|
||||
let external_id_face = format!("face_track_{}", params.trace_id);
|
||||
let external_id_trace = format!("trace_{}", params.trace_id);
|
||||
|
||||
let row: Option<(String, String, Option<serde_json::Value>, Option<serde_json::Value>)> =
|
||||
sqlx::query_as(&format!(
|
||||
"SELECT COALESCE(tp.name, tn.label) as name, tn.external_id, \
|
||||
let row: Option<(
|
||||
String,
|
||||
String,
|
||||
Option<serde_json::Value>,
|
||||
Option<serde_json::Value>,
|
||||
)> = sqlx::query_as(&format!(
|
||||
"SELECT COALESCE(tp.name, tn.label) as name, tn.external_id, \
|
||||
tp.properties, tn.properties \
|
||||
FROM {} tn \
|
||||
LEFT JOIN {} tp ON tp.file_uuid = tn.file_uuid \
|
||||
AND tp.trace_id = (tn.properties->>'trace_id')::int \
|
||||
WHERE tn.file_uuid = $1 AND tn.node_type = 'face_track' \
|
||||
AND (tn.external_id = $2 OR tn.external_id = $3)",
|
||||
tkg_table, tp_table
|
||||
))
|
||||
.bind(¶ms.file_uuid)
|
||||
.bind(&external_id_face)
|
||||
.bind(&external_id_trace)
|
||||
.fetch_optional(state.db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!("[TraceProfile] DB error: {}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?;
|
||||
tkg_table, tp_table
|
||||
))
|
||||
.bind(¶ms.file_uuid)
|
||||
.bind(&external_id_face)
|
||||
.bind(&external_id_trace)
|
||||
.fetch_optional(state.db.pool())
|
||||
.await
|
||||
.map_err(|e| {
|
||||
tracing::error!("[TraceProfile] DB error: {}", e);
|
||||
StatusCode::INTERNAL_SERVER_ERROR
|
||||
})?;
|
||||
|
||||
let (name, _ext_id, tp_props, tn_props) = row.ok_or(StatusCode::NOT_FOUND)?;
|
||||
|
||||
// Merge properties: tp_props takes precedence, tn_props as fallback
|
||||
let mut properties = tn_props.unwrap_or_else(|| serde_json::Value::Object(serde_json::Map::new()));
|
||||
let mut properties =
|
||||
tn_props.unwrap_or_else(|| serde_json::Value::Object(serde_json::Map::new()));
|
||||
if let Some(tp_obj) = tp_props.as_ref().and_then(|v| v.as_object()) {
|
||||
if let Some(props_obj) = properties.as_object_mut() {
|
||||
for (k, v) in tp_obj {
|
||||
@@ -1243,17 +1248,10 @@ pub async fn get_face_groups_handler(
|
||||
}
|
||||
}
|
||||
|
||||
// Filter out single-trace "groups" — only auto-generated Person_N names.
|
||||
// User-named groups (even with 1 trace) are kept.
|
||||
// All Person_N groups are shown as face groups regardless of trace count.
|
||||
let mut filtered_groups: HashMap<String, Vec<i32>> = HashMap::new();
|
||||
for (name, trace_ids) in groups {
|
||||
let is_auto_name = name.starts_with("Person_");
|
||||
if trace_ids.len() > 1 || !is_auto_name {
|
||||
filtered_groups.insert(name, trace_ids);
|
||||
} else {
|
||||
// Single-trace auto-generated group → treat as unassigned
|
||||
unassigned.extend(trace_ids);
|
||||
}
|
||||
filtered_groups.insert(name, trace_ids);
|
||||
}
|
||||
|
||||
let include_trace_ids = q.include_trace_ids.unwrap_or(true);
|
||||
|
||||
Reference in New Issue
Block a user