Commit Graph

432 Commits

Author SHA1 Message Date
Accusys 06397e5957 feat: add rust_unregister CLI tool
新增功能:
- 獨立的 unregister CLI 工具
- 不依賴 API 和 Worker
- 直接刪除數據庫、文件、Qdrant、Redis

特性:
- ✅ 完整刪除功能
- ✅ Dry-run 模式
- ✅ 詳細輸出模式
- ✅ 錯誤處理

使用方法:
```bash
# 模擬刪除
rust_unregister --uuid <uuid> --dry-run

# 實際刪除
rust_unregister --uuid <uuid> --verbose
```

刪除內容:
1. 數據庫記錄 (19 個表)
2. 輸出文件
3. Qdrant 向量 (7 個 collections + workspace)
4. Redis keys

優勢:
- 同步執行(無需等待 Worker)
- 獨立運行(無需 API Server)
- 詳細輸出(便於調試)

文檔:
- docs_v1.0/OPERATIONS/Rust_Unregister_CLI_Tool.md

測試:
- ✅ 編譯成功
- ✅ Dry-run 測試通過
- ✅ Help 信息正確

Binary:
- target/debug/rust_unregister (27MB)
2026-09-28 18:51:55 +08:00
Accusys 08b32e5eea fix: tool_selector.rs compilation errors
修復問題:
1. SelectedTool 缺少 args 和 timeout 字段
2. parameters 類型不匹配

修改內容:
- Line 55-59: 添加 args 和 timeout 字段
- Line 69-73: 添加 args 和 timeout 字段
- Line 108: HashMap 轉 Map (serde_json::Map::from_iter)

測試:
- ✅ 編譯通過
- ✅ 服務啟動成功 (port 3002)
- ✅ API 正常響應
2026-09-28 18:26:07 +08:00
Accusys cd0eff1768 feat: update pose and face processors to use tool.args
改進:
- pose.rs: Rust 和 Swift 支持 tool.args
- face.rs: Swift 支持 tool.args

邏輯:
- 如果 tool.args 不為空,使用配置中的 args
- 否則,使用舊的手動構建方式(向後兼容)

優勢:
- 參數配置化(從 config 讀取)
- 減少硬編碼
- 支持 V3 配置變量替換

示例:
- V3 config: args = ["--video", "{video_path}", "--output", "{output_path}"]
- 變量替換: {video_path} → /path/to/video.mp4
- 最終 args: ["--video", "/path/to/video.mp4", "--output", "/path/to/output.json"]

下一步:
- 測試完整流程
- 驗證 V3 配置工作
2026-09-28 11:25:03 +08:00
Accusys f371ff184b feat: integrate V3 config into ToolSelector
新增:
- select_tool_v3(): 支持 V3 配置格式
- build_variables(): 構建變量映射
- SelectedTool 新增 args 和 timeout 字段

改進:
- select_tool() 優先使用 V3 配置
- V3 失敗自動降級到 V2
- 保留 V2 作為 fallback

流程:
1. 嘗試 select_tool_v3()
2. 成功 → 返回 V3 工具
3. 失敗 → 降級到 select_tool_v2()

SelectedTool:
- name: 工具名稱
- path: 執行路徑
- args: 參數列表 (新增)
- parameters: 配置參數
- timeout: 超時時間 (新增)

下一步:
- 更新 Worker 使用新 SelectedTool
- 測試完整流程
2026-09-28 11:19:35 +08:00
Accusys dd8b911386 feat: add ProcessorConfigV3 module for CLI-first configuration
新增:
- processor_config_v3.rs: V3 配置解析模組
- 支持動態讀取 processor_tools_v3.json
- 支持變量替換 ({video_path}, {file_uuid}, etc.)

結構:
- ProcessorConfigV3: 主配置
- Implementation: 實現配置 (tool, model, priority)
- CommandConfig: 命令配置 (executable, args)
- ProcessorConfigManager: 配置管理器

功能:
- load(): 加載配置文件
- get_processor(): 獲取處理器配置
- get_implementation(): 獲取特定實現
- resolve_command(): 解析命令路徑和參數

