Skip to content

:hedgehog: PostHog is the leading platform for building self-driving products. Our developer tools – AI observability, analytics, session replay, flags, experiments, error tracking, logs, and more – capture all the context agents need to diagnose problems, uncover opportunities, and ship fixes. Steer it all from Slack, web, desktop, or the MCP.

156 KB
Raw Blame
/**
 * Auto-generated from the Django backend OpenAPI schema.
 * To modify these types, update the Django serializers or views, then run:
 *   hogli build:openapi
 * Questions or issues? #team-devex on Slack
 *
 * PostHog API - generated
 * OpenAPI spec version: 1.0.0
 */
export interface AuthorApi {
    /** Login handle of the pull request author. */
    handle: string
    /** Human-readable name; equals the handle in v1. */
    display_name: string
    /** URL of the author's avatar image. */
    avatar_url: string
    /** True if the author is a bot (handle ends in [bot] or is a known bot). */
    is_bot: boolean
}

export interface RepoRefApi {
    /** Code host provider, e.g. 'github'. */
    provider: string
    /** Repository owner or organization. */
    owner: string
    /** Repository name. */
    name: string
}

export interface CIStatusRollupApi {
    /** Distinct workflows run on the PR's head SHA. */
    runs: number
    /** Latest runs that completed with conclusion 'success'. */
    passing: number
    /** Latest runs that ended in failure, timeout, startup failure, or staleness. */
    failing: number
    /** Latest runs not yet completed (queued or in progress). */
    pending: number
    /** Latest runs that completed without a pass-or-fail verdict: cancelled, skipped, neutral, or action required. Together with the three counts above this covers every run, so a PR whose CI was entirely cancelled is not readable as passing. */
    inconclusive: number
    /** The workflow names behind `failing`, sorted - names what is failing instead of leaving a bare count. */
    failing_workflows?: string[]
}

export interface PushCISampleApi {
    /** Head commit SHA of this push (CI round). */
    head_sha: string
    /** Earliest workflow-run start on this push. */
    started_at: string
    /**
     * Wall-clock CI seconds for this push: earliest run start to latest completed run end. Null while nothing has completed.
     * @nullable
     */
    wall_seconds: number | null
    /** True when any latest-per-workflow run on this push ended in a decisive failure. */
    failed: boolean
    /** True when any latest-per-workflow run on this push hasn't completed yet. */
    pending: boolean
}

/**
 * * `open` - Open
 * * `closed` - Closed
 * * `merged` - Merged
 */
export type PRStateEnumApi = (typeof PRStateEnumApi)[keyof typeof PRStateEnumApi]

export const PRStateEnumApi = {
    Open: 'open',
    Closed: 'closed',
    Merged: 'merged',
} as const

export interface PullRequestListItemApi {
    /** The pull request author. */
    author: AuthorApi
    /** Repository the pull request belongs to. */
    repo: RepoRefApi
    /** CI status from the latest workflow runs on the head SHA. */
    ci: CIStatusRollupApi
    /** This PR's CI rounds oldest-first, capped to the most recent pushes - one sample per push for the push-history sparkline. `pushes` stays the uncapped count. */
    push_history: PushCISampleApi[]
    /** Pull request number within the repository. */
    number: number
    /** Pull request title. */
    title: string
    /** Derived state: 'open', 'closed', or 'merged'.
     *
     * * `open` - Open
     * * `closed` - Closed
     * * `merged` - Merged */
    state: PRStateEnumApi
    /** True if the pull request is a draft. */
    is_draft: boolean
    /** When the pull request was opened. */
    created_at: string
    /**
     * When the pull request was merged, or null.
     * @nullable
     */
    merged_at: string | null
    /**
     * Coarse open-to-merge time in seconds (merged_at - created_at; fuses draft and ready-for-review time). Null until merged.
     * @nullable
     */
    open_to_merge_seconds: number | null
    /**
     * True ready-to-merge cycle time in seconds: merged_at minus the last observed ready_for_review transition (only the last draft/ready switch counts), or minus created_at for a merged PR verifiably never drafted. Null when unmerged or not observed (the PR's life isn't fully inside the synced issue-event window) - null never means zero.
     * @nullable
     */
    ready_to_merge_seconds: number | null
    /** GitHub label names on the pull request. */
    labels: string[]
    /** CI triggers attributed to this PR: distinct head SHAs across its workflow runs. Fork-PR runs are unattributed. */
    pushes: number
    /** Workflow runs attributed to this PR that were a 2nd+ attempt (a re-run). */
    rerun_cycles: number
    /**
     * Estimated CI cost in USD summed over this PR's jobs (billable runners only). Null when nothing was costable or the job-level source isn't synced.
     * @nullable
     */
    estimated_cost_usd?: number | null
    /**
     * Billable (self-hosted) minutes summed over this PR's jobs. Null when the job source isn't synced.
     * @nullable
     */
    billable_minutes?: number | null
}

export interface AttentionPullRequestListApi {
    /** Open pull requests needing attention, failing CI first, then newest, capped at `limit`. */
    items: PullRequestListItemApi[]
    /** Number of open pull requests needing attention, including the ones past the cap. */
    total: number
    /** Maximum number of pull requests returned in `items`. */
    limit: number
}

/**
 * * `ci` - CI
 * * `review` - Review
 * * `queue` - Queue
 * * `rework` - Rework
 */
export type FrictionGroupEnumApi = (typeof FrictionGroupEnumApi)[keyof typeof FrictionGroupEnumApi]

export const FrictionGroupEnumApi = {
    Ci: 'ci',
    Review: 'review',
    Queue: 'queue',
    Rework: 'rework',
} as const

export interface FrictionGroupShareApi {
    /** ci (red CI and CI waits), review (waiting for the first approval), queue (merge-queue time and failed queue attempts), or rework (own failures and extra pushes).
     *
     * * `ci` - CI
     * * `review` - Review
     * * `queue` - Queue
     * * `rework` - Rework */
    group: FrictionGroupEnumApi
    /** This group's part of the score, in the same 'x typical' unit. The parts add up. */
    score: number
}

export interface AuthorFrictionApi {
    /** The score split by the kind of friction. */
    groups: FrictionGroupShareApi[]
    /** GitHub login. */
    author: string
    /** The author's GitHub avatar, or empty when the pull requests carry none. */
    avatar_url: string
    /** Friction as a multiple of the typical author: 1.0 is typical, 2.0 is twice as much. Counts only what happened to the author, never how much or how fast they ship. */
    score: number
    /** The author's merged pull requests in the window. */
    pr_count: number
    /** Position by friction in the repository, 1 is the most. */
    rank: number
    /** Low end of the rank band: the 10th percentile rank over resamples of the author's pull requests, and never above rank. */
    rank_low: number
    /** High end of the rank band: the 90th percentile rank over the same resamples, and never below rank. */
    rank_high: number
    /** The author's GitHub teams. Empty when the membership table isn't synced. */
    teams?: string[]
}

export interface TeamFrictionApi {
    /** GitHub team slug. */
    github_team: string
    /** The median friction of the team's scored members, in 'x typical' units. */
    median_score: number
    /** Members with enough merged pull requests to score. A team shows only above a floor, so one or two people never read as a team's figure. */
    scored_author_count: number
}

export interface AuthorFrictionListApi {
    /** Authors by friction, most first. */
    items: AuthorFrictionApi[]
    /** Teams with at least 3 scored members, by median member friction, most first. */
    teams: TeamFrictionApi[]
    /** False when the per-PR friction view does not exist yet: it needs a GitHub source with workflow runs, workflow jobs and pull requests synced. */
    available: boolean
    /** Pull requests merged in this many days before the view last refreshed. */
    window_days: number
    /** Authors with at least 3 merged pull requests, all ranked together. A team list keeps these repository-wide ranks. */
    ranked_author_count: number
    /**
     * The team the list is filtered to, or null for every author.
     * @nullable
     */
    github_team: string | null
    /** False when the team membership table isn't synced, so a team filter matches nobody. */
    has_membership_data: boolean
}

export interface PullRequestFrictionItemApi {
    /** The pull request's friction split by kind. */
    groups: FrictionGroupShareApi[]
    /** Pull request number. */
    number: number
    /** Repository owner. */
    repo_owner: string
    /** Repository name. */
    repo_name: string
    /** Pull request title, empty when the snapshot has none. */
    title: string
    /** Friction as a multiple of the typical pull request in the repository. */
    score: number
}

export interface AuthorFrictionDetailApi {
    /** The author's score and rank. Null below 3 merged pull requests in the window. */
    author: AuthorFrictionApi | null
    /** The author's teams without the author, each only with at least 2 other scored members. */
    teams: TeamFrictionApi[]
    /** The author's pull requests that added the most friction, most first. */
    pull_requests: PullRequestFrictionItemApi[]
    /** False when the per-PR friction view does not exist yet: it needs a GitHub source with workflow runs, workflow jobs and pull requests synced. */
    available: boolean
    /** Pull requests merged in this many days before the view last refreshed. */
    window_days: number
    /** Authors ranked in the repository: the denominator of rank. */
    ranked_author_count: number
    /** False when the team membership table isn't synced. */
    has_membership_data: boolean
    /** The author's merged pull requests in the window. */
    pr_count: number
}

export interface PRLLMSpendApi {
    /** Total agent LLM token cost in USD attributed to this PR (sum of $ai_total_cost_usd over the matched $ai_generation events). */
    cost_usd: number
    /** Total input (prompt) tokens across the attributed generations. */
    input_tokens: number
    /** Total output (completion) tokens across the attributed generations. */
    output_tokens: number
    /** Number of $ai_generation events attributed to this PR by git branch ($ai_git_branch). */
    generations: number
    /** Total prompt tokens read from the provider's prompt cache across the attributed generations ($ai_cache_read_input_tokens). Not included in input_tokens. */
    cache_read_input_tokens: number
    /** Total prompt tokens written to the provider's prompt cache across the attributed generations ($ai_cache_creation_input_tokens). Not included in input_tokens. */
    cache_creation_input_tokens: number
    /** Largest prompt any single attributed generation sent: input plus cache read plus cache write tokens. */
    peak_context_tokens: number
}

export interface AuthorPRLLMSpendApi {
    /** Agent LLM token spend attributed to this pull request, by the same rule as `pr_cost`, or null when no generation matched. */
    llm_spend: PRLLMSpendApi | null
    /** Pull request number. */
    number: number
    /** Pull request title. */
    title: string
    /** Pull request state: open, closed, or merged.
     *
     * * `open` - Open
     * * `closed` - Closed
     * * `merged` - Merged */
    state: PRStateEnumApi
    /** The pull request's head branch, which attribution joins on. */
    head_branch: string
    /** When the pull request was opened. */
    created_at: string
}

export interface AuthorLLMSpendListApi {
    /** The author's pull requests active in the window, newest first, capped at `limit`. Each spend covers the pull request's whole attribution window, so it can include spend from before date_from. */
    items: AuthorPRLLMSpendApi[]
    /** True when more pull requests matched than `limit`. */
    truncated: boolean
    /** Maximum number of pull requests returned in `items`. */
    limit: number
}

export interface WorkflowCostApi {
    /** GitHub Actions workflow name this cost is for. */
    workflow_name: string
    /** Billable (self-hosted) minutes for this workflow within the scope. */
    billable_minutes: number
    /**
     * Estimated dollar cost for this workflow, or null when nothing was costable.
     * @nullable
     */
    estimated_cost_usd: number | null
    /** Costed jobs for this workflow (billable Linux runner, finished). */
    costed_jobs: number
    /** Billable Linux jobs still queued/running for this workflow. */
    unsettled_jobs: number
    /** Provider-hosted/non-Linux jobs for this workflow, outside the estimate. */
    excluded_jobs: number
}

/**
 * * `breaking_master` - Breaking Master
 * * `blocking_merge_queue` - Blocking Merge Queue
 * * `novel_burst` - Novel Burst
 * * `potentially_resolved` - Potentially Resolved
 * * `flaky` - Flaky
 * * `pr_only` - PR Only
 */
export type BrokenTestStateEnumApi = (typeof BrokenTestStateEnumApi)[keyof typeof BrokenTestStateEnumApi]

export const BrokenTestStateEnumApi = {
    BreakingMaster: 'breaking_master',
    BlockingMergeQueue: 'blocking_merge_queue',
    NovelBurst: 'novel_burst',
    PotentiallyResolved: 'potentially_resolved',
    Flaky: 'flaky',
    PrOnly: 'pr_only',
} as const

/**
 * * `github_actions` - GitHub Actions
 * * `depot_ci` - Depot CI
 */
export type CIEngineEnumApi = (typeof CIEngineEnumApi)[keyof typeof CIEngineEnumApi]

export const CIEngineEnumApi = {
    GithubActions: 'github_actions',
    DepotCi: 'depot_ci',
} as const

export interface BrokenTestRowApi {
    /** Stable identity of this distinct failure: the failing test's node id plus a normalized error signature, so the same failure across runs groups into one row. */
    fingerprint: string
    /** The pytest node id from the CI 'FAILED <id>' line: the failing test. */
    test_id: string
    /** The trailing failure detail with volatile bits (numbers, hashes) normalized, shared across runs of the same failure. Empty when the FAILED line carried no detail. */
    error_signature: string
    /** The CI job the failure most recently came from. Matched against default-branch job status to decide whether trunk is currently broken by it. */
    job_name: string
    /** 'owner/name' repository the failure belongs to. */
    repo: string
    /** The classifier's verdict on how this failure is behaving right now: 'breaking_master' (failing on trunk, latest trunk run still red), 'blocking_merge_queue' (stopped a merge on a commit that already passed the PR's own CI, trunk still green), 'novel_burst' (new within a day and spreading across branches, not on trunk yet), 'potentially_resolved' (hit trunk but trunk is green again), 'flaky' (sporadic across branches over more than a day), or 'pr_only' (confined to one branch: one PR's own problem).
     *
     * * `breaking_master` - Breaking Master
     * * `blocking_merge_queue` - Blocking Merge Queue
     * * `novel_burst` - Novel Burst
     * * `potentially_resolved` - Potentially Resolved
     * * `flaky` - Flaky
     * * `pr_only` - PR Only */
    state: BrokenTestStateEnumApi
    /** Earliest failure line for this fingerprint in the analysis window. */
    first_seen: string
    /** Most recent failure line for this fingerprint in the analysis window. */
    last_seen: string
    /** Total failure lines for this fingerprint in the window. An absolute count, never a rate: passing runs aren't in this data. */
    occurrences: number
    /** Distinct branches the failure appeared on in the window. */
    branches: number
    /** Failure lines on the default branch (master/main). 0 means it never reached trunk. */
    master_hits: number
    /** The most recent failing workflow run for this fingerprint: pass it to run_failure_logs to fetch the actual failing log lines. */
    latest_run_id: number
    /** The branch of the most recent failing run. */
    latest_branch: string
    /** Hourly failure counts over the last 24 hours, oldest first (fixed 24-slot array), for the row sparkline. All zeros when nothing failed in the last day. */
    trend_24h?: number[]
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    latest_ci_engine?: CIEngineEnumApi | null
}

export interface BrokenTestsResultApi {
    /** Classified failures ranked by triage urgency: breaking trunk first, single-PR failures last. */
    rows: BrokenTestRowApi[]
    /** Default-branch job names whose latest completed run is failing: the 'what's on fire right now' summary. Empty when the job-level source isn't synced or trunk is green. */
    breaking_master_jobs: string[]
    /** Length in days of the analysis window the counts cover. */
    window_days: number
    /** True when more failures qualified than the cap; `rows` is the top `limit` by urgency. */
    truncated: boolean
    /** Maximum number of rows returned. */
    limit: number
}

/**
 * * `running` - Sync Running
 * * `completed` - Sync Completed
 * * `failed` - Sync Failed
 */
export type CISignalsSyncStatusEnumApi = (typeof CISignalsSyncStatusEnumApi)[keyof typeof CISignalsSyncStatusEnumApi]

export const CISignalsSyncStatusEnumApi = {
    Running: 'running',
    Completed: 'completed',
    Failed: 'failed',
} as const

export interface CISignalsConfigApi {
    /** Whether this project has ever configured CI signals. */
    configured: boolean
    /** Whether every CI signal detector is enabled. */
    enabled: boolean
    /** Aggregate sync status for pull requests, workflow runs, and workflow jobs.
     *
     * * `running` - Sync Running
     * * `completed` - Sync Completed
     * * `failed` - Sync Failed */
    sync_status: CISignalsSyncStatusEnumApi | null
}

