1090 Commits

Author SHA1 Message Date
Accusys 1576b27528 fix: replace hardcoded paths in processing.rs (A-4.2 P3)
Issues: 4 hardcoded output_dir paths

Solution: Use config::OUTPUT_DIR

Verification: cargo check --lib passes

Progress: admin_config.rs ✅, files.rs ✅, watcher.rs ✅, processing.rs ✅
2026-10-04 16:31:26 +08:00
Accusys c55f664e47 fix: replace hardcoded paths in watcher.rs (A-4.2 P3)
Issues: 4 hardcoded fallback paths
- default_dir: /Users/accusys/momentry/var/sftpgo/data/demo
- 2× output_dir: /Users/accusys/momentry/output
- scripts_dir: /Users/accusys/momentry_core_0.1/scripts

Solution: Use config constants and relative paths
- MOMENTRY_SFTP_ROOT or relative fallback
- config::OUTPUT_DIR for output
- path_utils::scripts_dir() for scripts

Verification: cargo check --lib passes, 0 hardcoded paths

Progress: admin_config.rs ✅, files.rs ✅, watcher.rs ✅
2026-10-04 16:27:44 +08:00
Accusys 1166599f70 fix: replace all hardcoded paths in files.rs (A-4.2 P3)
Issues: 7 hardcoded fallback paths
- 5× output_dir: /Users/accusys/momentry/output
- 2× scripts_dir: /Users/accusys/momentry_core_0.1/scripts

Solution: Use config constants and path_utils
- config::OUTPUT_DIR for output paths
- path_utils::scripts_dir() for scripts paths

Changes:
- Replaced all unwrap_or_else fallbacks
- Unified path resolution

Verification: cargo check --lib passes, 0 hardcoded paths remaining

Progress: files.rs ✅, admin_config.rs ✅

Remaining: ~24 P3 locations in other files
2026-10-04 16:18:42 +08:00
Accusys b4dec14f8d fix: replace hardcoded fallback paths with relative paths (A-4.2 P3)
Issues: 4 fallback paths in admin_config.rs
- default_output_dir: /Users/accusys/momentry/output
- default_backup_dir: /Users/accusys/momentry/backup/momentry
- default_scripts_dir: /Users/accusys/momentry_core_0.1/tools/script
- default_cli_dir: /Users/accusys/momentry_core_0.1/tools/cli

Solution: Use current_exe() relative paths as fallback
- var/output, var/backup, tools/script, tools/cli
- Works on any machine without hardcoding

Changes:
- All 4 default functions now use relative paths
- Falls back to current_exe() sibling directories

Verification: cargo check --lib passes

Remaining: ~31 P3 locations in other files

References:
- A-4.2 P3 in Momentry_Release_Requirements_20261004.md v1.1
- G-3 gate condition
2026-10-04 16:17:18 +08:00
Accusys e0eb7b9ce8 fix: resolve P2 hardcoded paths to use runtime resolution (A-4.2 P2)
Issues: Direct hardcoded paths without fallback
- proxy.rs:108 - audio_track_probe.py
- tool_selector.rs:136 - output_dir
- ocr.rs:241 - swift_ocr binary
- files.rs:1190 - legacy output dirs

Impact: These paths don't exist on release machines

Solution:
1. proxy.rs: Use path_utils::scripts_dir()
2. tool_selector.rs: Use config::OUTPUT_DIR
3. ocr.rs: Use swift_processor_path() helper
4. face.rs: Make swift_processor_path() public
5. files.rs: Reduce duplicate legacy paths

Changes:
- src/core/proxy.rs: Resolve audio_track_probe.py
- src/core/processor/tool_selector.rs: Use OUTPUT_DIR from config
- src/core/processor/ocr.rs: Use swift_processor_path()
- src/core/processor/face.rs: Export swift_processor_path()
- src/api/files.rs: Deduplicate legacy paths

Verification: cargo check --lib passes

Remaining: P3 (unwrap_or_else type, ~89 locations)

