fix(people): face pipeline — B1 remove unsound rekey + B2 locking/insert-only acceptance #718
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/face-pipeline-embedding-flush"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Scope fix (replacement head:
fix/face-pipeline-b1b2-locks@e25b72f54194556a36ab6357a87a73e5af798a87)Replaces the original head
fix/face-pipeline-embedding-flush@1d7d8e14per the review-718 integrity adjudication.Worker-side vectorized clustering from the replaced head is preserved on the frozen worktree and lands separately.B1 — embedding-flush scheduler — removal rationale
PendingEmbeddingReconciliationScheduler.rekeyLegacyFaceOccurrencesis REMOVED, not fixed. The "exactly one tentative face on the media" heuristic is unsound for any photo with 2+ faces: several fallback occurrences raced the same unique constraint (DuplicateKeyException, observed live) and a guess would silently move owner data. Scope of this PR is future-data repair only; existing fallback-keyed occurrences are intentionally left as-is.B2 — automated acceptance is locking + insert-only
letFacesForUpdate: deterministic sortedSELECT … FOR UPDATEon the pre-existingdiscovery_resultsface rows (lock order: face rows → class_instances → occurrences).insertOccurrenceNoSteal:ON CONFLICT (domain_key, owner_id, occurrence_type, occurrence_key) DO NOTHING RETURNING id(H2MERGE KEYfixture fallback). Automated paths NEVER update/reassign an already accepted occurrence.new_person_cluster; mixed clusters d�eduplicate per-face viafilterAssignedFaceRefs; a candidate whose faces are all accepted elsewhere is decidedrejected(lost_insert_race/all_faces_already_assigned) WITHOUT creating an empty person.allowMove=false,skipped_assigned_refsskip note.allowMove=true.ClassInstanceService.upsertGenericPeopleOccurrencetakes a single-face FOR UPDATE lock; regression-scope callers verified@Transactional, legacy retrospective entry point annotated.Evidence
Pr718IntegrityRegressionTest(7 cases incl. 2 b1/5 b2)e25b72f5PendingEmbeddingReconciliationSchedulerTest:apps:api:testfull suite:apps:worker-media:testRecovery limitations (honest)
Existing data is NOT fully resolved by this PR:
occurrence_refs/representative_evidence/existing_instance_id— no fuzzy matching.mitigated, ceiling documented in KNOWN_ISSUES.fix(people): face pipeline — occurrence keys/embedding flush, loop guard, vectorized clusteringto fix(people): face pipeline — B1 remove unsound rekey + B2 locking/insert-only acceptanceB1: PendingEmbeddingReconciliationScheduler no longer re-keys legacy fallback-keyed occurrences ("mediaItemId:index") — the single-face heuristic is unsound for multi-face media (DuplicateKeyException + permanently-wrong assignments on the owner DB). Fallback-keyed rows stay untouched; repair moves to a future exact-ID admin recovery endpoint. B2: ClassInstanceDiscoveryService acceptance is now locking + insert-only for automated paths (review-718 invariant I1/I2): - letFacesForUpdate: deterministic SELECT ... FOR UPDATE on the pre-existing people discovery_results face rows (lock order: face rows -> class_instances -> occurrences) - insertOccurrenceNoSteal: ON CONFLICT DO NOTHING RETURNING (H2 MERGE fallback), auto path never updates/reassigns an accepted occurrence - M1 auto-create gated to new_person_cluster; mixed cluster dedupes via filterAssignedFaceRefs; all-assigned candidate decided rejected (lost_insert_race) without an empty instance - M2 policy auto-accept locked + allowMove=false + skip decision - M3/M4 manual owner decisions lock first and keep allowMove=true - M5 upsertGenericPeopleOccurrence takes single-face FOR UPDATE; retrospective entry point annotated @Transactional Tests: ported 7 red Pr718IntegrityRegressionTest cases (now green, sen-1-approved helper semantics: counted non-empty persons + direct no-steal ownership asserts) + scheduler manifest seed; legacy auto-create fixtures aligned to insert-only semantics; version 1.21.29.