# ─────────────────────────────────────────────────────────────────────────────
# Brand Program Template — Phase 1
# ─────────────────────────────────────────────────────────────────────────────
# Copy this file, edit the values for your brand, and apply by inserting
# rows directly into the `monitoring_rules` table (or via the `/program`
# slash command if available in your bot deployment).
#
# A brand program is the bundle of:
#   - core events with supersession tiers (same event_type, growing rewards
#     and caps as min_tune_level rises),
#   - unlock events (single rows that become claimable past a tune-level gate),
#   - quality-gate parameters (strictness, heuristic penalties, reaction gating).
#
# All RSNC values below are the Resonance Official defaults — adjust freely
# to fit your brand's reward economy.
# ─────────────────────────────────────────────────────────────────────────────

# Your partner address (from the `partners` table). Every rule below is scoped
# to this brand_id. Each rule may also carry a server_id to scope to a single
# Discord server, or omit server_id to apply brand-wide.
brand_id: "0x0000000000000000000000000000000000000000"

# ─────────────────────────────────────────────────────────────────────────────
# Core Events with Supersession
# ─────────────────────────────────────────────────────────────────────────────
# Each core event has 10 tiers spaced ten tune levels apart. The event-handler
# automatically picks the highest-tier row a member qualifies for at the moment
# they trigger the event. detection_config should be IDENTICAL across tiers of
# the same event — strictness, reactor thresholds, etc. are properties of the
# event, not of the member's tune level.
core_events:

  # quality — substantive messages that pass the quality gate.
  # The largest event in the program by volume.
  quality:
    description: "Substantive message contribution; passes quality gate."
    detection_config:
      strictness: 7              # see quality-gate.md for the parameter table
      voter_reward: 0            # set >0 to also reward reactors (gated on parent pass)
    tiers:
      - { min_tune_level: 0,  reward: 15, max_claims_per_user: 50,  max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 10, reward: 20, max_claims_per_user: 58,  max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 20, reward: 25, max_claims_per_user: 66,  max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 30, reward: 30, max_claims_per_user: 74,  max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 40, reward: 35, max_claims_per_user: 82,  max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 50, reward: 40, max_claims_per_user: 90,  max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 60, reward: 50, max_claims_per_user: 98,  max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 70, reward: 58, max_claims_per_user: 106, max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 80, reward: 65, max_claims_per_user: 114, max_claims_period: week, cooldown: 300 }
      - { min_tune_level: 90, reward: 75, max_claims_per_user: 120, max_claims_period: week, cooldown: 300 }

  # gm_checkin — daily ritual check-in. Gentler curve since it's once a day.
  gm_checkin:
    description: "Daily check-in greeting; small ritual reward."
    detection_config:
      pattern: "^(gm|good morning)\\b"
      cooldown_hours: 6
    tiers:
      - { min_tune_level: 0,  reward: 10, max_claims_per_user: 1, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 10, reward: 11, max_claims_per_user: 1, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 20, reward: 12, max_claims_per_user: 2, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 30, reward: 14, max_claims_per_user: 2, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 40, reward: 16, max_claims_per_user: 2, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 50, reward: 19, max_claims_per_user: 2, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 60, reward: 22, max_claims_per_user: 3, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 70, reward: 26, max_claims_per_user: 3, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 80, reward: 32, max_claims_per_user: 3, max_claims_period: day, cooldown: 21600 }
      - { min_tune_level: 90, reward: 40, max_claims_per_user: 3, max_claims_period: day, cooldown: 21600 }

  # reaction_threshold — your message gets enough credible reactors.
  reaction_threshold:
    description: "Popular content — N distinct credible reactors within spread window."
    detection_config:
      reactor_threshold: 5             # bumped from default 3
      min_reactor_credibility: 40      # credScore filter
      burst_window_seconds: 30         # reactions arriving within 30s of first count as one
      spread_window_seconds: 300
      voter_reward: 2                  # small reactor reward; gated on parent passing quality
    tiers:
      - { min_tune_level: 0,  reward: 15, max_claims_per_user: 3,  max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 10, reward: 17, max_claims_per_user: 4,  max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 20, reward: 20, max_claims_per_user: 5,  max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 30, reward: 22, max_claims_per_user: 6,  max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 40, reward: 26, max_claims_per_user: 7,  max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 50, reward: 30, max_claims_per_user: 8,  max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 60, reward: 36, max_claims_per_user: 9,  max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 70, reward: 44, max_claims_per_user: 10, max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 80, reward: 52, max_claims_per_user: 11, max_claims_period: day, cooldown: 600 }
      - { min_tune_level: 90, reward: 60, max_claims_per_user: 12, max_claims_period: day, cooldown: 600 }

  # social_link — sharing a relevant link to Resonance Network or partner content.
  # Infrequent, weekly cap.
  social_link:
    description: "Share a Resonance Network or partner link; weekly cap."
    detection_config:
      url_allowlist: ["*.rsnc.network"]   # other URLs are weak anchors
      cooldown_hours: 6
    tiers:
      - { min_tune_level: 0,  reward: 30,  max_claims_per_user: 10, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 10, reward: 34,  max_claims_per_user: 12, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 20, reward: 40,  max_claims_per_user: 14, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 30, reward: 46,  max_claims_per_user: 15, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 40, reward: 55,  max_claims_per_user: 17, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 50, reward: 65,  max_claims_per_user: 18, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 60, reward: 76,  max_claims_per_user: 19, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 70, reward: 88,  max_claims_per_user: 20, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 80, reward: 92,  max_claims_per_user: 20, max_claims_period: week, cooldown: 21600 }
      - { min_tune_level: 90, reward: 100, max_claims_per_user: 20, max_claims_period: week, cooldown: 21600 }

