Merged
Conversation
4cd2c80 to
255c84a
Compare
c5fe0e0 to
3bb3bad
Compare
wailbentafat
approved these changes
Mar 25, 2026
Collaborator
wailbentafat
left a comment
There was a problem hiding this comment.
file structure is wrong u will fix it in the next pr
Collaborator
Author
|
Bon. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR implements a single‑face image matching worker driven by JetStream/NATS. The worker listens for face‑match requests, fetches images from MinIO, generates embeddings for single‑face images only, matches against users via pgvector similarity, and records the match. The flow is event‑driven, idempotent, and includes explicit guardrails + logging for failure modes.
Full Workflow
Event Trigger
A job is published to photo_faces.single.requested (JetStream).
Payload includes photo_id, image_ref, optional face_index, optional faces_detected, and extra metadata (ignored).
Subscription & Validation
SingleFaceMatchWorker subscribes using a durable consumer.
Payload is validated via SingleFaceMatchJob; malformed payloads are logged and skipped.
Guardrails
If faces_detected is provided and != 1 → skip
If image_ref missing → skip
If photo_id not found → skip
If match already exists for photo → skip (idempotency)
4) Image Fetch (MinIO)
image_ref is parsed and fetched from MinIO.
Transient failures are retried with linear backoff.
Face Detection / Embedding
Image is decoded; all faces are detected.
If not exactly one face → skip.
Embedding + bounding box extracted.
Upsert photo_faces
Writes photo_id, face_index, embedding, bbox.
DB errors are logged + rolled back.
User Matching
Finds closest user via pgvector similarity:
ORDER BY face_embedding <=> :embedding LIMIT 1
If no user embeddings → skip.
Insert face_matches
If match doesn’t exist, insert new row with confidence = distance.