export interface CISignalsConfigUpdateApi {
    /** Enable or disable every CI signal detector atomically. */
    enabled: boolean
}

export interface CICardSummaryApi {
    /** Count of open pull requests. */
    open_prs: number
    /** Distinct repositories with at least one open pull request. */
    repos: number
    /** Open, non-draft, non-bot pull requests older than 7 days. */
    stuck: number
    /** Open pull requests with at least one failing latest CI run. May lag until the workflow_run webhook settles late completions. */
    failing_ci: number
}

export interface CIDataFreshnessApi {
    /**
     * When the last completed sync of the stored workflow runs started. Every stored run is at least this fresh. The older of the GitHub and Depot CI times when the repository syncs both. Null when a runs table has never synced.
     * @nullable
     */
    runs_synced_at: string | null
    /**
     * The same time for the stored workflow jobs. Null when jobs are not synced.
     * @nullable
     */
    jobs_synced_at: string | null
}

export interface CIFailureLogLineApi {
    /**
     * 1-based line number in the full pre-thinning job log, or null for a '... N lines omitted ...' marker. The gap between consecutive values is how many lines were elided.
     * @nullable
     */
    original_line: number | null
    /** The log line text, or the omission-marker text. */
    text: string
}

export interface CIJobFailureLogApi {
    /** The thinned failure-log lines in original order, with omission markers. */
    lines: CIFailureLogLineApi[]
    /** Integer job id of the failed job; unique only together with ci_engine. */
    job_id: number
    /** Workflow run id the job belongs to. */
    run_id: number
    /** Job conclusion ('failure', 'timed_out', ...). Only failed jobs have logs. */
    conclusion: string
    /** Git branch the run was triggered on, or '' when unknown. */
    branch: string
    /** Total lines in the full job log before thinning (the denominator for each line's original_line); 0 when unknown. */
    original_total_lines: number
    /** Number of lines returned for this job (after the per-job cap). */
    line_count: number
    /** True when the job had more failure lines than the per-job cap. */
    truncated: boolean
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    ci_engine?: CIEngineEnumApi | null
}

export interface CIFailureLogsApi {
    /** Repository the pull request belongs to. */
    repo: RepoRefApi
    /** Failed CI jobs with their thinned failure logs, grouped by job. */
    jobs: CIJobFailureLogApi[]
    /** Pull request number the failure logs are for. */
    pr_number: number
    /** Workflow runs attributed to the PR (across all its pushes) that were searched for logs. */
    runs_attributed: number
    /** False when no failure logs were found: CI hasn't failed, the logs aged out of the short Logs retention, or a fork PR carries no run association to resolve. */
    logs_available: boolean
    /** True when the overall line cap across all jobs was hit. */
    truncated: boolean
}

/**
 * * `success` - Success
 * * `failure` - Failure
 */
export type CITimingSampleStatusEnumApi = (typeof CITimingSampleStatusEnumApi)[keyof typeof CITimingSampleStatusEnumApi]

export const CITimingSampleStatusEnumApi = {
    Success: 'success',
    Failure: 'failure',
} as const

export interface CITimingSampleApi {
    /** Integer run id of the sampled run; unique only together with ci_engine. */
    run_id: number
    /** Run attempt the sample was taken from, which is the run's latest. */
    run_attempt: number
    /**
     * Job id of the matched job. Null for a workflow or matrix sample, which spans jobs.
     * @nullable
     */
    job_id: number | null
    /**
     * Number of the matched step in the sampled job. Steps match by name, so it can differ from the selected step's number. Null unless kind is 'step'.
     * @nullable
     */
    step_number: number | null
    /** CI engine that ran the sampled run.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    ci_engine: CIEngineEnumApi
    /**
     * Source-native run id; use with ci_engine to link to the run.
     * @nullable
     */
    native_run_id: string | null
    /**
     * Source-native workflow run id; use with ci_engine to link to the run.
     * @nullable
     */
    native_workflow_run_id: string | null
    /**
     * Source-native job id of the matched job. Null for a workflow or matrix sample.
     * @nullable
     */
    native_job_id: string | null
    /**
     * Source-native job attempt id of the matched job. Null for a workflow or matrix sample.
     * @nullable
     */
    native_attempt_id: string | null
    /** 'success' when every matched job succeeded, or the matched step did. Otherwise 'failure'.
     *
     * * `success` - Success
     * * `failure` - Failure */
    status: CITimingSampleStatusEnumApi
    /** For a workflow, matrix or job: seconds from the first matched job's start to the last one's end. For a step: the step's own duration. */
    duration_seconds: number
    /** When the last matched job finished. */
    completed_at: string
    /** Commit SHA the sampled run ran on. */
    head_sha: string
}

/**
 * * `workflow_id` - Workflow id
 * * `workflow_name` - Workflow name
 */
export type CITimingIdentityEnumApi = (typeof CITimingIdentityEnumApi)[keyof typeof CITimingIdentityEnumApi]

export const CITimingIdentityEnumApi = {
    WorkflowId: 'workflow_id',
    WorkflowName: 'workflow_name',
} as const

/**
 * * `default_branch_unknown` - Default branch unknown
 * * `jobs_not_synced` - Jobs not synced
 * * `not_executed` - Not executed
 */
export type CITimingUnavailableReasonEnumApi =
    (typeof CITimingUnavailableReasonEnumApi)[keyof typeof CITimingUnavailableReasonEnumApi]

export const CITimingUnavailableReasonEnumApi = {
    DefaultBranchUnknown: 'default_branch_unknown',
    JobsNotSynced: 'jobs_not_synced',
    NotExecuted: 'not_executed',
} as const

export interface CITimingContextApi {
    /** The newest matched samples of any status, newest first. At most three. */
    recent: CITimingSampleApi[]
    /**
     * The repository's default branch, which the samples ran on. Null when unknown.
     * @nullable
     */
    default_branch: string | null
    /** How many days back the comparison looks. */
    window_days: number
    /** How runs of the same workflow were found: by 'workflow_id', which a rename keeps, or by 'workflow_name' when the run has no workflow id.
     *
     * * `workflow_id` - Workflow id
     * * `workflow_name` - Workflow name */
    identity: CITimingIdentityEnumApi
    /** How many default-branch runs of the workflow were checked for a match. */
    runs_scanned: number
    /** True when the window held more eligible runs than were checked, so the figures cover the newest runs only. */
    sampled: boolean
    /** How many checked runs matched the selection and succeeded. */
    sample_count: number
    /**
     * Mean duration of the successful samples, in seconds. Null when there are none. A run counts only when it ran the same jobs on the same runners, so a null means no comparable run.
     * @nullable
     */
    average_seconds: number | null
    /**
     * When the last completed sync of the stored workflow runs started. Null when unknown.
     * @nullable
     */
    runs_synced_at: string | null
    /**
     * When the last completed sync of the stored workflow jobs started. Null when unknown.
     * @nullable
     */
    jobs_synced_at: string | null
    /** Why no comparison was made: 'default_branch_unknown' (no synced pull request names the repository's default branch), 'jobs_not_synced', or 'not_executed' (every selected job was skipped, so there is no duration to compare). Null when the comparison ran, even if it found no samples.
     *
     * * `default_branch_unknown` - Default branch unknown
     * * `jobs_not_synced` - Jobs not synced
     * * `not_executed` - Not executed */
    unavailable_reason: CITimingUnavailableReasonEnumApi | null
}

export interface CurrentBranchHealthApi {
    /** Detected default branch ('master' or 'main') from runs in the same 24-hour window. */
    default_branch: string
    /** Workflows with at least one completed run in the last 24 hours. */
    settled_workflows: number
    /** Workflows whose latest completed run in the last 24 hours failed or timed out. */
    failing_workflows: number
    /** Alphabetical preview of failing workflow names, capped at 20; use failing_workflows for the complete count. */
    failing_workflow_names: string[]
}

export interface ReadyToMergeMediansApi {
    /** Pull requests merged in the window, bots and drafts excluded. */
    merged_pr_count: number
    /**
     * Median seconds from the last ready_for_review to merge. Null when nothing was measured.
     * @nullable
     */
    ready_to_merge_seconds: number | null
    /**
     * 90th percentile of the ready-to-merge seconds.
     * @nullable
     */
    p90_ready_to_merge_seconds: number | null
    /**
     * Median seconds from ready to the first approval, over the pull requests with an approval. Null when nothing was measured.
     * @nullable
     */
    ready_to_first_approval_seconds: number | null
    /**
     * Median seconds from the first approval to merge. The two approval medians do not add up to the ready-to-merge median.
     * @nullable
     */
    first_approval_to_merge_seconds: number | null
    /**
     * Share (0 to 1) of all ready-to-merge hours spent before the first approval, summed over the pull requests, so long pull requests weigh more.
     * @nullable
     */
    before_first_approval_share: number | null
}

export interface TeamReadyToMergeMediansApi {
    /** Over the pull requests by the team's members, the same population as a github_team scope, without the pr_number pull request. Null when fewer than three other authors contribute a ready time, because the author could read a teammate's value back from the median. The approval medians are null on the same terms for approvals. */
    medians: ReadyToMergeMediansApi | null
    /** The GitHub team slug. */
    github_team: string
}

export interface PullRequestReadyToMergeApi {
    /** The pull request number. */
    number: number
    /**
     * Seconds from the last ready_for_review to merge. Null when not observed.
     * @nullable
     */
    ready_to_merge_seconds: number | null
    /**
     * Seconds from ready to the first approval. Null without an approval or review data.
     * @nullable
     */
    ready_to_first_approval_seconds: number | null
    /**
     * Seconds from the first approval to merge. Null without an approval or review data.
     * @nullable
     */
    first_approval_to_merge_seconds: number | null
    /**
     * Share (0 to 1) of the ready-to-merge time spent before the first approval.
     * @nullable
     */
    before_first_approval_share: number | null
}

/**
 * * `pull_request` - Pull Request
 * * `review_requests` - Review Requests
 * * `only_team` - Only Team
 * * `all_teams` - All Teams
 * * `no_team` - No Team
 */
export type ComparisonTeamBasisEnumApi = (typeof ComparisonTeamBasisEnumApi)[keyof typeof ComparisonTeamBasisEnumApi]

export const ComparisonTeamBasisEnumApi = {
    PullRequest: 'pull_request',
    ReviewRequests: 'review_requests',
    OnlyTeam: 'only_team',
    AllTeams: 'all_teams',
    NoTeam: 'no_team',
} as const

export interface DeliveryComparisonApi {
    /** Over the author's pull requests, without the pr_number pull request. */
    author_medians: ReadyToMergeMediansApi
    /** The author's teams that team_basis picked, sorted by slug. Empty for no_team. */
    teams: TeamReadyToMergeMediansApi[]
    /** Over every non-bot pull request in the repository, the author's included and the pr_number pull request left out. */
    repo_medians: ReadyToMergeMediansApi
    /** The pr_number pull request measured the same way, when it merged in the window. Null otherwise. */
    pull_request: PullRequestReadyToMergeApi | null
    /** The GitHub login the comparison is for. */
    author: string
    /** True when the team membership table is synced. Without it, team_basis is no_team. */
    has_membership_data: boolean
    /** False when reviews aren't synced: the approval medians are then null. */
    review_data_available: boolean
    /** False when issue events aren't synced: the ready-to-merge medians are then null. */
    ready_data_available: boolean
    /** How the teams were picked from the author's teams that own code: pull_request (the pr_number asked the team to review); review_requests (the team the author's pull requests asked to review most often in the window, with ties kept); only_team (the author is in one team); all_teams (no review request points at one team); no_team (no team, or no membership data).
     *
     * * `pull_request` - Pull Request
     * * `review_requests` - Review Requests
     * * `only_team` - Only Team
     * * `all_teams` - All Teams
     * * `no_team` - No Team */
    team_basis: ComparisonTeamBasisEnumApi
}

export interface ScopeRepoFigureApi {
    /**
     * The figure over the pull requests in scope. Null when the scope has nothing to measure.
     * @nullable
     */
    scope: number | null
    /**
     * The same figure over every non-bot pull request in the repository, the scope included. Null when the repository has nothing to measure.
     * @nullable
     */
    repo: number | null
}

export interface DurationDistributionApi {
    /** Pull requests in the distribution. Every statistic is null when this is 0. */
    pr_count: number
    /**
     * Fastest duration, in seconds.
     * @nullable
     */
    min_seconds: number | null
    /**
     * 5th percentile, in seconds: the lower whisker.
     * @nullable
     */
    p05_seconds: number | null
    /**
     * 25th percentile, in seconds: the box's lower edge.
     * @nullable
     */
    p25_seconds: number | null
    /**
     * Median, in seconds.
     * @nullable
     */
    p50_seconds: number | null
    /**
     * Mean, in seconds.
     * @nullable
     */
    mean_seconds: number | null
    /**
     * 75th percentile, in seconds: the box's upper edge.
     * @nullable
     */
    p75_seconds: number | null
    /**
     * 95th percentile, in seconds: the upper whisker.
     * @nullable
     */
    p95_seconds: number | null
    /**
     * Slowest duration, in seconds.
     * @nullable
     */
    max_seconds: number | null
}

export interface ScopeRepoDistributionApi {
    /** The deployed pull requests in scope. */
    scope: DurationDistributionApi
    /** Every deployed pull request in the repository. */
    repo: DurationDistributionApi
}

export interface DeliveryLeadTimeApi {
    /** Open to the first successful deploy containing the merge, over PRs deployed in the window. */
    open_to_deploy: ScopeRepoDistributionApi
    /** Open to merge over the same deployed PRs, so it composes with merge_to_deploy. Includes draft time. */
    open_to_merge: ScopeRepoDistributionApi
    /** Merge to deploy over the same deployed PRs. */
    merge_to_deploy: ScopeRepoDistributionApi
    /** False when the deployments and deployment statuses tables aren't synced. The distributions are then empty. */
    deploy_data_available: boolean
    /** The deploy environments lead time was scoped to: production by default. Empty when deploy data is not available. */
    environment_scope: string
    /** PRs in scope merged in the window (bots and drafts excluded). */
    merged_pr_count: number
    /** Of merged_pr_count, the PRs whose first successful in-scope deployment was observed by the window end. The rest are still waiting for a deploy or fall outside the scan. */
    deployed_merged_pr_count: number
}

/**
 * * `author` - Author
 * * `github_team` - GitHub Team
 * * `pull_request` - Pull Request
 */
export type DeliveryScopeKindEnumApi = (typeof DeliveryScopeKindEnumApi)[keyof typeof DeliveryScopeKindEnumApi]

export const DeliveryScopeKindEnumApi = {
    Author: 'author',
    GithubTeam: 'github_team',
    PullRequest: 'pull_request',
} as const