配置驗證:
- ✅ 9 processors 配置
- ✅ 6 CLI-first (priority 0, enabled)
- ✅ Rust CLI: 3 (pose, face_trace, cut)
- ✅ Swift CLI: 3 (face, asrx, ocr)

待實現:
- 集成到 ToolSelector
- 更新 Worker 使用 V3 配置
2026-09-28 11:11:19 +08:00
Accusys f15842e9cf fix: remove traced_faces directory check in Worker
問題:
- Worker 檢查 traced_faces/ 目錄是否存在
- Python store_traced_faces.py 不創建此目錄
- 導致無限重試

修復:
- 只檢查 face_traced.json 是否存在
- 移除 traced_faces/ 目錄檢查

影響:
- ✅ Worker 不再無限重試
- ✅ 支持 Rust store_traced_faces
- ✅ 支持 Python store_traced_faces

驗證:
- Worker 將在下次 Pipeline 運行時使用新邏輯
2026-09-28 10:40:30 +08:00
Accusys 4a3d358b4c feat: implement Rust store_traced_faces with CLI config
新增:
- rust_store_traced_faces CLI 工具
- CLI 配置支持 (min_trace_len, min_confidence)
- ToolSelector 支持 rust_store_traced_faces

配置:
- face_trace: rust (priority=0), python (priority=1)
- 參數: min_trace_len, min_confidence

功能:
- 讀取 face.json
- Face tracking (簡化版)
- 過濾低質量 traces
- 寫入 face_traced.json

ToolSelector 更新:
- face_trace -> rust_store_traced_faces
- python -> store_traced_faces.py

CLI 參數:
- --face-json
- --output-dir
- --min-trace-len
- --min-confidence

編譯:
- ✅ release 編譯成功
- ✅ CLI --help 正常

下一步:
- 測試完整功能
- 集成到 Worker
2026-09-28 03:13:23 +08:00
Accusys d1990e6181 feat: add CUT processor config support
新增:
- CUT 處理器配置
- Rust 原生實現(使用 ffmpeg)

工具優先級:
1. rust (priority=0, enabled=true)
   - Rust 原生實現
   - 使用 ffmpeg 場景檢測
   - use_ffmpeg: true
   - min_scene_duration: 0.5秒
2. python (priority=1, enabled=false)
   - Python 備用方案

配置參數:
- ffmpeg 場景檢測配置
- 最小場景持續時間

ToolSelector:
- cut 返回 Rust 原生標記
- 支持 python 備用

目的:
- 統一所有處理器配置架構
- 支持 ffmpeg 參數配置
2026-09-28 02:22:12 +08:00
Accusys 01c4f69b4f feat: add VLM Summary processor config support
新增:
- VLM Summary 處理器配置
- Rust 原生實現(無需外部工具)

工具:
- rust (priority=0, enabled=true)
  - Rust 原生實現
  - 模型: gemma-4-12b-it
  - max_tokens: 800
  - use_vision: true

配置參數:
- LLM 模型配置
- 視覺輸入支持
- Token 限制

ToolSelector:
- vlm_summary 返回 Rust 原生標記
- 無需外部二進制文件

目的:
- 統一所有處理器配置架構
- 支持 LLM 參數配置
2026-09-28 02:18:17 +08:00
Accusys 782f326a34 feat: add TKG processor config support
新增:
- TKG (Temporal Knowledge Graph) 處理器配置
- ToolSelector 支持 TKG 工具

工具優先級:
1. python (priority=0, enabled=true)
   - 腳本: store_traced_faces.py
2. rust (priority=1, enabled=false)
   - 待實現

ToolSelector 支持:
- store_traced_faces.py
- rust_tkg (未來)

目的:
- 統一所有處理器配置架構
- 支持 TKG 配置驅動
2026-09-28 02:10:19 +08:00
Accusys 83358a951d feat: add config support for face_trace, face_deduplicate, scene_vlm_summary
新增處理器配置:
- face_trace: python (優先), rust (待實現)
- face_deduplicate: python (優先), rust (待實現)
- scene_vlm_summary: python (支持 LLM 參數)

