Repository navigation
Description
Problem Statement
devops pr monitor (and FastMCP pr_monitor, which shells out to it at src/devops_cli/ai/mcp/server.py:2151-2178) can report that Copilot is idle or has finished reviewing when it actually failed to read Copilot's state. Checked at the release/v0.2.25 tip:
_query_timeline_copilot_statereturns(False, "")(not working) when the timeline read exits non-zero (src/devops_cli/github/pr_monitor.py:321-334). An exhaustedrun_ghretry loop returnsreturncode=1with empty stdout and stderr (src/devops_cli/github/rate_limiter.py:1835-1858), and withcheck=Falsenothing raises (:1861-1871), so a rate-limited or failedghcall lands in the silent branch._fetch_raw_reviewsreturns[]when the reviews read fails (pr_monitor.py:509-522)._detect_copilot_statusthen reportscompletedfrom an earlier Copilot review, oridleif there is none (pr_monitor.py:377-391). Its state vocabulary isidle | working | completed | changes_requested(:80); there is no unread value.is_review_readytreats both states as settled (pr_monitor.py:132-142), and_check_pr_ready_steprepeats the same rule (pr_monitor.py:803-806).
The two other reads in the same status snapshot already fail loud: _fetch_pr_details raises GitHubOperationError (pr_monitor.py:499-501) and the threads read raises from _run_graphql_query (src/devops_cli/github/pr_threads.py:83-85). Only the timeline and reviews reads fail silent. The check-run side of the same module already has a fail-closed vocabulary: PRCheckRun.is_failure counts CheckBucket.UNREAD as a failure (pr_monitor.py:69, bucket from src/devops_cli/github/check_verdict.py:34).
A failed timeline read on its own is enough to hide a Copilot re-review that is still running. Take an approved PR whose checks pass: once the settle window has passed (pr_monitor.py:794-810), pr monitor certifies it ready with exit 0 (pr_monitor.py:764-773) while Copilot is still reviewing. AGENTS.md:278 ("Copilot post-ready review sessions have settled") and :283-285 ("Wait for Copilot Review Sessions to Settle") require Copilot to settle first.
A failed reviews read is narrower today: with --require-reviews (the default) the empty list makes _resolve_review_decision return None (pr_monitor.py:600-617) and the monitor exits 2 with the misattributed message "requires review approval before merging: current review decision is 'NONE'" (pr_monitor.py:747-756). With --no-require-reviews (approval_ok is True at :135) the PR can be certified ready with Copilot's latest changes-requested review unseen.
Proposed Solution
Add an unread state to CopilotReviewStatus that any failed Copilot read produces, make readiness treat it as not settled, and surface the reason everywhere pr monitor reports Copilot.
CopilotReviewStatus(pr_monitor.py:76-82):stategains the valueunread; a new fieldunread_reason: str = ""carries why, named afterCheckVerdictSummary.unread_reason(check_verdict.py:75), the existing fail-closed precedent for check runs.is_activestaysFalseforunread;messagereads "Copilot review state could not be read: ". The message is an inline string like the four existing state messages (pr_monitor.py:348-391); nolang/edit is needed.- The reason is the
ghstderr trimmed to 256 characters, orExit code Nwhen stderr is empty, the same rule_fetch_pr_detailsuses (pr_monitor.py:500). No dependency on the error classes of refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (v0.2.28, which lands after this item): the trimmed stderr is enough here, and refactor(github): the github session owns transport, ledger, error classes and link pagination #983 can later feedunread_reasonfrom its classifier without changing the field. _query_timeline_copilot_stateand_fetch_raw_reviewsreport failure to their caller instead of returning the "nothing happened" value. One shape that keeps the existing callers and test patches working: each returns its current value plus an error string (empty on success), andget_pr_monitoring_status(pr_monitor.py:625-672) passes both errors into_detect_copilot_status. The argv of both reads stays as it is (pr_monitor.py:323-330,:513-518), so refactor(github): the github session owns transport, ledger, error classes and link pagination #983's pagination change rebases onto this item without touching its logic. A successful read with empty output is not a failure: an empty timeline or an empty reviews list still meansidle, as the existing_detect_copilot_statustests already assert withMagicMock(returncode=0, stdout="")(tests/test_github_pr_monitor.py:503-504)._detect_copilot_status(pr_monitor.py:337-391): if either read failed, returnunreadbefore any other branch, includingchanges_requested. One rule, no precedence table.is_review_ready(pr_monitor.py:132-142) and_check_pr_ready_step(pr_monitor.py:803-806):unreadis not settled. The monitor loop keeps polling while the state isunread, exactly as it does forworkingand pending checks (pr_monitor.py:833-856), and on timeout_build_monitor_timeout_result(pr_monitor.py:777-791) appends the unread reason to its message. Exit codes stay0/1/2/3(pr_monitor.py:156)._build_failure_reasons(pr_monitor.py:551-579) addsCopilot review state could not be read: <reason>sofailure_reasonsin the--format json|yaml|markdownpayload (src/devops_cli/commands/pr.py:575-596, viamodel_dump) and the table output carry it. The table progress line (pr.py:648-651) already prints any non-idlestate, soCopilot: unreadappears without a change there.- Changelog fragment
changelog.d/806.mdand task filedocs/agent/tasks/task-806-<slug>.md, written in the delivering PR.CHANGELOG.mdanddocs/ROADMAP.mdare not edited.
Scope
One pull request touching src/devops_cli/github/pr_monitor.py, tests/test_github_pr_monitor.py, tests/test_pr_cmd.py, changelog.d/806.md and the task file. Effort Low, as groomed.
Key Questions
- Does a failed reviews read on its own make the state
unread? Answered (body): yes. The latest Copilot review is what decideschanges_requested, so an unread reviews list means that decision cannot be made. With--require-reviewsthis also replaces today's misattributed "requires review approval ... 'NONE'" exit 2 (pr_monitor.py:747-756) with the real reason. - Does
unreadtake precedence overchanges_requestedwhen only the timeline read fails? Answered (follows from the body's rule): yes. Any failed read producesunread, one rule. A Copilot re-review may have superseded the known review, and the next poll recovers the exit-2 signal. - Is this a critical fix for the current release? Answered (grooming comment, 2026-10-02): no. P1, placed in v0.2.27; the owner's planning decisions of 2026-10-02 keep it there.
- Must the feat(github): github tab in devops dashboard with an oldest-first pr queue, pr inspector, failing-log view and api quota (
tab-github) #685 inspector showunread? Answered (grooming comment): no. feat(github): github tab in devops dashboard with an oldest-first pr queue, pr inspector, failing-log view and api quota (tab-github) #685 is open andsrc/devops_cli/ui/has no GitHub tab at the tip (dashboard.py,pod_inspector.py,widgets.py, ...;docs/agent/tasks/task-685-*.md:4is stillBacklog); the criterion is dropped. When feat(github): github tab in devops dashboard with an oldest-first pr queue, pr inspector, failing-log view and api quota (tab-github) #685 lands, its inspector shows the state aspr monitorreports it, which will includeunread. - What does the monitor loop do while the state is
unread: keep polling until the timeout, or exit at once? Answered (settled from the issue and the code): keep polling; the timeout result (exit 3) carries the reason. The issue's deliverable is thatunreadis "not settled", and the monitor's meaning of not settled is to poll until the settle or timeout deadline (_check_pr_ready_stepreturnsNoneatpr_monitor.py:810; the loop continues at:848-856). An unread state is by construction a partial failure:get_pr_monitoring_statusreads the PR details first (:630) and that read raises on any failure (:499-501), so an outage or revoked token never reaches the timeline read; what does reach it (a rate-limited or 5xx secondary call) is transient and the next poll usually recovers. Raising like the details read would be an uncaught traceback, since nothing catchesGitHubOperationErroraroundmonitor_pr(pr.py:658-667,entry.py,main.py). A new exit code would ripple to every caller of0/1/2/3(pr_monitor.py:156) and to AGENTS.md. - Where does the reason live on the model? Answered (settled by precedent): a dedicated
unread_reasonfield plusmessage. The issue asks for theunreadvalue "with the reason it couldn't be read";CheckVerdictSummary.unread_reason(check_verdict.py:75,:98-112) is the existing name for the same fail-closed idea, andpr_monitor.pyalready imports that module's vocabulary (:17,:69). JSON consumers and tests assert one field instead of parsing prose; the cost is one Pydantic field. - Does this wait for, or conflict with, the GitHub session work? Answered (split decision of 2026-10-02): neither. refactor(github): one github session per identity owning token, quota and transport #767 (v0.2.26, Part A: identity and pin) does not edit
pr_monitor.py; the pagination and error-class work behind these two reads is refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (v0.2.28), which lands after this item and rebases onto it (the cross-check fixes fix(github): pr monitor reports copilot as idle or completed when its timeline or reviews read fails #806 before refactor(github): the github session owns transport, ledger, error classes and link pagination #983).
Acceptance Criteria
- Timeline read exits 1 and an earlier Copilot review exists:
_detect_copilot_statusreturnsstate == "unread"with a non-emptyunread_reason, notcompleted, and aPRMonitorStatuscarrying it hasis_review_readyFalse. Test: newtest_detect_copilot_status_unread_when_timeline_read_failsintests/test_github_pr_monitor.py, patchingdevops_cli.github.pr_monitor.run_ghwithMagicMock(returncode=1, stdout="", stderr="HTTP 403: rate limit"), as the_detect_copilot_statustests at:492-559do. - Reviews read exits 1:
get_pr_monitoring_statusreturnscopilot_status.state == "unread". Test: newtest_get_pr_monitoring_status_unread_when_reviews_read_fails, shaped liketest_get_pr_monitoring_status_success(:206-276) with thepulls/168/reviewsbranch ofmock_subprocessreturningreturncode=1. - Timeline read exits 1 and the known Copilot review recommends changes: the state is
unread, notchanges_requested. Test: newtest_detect_copilot_status_unread_wins_over_changes_requested. - A successful read with empty output still reports
idle, and every existing state is unchanged: the existing tests intests/test_github_pr_monitor.py(TestGetPRMonitoringStatus,TestMonitorPR, the_detect_copilot_statustests) andtests/test_pr_cmd.py::test_pr_monitor_*pass without edits. Command:uv run pytest tests/test_github_pr_monitor.py tests/test_pr_cmd.py -q. -
monitor_prdoes not certify an approved, green PR ready while Copilot isunread: withget_pr_monitoring_statuspatched to return an otherwise ready status whosecopilot_statusisunread, the result is exit 3 and the message contains the unread reason. Test: newtest_monitor_pr_does_not_certify_ready_while_copilot_unread, shaped liketest_monitor_pr_timeout(:368-392). -
failure_reasonsnames the unread reason. Test: newtest_build_failure_reasons_includes_copilot_unread, shaped liketest_build_failure_reasons_includes_review_approval(:875-890). -
devops pr monitor --format jsonoutput carriescopilot_status.state == "unread"andcopilot_status.unread_reason. Test: new case intests/test_pr_cmd.pypatchingdevops_cli.github.pr_monitor.monitor_prastest_pr_monitor_json_format_is_pure_json(:598-629) does, asserting on the parsed JSON payload. - No test hits the network: every new test patches
run_gh,get_pr_monitoring_statusormonitor_pr. Command:uv run devops cipasses. -
changelog.d/806.mdexists andCHANGELOG.mdanddocs/ROADMAP.mdare untouched. Command:devops pr check-readinesspasses.
Out of Scope
- The feat(github): github tab in devops dashboard with an oldest-first pr queue, pr inspector, failing-log view and api quota (
tab-github) #685 GitHub inspector. It does not exist at the tip (src/devops_cli/ui/has no GitHub tab); when it lands it shows the state aspr monitorreports it. run_gh --paginatereturning[]for the timeline when two events match, and the reviews list stopping at page 1 (both recorded in refactor(github): one github session per identity owning token, quota and transport #767 againstpr_monitor.py:322-331and:510-519). A successful-but-truncated read is not a failed read; refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (v0.2.28) fixes the pagination.- Classifying the failure (rate limit, missing scope, not found, unauthenticated): refactor(github): the github session owns transport, ledger, error classes and link pagination #983's error classes. Here the reason is the trimmed
ghstderr. - A failed check-runs read (
_fetch_commit_check_runsreturns[]atpr_monitor.py:415-416and:419-420):check-readinessalready fails closed throughCheckVerdictSummary.unread_reason; whetherpr monitorshould too is a separate candidate. - Changing which state a successful read reports (constraint kept from the original body).
- New exit codes for
pr monitor.
Dependencies
- Depends on: none.
- refactor(github): the github session owns transport, ledger, error classes and link pagination #983 (v0.2.28): lands after this item and rebases onto it; it changes the pagination behind the two reads this item touches (
pr_monitor.py:321-334,:509-522) and both keep the call-site argv, so fix(github): pr monitor reports copilot as idle or completed when its timeline or reviews read fails #806 goes first, as the cross-check fixes (fix(github): pr monitor reports copilot as idle or completed when its timeline or reviews read fails #806 before refactor(github): the github session owns transport, ledger, error classes and link pagination #983), and its body says the same. - refactor(github): one github session per identity owning token, quota and transport #767 (v0.2.26, Part A): no dependency either way; after the split it edits no line of
pr_monitor.py, and the reason string here comes fromghstderr, not from the classes that moved to refactor(github): the github session owns transport, ledger, error classes and link pagination #983. - feat(github): github tab in devops dashboard with an oldest-first pr queue, pr inspector, failing-log view and api quota (
tab-github) #685: related only, not in this run's item list; its inspector will showunreadaspr monitorreports it once it exists. - refactor(github): read a pull request's checks once, fail-closed, for wait, monitor and readiness #769: related only, not in this run's item list; the check-runs counterpart of this fail-closed rule.
Readiness check (2026-10-04)
Checked at the release/v0.2.26 tip (b61e5a0). Every cited symbol and test still exists, and the dependency picture is unchanged: #767 merged in v0.2.26 without touching these lines, and #983 is still open in v0.2.28. Only line numbers moved:
src/devops_cli/github/pr_monitor.py: every cited line from:42on is 4 lower, because feat(cli): extend the ruff rule set to the correctness families #420 shortenedPRCheckRun's validator. Current lines:PRCheckRun.is_failureis at:65andCopilotReviewStatusat:72-78, with the state comment at:76.is_review_readyis at:128-137, withapproval_okat:131. The exit-code comment is at:152._query_timeline_copilot_stateis at:317-330and_detect_copilot_statusat:333-387._fetch_pr_detailsraises at:495-497; the reason rule is on:496._fetch_raw_reviewsis at:505-518and_build_failure_reasonsat:547-575._resolve_review_decisionis at:596-613andget_pr_monitoring_statusat:621-668, with the details read on:626.- The review-approval exit 2 is at
:743-752and the ready certification at:760-769. _build_monitor_timeout_resultis at:773-787._check_pr_ready_stepis at:790-806, withcopilot_doneat:799-802andreturn Noneon:806.- The
monitor_prloop is at:829-854. The import on:17is unchanged.
src/devops_cli/commands/pr.py(3 lines lower):_emit_structured_monitor_resultis at:578-598.- The progress line is at
:651-654. - The
monitor_prcall is at:661-670.
src/devops_cli/ai/mcp/server.py:pr_monitoris at:2245-2271.src/devops_cli/github/rate_limiter.py: the retry loop is_run_gh_retry_loop(:1834-1877), and_raise_for_statusis at:1880-1890. An exhausted loop returns the last attempt's process with its stderr, so theExit code Nfallback applies only whenghprinted nothing.AGENTS.md: the settle rules are at:279and:286.- The test-file lines cited in the acceptance criteria are unchanged.
The acceptance criteria are unchanged. The item agrees with the rules in force: offline tests, a changelog.d fragment, and one PR that closes #806 only.
Metadata
Metadata
Assignees
Labels
Type
Projects
- StatusShow more project fieldsDone
Activity
dan-petty commentedon Oct 2, 2026
Grooming (2026-10-02): Placed in v0.2.27, one of its slots held for P1 work that surfaced after it was planned. Value High, effort Low. Before it starts: The last criterion ('the #685 inspector shows unread') cannot be met: #685 is open and there is no GitHub tab in ui/ at the tip. 'Depends on: none' is therefore inaccurate. Drop that criterion or make it conditional on #685.
Checked against the code at the release/v0.2.25 tip.
dan-petty commentedon Oct 3, 2026
Consolidation (2026-10-03): this item is a sub-issue of #998 (one readiness verdict). Its scope and v0.2.27 placement are unchanged, and it lands before #769 and #983. The rule it applies to the Copilot reads, that an unread fact blocks and names its reason, is the one #769 and #797 apply to check runs, statuses and threads.
fix(github): pr monitor reports copilot as idle or completed when its…
dan-petty-bot commentedon Oct 5, 2026
What changed
#1234, merged into
release/v0.2.27as 5651e62.5 file(s) changed.
How it was verified
Check runs at ac3ac2f:
Acceptance Criteria of
docs/agent/tasks/task-806-pr-monitor-reports-copilot-as-idle-or-completed-when-its-timeline-or-reviews-read-fails.md:_detect_copilot_statusreturnsstate == "unread"with non-emptyunread_reason, andPRMonitorStatus.is_review_readyisFalse.get_pr_monitoring_statusreturnscopilot_status.state == "unread".unread, taking precedence overchanges_requested.idle, and every existing state is unchanged.monitor_prdoes not certify an approved, green PR ready while Copilot isunread, exiting 3 with the unread reason in the timeout message.failure_reasonsnames the unread reason.devops pr monitor --format jsonoutput carriescopilot_status.state == "unread"andcopilot_status.unread_reason.changelog.d/806.mdexists andCHANGELOG.mdanddocs/ROADMAP.mdremain untouched.uv run devops cipasses on this branch.feat(release): v0.2.27 (#1257)