feat: face fix deployment + trace_* regeneration + executor stderr filter fix

- swift_face.swift: frame rounding (.rounded()), conf 0.75, min_size 64
- trace_* directories regenerated for KOBA (37 traces, start_frame 5307)
- executor.rs: stderr filter now logs all non-empty stderr (was discarding)
- VAD not skippable in ASRX (main_fixed.py Step 2 always runs)
- Step 2.5 sentence boundary refinement added
- Cluster agent async endpoints + similarity transparency
- Keyword search: relationship text extraction, priority ordering
- Face fix handoff doc for Studio team
This commit is contained in:
Accusys
2026-08-05 00:13:50 +08:00
parent 36a704e3d3
commit 3d13a06bd9
42 changed files with 3447 additions and 778 deletions
+80 -82
View File
@@ -4,114 +4,112 @@ use std::time::{Duration, Instant};
#[tokio::main]
async fn main() -> Result<()> {
dotenv::from_filename("/Users/accusys/momentry_core_0.1/.env.development").ok();
tracing_subscriber::fmt::init();
let pg = PostgresDb::init()
.await
.context("Failed to init PostgreSQL")?;
let qdrant = QdrantDb::new();
let embedder = Embedder::new("embeddinggemma-300m".to_string());
let uuid = "63acd3bb02b5b9dfbb9d6db499fcc864";
let chunk_table = momentry_core::core::db::schema::table_name("chunk");
let rows = sqlx::query_as::<_, (String, String, i64, i64, f64, f64, String)>(&format!(
"SELECT chunk_id, text_content, start_frame, end_frame, \
start_time, end_time, content::text \
// Get all files with unembedded sentence chunks
let files: Vec<(String,)> = sqlx::query_as(&format!(
"SELECT DISTINCT file_uuid FROM {} \
WHERE chunk_type = 'sentence' AND embedding IS NULL \
AND text_content IS NOT NULL AND text_content != ''",
chunk_table
))
.fetch_all(pg.pool())
.await?;
println!(
"Found {} files with unembedded sentence chunks",
files.len()
);
let start = Instant::now();
let mut total_stored = 0usize;
let mut total_errors = 0usize;
let mut total_chunks = 0usize;
for (file_uuid,) in &files {
let rows: Vec<(String, String, i64, i64, f64, f64)> = sqlx::query_as(&format!(
"SELECT chunk_id, text_content, start_frame, end_frame, start_time, end_time \
FROM {} \
WHERE file_uuid = $1 \
AND chunk_type = 'sentence' \
AND embedding IS NULL \
AND (text_content IS NOT NULL AND text_content != '') \
AND text_content IS NOT NULL AND text_content != '' \
ORDER BY id",
chunk_table
))
.bind(uuid)
.fetch_all(pg.pool())
.await?;
chunk_table
))
.bind(file_uuid)
.fetch_all(pg.pool())
.await?;
let total = rows.len();
println!(
"Found {} sentence chunks without embedding for {}",
total, uuid
);
let count = rows.len();
total_chunks += count;
println!(" {}: {} chunks to vectorize", file_uuid, count);
if total == 0 {
println!("Nothing to vectorize. Exiting.");
return Ok(());
}
let start = Instant::now();
let mut stored = 0usize;
let mut errors = 0usize;
for (chunk_id, text, start_frame, end_frame, start_time, end_time, _content_str) in &rows {
if text.is_empty() {
if count == 0 {
continue;
}
match embedder.embed_document(text).await {
Ok(vector) => {
if let Err(e) = pg.store_vector(chunk_id, &vector, uuid).await {
eprintln!("[ERROR] PG store failed for {}: {}", chunk_id, e);
errors += 1;
continue;
}
let payload = VectorPayload {
file_uuid: uuid.to_string(),
chunk_id: chunk_id.clone(),
chunk_type: "sentence".to_string(),
start_frame: *start_frame,
end_frame: *end_frame,
start_time: *start_time,
end_time: *end_time,
text: Some(text.clone()),
};
if let Err(e) = qdrant.upsert_vector(chunk_id, &vector, payload).await {
eprintln!("[ERROR] Qdrant upsert failed for {}: {}", chunk_id, e);
errors += 1;
continue;
}
stored += 1;
if stored % 500 == 0 || stored == total {
let elapsed = start.elapsed();
let rate = stored as f64 / elapsed.as_secs_f64();
let eta = if stored < total {
let remaining = Duration::from_secs_f64((total - stored) as f64 / rate);
format!(" (ETA: {}s)", remaining.as_secs())
} else {
String::new()
};
println!(
" [{}/{}] {:.1}% done | {:.0} vec/s | {} errors{}",
stored,
total,
100.0 * stored as f64 / total as f64,
rate,
errors,
eta,
);
}
for (chunk_id, text, start_frame, end_frame, start_time, end_time) in &rows {
if text.is_empty() {
continue;
}
Err(e) => {
eprintln!("[ERROR] Embedding failed for {}: {}", chunk_id, e);
errors += 1;
match embedder.embed_document(text).await {
Ok(vector) => {
if let Err(e) = pg.store_vector(&chunk_id, &vector, file_uuid).await {
eprintln!("[ERROR] PG store failed for {}: {}", chunk_id, e);
total_errors += 1;
continue;
}
let payload = VectorPayload {
file_uuid: file_uuid.clone(),
chunk_id: chunk_id.clone(),
chunk_type: "sentence".to_string(),
start_frame: *start_frame,
end_frame: *end_frame,
start_time: *start_time,
end_time: *end_time,
text: Some(text.clone()),
};
if let Err(e) = qdrant.upsert_vector(&chunk_id, &vector, payload).await {
eprintln!("[ERROR] Qdrant upsert failed for {}: {}", chunk_id, e);
total_errors += 1;
continue;
}
total_stored += 1;
if total_stored % 500 == 0 {
let elapsed = start.elapsed();
let rate = total_stored as f64 / elapsed.as_secs_f64();
println!(
" [{}/{}] {:.1} vec/s | {} errors",
total_stored, total_chunks, rate, total_errors
);
}
}
Err(e) => {
eprintln!("[ERROR] Embedding failed for {}: {}", chunk_id, e);
total_errors += 1;
}
}
}
}
let elapsed = start.elapsed();
println!(
"\nDone! {}/{} vectors stored ({} errors) in {:.1}s ({:.0} vec/s avg)",
stored,
total,
errors,
"\nDone! {}/{} vectors stored ({} errors) in {:.1}s",
total_stored,
total_chunks,
total_errors,
elapsed.as_secs_f64(),
stored as f64 / elapsed.as_secs_f64(),
);
Ok(())