- Changed from 'public, max-age=86400' to 'no-cache'
- Allows immediate verification of rebuilt key_face.jpg files
- Can be changed back to max-age=300 after verification
- Added request_logger middleware in middleware.rs
- Logs every API request with method, path, and query string
- Logs every API response with status code and duration
- Skips health checks and static files to reduce noise
- Error responses (4xx/5xx) logged at warn/error level
- Added to server router as global middleware
- tkg.rs key_frame: select=eq(n\,best_frame) instead of -ss frame/fps
- tkg.rs retry: same fix for need_retry block
- tools.rs agent frame: select=eq(n\,frame_number)
- media_api.rs segment video: select=between(n\,sf\,ef-1) for frame mode
VFR videos (r_frame_rate != actual fps) now get correct frames.
CFR videos unaffected: select=eq(n) produces same result as -ss frame/fps.
Fixes: face card / face-detail thumbnail mismatch for VFR files.
- Thumbnail endpoint was using select_rep_face (blurdetect) which could pick
a different frame than the trace_profile's key_frame/key_face
- This caused mismatch between Face Detail modal and thumbnail in trace list
- Fix: add Step 1.5 to check trace_profile's key_face.jpg before falling back
to select_rep_face
- Ensures thumbnail always matches what Face Detail modal shows
Verified: trace_21 thumbnail now matches key_face.jpg (same hash)
Now all unregister operations log:
- source: who triggered it (api, studio, watcher, auto-cleanup, etc.)
- reason: why it was triggered (manual, failed-processing, duplicate, etc.)
Also adds proper ERROR logging for failures:
- Transaction commit failures
- Redis client creation failures
- Qdrant deletion failures
This allows tracking which operations caused file deletion and
identifying failures that were previously silent.
trace_profiles was missing from the unregister cleanup, leaving orphaned
records when files were unregistered. This caused data inconsistency:
- trace_profiles remained while Qdrant _faces and TKG nodes were deleted
- Studio could show stale face groups pointing to non-existent data
Changes:
- Added trace_profiles_table to both unregister functions
- Added delete_safe! call to delete trace_profiles by file_uuid
- Updated log message to include trace_profiles count
Verified: Cleaned up 24 orphaned records for a4442006be2d401a7e22ed8ff29da772
Single-trace groups with auto-generated names (Person_N) are filtered
to unassigned, but user-named groups are kept even with 1 trace.
This fixes the issue where moving traces one-by-one to a new group
caused them to disappear from the UI.
Before: trace → 'NewGroup' → filtered → unassigned (FS disappeared)
After: trace → 'NewGroup' → shown as group (FS visible)
Direct access to trace key_face.jpg — simpler URL, faster routing.
Response: ~8ms (read from disk, no ffmpeg).
Studio can use: /api/v1/trace-thumb/{file_uuid}/{trace_id}
Instead of: /api/v1/face-thumbnail?uuid={uuid}&trace_id={tid}&frame={frame}
1. Thumbnail API now checks trace/{tid}/key_face.jpg before ffmpeg
- First request: 8ms (read from disk) vs ~500ms (ffmpeg)
- All 2,451 trace thumbnails now served from pre-cached key_face.jpg
2. Face-groups API accepts ?include_trace_ids=false
- Default: includes trace_ids (32KB for Charade)
- With flag: excludes trace_ids (17KB, 48% reduction)
- Frontend can fetch full data only when user clicks into a group
Add async_mode option to POST /api/v1/unregister:
- async_mode=false (default): synchronous, waits for completion
- async_mode=true: spawns background task, returns immediately with job_id
Response now includes job_id field (None for sync mode).
Used by Studio when unregistering large files that take >30s
(e.g., 83K faces, 20K tkg_nodes).
get_cluster_results_handler derived each group's trace_ids from
COALESCE(tp.properties, tn.properties)->>'trace_id'. Since
trace_profiles.properties is {} this was NULL -> fell back to 0 for
every row, so ALL groups reported trace_ids:[0] and collapsed to the
same representative trace.
Studio's People view renders groups from cluster-results, so every
group showed the same face (trace 0) and "Delete all" / "Merge" operated
on phantom data: batchDeleteGroups deleted trace 0 repeatedly and never
touched the real traces, which is why delete-all appeared to work but
left 16 groups behind and merge kept failing.
Now reads the real tp.trace_id (fallback tn.properties->>'trace_id'),
matching the face-groups fix in 4a480f46. Verified on 9cbeb112:
17 distinct traces now map correctly across 15 groups, no duplicate 0.
Two bugs broke Studio "Merge groups" on files where
trace_profiles.properties is empty {}:
1. get_face_groups_handler derived each group's trace_ids from
COALESCE(tp.properties, tn.properties)->>'trace_id'. Since
trace_profiles.properties is {} the value was NULL -> fell back to 0
for every row, so all groups reported trace_ids:[0] and group_uuid:None.
This corrupted Studio's group selection and caused the merge to fail
with "Target group cannot be in source_groups list" (the target name
collided with a corrupted source entry). Now reads the real
tp.trace_id (falling back to tn.properties->>'trace_id').
2. merge_groups_handler matched/updated tkg_nodes.label by the source
group NAME, which silently no-ops when tkg_nodes.label has drifted
out of sync with trace_profiles.name (e.g. after re-cluster), yielding
traces_merged:0. Rewrote it to resolve source trace_ids from
trace_profiles.name, then update both trace_profiles.name and
tkg_nodes.label by external_id=trace_{tid}, keeping both tables in
sync. Also defensively drops the target name from source_groups so a
client echoing the target no longer hard-fails.
Verified on file 9cbeb112 (FilmRiot): 17 groups now map to distinct
trace_ids 0-16; merge Person_4+Person_5 -> Person_0 yields
traces_merged:2 and updates both tp.name and tn.label. Test mutations
were reverted so the file is back to its original 17-group state.
Studio's "delete group" was calling hard_delete which physically removed
_faces points, tkg_nodes and trace_profiles (and silently failed to back
up to a non-existent _faces_trash collection, making undo impossible).
This permanently lost face groups and broke face-groups/cluster-results
(which are based on tkg_nodes) for any trace without a node row.
Changes:
- delete_trace hard-delete now means "restore to unassigned": keep
_faces/tkg_nodes/trace_profiles, only reset name to "Face Trace {id}".
Data is never destroyed so groups can be rebuilt and undo works.
- schema::ensure_face_track_node: create the face_track tkg_nodes row on
write so a trace that lost its node (old hard-delete) reappears in
face-groups/cluster-results (self-healing). Called from
update_trace_profile_handler, update_trace_profile_group_handler and
merge_groups_handler; the group handler also syncs tkg_nodes.label.
- restore_trace / undo_hard_delete_trace: when _faces_trash is empty
(new semantics), rebuild the named group from the operation snapshot
(tkg_nodes ON CONFLICT UPDATE + trace_profiles UPSERT) instead of 404.
Verified live on port 3002 (file bfba056f...): delete -> unassigned with
_faces preserved (4 points), rebuild group -> self-healing creates node
and group shows up, restore -> name restored to original. Also fixed the
pre-existing missing tkg_nodes row for trace 4621 via the same path.
- src/api/profile.rs: new get_cluster_results_handler
- Query param file_hash (Studio passes ?file_hash=)
- Builds face_groups from tkg_nodes + trace_profiles (same grouping as
face-groups handler) with group_id/cluster_id/name/trace_ids/
trace_count/representative_trace
- Scrolls _faces for the file, groups faces by frame into frames[]
- face_id = hex point id (matches identities.rs convention)
- timestamp = frame / fps (from videos table)
- cluster_id = group of the face's trace_id; unassigned faces skipped
- Response: { success, file_uuid, face_groups, frames } matching Studio
PeopleView.vue expected format
- 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)
keyword_search and semantic_search used page_size (default 5)
instead of req.limit, so clients sending limit=N got only 5 results.
Now both handlers respect the limit parameter.
- 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
- tkg.rs: use trace_N as primary external_id, delete duplicate face_track_N nodes
- trace_agent_api.rs: add POST /trace/:id/restore to undo soft delete
- ensure 1:1 mapping: each trace has exactly one TKG node with full profile
- 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
- Update system prompt to prioritize smart_search over find_file
- Add source prefix ([OCR], [ASRX], [ASRX+OCR]) to exec_smart_search results
- Users can now see chunk content with source indicators
- Add [OCR], [ASRX], [ASRX+OCR] prefix to text_content
- Add content field to SemanticSearchResult struct
- Update SQL queries to include content field
- Helps users distinguish the source of search results
- Fix OCR confidence threshold: 0.5 → 0.2
- Fix fetch_ocr_texts frame calculation (use start_frame from DB)
- Fix text_match filter to use text_content instead of summary
- Process all merged results (not just top 30) to include keyword results
- Add logging for keyword search debugging
Fixes issue where OCR text like 'AUDIO MONITORING' and 'thunderbolt'
could not be found via keyword search.
- agent_search.rs: text_region -> text_trace, removed skin_tone_trace
(never built, misleading LLM agents)
- tkg.rs + scan.rs: hand_object -> HAND_OBJECT for consistency with
all other edge types (CO_OCCURS_WITH, SPEAKS_AS, etc.)
- rule2_ingest.rs: added LIP_SYNC and HAND_OBJECT to edge_type
priority list so these edges generate relationship chunks
- Create src/core/db/schema.rs with t() and table_name() functions
- Remove duplicate t() from tkg.rs and trace_agent_api.rs
- postgres_db.rs uses schema::table_name() from shared module
- Created src/core/tkg/ module with service, log, and models
- Added tkg_operation_log table for tracking all TKG operations
- TkgService: build, rebuild (with force option), delete, get_operations
- Updated rebuild endpoint with force parameter
- Added GET /api/v1/file/:file_uuid/tkg for operation history
- Added DELETE /api/v1/file/:file_uuid/tkg for TKG deletion
- TKG rebuild now always triggers Rule 2 (even with 0 edges)
- Full audit trail for all TKG operations (create/update/delete/rebuild)
When a job status is 'completed', all ingestion steps are marked as 'done'
regardless of node/edge counts. This fixes the UI showing pending steps
for completed jobs with 0 nodes/edges (e.g., videos with single speaker).
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
Frontend:
- Add media type filter (全部/影片/照片)
- Add indexed status filter (未入庫/已入庫)
- Show media type column with icons
- Fix status filter to handle indexed/unindexed correctly
- Determine media type from file extension
Backend:
- Add total_chunks field to FileItem API response
- Query chunk counts efficiently in batch with IN clause
- Frontend uses total_chunks to determine is_indexed status
- Added text_content field to SearchResult and SemanticSearchResult
- Added get_chunk_by_id_no_embedding for keyword results without embedding requirement
- Fixed search_bm25 to use position-based ranking for CJK/Korean content
- Fixed sqlx column mapping with explicit alias
- Skip text_match filter for keyword-only results
- Use text_content as fallback when summary is empty
- Frontend calls /api/v1/face-thumbnail?uuid=...&frame=...
- Backend only had /api/v1/file/:file_uuid/thumbnail
- Added compat route and uuid field to ThumbQuery
- Removed trace_chunks field from PostgresStats struct
- Removed trace_chunks query from get_file_stats and get_ingestion_status
- Fixed OCR fetch_ocr_texts to compute frames from start_time*FPS
- Updated scan.rs to use separate count_nodes/count_edges functions
- get_pipeline_progress_handler now queries actual DB counts
- Fixed processor_results query (requires JOIN with monitor_jobs)
- Card progress bar and right-click content now consistent
- tkg_nodes has no edge_type column, query was failing silently
- Split into count_nodes(node_type) and count_edges(edge_type)
- Fixed text_region → text_trace node type name
- Also: OCR frame fix in rule1 (end_frame computed from end_time+FPS)