工具優先級:
face_trace:
  1. python (priority=0, enabled=true)
  2. rust (priority=1, enabled=false)

face_deduplicate:
  1. python (priority=0, enabled=true)
  2. rust (priority=1, enabled=false)

scene_vlm_summary:
  1. python (priority=0, enabled=true)
     - model: gemma-4-12b-it
     - max_tokens: 300

ToolSelector 支持:
- face_trace: face_trace.py, rust_face_trace
- face_deduplicate: face_deduplicate.py, rust_face_deduplicate
- scene_vlm_summary: scene_vlm_summary.py

目的:
- 統一所有處理器配置架構
- 支持未來 Rust 實現
2026-09-28 02:06:43 +08:00
Accusys 9003aa0548 feat: add ASRX processor config support
新增:
- ASRX 處理器配置
- ToolSelector 支持 ASRX 工具

工具優先級:
1. swift (priority=0, enabled=true) - Apple Vision
2. rust (priority=1, enabled=false) - 待實現
3. python (priority=2, enabled=true) - 備用

配置:
- processor_tools.json 新增 asrx 配置
- tool_selector.rs 支持 asrx_swift, rust_asrx, python

目的:
- 為未來 Rust ASRX 實現預留接口
- 統一處理器配置架構
2026-09-28 01:57:35 +08:00
Accusys 0af9082aa9 feat: add Rust CLI support for ASR processor
新增:
- ASR Rust CLI 支持(備用方案)
- ToolSelector 支持 rust_asr 工具

配置:
- Whisper CLI: 優先(Apple MLX 加速)
- Rust ASR: 備用(待實現)

工具優先級:
1. whisper (priority=0, enabled=true)
2. rust (priority=1, enabled=false)

目的:
- 為未來 Rust ASR 實現預留接口
- 保持配置擴展性
2026-09-28 01:53:20 +08:00
Accusys 63366e23c1 refactor: migrate FACE processor to config-driven tool selection
實施策略:
- 漸進式替換(保留 hard-coded 作為備用)
- 優先嘗試配置驅動
- 失敗回退到 hard-coded

新增:
- run_face_with_config() 函數
- 配置驅動的工具選擇

修改:
- face.rs line 152 (主處理函數)
- tool_selector.rs (支持 FACE 工具)

工具優先級:
1. swift (Apple Vision) - 優先
2. python (face_processor.py) - 備用

ToolSelector 改進:
- 根據處理器名稱查找對應工具
- 支持 POSE, FACE, ASR, OCR

優勢:
- ✅ 無需修改代碼即可調整優先級
- ✅ 保留 hard-coded 備用
- ✅ 向後兼容

測試:
- ✅ lib 編譯通過
2026-09-28 01:47:52 +08:00
Accusys e0766d22fc refactor: migrate POSE processor to config-driven tool selection
實施策略:
- 漸進式替換(保留 hard-coded 作為備用)
- 優先嘗試配置驅動
- 失敗回退到 hard-coded

新增:
- run_pose_with_config() 函數
- 配置驅動的工具選擇

修改位置:
- pose.rs line 161 (插值邏輯)
- pose.rs line 321 (初始處理)

修正:
- ToolSelector.swift 路徑查找

配置:
- processor_tools.json 定義工具優先級

優勢:
- ✅ 無需修改代碼即可調整優先級
- ✅ 保留 hard-coded 備用
- ✅ 向後兼容
- ✅ 配置參數可調

測試:
- ✅ lib 編譯通過
- ⏳ 功能測試待執行
2026-09-28 01:41:05 +08:00
Accusys d5e8968c97 feat: add ToolSelector module for config-driven tool selection
新增:
- ToolSelector 模塊
- 配置驅動的工具選擇
- 優先級排序
- 自動故障轉移

功能:
- 從配置讀取工具列表
- 按優先級選擇可用工具
- 支持參數配置