References:
- A-4.2 P2 in Momentry_Release_Requirements_20261004.md v1.1
- G-3 gate condition
2026-10-04 16:06:41 +08:00
Accusys 2f5e2c1314 fix: resolve all P1 hardcoded model paths at runtime (A-4.2 P1)
Issues: 6 P1 locations with hardcoded model paths
- asr.rs:81 - whisper model
- scene_classification.rs:68 - resnet18 model
- qwen_vl_manager.rs:25,26 - Qwen model + mmproj
- rust_vad.rs:18 - silero_vad model
- facenet_embedding.swift:24 - already fixed (A-11)

Impact: Missing models cause silent degradation (A-12)
        No embeddings → TKG 0 nodes (020.mp4 root cause)

Solution: Use path_utils::resolve_asset_path for all model paths
- Resolves via MOMENTRY_MODELS_DIR env var
- Falls back to current_exe sibling
- Final fallback to models/ directory

Changes:
1. asr.rs: Resolve whisper model dir
2. scene_classification.rs: Resolve resnet18 model path
3. qwen_vl_manager.rs: Resolve Qwen model + mmproj paths
4. rust_vad.rs: Resolve silero_vad model via env or relative

Benefits:
- All P1 models now configurable via MOMENTRY_MODELS_DIR
- No more silent failures when models missing
- Models can be placed in release bundle

Verification:
- cargo check --lib passes
- cargo build --release --bin rust_vad passes

Next steps: Address P2 (41 locations) and P3 (35 locations)

References:
- A-4.2 P1 in Momentry_Release_Requirements_20261004.md v1.1
- A-11, A-12
- G-3 gate condition
2026-10-04 15:59:56 +08:00
Accusys 0d11c60163 fix: allow pipeline to complete with 0 results (A-10)
Issue: Pipeline stages never complete when result count = 0
Files: src/api/scan.rs (5 locations)

Root causes:
- L1357: tkg_nodes only marked complete if count > 0
- L1373: rule2_ingestion only if relationship_count > 0
- L1384:补救分支仍要求 tkg_node_count > 0
- L1412: vlm_summary only updated if vlm_total > 0
- L1432: face_dedup only checked if tkg_node_count > 0

Impact: When TKG has 0 nodes, 4 stages (weight 0.25) stay pending forever
        overall_progress stuck at 0.75

Solution:
1. TKG stages (nodes/edges/rule2): Always mark completed with count
2. VLM summary: Mark completed with "no traces" if vlm_total = 0
3. Face dedup: Check whenever processors_done, not just if nodes > 0
4. Add "no faces" / "no relationships" reasons for 0-result cases

Benefits:
- Distinguishes "completed with 0 results" from "not started"
- overall_progress can now reach 1.0 for all files
- Fixes G-2 gate condition

Verification: cargo check --lib passes

References:
- A-10 in Momentry_Release_Requirements_20261004.md v1.1
- G-2 in M5Max128_Portability_Install_Test_20261004.md
- 020.mp4 diagnosis: overall_progress stuck at 0.75
2026-10-04 15:56:14 +08:00
Accusys ad30742374 fix: integrate phase_completed into status logic (A-9)
Issue: phase_completed was calculated but never used
File: src/api/files.rs:1982

Root cause:
- phase_completed = (phase == "COMPLETED")
- But new_status only checked all_consistent and any_json_exists
- This caused inconsistency between DB phase and reported status

Solution:
- Add phase_completed as highest priority condition
- If phase is COMPLETED and any_json_exists → status = completed
- This ensures DB phase is respected when available

Logic:
1. phase_completed + any_json_exists → completed (trust DB)
2. all_consistent + any_json_exists → completed (all JSONs ready)
3. any_json_exists → scanning (in progress)
4. no JSONs → registered (not started)

Benefits:
- Fixes G-1 gate condition
- Resolves potential inconsistency between phase and status
- Matches original design intent

Verification: cargo check --lib passes

References:
- A-9 in Momentry_Release_Requirements_20261004.md v1.1
- G-1 in M5Max128_Portability_Install_Test_20261004.md
2026-10-04 15:55:04 +08:00
Accusys 1ca3eb1abe docs: add A-7 decision document to version control
- 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

