feat-proof-watcher
✨ New Features
Proof Watcher (Change Stream)
Goal: Automatically trigger certificate ZIP generation when a proof is confirmed in MongoDB, to validate the Hotep certificate pipeline in real conditions without manual testing.
Solution: MongoDB Change Stream on the proofs collection, listening for inserts and updates where status becomes confirmed. Triggers ZipService.generateZipSystem() via a p-queue concurrency limiter. Controlled by PROOF_WATCHER_ENABLED env var (default false).
Features:
- Change Stream watches both
insert(status=confirmed) andupdate(status changed to confirmed) p-queueconcurrency control viaWATCHER_CONCURRENCYenv var (default 2)- Accurate result logging: OK / partial (N/M failed) / crashed per document
generateZipSystemreturns{ total, failed }for precise reporting- System-level ZIP generation without auth context (resolves user from document's jobRef)
- Feature flag: disabled by default, enable with
PROOF_WATCHER_ENABLED=true - Graceful cleanup on module destroy (closes Change Stream cursor, clears queue)
- Temporary feature: meant to be removed after production validation
Files Modified:
src/core/proof-watcher/proof-watcher.service.ts- Change Stream listener with p-queue concurrency controlsrc/core/proof-watcher/proof-watcher.module.ts- NestJS module (imports DocumentModule for ZipService)src/domains/document/zip.service.ts-generateZipSystemreturns stats,addProofAndCertificatereturns booleansrc/domains/document/document.module.ts- Export ZipService for cross-module injectionsrc/core/hotep/hotep.service.ts- Simplified (removed semaphore, Browserless now self-hosted)src/app.module.ts- Conditional import of ProofWatcherModulepackage.json- Added p-queue, mongoose override (snyk fix), jest transformIgnorePatterns for ESM deps
⚡ Improvements
CI pipeline
Goal: Add build verification, JUnit reports and coverage to GitLab CI.
Solution: Added npm run build before tests, JUnit + Cobertura reporting with artifacts.
Files Modified:
.gitlab-ci.yml- Build step, jest-junit reporter, coverage artifactspackage.json- jest-junit devDep, coverageReporters config
Dependency security
Goal: Fix Snyk vulnerabilities blocking CI.
Solution: Upgraded uuid to v14 (ESM-only, added transformIgnorePatterns), @azure/identity to 4.13.1, mongoose override to 8.22.1.
Files Modified:
package.json- Dependency upgrades and overrides