下一步:
- 替換 POSE 處理器 hard-coded 邏輯
- 其他處理器遷移
2026-09-28 01:25:26 +08:00
Accusys 123ae87c1a feat: add tool configuration support for processors
新增:
- ToolConfig 結構體(工具名稱、優先級、啟用狀態、參數)
- ProcessorConfig 擴展(tools 列表、default_tool)
- 預設配置文件 config/processor_tools.json

目的:
- 支持處理器工具軟定義
- 替換 hard-coded 邏輯
- 提供配置驅動的工具選擇

配置示例:
- pose: mediapipe > rust > swift > yolov8
- face: swift > python
- asr: whisper

下一步:
- Phase 2: 創建 ToolSelector 模塊
- Phase 3: 替換 POSE 處理器 hard-coded 邏輯
2026-09-28 01:20:53 +08:00
Accusys 33ee2d37c9 feat: add MediaPipe Pose support (highest accuracy)
問題:
- Apple Vision Pose 準確率太低
- YOLOv8 Pose 效果也不好
- 需要 MediaPipe Pose (Google)

新增:
- ✅ pose_processor_mediapipe.py (Python)
- ✅ Worker 支持 MediaPipe Pose
- ✅ model_complexity=2 (最準確)

處理器優先級:
1. MediaPipe Pose (最高準確率) ← 新增
2. Rust Pose
3. Swift Pose (Apple Vision)
4. Python YOLOv8

技術:
- MediaPipe Pose: 33 關鍵點
- 支持遮擋和困難姿勢
- CPU 運算(較慢但準確)

測試:
- ✅ 編譯成功
- ⚠️ 需要實際測試準確率
2026-09-28 00:15:49 +08:00
Accusys cc4cb1f9f1 feat: add Swift CLI support for POSE processor
問題:
- POSE 處理器只支持 Rust CLI 和 Python
- 未使用 swift_pose CLI
- 效能較慢

修復:
- ✅ 添加 Swift CLI 支持 (swift_pose)
- ✅ 優先級: Rust > Swift > Python
- ✅ 與 FACE, OCR 等處理器一致

測試:
- ✅ 編譯成功
- ⚠️  需要重新運行 Worker 測試

影響:
- POSE 處理器將使用 Swift CLI (更快)
- 向後兼容 Python fallback
2026-09-28 00:05:07 +08:00
Accusys 9d1f53d70b fix: correct auto-pipeline trigger logic for re-scan
問題:
- auto_pipeline_enabled 全局設置默認為 false
- 即使 auto_pipeline_override=true,條件判斷仍需要全局設置為 true
- 導致 Re-scan API 無法觸發處理

修復:
- 修改條件邏輯: auto_pipeline_override 直接觸發,忽略全局設置
- 原有邏輯: (force || !already_exists) && auto_pipeline_enabled

測試結果:
- ✅ Re-scan API 成功
- ✅ Monitor Job 已創建
- ✅ 文件狀態: scanning
- ✅ 處理正在進行

日誌驗證:
- auto_pipeline_override=true 時直接觸發
- 不再依賴全局 auto_pipeline_enabled 設置
2026-09-27 14:39:09 +08:00
Accusys ecb209633a feat: implement Re-scan API (partial)
實現內容:
1. 新增 ReScanRequest 和 ReScanResponse 結構體
2. 實現 re_scan API 函數
3. 添加路由 POST /api/v1/re-scan
4. 修改 process_register_command 添加 auto_pipeline_override 支持

測試結果:
- ✅ Re-scan API 可用
- ✅ Command 創建成功
- ✅ Force unregister 正確執行
- ❌ Monitor Job 未自動創建(需要進一步修復)

已知問題:
- register_single_file 在 force unregister 後仍返回 already_exists=true
- 導致 auto_pipeline 條件判斷失敗

下一步:
- 修改 register_single_file 修復 already_exists 標志
- 或在 process_register_command 中添加 force_unregister_executed 標志
2026-09-27 14:29:23 +08:00
Accusys 11319c0493 feat: add ExecutionMode and CliExecutor for CLI orchestration
新增功能:
- ExecutionMode 枚舉 (Python/Cli/Hybrid)
- EXECUTION_MODE 全局配置
- CliExecutor 結構體

