WAGERBABE DOCS
All Stories
4-5-4-account-linking-detectionDoneEpic 4.5

Story 4.5.4: Account Linking Detection

Status: done

Tasks

  • **Task 1: AccountLinkingDetector Class** (AC: 1, 2, 3)
    • 1.1 Create AccountLinkingDetector in `server/app/services/fraud/account_linking.py`
    • 1.2 Implement `check_for_links(user_id)` main method
    • 1.3 Implement `_check_payment_method_links()` with hashing
    • 1.4 Implement `_check_fingerprint_links()` method
    • 1.5 Implement `_check_ip_correlation()` with time windows
    • 1.6 Create AccountLink and AccountLinkResult dataclasses
  • **Task 2: Database Schema** (AC: 4)
    • 2.1 Create account_links table migration
    • 2.2 Add constraint: user_id_1 < user_id_2 (prevent duplicates)
    • 2.3 Create unique index on (user_id_1, user_id_2, link_type)
    • 2.4 Add indexes for efficient graph queries
  • **Task 3: Payment Method Hashing** (AC: 1)
    • 3.1 Implement `hash_payment_method(pm)` function
    • 3.2 Store hash in payment_methods table (payment_method_hash column added to users)
    • 3.3 Add migration to hash existing payment methods
    • 3.4 Ensure GDPR-compliant hashing (no reversibility)
  • **Task 4: Fraud Review Integration** (AC: 4)
    • 4.1 Create fraud_review entry for high-confidence links
    • 4.2 Implement `_create_fraud_review()` method
    • 4.3 Add link_type and confidence to review details
    • 4.4 Support agent actions: confirm, dismiss, merge
  • **Task 5: Promotion Abuse Prevention** (AC: 5)
    • 5.1 Create `check_promotion_eligibility(user_id, promo_id)` function
    • 5.2 Query linked accounts for prior promotion usage
    • 5.3 Return block reason with linked account details
    • 5.4 Implement agent override endpoint with audit log
  • **Task 6: Graph Visualization API** (AC: 6)
    • 6.1 Create GET /api/v1/agent/fraud/customers/{user_id}/account-links/graph endpoint
    • 6.2 Build graph traversal to N degrees (default 2)
    • 6.3 Return nodes (users) and edges (links) in JSON
    • 6.4 Include user metadata: username, status, created_at
  • **Task 7: Graph Visualization UI** (AC: 6)
    • 7.1 Create AccountLinkGraph React component
    • 7.2 Implement canvas-based graph rendering (custom implementation)
    • 7.3 Color-code edges by link_type and confidence
    • 7.4 Add click handlers for node details
    • 7.5 Mobile-friendly fallback (list view)
  • **Task 8: Testing**
    • 8.1 Unit tests for each detection method (62 tests)
    • 8.2 Integration tests with test user pairs (deferred)
    • 8.3 Graph API endpoint tests (deferred)
    • 8.4 Frontend graph component tests (deferred)

Progress

Tasks8/8
Acceptance Criteria0
Total Tasks8