Commit Graph

629 Commits

Author SHA1 Message Date
Accusys 4fc7d0cf6d docs: add Studio team face filter usage guide
- Comprehensive API usage guide for Studio team
- Includes all 6 API endpoints with examples
- Complete TypeScript code examples
- Filtering strategies and best practices
- Performance optimization recommendations
- Based on FaceNet analysis results from WD and KOBA videos

This document enables Studio team to integrate face filtering
functionality efficiently.
2026-08-09 19:27:35 +08:00
Accusys dfa515f249 feat: add bbox_size field for frontend filtering
- Database: Added bbox_size column (min(width, height)) to face_filter_features
- API: Updated all endpoints to include bbox_size in responses
- Documentation: Added bbox_size explanation and frontend filtering examples
- Maintains current Swift implementation calculation method
- Enables efficient frontend filtering without backend threshold

This allows the frontend to do real-time filtering using bbox_size
while the backend pre-computes and stores the value.
2026-08-09 19:05:09 +08:00
Accusys 9b6750b85e feat: implement face filter API for GUI filtering mechanism
- Database schema: face_filter_features and filter_rules tables
- Core engine: FilterEngine with 4 filter rules (landmark, mediapipe, embedding, temporal)
- API endpoints:
  - GET /faces - Get faces with filtering
  - GET /face/{id}/filter-report - Get filter report for single face
  - POST /faces/filter - Apply filter rules
  - GET /filter-stats - Get filter statistics
  - GET/POST /filter-rules - Manage filter rules
- API documentation for Studio team with examples
- Based on FaceNet analysis results from WD and KOBA videos
2026-08-09 17:11:07 +08:00
Accusys 575623c765 docs: add cross-video FaceNet analysis report (WD vs KOBA)
- Completed FaceNet experiments on KOBA video (120 samples)
- Cross-video analysis confirms:
  - Face size impact on stability is CONSISTENT (Large > Medium > Small)
  - Bbox quality is CONSISTENT (Apple Vision ≈ MediaPipe)
  - Recognition accuracy depends on video content
- Key recommendations:
  - Minimum face size: 80px
  - Bbox strategy: Apple Vision (default) or MediaPipe (efficient)
  - Quality metric: Minimum similarity > 0.70
- Based on 240 total samples across 2 videos
2026-08-09 15:57:10 +08:00
Accusys 1f71ab4e14 docs: add FaceNet retest analysis report
- Completed 3 experiments using real FaceNet model (Inception ResNet V1)
- Key findings:
  - Large faces (>150px) have highest stability (0.9995)
  - Apple Vision and MediaPipe bboxes produce identical quality (0.899)
  - Face size affects recognition accuracy lower bound (0.760 vs 0.648)
- Recommendations:
  - Minimum face size: 80px
  - Ideal face size: >150px
  - Both AV and MP bboxes are acceptable
- Included detailed comparison with simplified model results
2026-08-09 14:43:33 +08:00
Accusys 61b774ab0b docs: add embedding vs face size analysis report
- Completed 3 experiments on WD video with 120 samples
- Key findings:
  - Apple Vision bbox produces higher quality embeddings (0.841 vs 0.748)
  - MediaPipe bbox is more precise but lower quality
  - Recommendation: Use Apple Vision bbox for embedding calculation
- Included detailed methodology, results, and recommendations
- Suggested bbox selection strategy and size filtering thresholds
2026-08-09 14:25:44 +08:00
Accusys 496895422f docs: add MediaPipe threshold POC report
- Tested confidence thresholds: 0.1, 0.2, 0.3, 0.4, 0.5
- Key finding: 0.3 is optimal threshold
  - Zero false positives (correctly rejects frames 671, 1116)
  - Same detection rate as 0.5 (100%)
  - More permissive than 0.5, may detect more faces in other videos
- Recommendation: Use 0.3 as default min_confidence for MediaPipe
- Updated dual-source filtering strategy:
  - Apple Vision: primary detector (min_confidence=0.5, min_size=1)
  - MediaPipe: verifier (min_confidence=0.3)
