Commit Graph

1048 Commits

Author SHA1 Message Date
Accusys 646d2a1361 fix(P0): face_cluster_done 雙路徑檢查 + run_processor 改用 async get_output_dir_for_file; 補 ingestion_complete output_dir
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled
2026-11-17 03:03:16 +08:00
Accusys d01e456ae5 fix(P0): per-library output dir for worker ingestion/verification (face_cluster guard, verifier, TKG, qdrant_face, ASR/ASRX); fix face_cluster serde default for empty output; fix face_cluster dependencies in pipeline_flows.json
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled
2026-11-17 02:46:57 +08:00
Accusys db790e2c89 fix: face_cluster guard checks both global OUTPUT_DIR and demo subdirectory for face_traced.json
Cross-Project Integration / integration (push) Has been cancelled
Core Test / lint-and-test (push) Has been cancelled
2026-11-17 01:29:28 +08:00
Accusys 75cbaa3302 feat: rebuild embeddings endpoint + standalone tool (API + binary), clear collection before rebuild, fix upsert_scene_embedding args
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled
2026-11-16 21:56:43 +08:00
Accusys 083d73d287 feat: real service test endpoints (proxy 7-route round-trip, core/chat/vlm/markbase/embedding), unified log paths + errorLog, pipeline tools/import/export/folder APIs, face pipeline check, dynamic concurrency tuning
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled
2026-11-16 18:16:46 +08:00
Accusys d21d1ab960 fix: Library Re-run 完整重建搜尋索引 (ASR/ASRX/OCR/Scene VLM)
- trigger_processing: force 時僅刪除指定 processor 的輸出檔與 processor_results
  (其他 processor 資料保留),並設定 rerun_rebuild Redis flag 要求重建索引
- worker: 單一 processor Re-run 時強制 Rule 1 重新 chunk + vectorize
  (清除 momentry_rule1 舊 vectors,避免 stale 搜尋結果)
- Scene VLM Re-run: job_processors 含 scene_vlm 即 dispatch,
  scene-only job 完成條件改以 scenes.json 完整度判定
- 前端 redoProcessor 傳 force=true,Scene VLM 新增 🔄 Re-run 按鈕
2026-11-10 07:59:31 +08:00
Accusys 043dbbf24a fix: swift_ocr 支援日文識別
Cross-Project Integration / integration (push) Has been cancelled
- 加入 recognitionLanguages = ["ja", "en"] 使 Apple Vision Framework
  能識別日文和中文文字
- 使用 #available(macOS 12.0, *) 確保向後相容
- 兩處 VNRecognizeTextRequest 都已修改(主循環 + recognizeText 函式)

驗證: 065.mp4 從 0 幀 → 75 幀,1559 個日文文字區塊
(松原徳洲会病院、ここで検索、吹田市、寝屋川市 等)
2026-11-09 17:16:37 +08:00
Accusys 3d7ec83ec9 fix: Qdrant collection ensure + self-healing on clean install
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled
- qdrant_db.rs: ensure_collection now uses PUT /collections/{name}
  (was POST /collections without name) and checks response status.
  Previous code silently no-op'd, so every upsert got 404 on clean
  installs with empty Qdrant.
- face.rs: store_face_embeddings_to_qdrant ensures _faces (512D)
  collection exists before upsert (fixes face→facenet→Qdrant broken
  link on fresh machines).
- pipeline/mod.rs: vectorize_chunks ensures main text collection
  (768D) before upserts.
- job_worker.rs: vectorize_chunks ensures main collection (768D)
  before upserts; also 3 additional lines of job_worker WIP fixes.

Verified: after these fixes, Qdrant collections are auto-created
on first upsert, resolving the face embedding + rule1 vectorize
failures on 203.
2026-11-09 15:55:01 +08:00
Accusys 70f5667adc fix: processor-counts resolves face_trace -> face_traced.json
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled
get_processor_counts built the filename from the queue name
(face_trace.json) while rust_store_traced_faces writes face_traced.json
(per processor_tools_v3 output_file), so the API/UI reported
face_trace has_json=false and face_traced data was unreachable for
existing files. Map face_trace -> face_traced in both
get_processor_counts and get_processor_json.

