Commit Graph

407 Commits

Author SHA1 Message Date
Accusys d7df19e243 fix: remove cancelled 'pose' from required processors (A-8)
- Remove pose.json from required processor list in sync_file_status
- Pose was cancelled in the original plan, but still listed as required
- This caused status to stay in 'scanning' forever when pose.json is missing

Issue: 020.mp4 permanently showed 'Scanning' because pose.json was never generated
Root cause: all_consistent would never be true with missing pose.json
Solution: Remove pose from the required list

Verification: cargo check --lib passes

Next step: Implement configuration-driven processor list (A-8 requirement 2)

References:
- M4ProMini 020.mp4 diagnosis (appendix C)
- files.rs:1805-1813
- A-8 in Momentry_Release_Requirements_20261004.md v1.1
2026-10-04 14:32:03 +08:00
Accusys 1ec094571f docs: A-7 decision - re-scan as canonical API with auto_pipeline opt-in
- Decision: POST /api/v1/re-scan is canonical API
- Important: auto_pipeline=false by default (customer requirement)
- Provides manual control and safety over processing pipeline
- Includes workflow examples and Studio Team recommendations

Addresses: A-7 from Momentry_Release_Requirements_20261004.md
2026-10-04 13:51:50 +08:00
Accusys a3c3ed8dc1 refactor: eliminate all CARGO_MANIFEST_DIR compile-time dependencies (A-4)
- Add src/core/path_utils.rs with runtime path resolution helpers
- Replace all env!("CARGO_MANIFEST_DIR") with runtime resolution
- Priority: env var -> current_exe sibling -> dev fallback

Changes:
- executor.rs: scripts_dir(), cli_dir() (4 locations)
- face.rs: swift_processor_path()
- tool_selector.rs: swift_binary_path()
- thumbnail/mod.rs: script_path()

Issue: CARGO_MANIFEST_DIR expands to build machine path at compile time,
       breaking on binary-only release hosts.

Solution: Resolve paths at runtime in this order:
1. Explicit environment variable (MOMENTRY_SCRIPTS_DIR, MOMENTRY_CLI_DIR)
2. Sibling of current_exe (same directory as running binary)
3. Relative path fallback (dev machine)

Verified: cargo check --lib passes
2026-10-04 13:44:40 +08:00
Accusys f79292f867 fix: resolve rust_register/unregister at runtime for binary-only hosts
- Replace CARGO_MANIFEST_DIR compile-time constant with runtime resolution
- Priority: MOMENTRY_RUST_* env -> current_exe sibling -> target/release fallback
- Fixes sync-mode register/unregister on release machines (A-1)

Issue: env!("CARGO_MANIFEST_DIR") expands to build machine path at compile time,
       which doesn't exist on binary-only release hosts.

Solution: Resolve binary paths at runtime in this order:
1. MOMENTRY_RUST_REGISTER / MOMENTRY_RUST_UNREGISTER env (explicit override)
2. Sibling of current_exe (same directory as running momentry binary)
3. target/release fallback (dev machine)

Verified: M4ProMini deployment (2026-10-04)
2026-10-04 13:40:46 +08:00
Accusys 097b3721e8 fix: add face_cluster to auto-pipeline processors
The hardcoded processors array in create_monitor_job was missing
'face_cluster', causing jobs to never run face clustering and thus
never complete ingestion (face_cluster.json never created).

Successful jobs (e.g. 1250) have face_cluster in processors, but
newly created jobs (e.g. 1251) were missing it due to this hardcoded
array being incomplete.
2026-10-02 18:08:53 +08:00
Accusys ba71daf2c4 fix: store face embeddings to Qdrant in config-driven path
Config-driven swift/python branches in run_face_with_config were
saving face.json but not storing embeddings to Qdrant. This caused
TKG spawn to wait indefinitely for Qdrant face points that never
arrived, blocking ingestion completion.