export interface DeliverySummaryApi {
    /** Median estimated CI cost per merged PR, in USD, over every run linked to the PR (merge-queue gate runs included) that started up to 30 days before the window. Null when the jobs table isn't synced. */
    cost_per_merged_pr_usd: ScopeRepoFigureApi
    /** Median billable runner minutes per merged PR, on the billed clock. Null when the jobs table isn't synced. */
    billable_minutes_per_merged_pr: ScopeRepoFigureApi
    /** Total CI cost divided by total pushes over the merged PRs: the price of one iteration. A push is a distinct head commit that triggered CI. */
    cost_per_push_usd: ScopeRepoFigureApi
    /** Median seconds from the last ready_for_review to merge. Null when issue events aren't synced. */
    median_ready_to_merge_seconds: ScopeRepoFigureApi
    /** 90th percentile of the ready-to-merge seconds. */
    p90_ready_to_merge_seconds: ScopeRepoFigureApi
    /** Median seconds from ready to the first approval. An approval given while the PR was a draft counts as 0. PRs merged without an approval are left out. Null when reviews aren't synced. */
    median_ready_to_first_approval_seconds: ScopeRepoFigureApi
    /** Median seconds from the first approval to merge. This median and the one before it do not add up to the ready-to-merge median. */
    median_first_approval_to_merge_seconds: ScopeRepoFigureApi
    /** Share (0 to 1) of all ready-to-merge hours spent before the first approval, summed over the PRs, so long PRs weigh more. The rest came after the approval. */
    before_first_approval_share: ScopeRepoFigureApi
    /** Mean pushes after the first approval per merged PR, over PRs with an approval. */
    pushes_after_approval_per_merged_pr: ScopeRepoFigureApi
    /** Mean merge-queue gate attempts per merged PR that went through the queue. A bisection probe folds into its attempt. */
    merge_queue_attempts_per_merged_pr: ScopeRepoFigureApi
    /** Share (0 to 1) of queue-landed merged PRs with at least one failed gate attempt. A failure caused by another PR ahead in the queue also counts, because the queue history is not in the warehouse. */
    failed_merge_queue_share: ScopeRepoFigureApi
    /** Lead time to deploy for the scope against the repository. */
    lead_time: DeliveryLeadTimeApi
    /** What the read covers: 'author' (one GitHub login), 'github_team' (the members of one GitHub team, through the team membership table), or 'pull_request' (one pull request).
     *
     * * `author` - Author
     * * `github_team` - GitHub Team
     * * `pull_request` - Pull Request */
    scope_kind: DeliveryScopeKindEnumApi
    /** The GitHub login or GitHub team slug the summary is for. */
    scope: string
    /** True when the team membership table is synced. A github_team scope without it matches no pull requests, so every scope figure is empty rather than the whole repository. */
    has_membership_data: boolean
    /** True when the workflow jobs table is synced, which cost needs. */
    jobs_available: boolean
    /** True when the reviews table is synced, which the approval split needs. */
    review_data_available: boolean
    /** True when issue events are synced, which ready-to-merge time needs. */
    ready_data_available: boolean
    /** PRs in scope opened in the window, drafts included, bots excluded. */
    opened_pr_count: number
    /** PRs in scope merged in the window (bots and drafts excluded): the population of every per-merged-PR figure. */
    merged_pr_count: number
    /** PRs in scope that are open and not drafts right now. Ignores the window. */
    open_pr_count: number
    /** PRs in scope that are open drafts right now. Ignores the window. */
    draft_pr_count: number
    /**
     * Estimated CI cost summed over the merged PRs in scope. Null when nothing was costable.
     * @nullable
     */
    total_cost_usd: number | null
    /**
     * Billable minutes summed over the merged PRs in scope. Null when the jobs table isn't synced.
     * @nullable
     */
    total_billable_minutes: number | null
    /** Pushes summed over the merged PRs in scope. */
    push_count: number
}

export interface DepotCIRepoUsageApi {
    /** Repository the Depot source syncs, as lowercase 'owner/name'. */
    repo: string
    /** Run time of the finished Depot CI job attempts that started in the window, hand-off jobs included. */
    elapsed_seconds: number
    /** elapsed_seconds at the Depot CI list price for a 2-vCPU sandbox. Depot does not report the sandbox size of an attempt. */
    estimated_cost_usd: number
}

export interface DeploymentFrequencyBucketApi {
    /** Bucket start, aligned to series_granularity (top of hour, midnight, or Monday). */
    bucket_start: string
    /** Deployments whose first success status landed in this bucket, within the environment scope. Zero-filled: 0 means nothing shipped. */
    deployment_count: number
}

export interface LeadTimeBucketApi {
    /** Bucket start, aligned to series_granularity (top of hour, midnight, or Monday). Keyed on deploy time: a PR lands in the bucket its first post-merge deploy succeeded in. */
    bucket_start: string
    /** PRs whose first post-merge successful deployment landed in this bucket (bots and drafts excluded; narrowed by github_team when given). The same population backs every lead-time series, so the stages compare bucket by bucket. */
    deployed_pr_count: number
    /**
     * Fastest duration for this stage in this bucket, in seconds. Null when nothing deployed.
     * @nullable
     */
    min_seconds: number | null
    /**
     * 5th percentile of the stage's duration, in seconds: the lower whisker when outliers are excluded. Null when nothing deployed.
     * @nullable
     */
    p05_seconds: number | null
    /**
     * 25th percentile of the stage's duration, in seconds. Null when nothing deployed.
     * @nullable
     */
    p25_seconds: number | null
    /**
     * Median of the stage's duration, in seconds. Null when nothing deployed.
     * @nullable
     */
    p50_seconds: number | null
    /**
     * Mean of the stage's duration, in seconds. Null when nothing deployed.
     * @nullable
     */
    mean_seconds: number | null
    /**
     * 75th percentile of the stage's duration, in seconds. Null when nothing deployed.
     * @nullable
     */
    p75_seconds: number | null
    /**
     * 95th percentile of the stage's duration, in seconds: the upper whisker when outliers are excluded. Null when nothing deployed.
     * @nullable
     */
    p95_seconds: number | null
    /**
     * Slowest duration for this stage in this bucket, in seconds. Null when nothing deployed.
     * @nullable
     */
    max_seconds: number | null
}

export interface DoraOverviewApi {
    /** Successful deployments per bucket across the window, oldest first, zero-filled, bucketed by series_granularity. Empty when the deploy tables aren't synced. */
    deployment_frequency_series: DeploymentFrequencyBucketApi[]
    /** Merge-to-deploy distribution per bucket across the window, oldest first: the box-plot series (min/p5/p25/p50/mean/p75/p95/max seconds per bucket). Empty when the deploy tables aren't synced, or when github_team was passed without membership data synced. */
    merge_to_deploy_series: LeadTimeBucketApi[]
    /** Open-to-merge distribution over the SAME deployed PRs and buckets as merge_to_deploy_series, so the two stages compare bucket by bucket. Not the all-merged-PRs cycle time. Empty in the same cases as merge_to_deploy_series. */
    open_to_merge_series: LeadTimeBucketApi[]
    /** Open-to-deploy distribution over the same deployed PRs and buckets: the full open to first-successful-deploy span the two stages above compose into. Empty in the same cases as merge_to_deploy_series. */
    open_to_deploy_series: LeadTimeBucketApi[]
    /** False when the deployments/deployment_statuses tables aren't synced for the selected repo; every other field is then empty or null, never a fake zero. */
    deploy_data_available: boolean
    /** Display label for the selected environments, comma-separated, 'persistent' when no persistent environments were discovered. Use selected_environments for exact names. */
    environment_scope: string
    /** Distinct persistent environments from the metric scan window or the 30 days before its end, whichever starts earlier, most-deployed first. Transient environments are omitted. */
    environments: string[]
    /** Exact environment names used for these metrics. Defaults to all persistent environments marked production or named prod/production (including regional suffixes), falling back to the busiest persistent environment. Explicit filters are trimmed and deduplicated. DRF rejects blank or unknown names; real transient names are allowed. */
    selected_environments: string[]
    /** True when the optional team-membership snapshot is synced. When false, a github_team filter cannot be honored and the merge-to-deploy figures go empty rather than silently unfiltered. */
    has_membership_data: boolean
    /** Distinct GitHub team slugs from the membership snapshot, sorted: the team picker's options. Empty when membership isn't synced. */
    github_teams: string[]
    /** Deployments whose first success status landed in the window, within the environment scope. */
    deployment_count: number
    /** Same count over the equal-length window before date_from. */
    deployment_count_prev: number
    /**
     * deployment_count normalized by the window length in days. Null only when the deploy tables aren't synced.
     * @nullable
     */
    deployments_per_day: number | null
    /**
     * Previous-window twin of deployments_per_day. Null only when the deploy tables aren't synced.
     * @nullable
     */
    deployments_per_day_prev: number | null
    /**
     * Median seconds from a PR's merge to the first successful deployment containing it (bots/drafts excluded; narrowed by github_team when given). Containment is resolved through the deploy's head commit, not the deploy's success time. Keyed on deploy time. This is merge-to-deploy, not full commit-to-deploy DORA lead time. Null when nothing deployed in the window.
     * @nullable
     */
    median_merge_to_deploy_seconds: number | null
    /**
     * Previous-window twin of median_merge_to_deploy_seconds.
     * @nullable
     */
    median_merge_to_deploy_seconds_prev: number | null
    /**
     * Median seconds from a PR's open to the first successful deployment containing it: the full open-to-deploy lead time over the same deployed-PR population as median_merge_to_deploy_seconds. Null when nothing deployed in the window.
     * @nullable
     */
    median_open_to_deploy_seconds: number | null
    /**
     * Previous-window twin of median_open_to_deploy_seconds.
     * @nullable
     */
    median_open_to_deploy_seconds_prev: number | null
    /** PRs first deployed in the window: the population behind the merge-to-deploy median and box plot. */
    deployed_pr_count: number
    /** Previous-window twin of deployed_pr_count. */
    deployed_pr_count_prev: number
    /** Deployments with at least one failure/error status, keyed on the first failure time. */
    failed_deployment_count: number
    /** Previous-window twin of failed_deployment_count. */
    failed_deployment_count_prev: number
    /**
     * Failed deployments over deployments that reached any outcome (success or failure). A change-failure proxy: no incident data is linked, so a deploy that succeeded but broke production is not counted. Null when nothing reached an outcome.
     * @nullable
     */
    failed_deployment_share: number | null
    /**
     * Previous-window twin of failed_deployment_share.
     * @nullable
     */
    failed_deployment_share_prev: number | null
    /**
     * Median seconds from a deployment's first failure status to the next successful deployment in the same environment. A time-to-restore proxy: recovery by anything other than a deploy is invisible, and failures not yet recovered are excluded. Null when no failed deploy recovered in the window.
     * @nullable
     */
    median_failed_deploy_to_next_success_seconds: number | null
    /**
     * Previous-window twin of median_failed_deploy_to_next_success_seconds.
     * @nullable
     */
    median_failed_deploy_to_next_success_seconds_prev: number | null
    /** PRs merged in the window (bots and drafts excluded; narrowed by github_team when given): the denominator behind unattributed_merged_pr_share. */
    merged_pr_count: number
    /**
     * Share of merged_pr_count no successful in-scope deployment attributed: recent merges still waiting for their deploy, plus merges whose deploy the scope or scan bounds miss. Null when nothing merged in the window.
     * @nullable
     */
    unattributed_merged_pr_share: number | null
    /**
     * The newest deployment status row synced, any environment: how fresh the deploy data is. Windows ending after this instant undercount. Null when the deploy tables are empty.
     * @nullable
     */
    latest_deploy_status_at: string | null
    /** Bucket width of every series: the granularity param when given, else chosen to fit the window: 'hour', 'day', or 'week'. */
    series_granularity: string
}

/**
 * * `pytest` - Pytest
 * * `jest` - Jest
 */
export type CITestRunnerEnumApi = (typeof CITestRunnerEnumApi)[keyof typeof CITestRunnerEnumApi]

export const CITestRunnerEnumApi = {
    Pytest: 'pytest',
    Jest: 'jest',
} as const

/**
 * * `confirmed_flake` - Confirmed Flake
 * * `suspected_regression` - Suspected Regression
 * * `quarantined` - Quarantined
 */
export type FlakyTestClassificationEnumApi =
    (typeof FlakyTestClassificationEnumApi)[keyof typeof FlakyTestClassificationEnumApi]

export const FlakyTestClassificationEnumApi = {
    ConfirmedFlake: 'confirmed_flake',
    SuspectedRegression: 'suspected_regression',
    Quarantined: 'quarantined',
} as const

export interface FlakyTestItemApi {
    /** Test runner that emitted this signal: 'pytest' or 'jest'.
     *
     * * `pytest` - Pytest
     * * `jest` - Jest */
    runner: CITestRunnerEnumApi
    /** Runner-specific stable test identity (the CI span name). This is a grouping key, not necessarily runnable; use `selector` to run or quarantine the test. */
    nodeid: string
    /** Runnable pytest or Jest selector. Exact when the CI reporter emitted it; older pytest spans use a best-effort reconstruction from the nodeid. */
    selector: string
    /** confirmed_flake: one commit both failed and passed the test (a re-run attempt went green, or an in-job retry recovered it), so it is provably nondeterministic. quarantined: a tolerated failure was recorded while it was masked. suspected_regression: only failures were recorded, which is absence of proof, not proof that it is a real break.
     *
     * * `confirmed_flake` - Confirmed Flake
     * * `suspected_regression` - Suspected Regression
     * * `quarantined` - Quarantined */
    classification: FlakyTestClassificationEnumApi
    /** Runs where one commit both failed and passed the test: a 'Re-run failed jobs' attempt went green on the same commit, or an in-job pytest retry (tests hand-marked @pytest.mark.flaky(reruns=N)) recovered it. A pass in a different run is a different commit and never counts. */
    same_commit_recovery_run_count: number
    /** Distinct CI runs whose recorded outcome was failed or error. A run counts once however many matrix legs it failed in. */
    failed_run_count: number
    /** Distinct pull requests among the failed runs. Failures on master or unattributed branches carry no PR number and are excluded here (still in failed_run_count). */
    failed_pr_count: number
    /** Failed runs on the default branch (master/main approximation): the 'matters right now' signal that a test is breaking the trunk, not just PR branches. */
    master_failed_run_count: number
    /** Runs where the test recorded a tolerated failure while quarantined: already masked in CI, still failing. */
    quarantined_failed_run_count: number
    /** Most recent failure, recovery, or quarantined-failure run for this test in the window. */
    last_signal_at: string
}

export interface FlakyTestListApi {
    /** Tests worth acting on now, ranked by blast radius: master failures, then PRs hit, then runs. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a job attempt with 100 or more distinct failed or errored tests) excludes every trial of that attempt, not only its failures. */
    items: FlakyTestItemApi[]
    /** True when more tests qualified than the cap; `items` is the highest-ranked `limit` rows. */
    truncated: boolean
    /** Maximum number of tests returned in `items`. */
    limit: number
}

export interface WorkflowJobAggregateApi {
    /** De-sharded job name: the matrix '(G/N)' suffix is stripped and unexpanded '${{ matrix.* }}' templates are collapsed, so shards of one matrix aggregate together. */
    job_name: string
    /** Job instances observed in the window (all shards, all attempts). */
    job_count: number
    /** Distinct raw job names inside the group - the observed matrix width. */
    shard_count: number
    /** Distinct workflow runs the job appeared in. */
    runs_in: number
    /**
     * runs_in divided by the workflow's total runs in the window; below 1.0 means the job is conditional and skips some runs. Null when the workflow had no runs.
     * @nullable
     */
    run_share: number | null
    /**
     * Median queue wait (created to started) in seconds - where runner-capacity problems hide. Null when nothing started.
     * @nullable
     */
    queue_p50_seconds: number | null
    /**
     * Median duration of successful job instances, in seconds: cancelled and failed instances end early and would bias the percentile. Null if none succeeded.
     * @nullable
     */
    p50_seconds: number | null
    /**
     * 95th-percentile duration of successful job instances, in seconds: cancelled and failed instances end early and would bias the percentile. Null if none succeeded.
     * @nullable
     */
    p95_seconds: number | null
    /**
     * Decisive failures over job instances with a pass-or-fail verdict (0-1). Skipped, cancelled, neutral, and action-required instances are excluded. Null if none reached a verdict.
     * @nullable
     */
    failure_rate: number | null
    /** Job instances that ran on a 2nd+ run attempt - retry pressure. */
    retry_job_count: number
    /**
     * Billable (self-hosted) minutes across the group's instances; null when every instance ran on an unknown tier.
     * @nullable
     */
    billable_minutes: number | null
    /**
     * Estimated cost in USD via the runner-tier rate ladder; null when every instance ran on an unknown tier.
     * @nullable
     */
    estimated_cost_usd: number | null
}

/**
 * * `cache` - Cache
 * * `migrations` - Migrations
 */
export type JobLogBadgeKindEnumApi = (typeof JobLogBadgeKindEnumApi)[keyof typeof JobLogBadgeKindEnumApi]

export const JobLogBadgeKindEnumApi = {
    Cache: 'cache',
    Migrations: 'migrations',
} as const

/**
 * * `hit` - Cache hit
 * * `partial` - Older cache
 * * `miss` - Cache miss
 * * `failed` - Cache restore failed
 * * `none` - No migrations
 * * `applied` - Migrations applied
 */
export type JobLogBadgeStateEnumApi = (typeof JobLogBadgeStateEnumApi)[keyof typeof JobLogBadgeStateEnumApi]

