Feature/identity history store#33
Open
Soldier224K wants to merge 3 commits into
Open
Conversation
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
Contributor
There was a problem hiding this comment.
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.
|
|
||
| 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() |
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.
closes #17