The fallback hardcoded path had store_face_embeddings_to_qdrant
call, but config-driven path returned early without it.

Fix: call store_face_embeddings_to_qdrant after save_to_file in
both swift and python config-driven branches.
2026-10-02 17:23:44 +08:00
Accusys 65898ef71b fix: save face.json with computed status/total_faces
compute_status() updates FaceResult in memory but didn't write back
to the file. Ingestion gate checks face.json directly, so it still
saw status=null and skipped TKG/face_cluster/Qdrant.

Now calls save_to_file() after compute_status() in swift/python
config-driven branches, matching the 'existing file' path behavior.
2026-10-02 16:58:17 +08:00
Accusys e1f13f485f fix: recompute FaceResult status/total_faces after config-driven parse
The config-driven swift/python branches in run_face_with_config parsed
face.json into FaceResult without calling compute_status(). swift_face
outputs frames[].faces but no top-level 'status'/'total_faces' fields,
so the resulting FaceResult always reported 0 total faces and status=None
even when the file contained faces (e.g. 212 faces in 020.mp4).

This broke the whole downstream pipeline for any file processed via the
config-driven swift path:
- worker logged 'FACE completed, status=, 162 frames, 0 total faces'
- has_faces=false in P4 TKG trigger (face.json status mismatch)
- face_cluster / qdrant_face ingestion gates never satisfied
- job stuck in 'waiting for ingestion' forever

Fix: call compute_status() after parsing in both swift and python
config-driven branches, matching the existing face.json / mediapipe paths.

Adds test_compute_status_recalculates_total_faces to lock the behavior.
2026-10-02 15:28:01 +08:00
Accusys 162ece34f7 revert: disable Pose processor (was cancelled decision)
Pose was previously decided to be removed (ProcessorType::all()
already excludes it: 'Disabled in production pipeline'). However,
create_monitor_job's default processors array still contained 'pose',
job_worker's auto-pipeline status init still listed pose/appearance,
and processor_tools_v3.json had pose implementations enabled.

This reverts the pose portions of 8c6a2de8 (pose.rs placeholder
expansion and config --output args change) and fully disables Pose:

- config/processor_tools_v3.json: pose swift/mediapipe enabled=false,
  restore original --output args for swift
- src/core/db/postgres_db.rs: create_monitor_job default processors
  no longer includes 'pose'
- src/worker/job_worker.rs: auto-pipeline status init no longer lists
  pose/appearance
- src/core/processor/pose.rs: revert placeholder expansion (unchanged
  from pre-8c6a2de8)

Face config-driven fix (positional args + placeholder expansion) is kept.
2026-10-02 15:04:48 +08:00
Accusys 8c6a2de820 fix: use positional args for swift face/pose config-driven execution
The swift_face/swift_pose CLIs take positional <input> <output> paths,
but processor_tools_v3.json passed an unsupported --output flag, so the
config-driven path always failed (exit 64, 'Unknown option --output')
and fell back to hard-coded logic for every face/pose run.

- config/processor_tools_v3.json: drop --output, use positional args
- face.rs/pose.rs: expand {video_path}/{output_path}/{file_uuid}
  placeholders in config args before executing

Verified: positional args exit 0 and produce face.json; old args exit 64.
2026-10-02 14:25:44 +08:00
Accusys 9e1fa0a3ff fix: ASRX null frame tolerance and FaceCluster unblocking
- AsrxSegment.start_frame/end_frame -> Option<u64> so the ASR fallback
  (which emits null frames) deserializes instead of erroring
- P2 face-trace trigger gated on has_face alone (not has_asrx), so
  no-face videos still get face_traced.json via the fast-path,
  unblocking FaceCluster and preventing the job from failing