Verified: dev (201) & 203 processor-counts now report face_trace
has_json=true and /api/v1/processor-json?processor=face_trace returns 200.
2026-11-09 12:39:44 +08:00
Accusys 8ff77d7dba fix: rust_asr_asrx extracts audio into ~/momentry/temp, auto-cleans
Core Test / lint-and-test (push) Has been cancelled
Cross-Project Integration / integration (push) Has been cancelled
The extracted wav used to be written next to the source video
(<video>.wav), polluting the /library listing (002.wav, 025.wav leftovers).
- extract_audio now writes into MOMENTRY_TEMP_DIR (default ~/momentry/temp)
  with a unique per-run name (<stem>_asr_<millis>.wav) so concurrent jobs
  with the same basename cannot collide and mlx_whisper sidecar JSON is
  unique as well.
- TempAudioGuard removes the temp wav + /tmp/<stem>.json sidecar on every
  exit path (success, early bail, error).
- Verified: /library source dir stays clean, temp dir empty after run.
2026-11-09 12:15:30 +08:00
Accusys c1ede4ade8 fix: rust_asr_asrx handles MLX Whisper non-finite JSON literals
- MLX Whisper emits 'avg_logprob: NaN' / 'compression_ratio: Infinity' when a
  clip has no intelligible audio (e.g. near-silent test clips). serde_json
  strictly refuses those literals, so rust_asr_asrx failed with
  'expected value at line 1 column 151' and asrx never completed.
- Sanitize NaN / Infinity / -Infinity literals outside strings into null
  before parsing (sanitize_json_nonfinite).
- Add no-audio-track early-out. Clean up .wav byproduct after success.

Verified on dev (m5max48): 002.mp4 asrx re-scan now completes and produces
output/df6376c8....asrx.json; processor_results asrx = completed.
2026-11-09 12:02:19 +08:00
Accusys 5caecb887f fix: rebuild binary without MongoDB health check dependency
- Removed check_mongodb() from health.rs
- Health endpoint now depends only on PostgreSQL + Redis + Qdrant
- Regenerated .sqlx offline query cache (was incomplete, only 3 files)
- Binary rebuilt: target/release/momentry (47M, arm64)
- Deployed to 203 (m4promini)

Full clean-install + sample data install verified:
- clean-install.sh: ✅ (23 PASS / 0 FAIL)
- sample data: ✅ 100 videos, 899 processor_results, 100 monitor_jobs
- Health endpoint: status=ok (no MongoDB hang)
2026-11-08 23:39:53 +08:00
Accusys 4f4aa27da8 refactor: remove MongoDB from health check
- Removed check_mongodb() function from health.rs
- Health endpoint no longer requires MongoDB (status depends on PG+Redis+Qdrant only)
- ServiceHealth struct: mongodb field commented out
- Both health() and health_detailed() updated
- Removed MongoCache import

Note: Binary rebuild blocked by missing .sqlx cache files for
command/queue.rs and vlm/consumer.rs. Once build env is fixed:
  cd momentry_core && SQLX_OFFLINE=true cargo build --release
  cp target/release/momentry ../momentry/bin/momentry
2026-11-08 23:24:02 +08:00
Accusys c6cbb5d1fb feat: asrx recovery + pipeline fixes + face trace improvements
- ASR-ASRX unified processor (asr_asrx → asrx), output .asrx.json
- ffmpeg -vsync → -fps_mode (swift_ocr, swift_hand, swift_pose, frame_cache)
- ffprobe absolute path for probe
- PYTHONPATH + PATH added to executor subprocesses
- cut processor path fix (cut/cut_processor.py)
- scene_vlm fallback when blur_scores empty + ffmpeg absolute path
- rust_store_traced_faces generates key_face.jpg with --video-path
- face group representative trace picks highest best_confidence
- Studio: move FS doesn't remove from unassigned, always reload after move
- Studio: confirmMoveFaceToNewGroup simplified to just rename
- Studio: scene_vlm added to processors list
- Studio: scene_vlm shows (0) when ready but no scenes
- admin_config asr_config block added
2026-11-06 10:00:24 +08:00
Accusys e56e2892d0 docs: gitea sync section - correct repo to m4mini warren/momentry_core (110.200 host defunct) 2026-11-05 16:14:22 +08:00
Accusys be3837ff06 feat: asrx garbled text recovery - first-sentence trigger, config-driven language rotation, VLM audio rescue
- rust_asr_asrx: 3-layer recovery (auto → language rotation → VLM second
  reference via llama.cpp input_audio); rotation order loaded from
  admin_config.json asr_config block (no hard code); skips silent retry
  when asr_config absent (= current behavior)
