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
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
- 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
- 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).
Problem: Re-scan (/api/v1/file/:file_uuid/process) only deleted processor_results from DB,
but not output files. Worker checks if output file exists and skips re-processing,
resulting in stale/incorrect results persisting.
Solution:
- Add 'force' parameter to ProcessRequest struct (default: false)
- When force=true, delete all output files before re-processing
- Worker will then re-run processors from scratch
Changes:
- src/api/processing.rs:
- Added 'force: bool' to ProcessRequest
- Added delete_output_files_for_uuid() helper function
- Modified trigger_processing() to delete output files when force=true
API usage:
POST /api/v1/file/:file_uuid/process
{
"processors": ["face","ocr",...],
"force": true
}
Note: Build currently fails due to unrelated uncommitted admin_config changes.
Those should be fixed separately.
- 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
- vlm_summary now skips VLM call if description exists, but still generates embedding + Qdrant
- API endpoint checks both vlm_description AND vlm_embedding before saying 'already done'
- Fixed point_id hash generation (was creating 0, now properly hashes)
- Add upsert_vlm_embedding to QdrantDb with trace_id in payload
- chunk_id format: {file_uuid}_t{trace_id_hex} for search enrichment
- Update enrich_vlm_from_pg to extract trace_id from chunk_id
- VLM summary now searchable via semantic search with source_type=vlm
- Added trace_profiles query to compute vlm_done/vlm_total
- vlm_summary stage now shows actual progress (e.g. 312/4829)
- Status shows 'running' while in progress, 'completed' when done
- Add TraceArtifacts phase to TkgPhase enum (phase 18)
- Report progress as key_frame.jpg/key_face.jpg are created
- VLM trigger now polls until ALL key_frame.jpg files exist
(was: started after TKG build, before artifacts were ready)
- Add iron rule to AGENTS.md: ask before removing data
Tested: Gamma 8 (27 traces) → 27/27 VLM summaries completed
Register should only write videos table, not automatically create
monitor jobs. This violates the design principle that register does
not trigger deep scan.
The auto-pipeline (triggered only for new files with auto_pipeline_enabled)
handles job creation separately. Re-scan via processing API will handle
job creation when needed.
When a file is re-registered after unregister, the monitor_job is
missing. The register function now checks if a job exists and creates
one with full pipeline processors (cut, asr, asrx, ocr, face,
face_cluster) if missing.
This ensures re-scan after unregister triggers the complete pipeline
including face detection → TKG → VLM summary (P5).
- Add vlm_point_id column to trace_profiles (stores Qdrant point ID)
- Add upsert_chunk_embedding_u64 to QdrantDb (numeric ID support)
- Add chunk_id to VLM payload in Qdrant for search enrichment
- Update enrich_from_pg to fallback to VLM lookup when chunk not found
- Add /api/v1/file/:uuid/vlm-summary endpoint for manual trigger
- Fix VLM point_id: use u64 hash instead of string (Qdrant requirement)
- Fix VLM timeout: was 0 (immediate timeout), now 120s
Verified: semantic search returns [vlm] results with proper enrichment
- tkg.rs: key_frame/key_face/best_bbox now use best-confidence frame
(was cq_best capture-quality) so thumbnails agree with trace_agent_api
best_face_frame / [F..] labels
- keep cq_best_quality as trace-level stat only
- add backfill_trace_dirs + skip_existing resume mode
- trace_agent_api.rs regenerate-thumbnail: use strict > tie-break (reduce)
matching list_traces_sorted so equal-confidence frames pick the same one