# Claude Code Review — Analysis Workflow
#
# Thin wrapper around .github/workflows/ai-review-analysis.yml so provider
# specific triggers and workflow_dispatch inputs stay stable while the shared
# implementation lives in one reusable workflow.

name: Claude Code Review

on:
  workflow_run:
    workflows: ["facebook/rocksdb/pr-jobs"]
    types: [completed]

  # The early pull_request_target path is limited to same-repo PRs by the job
  # condition below. Fork PRs skip this path and rely on workflow_run instead.
  pull_request_target:
    types: [opened, reopened, synchronize]

  issue_comment:
    types: [created]

  workflow_dispatch:
    inputs:
      pr_number:
        description: PR number to review
        required: true
        type: number
      model:
        description: Claude model to use (defaults to latest Opus)
        required: false
        type: choice
        options:
          - claude-opus-4-6
          - claude-sonnet-4-6
        default: claude-opus-4-6
      thinking_budget:
        description: Override MAX_THINKING_TOKENS (blank = auto-classify, capped at 24000)
        required: false
        type: string
        default: ""

permissions:
  contents: read
  # The shared analysis workflow polls check state, inspects prior runs, and
  # reads PR metadata. Keep those permissions read-only in the caller.
  actions: read
  checks: read
  pull-requests: read

jobs:
  review:
    if: >-
      github.event_name != 'pull_request_target' ||
      github.event.pull_request.head.repo.full_name == github.repository
    uses: ./.github/workflows/ai-review-analysis.yml
    with:
      provider: claude
      display_name: Claude
      review_command: /claude-review
      query_command: /claude-query
      result_artifact_name: claude-review-result
      comment_file: claude-review-comment.md
      default_model: claude-opus-4-6
      selected_model: ${{ github.event_name == 'workflow_dispatch' && inputs.model || '' }}
      classifier_model: claude-sonnet-4-6
      recovery_model: claude-sonnet-4-6
      thinking_budget: ${{ github.event_name == 'workflow_dispatch' && inputs.thinking_budget || '' }}
      dispatch_pr_number: ${{ github.event_name == 'workflow_dispatch' && inputs.pr_number || '' }}
    secrets: inherit
