Skip to content

Read-only pull request readiness verdict with coded reasons #3482

Closed

Description

@integry

Problem

An external coordinator cannot ask ProPR "is this pull request ready to integrate, and if not, why". The inputs exist in six separate computations that share no types, and the only code path that evaluates all of them (processPRAutoMerge / reevaluatePRAutoMerge in packages/core/src/webhook/checkRunHandler.ts) also withdraws auto-merge, may update the branch and may merge. Most gates report no reason code, only log text.

What to build

A pure read that returns one verdict per pull request and never writes to GitHub or changes auto-merge state.

  • MCP tool get_pull_request_readiness (scope read, readOnly: true), args repository, number.
  • REST GET /api/pull-requests/:number/readiness?repository=owner/repo, registered in packages/api/routeRegistry.ts, documented in ROUTE_DOCS, answering errors with ErrorEnvelope, with a zod schema in packages/api/openapi/schemas.ts.
  • CLI: propr pr readiness <number> [--json].

Result shape

{
  repository, number, head, base, state: open|merged|closed, draft,
  verdict: ready | waiting | blocked | merged | closed | unknown,
  gates: [{ gate, status: pass|waiting|fail|unknown|not_applicable, reason, detail? }],
  blockingReasons: string[],   // reason codes of gates with status fail
  waitingReasons: string[],    // reason codes of gates with status waiting or unknown
  review: { score, goal, goalReached, reviewedHead, matchesCurrentHead } | null,
  ultrafix: { active, completionStatus, labelPresent } | null,
  checks: { reason, blockingFailed, blockingPending, nonBlockingCount },
  autoMerge: { eligible: eligible|ineligible|transient, policy: AutoMergeReason | null },
  evaluatedAt
}

Verdict rule: merged/closed from PR state; blocked if any gate fails; else waiting if any gate is waiting; else unknown if any gate is unknown; else ready.

Gates and stable reason codes

gate codes
open pull_request_merged, pull_request_closed
not_draft draft
checks reuse CiMergeReadiness.reason: checks_passing, checks_not_passing, no_ci, waiting_for_ci, unavailable
mergeable merge_conflict, branch_behind_base, branch_protection_blocked, merge_state_unknown
human_review changes_requested, review_required
ai_review no_review, review_stale_head, score_below_goal, goal_reached
ultrafix ultrafix_active, ultrafix_failed, ultrafix_state_unavailable, ultrafix_succeeded
active_work propr_work_active, active_work_unavailable
policy the existing AutoMergeReason values; not_applicable when auto-merge is not requested

ai_review is not_applicable when the PR has no ProPR review at all and no ultrafix label; it never blocks a PR that ProPR is not reviewing. policy and auto-merge eligibility are reported but do not change the verdict unless the PR or its issue carries the auto-merge label.

Constraints

  • No side effects. getCiMergeReadiness (packages/core/src/webhook/checkRunHelpers.ts) writes/deletes the Redis auto-merge:head-observed:* key. Split a pure classifier out of it (same blocking/non-blocking classification via summarizeCheckSignals, reads the observation key but never writes it) and have the existing function call it, so behaviour of the merge path is unchanged.
  • Reason codes for eligibility. evaluateAutoMergeEligibility (packages/core/src/webhook/autoMergeEvaluation.ts) returns only eligible|ineligible|transient. Add a variant that also returns a reason code; keep the existing function as a wrapper so callers are untouched.
  • Active-work check must not fail open in this read. getActiveTasksForPR returns empty on error; here an error must surface as active_work_unavailable (status unknown).
  • Export getUltrafixLoopState and the new read helpers from packages/core/src/index.ts; do not read the Redis key directly from the API package.
  • Project goal_reached in the score loader (packages/api/routes/reviewScoreStats.ts).
  • Use the App identity for the evaluation (same view the merge path has, including legacy commit statuses and non-blocking checks); authorise the caller's repository access the same way get_pull_request does.
  • Put the evaluation in one core function (for example evaluatePullRequestReadiness) returning the shape above; REST, MCP and CLI are thin wrappers. Do not create a third type named PullRequestSnapshot.
  • Do not change what merge_pull_request or auto-merge decide.

Acceptance criteria

  • A PR with green blocking checks, clean merge state, no changes requested, latest AI review at or above goal on the current head, and no active ProPR work returns ready with empty blockingReasons and waitingReasons.
  • Each reason code above is produced by at least one test.
  • A test proves the read performs no GitHub write and no Redis write (including the head-observation key) and does not call update-branch or merge.
  • Existing auto-merge tests (test/checkRunHandler.test.ts, packages/core/test/autoMerge*.test.ts) pass unchanged in behaviour.
  • npm run gen:openapi output is committed; openapiRouteCoverage, openapiResponseConformance, mcpObservableSurface, mcpDocs and mcpToolInputBudget tests pass.
  • docs/mcp.md, docs/mcp-coverage.md and docs/docs/operations/api-reference.md describe the verdict, every gate and every reason code. Any new backticked lowercase token in docs/mcp.md that is not a tool name is added to the allow-list in packages/api/test/mcpObservableSurface.test.ts.

Implementation

  1. Core: pure CI classifier split out of getCiMergeReadiness; reason-returning eligibility variant; evaluatePullRequestReadiness(owner, repo, number, deps) in a new file under packages/core/src/webhook/ or packages/core/src/services/; export from the core index together with getUltrafixLoopState.
  2. API: REST handler + route registry entry + route doc + zod schema; MCP tool in packages/api/mcp/toolsPullRequests.ts; add goal_reached to the score loader.
  3. CLI command propr pr readiness.
  4. Tests: core unit tests per gate and per reason code with injected deps; no-write test; MCP test following packages/api/test/mcpPullRequests.test.ts; REST route test.
  5. Regenerate OpenAPI and client types; update docs and the non-tool token allow-list.

Notes

Patterns: packages/api/mcp/pullRequestPreconditions.ts (ordered preconditions with codes), packages/api/mcp/toolsWorkOverview.ts (enrichPullRequests). The auto-merge files changed recently (PR #3450), so re-read them rather than trusting line numbers.

Activity

  1. propr-dev commented on Nov 12, 2026

    @propr-dev
    Contributor

    🤖 AI processing has started for this issue using claude agent with claude-opus-5-5 model.

    I'll analyze the problem and work on a solution. This may take a few minutes.

    Processing Details:

    • Agent: claude
    • Model: claude-opus-5-5
    • Branch: 3482/claude-opus-5-5-read-only-pull-request-re-20261112-1226-anv
    • Base Branch: 3482-epic-integration-signals-100
    • Worktree: issue-3482-20261112-1226-claude-opus-5-5-anv

    🔍 Track Task Execution

  2. added a commit that references this issue on Nov 12, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions