fix(api): admit owner_recognized faces with re-armed pending embeddings in owner-face-embeddings feed #987
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/face-feed-owner-recognized"
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?
Problem
After a soft people clustering reset ("Personen-Clustering zurücksetzen"), face recognition goes silent for the affected owner.
PeopleClusteringResetService(soft reset) removes occurrences but deliberately leaves faces indiscovery_results.state = 'owner_recognized'— its own comment says "the face stays in the recognition pool" — and re-arms their embeddings aspending_face_embeddingsrows (provenancesourceType='people_clustering_reset').However, the pending branch of the
OwnerFaceEmbeddingsControllerfeed's UNION ALL CTE filtereddr.state = 'owner_tentative'only. The re-armedowner_recognizedfaces matched the pending-embedding join but were rejected by the state predicate, making them invisible to every subsequent recognition run.Verified production impact: ~17,970
owner_recognizedfaces of the affected owner were excluded. The worker then clustered an 8,681-face pool whose density graph had zero triangles and correctly emitted 0 candidates — recognition produced no suggestions at all.Same bug family as ISSUE-082 (confirmed anchors disappeared from matching after auto-accept, fixed in PR #976).
Root cause
Branch 2 of the CTE in
OwnerFaceEmbeddingsController#getOwnerFaceEmbeddings:The soft reset's contract is: occurrences go away, the face stays in the recognition pool via a re-armed pending embedding. The feed's pending branch broke that contract by admitting only
owner_tentative.Fix
Widen the pending branch state filter:
Nothing else changes:
rn = 1per(face_annotation_id, model_name, model_version); the globalrankedCTE preferssource='accepted'over'pending'. A face that regains a live accepted occurrence still resolves to its accepted embedding even when a re-armed pending row coexists (pinned by test).owner_recognizedface with neither a pending embedding nor an accepted occurrence is still excluded (pinned by test).Test evidence
All in
OwnerFaceEmbeddingsControllerTest(Testcontainers Postgres, mirroring the existing suite):returnsOwnerRecognizedFaceWithReArmedPendingEmbeddingdoesNotReturnOwnerRecognizedFaceWithoutPendingEmbeddingOrAcceptedOccurrenceacceptedOccurrenceStillWinsOverPendingEmbeddingForSameFaceLocal runs:
rtk ./gradlew :apps:api:test --tests '*OwnerFaceEmbeddings*'→ 6/6 passedrtk ./gradlew :apps:api:test --tests 'dev.memories.api.people.*'→ 199/199 passed, 0 failures (21 test classes, 2m16s)