2026-08-09 13:36:51 +08:00
Accusys e1eae6a3d9 test: MediaPipe 1.0.0 vs 0.10.35 comparison results
- Upgraded MediaPipe from 0.10.35 to 1.0.0
- Re-ran same frame comparison experiment
- Key finding: MediaPipe 1.0.0 and 0.10.35 have identical performance
- Both versions: 2.5% recall, 100% precision (zero false positives)
- Apple Vision: 96.1% recall, 0% precision (3 false positives)
- Conclusion: MediaPipe is very conservative but reliable for false positive rejection
2026-08-09 12:55:49 +08:00
Accusys c7690f43d2 docs: add MediaPipe vs Apple Vision landmark comparison report
- Parallel detection on same frames (0, 3, 6, 9, 100, 200, 300, 400, 500, 671, 800, 1000, 1116, 1500)
- MediaPipe saves results as .mp_face.json format
- Key finding: MediaPipe 100% rejects false positives (frames 671, 1116)
- Trade-off: MediaPipe has lower recall (62.5% vs 100% for Apple Vision)
- Recommendation: Consider combining both detectors for best precision/recall balance
2026-08-09 12:42:56 +08:00
Accusys 5045d9f679 docs: update face_settings guide with correct log verification steps
- Updated log paths and examples to match actual implementation
- Added [WORKER] log verification
- Fixed swift_face log path (file_uuid.face_detect.json.log)
2026-08-08 23:24:08 +08:00
Accusys 1571f675a5 fix: worker reads face_settings from job and sets env vars for face processor
- 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.
2026-08-08 23:16:35 +08:00
Accusys 658f509500 fix: pass face_settings to create_monitor_job in register and process endpoints
- files.rs: register_file now converts FaceSettings to json and passes to create_monitor_job
- processing.rs: ProcessRequest now includes face_settings field
- processing.rs: trigger_processing now passes face_settings to create_monitor_job and updates existing jobs
- docs: updated API examples to use correct endpoints (/api/v1/files/register and /api/v1/files/:uuid/process)
2026-08-08 22:16:06 +08:00
Accusys d5c7fd91d9 docs: add face_settings studio guide for Studio team reference
- Complete guide for FACE_MIN_CONFIDENCE and FACE_MIN_SIZE configuration
- Includes environment variable setup (shell export + launchd plist)
- API parameter examples with curl commands
- Log verification steps for all three layers (Rust/Python/Swift)
- Recommended values for different scenarios
- Database schema documentation
- FAQ section for common issues
2026-08-08 21:55:25 +08:00
Accusys 8d83d9f217 fix: replace dev schema defaults with public
- schema.rs: Change DATABASE_SCHEMA default from 'dev' to 'public'
- rule2_ingest.rs, files.rs, tools.rs, scan.rs: Same schema default fix
- files.rs, watcher.rs, processing.rs: Change output_dev to output
- identities.rs: Change API schema parameter default from 'dev' to 'public'
- postgres_db.rs: Add face_settings column to SELECT query (fix ColumnIndexOutOfBounds panic)

This fixes worker not processing jobs due to missing dev schema.
2026-08-08 17:35:23 +08:00
Accusys 8dada662e8 fix: add parameter logging for face detection settings
- swift_face.swift: Log MIN_CONFIDENCE and MIN_SIZE at startup
- face_processor.py: Log settings passed to swift_face subprocess
- executor.rs: Log face settings being passed to Python subprocesses (4 run methods)
- Enables debugging of face detection parameter chain

