Skip to content

Raise reconciliation-mismatch alerts instead of only incrementing a counter #356

Description

@mikewheeleer

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

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.

Metadata

Metadata

Fields

No fields configured for Feature.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions