Skip to content

Feature/identity history store#33

Open
Soldier224K wants to merge 3 commits into
mainfrom
feature/identity-history-store
Open

Feature/identity history store#33
Soldier224K wants to merge 3 commits into
mainfrom
feature/identity-history-store

Conversation

@Soldier224K

@Soldier224K Soldier224K commented May 23, 2026

Copy link
Copy Markdown
Collaborator

closes #17

Raj added 3 commits May 23, 2026 20:52
- Add AuditLogService for comprehensive identity event logging
- Log verification attempts, face matches/mismatches, suspicious events
- Log admin override actions and examination access decisions
- Add get_timeline() for roll-number or session filtered audit trails
- Add search() for querying audit log content
- Add new event types: VERIFICATION_ATTEMPT, FACE_MATCH, FACE_MISMATCH, SUSPICIOUS_IDENTITY, ADMIN_OVERRIDE, EXAMINATION_ACCESS
- Add API endpoints: /audit/timeline, /audit/search, /audit/events/{type}
- Add 15 tests covering all audit logging functionality
- Add ExaminationAccessDecision for producing access decisions before viva
- Support ACCESS_GRANTED, ACCESS_DENIED, MANUAL_REVIEW_REQUIRED, TEMPORARY_BLOCK outcomes
- Aggregate verification outputs, identity conflict results, safety checks
- Generate explainable access decisions with evidence
- Issue secure examination authorization with decision IDs
- Add 12 tests covering all decision outcomes and flow scenarios
- Add IdentityHistoryStore for persistent face embedding tracking
- Link embeddings with roll numbers and session IDs
- Store exam timestamps and verification results
- Maintain searchable identity history by roll or session
- Deterministic record IDs via SHA256 hashing
- Add 13 tests covering all history tracking scenarios
Copilot AI review requested due to automatic review settings May 23, 2026 15:36

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

This PR introduces an identity history/audit/access-decision layer for backend identity verification flows and exposes audit read endpoints through FastAPI.

Changes:

  • Adds in-memory services for identity history, audit logging, and exam access decisions.
  • Extends event type definitions with audit-related event names.
  • Adds tests for the new services and exposes /audit/* endpoints.

Reviewed changes

Copilot reviewed 8 out of 8 changed files in this pull request and generated 5 comments.

Show a summary per file
File Description
backend/src/services/identity_history.py Adds identity record storage and query helpers.
backend/src/services/audit_log.py Adds audit event logging, timeline, type filtering, and search.
backend/src/services/access_decision.py Adds exam access decision rule engine and decision lookup helpers.
backend/src/models/events.py Adds audit-related EventType enum entries.
backend/src/main.py Instantiates audit log service and adds audit read endpoints.
backend/tests/test_identity_history.py Adds coverage for identity history behavior.
backend/tests/test_audit_log.py Adds coverage for audit logging behavior.
backend/tests/test_access_decision.py Adds coverage for access decision behavior.

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

Comment thread backend/src/main.py

app = FastAPI(title=settings.PROJECT_NAME)
face_service = FaceDetectionService()
audit_log = AuditLogService()
Comment on lines +31 to +36
VERIFICATION_ATTEMPT = "verification.attempt"
FACE_MATCH = "face.match"
FACE_MISMATCH = "face.mismatch"
SUSPICIOUS_IDENTITY = "suspicious.identity"
ADMIN_OVERRIDE = "admin.override"
EXAMINATION_ACCESS = "examination.access"
Comment on lines +130 to +134
confidence = 0.95
else:
decision = AccessDecision.ACCESS_GRANTED
reason = "All verification checks passed"
confidence = 0.95
Comment on lines +152 to +156
def get_decisions_for_roll(self, roll_number: str) -> List[AccessDecisionResult]:
return [
d for d in self._decisions.values()
if roll_number in str(d.evidence.get("verification", {}))
]
query_lower = query.lower()
results = []
for event in self._logs:
payload_str = json.dumps(event.payload).lower()
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 4 — Face History Tracking System

2 participants