Repository navigation
Conversation
…emoryReplSet
- Replace MongoMemoryServer (standalone, no transactions) with
MongoMemoryReplSet so MongoDB transactions used by CourseService and
AnomalyService work correctly in the test environment.
- Fix InversifyJS container wiring for tests: use unbind()+bind() instead
of the removed rebind() chain, and rebind GLOBAL_TYPES.Database so a
fresh MongoDatabase is constructed with the correct in-memory URI
(bypassing the hardcoded ssl/tls options).
- Break circular dep: import CourseSetting directly from its transformer
file instead of the setting barrel index to avoid the
'CourseSetting is not a constructor' Vite SSR error caused by the
courses <-> setting circular import chain.
- Fix multipart request format: send NewAnomalyData fields as individual
form fields (.field('courseId', ...)) rather than a single JSON-encoded
'data' field that bypassed class-validator.
- Mock CloudStorageService.uploadAnomaly to prevent calls to GCS during
tests (no credentials in CI).
- Replace bogus error scenario ('Input buffer contains unsupported image
format') with realistic 400 Bad Request tests: missing required fields
and an invalid AnomalyType enum value.
- Add afterAll teardown guard: suppress expected MongoDB shutdown-race
unhandled rejections (MongoClientClosedError, MongoWriteConcernError
ShutdownInProgress, MongoServerError InterruptedAtShutdown) that the
driver emits when the in-memory replica set is stopped.
…n metadata Introduce ViolationMetadata schema and plumbing to store plain-English reasons, duration, consecutive frame counts, and signal strength with violation anomalies. This ensures that instructors reviewing violation logs can easily understand why a violation was flagged without needing to understand raw biometric geometry or detector internals. This commit respects the 'trust, not surveillance' project philosophy by replacing opaque black-box flagging with structured, auditable, and human-readable metadata explanations. PR 1: - Add ViolationMetadata interface to backend Anomaly.ts and frontend reportanomaly.types.ts. - Add optional metadata field to backend IAnomalyData class (persisted to DB in constructor). - Add metadata field to NewAnomalyData validator DTO with class-transformer @Transform to parse incoming stringified JSON metadata in multipart requests. - Add integration tests verifying successful metadata persistence and round-tripping through POST /anomalies/record/image.
This introduces real-time liveness detection (stillness, freeze-frame, looking away) built on top of the ViolationMetadata schema from PR 1. This commit respects the 'trust, not surveillance' project philosophy by: - Requiring a sustained window (12s stillness, 5s looking away) and a minimum consecutive frame count (8 frames) before flagging. - Providing detailed plain-English violation descriptions for instructors (visible via tooltips). - Allowing course coordinators to toggle this feature on/off per-course. PR 2: - Register livenessDetection proctoring toggle in EditProctoringModal, ISettingRepository, and AnomalyType enum. - Enforce server-side settings gating for LIVENESS and LOOKING_AWAY anomalies in AnomalyController. - Build LivenessDetector React component supporting 12s stillness drift, 15s freeze-frame/photo variance check, and 5s looking away detection. - Implement debouncing (8 consecutive frames) and per-type cooldown (60s). - Build central useViolationReporter hook to capture canvas frame and submit anomalies. - Add teacher explanation badge with tooltip displaying full violation details on AnomaliesList table. - Add unit tests for stillness, freeze-frame, and head-turn math in Anomaly.test.ts.
This branch has not been deployed
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.
Description
This PR implements real-time webcam liveness detection (stillness, freeze-frame, and looking away signals) on top of the explainable violation metadata schema introduced in PR 1.
Project Philosophy Alignment: "Trust, Not Surveillance"
In alignment with the core project philosophy of "trust, not surveillance," this change ensures that:
LivenessDetectorrequires a sustained window (12s for stillness, 5s for looking away) and a minimum of 8 consecutive frames before triggering.Changes Introduced:
LivenessDetectorComponent: Monitors the primary face for three signals:livenessDetectiontoggle on the backend settings repository (ISettingRepository.ts) and the frontend setting modal (EditProctoringModal.tsx).ForbiddenErrorif a student submits a liveness/looking-away anomaly for a course where liveness detection is disabled.useViolationReporter: Built a hook to draw frame canvas snapshots and submit them to the backend with cooldown protection (60s limit per violation type).AnomaliesListtable using a color-coded hover tooltip displaying the reason and confidence score.Anomaly.test.ts.Related Issues
Closes #