- output adds recovery{} block (attempts/final_result/no_intelligible_speech)
- pipeline_flows: fix skip_if_exists *.asr_asrx.json -> *.asrx.json
  (actual output name; prevents redundant re-ASR on reprocess)
- design note: docs_v1.0/DESIGN/ASRX_Garbled_Text_Language_Rotation_V1.0.md
- verified on demo 004 (auto_ok, zero cost) / 020 (rotation_hit ja) /
  forced all-miss rotation (no_intelligible_speech via VLM refusal signal)
2026-11-05 16:13:55 +08:00
Accusys 0cbb024411 feat: add ASR garbled text detection and retry mechanism
- Add is_garbled() function to detect transcription errors:
  * Repetitive character detection (>40% same char)
  * Language-script mismatch detection
  * Compression ratio check for long text
- Expand COMMON_LANGUAGES fallback list: ja, en, zh, ko, th, vi, fr, de, es
- Add get_vad_settings() to disable VAD for short audio (<15s)
- Fix VAD filter causing 0 segments for short clips
- Improve language detection retry logic with garbled output check

Fixes: ASR producing garbled Sinhala text for Japanese audio
2026-11-05 04:52:32 +08:00
Accusys ada49d3491 fix: add DISTINCT ON to cluster-results handler to prevent duplicate group cards 2026-11-02 18:59:54 +08:00
Accusys eebaa11bfb fix: prevent duplicate face group cards - deduplicate tkg_nodes and DISTINCT ON in get_face_groups_handler 2026-11-02 17:30:29 +08:00
Accusys 6c85d2e871 feat: add upgrade_face_json_v2.sh and sync_face_data.sh scripts, fix SQLite path 2026-11-02 17:00:20 +08:00
Accusys f67219fe02 feat: add face_operations.rs SQLite module for face pipeline state management 2026-11-02 16:50:54 +08:00
Accusys 774ad4d820 feat: rust_store_traced_faces v2 schema - FaceTracedData with schema_version, stats, traces as Vec, TracePoint with timestamp/pose/landmarks 2026-11-02 15:52:11 +08:00
Accusys adcc5a1dc1 feat: face_tracker v2 schema - add schema_version, TraceBBox with x2/y2/center, TracePoint with pose/landmarks 2026-11-02 14:51:31 +08:00
Accusys 5d18183d82 feat: Face JSON v2 schema - add schema_version, bbox x2/y2/center, keep embeddings, update clustering 2026-11-02 14:34:02 +08:00
Accusys 2fca49b120 fix: update tkg_nodes.label when face_track node already exists
- ensure_face_track_node now UPDATEs label instead of returning early
- Fixes rename persistence - names are now stored in database
- Enables consistent names across all access points (localhost, DDNS)
2026-10-30 22:47:16 +08:00
Accusys b1bc83586f fix: fallback to MarkBase data for file_size and modified_time
- When videos table has null values, use MarkBase file info as fallback
- Ensures registered files display correct size and date
- Fixes issue where registered files showed '0B' and no date
2026-10-30 12:50:58 +08:00
Accusys d61d242f4e fix: use default SFTP root path for unregistered files
- Add fallback path when MOMENTRY_SFTP_ROOT env var is not set
- Default: /Users/accusys/momentry/var/sftpgo/data/demo
- Fixes 500 error when registering files (file_path was empty)
2026-10-30 12:26:51 +08:00
Accusys 6f97f4576f docs: 添加機器清單和 Studio API Key 修復需求
- 添加 m5max48 (192.168.110.201), m4promini (192.168.110.203), m4mini (192.168.110.210) 機器清單
- 創建 Studio API Key 修復需求文件 (register_file, unregister_file, merge_groups)
2026-10-30 09:00:56 +08:00
Accusys 70492235c7 docs: document MarkBase service management issue with launchd
- MarkBase is managed by launchd, auto-restarts after kill
- Stop API kills process but launchd restarts immediately
- Start API fails because port already in use
- Need to integrate launchctl commands into service API
- Documented problem analysis and proposed solutions
2026-10-24 15:08:58 +08:00
Accusys 7251a12469 feat: add comprehensive logging for scene VLM tags parsing
- Log VLM response content (first 500 chars)
- Log JSON extraction success/failure
- Log JSON parsing success/failure
- Log missing 'summary' field
- Log parsed objects and tags count
- Helps debug why vlm_tags may be empty in some cases
2026-10-24 13:44:42 +08:00
Accusys b6cf793e1b feat: add detailed logging for scene VLM tags generation
- Log tags count and content after generation
- Log JSON extraction and parsing status
- Log parsed objects and tags count
- Helps debug why vlm_tags may be empty in some cases
2026-10-24 12:55:51 +08:00
Accusys 78169c3bc0 docs: update service management API completion report
- Add issue found & fixed section
- Document route conflict problem and solution
- Clarify public vs protected endpoints
- Add authentication requirements for frontend
- Update version to 1.1
2026-10-24 11:55:30 +08:00
Accusys db12446a68 fix: resolve route conflict in service management API
- Remove duplicate health::health_routes() merge that was conflicting with public_health_routes
- Move service_management::router() to protected_routes for proper auth
- Service management now works correctly:
  - /api/v1/mbe/health (public) - shows VLM status
  - /api/v2/service/start (protected) - starts llama-server
  - /api/v2/service/stop (protected) - stops llama-server