Test results:
- FACE_MIN_CONFIDENCE=0.5, FACE_MIN_SIZE=1 → 392 faces (195 frames with 2 faces)
- SwiftFace log shows: MIN_CONFIDENCE=0.5, MIN_SIZE=1
- face_processor.py log shows: Settings passed to swift_face: FACE_MIN_CONFIDENCE=0.5, FACE_MIN_SIZE=1
2026-08-08 16:10:47 +08:00
Accusys a06973484b fix: pass FACE_MIN_CONFIDENCE and FACE_MIN_SIZE env vars to swift_face subprocess
- executor.rs: Add cmd.env() for FACE_MIN_CONFIDENCE and FACE_MIN_SIZE in all 4 run methods
- face_processor.py: Pass os.environ to subprocess.Popen to inherit env vars
- Fixes multi-face detection issue where second face was being filtered out
- Tested: CONFIDENCE=0.5 preserves both faces (392 total), CONFIDENCE=0.75 filters second face (196 total), SIZE=100 filters small faces (201 total)
2026-08-08 15:41:26 +08:00
Accusys 256e872fd9 fix: swift_face.swift reads MIN_CONFIDENCE and MIN_SIZE from env vars
- FACE_MIN_CONFIDENCE env var (default 0.75)
- FACE_MIN_SIZE env var (default 64)
- Allows per-file threshold configuration via environment
2026-08-08 04:19:45 +08:00
Accusys 606f4ce5be feat: add per-file face_settings (min_confidence, min_size) support
- DB: Added face_settings jsonb column to monitor_jobs
- API: RegisterFileRequest accepts face_settings
- DB: create_monitor_job accepts and stores face_settings
- MonitorJob struct includes face_settings field
- Swift face processor will read from FACE_MIN_CONFIDENCE and FACE_MIN_SIZE env vars
2026-08-08 04:17:05 +08:00
Accusys c184711bfc fix: thumbnail cache headers - no-cache + ETag for browser revalidation
- Changed Cache-Control from 'public, max-age=86400' to 'no-cache, must-revalidate'
- Added ETag header (sha256 hash of image bytes)
- Browser will revalidate on each request
- If file unchanged → 304 Not Modified (save bandwidth)
- If file changed → 200 with new image
- Applied to all thumbnail endpoints (trace, face, chunk, live extraction)
2026-08-08 02:13:14 +08:00
Accusys 1d3638649b fix: trace-thumbnail cache-control changed to no-cache for testing
- 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
2026-08-07 19:28:50 +08:00
Accusys 9244dbc853 fix: rebuild key_face.jpg for KOBA file with VFR-correct frames
- Force rebuilt all 37 traces for file 5e207a246fd6a2a65ee0a267440465ee
- Used select=eq(n\,frame) for VFR compatibility
- Each trace now uses best face (highest confidence) frame
2026-08-07 16:46:22 +08:00
Accusys ca8b910d59 fix: schema.rs COALESCE加固 + rebuild_trace_thumbs tool
- schema.rs: ON CONFLICT 加入 COALESCE 避免 edge case 把回填值打回 NULL
- rebuild_trace_thumbs: 從 Qdrant _faces 找 best face 重建 key_face.jpg
- 已完成 61/10184 traces(工具運作中,大檔案需較長時間)
2026-08-07 15:55:30 +08:00
Accusys b52777ac03 feat: add backfill_trace_profiles tool + backfill 8250 traces avg_confidence
- Created src/bin/backfill_trace_profiles.rs
- Queries Qdrant _faces once per file (optimized)
- Calculates avg confidence per trace
- Updates trace_profiles.avg_confidence and tkg_nodes.properties
- Backfilled 8250/9877 NULL traces (remaining 102 are edge cases without Qdrant data)
2026-08-07 14:26:39 +08:00
Accusys cd8df324be fix: tkg.rs avg_confidence moved before props construction + schema.rs ON CONFLICT backfill derived fields
- tkg.rs: avg_confidence calculation moved to line 1207 (before props json)
- tkg.rs: Added 'avg_confidence' to props json (round4)
- schema.rs: ON CONFLICT DO UPDATE expanded to backfill start_frame, end_frame,
  frame_count, key_frame, key_face, avg_confidence from tkg_nodes.properties

This fixes trace_profiles.avg_confidence always being NULL, and enables
automatic self-healing when upsert_trace_profile is called from any caller.
2026-08-07 14:04:54 +08:00
Accusys 64f5e3f543 feat: add request logging middleware for all API calls
- 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
2026-08-06 09:50:20 +08:00
Accusys 23c6f63742 feat: add face search API at trace level for People page FS filtering
- GET /api/v1/file/:file_uuid/faces/search
- q parameter: trace_id substring, frame fall-through, range overlap, name substring
- binding filter: assigned/unassigned
- min_confidence filter
- Pagination with page/page_size
- Response includes trace_id, file_uuid, file_name, name, start_frame, end_frame, frame_count, thumbnail_url
- SQL-based filtering with indexes on name/file_uuid for performance
2026-08-05 21:40:07 +08:00
Accusys a6d705abf1 fix: VFR frame extraction - use select=eq(n) instead of -ss frame/fps
- 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.
2026-08-05 12:36:25 +08:00
Accusys 2117ca60b8 fix: trace thumbnail now uses trace_profile key_face.jpg for consistency
- 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)
2026-08-05 02:42:38 +08:00
Accusys 15967929ef fix: ASR fails to find cut.json when executor uses .tmp output path
- ASR script used output_path.replace('.asr.json', '.cut.json') to find CUT file
- Executor passes output path with .tmp suffix (xxx.asr.json.tmp)
- This produced wrong path: xxx.cut.json.tmp (doesn't exist)
- Fix: use --uuid to construct CUT path from output_dir instead
- Also added executor Full command logging for debugging

Fixed IMG_9449 (1).MOV ASR failure: status changed from failed → completed
2026-08-05 01:45:59 +08:00
Accusys 3d13a06bd9 feat: face fix deployment + trace_* regeneration + executor stderr filter fix
- swift_face.swift: frame rounding (.rounded()), conf 0.75, min_size 64
- trace_* directories regenerated for KOBA (37 traces, start_frame 5307)
- executor.rs: stderr filter now logs all non-empty stderr (was discarding)
- VAD not skippable in ASRX (main_fixed.py Step 2 always runs)
- Step 2.5 sentence boundary refinement added
- Cluster agent async endpoints + similarity transparency
- Keyword search: relationship text extraction, priority ordering
- Face fix handoff doc for Studio team
2026-08-05 00:13:50 +08:00
Accusys 36a704e3d3 fix: two issues - per-job concurrency budget + face_cluster race condition
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.
2026-08-03 12:18:22 +08:00
Accusys c5c1b08ffd feat: add trigger source and reason logging to unregister
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.
2026-08-03 08:55:44 +08:00
Accusys 4d0d2204fd fix: auto-update face track labels after clustering in worker pipeline
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.
2026-08-03 08:09:16 +08:00
Accusys 975c72eb49 fix: add trace_profiles deletion to unregister
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
2026-08-03 07:17:40 +08:00
Accusys 5244386892 fix: executor output_idx corrupting --file-uuid arg in store_traced_faces.py
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.
2026-08-02 20:53:51 +08:00
Accusys e22393d577 feat: permanent trace delete (mode:delete) + best-face fields in /traces
- delete_trace: add mode:'delete' → permanent removal (Qdrant points,
  trace_profiles, tkg_nodes, on-disk files), no undo/history written
- list_unassigned_traces: exclude status=deleted (REQ-2), consistent
  with /traces endpoint
- /traces: return real best_face_id/frame/confidence/bbox (highest
  confidence face per trace) instead of start_frame/avg_confidence
- docs: Studio delete Core req + FS detail fix patch + handoff v2
2026-08-02 14:18:44 +08:00
Accusys 8eb130959c fix: keep user-named single-trace groups in face-groups
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)
2026-08-01 06:24:00 +08:00
Accusys 1602656fb6 docs: add trace-thumb endpoint to Studio handoff 2026-08-01 02:28:52 +08:00
Accusys 57f542fdad perf: add /api/v1/trace-thumb/:uuid/:tid endpoint
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}
2026-08-01 02:28:15 +08:00
Accusys d7980133e9 docs: update Studio handoff with Core API配套 changes
Added Core API optimizations already deployed:
- Thumbnail API uses pre-cached key_face.jpg (8ms vs 500ms)
- Face-groups API supports ?include_trace_ids=false (-48% payload)

