/** * PR-metadata evidence adapter (P4 — evidence collectors). * * Maps a pull-request review/checks payload (as returned by `gh pr view --json * reviewDecision,statusCheckRollup,mergeable,number,url,additions,deletions`) * into an `EvidenceItem` for `computeReleaseConfidence`, using the * `deploy-metadata` source kind — the closest P3-reserved kind for * PR-level ship-readiness. * * Design: * - Pure function. The caller fetches the `gh` JSON; this adapter scores it. * - Applicability: * `applicable` — a PR exists and review/check state is readable * `not_applicable` — no PR for this ref (direct push, script, etc.) * `unknown` — PR exists but checks are still pending / state ambiguous * - Score formula (0..100): * Base 60 points: PR is open and merge-ready (no conflicts) * +20: reviewDecision === 'APPROVED' * +20: all status checks pass (statusCheckRollup every entry state === 'SUCCESS') * Deductions: * -10: any failing status check (per failing check, capped at 20) * -15: reviewDecision === 'CHANGES_REQUESTED' * - The adapter NEVER fabricates a PR number or URL; if absent from the payload * the evidence strings omit them (WAVE-GUARDRAILS: no fabricated data). */ import type { EvidenceItem } from '../schemas/confidence.schema.js'; /** * Status-check entry shape from `gh pr view --json statusCheckRollup`. * Only the fields we actually use — extra fields are harmlessly ignored. */ export interface StatusCheck { /** e.g. "SUCCESS", "FAILURE", "PENDING", "SKIPPED", "NEUTRAL" */ state: string; /** CI job/check name — optional, used for the evidence string */ name?: string; /** Direct URL to the check — never fabricated; omit rather than invent */ targetUrl?: string; } /** GitHub review decision values as returned by the `gh` CLI. */ export type ReviewDecision = 'APPROVED' | 'CHANGES_REQUESTED' | 'REVIEW_REQUIRED' | null | undefined; /** Mergeable state as returned by `gh pr view --json mergeable`. */ export type MergeableState = 'MERGEABLE' | 'CONFLICTING' | 'UNKNOWN' | null | undefined; /** * Raw PR payload the caller provides. All fields are optional — the adapter * degrades gracefully when partial data is available. */ export interface PrMetadataInput { /** PR number. Never fabricated — omit if absent. */ number?: number; /** PR URL. Never fabricated — omit if absent. */ url?: string; /** Review decision from the `gh` response. null/undefined = no review yet. */ reviewDecision?: ReviewDecision; /** Array of status check entries (the `statusCheckRollup` field). */ statusCheckRollup?: StatusCheck[]; /** * Whether the PR is currently mergeable (no conflicts). * null/UNKNOWN counts as unknown-state. */ mergeable?: MergeableState; /** ISO-8601 when this payload was collected. Defaults to now. */ collectedAt?: string; /** * Set to true when there is explicitly NO PR for this ref (e.g. direct push). * Produces a `not_applicable` contribution so the aggregator abstains honestly. */ noPr?: boolean; } /** * Produce a `deploy-metadata` EvidenceItem from a PR metadata payload. * Returns `not_applicable` when `noPr` is true, `unknown` when checks are * pending or state is ambiguous, and `applicable` with a real score otherwise. */ export declare function prMetadataToEvidence(input: PrMetadataInput, collectedAt?: string): EvidenceItem; //# sourceMappingURL=pr-metadata-adapter.d.ts.map