2026-10-24 11:54:30 +08:00
Accusys c151b49334 feat: implement service management API for VLM control
- Add /api/v1/mbe/health endpoint for status checks
- Add /api/v2/service/start to start llama-server
- Add /api/v2/service/stop to stop llama-server
- Use TCP connection test for port detection (more reliable than lsof)
- Add ps aux fallback for PID detection
- Implement structured bilingual VLM tags
- Add VLM integration documentation for Studio team

Endpoints tested and working with Momentry Studio AdminView UI.
2026-10-24 02:37:53 +08:00
Accusys d14cd9f3de fix: clear paused state on unregister/re-scan
- Added Redis SREM to clear jobs:paused set in unregister_internal
- Ensures re-scan always starts with clean state
- Fixes issue where paused files remain paused after re-scan
2026-10-19 03:24:50 +08:00
Accusys 121610f8d9 feat: dynamic processor list from pipeline_flows.json
- Changed pipeline_flows.json: scene → scene_vlm
- Added get_enabled_processors() method to PipelineFlows
- Updated create_monitor_job to use dynamic processors
- Updated process_register_command to use dynamic processors
- Removed hardcoded processor arrays
- Added tests for get_enabled_processors()
2026-10-19 02:03:15 +08:00
Accusys de507c7bc0 docs: add status sync migration guide for Studio team
- Explains new automatic trigger-based synchronization
- Provides code examples for removing manual cache updates
- Documents new status query and sync APIs
- Includes migration checklist and testing guide
2026-10-18 22:09:08 +08:00
Accusys c4bdb01b21 feat: add status sync trigger and status query APIs
- Created PostgreSQL trigger to sync videos.status with monitor_jobs.status
- Added GET /api/v1/jobs/:uuid/status endpoint
- Added POST /api/v1/admin/sync-status endpoint for batch sync
- Status mapping: paused→paused, pending→registered, running→processing, completed→completed, failed→failed
- Migration file: 008_sync_video_status_trigger.sql
2026-10-18 22:08:19 +08:00
Accusys e027d84da4 docs: add Pause/Resume UI implementation guide for Studio team
- API endpoint documentation (pause, resume, list paused)
- Vue component examples for Pause/Resume buttons
- Paused Jobs management page template
- Navigation update suggestions
- State flow diagram
2026-10-18 20:15:01 +08:00
Accusys 9f7bc1c37a feat: add pause/resume job functionality
- Added Redis paused set for job management
- Worker skips paused jobs during polling
- Added POST /api/v1/jobs/:uuid/pause endpoint
- Added POST /api/v1/jobs/:uuid/resume endpoint
- Added GET /api/v1/jobs/paused endpoint
- Paused jobs are excluded from worker processing queue
2026-10-18 20:13:31 +08:00
Accusys 2c6b52f0ed docs: add Monitor Dashboard Improvements recommendation for Studio team
- Document new/enhanced API endpoints (worker_status, data-consistency)
- UI improvement recommendations (empty state, worker health, consistency check)
- Priority matrix and implementation guide
- Files to modify list for Studio team
2026-10-18 16:31:05 +08:00
Accusys f165dc1425 feat: enhance worker status API with PID, uptime, and liveness check
- Added worker_pid (from pgrep)
- Added uptime_secs
- Added last_poll_at (most recent job activity)
- Added poll_interval_secs
- Added is_alive (based on worker process existence)
2026-10-18 16:20:46 +08:00
Accusys 9cd386b720 feat: add data-consistency API + deprecate old face docs
- Added GET /api/v1/file/:uuid/data-consistency endpoint
  Checks consistency across tkg_nodes, trace_profiles, FS trace dirs, and Qdrant