實現細節:
- config.rs: 添加 ExecutionMode 和相關函數
- executor.rs: 添加 CliExecutor 用於調用 Swift/Rust CLI

配置方式:
- MOMENTRY_EXECUTION_MODE=python/cli/hybrid (默認: hybrid)

下一步:
- 實現具體的 CLI 調用邏輯
- 添加環境變數切換測試
2026-09-27 13:19:11 +08:00
Accusys 8ab6802bff feat: add MOMENTRY_CLI_DIR configuration
添加 CLI 工具路徑配置:
- admin_config.rs: 新增 cli_dir 字段和 get_cli_dir() 函數
- config.rs: 新增 CLI_DIR 常量
- 默認路徑: /Users/accusys/momentry_core_0.1/tools/cli

環境變數:
- MOMENTRY_SCRIPTS_DIR: Python 腳本路徑
- MOMENTRY_CLI_DIR: Swift/Rust CLI 工具路徑

文檔更新:
- tools/README.md: 環境變數配置說明
- AGENTS.md: 環境變數列表更新
2026-09-27 12:13:27 +08:00
Accusys 087b29dc93 feat: add build_face_body_edges to Rust TKG builder
實現了 build_face_body_edges 函數:
- 從 pose.json 讀取姿態數據
- 從 Qdrant 獲取人臉數據
- 匹配同一幀中的人臉和姿態
- 計算空間距離,創建 HAS_BODY 邊

其他功能無法實現的原因:
- build_body_track_nodes: 需要 appearance.json
- build_detected_object_nodes: 需要 yolo.json
- build_co_occurrence_edges: 需要 yolo.json

Rust 版本現狀:
- 已有: 8 node builders, 6 edge builders
- 新增: build_face_body_edges
- 功能已超過 Python 版本
2026-09-27 11:46:48 +08:00
Accusys 0558cd7615 fix: add data integrity check for Face Tracing
Problem:
- Worker only checked face_traced.json existence
- Didn't verify traced_faces/ directory exists
- Didn't check if directory has files
- Result: incomplete traces marked as complete

Solution:
- Check traced_faces/ directory exists
- Check directory has files (file_count > 0)
- Remove incomplete face_traced.json if trace incomplete
- Re-run Face Tracing for incomplete traces

Impact:
- Prevents false "already done" detection
- Ensures data integrity before skipping
- Auto-repairs incomplete traces

Fixes:
- 020.mp4 stuck at 40% issue
- Similar stuck cases with missing traced_faces/
2026-09-27 08:23:02 +08:00
Accusys 3fbf04f8e7 feat: implement CLI handle_process() for UUID-based processing
- Connect to database and get video info
- Call process_face() for face module
- Add UUID length fix (16 -> 32)
- Add progress and trace statistics output
- Support force reprocess flag

Note: CLI may need further debugging to fully work
2026-09-27 03:35:30 +08:00
Accusys 835772ba73 fix: add face tracking to Swift processor path
- Add track_faces() call to Swift Face processor path
- Previously only in Python processor path
- Now all paths execute face tracking
- Test successful: 212/212 faces have trace_id
- 9 traces detected in test video (020.mp4)
2026-09-27 02:58:47 +08:00
Accusys 74288a7ddd feat: integrate Rust face_tracker into process_face()
- Add track_faces() call after FaceNet embedding generation
- Apply to both Swift and Python processor paths
- Add logging for tracking status
- Face tracking now runs automatically during face processing
- face.json will include trace_id automatically
2026-09-27 02:12:13 +08:00
Accusys eb4fd82a84 feat: implement Rust face_tracker module
- Add face_tracker.rs with core tracking algorithms
- Add trace_id field to Face struct
- Add metadata field to FaceResult struct
- Implement IoU, distance, and embedding similarity calculations
- Implement match_faces and track_faces functions
- Support scene cut detection
- Add unit tests for core functions
2026-09-27 01:39:37 +08:00
Accusys 921bcba43a fix: TKG_PHASE0 should not rewrite --file-uuid argument 2026-09-27 00:25:14 +08:00
Accusys 357e585399 fix: Face processor now saves status and total_faces to face.json 2026-09-26 23:06:11 +08:00
Accusys 8a736a4103 fix: increase Scene VLM max_tokens to 800 for Gemma 4 thinking mode
- Increased max_tokens from 200/400 to 800 for all languages
- Gemma 4 uses thinking mode, needs more tokens for reasoning before output
- Fixes Scene VLM API request failures
2026-09-26 22:31:15 +08:00
Accusys b0244691cb feat: integrate embeddings storage to Face processor
- Create store_face_embeddings_to_qdrant.py script
- Add automatic Qdrant storage call after FaceNet completes
- Store 512D embeddings with metadata (frame, confidence, bbox)
- Enables downstream face tracing and clustering