# ─────────────────────────────────────────────────────────────────────────────
# Unlock Events (additive, tune-gated)
# ─────────────────────────────────────────────────────────────────────────────
# Single row each. Members qualify only when their tune_level >= min_tune_level.
# Locked events appear in the "🔒 Upcoming Unlocks" section of /cooldowns
# as motivation, but cannot be claimed.
unlock_events:

  # L0 — entry-level: create a thread, get 2+ distinct users to post in it.
  - event_type: thread_starter
    min_tune_level: 0
    reward: 30
    max_claims_per_user: 2
    max_claims_period: day
    detection_config:
      trigger: thread_create_with_activity
      distinct_users_required: 2
      time_window_hours: 24

  # L10 — host a Stage with 3+ distinct attendees.
  - event_type: stage_host
    min_tune_level: 10
    reward: 120
    max_claims_per_user: 1
    max_claims_period: week
    detection_config:
      trigger: stage_instance_create
      distinct_attendees_required: 3
      sustained_seconds: 60

  # L20 — reply to a message that already has ≥3 unique reactors.
  - event_type: deep_reply
    min_tune_level: 20
    reward: 24
    max_claims_per_user: 5
    max_claims_period: day
    detection_config:
      trigger: reply_to_endorsed_message
      parent_min_unique_reactors: 3

  # L30 — your message gets replies from ≥3 distinct users within 1h.
  - event_type: conversation_starter
    min_tune_level: 30
    reward: 40
    max_claims_per_user: 3
    max_claims_period: day
    detection_config:
      trigger: message_attracts_distinct_repliers
      distinct_repliers_required: 3
      time_window_minutes: 60

  # L40 — sustain ≥60 continuous voice minutes in one channel.
  - event_type: voice_sustained
    min_tune_level: 40
    reward: 48
    max_claims_per_user: 3
    max_claims_period: week
    detection_config:
      trigger: voice_session_continuous
      min_minutes: 60
      channel_hopping_resets: true

  # L50 — reply to a new member (joined ≤7d, <5 server msgs) within 24h.
  - event_type: mentor_reach
    min_tune_level: 50
    reward: 36
    max_claims_per_user: 3
    max_claims_period: day
    detection_config:
      trigger: reply_to_new_member
      target_max_age_days: 7
      target_max_msg_count: 5
      response_window_hours: 24
      one_per_target_per_week: true

  # L60 — @mentioned by ≥5 distinct users within 24h.
  - event_type: traffic_director
    min_tune_level: 60
    reward: 80
    max_claims_per_user: 1
    max_claims_period: week
    detection_config:
      trigger: distinct_mentioners_window
      distinct_mentioners_required: 5
      time_window_hours: 24

  # L70 — post a link with ≥3 distinct reactors; message also passes quality gate.
  - event_type: resonance_beacon
    min_tune_level: 70
    reward: 60
    max_claims_per_user: 3
    max_claims_period: week
    detection_config:
      trigger: link_message_endorsed
      distinct_reactors_required: 3
      requires_quality_pass: true

  # L80 — reply to a question; OP reacts ✅/🙏-class OR reply gets ≥3 reactors.
  - event_type: answered_question
    min_tune_level: 80
    reward: 90
    max_claims_per_user: 2
    max_claims_period: day
    detection_config:
      trigger: question_answered
      op_endorsement_emojis: ["✅", "👍", "🙏", "❤️", "💯"]
      fallback_distinct_reactors: 3
      fallback_window_hours: 24

  # L90 — first message in a channel after ≥8h silence; passes quality gate.
  - event_type: dawn_patrol
    min_tune_level: 90
    reward: 72
    max_claims_per_user: 1
    max_claims_period: day  # guild-wide, not per-channel
    detection_config:
      trigger: first_message_after_silence
      silence_hours: 8
      requires_quality_pass: true
      cap_scope: guild       # prevents rotating through silent channels

# ─────────────────────────────────────────────────────────────────────────────
# Quality Gate
# ─────────────────────────────────────────────────────────────────────────────
# Per-server settings. The threshold is computed as 40 + strictness * 6.
# Heuristic penalties apply after the weighted composite, before threshold check.
quality_gate:
  default_strictness: 7              # threshold = 40 + 7*6 = 82
  heuristics:
    anchor_score_penalty: 30         # H1: subtracted when no anchor present
    chain_similarity_threshold: 0.6  # H3: penalty starts above this Jaccard sim
    chain_similarity_penalty_max: 30 # H3: max penalty at sim=0.9
    reply_passed_parent_bonus: 10    # H3: bonus when parent passed quality gate
    dead_channel_penalty: 10         # H4: applied in busy servers if channel idle
    dead_channel_member_threshold: 100  # H4: only applies in servers >=100 members
    dead_channel_idle_minutes: 30
  reaction_gate:
    min_reactor_credibility: 40              # credScore floor for counting reactors
    burst_window_seconds: 30                 # reactions within 30s of first → 1 reactor
    spread_window_seconds: 300               # min spread for "distinct" credit
    default_reactor_threshold: 5             # bumped from 3
    voter_reward_requires_parent_pass: true  # voter_reward only fires if parent passed
  url_allowlist:
    - "*.rsnc.network"
    # Add partner domains here if you want them treated as strong anchors.
