{
  "agents": {
    "developer": {
      "model": "sonnet",
      "rationale": "Balanced capability for implementation tasks"
    },
    "senior_software_engineer": {
      "model": "opus",
      "rationale": "Escalation from developer - handles complex failures requiring deep reasoning"
    },
    "qa_expert": {
      "model": "sonnet",
      "rationale": "Balanced capability for test generation and validation"
    },
    "tech_lead": {
      "model": "opus",
      "rationale": "Always Opus - critical architectural decisions and security review"
    },
    "project_manager": {
      "model": "opus",
      "rationale": "Always Opus - strategic planning and final quality gate"
    },
    "investigator": {
      "model": "opus",
      "rationale": "Complex debugging and root cause analysis"
    },
    "requirements_engineer": {
      "model": "opus",
      "rationale": "Complex requirements analysis, codebase discovery, and risk assessment requiring deep reasoning"
    },
    "validator": {
      "model": "sonnet",
      "rationale": "Independent BAZINGA verification - spawned only by PM"
    },
    "orchestrator": {
      "model": "sonnet",
      "rationale": "Coordination and routing - inline execution via slash command"
    },
    "tech_stack_scout": {
      "model": "sonnet",
      "rationale": "Deep project analysis for tech stack detection - runs once at Step 0.5"
    }
  },
  "escalation_rules": {
    "developer_to_senior_software_engineer": {
      "triggers": [
        "revision_count >= 1",
        "challenge_level_3_fail",
        "challenge_level_4_fail"
      ],
      "description": "Escalate after first failure or Level 3-4 challenge fails"
    },
    "senior_software_engineer_to_tech_lead": {
      "triggers": [
        "senior_software_engineer_revision >= 2",
        "architectural_concern"
      ],
      "description": "Escalate after Senior Software Engineer struggles twice"
    }
  },
  "task_type_routing": {
    "research": {
      "agent": "requirements_engineer",
      "model": "sonnet",
      "markers": ["[R]", "research", "evaluate", "select", "compare", "design", "architecture"],
      "matching": "case-insensitive",
      "note": "Removed 'analyze' - too generic (e.g., 'analyze logs', 'analyze test results' matched research but should be debugging). Prefer explicit [R] marker.",
      "description": "External research, vendor comparison, technology decisions, architecture design"
    },
    "implementation": {
      "agent": "developer",
      "model": "from_complexity_score",
      "description": "Default for code implementation (uses complexity scoring)"
    },
    "security": {
      "agent": "senior_software_engineer",
      "model": "opus",
      "markers": ["auth", "authentication", "authorization", "security", "crypto", "encryption", "password", "jwt", "oauth", "saml", "sso", "bearer", "credential"],
      "note": "Removed generic 'token' - too broad (matches CSRF token, string token). Added 'bearer', 'credential' instead.",
      "matching": "case-insensitive",
      "flags": {"security_sensitive": true},
      "description": "Security-sensitive tasks - always SSE + mandatory TL review"
    }
  },
  "_metadata": {
    "version": "1.3.0",
    "description": "Model selection, escalation rules, and task type routing for BAZINGA agents",
    "last_updated": "2025-12-04",
    "notes": [
      "Tech Lead and PM are ALWAYS on Opus - non-negotiable",
      "Developer uses Sonnet for balanced capability",
      "Senior Software Engineer on Opus handles escalated complexity",
      "Escalation triggers after 1 failure (not 2)",
      "Security tasks always use SSE + mandatory TL review",
      "Research/architecture tasks route to Requirements Engineer",
      "Tech Stack Scout runs at Step 0.5 to detect project stack before PM"
    ]
  }
}