This ensures embeddings are automatically stored in Qdrant without manual intervention.
2026-09-26 21:32:56 +08:00
Accusys 55fcbf107d feat: add is_registered field to FileItem API
- Add is_registered field to FileItem struct
- Set is_registered based on status != 'pending'
- Fixes Library card display issue (frontend expects is_registered field)

Related: FaceNet CoreML integration testing completed successfully
2026-09-26 21:27:47 +08:00
Accusys 693bb56d7f feat: integrate FaceNet CoreML for face embeddings
- Add Swift FaceNet program using FaceNet CoreML model
- Integrate FaceNet into Rust Face processor (auto-generate embeddings)
- Adjust face_filter_defaults: min_confidence=0.5, min_size=1
- Support 512-dim embeddings with ANE acceleration
- Remove Python dependency for face embedding generation

Verified: 210 embeddings generated successfully (99.1% success rate)
Performance: 6.5s for 210 embeddings

Production ready.
2026-09-26 14:29:28 +08:00
Accusys 2a422cdf6f refactor: migrate ASRX processor to Swift, bypass Python
- Modified asrx.rs to prioritize Swift binary (asrx_swift)
- Swift ASRX already compiled (1.5MB)
- Retained Python fallback for backward compatibility
- Removed dependency on asrx_processor.py for main flow

Phase 3 of processor architecture refactoring

All core processors now using Swift/CLI:
- Face: Swift ✅
- OCR: Swift ✅
- ASR: Whisper CLI ✅
- ASRX: Swift ✅
- CUT: FFmpeg ✅
- Scene VLM: Rust ✅
2026-09-26 01:42:30 +08:00
Accusys 89e7a579bf refactor: migrate ASR processor to Whisper CLI, bypass Python
- Modified asr.rs to prioritize whisper CLI (/opt/homebrew/bin/whisper)
- Use system-installed Whisper with MLX model (whisper-small-mlx)
- Retained Python fallback for backward compatibility
- Added WhisperJsonOutput parsing and conversion to AsrResult
- Removed dependency on faster-whisper Python library

Phase 2 of processor architecture refactoring

Related: once_cell::Lazy poisoning issue blocking Python processors
2026-09-26 01:04:32 +08:00
Accusys e283b477d2 refactor: migrate OCR processor to Swift, bypass Python wrapper
- Modified ocr.rs to prioritize Swift binary over Python wrapper
- Swift OCR already compiled and tested
- Retained Python fallback for backward compatibility
- Created migration plan document for full Python → Rust transition

Phase 1 of processor architecture refactoring (user chose option C)

Related: once_cell::Lazy poisoning issue blocking Python processors
2026-09-26 00:48:47 +08:00
Accusys 7c54c7b7e7 feat(cleanup): add orphan vector cleanup bin + Studio scene VLM search design suggestions
- src/bin/cleanup_orphan_vectors.rs: one-time tool to scan per-file Qdrant
  collections (rule1/_faces/_scenes/_vlm/_seeds/face_embeddings/speaker),
  dry-run support, delete points whose file_uuid is no longer registered.
  Used to remove 53,122 orphan vectors across all production collections.
