Skip to content

Feature/face detection multi roll conflict#26

Merged
Rajkoli145 merged 9 commits into
mainfrom
feature/face-detection-multi-roll-conflict
May 23, 2026
Merged

Feature/face detection multi roll conflict#26
Rajkoli145 merged 9 commits into
mainfrom
feature/face-detection-multi-roll-conflict

Conversation

@Soldier224K

@Soldier224K Soldier224K commented May 22, 2026

Copy link
Copy Markdown
Collaborator

closes #19

Raj added 3 commits May 20, 2026 12:07
…ayer

Implements Issue 1: a durable, replay-safe session state manager for the
MAIN Agent.  The module encapsulates four sub-layers:

Models  (models/)
  session_state.py      — SessionLifecycleStage (7-stage FSM enum),
                          SessionState (JSON-serialisable durable fragment),
                          RecordedQuestion/Response, WeakAreaRecord,
                          ContradictionEntry, FollowUpRecord
  transcript_entry.py   — TranscriptEntry with examiner_question /
                          candidate_response factory helpers
  coverage_state.py     — CoverageState + TopicCoverage, recompute_percentage,
                          get_uncovered_planned_topics

Session  (session/)
  history.py            — SessionHistory: OrderedDict-backed, turn-index keyed,
                          deduplication-guarded Q/A store
  transitions.py        — TransitionManager FSM (13 valid edges),
                          InvalidTransitionError, is_terminal
  state.py              — VivaSessionState: MAIN-owned facade combining
                          _state / _history / _coverage
  persistence.py        — SessionPersistence generic adapter with
                          in_memory_persistence() and file_system_persistence()
                          factories — no direct FS/DB coupling

All mutation is explicit via method calls; FSM raises InvalidTransitionError
on illegal edges.  All state classes are dataclass-backed with to_dict() /
from_dict() / to_json() / from_json(), making them independently testable
without the full viva stack.  FollowUpRecord.add_turn() deduplicates on
repeated calls, keeping replay order stable across save/load cycles.
- Add FaceDetectionService for comparing face embeddings via cosine similarity
- Detect same-face usage across multiple roll numbers
- Generate conflict alerts for suspicious identity reuse
- Prevent automatic access on pending review conflicts
- Add API endpoints for face verification and alert management
- Add comprehensive test coverage for all acceptance criteria
@Soldier224K Soldier224K requested review from Rajkoli145 and Copilot and removed request for Copilot May 22, 2026 14:52

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Note

Copilot was unable to run its full agentic suite in this review.

Adds face-embedding based identity verification with conflict alerting (multi roll-number detection), exposes it via API/agent events, and introduces a new VivaSessionManager state/history/persistence layer.

Changes:

  • Implement in-memory face embedding store with cosine-similarity conflict detection + alert lifecycle.
  • Add FastAPI endpoints and onboarding-agent event emission around face verification + manual review workflow.
  • Add new VivaSessionManager modules for session state, transitions, persistence, and transcript records.

Reviewed changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 20 comments.

Show a summary per file
File Description
backend/src/services/face_detection.py New face verification service, conflict alert model, and access gating logic
backend/tests/test_face_detection.py Pytest coverage for face detection behaviors (add/verify/conflict/resolve)
backend/src/main.py Adds /face/* endpoints and request models wired to the face service
backend/src/agents/onboarding.py Integrates face verification into onboarding flow and emits new events
backend/src/models/events.py Adds new event types for face detection + manual review workflow
backend/src/agents/main_agent/VivaSessionManager/session/transitions.py Adds explicit FSM transition validation utilities
backend/src/agents/main_agent/VivaSessionManager/session/state.py Adds top-level viva session state facade (history/coverage/persistence)
backend/src/agents/main_agent/VivaSessionManager/session/persistence.py Adds persistence adapter + in-memory / filesystem factories
backend/src/agents/main_agent/VivaSessionManager/session/history.py Adds deterministic question/response history store
backend/src/agents/main_agent/VivaSessionManager/session/init.py Exposes session-layer public API
backend/src/agents/main_agent/VivaSessionManager/models/session_state.py Adds JSON-serializable session state + record types
backend/src/agents/main_agent/VivaSessionManager/models/coverage_state.py Adds topic coverage tracker
backend/src/agents/main_agent/VivaSessionManager/models/transcript_entry.py Adds transcript entry model + helpers
backend/src/agents/main_agent/VivaSessionManager/models/init.py Exposes model-layer public API
backend/src/agents/main_agent/VivaSessionManager/init.py Package public API exports for VivaSessionManager
Comments suppressed due to low confidence (1)

backend/src/services/face_detection.py:1

  • suspicious is annotated as Dict[str, List[str]] but uses tuple keys, which breaks the type contract and also makes it non-JSON-serializable (tuple keys become invalid for JSON responses). Use a string key (e.g., a stable joined key like 'R001|R002'), or return a list of structured objects instead.
from typing import Optional, List, Dict, Any, Tuple

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread backend/tests/test_face_detection.py
Comment thread backend/tests/test_face_detection.py Outdated
Comment thread backend/tests/test_face_detection.py
Comment thread backend/tests/test_face_detection.py Outdated
Comment thread backend/src/services/face_detection.py
Comment thread backend/src/agents/main_agent/VivaSessionManager/session/state.py
Comment thread backend/src/agents/main_agent/VivaSessionManager/session/transitions.py Outdated
Comment thread backend/src/agents/main_agent/VivaSessionManager/session/history.py
Comment thread backend/src/agents/main_agent/VivaSessionManager/session/persistence.py Outdated
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
@Rajkoli145

Copy link
Copy Markdown
Contributor

@Soldier224K please attach the PR you’re working on

@Soldier224K

Copy link
Copy Markdown
Collaborator Author

Issue 5 :- Face detection conflict

@Rajkoli145 Rajkoli145 merged commit 0858531 into main May 23, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

ISSUE 5 — Identity Conflict Detection Engine

3 participants