2026-10-02 13:50:49 +08:00
Accusys e0d04e242f feat: face clustering pipeline improvements and Rust/Swift face processing
- Add Rust face processor module (detection, embedding, tracking, qdrant)
- Add Facenet CoreML/ONNX conversion scripts and tests
- Refactor swift_face into Sources/swift_face with ArgumentParser support
- Update store_traced_faces to handle face.json correctly
- Fix ASRX parsing and TKG bbox reading from Qdrant
- Improve admin_config and trace_agent APIs
- Add M4 workspace docs for face clustering, dedup, and Facenet validation
- Fix worker heartbeat TTL (poll_interval x 3, min 60s) for offline detection
2026-10-02 12:24:55 +08:00
Accusys e987fb8119 fix: TKG bbox reading from Qdrant payload
問題:
- TKG 從 Qdrant 讀取 bbox 時,期望 payload['bbox']['x']
- 但實際 Qdrant payload 結構是 payload['x']
- 導致所有 bbox 值為 0.0
- trace_profile.json 的 best_bbox 和 avg_bbox 為 null
- key_face.jpg 無法生成

修復:
- parse_face_points: 直接從 payload 讀取 x, y, width, height
- get_representative_frame: 同樣修復

影響:
- 修復後,TKG 能正確讀取 bbox
- best_bbox 和 avg_bbox 將有正確數據
- key_face.jpg 能正常生成
- PeopleView 頁面能正常顯示人臉縮略圖

參考:
- 修復請求文檔:/Users/accusys/momentry_studio/docs/TKG_BBOX_WRITE_FIX_REQUEST.md
- 問題診斷:Qdrant payload 結構不匹配

感謝 Studio Team 的詳細問題報告!
2026-10-01 02:45:44 +08:00
Accusys 8c7a5efd49 fix: generate unique face_id when storing to Qdrant
問題:
- Face detection 階段未生成 face_id
- 存儲到 Qdrant 時轉換為空字符串
- 導致 API 無法正確查詢 trace 數據

修復:
- 在存儲到 Qdrant 時,如果 face_id 為空,生成唯一 ID
- 格式: face_{frame}_{idx}
- 例如: face_0_0, face_0_1, face_100_0

影響:
- 只影響新處理的文件
- 舊文件需要重新處理才能修正

相關問題:
- Trace API 404 Not Found
- Qdrant payload face_id 為空字符串
2026-10-01 00:16:39 +08:00
Accusys 4b694a1c2d remove: Portal project (Core Team 不再維護前端)
- 移除 portal/ 目錄 (Vue 3 + Tauri 前端)
- 更新 AGENTS.md 移除 Portal 相關說明
- 更新代碼註釋移除 Portal 引用
- 前端開發統一由 Studio Team 負責

參考: docs_v1.0/OPERATIONS/GUI_ARCHITECTURE_REVIEW.md
2026-09-30 18:59:40 +08:00
Accusys 6525a3fe94 feat: update API status to 'queued' immediately on Deep Scan
問題:
- 用戶點擊 Deep Scan 後,狀態顯示 'processing'
- 但實際上文件可能在排隊等待
- 用戶看不到 'Queued' 狀態

修復:
- API 觸發時立即更新狀態為 'queued'
- Worker 開始處理時更新為 'scanning'
- 用戶可以看到文件在隊列中等待

更改:
- phase: 'PROCESSING' → 'QUEUED'
- status: 'processing' → 'queued'

流程:
1. 用戶點擊 Deep Scan → status = 'queued' ✅
2. Worker 開始處理 → status = 'scanning' ✅
3. UI 顯示 'Queued' 或 'Waiting' 狀態

影響:
- 用戶體驗改善
- 狀態更清晰
- 可以看到隊列位置

相關:
- VideoStatus enum 已有 Queued 狀態
- Worker 已支持 Scanning 狀態
2026-09-29 10:10:29 +08:00
Accusys 676171cd64 fix: update checkin_api to use Completed status
修復:
- checkin: 使用 Completed 而不是 Indexed
- checkout: 使用 Completed 而不是 CheckedOut