- Marked 6 old face documents as deprecated with link to Face_Operations_Complete.md
2026-10-18 15:01:52 +08:00
Accusys 58431d1d8d feat: sync_trace_label unified function + fix is_tkg_done
- Created trace_sync module with sync_trace_label() to sync labels across:
  1. tkg_nodes.label (PostgreSQL)
  2. trace_profiles.name (PostgreSQL)
  3. trace_profile.json label (FS)
  4. Qdrant _faces payload.label (NEW - was missing)

- Fixed is_tkg_done: allow 0 trace dirs if tkg_nodes exist
  (prevents permanent stuck in 'Scanning' status)

- Updated Face Cluster to use sync_trace_label
- Updated merge_trace to use sync_trace_label + cleanup source dir

- Created Face_Operations_Complete.md reference document
  (consolidates all face-related docs into single source of truth)
2026-10-18 14:15:12 +08:00
Accusys f3013c8509 feat: add /api/v1/trace-profile-file endpoint
- Added endpoint to serve trace_profile.json files
- Fixes Studio proxy bug (missing file_uuid in path)
- Studio proxy at proxy.rs:809 constructs path without file_uuid
- Core endpoint now provides correct implementation
- Studio can proxy to this endpoint instead of local file reading
2026-10-18 09:23:49 +08:00
Accusys aecf64af27 fix: replace hardcoded store_traced_faces.py with Rust binary
- Worker was calling Python store_traced_faces.py instead of Rust version
- This caused trace_id=0 in Qdrant, blocking TKG and file completion
- Now uses rust_binary_path() to find and execute rust_store_traced_faces
- Also removed all Python implementations from processor config
- Removed POSE processor (deprecated)
- Added redis_publisher.py symlink for face clustering

Fixed: file stuck in 'Scanning' due to trace stability check failure
2026-10-18 08:43:56 +08:00
Accusys 17cdb6c7fd feat: implement dynamic concurrency control for SCENE_VLM (complete)
- Add DynamicSemaphore, SystemMonitor, VlmMonitor, AutoScaler
- Replace static SCENE_VLM_SEM with dynamic version (max: 3)
- Start AutoScaler in Worker::run() for automatic adjustment
- Configured for M5Max48: 48GB, thresholds at 38GB/41GB
- Expected processing time: 23-28 days for 10000 files

Note: VLM response tracking to be added separately if needed
2026-10-17 21:52:01 +08:00
Accusys 229eef6db1 fix: call start_autoscaler() in Worker::run() to enable dynamic concurrency 2026-10-17 21:49:58 +08:00
Accusys 9886a3a5b2 feat: implement dynamic concurrency control for SCENE_VLM
- Add dynamic_concurrency module with DynamicSemaphore, SystemMonitor, VlmMonitor, AutoScaler
- Replace static SCENE_VLM_SEM with dynamic version (max concurrency: 3)
- Add AutoScaler background task for automatic concurrency adjustment
- Configured for M5Max48 (48GB): thresholds at 38GB/41GB
- Expected processing time: 23-28 days for 10000 files

Related: Phase 1 implementation after Phase 0 TKG fix verification
2026-10-17 21:47:33 +08:00
Accusys 095df145d6 wip: additional processor improvements
- Update face clustering processor
- Update TKG processor
- Update Rust face cluster and trace storage
- Add M4 workspace documentation

Note: Work in progress, not yet tested
2026-10-17 18:31:08 +08:00