Note: This document was created during the session but not yet committed.
Commit 1ec09457 only included the code changes.
2026-10-04 15:10:17 +08:00
Accusys 3399a137d8 fix: resolve FaceNet model path at runtime (A-4.2 P1, A-11, A-12)
Issues:
- facenet_embedding.swift:28 hardcoded model path
- face.rs:227-231 did not pass model path parameter
- face.rs:249-255 only logged warnings, causing silent degradation
- M4ProMini missing facenet512.mlpackage → embeddings all None → TKG 0 nodes

Changes:
1. facenet_embedding.swift:
   - Add --model option (default: models/facenet512.mlpackage)
   - Validate model file exists before loading
   - Print clear error message if missing

2. face.rs:
   - Use path_utils::resolve_asset_path for models dir
   - Pass --model argument to facenet_embedding
   - Validate model exists before running
   - Elevate errors from warn! to error! + bail!
   - Fail fast on embedding generation failure

Benefits:
- Runtime resolution via MOMENTRY_MODELS_DIR
- No silent degradation - missing model causes explicit error
- Clear error messages guide users to fix

Verification:
- cargo check --lib passes
- swift build -c release passes

Next steps:
- Add facenet512.mlpackage to release delivery (A-11 requirement 3)
- Update smoketest to verify embeddings != None (A-5.3)

References:
- A-4.2 P1 in Momentry_Release_Requirements_20261004.md v1.1
- A-11, A-12
- 020.mp4 diagnosis (appendix C)
2026-10-04 14:37:49 +08:00
Accusys b331a3d0cd docs: A-8 design - configuration-driven processor list
- Analyze three approaches: database table, config file, environment variable
- Recommend: Phase 1 (config file) → Phase 2 (database table)
- Provide implementation plan and acceptance criteria

References:
- A-8 in Momentry_Release_Requirements_20261004.md v1.1
- Quick fix (remove pose): commit d7df19e2
2026-10-04 14:32:49 +08:00
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 3d363e6266 feat: add release build scripts and manifest (A-2, A-3)
- scripts/build_release.sh: Build 3 binaries + generate manifest
- scripts/sign_binaries.sh: Ad-hoc sign binaries for macOS
- RELEASE_MANIFEST.txt: Record binary sizes, MD5, SHA256

Solves:
- A-2: Release build now includes momentry, rust_register, rust_unregister
- A-3: Binaries are signed to avoid SIGKILL on release machines

Verified: M4ProMini deployment (2026-10-04)
2026-10-04 13:42:17 +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 15fc356666 fix: handle metadata=None in face_tracker.py
Two places assumed metadata dict exists but didn't handle None value:
1. L455: dict.get('metadata', {}) returns None if key exists with None value
2. L467: 'metadata not in face_data' doesn't catch metadata=None

Fixes:
- Use 'or {}' pattern to handle None: (face_data.get('metadata') or {}).get(...)
- Use 'if not face_data.get("metadata")' to catch both missing and None
2026-10-02 17:10:25 +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 193af91cd7 docs: switch production 3002 management to launchd (release binary)
- com.momentry.server + com.momentry.worker manage target/release/momentry
- mark run-server-3002.sh as dev/emergency only (conflicts with launchd)
- AGENTS.md: update startup/log tables, add launchd worker bootstrap note
2026-10-02 12:47:55 +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 323fd342f1 fix: ASRX and FS VLM Summary configuration
1. FS VLM Summary: max_tokens 300 -> 900
   - Gemma4 思考模式需要更多 tokens 才能完成
   - 修復 VLM 調用失敗問題

2. ASRX: 禁用 Swift,啟用 Python
   - Swift ASRX 10 秒超時導致所有 segments=0
   - Python ASRX 使用 Whisper,更穩定
   - 優先級從 2 提升到 0

問題診斷:
- ASRX: 所有 10 個文件 segments=0
- 原因: RunLoop.current.run(until: Date(timeIntervalSinceNow: 10))
- VLM: max_tokens 太小導致 Gemma4 思考截斷

參考: AGENTS.md - Gemma4 思考模式特性
2026-09-30 21:42:35 +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 144ec0768a docs: face data loss complete diagnosis
問題:
- UI 卡片 face icon 消失
- Library 顯示沒有 faces

診斷結果:
- Qdrant 中只剩 212 個無效 faces
- 所有現有 face.json 都是 bbox=0x0 (無效)
- 無法從現有文件恢復

