# Token Rules — Agent reward/penalty configuration for automations
#
# This file defines the token economy for agent actions.
# Modify values here to adjust incentives without code changes.
#
# Used by: timmy_automations.utils.token_rules

version: "1.0.0"
description: "Token economy rules for agent automations"

# ── Events ─────────────────────────────────────────────────────────────────
# Each event type defines rewards/penalties and optional gating thresholds

events:
  # Triage actions
  triage_success:
    description: "Successfully triaged an issue (scored and categorized)"
    reward: 5
    category: "triage"

  deep_triage_refinement:
    description: "LLM-driven issue refinement with acceptance criteria added"
    reward: 20
    category: "triage"

  quarantine_candidate_found:
    description: "Identified a repeat failure issue for quarantine"
    reward: 10
    category: "triage"

  # Daily Run completions
  daily_run_completed:
    description: "Completed a daily run cycle successfully"
    reward: 5
    category: "daily_run"

  golden_path_generated:
    description: "Generated a coherent mini-session plan"
    reward: 3
    category: "daily_run"

  weekly_narrative_created:
    description: "Generated weekly summary of work themes"
    reward: 15
    category: "daily_run"

  # PR merges
  pr_merged:
    description: "Successfully merged a pull request"
    reward: 10
    category: "merge"
    # Gating: requires minimum tokens to perform
    gate_threshold: 0

  pr_merged_with_tests:
    description: "Merged PR with all tests passing"
    reward: 15
    category: "merge"
    gate_threshold: 0

  # Test fixes
  test_fixed:
    description: "Fixed a failing test"
    reward: 8
    category: "test"

  test_added:
    description: "Added new test coverage"
    reward: 5
    category: "test"

  critical_bug_fixed:
    description: "Fixed a critical bug on main"
    reward: 25
    category: "test"

  # General operations
  automation_run:
    description: "Ran any automation (resource usage)"
    penalty: -1
    category: "operation"

  automation_failure:
    description: "Automation failed or produced error"
    penalty: -2
    category: "operation"

  cycle_retro_logged:
    description: "Logged structured retrospective data"
    reward: 5
    category: "operation"

  pre_commit_passed:
    description: "Pre-commit checks passed"
    reward: 2
    category: "operation"

  pre_commit_failed:
    description: "Pre-commit checks failed"
    penalty: -1
    category: "operation"

# ── Gating Thresholds ──────────────────────────────────────────────────────
# Minimum token balances required for sensitive operations

gating_thresholds:
  pr_merge: 0
  sensitive_config_change: 50
  agent_workspace_create: 10
  deep_triage_run: 0

# ── Daily Limits ───────────────────────────────────────────────────────────
# Maximum tokens that can be earned/spent per category per day

daily_limits:
  triage:
    max_earn: 100
    max_spend: 0
  daily_run:
    max_earn: 50
    max_spend: 0
  merge:
    max_earn: 100
    max_spend: 0
  test:
    max_earn: 100
    max_spend: 0
  operation:
    max_earn: 50
    max_spend: 50

# ── Audit Settings ─────────────────────────────────────────────────────────
# Settings for token audit and inspection

audit:
  log_all_transactions: true
  log_retention_days: 30
  inspectable_by: ["orchestrator", "auditor", "timmy"]