export const JobLogBadgeStateEnumApi = {
    Hit: 'hit',
    Partial: 'partial',
    Miss: 'miss',
    Failed: 'failed',
    None: 'none',
    Applied: 'applied',
} as const

export interface JobLogBadgeApi {
    /** What the badge is about: a dependency cache, or migrations.
     *
     * * `cache` - Cache
     * * `migrations` - Migrations */
    kind: JobLogBadgeKindEnumApi
    /** What happened. For a cache: 'hit' (exact key restored), 'partial' (an older cache restored from a restore key), 'miss' (nothing restored), 'failed' (the restore itself failed). For migrations: 'none' (nothing to apply) or 'applied'.
     *
     * * `hit` - Cache hit
     * * `partial` - Older cache
     * * `miss` - Cache miss
     * * `failed` - Cache restore failed
     * * `none` - No migrations
     * * `applied` - Migrations applied */
    state: JobLogBadgeStateEnumApi
    /** How many times the log reports this outcome. */
    count: number
    /** What each occurrence was about: a cache key or a migration name. Capped, so it can hold fewer entries than `count`. */
    detail: string[]
}

export interface JobStepLogBadgesApi {
    /** What the log says this step did. */
    badges: JobLogBadgeApi[]
    /** The step's number in the job, matching `number` of the job's steps. */
    number: number
}

export interface JobLogInsightsApi {
    /** Every badge found in the log, for the job as a whole. */
    job: JobLogBadgeApi[]
    /** The same badges per step. Only steps with a badge are listed. Empty when `attributed_to_steps` is false. */
    steps: JobStepLogBadgesApi[]
    /** False when no log was read: a Depot CI job, a job the source does not hold, a log GitHub no longer keeps, or a failed fetch. Empty badges then mean 'unknown', not 'nothing found'. */
    log_read: boolean
    /** False when the log's step markers did not line up with the job's steps, so the badges are reported for the job only. */
    attributed_to_steps: boolean
    /** True when only part of the log was parsed, because the log is too large or its download took too long. The badges are then a lower bound: an outcome in the part that was not parsed is missing. */
    log_truncated?: boolean
}

export interface LLMSpendCoverageApi {
    /** Total cost in USD of the $ai_generation events stamped with this repository ($ai_git_repo) in the window. Generations with no repository stamp are not counted. */
    cost_usd: number
    /** The part of cost_usd that the branch and session attribution credits to a pull request. A generation credited to several pull requests counts once. */
    attributed_cost_usd: number
    /** Number of $ai_generation events in cost_usd. */
    generations: number
    /** Number of $ai_generation events in attributed_cost_usd. */
    attributed_generations: number
}

export interface MasterFailureGroupApi {
    /** Repository the failures occurred in. */
    repo: RepoRefApi
    /** GitHub Actions workflow name the failing runs belong to. */
    workflow_name: string
    /** De-sharded failing job name (matrix '(G/N)' suffix stripped): the group's failure signature together with the workflow. '' when the job-level source isn't synced and the group degrades to workflow level. */
    failed_job: string
    /** Distinct failing default-branch runs in this group within the window. */
    run_count: number
    /** When the oldest failing run in the group started. */
    first_seen: string
    /** When the newest failing run in the group started. */
    last_seen: string
    /** Run id of the newest failing run: the drill-down anchor. */
    latest_run_id: number
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    latest_ci_engine?: CIEngineEnumApi | null
}

export interface RunCostApi {
    /** Integer run id this cost is for; unique only together with ci_engine. */
    run_id: number
    /** Re-run attempt number; 1 for the first attempt. */
    run_attempt: number
    /** Billable (self-hosted) minutes for this run attempt. */
    billable_minutes: number
    /**
     * Estimated dollar cost for this run attempt, or null when nothing was costable.
     * @nullable
     */
    estimated_cost_usd: number | null
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    ci_engine?: CIEngineEnumApi | null
}

export interface PRCostSummaryApi {
    /** Same spend broken down per workflow. */
    by_workflow: WorkflowCostApi[]
    /** Same spend broken down per workflow run, keyed by (run_id, run_attempt). */
    by_run: RunCostApi[]
    /** Agent LLM token spend attributed to this PR by git branch ($ai_git_branch), or null when no generation matched: independent of the CI cost figures, so it can be present even when jobs_available is false. The UI hides the row when null. */
    llm_spend?: PRLLMSpendApi | null
    /** False when the job-level source (github_workflow_jobs) isn't synced: every figure is then zero/null and the cost cards should be hidden. */
    jobs_available: boolean
    /** Billable CI minutes: each costed (self-hosted) job's elapsed time, summed. Parallel jobs add up, so this is compute time spent, not wall-clock run duration. */
    billable_minutes: number
    /**
     * Estimated dollar cost (sum of per-job estimates: elapsed x tier multiplier x reference rate). Null when no job was costable.
     * @nullable
     */
    estimated_cost_usd: number | null
    /** Jobs counted in the estimate (billable Linux runner, finished). */
    costed_jobs: number
    /** Billable Linux jobs still queued/running (no elapsed): excluded from the estimate. */
    unsettled_jobs: number
    /** Jobs on provider-hosted (GitHub-hosted, free) or non-Linux runners: outside the estimate. */
    excluded_jobs: number
}

export interface PullRequestApi {
    /** The pull request author. */
    author: AuthorApi
    /** Repository the pull request belongs to. */
    repo: RepoRefApi
    /** GitHub pull request id. */
    id: number
    /** Pull request number within the repository. */
    number: number
    /** Pull request title. */
    title: string
    /** Derived state: 'open', 'closed', or 'merged'.
     *
     * * `open` - Open
     * * `closed` - Closed
     * * `merged` - Merged */
    state: PRStateEnumApi
    /** True if the pull request is a draft. */
    is_draft: boolean
    /** When the pull request was opened. */
    created_at: string
    /**
     * When the pull request was merged, or null.
     * @nullable
     */
    merged_at: string | null
    /**
     * When the pull request was closed, or null.
     * @nullable
     */
    closed_at: string | null
}

/**
 * * `opened` - Opened
 * * `ready_for_review` - Ready For Review
 * * `converted_to_draft` - Converted To Draft
 * * `ci_started` - CI Started
 * * `ci_finished` - CI Finished
 * * `merged` - Merged
 * * `closed` - Closed
 */
export type PRLifecycleEventKindEnumApi = (typeof PRLifecycleEventKindEnumApi)[keyof typeof PRLifecycleEventKindEnumApi]

export const PRLifecycleEventKindEnumApi = {
    Opened: 'opened',
    ReadyForReview: 'ready_for_review',
    ConvertedToDraft: 'converted_to_draft',
    CiStarted: 'ci_started',
    CiFinished: 'ci_finished',
    Merged: 'merged',
    Closed: 'closed',
} as const

export interface PRLifecycleEventApi {
    /** Event kind: opened, ready_for_review, converted_to_draft, ci_started, ci_finished, merged, or closed.
     *
     * * `opened` - Opened
     * * `ready_for_review` - Ready For Review
     * * `converted_to_draft` - Converted To Draft
     * * `ci_started` - CI Started
     * * `ci_finished` - CI Finished
     * * `merged` - Merged
     * * `closed` - Closed */
    kind: PRLifecycleEventKindEnumApi
    /** When the event occurred. */
    at: string
    /**
     * Optional detail: workflow name and conclusion for CI events, the acting user's login for draft/ready transitions.
     * @nullable
     */
    detail?: string | null
    /**
     * GitHub Actions run id for ci_started/ci_finished events, null otherwise.
     * @nullable
     */
    run_id?: number | null
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    ci_engine?: CIEngineEnumApi | null
}

/**
 * * `precise` - Precise
 * * `coarse` - Coarse
 * * `partial` - Partial
 */
export type MetricQualityEnumApi = (typeof MetricQualityEnumApi)[keyof typeof MetricQualityEnumApi]

export const MetricQualityEnumApi = {
    Precise: 'precise',
    Coarse: 'coarse',
    Partial: 'partial',
} as const

export interface PRLifecycleApi {
    /** The pull request header. */
    pull_request: PullRequestApi
    /** Lifecycle events ordered by time. */
    events: PRLifecycleEventApi[]
    /** Always 'partial': CI events only; reviews and comments are not yet available.
     *
     * * `precise` - Precise
     * * `coarse` - Coarse
     * * `partial` - Partial */
    metric_quality?: MetricQualityEnumApi
}

export interface WorkflowRunDetailApi {
    /** Repository the run belongs to. */
    repo: RepoRefApi
    /** Integer run id; unique only together with ci_engine. */
    id: number
    /** CI workflow name. */
    workflow_name: string
    /** Commit SHA the run was triggered on. */
    head_sha: string
    /** Git branch the run was triggered on. */
    head_branch: string
    /** Raw run status: 'queued', 'in_progress', 'completed', etc. */
    status: string
    /**
     * Run conclusion ('success', 'failure', 'timed_out', 'cancelled', 'skipped', 'action_required', ...), or null while still in progress.
     * @nullable
     */
    conclusion: string | null
    /**
     * When the run started, or null for a queued/barely-started run.
     * @nullable
     */
    run_started_at: string | null
    /**
     * When the run was last updated (its finish time once completed), or null when unstarted.
     * @nullable
     */
    updated_at: string | null
    /**
     * Wall-clock duration in seconds; null until the run completes.
     * @nullable
     */
    duration_seconds: number | null
    /** Re-run attempt number; 1 for the first attempt. */
    run_attempt: number
    /** Pull request this run ran for, from the run's own-repo PR association; 0 when unattributed (a default-branch push, or a fork PR). */
    pr_number: number
    /**
     * Pull request whose merge produced this run's head commit, resolved through the merged pull request's merge commit and falling back to the commit subject's '(#NNNN)' suffix. Null when neither resolves. The only PR attribution a default-branch push has: read pr_number first and fall back to this.
     * @nullable
     */
    commit_pr_number: number | null
    /** True when a merge queue pushed this run to gate pr_number, rather than the author pushing it. Count it when measuring CI; drop it when counting what the author did. */
    is_merge_queue: boolean
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    ci_engine?: CIEngineEnumApi | null
    /**
     * Source-native run id; use with ci_engine for identity.
     * @nullable
     */
    native_run_id?: string | null
    /**
     * Source-native workflow run id; use with ci_engine for identity.
     * @nullable
     */
    native_workflow_run_id?: string | null
    /**
     * GitHub's numeric id of the workflow. It stays the same when the workflow is renamed, so use it to follow one workflow over time. Null for a Depot CI run, and for a run whose source does not carry the id.
     * @nullable
     */
    workflow_id?: number | null
    /**
     * Event that triggered the run, such as 'push', 'pull_request' or 'schedule'. Null when unknown, as for a Depot CI run.
     * @nullable
     */
    event?: string | null
}

export interface PullRequestFrictionBreakdownApi {
    /** The pull request's friction split by kind. */
    groups: FrictionGroupShareApi[]
    /** Friction as a multiple of the typical pull request in the repository. */
    score: number
    /** Red stretches that a re-run of the same commit turned green. */
    flake_red_count: number
    /** Red stretches where the same job failed on the default branch within 12 hours. */
    master_red_count: number
    /** Red stretches with no provable cause. */
    unknown_red_count: number
    /** Red stretches that a later push fixed. */
    own_red_count: number
    /** Re-runs that failed again. */
    futile_rerun_count: number
    /** Pushes that triggered CI. */
    push_count: number
    /** CI running time of each push, oldest first. */
    ci_wait_seconds: number[]
    /**
     * From ready for review to the first approval. Null when either is not observed.
     * @nullable
     */
    first_approval_wait_seconds: number | null
    /**
     * Pushes after the first approval. Null without an approval.
     * @nullable
     */
    pushes_after_approval: number | null
    /**
     * Time in the merge queue. Null when the pull request never entered it.
     * @nullable
     */
    queue_seconds: number | null
    /**
     * Merge queue attempts where at least one workflow run failed. A failed check the queue does not require leaves the pull request in the queue, so this is an upper bound on the times the queue removed it. Null when the pull request never entered the merge queue.
     * @nullable
     */
    kickout_count: number | null
}

export interface PullRequestFrictionDetailApi {
    /** Null when the pull request did not merge in the window, or a bot authored it. */
    pull_request: PullRequestFrictionBreakdownApi | null
    /** False when the per-PR friction view does not exist yet: it needs a GitHub source with workflow runs, workflow jobs and pull requests synced. */
    available: boolean
    /** Pull requests merged in this many days before the view last refreshed. */
    window_days: number
}

export interface PRTimelinePushApi {
    /** The pushed head commit. */
    head_sha: string
    /** When the commit's first workflow run was created, which is when the commit arrived. */
    pushed_at: string
}

/**
 * * `draft` - Draft
 * * `waiting_for_review` - Waiting For Review
 * * `changes_requested` - Changes Requested
 * * `approved_not_enqueued` - Approved Not Enqueued
 * * `review_state_unknown` - Review State Unknown
 * * `ci_running` - CI Running
 * * `red_passed_on_rerun` - Red Passed On Rerun
 * * `red_master_broken` - Red Master Broken
 * * `red_fixed_by_push` - Red Fixed By Push
 * * `red_not_provable` - Red Not Provable
 * * `merge_queue` - Merge Queue
 * * `out_of_merge_queue` - Out Of Merge Queue
 */
export type PRTimelineSegmentKindEnumApi =
    (typeof PRTimelineSegmentKindEnumApi)[keyof typeof PRTimelineSegmentKindEnumApi]

export const PRTimelineSegmentKindEnumApi = {
    Draft: 'draft',
    WaitingForReview: 'waiting_for_review',
    ChangesRequested: 'changes_requested',
    ApprovedNotEnqueued: 'approved_not_enqueued',
    ReviewStateUnknown: 'review_state_unknown',
    CiRunning: 'ci_running',
    RedPassedOnRerun: 'red_passed_on_rerun',
    RedMasterBroken: 'red_master_broken',
    RedFixedByPush: 'red_fixed_by_push',
    RedNotProvable: 'red_not_provable',
    MergeQueue: 'merge_queue',
    OutOfMergeQueue: 'out_of_merge_queue',
} as const

export interface PRTimelineSegmentApi {
    /** What the PR waited on: draft; waiting_for_review (no approval yet, or re-review after a push); changes_requested (no push since); approved_not_enqueued (approved, with no failing or running check); review_state_unknown (reviews not synced); ci_running; red_passed_on_rerun (the failed workflows passed a re-run of the same commit); red_master_broken (the failed jobs also failed on the default branch within 12 hours); red_fixed_by_push (a later commit arrived); red_not_provable; merge_queue (every queue state collapsed); out_of_merge_queue (open PR, Trunk says failed or cancelled).
     *
     * * `draft` - Draft
     * * `waiting_for_review` - Waiting For Review
     * * `changes_requested` - Changes Requested
     * * `approved_not_enqueued` - Approved Not Enqueued
     * * `review_state_unknown` - Review State Unknown
     * * `ci_running` - CI Running
     * * `red_passed_on_rerun` - Red Passed On Rerun
     * * `red_master_broken` - Red Master Broken
     * * `red_fixed_by_push` - Red Fixed By Push
     * * `red_not_provable` - Red Not Provable
     * * `merge_queue` - Merge Queue
     * * `out_of_merge_queue` - Out Of Merge Queue */
    kind: PRTimelineSegmentKindEnumApi
    /** Segment start. */
    started_at: string
    /** Segment end: the next segment's start, the merge or close, or now. */
    ended_at: string
}

export interface PRTimelineApi {
    /** The repository the pull request belongs to. */
    repo: RepoRefApi
    /** Distinct head commits that triggered CI, oldest first, merge-queue gate runs excluded. A PR listed for an author or a team misses pushes from more than 30 days before the window. */
    pushes: PRTimelinePushApi[]
    /** Consecutive segments from started_at to the merge, the close, or now, with no gaps. */
    segments: PRTimelineSegmentApi[]
    /** Pull request number. */
    number: number
    /** Pull request title. */
    title: string
    /** The pull request's author. */
    author: AuthorApi
    /** open, merged, or closed. Author and team scopes list open and merged PRs only; a pull_request scope returns the PR whatever its state.
     *
     * * `open` - Open
     * * `closed` - Closed
     * * `merged` - Merged */
    state: PRStateEnumApi
    /** True when the PR is a draft right now. */
    is_draft: boolean
    /** When the PR was opened. */
    created_at: string
    /** Where the timeline starts: the last ready_for_review before the end, else created_at. A PR listed for an author or a team starts no earlier than 30 days before the window, because older CI is not read. */
    started_at: string
    /**
     * Merge time; null when not merged.
     * @nullable
     */
    merged_at: string | null
    /**
     * Estimated CI cost over the PR's runs, in USD. Null when nothing was costable.
     * @nullable
     */
    estimated_cost_usd: number | null
    /**
     * Billable minutes over the PR's runs. Null when the jobs table isn't synced.
     * @nullable
     */
    billable_minutes: number | null
}