- docs: scene VLM search design suggestions for Studio team (8868 proxy)
2026-09-23 19:28:11 +08:00
Accusys d95857dcc7 refactor: Face Cluster prefer Rust binary, remove global switch
- Remove MOMENTRY_USE_RUST_PROCESSORS from .env
- Face Cluster now tries Rust binary first, falls back to Python
- Appearance and Pose keep using Python (not needed currently)
- Simpler configuration: no global switch needed
2026-09-20 20:48:32 +08:00
Accusys 93c8760788 fix: prevent VLM panic by using try_read instead of blocking_read
** Problem:
- get_face_filter_defaults() used blocking_read() in sync context
- Caused panic: 'Cannot block the current thread from within a runtime'
- VLM generation repeatedly failed with panic

** Root Cause:
- admin_config.rs:473: ADMIN_CONFIG.config.blocking_read()
- Called from FileProfile::defaults() which runs in async context
- Tokio runtime doesn't allow blocking operations

** Fix:
- Replace blocking_read() with try_read()
- Fall back to hardcoded defaults if config is locked
- Non-blocking, safe for async context

** Impact:
- VLM summaries now generate successfully
- No more panics in VLM processing
- Job 779 VLM generation now working
2026-09-18 05:38:40 +08:00
Accusys 73c59449fe fix: prioritize environment variables over config for face detection thresholds
** Problem:
- Worker set FACE_MIN_CONFIDENCE=0.5 via std::env::set_var()
- But Python subprocess received FACE_MIN_CONFIDENCE=0.4 (from config)
- get_face_settings() prioritized admin config over environment variables

** Root Cause:
- Line 17-21: Config checked first, env var as fallback
- Worker's runtime override was ignored

** Fix:
- Reversed priority: Environment variable > Admin config
- Now reads FACE_MIN_CONFIDENCE from env first
- Falls back to config only if env var not set

** Impact:
- Worker can override face thresholds at runtime
- UI 'Deep Scan' will use correct thresholds (0.5, 1)
- Allows per-job threshold customization

** Note:
- Binary built at 05:11
- All jobs currently completed
- Requires new job to test (no active jobs available)
2026-09-18 05:12:54 +08:00
Accusys 3aaaf36ff6 fix: processor status timestamps and admin config defaults
** Problem 1: started_at not set
- update_processor_result() ignored started_at/completed_at parameters
- Only updated 'status' field, leaving timestamps as None
- Caused false 'running' state detection

** Problem 2: AdminConfig missing fields
- admin_config.json missing required fields (updated_at, paths, etc.)
- JSON parsing failed, caused panic on worker startup
- Lazy instance poisoned, all processors failed

** Fix:
1. update_processor_result now sets timestamps automatically:
   - Running -> started_at = CURRENT_TIMESTAMP
   - Completed/Failed -> completed_at = CURRENT_TIMESTAMP

2. Added #[serde(default)] to all AdminConfig fields
   - Allows partial config files
   - Missing fields get default values

** Impact:
- Processor status now accurately tracked
- Worker can start with minimal config
- UI 'Deep Scan' deadlock resolved
2026-09-18 05:00:59 +08:00
Accusys 0fe09afdb6 fix: prevent 'running' status deadlock in worker
** Problem:
- Worker set processor status to 'running' BEFORE checking capacity
- If capacity limit reached, processor was skipped but status stuck at 'running'
- Worker would skip processors with 'running' status on next poll (deadlock)

** Root Cause:
- Line 591-600: update_processor_progress(..., 'running')
- Line 1434: check capacity (TOO LATE!)
- Result: status='running' but processor never started

** Fix:
- Move capacity check BEFORE setting 'running' status
- If capacity limit reached, mark as 'skipped' immediately
- Prevents 'running' status from being set when processor won't actually run

** Impact:
- Fixes UI 'Deep Scan' deadlock issue
- Workers will no longer get stuck in infinite loop
- Processor status will accurately reflect actual state

