Summary
Implement credit event dispute flow so users/operators can flag incorrect partner reports and reverse score impact without manual DB edits.
Builds on admin dashboard (#43), recalc CLI (#50), and score history (#34).
Problem
Partner platforms (#17, #18) may report wrong wallet, amount, or duplicate events. Today there is no structured dispute — only npm run recalc:scores for batch fixes.
Proposed design
Schema
Add to CreditEvent:
disputed Boolean @default(false)
disputeReason String?
disputedAt DateTime?
disputedBy String? // admin operator id or "user"
API
| Endpoint |
Auth |
Action |
POST /api/admin/events/{id}/dispute |
X-Admin-Key |
Mark disputed + reason |
POST /api/admin/events/{id}/reinstate |
X-Admin-Key |
Clear dispute |
POST /api/admin/users/{wallet}/recalculate |
X-Admin-Key |
Trigger recalc for one wallet |
Disputed events excluded from score sum in score-recalc.service.ts.
Admin UI
Extend /admin — dispute button on recent events table, recalc trigger.
Acceptance criteria
How to verify
# Seed event, dispute it, recalc
npm run recalc:scores --prefix Server -- --wallet G... --dry-run
npm run recalc:scores --prefix Server -- --wallet G... --apply
Related
Server/scripts/recalculate-scores.ts
Server/src/services/score-recalc.service.ts
Summary
Implement credit event dispute flow so users/operators can flag incorrect partner reports and reverse score impact without manual DB edits.
Builds on admin dashboard (#43), recalc CLI (#50), and score history (#34).
Problem
Partner platforms (#17, #18) may report wrong wallet, amount, or duplicate events. Today there is no structured dispute — only
npm run recalc:scoresfor batch fixes.Proposed design
Schema
Add to
CreditEvent:API
POST /api/admin/events/{id}/disputeX-Admin-KeyPOST /api/admin/events/{id}/reinstateX-Admin-KeyPOST /api/admin/users/{wallet}/recalculateX-Admin-KeyDisputed events excluded from score sum in
score-recalc.service.ts.Admin UI
Extend
/admin— dispute button on recent events table, recalc trigger.Acceptance criteria
recalculateUserScoreCreditEventHow to verify
# Seed event, dispute it, recalc npm run recalc:scores --prefix Server -- --wallet G... --dry-run npm run recalc:scores --prefix Server -- --wallet G... --applyRelated
Server/scripts/recalculate-scores.tsServer/src/services/score-recalc.service.ts