export interface PRTimelineRedTimeApi {
    /** The red segment cause.
     *
     * * `draft` - Draft
     * * `waiting_for_review` - Waiting For Review
     * * `changes_requested` - Changes Requested
     * * `approved_not_enqueued` - Approved Not Enqueued
     * * `review_state_unknown` - Review State Unknown
     * * `ci_running` - CI Running
     * * `red_passed_on_rerun` - Red Passed On Rerun
     * * `red_master_broken` - Red Master Broken
     * * `red_fixed_by_push` - Red Fixed By Push
     * * `red_not_provable` - Red Not Provable
     * * `merge_queue` - Merge Queue
     * * `out_of_merge_queue` - Out Of Merge Queue */
    kind: PRTimelineSegmentKindEnumApi
    /** Average seconds per merged pull request attributed to this cause. */
    seconds_per_merged_pr: number
}

export interface PullRequestTimelinesApi {
    /** The pull requests in scope, newest first: open PRs plus PRs merged in the window, or the one pull request of a pull_request scope. */
    items: PRTimelineApi[]
    /** Average red time per merged pull request, grouped by the evidence that classifies each red stretch. */
    red_seconds_per_merged_pr: PRTimelineRedTimeApi[]
    /** What the read covers: 'author' (one GitHub login), 'github_team' (the members of one GitHub team, through the team membership table), or 'pull_request' (one pull request).
     *
     * * `author` - Author
     * * `github_team` - GitHub Team
     * * `pull_request` - Pull Request */
    scope_kind: DeliveryScopeKindEnumApi
    /** The GitHub login, GitHub team slug, or 'owner/name#number' the timelines are for. */
    scope: string
    /** True when the team membership table is synced. A github_team scope without it lists no pull requests. */
    has_membership_data: boolean
    /** False when reviews aren't synced: review stretches read review_state_unknown. */
    review_data_available: boolean
    /** False when workflow jobs aren't synced: a check a re-run turned green is not visible, and no red stretch reads red_master_broken. */
    jobs_available: boolean
    /** True when the Trunk merge-queue table is synced, so out_of_merge_queue can appear. */
    merge_queue_state_available: boolean
    /** The now every open PR's timeline ends at. */
    generated_at: string
    /** Every pull request merged in the selected scope and window. */
    merged_pr_count: number
    /** True when more PRs matched than the limit. */
    truncated: boolean
    /** The maximum number of PRs returned. */
    limit: number
}

export interface PullRequestListApi {
    /** This page of pull requests, newest first, capped at `limit`. */
    items: PullRequestListItemApi[]
    /** True when more pull requests match after this page; call again with `offset` increased by `limit` to read them. The aggregate counts in ci_cards can exceed `items`. */
    truncated: boolean
    /** Maximum number of pull requests returned in `items`. */
    limit: number
}

/**
 * * `run` - Run
 * * `skip` - Skip
 */
export type QuarantineModeEnumApi = (typeof QuarantineModeEnumApi)[keyof typeof QuarantineModeEnumApi]

export const QuarantineModeEnumApi = {
    Run: 'run',
    Skip: 'skip',
} as const

/**
 * * `active` - Active
 * * `expiring_soon` - Expiring Soon
 * * `in_grace` - In Grace
 * * `overdue` - Overdue
 */
export type QuarantineLifecycleEnumApi = (typeof QuarantineLifecycleEnumApi)[keyof typeof QuarantineLifecycleEnumApi]

export const QuarantineLifecycleEnumApi = {
    Active: 'active',
    ExpiringSoon: 'expiring_soon',
    InGrace: 'in_grace',
    Overdue: 'overdue',
} as const

/**
 * * `product` - Product
 * * `file` - File
 * * `directory` - Directory
 * * `test` - Test
 */
export type QuarantineSelectorKindEnumApi =
    (typeof QuarantineSelectorKindEnumApi)[keyof typeof QuarantineSelectorKindEnumApi]

export const QuarantineSelectorKindEnumApi = {
    Product: 'product',
    File: 'file',
    Directory: 'directory',
    Test: 'test',
} as const

export interface QuarantineEntryApi {
    /** Test selector: an exact test id, a file, a directory, a class prefix, or 'product:<dashed-name>'. */
    id: string
    /** Test runner the selector targets, e.g. 'pytest' or 'jest'. */
    runner: string
    /** Why the test was quarantined. */
    reason: string
    /** GitHub team or user handle responsible for the fix. */
    owner: string
    /** Tracking issue URL, or empty when none was filed. */
    issue: string
    /** ISO date the entry was added. */
    added: string
    /** ISO date the quarantine expires; past it the test blocks CI normally again. */
    expires: string
    /** 'run' (the test still executes but cannot fail the suite) or 'skip' (not run at all).
     *
     * * `run` - Run
     * * `skip` - Skip */
    mode: QuarantineModeEnumApi
    /** Expiry classification: 'active' (>7 days left), 'expiring_soon' (0-7 days left), 'in_grace' (expired up to 7 days ago), 'overdue' (expired beyond the grace period).
     *
     * * `active` - Active
     * * `expiring_soon` - Expiring Soon
     * * `in_grace` - In Grace
     * * `overdue` - Overdue */
    lifecycle: QuarantineLifecycleEnumApi
    /** Days until the entry expires; negative once past expiry. */
    days_until_expiry: number
    /** What the selector covers: 'test' (contains '::'), 'file', 'directory', or 'product'.
     *
     * * `product` - Product
     * * `file` - File
     * * `directory` - Directory
     * * `test` - Test */
    selector_kind: QuarantineSelectorKindEnumApi
}

export interface QuarantineFileApi {
    /** Quarantined selectors, most urgent first (overdue, in_grace, expiring_soon, active), then by soonest expiry. */
    entries: QuarantineEntryApi[]
    /** Repository the file was read from. Null in local-dev mode, where the server's own checkout is read. */
    repo: RepoRefApi | null
    /** False when the repository has no quarantine file (not an error) or it could not be fetched. */
    available: boolean
    /** Contract violations (malformed JSON, bad entries) or fetch failures. Malformed entries are dropped; well-formed ones are kept. */
    parse_errors: string[]
    /** Forward-compatibility notices, e.g. unknown entry fields. */
    parse_warnings: string[]
    /** GitHub blob URL of the quarantine file, or empty when read locally or unavailable. */
    source_url: string
    /** When this snapshot was computed (UTC); expiry math uses this clock. */
    generated_at: string
}

/**
 * * `quarantine` - Quarantine
 * * `extend` - Extend
 * * `remove` - Remove
 */
export type QuarantineRequestActionEnumApi =
    (typeof QuarantineRequestActionEnumApi)[keyof typeof QuarantineRequestActionEnumApi]

export const QuarantineRequestActionEnumApi = {
    Quarantine: 'quarantine',
    Extend: 'extend',
    Remove: 'remove',
} as const

/**
 * * `pytest` - Pytest
 * * `jest` - Jest
 * * `playwright` - Playwright
 */
export type QuarantineRunnerEnumApi = (typeof QuarantineRunnerEnumApi)[keyof typeof QuarantineRunnerEnumApi]

export const QuarantineRunnerEnumApi = {
    Pytest: 'pytest',
    Jest: 'jest',
    Playwright: 'playwright',
} as const

export interface QuarantineRequestApi {
    /** What to do: 'quarantine' (add or replace an entry and file a tracking issue), 'extend' (re-stamp an existing entry's expiry, reusing its issue), or 'remove' (delete the entry). All three open a pull request.
     *
     * * `quarantine` - Quarantine
     * * `extend` - Extend
     * * `remove` - Remove */
    operation: QuarantineRequestActionEnumApi
    /** Test selector to act on: an exact test id, a file, a directory, a class prefix, or 'product:<dashed-name>'. */
    selector: string
    /** Test runner the selector targets: 'pytest', 'jest', or 'playwright'. Existing entries and Jest file extensions are inferred for older clients that omit it; other selectors default to 'pytest'.
     *
     * * `pytest` - Pytest
     * * `jest` - Jest
     * * `playwright` - Playwright */
    runner?: QuarantineRunnerEnumApi | null
    /**
     * Optional 'owner/name' repository override; defaults to the team's most active repo.
     * @nullable
     */
    repo?: string | null
    /** Why the test is quarantined. Required for quarantine and extend; ignored by remove. */
    reason?: string
    /** GitHub team or user handle responsible for the fix, e.g. '@PostHog/team-x'. Required for quarantine and extend. */
    owner?: string
    /** Existing tracking issue URL, carried forward on extend and remove. Ignored by quarantine, which files a fresh issue. */
    issue?: string
    /**
     * ISO date the quarantine expires (at most 30 days out). Defaults to 14 days from today. Ignored by remove.
     * @nullable
     */
    expires?: string | null
    /** 'run' (the test still executes but cannot fail the suite) or 'skip' (not run at all). Defaults to 'run'.
     *
     * * `run` - Run
     * * `skip` - Skip */
    mode?: QuarantineModeEnumApi
}

export interface QuarantineRequestResultApi {
    /** URL of the opened pull request that edits the quarantine file. */
    pr_url: string
    /** URL of the tracking issue filed for a new quarantine; empty for extend and remove. */
    issue_url: string
    /** Branch the pull request was opened from. */
    branch: string
}

export interface CostPerMergeBucketApi {
    /** Bucket start, aligned to cost_series_granularity (top of hour, midnight, or Monday). */
    bucket_start: string
    /**
     * Estimated Depot CI cost (USD) of all runs started in this bucket. Null when nothing was costable (no billable self-hosted Linux jobs) or the job source isn't synced.
     * @nullable
     */
    estimated_cost_usd: number | null
    /** PRs merged in this bucket (all authors, bots included). */
    merges: number
    /**
     * Rolling ratio: trailing-window CI cost divided by trailing-window merges (24 h / 7 d / 4 w to match the granularity). Null when the trailing window had no merges or no costable cost.
     * @nullable
     */
    cost_per_merge_usd: number | null
}

export interface TimeToGreenBucketApi {
    /** Bucket start, aligned to time_to_green_series_granularity (top of hour, midnight, or Monday). */
    bucket_start: string
    /**
     * Median wall-clock seconds from a PR push round's first run start until every workflow on that head SHA first completed benign, over rounds started in this bucket (merge-queue gates and partially-attributed fork rounds excluded). Null when the bucket had no fully green round (a gap, not instant CI).
     * @nullable
     */
    p50_seconds: number | null
}

export interface PassRateBucketApi {
    /** Bucket start, aligned to success_rate_series_granularity (top of hour, midnight, or Monday). */
    bucket_start: string
    /**
     * Fraction (0-1) of conclusive runs started in this bucket that succeeded. Skipped, cancelled, neutral, and action_required runs are excluded. Null when the bucket had no conclusive run (a gap, not a 0% pass rate).
     * @nullable
     */
    success_rate: number | null
}

export interface OpenToMergeBucketApi {
    /** Bucket start, aligned to open_to_merge_series_granularity (top of hour, midnight, or Monday). */
    bucket_start: string
    /**
     * Median merged_at - created_at seconds over PRs merged in this bucket, bots and drafts excluded. Null when nothing merged in the bucket (a gap, not instant merges).
     * @nullable
     */
    p50_seconds: number | null
}

/**
 * * `open_to_gate` - Open To Gate
 * * `gate_to_merge` - Gate To Merge
 */
export type DeliveryStageEnumApi = (typeof DeliveryStageEnumApi)[keyof typeof DeliveryStageEnumApi]

export const DeliveryStageEnumApi = {
    OpenToGate: 'open_to_gate',
    GateToMerge: 'gate_to_merge',
} as const

export interface DeliveryStageTimingApi {
    /** Which leg this is: 'open_to_gate' (created_at to the PR's first merge-queue gate run starting) or 'gate_to_merge' (that gate run to merged_at). The post-merge leg is the DORA endpoint's median_merge_to_deploy_seconds.
     *
     * * `open_to_gate` - Open To Gate
     * * `gate_to_merge` - Gate To Merge */
    stage: DeliveryStageEnumApi
    /**
     * Median seconds for this leg. Null when no PR in the window has both of its bounds observed.
     * @nullable
     */
    median_seconds: number | null
    /**
     * 90th-percentile seconds for this leg. Null when not observed.
     * @nullable
     */
    p90_seconds: number | null
    /** PRs behind this leg's figures: those with an observed gate run. A PR that skipped the merge queue has no gate legs, so read a median against this count, not merged_pr_count. */
    pr_count: number
}

export interface DeliveryPipelineApi {
    /** The legs, ordered open to merge. A leg with nothing observed still appears, with a zero pr_count and null timings. The leg medians do not sum to a cycle-time median: a median of sums is not a sum of medians. */
    stages: DeliveryStageTimingApi[]
    /** PRs merged in the window with bots and drafts excluded. A narrower population than RepoOverview.merged_pr_count, which counts all authors. */
    merged_pr_count: number
}

export interface ReadyToMergeBucketApi {
    /** Bucket start, aligned to ready_to_merge_series_granularity (top of hour, midnight, or Monday). */
    bucket_start: string
    /**
     * Median per-PR ready_to_merge_seconds (merged_at minus the last observed ready-for-review transition) over PRs merged in this bucket, bots and drafts excluded. Null when nothing merged with an observed value (a gap, never zero).
     * @nullable
     */
    p50_seconds: number | null
}

export interface RevertShareBucketApi {
    /** Bucket start, aligned to revert_share_series_granularity (top of hour, midnight, or Monday). Keyed on the revert's own merge time. */
    bucket_start: string
    /** PRs merged in this bucket, all authors and bots included. */
    merged_pr_count: number
    /** Of those, PRs whose title names a revert: GitHub's 'Revert "..."' or a conventional-commit 'revert: ...' / 'revert(scope): ...' title. */
    reverting_pr_count: number
    /**
     * reverting_pr_count divided by merged_pr_count. Null when nothing merged in the bucket.
     * @nullable
     */
    revert_share: number | null
}

export interface RepoOverviewApi {
    /** CI cost per merged PR across the window, oldest first, zero-filled, bucketed by cost_series_granularity. Empty when the job-level source isn't synced or include_series=false. */
    cost_series: CostPerMergeBucketApi[]
    /** Median time-to-green (p50 wall clock for a PR push round to settle fully green) per bucket across the window, oldest first, bucketed by time_to_green_series_granularity. Empty buckets carry null; the whole series is empty when include_series=false. */
    time_to_green_series: TimeToGreenBucketApi[]
    /** CI pass rate (conclusive runs that succeeded, all branches) per bucket across the window, oldest first, bucketed by success_rate_series_granularity. Skipped, cancelled, neutral, and action_required runs are excluded. Empty buckets carry null; the whole series is empty when include_series=false. */
    success_rate_series: PassRateBucketApi[]
    /** Median time-to-merge (p50 open_to_merge_seconds, bots/drafts excluded) per bucket across the window, oldest first, bucketed by open_to_merge_series_granularity. Empty buckets carry null; the whole series is empty when include_series=false. */
    open_to_merge_series: OpenToMergeBucketApi[]
    /** Where a change's wall-clock time goes on the way to production, over PRs merged in the window with bots and drafts excluded. */
    delivery_pipeline: DeliveryPipelineApi
    /** Median cycle time (p50 per-PR ready_to_merge_seconds, bots/drafts excluded) per bucket across the window, oldest first, bucketed by ready_to_merge_series_granularity. Empty buckets carry null; the whole series is empty when the issue-events table isn't synced or include_series=false, so fall back to open_to_merge_series. */
    ready_to_merge_series: ReadyToMergeBucketApi[]
    /** Reverting merges over all merges (all authors, bots included) per bucket across the window, oldest first, zero-filled, bucketed by revert_share_series_granularity. Empty buckets carry a null share; the whole series is empty when include_series=false. */
    revert_share_series: RevertShareBucketApi[]
    /** Workflow runs started in the window, all branches and workflows. */
    run_count: number
    /** Same count over the equal-length window immediately before date_from: the delta baseline. */
    run_count_prev: number
    /**
     * Fraction of conclusive runs that succeeded (0-1) in the window. Skipped, cancelled, neutral, and action_required runs are excluded. Null if no run reached a verdict.
     * @nullable
     */
    success_rate: number | null
    /**
     * Conclusive-run success rate over the previous window. Null if no run reached a verdict.
     * @nullable
     */
    success_rate_prev: number | null
    /** Runs in the window that were a 2nd+ attempt (attempt > 1). */
    rerun_cycles: number
    /** Re-run cycles over the previous window. */
    rerun_cycles_prev: number
    /** PRs merged in the window, all authors and bots included. billable_minutes and estimated_cost_usd cover every run in the window, including default-branch and unmerged PR runs, so dividing them by this count spreads all CI spend over the merges. */
    merged_pr_count: number
    /** Merged-PR count over the previous window. */
    merged_pr_count_prev: number
    /** PRs merged in the window whose title names a revert: GitHub's 'Revert "..."' or a conventional-commit 'revert: ...' / 'revert(scope): ...' title. Counts the revert when it merges, not the change it undid, which may have merged in an earlier window. Same population as merged_pr_count. */
    reverting_pr_count: number
    /** Reverting-PR count over the previous window. */
    reverting_pr_count_prev: number
    /**
     * reverting_pr_count divided by merged_pr_count: the share of merges that undid an earlier merge. The guardrail to watch when review requirements are loosened. Null when nothing merged.
     * @nullable
     */
    revert_share: number | null
    /**
     * The same share over the previous window. Null when nothing merged.
     * @nullable
     */
    revert_share_prev: number | null
    /**
     * Median merged_at - created_at over PRs merged in the window, bots and drafts excluded. Coarse by design: draft and ready-for-review time are fused. Null when nothing merged.
     * @nullable
     */
    median_open_to_merge_seconds: number | null
    /**
     * The same median over the previous window. Null when nothing merged.
     * @nullable
     */
    median_open_to_merge_seconds_prev: number | null
    /**
     * Median per-PR ready_to_merge_seconds (the true cycle time: merged_at minus the last observed ready-for-review transition) over PRs merged in the window, bots and drafts excluded. Null when the issue-events table isn't synced or no merged PR has an observed value; fall back to median_open_to_merge_seconds and label it open-to-merge.
     * @nullable
     */
    median_ready_to_merge_seconds: number | null
    /**
     * The same median over the previous window. Null when not observed.
     * @nullable
     */
    median_ready_to_merge_seconds_prev: number | null
    /**
     * Billable (self-hosted) job minutes in the window; null when the job-level source isn't synced.
     * @nullable
     */
    billable_minutes: number | null
    /**
     * Billable minutes over the previous window; null when the job-level source isn't synced.
     * @nullable
     */
    billable_minutes_prev: number | null
    /**
     * Estimated CI cost in USD (billable minutes x runner-tier rate); null when the job-level source isn't synced.
     * @nullable
     */
    estimated_cost_usd: number | null
    /**
     * Estimated cost over the previous window; null when the job-level source isn't synced.
     * @nullable
     */
    estimated_cost_usd_prev: number | null
    /**
     * estimated_cost_usd divided by merged_pr_count: the window's CI cost per merged PR. Null when the job-level source isn't synced or nothing merged.
     * @nullable
     */
    cost_per_merge_usd: number | null
    /**
     * The same ratio over the previous window. Null when the job-level source isn't synced or nothing merged.
     * @nullable
     */
    cost_per_merge_usd_prev: number | null
    /**
     * Slice of billable_minutes spent on merge-queue batch branches (trunk-merge/**); null when the job-level source isn't synced.
     * @nullable
     */
    merge_queue_billable_minutes: number | null
    /**
     * Merge-queue billable minutes over the previous window; null when the job-level source isn't synced.
     * @nullable
     */
    merge_queue_billable_minutes_prev: number | null
    /**
     * Slice of billable_minutes from jobs that ran on the Depot CI engine; null when the job-level source isn't synced.
     * @nullable
     */
    depot_ci_billable_minutes: number | null
    /**
     * Depot CI billable minutes over the previous window; null when the job-level source isn't synced.
     * @nullable
     */
    depot_ci_billable_minutes_prev: number | null
    /** PRs merged in the window with at least one corroborated merge-queue gate run: the population behind every merge_queue_* landing stat. All authors, bots included. */
    merge_queue_merged_pr_count: number
    /** Queue-landed merges over the previous window. */
    merge_queue_merged_pr_count_prev: number
    /**
     * Median seconds from a PR's first observed merge-queue gate run starting to the PR merging. Pending time before gate testing starts is not included. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_median_first_gate_to_merge_seconds: number | null
    /**
     * The same median over the previous window. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_median_first_gate_to_merge_seconds_prev: number | null
    /**
     * p90 of the same first-gate-run-to-merge measure: the tail, where queue pain concentrates. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_p90_first_gate_to_merge_seconds: number | null
    /**
     * The same p90 over the previous window. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_p90_first_gate_to_merge_seconds_prev: number | null
    /**
     * p95 of the same first-gate-run-to-merge measure. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_p95_first_gate_to_merge_seconds: number | null
    /**
     * The same p95 over the previous window. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_p95_first_gate_to_merge_seconds_prev: number | null
    /**
     * p99 of the same first-gate-run-to-merge measure. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_p99_first_gate_to_merge_seconds: number | null
    /**
     * The same p99 over the previous window. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_p99_first_gate_to_merge_seconds_prev: number | null
    /**
     * Mean distinct gate attempts (distinct gate branches, flake-bisection branches collapsed) per queue-landed merge. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_avg_attempts_per_merge: number | null
    /**
     * The same mean over the previous window. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_avg_attempts_per_merge_prev: number | null
    /**
     * Fraction (0-1) of queue-landed merges that needed more than one gate attempt. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_multi_attempt_merge_share: number | null
    /**
     * The same fraction over the previous window. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_multi_attempt_merge_share_prev: number | null
    /**
     * Fraction (0-1) of queue-landed merges with at least one failed gate run before merging. Derived from CI run conclusions, not the queue's own eviction records. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_failed_gate_merge_share: number | null
    /**
     * The same fraction over the previous window. Null when no queue-landed merges.
     * @nullable
     */
    merge_queue_failed_gate_merge_share_prev: number | null
    /** Whether the team's TrunkIo warehouse source has the opt-in merge-queue endpoint synced and readable by the requesting user. When false, every merge_queue_failed_or_cancelled_* and merge_queue_skip_the_line_* field is null; fall back to merge_queue_failed_gate_merge_share. */
    merge_queue_trunk_available: boolean
    /**
     * Fraction (0-1) of concluded queue entries (merged, failed, or cancelled) that ended failed or cancelled, from the queue's own records. Windowed on each entry's last state change. Null when the Trunk source isn't synced or nothing concluded.
     * @nullable
     */
    merge_queue_failed_or_cancelled_share: number | null
    /**
     * The same fraction over the previous window. Null when the Trunk source isn't synced or nothing concluded.
     * @nullable
     */
    merge_queue_failed_or_cancelled_share_prev: number | null
    /**
     * Queue entries flagged skip-the-line (prioritized past the queue order) in the window, whatever state they reached. Null when the Trunk source isn't synced.
     * @nullable
     */
    merge_queue_skip_the_line_count: number | null
    /**
     * Skip-the-line entries over the previous window. Null when the Trunk source isn't synced.
     * @nullable
     */
    merge_queue_skip_the_line_count_prev: number | null
    /**
     * Median wall clock for a PR push round to settle fully green over the window: the window-level twin of time_to_green_series, same population and exclusions. Null when no fully green rounds.
     * @nullable
     */
    median_time_to_green_seconds: number | null
    /**
     * The same median over the previous window. Null when no fully green rounds.
     * @nullable
     */
    median_time_to_green_seconds_prev: number | null
    /** Whether the job-level source is synced (cost and queue figures exist). */
    jobs_available: boolean
    /** 'master' or 'main', picked by observed run volume in the window. */
    default_branch: string
    /** Bucket width of the cost_series trend, chosen to fit the window: 'hour', 'day', or 'week'. */
    cost_series_granularity: string
    /** Bucket width of the time_to_green_series trend: 'hour', 'day', or 'week'. */
    time_to_green_series_granularity: string
    /** Bucket width of the success_rate_series trend: 'hour', 'day', or 'week'. */
    success_rate_series_granularity: string
    /** Bucket width of the open_to_merge_series trend: 'hour', 'day', or 'week'. */
    open_to_merge_series_granularity: string
    /** Bucket width of the ready_to_merge_series trend: 'hour', 'day', or 'week'. */
    ready_to_merge_series_granularity: string
    /** Bucket width of the revert_share_series trend: 'hour', 'day', or 'week'. */
    revert_share_series_granularity: string
}

export interface WorkflowRunActivityPointApi {
    /** Integer run id; unique only together with ci_engine. */
    run_id: number
    /**
     * Run conclusion ('success', 'failure', 'timed_out', 'cancelled', 'skipped', ...), or null while still in progress.
     * @nullable
     */
    conclusion: string | null
    /** When the run started. Never null on this endpoint: runs without a parseable start timestamp are excluded from the window (they can't be plotted on the chart's time axis). */
    run_started_at: string
    /**
     * Wall-clock duration in seconds; null until the run completes.
     * @nullable
     */
    duration_seconds: number | null
    /** Git branch the run was triggered on, or '' when unknown. */
    head_branch: string
    /** Attributed pull request number, or 0 when unattributed. */
    pr_number: number
    /** Head commit SHA of the run/commit, or '' when unknown. */
    head_sha: string
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    ci_engine?: CIEngineEnumApi | null
}

export interface WorkflowRunActivityApi {
    /** Per-run chart points, newest first, capped at `limit`. */
    points: WorkflowRunActivityPointApi[]
    /** True when more runs matched than the cap; `points` is the newest `limit` runs, so the chart covers only the most recent activity, not the full window. */
    truncated: boolean
    /** Maximum number of run points returned in `points`. */
    limit: number
}

export interface BranchPRMatchApi {
    /** Repository the pull request belongs to, as 'owner/name'. */
    repo: string
    /** Pull request number within the repository: pair with `repo` to link to it. */
    number: number
    /**
     * Pull request title, or null when the snapshot carries no title.
     * @nullable
     */
    title: string | null
    /**
     * Derived PR state ('open', 'closed', 'merged'), or null when the snapshot carries no state.
     * @nullable
     */
    state: string | null
}

export interface RunFailureLogsApi {
    /** Failed CI jobs of this run with their thinned failure logs, grouped by job. */
    jobs: CIJobFailureLogApi[]
    /** Workflow run id the failure logs are for. */
    run_id: number
    /** False when no failure logs were found: the run didn't fail, or its logs aged out of the short Logs retention. */
    logs_available: boolean
    /** True when the overall line cap across all jobs was hit. */
    truncated: boolean
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    ci_engine?: CIEngineEnumApi | null
}

export interface GitHubSourceApi {
    /** Source id: pass back as `source_id` (with `repo`) to read this repository. */
    id: string
    /** Repository as 'owner/name': pass back as `repo` to scope to it. One entry per repository a source syncs; '' if unknown. */
    repo: string
    /** User-chosen warehouse table-name prefix for this source, or '' when none. */
    prefix: string
    /** Whether this repo has both pull_requests and workflow_runs synced (readable now). Default the picker to the first synced entry so its label matches the resolved repo. */
    synced?: boolean
}

export interface TeamTestSignalApi {
    /** Test runner that emitted this signal: 'pytest' or 'jest'.
     *
     * * `pytest` - Pytest
     * * `jest` - Jest */
    runner: CITestRunnerEnumApi
    /** Runner-specific test identity (the CI span name), a stable grouping key. */
    nodeid: string
    /** Runnable pytest or Jest selector; exact for newly emitted spans. */
    selector: string
    /** Runs in the current window where the test failed, errored, or a retry recovered it (quarantined failures excluded). */
    signal_count: number
    /** Same count over the equal-length window before date_from. */
    signal_count_prior: number
    /** Most recent failure, recovery, or quarantined-failure run for this test, either window. */
    last_seen_at: string
}

export interface TeamCIActivityApi {
    /** The team's owned tests with signal in either window, ranked by the stronger window's count (the current-vs-prior pairs behind a before/after comparison). */
    tests: TeamTestSignalApi[]
    /** The team slug this activity is scoped to, or 'unowned'. */
    owner_team: string
    /** True when more owned tests had signal than the test cap. */
    truncated_tests: boolean
}

export interface TeamCIHealthItemApi {
    /** Owning team slug from the repo's owners.yaml map (e.g. 'team-replay'), or the literal 'unowned' for tests whose spans carry no ownership stamp. */
    owner_team: string
    /** Owned tests one commit was seen both failing and passing in the window: the same proof, and the same word, that flaky_tests calls a confirmed_flake. Compare with flaky_test_count_prior for the delta. */
    flaky_test_count: number
    /** Same count over the equal-length window immediately before date_from. */
    flaky_test_count_prior: number
    /** Owned tests that failed with no recorded same-commit recovery and still hit the blast-radius bar (a master/main failure, or min_failed_prs distinct PRs). Not flakes: absence of proof, not proof. */
    regression_test_count: number
    /** Same count over the prior window. */
    regression_test_count_prior: number
    /** Distinct CI runs where at least one owned test failed or errored. A run with many failing owned tests counts once. An absolute count, not a rate: fast passing runs are not emitted. */
    failed_run_count: number
    /** Same count over the prior window. */
    failed_run_count_prior: number
    /** Distinct CI runs where one commit both failed and passed at least one owned test: a re-run attempt went green, or an in-job retry recovered it. */
    same_commit_recovery_run_count: number
    /** Same count over the prior window. */
    same_commit_recovery_run_count_prior: number
    /** Distinct CI runs where at least one owned test recorded a tolerated failure while quarantined. */
    quarantined_failed_run_count: number
    /** Same count over the prior window. */
    quarantined_failed_run_count_prior: number
    /**
     * Most recent failure, recovery, or quarantined-failure run across the team's owned tests, either window. Null for a team present only through the census (no CI signal recorded).
     * @nullable
     */
    last_seen_at: string | null
    /**
     * Test files the team owns per the daily owners.yaml census. Null until a census event exists for the repository.
     * @nullable
     */
    test_file_count?: number | null
    /**
     * The latest census value at or before the window start, for the trend.
     * @nullable
     */
    test_file_count_prior?: number | null
    /**
     * Merged PRs authored by the team's members in the window, bots excluded. Null when the team_members snapshot isn't synced, or for 'unowned'.
     * @nullable
     */
    merged_pr_count?: number | null
    /**
     * Same count over the prior window.
     * @nullable
     */
    merged_pr_count_prior?: number | null
}

export interface TeamCIHealthListApi {
    /** Owning teams ranked by current flaky + failure signal, heaviest first, capped at `limit`. Teams are organizational owners of code surfaces; this never aggregates by author. A CI setup break (a run attempt whose tests errored in 3 or more jobs or for 3 or more owning teams, or a job attempt with 100 or more distinct failed or errored tests) excludes every trial of that attempt, not only its failures. */
    items: TeamCIHealthItemApi[]
    /** True when more teams had signal than the cap. */
    truncated: boolean
    /** Maximum number of teams returned in `items`. */
    limit: number
}

export interface TeamMergeTrendPointApi {
    /** Start of the day bucket (team timezone), keyed on merged_at. */
    day: string
    /**
     * Median open→merge seconds of the PRs this team's members merged that day; null on a day the team merged nothing.
     * @nullable
     */
    median_seconds: number | null
    /**
     * Average open→merge seconds over the same merges; diverges above the median when a few long-running PRs drag the mean. Null on a day the team merged nothing.
     * @nullable
     */
    average_seconds: number | null
    /** Merged PRs behind that day's median and average. */
    merged_count: number
}

export interface TeamMergeTrendApi {
    /** Daily median and average open→merge over the PRs this team's members merged, ascending by day. Coarse timing (open→merge combines draft and review time); bots excluded. */
    points: TeamMergeTrendPointApi[]
    /** The team slug this trend is scoped to. */
    owner_team: string
    /** False when the GitHub source has no team_members snapshot synced: the trend then has no honest team attribution and `points` is empty. */
    has_membership_data: boolean
}

export interface TrunkQuarantineTeamDebtApi {
    /** Owning team slug, or 'unowned'. */
    owner_team: string
    /** Tests this team owns that Trunk currently quarantines. */
    test_count: number
    /** Of those, tests quarantined longer than ttl_days. */
    overdue_count: number
    /** Age in days of the team's oldest standing quarantine. */
    oldest_age_days: number
}

export interface TrunkQuarantinedTestApi {
    /** Test runner: 'pytest' or 'jest'. */
    runner: string
    /** Runner-native test id reconstructed from Trunk's (file, classname, name) key. */
    nodeid: string
    /** Repo-relative path of the test file, empty when neither the repository nor Trunk places it. */
    file: string
    /** Owning team slug from the repository's ownership files, or 'unowned' when the test's file cannot be placed or no team claims its path. */
    owner_team: string
    /** Trunk's current health verdict on the test, e.g. 'flaky' or 'broken'. */
    status: string
    /** When Trunk quarantined the test. */
    quarantined_at: string
    /** Whole days since the quarantine started. */
    age_days: number
    /** True once age_days exceeds ttl_days: the quarantine has outlived the TTL. */
    overdue: boolean
    /**
     * The Trunk app's page for this test; null when Trunk returned no URL and the source has no organization slug or the row carries no test id.
     * @nullable
     */
    trunk_url: string | null
}

export interface TrunkQuarantineDebtApi {
    /** Per-team rollup, most indebted first: overdue count, then test count, then oldest age. */
    teams: TrunkQuarantineTeamDebtApi[]
    /** Every currently quarantined test, oldest first. */
    tests: TrunkQuarantinedTestApi[]
    /** False when no TrunkIo source has the QuarantinedTests endpoint synced; not an error. */
    available: boolean
    /** False when the repository's ownership files could not be read, so every test reads as 'unowned' for that reason rather than because no team claims it. */
    owners_resolved: boolean
    /** Days a quarantine may stand before it counts as overdue. */
    ttl_days: number
    /** The 'owner/name' repository the debt was read for; test file paths are relative to it. */
    repository: string
    /**
     * The Trunk app's flaky-tests page for this repository; null when the connected source has no organization slug.
     * @nullable
     */
    trunk_url: string | null
    /** True when more tests are quarantined than limit. The per-team counts then cover only the returned tests, so treat them as lower bounds. */
    truncated: boolean
    /** Maximum tests returned, oldest quarantine first. */
    limit: number
}

export interface WorkflowHealthBucketApi {
    /** Bucket start, aligned to the item's granularity (top of hour, midnight, or Monday). */
    bucket_start: string
    /** Runs started in this bucket. */
    run_count: number
    /** Runs that completed in this bucket. */
    completed: number
    /** Completed runs with conclusion 'success' in this bucket. */
    successes: number
    /** Completed runs with conclusion 'failure', 'timed_out', 'startup_failure', or 'stale'. Skipped, cancelled, neutral, and action_required runs are excluded. */
    failures: number
}

export interface WorkflowHealthItemApi {
    /** Repository the workflow runs in. */
    repo: RepoRefApi
    /** Run history across the whole window, oldest first, zero-filled, bucketed by granularity. */
    buckets: WorkflowHealthBucketApi[]
    /** GitHub Actions workflow name. */
    workflow_name: string
    /** Total runs started in the window. */
    run_count: number
    /** Completed runs with conclusion 'success'. */
    successful_run_count: number
    /** Completed runs that succeeded or ended in failure, timeout, startup failure, or staleness. This is the success_rate denominator. */
    conclusive_run_count: number
    /**
     * Fraction of conclusive runs that succeeded (0-1). Failures include failure, timed_out, startup_failure, and stale. Skipped, cancelled, neutral, and action_required runs are excluded. Null if no run reached a verdict.
     * @nullable
     */
    success_rate: number | null
    /**
     * Median duration in seconds over successful runs only: cancelled (superseded) and failed runs end early and would bias the percentile. Runs under 10 seconds that did no work are excluded when longer successful runs exist. An all-fast workflow uses every successful run. Null if no run succeeded in the window.
     * @nullable
     */
    p50_seconds: number | null
    /**
     * 95th-percentile duration in seconds over successful runs only: cancelled (superseded) and failed runs end early and would bias the percentile. Runs under 10 seconds that did no work are excluded when longer successful runs exist. An all-fast workflow uses every successful run. Null if no run succeeded in the window.
     * @nullable
     */
    p95_seconds: number | null
    /**
     * When the most recent decisive failure started, or null.
     * @nullable
     */
    last_failure_at: string | null
    /**
     * Whether the most recent completed run ended in failure, timeout, startup failure, or staleness. Null when no run has completed in the window. Powers the OK/RED status badge.
     * @nullable
     */
    latest_run_failed: boolean | null
    /**
     * Raw conclusion of the most recent completed run ('success', 'cancelled', 'skipped', ...), so a real pass can be told from a non-failure non-success. Null when none completed.
     * @nullable
     */
    latest_run_conclusion: string | null
    /** @nullable */
    latest_run_id: number | null
    /** @nullable */
    latest_run_attempt: number | null
    /** Bucket width of the `buckets` series, chosen to fit the window: 'hour', 'day', or 'week'. */
    granularity: string
    /**
     * Billable (self-hosted) minutes over this workflow's jobs in the window. Null when the job-level source isn't synced.
     * @nullable
     */
    billable_minutes?: number | null
    /**
     * Estimated cost in USD over this workflow's jobs in the window. Null when nothing was costable or the job source isn't synced.
     * @nullable
     */
    estimated_cost_usd?: number | null
    /** Runs in the window that were a 2nd+ attempt - retry pressure, a flakiness proxy. */
    rerun_cycles?: number
    /**
     * Conclusive-run success rate over the equal-length window before date_from - the delta baseline. Null when that window had no conclusive runs.
     * @nullable
     */
    success_rate_prev?: number | null
    /** Successful runs lasting at least 10 seconds. Zero when p50/p95 fall back to shorter successful runs. */
    percentile_run_count?: number
    /** Runs on merge-queue gate branches (trunk-merge/**) in the window, counted regardless of branch or run_scope. Non-zero marks a workflow the queue runs before a merge lands, the closest available proxy for a required check. */
    merge_queue_run_count?: number
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    latest_ci_engine?: CIEngineEnumApi | null
}

export interface WorkflowJobStepApi {
    /** 1-based position of the step in the job. */
    number: number
    /** Step name. */
    name: string
    /** Raw step status: 'queued', 'in_progress', 'completed', etc. */
    status: string
    /**
     * Step conclusion ('success', 'failure', 'cancelled', 'skipped', ...), or null until the step finishes.
     * @nullable
     */
    conclusion: string | null
    /**
     * When the step started, or null if it has not started.
     * @nullable
     */
    started_at: string | null
    /**
     * When the step finished, or null while it runs.
     * @nullable
     */
    completed_at: string | null
    /**
     * Wall-clock duration in seconds; null until the step finishes.
     * @nullable
     */
    duration_seconds: number | null
}

export interface WorkflowJobApi {
    /** The job's steps in run order. Empty when the source reports no steps, as for a Depot CI job. */
    steps: WorkflowJobStepApi[]
    /** Integer job id; unique only together with ci_engine. */
    id: number
    /** The workflow run id this job belongs to. */
    run_id: number
    /** Job name. */
    name: string
    /** Raw job status: 'queued', 'in_progress', 'completed', etc. */
    status: string
    /**
     * Job conclusion ('success', 'failure', 'cancelled', 'skipped', ...), or null while running.
     * @nullable
     */
    conclusion: string | null
    /**
     * When the job started, or null while still queued.
     * @nullable
     */
    started_at: string | null
    /**
     * When the job completed, or null while still running.
     * @nullable
     */
    completed_at: string | null
    /**
     * Wall-clock duration in seconds; null until the job completes.
     * @nullable
     */
    duration_seconds: number | null
    /** Where the job ran: 'github_hosted' (free for open source), 'self_hosted' (billable), or 'unknown'. */
    runner_provider: string
    /** Runner tier the job ran on (e.g. '16-core' or 'ubuntu-latest'), or '' when unknown. */
    runner_label: string
    /**
     * Estimated cost in USD from runner tier + elapsed time; null when the tier is unknown or the job hasn't finished.
     * @nullable
     */
    estimated_cost_usd: number | null
    /** CI execution engine; null when unknown.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI */
    ci_engine?: CIEngineEnumApi | null
    /**
     * Source-native run id; use with ci_engine for identity.
     * @nullable
     */
    native_run_id?: string | null
    /**
     * Source-native workflow run id; use with ci_engine for identity.
     * @nullable
     */
    native_workflow_run_id?: string | null
    /**
     * Source-native job id; use with ci_engine for identity.
     * @nullable
     */
    native_job_id?: string | null
    /**
     * Source-native attempt id; use with ci_engine for identity.
     * @nullable
     */
    native_attempt_id?: string | null
}

export interface WorkflowRunnerCostApi {
    /** 'self_hosted' (billable), 'github_hosted' (free), or 'unknown'. */
    provider: string
    /** Runner tier, e.g. '16-core' or 'ubuntu-latest'. */
    runner_label: string
    /** Jobs that ran on this tier for the workflow. */
    job_count: number
    /** Billable minutes on this tier. */
    billable_minutes: number
    /**
     * Estimated cost in USD on this tier; null for non-billable (github-hosted/non-Linux).
     * @nullable
     */
    estimated_cost_usd: number | null
}

