feat: Fund flow audit — fix all critical/high/medium gaps (Go/Rust/Python/TS)#36
Merged
Merged
Conversation
…t/Python CRITICAL fixes: - cashIn/cashOut: FOR UPDATE locking to prevent race conditions on float balance - cashIn/cashOut: Kafka event publishing for domain events - chargebackManagement: GL reversal entries on refund resolution - disputeRefund: GL double-entry for refund processing - transactionReversalManager: executeReversal mutation with GL reversals - reversalApproval: approve mutation with GL reversal + balance restoration - ecommerceOrders: GL reversal on refund/cancel status - crossBorderRemittance.send: complete money movement (CBN limits, FOR UPDATE, GL entries, idempotency, Kafka events) - multiCurrencyExchange.convert: fixed wrong table query (was querying agentPushSubscriptions), implemented real FX conversion with 15 currencies, 48 corridors, GL double-entry - bnplEngine: processRepayment mutation with FOR UPDATE, GL entries, late penalty calculation, collectOverdue batch processing HIGH fixes: - airtimeVending: Kafka event publishing on vend - billPayments: Kafka event publishing on payment - splitPayments: Kafka event publishing on split - floatTopUp: idempotencyKey support - merchantPayments: idempotencyKey + Kafka events - recurringPayments: idempotencyKey + Kafka events MEDIUM fixes: - savingsProducts: compound interest calculation (daily/monthly/quarterly/annual), interest accrual mutation with GL entries, real DB queries replacing stubs Polyglot microservices: - Go: fund-flow-engine (BNPL repayment, FX conversion, reversal execution, GL reconciliation) - port 8250 - Rust: fund-flow-settlement (BNPL installment scheduling with amortization, FX rate engine with spread, GL reconciliation) - port 8251 - Python: fund-flow-analytics (BNPL portfolio analytics, credit risk scoring, FX rate forecasting, reversal fraud detection, anomaly detection) - port 8252 Co-Authored-By: Patrick Munis <pmunis@gmail.com>
Contributor
Author
Original prompt from Patrick
|
Contributor
Author
🤖 Devin AI EngineerI'll be helping with this pull request! Here's what you should know: ✅ I will automatically:
Note: I can only respond to comments from users who have write access to this repository. ⚙️ Control Options:
|
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.
Summary
Comprehensive fund flow audit across 485+ routers identified 15 gaps where money moves without proper accounting, events, or idempotency. All fixed across TypeScript, Go, Rust, and Python.
CRITICAL fixes (9 production-blocking issues)
Race condition —
cashIn/cashOutbalance read was OUTSIDE the transaction. Now usesSELECT ... FROM agents WHERE id = $1 FOR UPDATEinsidewithTransaction()to prevent concurrent overdraw.Missing GL journal entries — 6 routers moved money without double-entry:
chargebackManagement: GL reversal on refund (Debit 5001 Chargeback Expense → Credit 1001 Cash)disputeRefund: GL reversal on refund (Debit 5002 Refund Expense → Credit 1001 Cash)reversalApproval/transactionReversalManager: GL reversal + balance restoration on approveecommerceOrders: GL reversal on refund/cancel statuscrossBorderRemittance.send: Was only creating audit log — now debits float, creates GL entries (Debit 3001 Remittance Payable → Credit 2001 Agent Float), checks CBN limits, publishes Kafka eventsWrong table query —
multiCurrencyExchange.convertwas queryingagentPushSubscriptionsinstead of doing FX conversion. Completely rewritten with 15 currencies (NGN/USD/EUR/GBP/GHS/XOF/KES/ZAR/EGP/USDT/USDC/TZS/UGX/RWF/ZMW), 48 bidirectional corridors, FOR UPDATE locking, GL double-entry, and Kafka events.BNPL repayment —
bnplEnginehad zero repayment flow. AddedprocessRepaymentmutation (FOR UPDATE → debit float → GL entry → late penalty calculation → Kafka event) andcollectOverduebatch processor.HIGH fixes
airtimeVending,billPayments,splitPayments: AddedpublishEvent()Kafka domain eventsfloatTopUp,merchantPayments,recurringPayments: AddedidempotencyKeyinput +withIdempotency()wrapping + Kafka eventsMEDIUM fixes
savingsProducts: AddedcalculateInterest(compound interest with daily/monthly/quarterly/annual compounding) andaccrueInterestmutation with GL entries. Replaced hardcoded stub responses with real DB queries.Polyglot microservices
fund-flow-enginefund-flow-settlementfund-flow-analyticsTest impact
react-i18next/@dnd-kittype declarations)db-performance/critical-flows, 1 expected:sprint46multi-currency test expectsactivePairs: 42from old hardcoded stub — now dynamically computed as 48 due to expanded corridor coverage)go vetpassespy_compilepassesLink to Devin session: https://app.devin.ai/sessions/3ebd42bf0430422a9a2bd85ed9f9cd4c
Requested by: @munisp