Skip to content

P0: Card Generation Audit - Ensure All Card Types Are Firing #163

@kevsilk597

Description

@kevsilk597

Objective

We have 6 total cards across 4 days. This is not enough to demo or sell. We need to understand why card generation is so thin and fix it.

Current State

Total active cards: 6
Date range: March 20-24
Card types seen: rivalry (1), trap_game (1), sleeper (few, mostly filtered)
Card types NOT seen: hot_streak, cold_streak, matchup, crossref, injury_impact, team_trend, referee, etc.

Requirements

1. Audit Card Detector Inventory

Create a complete list of every card detector that exists in the codebase:

# Find all card type definitions
grep -rn "card_type\|cardType\|CARD_TYPE" --include="*.py" . | grep -E "=.*[A-Z_]+"

# Find all detector functions
grep -rn "def detect_" --include="*.py" .

Document in a table:

Card Type Detector Function File Status (Running/Broken/Disabled)
hot_streak detect_hot_streak anomaly_detector.py ?
cold_streak detect_cold_streak anomaly_detector.py ?
matchup detect_matchup ? ?
rivalry detect_rivalry ? Running
trap_game detect_trap_game ? Running
... ... ... ...

2. Verify Each Detector Runs

For each detector found, verify it is:

  1. Called during pipeline execution
  2. Not throwing silent exceptions
  3. Actually producing output

Add logging to each detector:

def detect_hot_streak(games_df, player_stats_df):
    logger.info(f"[DETECTOR] hot_streak: checking {len(player_stats_df)} player records")
    
    cards = []
    # ... detection logic ...
    
    logger.info(f"[DETECTOR] hot_streak: generated {len(cards)} cards")
    return cards

3. Check Detector Filtering Thresholds

The quality filters we added (player tier, sigma thresholds, type caps) may be too aggressive.

For each detector, log what is being filtered and why:

# In player tier filter
if tier == 4:
    logger.debug(f"[FILTER] Skipped {player_name}: tier=4 (deep_bench)")
    continue

if tier == 3 and sigma < 2.0:
    logger.debug(f"[FILTER] Skipped {player_name}: tier=3, sigma={sigma:.2f} (below threshold)")
    continue

Run pipeline and analyze filter logs:

grep "\[FILTER\]" /var/log/cypher.log | sort | uniq -c | sort -rn

If 95% of potential cards are being filtered, thresholds may be too strict.

4. NBA Game Coverage

For today's NBA games, verify we attempt to generate cards for each:

SELECT game_date, home_team, away_team 
FROM games 
WHERE game_date = CURRENT_DATE AND sport = 'NBA'
ORDER BY start_time;

For each game, we should attempt:

  • Matchup history card
  • Rivalry card (if applicable)
  • Trap game card (if schedule spot applies)
  • Player streak cards for starters on both teams
  • Injury impact cards (if key players out)

Log which games get which card types attempted.

5. Star Player Coverage

Query the top 30 NBA players by PPG this season:

SELECT player_name, team, AVG(pts) as ppg, COUNT(*) as games
FROM player_stats
WHERE game_date > CURRENT_DATE - INTERVAL '30 days'
GROUP BY player_name, team
ORDER BY ppg DESC
LIMIT 30;

For each star, check if they have had ANY card generated in the last 7 days:

SELECT DISTINCT player_name 
FROM intelligence_cards 
WHERE card_date > CURRENT_DATE - INTERVAL '7 days'
AND player_name IN (/* top 30 list */);

If stars are missing, investigate why.

6. Minimum Card Targets

Set minimum targets per game day:

Card Type Minimum Per Day Notes
Player streak (hot/cold) 5 Focus on starters, stars
Matchup 3 Historical H2H angles
Team situation (trap, revenge, B2B) 3 Schedule-based
Injury impact 2 When key players are out
Total minimum 13 Per day with 10+ games

If we're below minimums, either:

  • Detectors are broken
  • Thresholds are too strict
  • Data is missing

7. Fix What's Broken

Based on audit findings, create sub-tasks for each broken/disabled detector.

Validation

After fixes:

  1. Run pipeline for today's games
  2. Query card output:
curl "http://cypher.178.156.223.137.nip.io/api/v1/feed?date=$(date +%Y-%m-%d)" | jq '[.cards[] | .cardType] | group_by(.) | map({type: .[0], count: length})'
  1. Verify:
  • At least 10 cards generated
  • At least 3 different card types
  • At least 2 cards about star players (top 30 PPG)

Definition of Done

  • Complete inventory of all card detectors documented
  • Each detector verified running or fixed
  • Filter thresholds validated (not too aggressive)
  • Every NBA game today has at least 1 card attempt
  • At least 3 star players have cards in today's feed
  • Minimum 10 cards per game day with 10+ games
  • At least 3 different card types per day

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions