- AsrxSegment.start_frame/end_frame -> Option<u64> so the ASR fallback
(which emits null frames) deserializes instead of erroring
- P2 face-trace trigger gated on has_face alone (not has_asrx), so
no-face videos still get face_traced.json via the fast-path,
unblocking FaceCluster and preventing the job from failing
- 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:
- Worker set processor status to 'running' BEFORE checking capacity
- If capacity limit reached, processor was skipped but status stuck at 'running'
- Worker would skip processors with 'running' status on next poll (deadlock)
** Root Cause:
- Line 591-600: update_processor_progress(..., 'running')
- Line 1434: check capacity (TOO LATE!)
- Result: status='running' but processor never started
** Fix:
- Move capacity check BEFORE setting 'running' status
- If capacity limit reached, mark as 'skipped' immediately
- Prevents 'running' status from being set when processor won't actually run
** Impact:
- Fixes UI 'Deep Scan' deadlock issue
- Workers will no longer get stuck in infinite loop
- Processor status will accurately reflect actual state
** Files Changed:
- src/worker/job_worker.rs: Moved capacity check to line 591-592
- Removed duplicate capacity check at line 1464-1493
- 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).
- 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 ChunkType::Moment to types.rs
- Add moment_interval to FileProfile (configurable, default 10s)
- Create rule3_moment.rs: reads trace_profile.json, groups by time window,
selects 1-2 diverse key frames using Jaccard similarity on VLM text
- Embed moment chunks into Qdrant using trace VLM embeddings
- Wire into worker: triggers after VLM completes, blocks job completion
- Add moment_chunks progress stage (weight: 0.01)
Problem: vlm_done_bool=true was hardcoded, so job completed immediately
without waiting for VLM generation. After re-scan, trace_profile.json
showed vlm_summary: null.
Fix: Query trace_profiles to check VLM completion status before
marking all_ok=true. Job now blocks until vlm_done_count >= vlm_total.
- Move VLM trigger from TKG spawn to worker poll loop
- Each poll checks if VLM is incomplete and key_frames are ready
- If VLM was interrupted (server restart), next poll will restart it
- Removed duplicate VLM spawn from TKG block
- 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
- Move P5 VLM trigger from TKG block to Face Dedup block
(trace_profiles DB is written by update_face_track_labels, not TKG)
- Update on-disk trace_profile.json label when Face Dedup updates names
- Add output_dir and redis_clone to Face Dedup spawn scope
Pipeline flow:
Face → P2 Tracing → P3 Cluster → update_face_track_labels
→ DB trace_profiles + on-disk JSON updated
→ P5 VLM triggered with verified trace count
VLM summary was blocking job completion, causing jobs created before
P5 deployment to be stuck forever (vlm=false, all_ok=false).
Now VLM logs progress but doesn't block: vlm_done_bool always true.
This allows older jobs to complete while VLM can be triggered
separately via API.
verify_traces_ready now runs synchronously after build_tkg().await
completes, not inside a separate spawned task. This guarantees the
DB transaction from TKG is fully committed before VLM checks for data.
Before: TKG spawn → P5 spawn (race: P5 may run before TKG DB commit)
After: TKG spawn → build_tkg() await → verify → spawn VLM (sequential)
B: Replace wait_for_traces polling with verify_traces_ready
- Uses JOIN query: trace_profiles INNER JOIN tkg_nodes
- Ensures trace_profiles data is consistent with TKG before VLM runs
- Single query instead of 30 retry attempts
C: Add 5-minute timeout to VLM generation
- tokio::time::timeout(300s) prevents worker from hanging
- Logs completion stats or timeout error
This fixes the root cause: P5 no longer polls blindly waiting for
TKG to finish. The JOIN query only returns rows when both
trace_profiles AND tkg_nodes face_track entries exist.
- Add wait_for_traces() helper: polls trace_profiles table every 2s
up to 60s, returning when rows appear (TKG may still be writing)
- Replace one-shot face_count query in both P5 triggers (has_face +
no-face paths) with polling
- Verified: 22/22 traces summarized for 9df18017, semantic search
returns 10 VLM results with sim 0.601-0.696
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).
- job_worker.rs: Read face_settings from monitor_jobs before processing
- job_worker.rs: Set FACE_MIN_CONFIDENCE and FACE_MIN_SIZE env vars
- job_worker.rs: Restore env vars after processing completes
- Add detailed logging: [WORKER] face_settings and env var changes
This ensures the executor receives the correct face settings from the job.
1. Per-job concurrency budget: add can_start_for_job() to ProcessorPool
so multiple files process in parallel instead of one job starving others.
Uses active_job_count to compute fair slot budget per job.
2. FaceCluster race condition: add face_traced.json existence check before
running face_cluster processor. face_traced.json is produced by P2
store_traced_faces.py which runs AFTER process_job completes, so
clustering was producing no_faces (0 clusters) despite having faces.
The P3 Face Dedup trigger previously only logged when cluster_count !=
face_track_count without actually syncing labels. Now it calls
update_face_track_labels to:
- UPDATE tkg_nodes SET label = cluster_id for each trace
- UPSERT trace_profiles SET name = cluster_id
- Reset unclustered traces to default Person_N name
This matches what the manual 'Face Deduplication' button in Studio
already does via the cluster-agent API endpoint, ensuring the automatic
pipeline produces the same result without requiring manual intervention.
The PythonExecutor.run() hardcoded output_idx=1, which treats args[1] as
an output file path and rewrites it to .json.tmp. For scripts like
store_traced_faces.py that use --file-uuid (not an output path) at
position 1, this corrupted the UUID into a file path, causing the script
to fail with exit status 1 within 90ms.
- run_with_output_idx: output_idx changed from usize to Option<usize>
- run_with_output_idx_and_frames: same change
- run(): doc comment added, passes Some(1) for backward compatibility
- job_worker.rs: store_traced_faces.py and release_pack.py calls now
pass None for output_idx (no output path substitution)
- appearance.rs: passes Some(2) explicitly (output at index 2)
Verified: Gamma 8 file completed full pipeline with 24 face traces
and 185 TKG nodes.
- profile.rs: single/group/merge_groups/undo all use upsert_trace_profile
- trace_agent_api.rs: hard delete/merge snapshot + delete trace_profiles
- cluster_agent.rs, job_worker.rs: background name writes use UPSERT
- schema.rs: upsert_trace_profile helper (backfill from tkg_nodes)
- Studio 3 API gaps documented (cluster-results/identity-matches/similar)
- get_face_groups_handler: COALESCE(tp.name, tn.label) for name consistency
- sync_file_status: compare JSON vs pre_chunks (not chunk table)
- face consistency: compare frames.len() not total_faces
- cleanup 2 ghost records with NULL file_name/file_path
- replace identity_agent with face_dedup in pipeline stages
- remove identity_agent_api.rs and all references
- update required_processors to match actual processors
- update AGENTS.md with team responsibilities
- add Studio pipeline changes documentation
- Add Qdrant count verification before TKG build
- Wait up to 30 seconds for Qdrant to have all face embeddings
- Prevents race condition where TKG reads incomplete data
- Add count_points method to QdrantDb
- Check face.json status before waiting for face_traced.json
- If status='no_faces', spawn TKG immediately (no face_track nodes)
- If status='has_faces', wait for face_traced.json
- Prevents infinite wait when video has no faces
- Add check for face_traced.json existence before spawning TKG build
- Prevents race condition where TKG reads Qdrant before trace_id is written
- Logs clearly when waiting and when proceeding
- Add POST /api/v1/file/:file_uuid/cluster-agent endpoint for on-demand face clustering
- Fix OCR chunks being labeled as ASRX: use ChunkType.as_str() instead of {:?}
- Rule 1 now deletes old chunks before re-inserting to avoid stale data
- Add fallback face_traced.json when store_traced_faces.py fails
- ingestion_complete now handles status='error' to unblock jobs
- VLM describe tool now uses trace_id with pre-extracted face crops
1. Add Redis PipelineProgress cleanup in unregister_internal
- Deletes progress key when file is unregistered
2. Fix ingestion_complete asr_status query
- Query ASRX first, then ASR
- Filter out NULL values to avoid false negatives
3. Fix TKG 0 nodes/edges support
- TKG is considered done if face traces are complete
- TKG may create 0 nodes/edges for videos with minimal content
4. Add ASRX fallback to ASR segments
- When ASRX has 0 segments but ASR has segments, use ASR segments
- Ensures at least one ASRX output when ASR has content
When a job completes via the essential_completed branch (all essential
processors done but some non-essential failed), the PipelineProgress
was not being updated to 100%, causing a discrepancy where the status
showed 'completed' but progress showed <100%.
Now PipelineProgress.mark_completed() is called in both completion paths.
1. trace_done now checks for 'no_faces' status in face_traced.json
- Videos with no detected faces now complete correctly
- Previously stuck because trace_count=0 returned false
2. ASRX fallback to ASR segments includes start_frame/end_frame
- Added _convert_asr_segments_to_asrx helper function
- TKG can now process fallback segments correctly
This allows processing of:
- Videos with no audio track (ASR: no_audio_track)
- Videos with no faces (face_traced.json: no_faces)
When a file is re-registered, the old PipelineProgress in Redis
was not cleared, causing the Portal to show 'completed' status
even though the new job was still running.
Now PipelineProgress is deleted when a new job starts processing.
Previously, ingestion_complete only checked ASR and face traces,
causing jobs to complete before TKG was triggered. This resulted in
TKG nodes being 0 even after job completion.
Now ingestion_complete also checks if TKG nodes exist for the file.
The job stays in 'running' status until TKG completes.
The TKG guard was checking if nodes exist before spawning TKG build.
This caused a deadlock when:
1. TKG spawns (async)
2. ingestion_complete checks → false (nodes not yet created)
3. Returns Ok(false), job stays running
4. Next poll: guard checks nodes → no nodes yet (TKG still running)
5. Skips TKG → deadlock!
Since build_tkg uses ON CONFLICT (idempotent), it's safe to call
multiple times. Removed the guard to fix the deadlock.
When a job is deleted from the database (e.g., by unregister),
the worker now checks if the job still exists before processing.
If the job no longer exists, it skips it instead of getting stuck.
This fixes the issue where unregistering a file would leave the
worker stuck trying to process a non-existent job.