export type EngineeringAnalyticsAttentionPullRequestsParams = {
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsAuthorFrictionParams = {
    /**
     * GitHub team slug: list only the team's members, through the team membership table. Ranks stay repository-wide.
     */
    github_team?: string
    /**
     * 'owner/name' repository, when the selected source syncs several.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsAuthorFrictionDetailParams = {
    /**
     * GitHub login of the author to show.
     */
    author: string
    /**
     * 'owner/name' repository, when the selected source syncs several.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsAuthorLlmSpendParams = {
    /**
     * GitHub handle whose pull requests to list.
     */
    author: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * Maximum pull requests to return, 1 to 200. Defaults to 100.
     */
    limit?: number
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsAuthorWorkflowCostsParams = {
    /**
     * GitHub handle whose CI spend to break down.
     */
    author: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsBrokenTestsParams = {
    /**
     * Optional exact branch name. Keeps only tests that failed on it, but the counts still cover every branch, so a row shows whether the test also fails elsewhere. Applied before the limit.
     */
    branch?: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Optional case-insensitive substring of the test id to keep, e.g. 'test_cohort' or 'posthog/api/test/test_user.py'. Applied before the limit, so a test past the cap is still found.
     */
    test?: string
}

export type EngineeringAnalyticsCiCardsParams = {
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsCiDataFreshnessParams = {
    /**
     * 'owner/name' repository to report on.
     * @minLength 1
     */
    repo: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the source connected for `repo`.
     */
    source_id?: string
}

export type EngineeringAnalyticsCiFailureLogsParams = {
    /**
     * Pull request number whose CI failure logs to fetch.
     */
    pr_number: number
    /**
     * 'owner/name' repository the pull request belongs to.
     */
    repo: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsCiTimingContextParams = {
    /**
     * CI engine that ran the run.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI
     * @minLength 1
     */
    ci_engine: EngineeringAnalyticsCiTimingContextCiEngine
    /**
     * Comma-separated job ids from workflow_jobs, at most 200. Required for 'matrix', 'job' and 'step'. Give exactly one id for 'job' and 'step'. Ignored for 'workflow'.
     * @minLength 1
     */
    job_ids?: string
    /**
     * What to compare: the whole 'workflow', a 'matrix' (several jobs of the run), one 'job', or one 'step' of a job.
     *
     * * `workflow` - Workflow
     * * `matrix` - Matrix
     * * `job` - Job
     * * `step` - Step
     * @minLength 1
     */
    kind: EngineeringAnalyticsCiTimingContextKind
    /**
     * 'owner/name' repository the run belongs to.
     * @minLength 1
     */
    repo: string
    /**
     * Run attempt that holds the selection.
     * @minimum 1
     */
    run_attempt: number
    /**
     * Integer run id of the run that holds the selection.
     */
    run_id: number
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the source connected for `repo`.
     */
    source_id?: string
    /**
     * Number of the step within the job. Required when kind is 'step'.
     */
    step_number?: number
}

export type EngineeringAnalyticsCiTimingContextCiEngine =
    (typeof EngineeringAnalyticsCiTimingContextCiEngine)[keyof typeof EngineeringAnalyticsCiTimingContextCiEngine]

export const EngineeringAnalyticsCiTimingContextCiEngine = {
    GithubActions: 'github_actions',
    DepotCi: 'depot_ci',
} as const

export type EngineeringAnalyticsCiTimingContextKind =
    (typeof EngineeringAnalyticsCiTimingContextKind)[keyof typeof EngineeringAnalyticsCiTimingContextKind]

export const EngineeringAnalyticsCiTimingContextKind = {
    Workflow: 'workflow',
    Matrix: 'matrix',
    Job: 'job',
    Step: 'step',
} as const

export type EngineeringAnalyticsCurrentBranchHealthParams = {
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsDeliveryComparisonParams = {
    /**
     * GitHub login of the author to compare with their team and the repository.
     */
    author: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * A pull request by the author. Needs repo. A team of the author's that this pull request asked to review is the team to compare with, and the pull request stays out of the medians.
     */
    pr_number?: number
    /**
     * 'owner/name' repository. Required with pr_number; otherwise it picks the repository when the selected source syncs several.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsDeliverySummaryParams = {
    /**
     * GitHub login: scope the read to this author's pull requests. Pass exactly one scope.
     */
    author?: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * GitHub team slug: scope the read to pull requests authored by the team's members, through the team membership table. Pass exactly one scope.
     */
    github_team?: string
    /**
     * 'owner/name' repository. Required with pr_number; otherwise it picks the repository when the selected source syncs several.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsDepotCiUsageParams = {
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
}

export type EngineeringAnalyticsDoraParams = {
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * Deploy environment(s) to scope to, repeatable (from the response's `environments` list). Omit to include all persistent environments marked production or named prod/production (including regional suffixes), falling back to the busiest persistent environment when none match. Explicit names are trimmed, deduplicated, and validated against the source, including transient environments. Blank or unknown names are rejected with a 400 response.
     */
    environment?: string[]
    /**
     * GitHub team slug (from the response's `github_teams` list) to narrow the PR-scoped merge-to-deploy figures to that team's authors. Deploy counts stay repo-wide. Needs the team-membership snapshot synced; without it the merge-to-deploy figures return empty rather than silently unfiltered.
     */
    github_team?: string
    /**
     * Bucket width for every series. Omit to pick one that fits the window: hour up to 48h, day up to 90 days, week beyond.
     */
    granularity?: EngineeringAnalyticsDoraGranularity
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsDoraGranularity =
    (typeof EngineeringAnalyticsDoraGranularity)[keyof typeof EngineeringAnalyticsDoraGranularity]

export const EngineeringAnalyticsDoraGranularity = {
    Day: 'day',
    Hour: 'hour',
    Week: 'week',
} as const

export type EngineeringAnalyticsFlakyTestsParams = {
    /**
     * Optional exact branch name. Keeps only tests that failed on it, but the counts still cover every branch, so a row shows whether the test also fails elsewhere. Applied before the limit.
     */
    branch?: string
    /**
     * Window start: relative ('-7d', '-30d') or ISO8601. Defaults to -7d; the window may span at most 30 days.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * Maximum number of tests to return (1-200). Defaults to 50.
     */
    limit?: number
    /**
     * A test with no recorded recovery qualifies once it failed on at least this many distinct pull requests in the window. Minimum 1. Defaults to 3.
     */
    min_failed_prs?: number
    /**
     * Optional pull request number. Keeps only tests that failed in that PR's CI runs, but the counts still cover every PR. Pass min_failed_prs=1 too, so a test that failed on this PR alone qualifies. Applied before the limit.
     */
    pr_number?: number
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Optional test runner to return: 'pytest' or 'jest'.
     */
    runner?: EngineeringAnalyticsFlakyTestsRunner
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Optional case-insensitive substring of the test id to keep, e.g. 'test_cohort' or 'posthog/api/test/test_user.py'. Applied before the limit, so a test past the cap is still found.
     */
    test?: string
}

export type EngineeringAnalyticsFlakyTestsRunner =
    (typeof EngineeringAnalyticsFlakyTestsRunner)[keyof typeof EngineeringAnalyticsFlakyTestsRunner]

export const EngineeringAnalyticsFlakyTestsRunner = {
    Jest: 'jest',
    Pytest: 'pytest',
} as const

export type EngineeringAnalyticsJobAggregatesParams = {
    /**
     * Optional exact git branch (head_branch) to scope results to, e.g. 'main'. Omit or leave blank to aggregate across all branches.
     */
    branch?: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Which group of runs to report on: 'all' (default) is every run; 'default_branch' is runs on master or main; 'pull_request' is runs on PR branches, excluding default-branch and merge-queue runs; 'merge_queue' is the gate runs the merge queue fired before a merge landed. Fork PRs carry no PR attribution (a GitHub limitation), so they appear only under 'all'. Any other value is a 400.
     */
    run_scope?: EngineeringAnalyticsJobAggregatesRunScope
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Workflow name to aggregate jobs for.
     */
    workflow_name: string
}

export type EngineeringAnalyticsJobAggregatesRunScope =
    (typeof EngineeringAnalyticsJobAggregatesRunScope)[keyof typeof EngineeringAnalyticsJobAggregatesRunScope]

export const EngineeringAnalyticsJobAggregatesRunScope = {
    All: 'all',
    DefaultBranch: 'default_branch',
    MergeQueue: 'merge_queue',
    PullRequest: 'pull_request',
} as const

export type EngineeringAnalyticsJobLogInsightsParams = {
    /**
     * CI engine. Required when job_id exists in both engines. Only GitHub Actions job logs are read.
     *
     * * `github_actions` - GitHub Actions
     * * `depot_ci` - Depot CI
     * @minLength 1
     */
    ci_engine?: EngineeringAnalyticsJobLogInsightsCiEngine
    /**
     * Job id to read the log of; a row id from workflow_jobs.
     */
    job_id: number
    /**
     * 'owner/name' repository the job ran in.
     * @minLength 1
     */
    repo: string
    /**
     * Workflow run id the job belongs to.
     */
    run_id: number
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the source connected for `repo`.
     */
    source_id?: string
}

export type EngineeringAnalyticsJobLogInsightsCiEngine =
    (typeof EngineeringAnalyticsJobLogInsightsCiEngine)[keyof typeof EngineeringAnalyticsJobLogInsightsCiEngine]

export const EngineeringAnalyticsJobLogInsightsCiEngine = {
    GithubActions: 'github_actions',
    DepotCi: 'depot_ci',
} as const

export type EngineeringAnalyticsLlmSpendCoverageParams = {
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsMasterFailuresParams = {
    /**
     * Optional exact git branch (head_branch) to scope results to, e.g. 'main'. Omit or leave blank to aggregate across all branches.
     */
    branch?: string
    /**
     * Window start: relative ('-24h', '-7d') or ISO8601. Defaults to -24h.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsPrCostParams = {
    /**
     * Pull request number to estimate cost for.
     */
    pr_number: number
    /**
     * 'owner/name' repository the pull request belongs to.
     */
    repo: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsPrLifecycleParams = {
    /**
     * Pull request number to inspect.
     */
    pr_number: number
    /**
     * 'owner/name' repository the pull request belongs to.
     */
    repo: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsPrRunsParams = {
    /**
     * Pull request number whose runs to list.
     */
    pr_number: number
    /**
     * 'owner/name' repository the pull request belongs to.
     */
    repo: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsPullRequestFrictionParams = {
    /**
     * Pull request number to show.
     */
    pr_number: number
    /**
     * 'owner/name' repository the pull request belongs to.
     */
    repo: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsPullRequestTimelinesParams = {
    /**
     * GitHub login: scope the read to this author's pull requests. Pass exactly one scope.
     */
    author?: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * GitHub team slug: scope the read to pull requests authored by the team's members, through the team membership table. Pass exactly one scope.
     */
    github_team?: string
    /**
     * Pull request number: scope the read to this one pull request. Needs repo. Pass exactly one scope.
     */
    pr_number?: number
    /**
     * 'owner/name' repository. Required with pr_number; otherwise it picks the repository when the selected source syncs several.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsPullRequestsParams = {
    /**
     * Optional GitHub login to scope the list to one author's pull requests.
     */
    author?: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Optional exclusive upper bound for merged_at / closed_at: relative or ISO8601. Defaults to now. Set a fixed value when you page, so new merges do not move rows between pages.
     */
    date_to?: string
    /**
     * Page size, 1 to 1000. Defaults to 1000.
     */
    limit?: number
    /**
     * Number of rows to skip. Defaults to 0. While `truncated` is true, add `limit` to offset to read the next page.
     */
    offset?: number
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Optional state filter. 'merged' lists PRs merged in the window, newest merged_at first. 'closed' lists PRs closed without a merge in the window, newest closed_at first. 'open' lists all open PRs whatever their age, newest first. Omit it to get open PRs plus any merged or closed in the window.
     */
    state?: EngineeringAnalyticsPullRequestsState
}

export type EngineeringAnalyticsPullRequestsState =
    (typeof EngineeringAnalyticsPullRequestsState)[keyof typeof EngineeringAnalyticsPullRequestsState]

export const EngineeringAnalyticsPullRequestsState = {
    Closed: 'closed',
    Merged: 'merged',
    Open: 'open',
} as const

export type EngineeringAnalyticsQuarantineParams = {
    /**
     * Optional 'owner/name' repository to read the quarantine file from. Defaults to the connected GitHub source's most active repo over the last 30 days.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsRepoOverviewParams = {
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * Set false to skip the chart series (cost_series, time_to_green_series, success_rate_series, open_to_merge_series return empty) and their query cost: for headline-only consumers like the weekly digest. Defaults to true.
     */
    include_series?: boolean
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsRepoRunActivityParams = {
    /**
     * Optional exact git branch (head_branch) to chart, e.g. 'main'. Omit or leave blank to use the repo's detected default branch.
     */
    branch?: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsResolveBranchParams = {
    /**
     * Git branch (the PR's head ref) to resolve. Open PRs are returned first, then most recently updated.
     */
    branch: string
    /**
     * Optional 'owner/name' repository to narrow matching to a single repo.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Optional ISO8601 timestamp, e.g. the trace's capture time. When a branch name has been reused across PRs over time, the PR whose lifetime window contains this moment is ranked first so the result matches the PR that was active when the trace was captured. A preference only, not a filter; omit to rank purely by open state then recency.
     */
    timestamp?: string
}

export type EngineeringAnalyticsRunFailureLogsParams = {
    /**
     * CI engine. Required when run_id exists in both engines.
     */
    ci_engine?: EngineeringAnalyticsRunFailureLogsCiEngine
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Workflow run id whose failure logs to fetch.
     */
    run_id: number
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsRunFailureLogsCiEngine =
    (typeof EngineeringAnalyticsRunFailureLogsCiEngine)[keyof typeof EngineeringAnalyticsRunFailureLogsCiEngine]

export const EngineeringAnalyticsRunFailureLogsCiEngine = {
    DepotCi: 'depot_ci',
    GithubActions: 'github_actions',
} as const

export type EngineeringAnalyticsTeamCiActivityParams = {
    /**
     * Window start: relative ('-14d', '-7d') or ISO8601. Defaults to -14d; the window may span at most 30 days. An equal-length prior window feeds the *_prior twins; near the 30-day ceiling that prior window can reach past Traces retention, deflating *_prior counts.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * Owning team slug to scope to (as returned by team_ci_health), e.g. 'team-replay', or the literal 'unowned' for tests with no ownership stamp.
     */
    owner_team: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Maximum number of per-test signal rows to return (1-100). Defaults to 25.
     */
    test_limit?: number
}

export type EngineeringAnalyticsTeamCiHealthParams = {
    /**
     * Window start: relative ('-14d', '-7d') or ISO8601. Defaults to -14d; the window may span at most 30 days. An equal-length prior window is scanned for the *_prior twins; near the 30-day ceiling that prior window can reach past Traces retention, deflating *_prior counts and overstating deltas.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * Maximum number of teams to return (1-200). Defaults to 100.
     */
    limit?: number
    /**
     * An unrecovered test counts toward regression_test_count once it failed on at least this many distinct pull requests in the window. Minimum 1. Defaults to 3. Does not affect flaky_test_count, which needs proof, not a threshold.
     */
    min_failed_prs?: number
    /**
     * Restrict the roster to one owning team slug (or 'unowned'). The cheap way to read a single team's rollup.
     */
    owner_team?: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsTeamMergeTrendParams = {
    /**
     * Window start: relative ('-14d', '-7d') or ISO8601. Defaults to -14d; the window may span at most 30 days.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * Team slug to scope to (as returned by team_ci_health), matched against the GitHub org team slug of the source's team_members snapshot. The literal 'unowned' names an ownership gap, not an org team, and has no merge trend.
     */
    owner_team: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsTrunkQuarantineParams = {
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsWorkflowHealthParams = {
    /**
     * Optional exact git branch (head_branch) to scope results to, e.g. 'main'. Omit or leave blank to aggregate across all branches.
     */
    branch?: string
    /**
     * Window start: relative ('-24h', '-7d') or ISO8601. Defaults to -24h.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Which group of runs to report on: 'all' (default) is every run; 'default_branch' is runs on master or main; 'pull_request' is runs on PR branches, excluding default-branch and merge-queue runs; 'merge_queue' is the gate runs the merge queue fired before a merge landed. Fork PRs carry no PR attribution (a GitHub limitation), so they appear only under 'all'. Any other value is a 400.
     */
    run_scope?: EngineeringAnalyticsWorkflowHealthRunScope
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Optional exact workflow name to scope results to, e.g. 'Backend CI'. Omit to rank every workflow. Pass it when you want one workflow's figures over the whole window rather than the top slice.
     */
    workflow_name?: string
}

export type EngineeringAnalyticsWorkflowHealthRunScope =
    (typeof EngineeringAnalyticsWorkflowHealthRunScope)[keyof typeof EngineeringAnalyticsWorkflowHealthRunScope]

export const EngineeringAnalyticsWorkflowHealthRunScope = {
    All: 'all',
    DefaultBranch: 'default_branch',
    MergeQueue: 'merge_queue',
    PullRequest: 'pull_request',
} as const

export type EngineeringAnalyticsWorkflowJobsParams = {
    /**
     * CI engine. Required when run_id exists in both engines.
     */
    ci_engine?: EngineeringAnalyticsWorkflowJobsCiEngine
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Which re-run attempt to scope jobs to. Omit to use the run's latest attempt; pass an explicit attempt to avoid mixing jobs across a re-run's attempts.
     */
    run_attempt?: number
    /**
     * Workflow run id to list jobs for.
     */
    run_id: number
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsWorkflowJobsCiEngine =
    (typeof EngineeringAnalyticsWorkflowJobsCiEngine)[keyof typeof EngineeringAnalyticsWorkflowJobsCiEngine]

export const EngineeringAnalyticsWorkflowJobsCiEngine = {
    DepotCi: 'depot_ci',
    GithubActions: 'github_actions',
} as const

export type EngineeringAnalyticsWorkflowRunParams = {
    /**
     * CI engine. Required when run_id exists in both engines.
     */
    ci_engine?: EngineeringAnalyticsWorkflowRunCiEngine
    /**
     * 'owner/name' repository to scope to when the selected source syncs several repositories (from the `sources` list). Defaults to the source's first repository.
     */
    repo?: string
    /**
     * Integer run id to inspect; unique only together with ci_engine.
     */
    run_id: number
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
}

export type EngineeringAnalyticsWorkflowRunCiEngine =
    (typeof EngineeringAnalyticsWorkflowRunCiEngine)[keyof typeof EngineeringAnalyticsWorkflowRunCiEngine]

export const EngineeringAnalyticsWorkflowRunCiEngine = {
    DepotCi: 'depot_ci',
    GithubActions: 'github_actions',
} as const

export type EngineeringAnalyticsWorkflowRunActivityParams = {
    /**
     * Optional exact git branch (head_branch) to scope results to, e.g. 'main'. Omit or leave blank to aggregate across all branches.
     */
    branch?: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository the workflow belongs to.
     */
    repo: string
    /**
     * Which group of runs to report on: 'all' (default) is every run; 'default_branch' is runs on master or main; 'pull_request' is runs on PR branches, excluding default-branch and merge-queue runs; 'merge_queue' is the gate runs the merge queue fired before a merge landed. Fork PRs carry no PR attribution (a GitHub limitation), so they appear only under 'all'. Any other value is a 400.
     */
    run_scope?: EngineeringAnalyticsWorkflowRunActivityRunScope
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Workflow name to load run activity for.
     */
    workflow_name: string
}

export type EngineeringAnalyticsWorkflowRunActivityRunScope =
    (typeof EngineeringAnalyticsWorkflowRunActivityRunScope)[keyof typeof EngineeringAnalyticsWorkflowRunActivityRunScope]

export const EngineeringAnalyticsWorkflowRunActivityRunScope = {
    All: 'all',
    DefaultBranch: 'default_branch',
    MergeQueue: 'merge_queue',
    PullRequest: 'pull_request',
} as const

export type EngineeringAnalyticsWorkflowRunnerCostsParams = {
    /**
     * Optional exact git branch (head_branch) to scope results to, e.g. 'main'. Omit or leave blank to aggregate across all branches.
     */
    branch?: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository the workflow belongs to.
     */
    repo: string
    /**
     * Which group of runs to report on: 'all' (default) is every run; 'default_branch' is runs on master or main; 'pull_request' is runs on PR branches, excluding default-branch and merge-queue runs; 'merge_queue' is the gate runs the merge queue fired before a merge landed. Fork PRs carry no PR attribution (a GitHub limitation), so they appear only under 'all'. Any other value is a 400.
     */
    run_scope?: EngineeringAnalyticsWorkflowRunnerCostsRunScope
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Workflow name to break down cost for.
     */
    workflow_name: string
}

export type EngineeringAnalyticsWorkflowRunnerCostsRunScope =
    (typeof EngineeringAnalyticsWorkflowRunnerCostsRunScope)[keyof typeof EngineeringAnalyticsWorkflowRunnerCostsRunScope]

export const EngineeringAnalyticsWorkflowRunnerCostsRunScope = {
    All: 'all',
    DefaultBranch: 'default_branch',
    MergeQueue: 'merge_queue',
    PullRequest: 'pull_request',
} as const

export type EngineeringAnalyticsWorkflowRunsParams = {
    /**
     * Optional exact git branch (head_branch) to scope results to, e.g. 'main'. Omit or leave blank to aggregate across all branches.
     */
    branch?: string
    /**
     * Window start: relative ('-30d', '-8w') or ISO8601. Defaults to -30d.
     */
    date_from?: string
    /**
     * Window end: relative or ISO8601. Defaults to now.
     */
    date_to?: string
    /**
     * 'owner/name' repository the workflow belongs to.
     */
    repo: string
    /**
     * Which group of runs to report on: 'all' (default) is every run; 'default_branch' is runs on master or main; 'pull_request' is runs on PR branches, excluding default-branch and merge-queue runs; 'merge_queue' is the gate runs the merge queue fired before a merge landed. Fork PRs carry no PR attribution (a GitHub limitation), so they appear only under 'all'. Any other value is a 400.
     */
    run_scope?: EngineeringAnalyticsWorkflowRunsRunScope
    /**
     * Connected GitHub data warehouse source to read from. Defaults to the oldest connected GitHub source that the `sources` list reports as synced, when the team has more than one.
     */
    source_id?: string
    /**
     * Workflow name to list runs for.
     */
    workflow_name: string
}

export type EngineeringAnalyticsWorkflowRunsRunScope =
    (typeof EngineeringAnalyticsWorkflowRunsRunScope)[keyof typeof EngineeringAnalyticsWorkflowRunsRunScope]

export const EngineeringAnalyticsWorkflowRunsRunScope = {
    All: 'all',
    DefaultBranch: 'default_branch',
    MergeQueue: 'merge_queue',
    PullRequest: 'pull_request',
} as const