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:
Accusys
2026-10-12 10:00:51 +08:00
parent 0a18e70639
commit 63fbbe1225
418 changed files with 44084 additions and 4280 deletions
+32 -28
View File
@@ -57,21 +57,27 @@ fn test_track_faces_with_real_data() {
}
]
}"#;
// 解析
let mut face_result: FaceResult = serde_json::from_str(face_json)
.expect("Failed to parse test data");
let mut face_result: FaceResult =
serde_json::from_str(face_json).expect("Failed to parse test data");
println!("測試數據:");
println!(" Frames: {}", face_result.frames.len());
println!(" Total faces: {}", face_result.frames.iter().map(|f| f.faces.len()).sum::<usize>());
println!(
" Total faces: {}",
face_result
.frames
.iter()
.map(|f| f.faces.len())
.sum::<usize>()
);
// 執行追蹤
track_faces(&mut face_result, 0.3, 0.7, 100.0, true, None)
.expect("Failed to track faces");
track_faces(&mut face_result, 0.3, 0.7, 100.0, true, None).expect("Failed to track faces");
println!("\n追蹤完成");
// 驗證 trace_id
let mut trace_ids = Vec::new();
for frame in &face_result.frames {
@@ -84,16 +90,16 @@ fn test_track_faces_with_real_data() {
}
}
}
// 所有 faces 應該有相同的 trace_id(因為它們是同一個人)
assert_eq!(trace_ids.len(), 3);
assert!(trace_ids.iter().all(|&id| id == trace_ids[0]));
// 驗證 metadata
assert!(face_result.metadata.is_some());
let metadata = face_result.metadata.as_ref().unwrap();
assert!(metadata.get("traces").is_some());
println!("\n✅ 測試通過");
}
@@ -155,13 +161,12 @@ fn test_track_multiple_faces() {
}
]
}"#;
let mut face_result: FaceResult = serde_json::from_str(face_json)
.expect("Failed to parse test data");
track_faces(&mut face_result, 0.3, 0.7, 100.0, true, None)
.expect("Failed to track faces");
let mut face_result: FaceResult =
serde_json::from_str(face_json).expect("Failed to parse test data");
track_faces(&mut face_result, 0.3, 0.7, 100.0, true, None).expect("Failed to track faces");
// 應該有兩個不同的 trace_id
let mut trace_ids = std::collections::HashSet::new();
for frame in &face_result.frames {
@@ -171,7 +176,7 @@ fn test_track_multiple_faces() {
}
}
}
assert_eq!(trace_ids.len(), 2);
println!("✅ 多人追蹤測試通過: {} 個 traces", trace_ids.len());
}
@@ -185,13 +190,12 @@ fn test_track_no_faces() {
"total_faces": 0,
"frames": []
}"#;
let mut face_result: FaceResult = serde_json::from_str(face_json)
.expect("Failed to parse test data");
track_faces(&mut face_result, 0.3, 0.7, 100.0, true, None)
.expect("Failed to track faces");
let mut face_result: FaceResult =
serde_json::from_str(face_json).expect("Failed to parse test data");
track_faces(&mut face_result, 0.3, 0.7, 100.0, true, None).expect("Failed to track faces");
// 不應該崩潰
println!("✅ 無人臉測試通過");
}
+39 -26
View File
@@ -4,38 +4,44 @@ use momentry_core::core::processor::face_tracker::track_faces;
#[test]
fn test_track_real_face_json() {
// 讀取實際的 face.json
let face_json_path = "/Users/accusys/momentry/output/b496a68800f90770aa7246c877f38985.face.json";
let face_json_path =
"/Users/accusys/momentry/output/b496a68800f90770aa7246c877f38985.face.json";
if !std::path::Path::new(face_json_path).exists() {
println!("⚠️ face.json not found, skipping real data test");
return;
}
let face_json = std::fs::read_to_string(face_json_path)
.expect("Failed to read face.json");
let mut face_result: FaceResult = serde_json::from_str(&face_json)
.expect("Failed to parse face.json");
let face_json = std::fs::read_to_string(face_json_path).expect("Failed to read face.json");
let mut face_result: FaceResult =
serde_json::from_str(&face_json).expect("Failed to parse face.json");
println!("\n實際數據測試:");
println!(" Frames: {}", face_result.frames.len());
println!(" FPS: {}", face_result.fps);
println!(" Total faces: {}", face_result.frames.iter().map(|f| f.faces.len()).sum::<usize>());
println!(
" Total faces: {}",
face_result
.frames
.iter()
.map(|f| f.faces.len())
.sum::<usize>()
);
// 執行追蹤
let start = std::time::Instant::now();
track_faces(&mut face_result, 0.3, 0.7, 100.0, true, None)
.expect("Failed to track faces");
track_faces(&mut face_result, 0.3, 0.7, 100.0, true, None).expect("Failed to track faces");
let duration = start.elapsed();
println!("\n✅ 追蹤完成");
println!(" 耗時: {:?}", duration);
// 統計 trace_id
let mut total_faces = 0;
let mut faces_with_trace_id = 0;
let mut trace_ids = std::collections::HashSet::new();
for frame in &face_result.frames {
for face in &frame.faces {
total_faces += 1;
@@ -45,35 +51,42 @@ fn test_track_real_face_json() {
}
}
}
println!("\n追蹤結果:");
println!(" Total faces: {}", total_faces);
println!(" Faces with trace_id: {}", faces_with_trace_id);
println!(" Unique traces: {}", trace_ids.len());
// 驗證所有 faces 都有 trace_id
assert_eq!(faces_with_trace_id, total_faces, "Not all faces have trace_id!");
assert_eq!(
faces_with_trace_id, total_faces,
"Not all faces have trace_id!"
);
// 驗證 metadata
assert!(face_result.metadata.is_some(), "Metadata is missing!");
let metadata = face_result.metadata.as_ref().unwrap();
let traces = metadata.get("traces")
let traces = metadata
.get("traces")
.expect("Traces missing in metadata")
.as_object()
.expect("Traces is not an object");
println!(" Traces in metadata: {}", traces.len());
// 顯示一些追蹤信息
println!("\n前 5 個 traces:");
for (i, (trace_id, trace_data)) in traces.iter().take(5).enumerate() {
if let Some(start_frame) = trace_data.get("start_frame") {
if let Some(end_frame) = trace_data.get("end_frame") {
println!(" Trace {}: frames {} - {}", trace_id, start_frame, end_frame);
println!(
" Trace {}: frames {} - {}",
trace_id, start_frame, end_frame
);
}
}
}
println!("\n✅ 實際數據測試通過");
}
+18 -12
View File
@@ -4,38 +4,44 @@ use momentry_core::core::processor::processor_config_v3::ProcessorConfigManager;
async fn test_load_config() {
let manager = ProcessorConfigManager::load().await;
assert!(manager.is_ok(), "Failed to load config");
let manager = manager.unwrap();
let processors = manager.get_all_processors();
assert!(!processors.is_empty(), "No processors found");
println!("Processors: {:?}", processors);
// Test POSE processor
let pose_impls = manager.get_implementations_by_priority("pose");
assert!(!pose_impls.is_empty(), "No POSE implementations");
let first_impl = &pose_impls[0];
assert_eq!(first_impl.tool, "rust", "First POSE implementation should be Rust");
assert_eq!(
first_impl.tool, "rust",
"First POSE implementation should be Rust"
);
assert_eq!(first_impl.priority, 0);
assert!(first_impl.enabled);
println!("POSE implementations: {:#?}", pose_impls);
}
#[tokio::test]
async fn test_resolve_command() {
let manager = ProcessorConfigManager::load().await.unwrap();
let mut variables = std::collections::HashMap::new();
variables.insert("video_path".to_string(), "/path/to/video.mp4".to_string());
variables.insert("output_path".to_string(), "/path/to/output.json".to_string());
variables.insert(
"output_path".to_string(),
"/path/to/output.json".to_string(),
);
variables.insert("file_uuid".to_string(), "test-uuid".to_string());
// Test Rust POSE
let result = manager.resolve_command("pose", "rust", &variables);
assert!(result.is_ok(), "Failed to resolve command");
if let Ok(Some((executable, args))) = result {
println!("Executable: {:?}", executable);
println!("Args: {:?}", args);
@@ -45,10 +51,10 @@ async fn test_resolve_command() {
#[tokio::test]
async fn test_get_default() {
let manager = ProcessorConfigManager::load().await.unwrap();
let default = manager.get_default_implementation("pose");
assert!(default.is_some(), "No default implementation for POSE");
let default = default.unwrap();
println!("Default POSE implementation: {:?}", default.tool);
}
+28 -16
View File
@@ -6,37 +6,49 @@ fn test_rust_face_tracker_with_real_data() {
// 讀取測試數據
let json_str = std::fs::read_to_string("/tmp/test_input_no_trace.json")
.expect("Failed to read test input");
let mut result: FaceResult = serde_json::from_str(&json_str)
.expect("Failed to parse FaceResult");
let mut result: FaceResult =
serde_json::from_str(&json_str).expect("Failed to parse FaceResult");
println!("Processing {} frames", result.frames.len());
println!("Total faces: {}", result.total_faces);
// 檢查沒有 trace_id
let before_count = result.frames.iter()
let before_count = result
.frames
.iter()
.flat_map(|f| &f.faces)
.filter(|face| face.trace_id.is_some())
.count();
println!("Faces with trace_id before: {}/{}", before_count, result.total_faces);
println!(
"Faces with trace_id before: {}/{}",
before_count, result.total_faces
);
assert_eq!(before_count, 0, "No faces should have trace_id initially");
// 執行 tracking
track_faces(&mut result, 0.3, 0.7, 100.0, true, None)
.expect("Tracking failed");
track_faces(&mut result, 0.3, 0.7, 100.0, true, None).expect("Tracking failed");
// 檢查結果
let after_count = result.frames.iter()
let after_count = result
.frames
.iter()
.flat_map(|f| &f.faces)
.filter(|face| face.trace_id.is_some())
.count();
println!("Faces with trace_id after: {}/{}", after_count, result.total_faces);
println!(
"Faces with trace_id after: {}/{}",
after_count, result.total_faces
);
// 保存結果
let output = serde_json::to_string_pretty(&result).expect("Failed to serialize");
std::fs::write("/tmp/test_rust_output.json", output).expect("Failed to write");
println!("Output saved to /tmp/test_rust_output.json");
// 驗證
assert!(after_count > 0, "At least some faces should have trace_id after tracking");
assert!(
after_count > 0,
"At least some faces should have trace_id after tracking"
);
}