Skip to content

Issue 21 admin review workflow#35

Open
Soldier224K wants to merge 4 commits into
mainfrom
issue-21-admin-review-workflow
Open

Issue 21 admin review workflow#35
Soldier224K wants to merge 4 commits into
mainfrom
issue-21-admin-review-workflow

Conversation

@Soldier224K

@Soldier224K Soldier224K commented May 24, 2026

Copy link
Copy Markdown
Collaborator

closes #21

Raj added 4 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
- Add AdminReviewWorkflow service for flagging/approving/rejecting conflicts
- Integrate with AuditLogService for override action logging
- Integrate with IdentityHistoryStore for prior face history inspection
- Add comprehensive tests covering full admin review workflow
Copilot AI review requested due to automatic review settings May 24, 2026 11:32

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

Adds an in-memory admin review + audit logging + access-decision layer around suspicious identity conflicts (Issue #21), with accompanying unit tests and new API endpoints to query audit timelines.

Changes:

  • Introduces new service modules: IdentityHistoryStore, AuditLogService, AdminReviewWorkflow, and ExaminationAccessDecision.
  • Adds /audit/* endpoints to retrieve/search audit events.
  • Adds comprehensive unit tests for the new services and access-decision behavior.

Reviewed changes

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

Show a summary per file
File Description
backend/tests/test_identity_history.py Adds tests for identity-history storage/query helpers.
backend/tests/test_audit_log.py Adds tests for audit event logging, querying, and search.
backend/tests/test_admin_review_workflow.py Adds tests for conflict flagging, approve/reject, and audit logging side-effects.
backend/tests/test_access_decision.py Adds tests for access-decision outcomes across verification/conflict/safety inputs.
backend/src/services/identity_history.py Adds an in-memory identity record store with indexing and event extraction helpers.
backend/src/services/audit_log.py Adds an in-memory audit event log with basic query/search APIs.
backend/src/services/admin_review_workflow.py Adds an in-memory admin review workflow that logs override/access events.
backend/src/services/access_decision.py Adds access decision logic and a decision history store.
backend/src/models/events.py Adds new EventType entries for audit-log-related events.
backend/src/main.py Adds new /audit/* API endpoints and a module-level AuditLogService instance.

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

Comment on lines +85 to +89
evidence["verification"] = {
"verified": verification.verified,
"confidence": verification.confidence,
"timestamp": verification.timestamp.isoformat(),
}
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", {}))
]
Comment on lines +109 to +113
elif conflict and conflict.has_conflict:
if conflict.status == "pending_review":
decision = AccessDecision.MANUAL_REVIEW_REQUIRED
reason = f"Identity conflict pending review: {conflict.conflict_id}"
else:
Comment on lines +52 to +55
def _generate_conflict_id(self, roll_number: str, matched_rolls: List[str], timestamp: datetime) -> str:
sorted_rolls = sorted([roll_number] + matched_rolls)
raw = f"{timestamp.isoformat()}:{','.join(sorted_rolls)}"
return hashlib.md5(raw.encode()).hexdigest()[:12]
confidence_scores: List[float],
session_id: Optional[str] = None,
) -> ReviewConflict:
timestamp = datetime.now(timezone.utc)
Comment on lines +48 to +50
self._conflicts: Dict[str, ReviewConflict] = {}
self._audit_log = audit_log or AuditLogService()
self._identity_history = identity_history or IdentityHistoryStore()
Comment on lines +46 to +49
event = AuditEvent(
event_id=self._generate_event_id(roll_number, "verification_attempt", datetime.now(timezone.utc)),
timestamp=datetime.now(timezone.utc),
event_type="verification_attempt",
Comment on lines +30 to +33
class AuditLogService:
def __init__(self):
self._logs: List[AuditEvent] = []

Comment thread backend/src/main.py
Comment on lines +104 to +113
@app.get("/audit/timeline")
async def get_audit_timeline(roll_number: Optional[str] = None, session_id: Optional[str] = None):
result = []
if session_id:
result = audit_log.get_session_timeline(session_id)
elif roll_number:
result = audit_log.get_timeline(roll_number)
else:
result = audit_log.get_timeline()
return result
Comment on lines +30 to +36
# Audit Log Events
VERIFICATION_ATTEMPT = "verification.attempt"
FACE_MATCH = "face.match"
FACE_MISMATCH = "face.mismatch"
SUSPICIOUS_IDENTITY = "suspicious.identity"
ADMIN_OVERRIDE = "admin.override"
EXAMINATION_ACCESS = "examination.access"
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 7 — Admin Review & Override System

2 participants