Issue: Files with face_traced.json status=null and total_faces=0 stuck in PROCESSING forever
Root cause:
- ingestion_complete checks trace_status == 'no_faces' to skip TKG
- But some old files have status=null instead of 'no_faces'
- TKG check fails because no nodes for no-face videos
Solution:
- Check both status='no_faces' AND total_faces=0
- Skip TKG check for no-face videos (total_faces=0)
- Also update face_cluster_done to handle total_faces=0
Impact:
- Fixes stuck files with null status in face_traced.json
- Consistent with scan.rs fix (commit 0d11c601)
Affected: M4ProMini file 18173b62d80bf829910348fa1a6ddcf5
- Gemma4 returns both content and reasoning_content
- reasoning_content is the thinking process, not the final answer
- content contains the actual scene description
- Changed priority: content first, reasoning_content as fallback
Fixes: Scene VLM generated 0 descriptions issue
Root cause: Using reasoning_content (thinking) instead of content (answer)
- Improve face fast-path trigger: recognize has_faces with empty frames
- Add re-evaluation mechanism: check PROCESSING files every 10 mins
- Enhance ASRX silent fast-path: detect empty segments array
- Fix files stuck in PROCESSING status when all data is produced
Related: M4ProMini deep scan (114 files, 89 bad + 2 stuck)
Issue: ASRX & FACE_CLUSTER forever running/0, no completion trigger
**Problem**:
- Changed to hyphenated format (36 chars)
- videos.file_uuid is varchar(32)
- Caused regression: 'value too long for type'
**Fix**:
- Reverted to simple().to_string() (32 chars)
- Schema convention: ~10 tables use varchar(32)
- Hyphenated format is for command_id, not file_uuid
**Kept**:
- FFPROBE_PATH environment variable (verified working)
**Reference**: M4 analysis of schema constraints
**Fixes**:
1. file_uuid: Use standard format with hyphens (consistent with other 11 places)
- Changed from simple().to_string() to to_string()
- Format: xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx
2. ffprobe: Use FFPROBE_PATH environment variable
- Fallback to 'ffprobe' in PATH
- Follows project convention (DATABASE_URL, AUDIT_ENCRYPTION_KEY)
- Solves non-interactive PATH issue
**Rationale**:
- Both are one-line changes
- Reduces packaging cycles (avoiding 4th binary sync issue)
- Critical for data consistency and deployment automation
**Problem**:
- key_type stored as "user" (with quotes, len=6)
- Future WHERE key_type = 'user' would silently fail
**Solution**:
- Added ApiKeyType::as_str() method
- Returns bare string: "system", "user", etc.
- handlers.rs:437 now uses as_str() instead of serde_json::to_string()
**Impact**:
- Existing test keys in test DBs can be safely ignored
- Production DB has no api_keys yet
- No code relies on JSON-quoted format
- Add logic to read and execute .sql migration files
- Replace schema placeholders (public. -> current schema)
- Track applied migrations in schema_migrations table
- Support both public and dev schema environments
- Fixes B-4: 27/40 migrations failed on M5Max128
Ref: docs_v1.0/M4_workspace/2026-10-04_B-4_Migration_Fixed.md
Issue: Previous edit missed L11 hardcoded path
Solution: Use same env var + current_exe() pattern as L24
Verification: strings shows 0 dev paths in binary
D-4: ✅ Complete
Final cleanup:
1. main.rs:35 - Remove hardcoded .env fallback
- Rationale: L30-34 already provide correct current_exe() resolution
- Removes dev path, aligns with A-14.3 "禁止读取 dev 设定"
2. docs.rs:11,24 - Use current_exe() resolution
- Replace hardcoded doc_wasm paths
- Add MOMENTRY_DOCS_DIR env var support
- Fallback to relative path
Result:
- All hardcoded dev paths removed from release binary
- D-4 Gate satisfied
- Zero momentry_core/nextorageai paths in source
Impact:
- Binary fully portable
- No dev environment assumptions
- All paths runtime-resolved
Found 4 dev paths in momentry binary via strings:
1. pose.rs (2 paths) - CRITICAL
- Line 250, 410: swift_pose path
- Impact: processor execution path
- Fix: Use path_utils::cli_dir() + relative path
2. docs.rs (2 paths) - MEDIUM
- Line 11, 24: doc_wasm path
- Impact: documentation service
- Fix: cfg(debug_assertions) + env var
3. markbase_compat.rs (2 paths) - MEDIUM
- Line 31, 58: Studio data path
- Impact: SFTP service
- Fix: MOMENTRY_STUDIO_DATA_DIR env + fallback
Verification:
- cargo check passes
- All paths now runtime-resolved or dev-only
- D-4 Gate should pass after rebuild
Problem:
- GET /api/v1/files (list) returns DB status
- GET /api/v1/file/:uuid (detail) returns DB status
- DB status may be stale
- Results in inconsistency
Solution:
1. Add compute_file_status() helper function
- Checks processing_status->>'phase'
- Checks processor JSON files
- Derives actual status
2. Fix get_file_detail:
- Always use computed status
- Ensures accuracy for single file queries
3. Fix list_files:
- Add sync_status query parameter
- sync_status=true: compute status for each file
- sync_status=false (default): use DB status
- Balances performance and accuracy
Verification: cargo check --lib passes
Impact:
- detail endpoint now returns accurate status
- list endpoint can optionally sync status
- Both endpoints use same derivation logic
G-4 status: ✅ Completed
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
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
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
- 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
- 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
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.
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.