Commit Graph

20 Commits

Author SHA1 Message Date
Accusys 1379cf59cf feat: FaceFilterSettings 透明文件管理(自动迁移)
核心特性:
- 读取优先级: 文件 > 数据库 > 默认值
- 自动迁移: 数据库数据自动迁移到文件
- 向后兼容: 旧数据透明处理
- 用户无感知: 不需要手动迁移脚本

工作原理:
1. GET /file-profile
   - 优先从文件读取
   - 文件不存在时从数据库读取
   - 自动创建文件(透明迁移)

2. PUT /file-profile
   - 直接写入文件
   - 数据库不再存储新数据

优势:
- ✅ 零配置迁移(第一次访问自动迁移)
- ✅ 架构简化(文件即 primary source)
- ✅ 跨设备同步(只需同步文件)
- ✅ 调试方便(直接编辑 JSON)

删除:
- ❌ migrate_face_filter_to_files.py(不需要)

文档更新:
- docs_v1.0/DESIGN/FACE_FILTER_FILE_STORAGE.md
- 说明透明管理机制
- 添加自动迁移流程图

Git: 3658c288 (enhanced)
2026-10-09 16:38:20 +08:00
Accusys 3658c2888e feat: FaceFilterSettings 改用文件存储而非数据库
架构变更:
- GET /api/v1/file-profile: 从 .profile.json 读取 face_filter
- PUT /api/v1/file-profile: 写入 .profile.json 而非数据库
- 数据库不再存储 face_filter (仅存储路径/文件名)

优势:
- 文件是 primary source of truth
- 架构更简单、更清晰
- 便于跨设备同步
- 避免 DB 迁移复杂度

新增工具:
- migrate_face_filter_to_files.py: 迁移现有数据库数据到文件
- 支持增量迁移(只迁移有变化的文件)
- 支持 dry-run 测试

测试:
- ✅ 编译通过
- ⏳ 功能测试待进行

对应设计文档:
- .opencode/plans/persistence_design/01_overview.md
- 三段式实体文件持久化架构
2026-10-09 16:30:50 +08:00
Accusys 86c776ce41 feat: 更新 FaceFilterSettings 为三段式统一结构
数据模型更新:
- 新增 UiFilterRules 结构(UI 过滤规则)
- 新增 ProcessingThresholds 结构(处理阈值)
- 新增 TraceSettings 结构(Trace 配置)
- FaceFilterSettings 整合三个子结构
- min_confidence 范围从 0-100 改为 0.0-1.0
- min_size 重命名为 min_bbox_size
- 新增字段: max_confidence, max_bbox_size, source, backend_status

向后兼容性:
- 新增 from_legacy() 方法自动转换旧格式
- defaults() 方法自动转换 0-100 到 0.0-1.0

测试:
- 更新 test_face_filter_roundtrip
- 更新 test_face_filter_defaults_match_detection_defaults
- 新增 test_face_filter_new_method
- 新增 test_face_filter_from_legacy
- 所有测试通过 ✅

文件修改:
- src/core/file_profile.rs: 数据结构定义(+150 行)
- src/core/processor/vlm_summary.rs: 字段访问更新
- src/api/identities.rs: 字段访问更新
- src/api/profile.rs: 字段访问更新(3 处)
- migrations/20261009_face_filter_v2.sql: 数据库迁移脚本

状态: P0 第 1 个文件完成
2026-10-09 14:42:26 +08:00
Accusys 357e585399 fix: Face processor now saves status and total_faces to face.json 2026-09-26 23:06:11 +08:00
Accusys 474a5bee99 refactor: remove YOLO processor and dependencies
- 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
2026-09-17 16:56:25 +08:00
Accusys 9f12e835b8 feat: add TraceArtifacts phase + VLM waits for all key_frame.jpg
- 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
2026-08-24 19:13:11 +08:00
Accusys c1e158a368 fix: trace-profile API SQL errors (missing FROM alias + null decoding)
Two pre-existing bugs broke rename/get operations:

1. schema.rs: DO UPDATE referenced 'tp' alias from LEFT JOIN which is
   invisible in ON CONFLICT scope → 'missing FROM-clause entry for table tp'
   Fix: use {tp_table}.column instead of tp.column

2. profile.rs: SELECT tp.properties / tn.properties can be NULL when no
   trace_profile row exists but decoder expected non-optional Value
   → 'unexpected null; try decoding as an Option'
   Fix: decode as Option<serde_json::Value> and handle None in merge logic
2026-08-12 05:51:12 +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 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 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 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 85d5e1fe51 feat: trace_id i64→i32 fix, OCR search filter, Rule1 OCR trigger
- Fix trace_id SQL type mismatch: i64 → i32 in profile.rs structs and queries
- Add /ocr /asr /asrx search filter suffix to keyword/semantic/smart search
- Fix fetch_ocr_texts to handle both OCR data formats (string array + object array)
- Add has_ocr trigger for Rule1 chunk ingestion in job_worker.rs
- Add search_bm25 chunk_type filter parameter
- Fix single-frame video clip duration (0-frame → 1-frame minimum)
- Re-run Rule1 for 14 files with stuck OCR in pre_chunks
2026-07-30 19:34:35 +08:00
Accusys 39a2cbc65b fix: face group name read consistency, sync_file_status fix, cleanup ghost records, identity_agent replaced with face_dedup
- 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
2026-07-27 02:15:51 +08:00
Accusys 0ad6927d25 feat: fix TKG external_id mismatch, add trace delete/merge endpoints, fix no-faces progress update
- identity_binding.rs: match both face_track_N and trace_N external_id formats in bind/unbind/create_pending_person
- profile.rs: fix external_id matching and parameter ordering in trace profile updates
- trace_agent_api.rs: add DELETE /trace/:id (soft/hard delete) and POST /trace/:src/merge/:target endpoints
- qdrant_db.rs: add delete_points_by_filter method
- tkg.rs: add debug logging for scroll and parse operations
- job_worker.rs: update progress for no-faces TKG path
2026-07-21 02:45:34 +08:00
Accusys d0b7bfa56b feat: add pose and appearance endpoints for face detail display
- Add GET /api/v1/file/:file_uuid/pose endpoint
- Add GET /api/v1/file/:file_uuid/appearance endpoint
- Keypoint deduplication (highest confidence)
- Add face-groups endpoint for Studio integration
- Add profile routes (trace-profile, file-profile)
- Update API documentation
2026-07-19 20:43:35 +08:00
Accusys 87aa7e0c40 feat: add source prefix to search results
- 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
2026-07-19 14:06:06 +08:00