feat: prediction fraud signals, dispute SLA timers, referral tracking… - #1482
Merged
Olowodarey merged 2 commits intoJul 27, 2026
Merged
Conversation
…, weighted arbiter voting Implements four independent features: - Prediction fraud signals (Arena1X#1389): computes timing-clustering and counterparty-concentration signals per user, raises advisory PredictionFraudFlag records against configurable thresholds, and exposes them via GET /admin/predictions/fraud-flags. No automatic enforcement is taken from flags alone. - Dispute SLA timers and escalation (Arena1X#1394): attaches an SLA deadline to each dispute's stage (initial review -> escalated), runs an hourly sweep that detects approaching/breached deadlines, notifies assigned arbiters and admins, and escalates breached disputes to a second SLA window per configurable policy. - Referral tracking API (Arena1X#1390): records referrer -> referred relationships via POST /users/me/referrals/claim (self-referral and duplicate attribution rejected), reports counts/statuses via GET /users/me/referrals, and advances a referral to "qualified" when the referred user completes their first prediction. - Weighted arbiter quorum voting with slashing (Arena1X#1359, contract): admins assign a panel of arbiters to a dispute with per-arbiter weight (stake x reputation multiplier) snapshotted at assignment; finalization requires assigned weight meeting a configurable quorum and slashes non-voters, redistributing the slashed stake to voters exactly. Ties resolve to reject, preserving the original resolution. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
|
@Immex171 Great news! 🎉 Based on an automated assessment of this PR, the linked Wave issue(s) no longer count against your application limits. You can now already apply to more issues while waiting for a review of this PR. Keep up the great work! 🚀 |
- disputes.service.ts: compare arbiter.role against string literals instead of the Role enum (User.role is typed as string, so the enum comparison tripped @typescript-eslint/no-unsafe-enum-comparison). - bulk-import-markets.spec.ts: add the missing PredictionsService provider now required by AdminService's constructor. - disputes.service.spec.ts: stop reusing the shared, mutable mockDispute fixture in two assignArbiter tests - earlier specs in the file mutate its status in place via the service, making those tests order-dependent. Clone it with status explicitly set instead. Verified with the exact CI-pinned toolchain (pnpm install --frozen-lockfile): lint is 0 errors, and all 85 suites / 1032 tests pass. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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
Implements four independent tasks:
[Backend] Prediction Pattern Fraud Signals
Closes #1389
PredictionFraudFlagrecords — never auto-enforced.GET /admin/predictions/fraud-flags(filterable by status/signal_type/user).backend/src/predictions/predictions.service.ts,backend/src/predictions/entities/prediction-fraud-flag.entity.ts,backend/src/admin/admin.service.ts,backend/src/admin/admin.controller.ts.[Backend] Dispute SLA Timers and Escalation
Closes #1394
initial_review→escalated).DisputesService.runSlaCheck) detects approaching/breached SLAs, notifies the assigned arbiter and all admins, and escalates breached disputes into a second SLA window per configurable policy.PATCH /admin/disputes/:id/assign-arbiterendpoint to assign an admin/moderator as the dispute's arbiter.backend/src/disputes/disputes.service.ts,backend/src/disputes/entities/dispute.entity.ts,backend/src/notifications/notification-generator.service.ts.[Backend] Referral Tracking API
Closes #1390
POST /users/me/referrals/claim(a user's own ID doubles as their shareable referral code).GET /users/me/referralsreports counts and per-referral status.pendingtoqualified.backend/src/users/users.service.ts,backend/src/users/users.controller.ts,backend/src/users/entities/user-referral.entity.ts,backend/src/users/dto/referral.dto.ts.[Contract] Weighted Arbiter Quorum Voting with Slashing
Closes #1359
assign_arbiters); each arbiter's voting weight (staked bond × reputation multiplier) is snapshotted at assignment, immune to later stake/reputation changes.finalize_arbiter_voterequires assigned weight meeting a configurable quorum (Config::arbiter_quorum_bps) and the voting deadline to have passed.Config::arbiter_slash_bps; the slashed amount is redistributed to voters exactly (verified in tests).get_arbiter_tallyexposes a read-only tally, quorum progress, and per-arbiter participation.contracts/open-market/src/dispute.rs,contracts/open-market/src/storage_types.rs,contracts/open-market/src/config.rs.DataKeyandInsightArenaErrorare already at their 50-variant XDR cap, so this reuses the existing raw-tuple-key pattern (seereputation::trusted_creator_key) for arbiter stake storage, and documents each reused error variant inline.Test plan
cd backend && npm test— unit tests added/updated inpredictions.service.spec.ts,disputes.service.spec.ts,users.service.spec.ts,admin.service.spec.ts.cd contracts/open-market && cargo test— newtests/arbiter_vote_tests.rscovers staking, weight snapshotting, quorum gating, tie resolution, and exact slash/redistribution accounting.POST /users/me/referrals/claimandGET /admin/predictions/fraud-flagsagainst a running backend.