根本原因:
- Swift Face processor 輸出了大量無效 bbox
- 之前清理 78,002 個無效 faces 是正確的
- 但現有文件都需要重新處理

解決方案:
- 唯一方案: 批量重新處理所有文件
- 使用修復後的 Swift Face processor
- 預估時間: 4-8 小時 (110 文件)

建議:
- 優先處理關鍵文件(用戶查看最多的)
- 制定批量處理計劃
- 安排處理時間

狀態: 🚨 Critical - 需要批量重新處理

文檔:
- docs_v1.0/M4_workspace/2026-09-29_face_data_loss_diagnosis.md
2026-09-29 10:18:17 +08:00
Accusys 91c4cf9dde docs: session summary - pipeline blocking fixes
已完成:
✅ 诊断 020.mp4 卡在 95% - Qdrant 无效 faces
✅ 诊断 016.mp4 延迟 17 分钟 - Job 阻塞
✅ 提升 max_concurrent 从 2 到 6
✅ 修复 API 状态更新 - processing → queued

效果:
- 并行处理能力提升 3 倍
- 状态更新更及时
- 用户体验改善

待修复:
- 清理 Qdrant 无效 faces
- 测试 queued 状态
- 修复 ingestion 卡住

状态: ✅ 主要问题已修复,等待测试验证

文档:
- docs_v1.0/M4_workspace/2026-09-29_session_summary.md
2026-09-29 10:10:52 +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 8ce531e12a docs: Worker max_concurrent fix completed
修復:
- ✅ 更新 run-server-3002.sh,添加 CLI 參數
- ✅ max_concurrent 從 2 提升到 6
- ✅ Worker 日誌驗證: Dynamic concurrency: 6 (config: 6)

影響:
- 多個文件可並行處理
- 減少阻塞風險
- 狀態更新更及時

建議:
- 立即測試新文件註冊
- 觀察並行處理效果

狀態: ✅ 修復完成

文檔:
- docs_v1.0/M4_workspace/2026-09-29_max_concurrent_fix.md
2026-09-29 09:48:56 +08:00
Accusys dd09065daa fix: update run-server-3002.sh with correct Worker CLI parameters
問題:
- Worker 使用默認值 max_concurrent=2
- 導致文件被阻塞 17 分 50 秒

修復:
- 添加 CLI 參數 --max-concurrent 6
- 添加 --poll-interval 5
- 添加 --batch-size 10

驗證:
- Worker 日誌顯示: Dynamic concurrency: 6 (config: 6) ✅
- 並發限制從 2 提升到 6

影響:
- 多個文件可並行處理
- 減少阻塞問題

文檔:
- docs_v1.0/M4_workspace/2026-09-29_dynamic_concurrency_issue.md
2026-09-29 09:48:56 +08:00
Accusys c419c07042 docs: dynamic concurrency issue causing worker blocking
問題:
- 用戶點擊 Deep Scan 後延遲 17 分 50 秒
- Job 998 卡在 'waiting for ingestion' 12 分鐘
- Dynamic concurrency 限制在 2,阻塞新文件

根本原因:
1. Job 998 ingestion 卡住
2. max_concurrent=2 太低
3. Dynamic concurrency 自動降低到 2

影響:
- 新文件無法及時處理
- Worker 被阻塞

解決方案:
A. 調整 Dynamic concurrency 閾值
B. 禁用 Dynamic concurrency
C. 優化 ingestion 邏輯

狀態: ⚠️ Dynamic Concurrency 限制導致阻塞

文檔:
- docs_v1.0/M4_workspace/2026-09-29_dynamic_concurrency_issue.md
2026-09-29 09:43:09 +08:00
Accusys acc8381ca5 docs: 020.mp4 processing issue root cause identified
問題診斷:
- 文件狀態: registered (已註冊)
- Job ID: None (無 job) ❌
- 處理器未運行,face.json 缺失 ❌

根本原因:
1. 文件已註冊但無 job → 需調用 API 觸發
2. 處理器未運行 → Worker 誤判或跳過

已嘗試:
- ✅ API 觸發成功: POST /api/v1/file/{file_uuid}/process
- ✅ Worker 開始處理
- ❌ face.json not found

解決方案:
A. 手動運行 Swift Face processor (推薦)
B. Unregister → Register → Deep Scan
C. 修復處理器觸發邏輯

