Alert on escrow reconciliation mismatches
Description
The nightly reconciliation job in src/jobs/reconcileEscrow.js compares DB fundedTotal against on-chain fundedAmount (via src/services/escrowRead.js), persists results to reconciliation_runs, and increments escrowReconciliationMismatches in src/metrics.js — but a mismatch raises no actionable alert, so funded-amount drift can sit undetected until someone queries the metric. This issue adds explicit alerting on mismatch beyond the counter.
Requirements and context
- Repository scope: Liquifact/Liquifact-backend only.
- On a detected mismatch, capture a structured alert (logged at
error/warn with invoiceId, expected vs actual) and capture it to Sentry via src/observability/sentry.js when enabled, with sensitive fields scrubbed.
- Surface a mismatch summary through the reconciliation health check in
src/services/health.js (checkReconciliationHealth) so /ready can degrade if drift exceeds a configurable threshold.
- Keep the existing keyset pagination,
reconciliation_runs persistence, and counter increments unchanged.
- Make the alert threshold and channel configurable via env and documented.
Suggested execution
- Fork the repo and create a branch
git checkout -b enhancement/reconciliation-14-mismatch-alerts
- Implement changes
- Test and commit
Test and commit
- Run
npm test and npm run lint.
- Cover edge cases: no mismatch, single mismatch alert, threshold breach degrades readiness, Sentry disabled, read failure.
- Include the full
npm test output and a short security-notes section in the PR description.
Example commit message
feat(reconciliation): raise structured alerts on funded-amount mismatches
Guidelines
- Minimum 95 percent test coverage for impacted modules.
- Clear, reviewer-focused documentation.
- Timeframe: 96 hours.
Community & contribution rewards
- 💬 Join the Liquifact community on Discord for questions, reviews, and faster merges: https://discord.gg/JrGPH4V3
- ⭐ This is a GrantFox OSS / Official Campaign task and may be rewarded. When your PR is merged you'll be prompted to rate the project — if this issue and the maintainers helped you ship, we'd be grateful for a 5-star rating. Clear questions in Discord and tidy, well-tested PRs are the fastest path to a merge and a reward.
Alert on escrow reconciliation mismatches
Description
The nightly reconciliation job in
src/jobs/reconcileEscrow.jscompares DBfundedTotalagainst on-chainfundedAmount(viasrc/services/escrowRead.js), persists results toreconciliation_runs, and incrementsescrowReconciliationMismatchesinsrc/metrics.js— but a mismatch raises no actionable alert, so funded-amount drift can sit undetected until someone queries the metric. This issue adds explicit alerting on mismatch beyond the counter.Requirements and context
error/warnwith invoiceId, expected vs actual) and capture it to Sentry viasrc/observability/sentry.jswhen enabled, with sensitive fields scrubbed.src/services/health.js(checkReconciliationHealth) so/readycan degrade if drift exceeds a configurable threshold.reconciliation_runspersistence, and counter increments unchanged.Suggested execution
git checkout -b enhancement/reconciliation-14-mismatch-alertssrc/jobs/reconcileEscrow.jsandsrc/services/health.js.tests/reconcileEscrow.test.js.docs/ops-reconcile.md.Test and commit
npm testandnpm run lint.npm testoutput and a short security-notes section in the PR description.Example commit message
feat(reconciliation): raise structured alerts on funded-amount mismatchesGuidelines
Community & contribution rewards