1090 Commits

Author SHA1 Message Date
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
Accusys 91f83f781c fix(tkg): remove tkg_nodes.json file check in is_tkg_done()
- TKG processor writes to database, not file
- Check database + trace directories instead
- Fix infinite loop for completed files
- Related: Phase 0 preparation for dynamic concurrency
2026-10-17 18:24:26 +08:00
Accusys 0361510a05 feat: add trace profile API path parameter support
- Add TraceProfilePath struct for path parameters
- Refactor get_trace_profile_handler to support both formats:
  - Query parameters: /api/v1/trace-profile?file_uuid=...&trace_id=...
  - Path parameters: /api/v1/trace-profile/:file_uuid/:trace_id
- Maintain backward compatibility with existing query parameter format
- Fix 404 error when Studio calls trace profile API with path format

Fixes: Studio right-click key frame trace profile error

Deployment: Released to production (3002) on 2026-10-17
2026-10-17 00:16:03 +08:00
Accusys 93006fd299 feat: add Qdrant trace_id update to Rust Face Tracing
## Problem
- Rust Face Tracing only generated face_traced.json
- Did not update trace_id in Qdrant
- Caused trace_id to remain null in Qdrant
- Face Clustering failed due to missing trace_ids

## Solution
Added two functions:
- build_trace_mapping(): Build (frame, bbox) -> trace_id mapping
- update_qdrant_trace_ids(): Batch update Qdrant points with trace_ids

## Flow
1. Read embeddings from Qdrant
2. Calculate traces (IoU + Similarity)
3. Generate face_traced.json
4. Update trace_ids in Qdrant (NEW)

## Testing
- Previous: trace_id=null in Qdrant
- After: trace_id correctly set
- Face Clustering now works

## Files Changed
- tools/cli/rust/src/bin/rust_store_traced_faces.rs

Closes #QDRANT_TRACE_ID_NULL
2026-10-16 22:11:41 +08:00
Accusys 81ba3ae6e8 feat: improve Face Tracing with IoU + Embedding similarity matching
## Changes

### Face Tracing Improvements
- Replace bbox distance matching with IoU (Intersection over Union)
- Add embedding similarity matching from Qdrant _faces collection
- Add Qdrant HTTP client to load face embeddings
- Fix Qdrant data format reading (x, y, width, height directly, not in bbox object)
- Add debug logging for trace matching
- Add --similarity-threshold and --iou-threshold parameters

### Results
- Before: 374 traces (each face a separate trace)
- After: 22 traces (continuous face sequences)
- Matching validation: IoU 0.819-1.000, Similarity 0.976-1.000

### Pipeline Configuration
- Add face_trace tool configuration with Rust implementation
- Set default parameters: similarity_threshold=0.85, iou_threshold=0.3
- Document usage notes for trace definition

### Face Clustering
- Update threshold to 0.15 for correct male/female separation
- Add auto-filtering for low-quality clusters (face_count<20, bbox_area>150000)

## Testing
- Test video: Accusys-WD_FilmRiot_test.mp4 (374 faces, 188 frames)
- Final result: 2 persons (104 + 79 = 183 faces assigned)
- All faces correctly assigned with cluster_id

## Documentation
- Add test report: docs_v1.0/M4_workspace/2026-10-16_face_tracing_fix_test_report.md

## Files Modified
- tools/cli/rust/src/bin/rust_store_traced_faces.rs
- config/pipeline_flows.json
- scripts/face_clustering_processor.py
- docs_v1.0/M4_workspace/2026-10-16_face_tracing_fix_test_report.md (new)

Closes #FACE_TRACE_IMPROVEMENT
2026-10-16 19:52:17 +08:00
Accusys dbd9efc8f5 docs: add Face Tracing improvement plan
Comprehensive plan to fix Face Tracing quality issues:

Problem:
- Python version: low thresholds (0.7, fallback 0.65)
- Rust version: incomplete implementation (bbox only, no embedding check)
- Result: 16 traces for 2 persons, internal similarity as low as 0.18

Solution:
- Improve Rust version to use embedding similarity (threshold=0.85)
- Add Qdrant integration to read embeddings
- Add quality control (trace internal similarity check)
- Expected: 2-4 traces, similarity > 0.85

Timeline: 2-3 days
Priority: P0 (core feature defect)
2026-10-16 15:42:27 +08:00
Accusys 4dbaf69a3e docs: add Studio integration guide for trace-profile API
- Complete solution documentation for Studio team
- API endpoint usage examples
- Testing results
- Integration guide
- Benefits and deployment status
2026-10-16 13:37:44 +08:00
Accusys 2090dd25ea feat: improve face clustering and add trace-profile API fallback
Core changes:
- Face clustering threshold: 0.35 → 0.15 (better male/female separation)
- Add auto-filtering for low-quality clusters (face_count<20, bbox_area>150000)
- Add filesystem fallback for trace-profile API

Face clustering improvements:
- Correctly separates male and female faces
- Filters hand detections and isolated faces
- Result: 2 persons (186 male, 174 female) vs 4 persons before

Trace profile API:
- GET /api/v1/trace-profile?file_uuid=X&trace_id=Y
- Returns data from PostgreSQL or filesystem fallback
- Simplifies frontend: no need to know filesystem structure
- Fixes Studio 'trace profile not found' error

Issue: docs_v1.0/M4_workspace/2026-10-16_studio_trace_profile_bug_report.md
2026-10-16 13:36:29 +08:00
Accusys e8b26f997f docs: add Studio bug report for trace_profile not found issue 2026-10-16 13:21:39 +08:00