推薦行動:
立即執行方案 A - 手動運行處理器

狀態: ⚠️ 根本原因已識別 - 需手動運行處理器或修復觸發邏輯

文檔:
- docs_v1.0/M4_workspace/2026-09-28_020_mp4_final_summary.md
2026-09-29 04:19:33 +08:00
Accusys 92034e3147 docs: pipeline cleanup result - partial success
已完成:
- ✅ 清理 78,002 個無效 Qdrant faces
- ✅ Worker 不再無限循環
- ✅ 系統恢復可處理狀態

問題:
- ⚠️ 處理器未實際運行
- ⚠️ face.json 不存在
- ⚠️ store_traced_faces.py 失敗

可能原因:
- AUTO-REPAIR 機制誤判
- 處理器跳過邏輯問題
- 處理器輸出驗證缺失

建議:
A. 手動運行處理器
B. Unregister -> Register -> Deep Scan
C. 修復處理器觸發邏輯

狀態: ⚠️ 部分成功 - Worker 恢復,但處理器觸發問題待解決

文檔:
- docs_v1.0/M4_workspace/2026-09-28_pipeline_cleanup_result.md
2026-09-29 04:07:43 +08:00
Accusys 10c238bbd9 critical: 30 files with 79,495 invalid faces discovered
問題:
- 30 個文件有無效 bbox (0x0)
- 總計約 79,495 個無效 faces
- Worker 完全阻塞,無法處理新文件

問題文件:
- a0ae64af...: 64,830 個無效 faces
- b0197686...: 2,366 個無效 faces
- 23412db5...: 2,261 個無效 faces
- ... 還有 27 個文件

根本原因:
- Face detection 輸出無效 bbox
- 所有無效數據被保存到 Qdrant
- Worker 在處理時無限循環

影響:
- 020.mp4 無法被處理(狀態: 登録済み)
- 所有新文件都無法被處理
- 系統完全阻塞

解決方案:
A. 批量清理所有無效數據 (~79,496 faces)
B. 選擇性清理(小文件優先)
C. 修復 Worker 超時機制

建議: 方案 A + C
1. 立即清理所有無效數據
2. 修復 Worker 超時
3. 重新處理所有文件

狀態: 🚨 Critical - 需要立即決策

文檔:
- docs_v1.0/M4_workspace/2026-09-28_massive_invalid_faces.md
2026-09-29 03:52:28 +08:00
Accusys 2c274ecfdb docs: pipeline blockage root cause identified
問題確認:
- ✅ 48991f2424... 文件有 7 個無效 faces
- ❌ 所有 bbox = 0x0
- ❌ 所有 trace_id = -1
- ❌ 沒有 trace_* 目錄
- ❌ 缺少 key_face.jpg, key_frame.jpg, trace_profile.json

根本原因:
- Face detection 輸出無效 bbox (0x0)
- 直接保存到 Qdrant → trace_id = -1
- Worker TKG 驗證 → trace_count = 0
- 無限循環 (trace stability 永遠 = 0)

已修復:
- ✅ 清理 7 個無效 Qdrant faces
- ✅ Worker 已重啟

待執行:
- Re-scan 問題文件
- 修復 Worker 超時機制
- 驗證修復效果

文檔:
- docs_v1.0/M4_workspace/2026-09-28_pipeline_blockage_summary.md
2026-09-29 03:09:31 +08:00
Accusys e643649323 critical: pipeline blocked by Worker infinite loop
問題:
- 觸發 Deep Scan 後,文件沒有被處理
- 所有處理器輸出文件都缺失
- Worker 卡在其他文件的 TKG 循環

診斷:
1. ❌ 處理器全部未運行 (ASR, Face, etc.)
2. ⚠️ Worker 在 TKG 循環中 (7 faces, trace stability = 0)
3. ❌ 新文件無法被處理 (Worker 被阻塞)

根本原因:
- Worker TKG 驗證循環缺少超時退出
- trace_id = -1 或 0 導致無法滿足條件
- 無限循環阻塞所有處理

修復方案:
A. 添加超時退出機制
B. 檢查 trace_id 有效性
C. 跳過問題文件並標記 Failed

