release: v1.3.1 - Pipeline Queue Integration, OCR Fix, Worker Compatibility
Major Changes: - Pipeline Queue integration completed (internal.file + pipeline.commands) - Fixed old job_worker database compatibility with new command_queue table - Compiled Swift OCR binary (was missing, causing empty OCR results) - Added deep scan functionality through re-scan API Fixes: - Changed CommandJob.id from i32 to i64 for database compatibility - Added UUID generation in create_command (message_id field) - Fixed claim_pending_commands to query queue_name = 'internal.file' - Fixed field mappings: command_id → message_id, job_type → command_type - Added support for 'processing' status in CommandJobStatus Queue System: - internal.file queue: for register/unregister/re-scan commands (job_worker) - pipeline.commands queue: for vectorize/store_asrx/etc commands (pipeline_worker) Documentation: - Added comprehensive queue system documentation - Created M4 workspace status reports - Updated AGENTS.md with queue system details
This commit is contained in:
+94
-77
@@ -45,52 +45,60 @@ pub async fn handle_process(
|
||||
if is_uuid {
|
||||
// UUID-based processing
|
||||
println!("\n[PROCESS] Processing video with UUID: {}", target);
|
||||
|
||||
|
||||
// Connect to database
|
||||
let database_url = std::env::var("DATABASE_URL")
|
||||
.unwrap_or_else(|_| "postgres://accusys@localhost:5432/momentry".to_string());
|
||||
|
||||
|
||||
let db = momentry_core::core::db::PostgresDb::new(&database_url).await?;
|
||||
|
||||
|
||||
// Get video info
|
||||
let video = db.get_video_by_uuid(target).await?
|
||||
let video = db
|
||||
.get_video_by_uuid(target)
|
||||
.await?
|
||||
.ok_or_else(|| anyhow::anyhow!("Video not found: {}", target))?;
|
||||
let file_path = video.file_path.clone();
|
||||
let output_dir = std::env::var("MOMENTRY_OUTPUT_DIR")
|
||||
.unwrap_or_else(|_| "/Users/accusys/momentry/output".to_string());
|
||||
|
||||
|
||||
println!("[PROCESS] Video path: {}", file_path);
|
||||
|
||||
|
||||
// Process modules
|
||||
let modules_to_process = modules.unwrap_or_else(|| vec!["face".to_string()]);
|
||||
|
||||
|
||||
for module in &modules_to_process {
|
||||
match module.as_str() {
|
||||
"face" => {
|
||||
let output_path = format!("{}/{}.face.json", output_dir, target);
|
||||
|
||||
|
||||
// Check if already exists
|
||||
if !force && std::path::Path::new(&output_path).exists() {
|
||||
println!("[FACE] Output already exists, use --force to reprocess");
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
println!("[FACE] Starting face processing...");
|
||||
|
||||
|
||||
use momentry_core::core::processor::face::process_face;
|
||||
let result = process_face(&file_path, &output_path, Some(target), None).await?;
|
||||
|
||||
println!("[FACE] Completed: {} frames, {} faces",
|
||||
result.frames.len(),
|
||||
|
||||
println!(
|
||||
"[FACE] Completed: {} frames, {} faces",
|
||||
result.frames.len(),
|
||||
result.total_faces
|
||||
);
|
||||
|
||||
|
||||
// Show trace statistics
|
||||
let with_trace = result.frames.iter()
|
||||
let with_trace = result
|
||||
.frames
|
||||
.iter()
|
||||
.flat_map(|f| &f.faces)
|
||||
.filter(|face| face.trace_id.is_some())
|
||||
.count();
|
||||
println!("[FACE] Faces with trace_id: {}/{}", with_trace, result.total_faces);
|
||||
println!(
|
||||
"[FACE] Faces with trace_id: {}/{}",
|
||||
with_trace, result.total_faces
|
||||
);
|
||||
}
|
||||
"asr" => {
|
||||
println!("[ASR] ASR processing not yet implemented in CLI");
|
||||
@@ -103,7 +111,7 @@ pub async fn handle_process(
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
println!("\n✅ Processing completed for UUID: {}", target);
|
||||
} else {
|
||||
// Path-based processing
|
||||
@@ -113,21 +121,26 @@ pub async fn handle_process(
|
||||
}
|
||||
|
||||
println!("\n[PROCESS] Processing file: {}", target);
|
||||
|
||||
|
||||
// For now, just process face module
|
||||
if modules.as_ref().map(|m| m.contains(&"face".to_string())).unwrap_or(true) {
|
||||
if modules
|
||||
.as_ref()
|
||||
.map(|m| m.contains(&"face".to_string()))
|
||||
.unwrap_or(true)
|
||||
{
|
||||
let output_path = format!("{}.face.json", target);
|
||||
|
||||
|
||||
if !force && std::path::Path::new(&output_path).exists() {
|
||||
println!("[FACE] Output already exists, use --force to reprocess");
|
||||
} else {
|
||||
println!("[FACE] Starting face processing...");
|
||||
|
||||
|
||||
use momentry_core::core::processor::face::process_face;
|
||||
let result = process_face(target, &output_path, None, None).await?;
|
||||
|
||||
println!("[FACE] Completed: {} frames, {} faces",
|
||||
result.frames.len(),
|
||||
|
||||
println!(
|
||||
"[FACE] Completed: {} frames, {} faces",
|
||||
result.frames.len(),
|
||||
result.total_faces
|
||||
);
|
||||
}
|
||||
@@ -397,20 +410,20 @@ pub async fn handle_api_key(
|
||||
key: Option<String>,
|
||||
key_id: Option<String>,
|
||||
) -> Result<()> {
|
||||
use momentry_core::core::db::PostgresDb;
|
||||
use momentry_core::core::api_key::ApiKeyService;
|
||||
use momentry_core::core::api_key::CreateApiKeyRequest;
|
||||
|
||||
use momentry_core::core::db::PostgresDb;
|
||||
|
||||
// Connect to database
|
||||
let database_url = std::env::var("DATABASE_URL")
|
||||
.unwrap_or_else(|_| "postgres://accusys@localhost:5432/momentry".to_string());
|
||||
let db = PostgresDb::new(&database_url).await?;
|
||||
let service = ApiKeyService::new(database_url);
|
||||
|
||||
|
||||
match action {
|
||||
crate::cli::args::ApiKeyAction::Create => {
|
||||
let name = name.unwrap_or_else(|| "unnamed-key".to_string());
|
||||
|
||||
|
||||
// Parse key type
|
||||
let key_type_enum = match key_type.as_deref() {
|
||||
Some("service") => momentry_core::core::api_key::ApiKeyType::Service,
|
||||
@@ -418,7 +431,7 @@ pub async fn handle_api_key(
|
||||
Some("emergency") => momentry_core::core::api_key::ApiKeyType::Emergency,
|
||||
_ => momentry_core::core::api_key::ApiKeyType::User,
|
||||
};
|
||||
|
||||
|
||||
// Create request with default permissions
|
||||
let request = CreateApiKeyRequest {
|
||||
name: name.clone(),
|
||||
@@ -428,15 +441,15 @@ pub async fn handle_api_key(
|
||||
permissions: vec!["read".to_string(), "write".to_string()], // Default permissions
|
||||
ttl_days: ttl.map(|u| u as i64),
|
||||
};
|
||||
|
||||
|
||||
// Generate key
|
||||
let response = service.create_key(request)?;
|
||||
|
||||
|
||||
// Hash key
|
||||
let key_hash = service.hash_key(&response.key);
|
||||
let key_type_str = key_type_enum.as_str().to_string();
|
||||
let permissions = serde_json::json!(["read", "write"]); // Default permissions
|
||||
|
||||
|
||||
// Create config
|
||||
let config = momentry_core::core::db::CreateApiKeyConfig::new(
|
||||
&response.key_id,
|
||||
@@ -447,14 +460,20 @@ pub async fn handle_api_key(
|
||||
)
|
||||
.with_permissions(&permissions)
|
||||
.with_expires_at(response.expires_at);
|
||||
|
||||
|
||||
// Insert into database - fail on error
|
||||
db.create_api_key(config).await?;
|
||||
|
||||
|
||||
println!("\n✅ API Key created successfully!");
|
||||
println!("\n┌─────────────────────────────────────────────────────────────────────────────┐");
|
||||
println!("│ ⚠️ IMPORTANT: Save this key now - it will not be shown again! │");
|
||||
println!("└─────────────────────────────────────────────────────────────────────────────┘");
|
||||
println!(
|
||||
"\n┌─────────────────────────────────────────────────────────────────────────────┐"
|
||||
);
|
||||
println!(
|
||||
"│ ⚠️ IMPORTANT: Save this key now - it will not be shown again! │"
|
||||
);
|
||||
println!(
|
||||
"└─────────────────────────────────────────────────────────────────────────────┘"
|
||||
);
|
||||
println!("\nKey ID: {}", response.key_id);
|
||||
println!("API Key: {}", response.key);
|
||||
println!("Expires: {}", response.expires_at);
|
||||
@@ -462,52 +481,50 @@ pub async fn handle_api_key(
|
||||
println!("\n⚠️ {}", response.warning);
|
||||
}
|
||||
}
|
||||
crate::cli::args::ApiKeyAction::List => {
|
||||
match db.list_api_keys().await {
|
||||
Ok(keys) => {
|
||||
println!("\n📋 API Key List");
|
||||
if keys.is_empty() {
|
||||
println!(" (no API keys found)");
|
||||
} else {
|
||||
println!("\n┌────────────────────────────────────────────────────────────────────────────┐");
|
||||
crate::cli::args::ApiKeyAction::List => match db.list_api_keys().await {
|
||||
Ok(keys) => {
|
||||
println!("\n📋 API Key List");
|
||||
if keys.is_empty() {
|
||||
println!(" (no API keys found)");
|
||||
} else {
|
||||
println!("\n┌────────────────────────────────────────────────────────────────────────────┐");
|
||||
println!(
|
||||
"│ {:8} │ {:20} │ {:12} │ {:8} │ {:15} │",
|
||||
"Status", "Name", "Type", "Usage", "Last Used"
|
||||
);
|
||||
println!("├────────────────────────────────────────────────────────────────────────────┤");
|
||||
for k in &keys {
|
||||
let status = if k.status == "active" {
|
||||
"✓ active"
|
||||
} else {
|
||||
&k.status
|
||||
};
|
||||
let last_used = k
|
||||
.last_used_at
|
||||
.map(|dt| dt.format("%Y-%m-%d %H:%M").to_string())
|
||||
.unwrap_or_else(|| "never".to_string());
|
||||
println!(
|
||||
"│ {:8} │ {:20} │ {:12} │ {:8} │ {:15} │",
|
||||
"Status", "Name", "Type", "Usage", "Last Used"
|
||||
);
|
||||
println!("├────────────────────────────────────────────────────────────────────────────┤");
|
||||
for k in &keys {
|
||||
let status = if k.status == "active" {
|
||||
"✓ active"
|
||||
status,
|
||||
if k.name.len() > 20 {
|
||||
&k.name[..17]
|
||||
} else {
|
||||
&k.status
|
||||
};
|
||||
let last_used = k
|
||||
.last_used_at
|
||||
.map(|dt| dt.format("%Y-%m-%d %H:%M").to_string())
|
||||
.unwrap_or_else(|| "never".to_string());
|
||||
println!(
|
||||
"│ {:8} │ {:20} │ {:12} │ {:8} │ {:15} │",
|
||||
status,
|
||||
if k.name.len() > 20 {
|
||||
&k.name[..17]
|
||||
} else {
|
||||
&k.name
|
||||
},
|
||||
k.key_type,
|
||||
k.usage_count,
|
||||
last_used
|
||||
);
|
||||
}
|
||||
println!("└────────────────────────────────────────────────────────────────────────────┘");
|
||||
println!("\nTotal: {} key(s)", keys.len());
|
||||
&k.name
|
||||
},
|
||||
k.key_type,
|
||||
k.usage_count,
|
||||
last_used
|
||||
);
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("\n❌ Failed to list API keys: {}", e);
|
||||
return Err(e);
|
||||
println!("└────────────────────────────────────────────────────────────────────────────┘");
|
||||
println!("\nTotal: {} key(s)", keys.len());
|
||||
}
|
||||
}
|
||||
}
|
||||
Err(e) => {
|
||||
eprintln!("\n❌ Failed to list API keys: {}", e);
|
||||
return Err(e);
|
||||
}
|
||||
},
|
||||
crate::cli::args::ApiKeyAction::Validate => {
|
||||
eprintln!("⚠️ Validate action not implemented");
|
||||
std::process::exit(1);
|
||||
|
||||
Reference in New Issue
Block a user