Repository navigation
Description
Context & Rationale
The readiness rules live inside a Typer module. commands/pr.py:1177-1806 is 33 helpers and 525 lines; typer.Exit is raised 14 times inside commands and 23 times inside 14 helpers. Checked at 9c879ae.
- Fetching and classifying check runs is written three times (
pr.py:1258-1405,github/pr_monitor.py:394-495,github/check_verdict.py:220-355);_extract_page_runsexists three times,_fetch_pr_detailstwice, the mergeable evaluation twice, the unresolved-thread evaluation twice. refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769 unifies the check read; this item unifies the verdict around it. - The Item rule from feat(github): pr readiness requires an issue-linked, completed task file #704, "one PR closes exactly one issue and changes its Task file", exists only as private helpers (
_closes_one_issueand_changes_its_task_file) called from_grounding_blockers. pr monitorre-fetches details, checks and threads with its own helpers and its ownPRMonitorStatus.is_ready_for_merge;pr readyuses a third path throughcheck_verdict.fetch_pr_check_verdicts.- The MCP tool
pr_check_readiness(ai/mcp/server.py:2204) reuses the rules by spawninguv run devops pr check-readiness. - Tests import or patch 19
pr.pyprivate helpers and patchcommands.pr.run_gh21 times.
Deletion test: delete the pr.py block and the rules reappear in pr_monitor and the MCP tool. One module concentrates them.
Scope & Deliverables
- Deliverable: one module that, given a repository, a pull request number and a runner, returns a readiness verdict as data: the blockers and the grounding facts.
pr check-readinessrenders it and exits;pr readyandpr monitorloop over it; the MCP tool returns it. The three check-run copies, the two mergeable and two thread evaluations become one. - Tests: the verdict is computed from canned payloads through a fake runner (the
GhRunnerpattern from refactor(github): roadmap store that reads and writes items, releases and board fields behind one interface #768). The patch-run_ghreadiness tests intest_pr_cmd.pyandtest_pr_check_runs.pygo;pr_monitortests shrink to the loop and the exit codes. - Key questions (open):
- Does the verdict live under
github/orroadmap/? It enforces an Item rule. - How do feat(github): defect prs carry their hardening readiness blocker and post-merge audit #697's hardening blocker and fix(github): pr readiness passes when review threads can't be read #797's unreadable-threads fix land in it?
- Which facts are blockers and which are advisory, and who decides the exit code?
- Does the verdict live under
- Constraint: builds on refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769's fail-closed check read; the feat(github): fail-closed pr check verdicts from one bucket classifier #707 classifier table stays as it is.
Strategic Alignment
- Design: CONTEXT.md (Item, Task file, Service)
- Depends on: refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769
- Related: feat(github): pr readiness requires an issue-linked, completed task file #704, feat(github): fail-closed pr check verdicts from one bucket classifier #707, fix(github): pr readiness passes when review threads can't be read #797, feat(github): defect prs carry their hardening readiness blocker and post-merge audit #697, refactor(github): pull request, repository and ssh key calls move from pygithub onto the github session #891, feat(release): item closure summaries, generated changelog and automatic release cut (
devops roadmap close) #743, feat(roadmap): run the roadmap jobs when they are due (devops roadmap run) #981 - Source: architecture review of 2026-10-02, commands over the GitHub and roadmap packages
Scope added 2026-10-02: checked at 38517a8. _extract_page_runs is in commands/pr.py:1277 and github/pr_monitor.py:394, and github/check_verdict.py:220 holds the third copy as _extract_page_check_runs. _fetch_pr_details is at pr.py:228 and pr_monitor.py:495. The Item rules are at pr.py:1594-1700, and _evaluate_pr_blockers at :1703. The MCP tool pr_check_readiness (ai/mcp/server.py:2208-2222) runs uv run devops pr check-readiness. Tests name devops_cli.commands.pr.run_gh 53 times in 3 files, 19 of them as one-line patch(...) calls. Check-run exit codes already live on CheckVerdictSummary.exit_code: 0 pass, 8 pending, 1 failing or unread (check_verdict.py:101-115).
Acceptance criteria
- One module returns a readiness verdict from a repository, a pull request number and a runner with
run_gh's signature (the GitHub session once refactor(github): the github session owns transport, ledger, error classes and link pagination #983 lands; refactor(github): the github session owns transport, ledger, error classes and link pagination #983 removes theGhRunnerProtocol,roadmap/github_store.py:91): blockers, advisories, grounding facts and an exit code. It prints nothing and raises notyper.Exit. -
pr check-readiness,pr ready,pr monitorand the MCPpr_check_readinesstool use it. The MCP tool returns the verdict as JSON and spawns nodevopsprocess. - The verdict takes its checks from refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769's fail-closed reader and reads none itself. refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769 owns collapsing the three check-run readers; this item checks that
rg 'def _extract_page' srcstill finds one function. Mergeable state and unresolved threads, read today by bothcommands/pr.pyandgithub/pr_monitor.py, are each evaluated once. - The Item rules (
_closes_one_issueand_changes_its_task_file) are public predicates over the grounding facts, each with a table test. - Tests compute verdicts from canned payloads through a scripted runner with
run_gh's signature. No readiness test patchesdevops_cli.commands.pr.run_gh.pr monitortests cover only its loop and exit codes. - The exit codes of
pr check-readiness,pr readyandpr monitordo not change. A table test pins each command's code for ready, pending, failing and unread checks, unresolved threads and a draft, and the monitor's timeout. - The tests run offline.
-
uv run devops cipasses. - (person-run)
devops pr check-readiness <open PR>gives the same blockers before and after the change.
Key questions
- Does the verdict live under
github/orroadmap/? It enforces an Item rule. (proposed) Both, split by concern.github/reads the PR and assembles the verdict. The Item rules are pure predicates inroadmap/, because they state CONTEXT.md's Item definition. - How do feat(github): defect prs carry their hardening readiness blocker and post-merge audit #697's hardening blocker and fix(github): pr readiness passes when review threads can't be read #797's unreadable-threads fix land in it? (proposed) fix(github): pr readiness passes when review threads can't be read #797 is a defect fix and lands first, on today's code. feat(github): defect prs carry their hardening readiness blocker and post-merge audit #697's blocker becomes one more predicate in whichever of the two lands second.
- Which facts are blockers and which are advisory, and who decides the exit code? (proposed) The verdict decides what blocks and what is advisory, and carries pending checks as their own fact. Each command maps the verdict to the exit codes it has today, because they differ:
pr check-readinessexits 1 on any blocker and counts pending checks as one unless--allow-pending-checksis given (commands/pr.py:1396-1400);pr readyexits 8 while checks are pending and 1 when one fails or cannot be read (:978-1016);pr monitorexits 1 for failing checks, 2 for a draft or unresolved threads and 3 on timeout (github/pr_monitor.py:156). Advisories never change a code.
Finding from the v0.2.25 release PR (2026-10-03): pr wait gives up before pending checks finish
Problem (added). On #1089 (the v0.2.25 release PR), devops pr wait exited as soon as it saw unresolved review threads while required checks were still running. A person then had to re-run the wait after resolving the threads, and a check failure that arrived later was reported only on that second run. Unresolved threads are a blocker a person can still clear while CI runs; they are not a reason to stop waiting for checks.
Acceptance criteria (added).
- The verdict separates pending (checks still running or queued) from blocked. While any required check is pending,
pr waitkeeps waiting, whatever other blockers it sees. - When the checks settle,
pr waitreports every blocker at once: failed or unread checks, unresolved threads, Copilot state and any other predicate, each with its reason. - A scripted test: a head with two pending required checks and one unresolved thread; the checks complete (one fails) after the thread is first seen.
pr waitreturns once, after the checks settle, and names both the failed check and the thread.
Placement. No change. This item's children (#806, #797, #769) supply the reads; the waiting rule lives in this one verdict.
Update 2026-10-08: refinement
#769 and #806 landed; this waits on #797. Checks have one reader (github/check_verdict.py:220), and rg 'def _extract_page' would also hit rate_limiter.py:1581; use rg -n 'def _extract_page_(check_)?runs' src. Still duplicated: _fetch_pr_details, the mergeable rules and thread reads (commands/pr.py:239, :1209; github/pr_monitor.py:488, :525). pr wait still exits while checks pend (pr_monitor.py:681-723). #1324 moves readiness into github/; the Item rules go to roadmap/. Whichever lands second rebases.
Proposed design
Problem statement
The pull request readiness rules are currently scattered across multiple modules and duplicated in several places, making them hard to maintain and test. The goal is to centralize these rules into a single module that can be consumed by various commands, monitors, MCP tools, and future components like Closure and the Service.
Acceptance criteria
- Criterion 1: One module returns a readiness verdict from a repository, a pull request number and a runner with run_gh's signature
Verification: The new module accepts repository, PR number and a runner with run_gh's signature, returning blockers, advisories, grounding facts and an exit code - Criterion 2: pr check-readiness, pr ready, pr monitor and the MCP pr_check_readiness tool use the centralized verdict module
Verification: All commands and tools call the new verdict module instead of their own implementations - Criterion 3: The verdict takes its checks from refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769's fail-closed reader and reads none itself
Verification: Verify that the check-run readers are consolidated in one place and the new verdict module uses them - Criterion 4: The Item rules are public predicates over the grounding facts, each with a table test
Verification: Item rules (_closes_one_issue, _changes_its_task_file, _leaves_release_files_to_the_cut) are moved to roadmap/ and tested with table tests - Criterion 5: Tests compute verdicts from canned payloads through a scripted runner
Verification: No readiness test patches devops_cli.commands.pr.run_gh; all tests use the new fake runner pattern - Criterion 6: The exit codes of pr check-readiness, pr ready and pr monitor do not change
Verification: Run existing tests to ensure exit code behavior is preserved for all commands
Key questions
- Does the verdict live under github/ or roadmap/?: Both, split by concern. github/ reads the PR and assembles the verdict. The Item rules are pure predicates in roadmap/, because they state CONTEXT.md's Item definition and feat(github): current release admission, cap, descoping and stall rules (
devops roadmap reprioritize) #740 and feat(release): item closure summaries, generated changelog and automatic release cut (devops roadmap close) #743 apply them without a PR's checks. (proposed) - How do feat(github): defect prs carry their hardening readiness blocker and post-merge audit #697's hardening blocker and fix(github): pr readiness passes when review threads can't be read #797's unreadable-threads fix land in it?: fix(github): pr readiness passes when review threads can't be read #797 is a defect fix and lands first, on today's code. feat(github): defect prs carry their hardening readiness blocker and post-merge audit #697's blocker becomes one more predicate in whichever of the two lands second. (proposed)
- Which facts are blockers and which are advisory, and who decides the exit code?: The verdict decides what blocks and what is advisory, and carries pending checks as their own fact. Each command maps the verdict to the exit codes it has today, because they differ: pr check-readiness exits 1 on any blocker and counts pending checks as one unless --allow-pending-checks is given; pr ready exits 8 while checks are pending and 1 when one fails or cannot be read; pr monitor exits 1 for failing checks, 2 for a draft or unresolved threads and 3 on timeout. (proposed)
- Does it land before or after feat(github): current release admission, cap, descoping and stall rules (
devops roadmap reprioritize) #740?: After feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 and refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769. feat(github): current release admission, cap, descoping and stall rules (devops roadmap reprioritize) #740 adds a blocker to _evaluate_pr_blockers in v0.2.25, and this item moves it with the others. (proposed)
Fit
Fits in one pull request.
Suspected block
None.
Dependencies
None.
Sub-issues
Collapse Sub-issuesSub-issues
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsReady
- StatusShow more project fieldsReady
Activity
dan-petty commentedon Oct 3, 2026
Consolidation (2026-10-03): this item is the parent of the readiness reads. One rule applies to every input: an unread fact blocks and names its reason (
unread_reason). Sub-issues and order:Linked, not sub-issues:
dan-petty commentedon Oct 17, 2026
Moved to v0.2.37: v0.2.37 started with fewer than its 16 items and was topped up to 16 from Ready items, critical fixes and P0 features first. (devops roadmap reprioritize)
dan-petty commentedon Oct 18, 2026
Amendment (2026-10-18): a test-shaped handler in the check verdict module
_fetch_commit_statuses_from_rest(src/devops_cli/github/check_verdict.py:360-388at release/v0.2.37 66ff3d6) wraps its runner call inexcept StopIteration, IndexError: return [], None, "".run_gh, never raises either. Both come from a test's mocked reply list running out, so the handler exists only to cope with mocks. AGENTS.md lists product code that detects tests as a signal to stop and fix the cause.github_apifake. A read that fails reports its unread reason, as the check-runs read does once refactor(github): the github session owns transport, ledger, error classes and link pagination #983 PR 4 merges.Found while #983 PR 4 moved
_fetch_check_runs_from_rest(in the same module) onto the GitHub session.dan-petty commentedon Oct 18, 2026
Amendment (2026-10-18): the monitor ends on one transient unread poll
devops pr monitor 1678exited 1 after its third poll with "PR check verification failed closed: GitHub check-runs API error: GitHub gave no readable answer to GET /repos/dan-petty/devops-cli/commits/.../check-runs (page 1): ConnectTimeout". The first two polls had read the check runs fine. Three probes of the same read right afterwards each returned all 15 runs in under 2 s, and a fresh monitor reported 15/15 passed. One transient connect timeout ended the watch and reported a CI failure that did not exist.Cause, at release/v0.2.37 cca1ed9:
_fetch_rest_check_runs(src/devops_cli/github/pr_monitor.py:451-463) turns any unread verdict into oneCheckBucket.UNREADrow._check_early_pr_failures(:681-696) ends the monitor with exit 1 on the first poll holding one.ghread produced the same row. The session does not retry a connection error by design (refactor(github): the github session owns transport, ledger, error classes and link pagination #983's plan, matchingrun_gh), so the poll loop is the place to absorb a transient one.Failing closed is right for a one-shot readiness verdict (
devops pr check-readiness). A polling monitor should treat an unread poll as "not known yet". It keeps polling and fails closed only when the reads stay unread: for a set number of consecutive polls (a constant inconfig/defaults.py), or until its own timeout, whichever comes first. Its output names the read failures it saw either way.Tests first, offline: a monitor over a fake whose check-runs read fails once and then reports every check passed finishes successfully, and its output mentions the one unread poll. A read that stays unread for the bound fails closed with exit 1, naming the last reason.
dan-petty commentedon Oct 18, 2026
Amendment (2026-10-18), from #1345 PR 1's review
The review decision lets a COMMENTED reply replace a person's verdict.
_extract_latest_reviews_by_user(src/devops_cli/github/pr_monitor.py:558-572at 7607f0f) keeps each person's latest review of any state.config/constants.py. Do not switch to GraphQLreviewDecision, which is null when the base requires no approvals.No budget rule in the monitor. #1345's plan says this item "moves the monitor's review gate, with the budget rule, into the one verdict module". #1345 PR 1 adds no budget rule to the monitor. Its review confirmed
_build_changes_status(#216) already reports Copilot's changes-recommended state as completed once no thread is unresolved, and an unresolved thread blocks by itself. Drop the budget rule from this item's plan. Optionally, have the verdict module name the unresolved threads in its "Copilot review requested changes" message, which is the only difference the rule would have made.dan-petty commentedon Oct 19, 2026
Status set to Ready at 0ae4ea4 (see proposed design in issue body).
[-]refactor(github): pr readiness is one verdict module that the pr commands, the monitor, mcp and closure consume[/-][+]refactor(github): pr readiness is one verdict module that the pr commands, the monitor and mcp consume[/+]dan-petty commentedon Oct 28, 2026
This item is larger than one pull request on today's code (origin/main 4226904), so it is split into two sub-issues:
github/thatdevops pr check-readinessrenders, and the item rules as public predicates inroadmap/. No behavior changes.devops pr readyanddevops pr monitor(andpr wait) read that verdict, and the monitor waits until the checks settle and then names every blocker. This part changes the monitor's behavior.Evidence of the size:
src/devops_cli/commands/pr.pyis about 750 lines, from_check_mergeable_blockertocheck_readiness. The rules now include the OpenSpec archive rules and thepriority/*Item rule of ADR 0016 (feat(roadmap): labels and milestones hold each item's status, priority, value and effort, and no roadmap job reads or writes the project board #2435).tests/test_pr_cmd.py(2,641 lines),tests/test_github_pr_monitor.py(1,445 lines) andtests/test_pr_check_runs.py.What changed since this item was written:
pr_check_readinessis generated from the Typer command (refactor(mcp): the mcp tool bridge is generated from the typer app instead of 147 hand-written argv lists #997) and runs it in-process. It spawns nodevopsprocess, so it needs no separate change._changes_its_task_fileis gone. The item rules are now the OpenSpec archive rules and thepriority/*label rule.github/check_verdict.py).pr waitis an alias ofpr monitor.Decisions on the key questions (best practice):
github/. The item rules are pure predicates inroadmap/.refactor(github): pr check-readiness reads one merge-readiness verdic…
dan-petty commentedon Oct 28, 2026
Both parts of this item are merged:
github/merge_readiness.py) returns the readiness verdict as data, andpr check-readinessrenders it. The item rules are public predicates inroadmap/grounding.py.pr monitor,pr waitandpr readyconsume that verdict.fetch_pr_detailsingithub/pr_monitor.pyis the only pull request read.The MCP tool needed no change: since #997 it is generated from the command and runs in process.