feat(compliance): compliance reporting engine (SAT/UIF) + alert SLA p… - #320
Conversation
ericmt-98
left a comment
There was a problem hiding this comment.
Thanks for this — the append-only trigger design, the 24h-SLA alert tracking, the zero-report path, and the injected test suite are all the right shape for what #317 needs. Two blockers and a couple of cleanups before this can merge:
🔴 Blocker 1 — micopay/backend/src/config.ts is truncated to a broken 10-line fragment
The committed config.ts on this branch is only:
// Compliance / SAT reporting
umaValMxn: parseFloat(process.env.UMA_VAL_MXN || '113.15'),
satFilingThresholdUma: parseFloat(process.env.SAT_FILING_THRESHOLD_UMA || '210'),
// LFPIORPI aviso (reporting) thresholds
umaDailyMxn: ...The entire module is gone — the imports, loadEnv, parseAllowedOrigins, the KycOperationType/KycThresholdTier types, parseKycOperationThresholds, the whole config object (port, databaseUrl, stellar, jwt, rate limits, the KYC gate config…), validateConfig, and getCorsOptions. The backend won't compile or boot with this. It looks like a merge/rebase conflict against the recent threshold-config commit (fbc8c7b) got resolved by dropping the file's contents.
Fix: rebase onto latest main and re-apply only your compliance additions (umaValMxn/satFilingThresholdUma) on top of the full file. Note main already has umaDailyMxn (117.31) and kycAvisoThresholdUma (210) from fbc8c7b — reuse those instead of adding parallel copies (see the two minor notes below).
CI would normally have caught this, but it doesn't run on fork branches — so please run cd micopay/backend && npx tsc --noEmit locally to confirm before pushing.
🔴 Blocker 2 — compliance_filings.status contradicts the append-only trigger
The table defines status VARCHAR(20) DEFAULT 'pending_submission', which implies status later moves to submitted. But enforce_append_only_compliance_filings blocks all UPDATEs on the table, so status can never change. Either the filing status needs to be mutable (then it can't live on an append-only table — split the mutable status into a separate table, or track submission as a new appended row), or it's genuinely immutable (then drop the status column). As written the submission workflow is unreachable.
Minor
- Stale UMA value:
umaValMxndefaults to113.15— that's the 2025 UMA. The 2026 value is117.31(already inmainasumaDailyMxn). Please consolidate onto the single existingumaDailyMxnrather than introducing a second, stale UMA constant. - Duplicate threshold:
satFilingThresholdUmaduplicates the existingkycAvisoThresholdUma(both 210 UMA). Reuse the existing one.
The reporting logic and migration are otherwise solid — this is mostly reconciling with what already landed on main. Thanks again!
|
Hi @ShantelPeters — just checking in, no pressure on timing. The main thing here is the |
…ipeline Closes Micopay#317 - Adds monthly aggregation (>=210 UMA threshold) & zero-report generation (compliance.service.ts) - Adds compliance_alerts table with 24h SLA deadline tracking and compliance_filings table (migration 20260721130000_compliance_reporting) - Adds append-only triggers on platform_risk_events, compliance_alerts, and compliance_filings - Exposes query/admin endpoints (/admin/compliance/alerts, /admin/compliance/filings, /admin/compliance/filings/trigger) - Adds 10-year retention policy documentation (RETENTION_POLICY.md) - Adds unit/integration test suite (compliance.test.ts)
1c92dfe to
48f4c51
Compare
|
Merging — thanks for the quick turnaround, @ShantelPeters. Both blockers are properly resolved and I built + ran it locally (CI doesn't run on fork branches):
One hardening note for later (not a blocker for single-instance testnet): the hourly |
…ipeline
Closes #317
CLOSES #317