原因:
- 已簡化狀態為 Scanning 和 Completed
- 移除了 Indexed 和 CheckedOut 狀態
2026-09-29 02:14:21 +08:00
Accusys 8eca08c7c9 refactor: simplify status to scanning and completed only
變更:
- ✅ 移除 Processing 狀態
- ✅ 移除 Waiting 狀態
- ✅ 移除 Indexed 狀態
- ✅ 移除其他中間狀態
- ✅ 只保留 Scanning 和 Completed

VideoStatus 枚舉:
- Unregistered
- Registered
- Pending
- Queued
- Scanning (處理中)
- Completed (完成)
- Failed (失敗)

狀態流程:
Scanning → Completed

簡化原因:
- 中間狀態太多導致用戶困惑
- Scanning 和 Completed 足夠表示處理狀態
- 其他狀態(Pending, Queued, Failed)仍保留

狀態: ✅ 已實施
2026-09-29 02:11:30 +08:00
Accusys aa4e50f4dc feat: add Waiting status for long-running operations
問題:
- 處理過程中有長時間等待
- 用戶不知道為什麼卡住
- 無法區分「處理中」和「等待中」

修復:
- ✅ 添加 VideoStatus::Waiting 狀態
- ✅ 修復重複的 match arms
- ✅ TKG verification 前設為 Waiting
- ✅ Ingestion 前設為 Waiting

狀態流程:
- Scanning → Processing → Waiting → Indexed → Completed

用戶體驗:
- 等待 TKG 時顯示 'waiting'
- 等待 ingestion 時顯示 'waiting'
- 更清晰的狀態區分

狀態: ✅ 已實施
2026-09-29 01:35:19 +08:00
Accusys ef94fac8fa feat: add intermediate status updates during processing
問題:
- Worker 只在開始時更新 status 為 scanning
- 只在完成時更新為 completed 或 failed
- 中間沒有狀態更新
- 用戶無法知道當前在哪個步驟

修復:
- ✅ Processing: 處理器開始運行時
- ✅ Indexed: Rule 1 完成時
- ✅ Completed: 全部完成時(已存在)

影響:
- 用戶可以看到處理進度
- 更好的狀態透明度
- 問題排查更容易

文檔:
- docs_v1.0/M4_workspace/2026-09-28_status_update_proposal.md

狀態: ✅ 已實施基本狀態更新
2026-09-29 01:21:22 +08:00
Accusys c3b40e6f27 fix: worker reads vlm_output_language from admin_config
修復:
- Worker 啟動時讀取 admin_config.search.vlm_output_language
- 設置 preferred_language
- Scene VLM 將使用該語言生成本地化描述

測試:
- 重啟 Server 和 Worker
- 等待處理新文件
- 檢查日誌中的 preferred language 設置

狀態: ✅ 已修復
2026-09-28 23:40:27 +08:00
Accusys 585fd8728a fix: VLM output language configuration
問題:
- admin_config.json 的 vlm_output_language 被忽略
- Worker 使用默認語言 (zh-TW)
- VLM 輸出語言無法設置

修復:
- ✅ SearchConfig 添加 vlm_output_language 字段
- ✅ Worker 讀取 admin_config 並設置語言
- ✅ Scene VLM 使用 preferred_language

配置優先級:
1. admin_config.json (最高)
2. MOMENTRY_PREFERRED_LANGUAGE 環境變數
3. 默認值 zh-TW

支持語言:
- ja (日文)
- en (英文)
- zh-TW (繁體中文,默認)
- zh-CN (簡體中文)
- ko (韓文)

文檔:
- docs_v1.0/M4_workspace/2026-09-28_vlm_output_language_fix.md

狀態: ✅ 已修復
2026-09-28 23:23:12 +08:00
Accusys 5f9ddd2d02 fix: change async_mode default to false for register API
問題:
- Library 卡片 register 不成功
- 前端未傳遞 async_mode 參數
- API 默認異步模式,返回警告
- file_uuid 為空,前端無法使用