緊急修復:
- 停止 Worker 循環
- 清理有問題的文件

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

狀態: 🚨 Critical - 需要立即修復
2026-09-29 02:58:30 +08:00
Accusys fa1f50d9e0 docs: status flow confirmation
用戶確認:
- ✅ Deep scan 後狀態改為 Scanning
- ✅ Re-scan 後狀態改為 Scanning (unregister → register → deep scan)

當前實現:
- Scanning: job_worker.rs:754
- Completed: job_worker.rs:3728

狀態流程:
- Deep Scan: (初始) → Scanning → Completed
- Re-scan: Completed → Unregistered → Registered → Scanning → Completed

UI 顯示:
- スキャン中 → 完了

確認: ✅ 符合用戶需求

文檔:
- docs_v1.0/M4_workspace/2026-09-28_status_flow_confirmation.md
2026-09-29 02:33:48 +08:00
Accusys 1aee0ce7ee fix: 020.mp4 face bbox fix completed
修復過程:
1. ✅ 診斷問題: 210個faces全無效
2. ✅ 修復 Swift Face processor bbox驗證
3. ✅ 手動測試: 212個faces全有效
4. ✅ 複製有效face.json到輸出目錄

驗證結果:
- Before: 210 faces, bbox=0x0 (100%無效)
- After: 212 faces, bbox有效 (100%有效)

當前狀態:
- ✅ Face detection 已修復
- ✅ face.json 已生成 (399KB)
- ⏳ 待觸發: Face tracing, TKG, Trace profiles

下一步:
- 通過API或UI觸發Re-scan
- 或手動運行後續處理

文檔:
- docs_v1.0/M4_workspace/2026-09-28_020_mp4_fix_completed.md
2026-09-29 02:28:00 +08:00
Accusys bca93c3a5d issue: 020.mp4 face card missing
問題:
- Face page 沒有卡片顯示
- 100 個 faces 全部無效 (bbox=0x0, trace_id=-1)
- Worker 無限循環

根本原因:
- Face detection 輸出無效 bbox (與之前相同)

已修復:
- ✅ Swift Face processor bbox 驗證
- ✅ Binary 重新編譯 (Sep 29 02:22)
- ✅ 清理無效數據

待執行:
- 重新處理文件 (Re-scan)
- 驗證修復效果

文檔:
- docs_v1.0/M4_workspace/2026-09-28_020_mp4_face_card_missing.md
2026-09-29 02:23:03 +08:00
Accusys 08f574efc5 docs: status simplification final report
實施內容:
- ✅ 簡化 VideoStatus 為 Scanning 和 Completed
- ✅ 移除 Processing, Waiting, Indexed 等中間狀態
- ✅ 保留必要狀態: Unregistered, Registered, Pending, Queued, Failed

狀態流程:
Scanning → Completed

優點:
- 簡單明瞭
- 用戶不會困惑
- 維護簡單

前端需要:
- 更新狀態映射
- 移除對中間狀態的處理

文檔:
- docs_v1.0/M4_workspace/2026-09-28_status_simplification_final.md
2026-09-29 02:15:10 +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 7963cd0223 docs: scanning vs processing status clarity proposal
問題:
- Scanning 和 Processing 設置時間點太接近
- 用戶無法區分這兩個狀態
- 時間差 < 1 秒,幾乎看不到

建議方案:
A. 明確區分階段 (推薦)
   - Scanning: 初始檢查、元數據提取 (1-5秒)
   - Processing: 處理器實際運行

B. 移除 Scanning
   - 直接用 Processing 從頭到尾

C. 重命名
   - Scanning → Initializing
   - Processing → Analyzing

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

狀態: 📋 待確認
2026-09-29 01:49:58 +08:00
Accusys 50a9675513 docs: waiting status implementation report
實施內容:
- ✅ VideoStatus::Waiting 狀態
- ✅ TKG verification 前設為 Waiting
- ✅ Ingestion 前設為 Waiting
- ✅ 修復重複的 match arms
- ✅ Worker 已重啟

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

前端需要:
- 添加 'waiting' 狀態映射
- 多語言支持

文檔:
- docs_v1.0/M4_workspace/2026-09-28_waiting_status_implementation.md
2026-09-29 01:36:53 +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