- 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
Consolidated snapshot (previously WIP in working tree).
- core/pipeline_config: new module loading config/pipeline_flows.json as the
source of truth for stage execution mode (parallel/blocking) and dependencies
- worker/job_worker: dispatch Scene VLM to a background task when the stage is
declared parallel, unblocking the worker poll loop; resolve processor
dependencies from pipeline_flows.json (fallback to built-in)
- config/pipeline_flows.json: asrx depends on [cut, asr]
- scripts/fix_stuck_jobs: fix UTC timezone comparison, raise default threshold
to 6h, skip jobs with recent processor activity
- rust_asrx: Rust speaker diarization CLI + processor wiring
- processor metadata helper; fast_face_clustering script; file_progress pipeline
API; scan API; VAD updates
Major Changes:
- Pipeline Queue integration completed (internal.file + pipeline.commands)
- Fixed old job_worker database compatibility with new command_queue table
- Compiled Swift OCR binary (was missing, causing empty OCR results)
- Added deep scan functionality through re-scan API
Fixes:
- Changed CommandJob.id from i32 to i64 for database compatibility
- Added UUID generation in create_command (message_id field)
- Fixed claim_pending_commands to query queue_name = 'internal.file'
- Fixed field mappings: command_id → message_id, job_type → command_type
- Added support for 'processing' status in CommandJobStatus
Queue System:
- internal.file queue: for register/unregister/re-scan commands (job_worker)
- pipeline.commands queue: for vectorize/store_asrx/etc commands (pipeline_worker)
Documentation:
- Added comprehensive queue system documentation
- Created M4 workspace status reports
- Updated AGENTS.md with queue system details
Problem:
- L24 had hardcoded model path as default_value
- Would cause D-4 failure (strings shows dev path)
Solution:
- Remove default_value
- Add runtime resolution:
1. CLI --model argument
2. MOMENTRY_MODELS_DIR env var
3. Sibling of binary (models/facenet512.mlpackage)
Impact:
- Swift CLI now portable
- No dev path strings in binary
- D-4 Gate condition satisfied
Verification: grep shows 0 hardcoded paths
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
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
- 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
Problem: TKG Builder used deprecated face_detections table
Solution: Migrated to Qdrant _faces collection
Changes:
- Added qdrant_faces module import
- Replaced SQL queries with Qdrant API calls
- Updated build_face_track_nodes to use get_file_faces()
- Updated build_co_occurrence_edges to fetch from Qdrant
- Updated build_speaker_face_edges to calculate trace spans from Qdrant
- Updated build_face_face_edges to find co-occurrences in Python
- Updated build_face_body_edges to fetch face data from Qdrant
- Changed default schema from 'dev' to 'public'
- Changed default output_dir to /Users/accusys/momentry/output
Test results:
- ✅ Successfully created 7 face_track nodes
- ✅ Successfully created 6 face-face co-occurrence edges
- TKG Builder now works with V4.0 architecture
Related: #V4.0-migration
Features:
- New --try-common-languages flag for smart language detection
- Tries en, zh, ja when auto-detection fails or quality is poor
- Quality scoring based on avg_logprob, no_speech_prob, segment count
- Automatically selects best result from all attempts
Quality metrics:
- avg_logprob (higher is better)
- no_speech_prob (lower is better)
- segment count (more is better)
Use case:
- Fixes garbled output from wrong language detection
- Prevents Sinhala character output for Japanese audio
- Provides better language detection for common languages
- Analyze why Whisper detected 'nn' instead of Japanese
- Document root causes: poor audio quality, high noise, model confusion
- Provide diagnostic tool (analyze_whisper_language.py)
- Document 4 solutions: force language, audio preprocessing, model upgrade, parameter tuning
- Recommend integration into Momentry ASR pipeline
- Check if face.json already has trace_id (from Rust face_tracker)
- Skip Python tracking if traces already assigned
- Prevent duplicate tracking and preserve Rust results
- Support both list (FaceResult) and dict formats
- Create store_face_embeddings_to_qdrant.py script
- Add automatic Qdrant storage call after FaceNet completes
- Store 512D embeddings with metadata (frame, confidence, bbox)
- Enables downstream face tracing and clustering
This ensures embeddings are automatically stored in Qdrant without manual intervention.
- Add Swift FaceNet program using FaceNet CoreML model
- Integrate FaceNet into Rust Face processor (auto-generate embeddings)
- Adjust face_filter_defaults: min_confidence=0.5, min_size=1
- Support 512-dim embeddings with ANE acceleration
- Remove Python dependency for face embedding generation
Verified: 210 embeddings generated successfully (99.1% success rate)
Performance: 6.5s for 210 embeddings
Production ready.
- Changed min_confidence from 50.0 to 0.5 (Vision uses 0.0-1.0 range)
- Changed min_size from 32 to 1 (was filtering out all small faces)
- Changed min_capture_quality from 25.0 to 0.25
- Fixes issue where all videos showed 0 faces detected
Root cause: admin_config.rs used wrong defaults (50.0/32) instead of
config.rs constants (0.5/1), causing Vision framework to filter out
ALL faces because confidence threshold exceeded valid range.
Verified: IMG_9449 now correctly detects 191 faces (was 0).
- Replace fixed 320px downscale with smart resolution handling
- Videos <= 1920px: use native resolution (no downscale)
- Videos > 1920px: downscale to 1920px width
- Improves OCR quality for small text, subtitles, and scene text
Before: All videos scaled to 320px → poor OCR for small text
After: 1080p/720p videos use native resolution, 4K scales to 1920px
Verified: swift_ocr binary builds and runs correctly
- 720x890 video: native resolution (no scaling)
- 1920x1080 video: native resolution (at threshold)
- Detects video width and applies conditional scaling
Note: PaddleOCR fallback (ocr_processor_mps.py) already uses native resolution
- Delete YOLO processor implementation (src/core/processor/yolo.rs)
- Remove YOLO from processing pipeline and worker
- Clean up YOLO-related code across multiple modules
- Add migration 033_remove_yolo.sql
YOLO functionality removed as part of architecture simplification
- Add info log in vlm_summary.rs showing VLM model name
- Add print statements in Python VLM scripts showing model name
- Applies to: trace_vlm_caption.py, scene_vlm_caption.py, interval_vlm_caption.py
Apple Vision provides two distinct scores:
- confidence: detection confidence (is this a face?)
- faceCaptureQuality: capture quality (is this face suitable for recognition?)
Previously these were mixed together as 'confidence'. Now both are
stored separately in the output JSON for downstream use.
job_worker.rs was overriding Apple Vision defaults with 0.75/64 even when
no face_settings were provided, causing fewer faces to be detected.
Now detect all faces with Vision defaults (confidence 0.5, min_size 1px);
filter later for display via face_filter settings.
Part B (source fix): Enhanced TKG build Qdrant readiness check in
job_worker.rs. Previously only checked point count >= expected_faces,
which could fire before short traces finished uploading. Now verifies
trace_id stability: two consecutive scroll checks (2s apart) with same
unique trace count before proceeding.
Part A (repair): New scripts/repair_tkg_face_tracks.py reconciles Qdrant
_faces traces with PG tkg_nodes face_track rows, inserts missing ones.
Fixed 233 missing traces in 44c37c (1197 → 1430).
Large files (>1000 traces) used min_faces_per_trace=4, silently dropping
short traces (<=3 face points) from dedup. For 44c37c this excluded
484/1430 traces (34%) — walk-ons and passers-by never got a person label.
Now use min_faces=1 constant; noise is handled by the confidence>=0.5
filter in cluster_by_trace instead of dropping short appearances.
Result on 44c37c: 1430/1430 traces clustered, 21717/21717 faces assigned,
clusters 104 -> 203.
- auto_bind_speakers: remove dead DB writes to nonexistent talents table,
output speaker_person_mapping metadata into face_cluster.json instead
- fix representative_face.face_id to use face_idx (was frame_idx twice,
causing duplicate face_ids for multi-face frames)
- fix asrx segment field names (start_time/end_time) and pass correct
asrx path (ASRX_JSON_PATH was stale after UUID reassignment)
- Fixed upsert_trace_profile() SQL: replaced scalar subqueries with LEFT JOIN
to properly reference trace_profiles table in backfill logic
- Fixed face_filter routes: changed {file_uuid} to :file_uuid syntax for
axum 0.7.9 compatibility
- Both fixes resolve HTTP 500 errors in rename and 404 errors in face filter
- Verified both APIs working correctly with test requests
- executor.rs: Add cmd.env() for FACE_MIN_CONFIDENCE and FACE_MIN_SIZE in all 4 run methods
- face_processor.py: Pass os.environ to subprocess.Popen to inherit env vars
- Fixes multi-face detection issue where second face was being filtered out
- Tested: CONFIDENCE=0.5 preserves both faces (392 total), CONFIDENCE=0.75 filters second face (196 total), SIZE=100 filters small faces (201 total)