version: 2

models:
  - name: recs_hooks_ranker_user_feature_store
    description: "User features for Hooks ML Ranker - Feast feature store. Computes daily rolling 30-day and 7-day metrics per user including average, median, and 95th percentile watch time, plus activity frequency."
    config:
      database: SUNO_DEV_DELPHINE
      schema: PROD
      group: recommendations
      tags: ['feature_store', 'hooks_ranker']
    meta:
      dagster:
        partitions_def:
          type: daily
          start_date: 2024-09-18
          end_offset: 0
        backfill_policy:
          max_partitions_per_run: 7
    columns:
      - name: user_id
        description: "User identifier"
        tests:
          - not_null
      - name: p_date
        description: "Partition date"
        tests:
          - not_null
      - name: average_watch_time_30d
        description: "Average watch time for hooks in last 30 days (seconds)"
      - name: median_watch_time_30d
        description: "Median watch time for hooks in last 30 days (seconds)"
      - name: p95_watch_time_30d
        description: "95th percentile watch time for hooks in last 30 days (seconds)"
      - name: num_active_days_30d
        description: "Number of distinct days with hook watching activity in last 30 days"
      - name: average_watch_time_7d
        description: "Average watch time for hooks in last 7 days (seconds)"
      - name: median_watch_time_7d
        description: "Median watch time for hooks in last 7 days (seconds)"
      - name: p95_watch_time_7d
        description: "95th percentile watch time for hooks in last 7 days (seconds)"
      - name: num_active_days_7d
        description: "Number of distinct days with hook watching activity in last 7 days"
      - name: event_timestamp
        description: "Event timestamp for Feast point-in-time correctness (same as p_date)"
      - name: created_timestamp
        description: "Timestamp when feature was computed"

  - name: recs_hooks_ranker_hook_feature_store
    description: "Hook features for Hooks ML Ranker - Feast feature store. Computes daily rolling 30-day and 7-day average, median, and 95th percentile watch time per hook."
    config:
      database: SUNO_DEV_DELPHINE
      schema: PROD
      group: recommendations
      tags: ['feature_store', 'hooks_ranker']
    meta:
      dagster:
        partitions_def:
          type: daily
          start_date: 2024-09-18
          end_offset: 0
        backfill_policy:
          max_partitions_per_run: 7
    columns:
      - name: hook_id
        description: "Hook identifier"
        tests:
          - not_null
      - name: p_date
        description: "Partition date"
        tests:
          - not_null
      - name: average_watch_time_30d
        description: "Average watch time for this hook in last 30 days (seconds)"
      - name: median_watch_time_30d
        description: "Median watch time for this hook in last 30 days (seconds)"
      - name: p95_watch_time_30d
        description: "95th percentile watch time for this hook in last 30 days (seconds)"
      - name: average_watch_time_7d
        description: "Average watch time for this hook in last 7 days (seconds)"
      - name: median_watch_time_7d
        description: "Median watch time for this hook in last 7 days (seconds)"
      - name: p95_watch_time_7d
        description: "95th percentile watch time for this hook in last 7 days (seconds)"
      - name: event_timestamp
        description: "Event timestamp for Feast point-in-time correctness (same as p_date)"
      - name: created_timestamp
        description: "Timestamp when feature was computed"

  - name: recs_hooks_ranker_user_hook_feature_store
    description: "User-hook interaction features for Hooks ML Ranker - Feast feature store. Contains individual hook play events for user-hook pairs over last 30 days."
    config:
      database: SUNO_DEV_DELPHINE
      schema: PROD
      group: recommendations
      tags: ['feature_store', 'hooks_ranker', 'interactions']
    meta:
      dagster:
        partitions_def:
          type: daily
          start_date: 2024-09-18
          end_offset: 0
        backfill_policy:
          max_partitions_per_run: 7
    columns:
      - name: hook_id
        description: "Hook identifier"
        tests:
          - not_null
      - name: user_id
        description: "User identifier"
        tests:
          - not_null
      - name: creator_id
        description: "Creator user identifier (hook owner)"
        tests:
          - not_null
      - name: clip_id
        description: "Clip identifier associated with the hook"
        tests:
          - not_null
      - name: p_date
        description: "Partition date"
        tests:
          - not_null
      - name: p_hour
        description: "Partition hour"
        tests:
          - not_null
      - name: event_timestamp
        description: "Timestamp when the hook was played by the user (PLAY_START_TS_UTC)"
        tests:
          - not_null
      - name: watch_time
        description: "Duration of watch in seconds (unique play duration)"
      - name: created_timestamp
        description: "Timestamp when feature was computed"

  - name: recs_hooks_ranker_creator_feature_store
    description: "Creator features for Hooks ML Ranker - Feast feature store. Computes daily rolling 30-day and 7-day average, median, and 95th percentile watch time for hooks created by each creator."
    config:
      database: SUNO_DEV_DELPHINE
      schema: PROD
      group: recommendations
      tags: ['feature_store', 'hooks_ranker']
    meta:
      dagster:
        partitions_def:
          type: daily
          start_date: 2024-09-18
          end_offset: 0
        backfill_policy:
          max_partitions_per_run: 7
    columns:
      - name: creator_id
        description: "Creator user identifier"
        tests:
          - not_null
      - name: p_date
        description: "Partition date"
        tests:
          - not_null
      - name: average_watch_time_30d
        description: "Average watch time for all hooks created by this creator in last 30 days (seconds)"
      - name: median_watch_time_30d
        description: "Median watch time for all hooks created by this creator in last 30 days (seconds)"
      - name: p95_watch_time_30d
        description: "95th percentile watch time for all hooks created by this creator in last 30 days (seconds)"
      - name: average_watch_time_7d
        description: "Average watch time for all hooks created by this creator in last 7 days (seconds)"
      - name: median_watch_time_7d
        description: "Median watch time for all hooks created by this creator in last 7 days (seconds)"
      - name: p95_watch_time_7d
        description: "95th percentile watch time for all hooks created by this creator in last 7 days (seconds)"
      - name: event_timestamp
        description: "Event timestamp for Feast point-in-time correctness (same as p_date)"
      - name: created_timestamp
        description: "Timestamp when feature was computed"

  - name: recs_hooks_ranker_clip_feature_store
    description: "Clip features for Hooks ML Ranker - Feast feature store. Contains genre information for clips from hook plays. Incremental model with delete+insert strategy on (clip_id, p_date, p_hour)."
    config:
      group: recommendations
      tags: ['feature_store', 'hooks_ranker']
    meta:
      dagster:
        partitions_def:
          type: hourly
          start_date: 2025-01-09
          end_offset: 0
        backfill_policy:
          max_partitions_per_run: 7
    columns:
      - name: CLIP_ID
        description: "Clip identifier"
        tests:
          - not_null
      - name: p_date
        description: "Partition date"
        tests:
          - not_null
      - name: p_hour
        description: "Partition hour (0-23)"
        tests:
          - not_null
      - name: GENRE_TAG
        description: "Genre tag for the clip"
      - name: event_timestamp
        description: "Timestamp when the clip-genre relationship was created"
      - name: created_timestamp
        description: "Timestamp when feature was computed"

  - name: recs_hooks_ranker_user_creator_feature_store
    description: "User-creator interaction features for Hooks ML Ranker - Feast feature store. Computes daily rolling 30-day interaction metrics between users and creators."
    config:
      database: SUNO_DEV_DELPHINE
      schema: PROD
      group: recommendations
      tags: ['feature_store', 'hooks_ranker', 'interactions']
    meta:
      dagster:
        partitions_def:
          type: daily
          start_date: 2024-09-18
          end_offset: 0
        backfill_policy:
          max_partitions_per_run: 7
    columns:
      - name: user_id
        description: "User identifier"
        tests:
          - not_null
      - name: creator_id
        description: "Creator user identifier"
        tests:
          - not_null
      - name: p_date
        description: "Partition date"
        tests:
          - not_null
      - name: average_watch_time_30d
        description: "Average watch time for this user watching this creator's hooks in last 30 days (seconds)"
      - name: event_timestamp
        description: "Event timestamp for Feast point-in-time correctness (same as p_date)"
      - name: created_timestamp
        description: "Timestamp when feature was computed"

  - name: recs_hooks_ranker_user_genre_feature_store
    description: "User genre preference features for Hooks ML Ranker - Feast feature store. Computes daily rolling 30-day average watch time per genre for each user. Each row has 18 genre columns (one per genre)."
    config:
      database: SUNO_DEV_DELPHINE
      schema: PROD
      group: recommendations
      tags: ['feature_store', 'hooks_ranker', 'genres']
    meta:
      dagster:
        partitions_def:
          type: daily
          start_date: 2024-09-18
          end_offset: 0
        backfill_policy:
          max_partitions_per_run: 7
    columns:
      - name: user_id
        description: "User identifier"
        tests:
          - not_null
      - name: p_date
        description: "Partition date"
        tests:
          - not_null
      - name: genre_pop_avg_watch_time_30d
        description: "Average watch time for pop genre in last 30 days (dynamically generated for all genres)"
      - name: event_timestamp
        description: "Event timestamp for Feast point-in-time correctness (same as p_date)"
      - name: created_timestamp
        description: "Timestamp when feature was computed"
  - name: recs_hooks_ranker_hook_characteristics_feature_store
    description: "Hook characteristics features for Hooks ML Ranker - Feast feature store. Contains characteristics for hooks."
    config:
      database: SUNO_DEV_DELPHINE
      schema: PROD
      group: recommendations
      tags: ['feature_store', 'hooks_ranker']
    meta:
      dagster:
        partitions_def:
          type: daily
          start_date: 2024-09-18
          end_offset: 0
        backfill_policy:
          max_partitions_per_run: 7
    columns:
      - name: hook_id
        description: "Hook identifier"
        tests:
          - not_null
      - name: p_date
        description: "Partition date"
        tests:
          - not_null
      - name: p_hour
        description: "Partition hour"
        tests:
          - not_null
      - name: is_ai_generated
        description: "Whether the hook was generated by AI"
        tests:
          - not_null
      - name: is_ugc
        description: "Whether the hook was created by a user"
        tests:
          - not_null
      - name: has_ugc_face
        description: "Whether the hook has a UGC face"
        tests:
          - not_null
      - name: has_ugc_face_in_first_frame
        description: "Whether the hook has a UGC face in the first frame"
        tests:
          - not_null
      - name: hook_creation_type_json
        description: "Hook creation type metadata as JSON"
        tests:
          - not_null
      - name: gemini_rating
        description: "Content rating assigned by Gemini AI model (0=SUPPRESS, 1=CONDITIONAL, 2=APPROVED, 3=PROMOTE, 4=CHAMPION)"
        tests:
          - not_null