fix: ASRX duplication, TKG edges, trace ingest, and add pipeline progress publishing
- ASRX handler no longer stores duplicate 'asr' pre_chunks - Pre_chunks storage made idempotent (delete-before-insert) - Rule 1 + trace_ingest changed to query 'asrx' not 'asr' - Trace chunks removed (dynamic from TKG/Qdrant) - TKG scroll_face_points fixed: trace_id >= 1 (not == 1) - TKG AsrxSegmentEntry: start/end -> start_time/end_time (match ASRX JSON) - Unregister error handling: log instead of silent discard - Add publish_pipeline_progress calls at each pipeline stage (processors, rule1, face_trace, identity_agent, TKG, rule2, completion)
This commit is contained in:
+700
-263
File diff suppressed because it is too large
Load Diff
@@ -813,6 +813,109 @@ impl QdrantDb {
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
/// Scroll points matching a filter, returning payload data (single page)
|
||||
pub async fn scroll_points(
|
||||
&self,
|
||||
collection: &str,
|
||||
filter: serde_json::Value,
|
||||
limit: usize,
|
||||
offset: Option<serde_json::Value>,
|
||||
) -> Result<(Vec<serde_json::Value>, Option<serde_json::Value>)> {
|
||||
let url = format!("{}/collections/{}/points/scroll", self.base_url, collection);
|
||||
|
||||
let mut body = serde_json::json!({
|
||||
"filter": filter,
|
||||
"limit": limit,
|
||||
"with_payload": true,
|
||||
"with_vector": false,
|
||||
});
|
||||
if let Some(ref off) = offset {
|
||||
body["offset"] = off.clone();
|
||||
}
|
||||
|
||||
let resp = self
|
||||
.client
|
||||
.post(&url)
|
||||
.header("api-key", &self.api_key)
|
||||
.header("Content-Type", "application/json")
|
||||
.json(&body)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
anyhow::bail!("Qdrant scroll failed: {}", resp.status());
|
||||
}
|
||||
|
||||
let result: serde_json::Value = resp.json().await?;
|
||||
let points = result["result"]["points"]
|
||||
.as_array()
|
||||
.cloned()
|
||||
.unwrap_or_default();
|
||||
let next_offset = result["result"]["next_page_offset"].clone();
|
||||
let next_offset = if next_offset.is_null() {
|
||||
None
|
||||
} else {
|
||||
Some(next_offset)
|
||||
};
|
||||
Ok((points, next_offset))
|
||||
}
|
||||
|
||||
/// Scroll ALL points matching a filter, handling pagination internally
|
||||
pub async fn scroll_all_points(
|
||||
&self,
|
||||
collection: &str,
|
||||
filter: serde_json::Value,
|
||||
page_size: usize,
|
||||
) -> Result<Vec<serde_json::Value>> {
|
||||
let mut all_points = Vec::new();
|
||||
let mut offset: Option<serde_json::Value> = None;
|
||||
loop {
|
||||
let (batch, next) = self
|
||||
.scroll_points(collection, filter.clone(), page_size, offset)
|
||||
.await?;
|
||||
let batch_len = batch.len();
|
||||
all_points.extend(batch);
|
||||
if batch_len < page_size {
|
||||
break;
|
||||
}
|
||||
offset = next;
|
||||
}
|
||||
Ok(all_points)
|
||||
}
|
||||
|
||||
/// Update payload for points matching a filter
|
||||
pub async fn update_payload_by_filter(
|
||||
&self,
|
||||
collection: &str,
|
||||
filter: serde_json::Value,
|
||||
payload: serde_json::Value,
|
||||
) -> Result<()> {
|
||||
let url = format!(
|
||||
"{}/collections/{}/points/payload",
|
||||
self.base_url, collection
|
||||
);
|
||||
|
||||
let body = serde_json::json!({
|
||||
"filter": filter,
|
||||
"payload": payload
|
||||
});
|
||||
|
||||
let resp = self
|
||||
.client
|
||||
.post(&url)
|
||||
.header("api-key", &self.api_key)
|
||||
.header("Content-Type", "application/json")
|
||||
.json(&body)
|
||||
.send()
|
||||
.await?;
|
||||
|
||||
if !resp.status().is_success() {
|
||||
anyhow::bail!("Qdrant payload update failed: {}", resp.status());
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
}
|
||||
|
||||
#[async_trait]
|
||||
|
||||
@@ -193,7 +193,10 @@ impl QdrantWorkspace {
|
||||
let chunks = self
|
||||
.scroll_collection(&self.chunks_collection(), file_uuid)
|
||||
.await?;
|
||||
Ok(WorkspaceScrollResult { chunks, traces: Vec::new() })
|
||||
Ok(WorkspaceScrollResult {
|
||||
chunks,
|
||||
traces: Vec::new(),
|
||||
})
|
||||
}
|
||||
|
||||
async fn scroll_collection(
|
||||
|
||||
@@ -476,6 +476,7 @@ impl RedisClient {
|
||||
let _: i32 = conn.del(&key).await?;
|
||||
|
||||
let processor_types = [
|
||||
"appearance",
|
||||
"asr",
|
||||
"cut",
|
||||
"yolo",
|
||||
|
||||
@@ -253,29 +253,18 @@ impl WorkspaceDb {
|
||||
}
|
||||
|
||||
// ── Face Detections ──
|
||||
// DEPRECATED: face_detections table is being replaced by Qdrant workspace traces
|
||||
// This function is kept for backward compatibility but no longer writes to the table
|
||||
|
||||
pub async fn store_face_detections_batch(
|
||||
&self,
|
||||
detections: &[FaceDetectionBatchItem],
|
||||
) -> Result<()> {
|
||||
for d in detections {
|
||||
sqlx::query(
|
||||
"INSERT INTO face_detections (file_uuid, face_id, frame_number, timestamp_secs, \
|
||||
x, y, w, h, confidence) \
|
||||
VALUES (?1, ?2, ?3, ?4, ?5, ?6, ?7, ?8, ?9)",
|
||||
)
|
||||
.bind(&self.file_uuid)
|
||||
.bind(&d.face_id)
|
||||
.bind(d.frame)
|
||||
.bind(d.ts)
|
||||
.bind(d.x)
|
||||
.bind(d.y)
|
||||
.bind(d.w)
|
||||
.bind(d.h)
|
||||
.bind(d.confidence)
|
||||
.execute(&self.pool)
|
||||
.await?;
|
||||
}
|
||||
// Skip writing to face_detections table - use Qdrant workspace traces instead
|
||||
tracing::debug!(
|
||||
"[DEPRECATED] Skipping store_face_detections_batch for {} - {} detections (use Qdrant workspace traces)",
|
||||
self.file_uuid, detections.len()
|
||||
);
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user