Updated Studio instructions to use these new endpoints.
2026-08-01 02:12:43 +08:00
Accusys 8a766799c7 perf: optimize face thumbnail loading + reduce face-groups payload
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
2026-08-01 02:08:00 +08:00
Accusys 4ca967e979 docs: Studio face group performance optimization handoff
Document for Studio team to implement lazy loading + concurrency increase
for face group thumbnail loading. Expected improvement: Charade load time
from ~76s to <2s.
2026-08-01 01:58:50 +08:00
Accusys d6653f8240 feat: async unregister mode for large files
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).
2026-07-31 18:30:27 +08:00
Accusys 4c8041974a fix: executor .tmp output handling clobbered fresh script results
run_with_frames / run_with_output_idx / run_with_output_idx_and_frames
had an inverted .tmp-file flow:

1. Before spawning, if the final .json existed it was renamed to .json.tmp
   (the OLD output set aside as "tmp").
2. The script was passed the FINAL .json path, so it wrote fresh data there.
3. On success, .json.tmp (the OLD/empty file) was renamed back OVER the
   fresh .json, discarding the new result.

For face clustering this meant the freshly-clustered 2-person result was
always overwritten by the stale/empty previous face_cluster.json, so the
cluster agent reported "0 clusters" and Face Deduplication matched nothing.

Fix: remove the bogus pre-rename and instead pass the .tmp path to the
script as its output argument, then promote .tmp -> .json only on success.
This guarantees the fresh result is what lands in the final file. Applied
identically to all three run_* helpers.

Verified on 9cbeb112 (FilmRiot): cluster-agent now returns 2 clusters /
17 traces and face_cluster.json contains the real clustering (was 0).
2026-07-31 14:59:37 +08:00
Accusys d91ce0b4fc fix: cluster-results trace_id mapping (same bug as face-groups)
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.
2026-07-31 14:45:09 +08:00
Accusys 4a480f46fd fix: face-groups trace_id mapping + robust group merge
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.
2026-07-31 14:04:16 +08:00
Accusys 40fc8c6a53 fix: group delete semantics - unassign instead of destroy, self-heal tkg_nodes
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.
2026-07-31 13:14:23 +08:00
Accusys d36132d93a feat: add GET /api/v1/cluster-results endpoint for Studio face groups
- 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
2026-07-31 11:58:36 +08:00
Accusys aab727b297 docs: trace_profile UPSERT fixes + Studio face group API gap analysis
- 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)
2026-07-31 11:16:18 +08:00
Accusys 7272077b65 docs: trace_profile UPSERT fix plan with delete/undo/restore flow diagrams 2026-07-31 10:46:31 +08:00