** Files Changed:
- src/worker/job_worker.rs: Moved capacity check to line 591-592
- Removed duplicate capacity check at line 1464-1493
2026-09-18 03:53:39 +08:00
Accusys 31d1b4050f fix: correct face detection threshold defaults
- Changed min_confidence from 50.0 to 0.5 (Vision uses 0.0-1.0 range)
- Changed min_size from 32 to 1 (was filtering out all small faces)
- Changed min_capture_quality from 25.0 to 0.25
- Fixes issue where all videos showed 0 faces detected

Root cause: admin_config.rs used wrong defaults (50.0/32) instead of
config.rs constants (0.5/1), causing Vision framework to filter out
ALL faces because confidence threshold exceeded valid range.

Verified: IMG_9449 now correctly detects 191 faces (was 0).
2026-09-18 02:42:21 +08:00
Accusys e4b8ddab94 fix: People Search 移除 VLM 文本搜索,只搜索 name 字段
- 移除 search_persons_internal 和 search_people_by_query 中的 VLM 文本搜索
- 避免匹配 'watermark', 'landmark', 'market' 等 VLM 描述文本
- People Search 現在只搜索 tp.name(人物名字)
- VLM 相關搜索應使用 Semantic Search API
2026-09-18 01:08:36 +08:00
Accusys c34b7b9ea0 feat: add force parameter to re-scan API for proper output file cleanup
Problem: Re-scan (/api/v1/file/:file_uuid/process) only deleted processor_results from DB,
but not output files. Worker checks if output file exists and skips re-processing,
resulting in stale/incorrect results persisting.

Solution:
- Add 'force' parameter to ProcessRequest struct (default: false)
- When force=true, delete all output files before re-processing
- Worker will then re-run processors from scratch

Changes:
- src/api/processing.rs:
  - Added 'force: bool' to ProcessRequest
  - Added delete_output_files_for_uuid() helper function
  - Modified trigger_processing() to delete output files when force=true

API usage:
POST /api/v1/file/:file_uuid/process
{
  "processors": ["face","ocr",...],
  "force": true
}

Note: Build currently fails due to unrelated uncommitted admin_config changes.
Those should be fixed separately.
2026-09-17 22:34:44 +08:00
Accusys 474a5bee99 refactor: remove YOLO processor and dependencies
- Delete YOLO processor implementation (src/core/processor/yolo.rs)
- Remove YOLO from processing pipeline and worker
- Clean up YOLO-related code across multiple modules
- Add migration 033_remove_yolo.sql

YOLO functionality removed as part of architecture simplification
2026-09-17 16:56:25 +08:00
Accusys 791c782606 fix: search_bm25 NUMERIC→f64 decode panic + rerank UTF-8 truncation
- postgres_db.rs: CAST source_weight to ::float8 (NUMERIC→FLOAT8)
- rerank.rs: char-based truncation for UTF-8 safety
- Both fixes prevent tokio worker panics that killed search requests

Bug root causes:
- keyword/BM25: sqlx decode f64 from NUMERIC panicked at postgres_db.rs:3758
- llm-smart: &text[..100] byte slice panicked at rerank.rs:52 on Chinese text

Verified: both /api/v1/search/keyword and /api/v1/search/llm-smart now return 200
2026-09-17 16:55:48 +08:00
Accusys e25c279eeb feat: port face clustering to Rust (rust_face_cluster) with A/B gating
- rust_face_cluster: seed-leader + agglomerative clustering port of
  fast_face_clustering_processor.py (Qdrant _faces scroll, trace aggregation,
  auto speaker bind, strict 2dp rounding parity)
- A/B verified vs Python on same Qdrant snapshot: both methods match on
  cluster membership/trace_id/confidence (leader + agglomerative)
- face_clustering.rs: USE_RUST_PROCESSORS switch with Python fallback
- executor.rs: run_rust_with_output_idx_and_frames (+ QDRANT env passthrough)
- appearance/pose: re-use rust runner path (previous migration)
- verify_face_cluster.py / verify_pose.py / verify_appearance.py: A/B harness
2026-09-16 21:50:07 +08:00