根本原因:
1. 前端調用 API 時未指定 async_mode
2. API 默認 async_mode=true (異步)
3. 異步模式返回空 file_uuid
4. Worker health key 未更新,顯示警告

解決方案:
- 修改 async_mode 默認值從 true 改為 false
- 前端現在默認使用同步模式
- 立即返回完整信息(file_uuid, duration, etc.)

測試結果:
- ✅ 同步模式 (默認): 立即返回 UUID 和元數據
- ✅ 異步模式 (明確指定): 正常排隊處理

影響:
- Studio (LibraryView): 現使用同步模式
- Portal (client.ts): 現使用同步模式

優勢:
- ✅ 快速響應 (~1秒)
- ✅ 完整信息返回
- ✅ 無警告
- ✅ 開發測試友好

注意:
- ⚠️ 行為變更: 默認從異步改為同步
- ⚠️ 生產環境建議明確指定 async_mode=true

待解決:
- Worker health key 更新問題

文檔:
- docs_v1.0/M4_workspace/2026-09-28_register_issue_analysis.md

狀態: ✅ 已修復
2026-09-28 20:20:41 +08:00
Accusys efd6f4372e feat: integrate rust_register and rust_unregister into API
新增功能:
- API 支持 sync/async 模式切換
- 同步模式直接調用 rust_register / rust_unregister
- 異步模式通過 Worker 執行

修改:
1. UnregisterRequest 添加 async_mode 參數
2. RegisterFileRequest 添加 async_mode 參數
3. unregister() 函數支持雙模式
4. register_file() 函數支持雙模式

API 使用:
```bash
# 同步模式
POST /api/v1/unregister
{"file_uuid": "...", "async_mode": false}

POST /api/v1/files/register
{"file_path": "...", "async_mode": false}

# 異步模式
POST /api/v1/unregister
{"file_uuid": "...", "async_mode": true}

POST /api/v1/files/register
{"file_path": "...", "async_mode": true}
```

測試結果:
- ✅ Unregister 同步模式: 通過
- ✅ Unregister 異步模式: 通過
- ✅ Register 同步模式: 通過
- ✅ Register 異步模式: 通過

性能:
- 同步 Register: ~1s
- 同步 Unregister: ~2s
- 異步模式: 立即返回

優勢:
- 開發測試: 同步模式快速反饋
- 生產環境: 異步模式不阻塞

文檔:
- docs_v1.0/M4_workspace/2026-09-28_api_rust_integration_test.md

狀態: ✅ 測試通過,生產就緒
2026-09-28 19:41:40 +08:00
Accusys 6bac60bcf8 feat: add rust_register CLI tool
新增功能:
- 獨立的 register CLI 工具
- 不依賴 API 和 Worker
- 直接註冊視頻文件到數據庫

特性:
- ✅ 元數據提取 (ffprobe)
- ✅ Birth UUID 計算
- ✅ Force 模式 (覆蓋已存在)
- ✅ 詳細輸出模式
- ✅ 錯誤處理

使用方法:
```bash
# 註冊文件
rust_register /path/to/video.mp4

# 強制重新註冊
rust_register /path/to/video.mp4 --force

# 詳細輸出
rust_register /path/to/video.mp4 --verbose
```

功能:
1. 文件驗證
2. UUID 計算 (birth UUID)
3. 元數據提取 (duration, resolution, fps)
4. 數據庫插入
5. Force 模式 (自動 unregister)

元數據:
- Duration: 8.80s
- Resolution: 1920x1080
- FPS: 59.94
- Total frames: 527

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

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

測試:
- ✅ 編譯成功
- ✅ 基本註冊測試通過
- ✅ Force 模式測試通過
- ✅ Verbose 模式測試通過

Binary:
- target/debug/rust_register
2026-09-28 19:27:43 +08:00
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