fix: resolve P2 hardcoded paths to use runtime resolution (A-4.2 P2)

Issues: Direct hardcoded paths without fallback
- proxy.rs:108 - audio_track_probe.py
- tool_selector.rs:136 - output_dir
- ocr.rs:241 - swift_ocr binary
- files.rs:1190 - legacy output dirs

Impact: These paths don't exist on release machines

Solution:
1. proxy.rs: Use path_utils::scripts_dir()
2. tool_selector.rs: Use config::OUTPUT_DIR
3. ocr.rs: Use swift_processor_path() helper
4. face.rs: Make swift_processor_path() public
5. files.rs: Reduce duplicate legacy paths

Changes:
- src/core/proxy.rs: Resolve audio_track_probe.py
- src/core/processor/tool_selector.rs: Use OUTPUT_DIR from config
- src/core/processor/ocr.rs: Use swift_processor_path()
- src/core/processor/face.rs: Export swift_processor_path()
- src/api/files.rs: Deduplicate legacy paths

Verification: cargo check --lib passes

Remaining: P3 (unwrap_or_else type, ~89 locations)

References:
- A-4.2 P2 in Momentry_Release_Requirements_20261004.md v1.1
- G-3 gate condition
This commit is contained in:
Accusys
2026-10-04 16:06:41 +08:00
parent 2f5e2c1314
commit e0eb7b9ce8
5 changed files with 10 additions and 5 deletions
+1 -1
View File
@@ -7,7 +7,7 @@ use super::FaceStatus;
const FACE_TIMEOUT: Duration = Duration::from_secs(7200);
fn swift_processor_path(bin: &str) -> std::path::PathBuf {
pub fn swift_processor_path(bin: &str) -> std::path::PathBuf {
use std::path::PathBuf;
let rel = format!(".build/release/{}", bin);
let rel = rel.as_str();
+2 -1
View File
@@ -238,7 +238,8 @@ pub async fn process_ocr(
) -> Result<OcrResult> {
tracing::info!("[OCR] Starting text recognition: {}", video_path);
let swift_ocr_path = std::path::Path::new("/Users/accusys/momentry_core/scripts/swift_processors/.build/release/swift_ocr");
// Resolve Swift OCR processor path
let swift_ocr_path = crate::core::processor::face::swift_processor_path("swift_ocr");
if swift_ocr_path.exists() {
tracing::info!("[OCR] Using Swift processor: {:?}", swift_ocr_path);
+3 -1
View File
@@ -133,7 +133,9 @@ impl ToolSelector {
if let Ok(output_dir) = std::env::var("MOMENTRY_OUTPUT_DIR") {
vars.insert("output_dir".to_string(), output_dir);
} else {
vars.insert("output_dir".to_string(), "/Users/accusys/momentry/output".to_string());
// Resolve output_dir from environment or config
let output_dir = crate::core::config::OUTPUT_DIR.to_string();
vars.insert("output_dir".to_string(), output_dir);
}
vars