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 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 the schema, validation, and database plumbing for storing explainable, confidence-weighted violation metadata alongside proctoring anomalies.
Project Philosophy Alignment: "Trust, Not Surveillance"
In alignment with the core project philosophy of "trust, not surveillance," this change replaces opaque black-box proctoring flags with auditable, explainable data structures. Instead of storing raw biometric geometry or using unexplainable signals, every violation record now supports a plain-English
reasonstring, consecutive frame count, signal duration, and signal strength. This ensures instructors can review flagged students fairly and transparently.Changes Introduced:
ViolationMetadataSchema: Created a structured interface on both backend (Anomaly.ts) and frontend (reportanomaly.types.ts) to store:reason(Plain-English explanation of why the anomaly triggered).durationMs(How long the signal was continuously active).consecutiveFrames(Number of frames showing the violation).signalStrength(System confidence score between 0 and 1).detectedAt(ISO timestamp when the signal started).metadatafield to theIAnomalyDataclass and constructor logic to save metadata directly into MongoDB records.metadatafield inNewAnomalyDatawith theclass-transformer@Transformdecorator to correctly parse JSON-encoded form fields sent during multipart webcam/image uploads.AnomalyController.test.tsto verify backward compatibility (saving anomalies without metadata) and verify successful round-trip persistence of anomaly metadata.Related Issues
Closes #