Repository navigation
[3482 by Claude Opus 5.5] Read-only pull request readiness verdict with coded reasons - #3489
Conversation
…ss verdict plus a coded reason for every gate, through REST, MCP and the CLI. The new tests and every regression suite I ran pass, including `checkRunHandler` (145/145) and the `autoMerge*` core suites, unchanged in behaviour. Core (`packages/core`) - CI check: `getCiMergeReadiness` now uses a pure classifier, `classifyCiMergeReadiness`. A new `readCiMergeReadiness` reads the `auto-merge:head-observed:*` key but never writes or deletes it. The merge path still records and clears that key exactly as before. - Eligibility: `evaluateAutoMergeEligibilityWithReason` returns the eligibility plus a reason code. The old `evaluateAutoMergeEligibility` is now a thin wrapper, so its callers are untouched. - Active work: `readActiveTasksForPR` throws on a queue or database error, so the readiness read reports `active_work_unavailable` instead of "idle". `getActiveTasksForPR` keeps its old fail-open behaviour. - Evaluator: `evaluatePullRequestReadiness(owner, repo, number, deps)` lives in `webhook/pullRequestReadiness.ts`, with the per-gate logic as pure functions in `pullRequestReadinessGates.ts`. It runs as the GitHub App by default, and every dependency can be injected. - Exports: the core index exports these plus `getUltrafixLoopState`. API and CLI - REST: `GET /api/pull-requests/:number/readiness?repository=owner/repo` is registered, documented with `errors: 'envelope'`, and has a `PullRequestReadiness` zod schema. Errors are `INVALID_INPUT` (400), `PULL_REQUEST_NOT_FOUND` (404) and `GITHUB_UNAVAILABLE` (502). - MCP: `get_pull_request_readiness` (`read` scope, `readOnly`, args `repository` and `number`) first reads the PR with the caller's own GitHub access, as `get_pull_request` does, then evaluates as the App. - Score loader: it now returns `goal_reached` as a boolean or null. - CLI: `propr pr readiness <number> [-p owner/repo] [--json]`. - Generated files: `npm run gen:openapi` output is regenerated, and `gen:openapi:check` passes. Docs: `docs/mcp.md`, `docs/mcp-coverage.md` and the API reference describe the verdict rule and every gate and reason code. The CLI page lists the new command, and the new doc tokens are in the allow-list in `mcpObservableSurface.test.ts`. Tests - Core: one test per gate and reason code, a ready-PR case, and a no-write test. That test fails on any non-GET GitHub call, on any merge or update-branch, and on any Redis set or delete, including the head-observation key. - REST: the handler is checked against the OpenAPI schema and the error envelope. - MCP: grant check, caller access versus App identity, and the not-found path. - CLI: arguments, options and output formatting. - Updated: the score-loader test now covers `goal_reached`. - Existing suites also pass: `mcpPullRequests`, `mcpIntegration`, `mcpMergePreconditions`, `mcpOperatorSurface`, `mcpDocs`, `mcpToolInputBudget`, `mcpObservableSurface`, `openapiRouteCoverage`, `openapiResponseConformance`, `epicMergeProgressHandler` and `taskIntentWithdrawal`. - Lint passes with zero warnings across the api and core packages. Decisions to check in review - Extra reason codes: every gate needs a reason even when it passes or doesn't apply, so I added codes beyond the issue's table. These are `pull_request_open`, `not_draft`, `mergeable`, `approved`/`no_changes_requested`, `no_active_work`, `ultrafix_pending`, `ultrafix_not_requested` and `auto_merge_not_requested`. There are also three for unreadable data: `review_state_unavailable`, `review_scores_unavailable` and `ultrafix_state_unavailable`. All are documented and tested. - Extra field: `autoMerge` also carries the eligibility `reason`, which the issue's shape didn't include. - Behind base: `branch_behind_base` counts as a failure. - Blocked by protection: `branch_protection_blocked` only waits while checks or a required review are still pending; otherwise it fails. This stops a PR whose CI is still running from showing as `blocked`. - Plain reviews: a plain `/review` uses the instance `ultrafix_rating_goal` as its goal and must have no blockers to count as reaching it. - MCP test location: I put it in a new file, `mcpPullRequestReadiness.test.ts`, rather than extending the large `mcpPullRequests.test.ts`, and added it to the `test:mcp` list in `package.json`. No visual previews: the change has no UI.
|
/ultrafix goal=8 max=10 |
|
🔄 Ultrafix loop started (goal: 8/10, max cycles: 10) First action:
|
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds a well-structured readiness evaluator across REST, MCP and CLI, but needs changes before merge: three paths can produce an incorrect readiness verdict. ✅ Read-only CI classification — The new reader reuses the CI classifier without setting or deleting head-observation keys. ✅ MCP access boundary — The tool checks the caller’s PR access before evaluating with the App identity. ✅ Explicit failure reporting — Queue and score-loading failures become unknown gates instead of silently reporting idle work or absent reviews. This review is based on static tracing of the supplied diff and context; no commands were run. The supplied current-head status has no failures and three pending checks. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F1: 🔴 Paginate reviews before choosing reviewer verdicts
F2: 🔴 Keep unreadable auto-merge intent unknown
F3: 🔴 Bind policy evaluation to the reported head
SuggestionsThese are optional follow-ups and are not sent to No suggestions. ScoreThe implementation has clear separation of responsibilities and substantial test coverage, but incomplete review history, unknown intent handling and mixed snapshots undermine the central verdict contract. These require localized corrections before merge. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit b3abbb7
Summary of ChangesF1, F2 and F3 are fixed in F1: reviews are paginated. A new F2: an unreadable auto-merge request stays unknown. Whether auto-merge is requested now has three states. If the PR has no F3: the policy decision must match the reported head. I kept the policy's snapshot and moved the policy step into a small Same assumption elsewhere: no other gate reads its own copy of the PR. Checks and the AI review are already tied to the initial head, and none of the other signals is read as a single page, so no other part of the PR's code needed the same fix. Docs and schema: the two new codes are added to Checks run:
Separate issue, not fixed: in 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…equestReadiness.ts`, and each has a regression test. I ran the three new tests against the old source and they failed there; on the new code all 16 readiness tests pass.
F1, F2 and F3 are fixed in `packages/core/src/webhook/pullRequestReadiness.ts`, and each has a regression test. I ran the three new tests against the old source and they failed there; on the new code all 16 readiness tests pass.
**F1: reviews are paginated.** A new `readAllReviews` reads every page of 100 reviews, oldest first, before building each reviewer's latest verdict. If a page isn't a list, or the history runs past `MAX_REVIEW_PAGES` (30 pages, so 3,000 reviews), the gate reports `review_state_unavailable` instead of judging from a partial history. The regression puts a change request on page one and the same reviewer's approval on page two: the gate now passes with `approved` and the verdict is `ready`. A second case checks that a history longer than the cap is `unknown`.
**F2: an unreadable auto-merge request stays unknown.** Whether auto-merge is requested now has three states. If the PR has no `auto-merge` label and the linked issue can't be read, the policy gate is `unknown` with a new reason code, `auto_merge_request_unavailable`, and that code appears in `waitingReasons`. Previously this case was reported as `auto_merge_not_requested`. The regression combines an unreadable linked issue with a policy that disables auto-merge and confirms the verdict can't be `ready`.
**F3: the policy decision must match the reported head.** I kept the policy's snapshot and moved the policy step into a small `readPolicy` helper to stay under the lint complexity limit. If the policy saw a different head SHA or base branch from the one the readiness verdict reports, the gate is `unknown` with a new reason code, `pull_request_changed`, and `autoMerge.policy` is `null`. That stops the other snapshot's decision from leaking into the result. I didn't retry the evaluation: GitHub gives no way to lock out a push, so the race can't be closed, only detected. The regression is the scenario from the finding. Head H1 touches a protected path. The PR then moves to H2, which doesn't, and the policy would arm on H2. The verdict for H1 now comes back `unknown`, not `ready`. A second case covers a base-branch change.
**Same assumption elsewhere:** no other gate reads its own copy of the PR. Checks and the AI review are already tied to the initial head, and none of the other signals is read as a single page, so no other part of the PR's code needed the same fix.
**Docs and schema:** the two new codes are added to `docs/mcp.md`, `docs/mcp-coverage.md`, the API reference, the zod schema and the doc-token allow-list in `mcpObservableSurface.test.ts`. I regenerated the OpenAPI output, and `gen:openapi:check` passes.
**Checks run:**
- Lint passes with zero warnings on the changed core and API source files (the core lint config doesn't cover test files, as before).
- `tsc` passes for core and api.
- 47 tests pass across `mcpPullRequestReadiness`, `pullRequestReadinessRoutes`, `mcpObservableSurface`, `openapiResponseConformance`, `mcpDocs` and `autoMergeGate`.
**Separate issue, not fixed:** in `checkRunHelpers.ts`, `getCheckSignals` fetches check runs (`GET …/commits/{ref}/check-runs`) without `per_page` or pagination, so GitHub returns only the first 30. On a head with more check runs, a failing or pending one could be missed. That code predates this PR and wasn't one of the selected findings, so I left it unchanged.
PR: #3489
Comment by: @propr-ultrafix (ID: 0)
Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
|
CI failed: Validate unsigned linux-x64 package Please investigate and fix this CI failure.
Failure evidence
|
|
✅ Applied the requested follow-up changes in commit b507e9f Summary of ChangesI fixed the What failed: after a new account connects, the app swaps its CSP and reloads the page. Requests the old page makes in that gap are blocked on purpose. The harness accepts those blocked-request console errors only with matching proof from Chromium's DevTools protocol (CDP). In this run:
The fix, in Tests, in
Checks:
I couldn't run the full packaged acceptance ( There are no previews because nothing visible changed. 🤖 Implementation Details
Undo Changes • View Task Execution 💡 ProPR Slash Commands
🤖 Generated by ProPR |
…It wasn't caused by this PR's code: nothing under `apps/desktop` changed, `main` has the same code, and the linux-arm64 and darwin-arm64 jobs passed on the same commit. The darwin-x64 job was cancelled. The cause is a gap in the packaged-acceptance test harness's CSP (Content Security Policy) check, so the fix is a small change there. I fixed the `Validate unsigned linux-x64 package` failure. It wasn't caused by this PR's code: nothing under `apps/desktop` changed, `main` has the same code, and the linux-arm64 and darwin-arm64 jobs passed on the same commit. The darwin-x64 job was cancelled. The cause is a gap in the packaged-acceptance test harness's CSP (Content Security Policy) check, so the fix is a small change there. **What failed:** after a new account connects, the app swaps its CSP and reloads the page. Requests the old page makes in that gap are blocked on purpose. The harness accepts those blocked-request console errors only with matching proof from Chromium's DevTools protocol (CDP). In this run: - **current-user request:** Chromium's CSP report arrived as usual, so its three console errors were fine. - **demo-mode request:** the reload replaced the page before Chromium's report arrived. The harness did record a "page replaced before the report" entry for it. - **The rejection:** the harness only accepted that kind of entry for the current-user request; that rule came from the earlier flake fix in #3376. It refused the demo-mode error, and one refusal throws out every exemption. So the run ended with 4 unexpected errors. **The fix**, in `apps/desktop/scripts/packaged-acceptance-csp-reload.mjs`: the "page replaced before the report" entry now also covers demo-mode, but only for its "Connecting to … violates" console line. Everything else stays strict: the URL, page and test step must match exactly, the fetch must have happened once and never got a response, and the existing caps on how many errors are allowed per request still apply. "Fetch API cannot load" errors still need Chromium's report. **Tests**, in `packaged-acceptance-csp-reload.test.mjs`: - **New regression test:** it replays the exact CI order of events and checks that the run ends with zero unexpected errors. A third demo-mode error, or an unrelated error, still fails. Against the old code this test fails. - **Updated test:** the earlier test that expected demo-mode to be refused now checks the narrower rule. A demo-mode "Fetch API cannot load" error is still refused, and evidence for one request can't excuse the other. **Checks:** - That test file passes 51/51, and 52/52 with the real-Chromium boundary test turned on (`PROPR_DESKTOP_REAL_CHROMIUM_BOUNDARY=1`). - The full desktop unit suite (`npm run desktop:test`) passes: 1381 passed, 0 failed, 56 skipped. - Lint with zero warnings is clean on both files. I couldn't run the full packaged acceptance (`npm run desktop:acceptance`) here: this container has no Xvfb, Electron package or keyring. The next linux-x64 run in CI is the real confirmation. The PR will now also touch these two desktop harness files, so reviewers will see a change outside the readiness feature. There are no previews because nothing visible changed. PR: #3489 Comment by: @propr-dev[bot] (ID: 6825208801) Model: Claude Opus 5.5
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR delivers a shared readiness evaluator across REST, MCP and CLI, with clear gate classifications and substantial coverage. It needs a localized correctness fix before merge. ✅ Shared classification — CI readiness reuses a pure classifier while preserving the merge path’s observation writes. ✅ Explicit uncertainty — Queue and score-read failures produce unknown gates rather than falsely reporting idle work or absent reviews. ✅ Caller authorization — MCP checks the caller’s PR access before evaluating with the App identity. This review is based on static tracing of the supplied code; no commands were run. Current checks show 32 passed, two pending and no failures. Merge blockersEvery finding below was introduced by this PR and must be resolved before merging. F4: 🔴 Canonicalize repository identity before internal reads
SuggestionsThese are optional follow-ups and are not sent to No suggestions. ScoreThe implementation is well structured and broadly tested, but repository identity handling can produce a false-ready verdict. The correction is localized; the two pending checks must also finish before merge. Score: 6/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
|
✅ Applied the requested follow-up changes in commit 28e69ee
Summary of ChangesF4 is fixed: the readiness evaluator now uses GitHub's spelling of the repository for every internal lookup, whatever capitalization the caller sends. A request for The fix (
Regression test (in
Other checks: core Separate issue, not changed: queued jobs and tasks are matched by exact string. Any that were created with a non-standard spelling, for example a repository name typed by a user, would still not be counted as active work. That comes from how jobs are written, not from this PR, so I left it alone. 🤖 Implementation Details
💡 ProPR Slash Commands
🤖 Generated by ProPR |
…ling of the repository for every internal lookup, whatever capitalization the caller sends. A request for `ACME/App` now gets the same review, Ultrafix and active-work gates as one for `acme/app`. F4 is fixed: the readiness evaluator now uses GitHub's spelling of the repository for every internal lookup, whatever capitalization the caller sends. A request for `ACME/App` now gets the same review, Ultrafix and active-work gates as one for `acme/app`. **The fix** (`packages/core/src/webhook/pullRequestReadiness.ts`) - The evaluator already reads the PR from GitHub first. It now takes the owner and name from that response (`base.repo.owner.login` and `base.repo.name`). These match the spelling that webhooks store, so stored rows and keys line up with it. - After that first read, every lookup uses the canonical name. That covers review scores (`repository_id`), active tasks, queued jobs, the Ultrafix state key, the head-observation key, and the non-blocking-checks config. The `repository` field in the response also uses it. - If the response has no `base.repo`, it falls back to the caller's spelling. - REST and MCP both call this evaluator, so the one change fixes both. The score loader and `readActiveTasksForPR` didn't need changes: they were right to match exactly; they were just given the wrong spelling. **Regression test** (in `packages/core/test/pullRequestReadiness.test.ts`) - The fake loaders only return data stored under `acme/app`: a review below its goal, a running task, and an active Ultrafix loop. - A request spelled `ACME/App` gets the same `ai_review`, `ultrafix` and `active_work` gates and the same `blocked` verdict as `acme/app`, and every internal read uses `acme/app`. - For a head with no CI, the check result comes from the observation stored under `acme:app`. - Against the old evaluator this test fails, as it should; with the fix all 17 readiness tests pass. **Other checks:** core `tsc` passes, and lint passes with zero warnings on the changed source file and on all of `packages/api`. The REST and MCP readiness tests pass. ESLint has no config for core test files, so it skipped the test file. **Separate issue, not changed:** queued jobs and tasks are matched by exact string. Any that were created with a non-standard spelling, for example a repository name typed by a user, would still not be counted as active work. That comes from how jobs are written, not from this PR, so I left it alone. PR: #3489 Comment by: @propr-ultrafix (ID: 0) Model: Claude Opus 5.5
|
✅ AI Code Review Complete requested by @propr-ultrafix Posted 1 review: |
🔍 AI Code Review — codex:gpt-6-astraOverall EvaluationThe PR adds a shared readiness evaluator across REST, MCP and CLI, with explicit gate statuses and documented reason codes. The supplied diff supports merge readiness within scope, conditional on the remaining validation check completing successfully. ✅ Read-only CI classification — The new reader shares classification logic with auto-merge while avoiding writes and deletes to the head-observation key. ✅ MCP authorization boundary — The tool verifies caller access before evaluating with the App identity; tests cover grant denial and differences between caller and App visibility. ✅ Conservative failure handling — Unreadable CI, scores and active work produce unknown gates instead of being treated as passing. Review was limited to static analysis of the supplied code; no commands were run. Current checks show 34 passed, none failed and one pending. Merge blockersNo merge blockers. SuggestionsThese are optional follow-ups and are not sent to S1: 🟢 Exercise default read dependenciesThe no-write test injects the observation store, active-work reader and Ultrafix-state reader. It verifies evaluator orchestration well, but does not exercise those production defaults together. An integration test observing Redis commands through the default dependency path would strengthen the read-only guarantee. This is additional coverage, not a demonstrated defect or merge requirement. ScoreThe implementation has coherent contracts, substantial targeted coverage and no verified merge blockers in the supplied diff. The remaining validation check is pending; production-default integration coverage could further strengthen confidence. Score: 8/10 🤖 Review Details
Copy and edit to choose records from this review: 🤖 Review by ProPR |
…It wasn't caused by this PR's scheduler code: the PR changes nothing under `apps/desktop` or `.github`. The fix is in the packaged-acceptance test harness. I fixed the `Validate unsigned linux-x64 package` failure. It wasn't caused by this PR's scheduler code: the PR changes nothing under `apps/desktop` or `.github`. The fix is in the packaged-acceptance test harness. **Cause.** The job failed with `Packaged acceptance observed unexpected renderer errors`, with 4 records in the `csp-reload-pairing` phase. This is a known harness race (a timing gap in the test's check, not a product bug). The `current-user` request was denied by CSP (Content Security Policy) and Chromium reported it properly. The `demo-mode` request was cut off by the policy reload before Chromium reported its denial, so all the harness had for it was a `document-replaced` record. The check that decides which errors are expected only accepted that kind of record for `current-user`. Because it rejected one record, it rejected all four. PR #3489 already fixed this exact case on 2026-11-12, but that fix is not on `main`. #3489's merge commit `7b335a5ba` is not part of `main`'s current history, and `main`'s copy of the file is identical to this branch's, without the fix. So it was lost from `main`, and this branch never got it. **Fix.** I applied #3489's change to this branch unchanged: - `apps/desktop/scripts/packaged-acceptance-csp-reload.mjs`: the `document-replaced` record can now explain a `connect-src` denial for `demo-mode` as well as `current-user`. The check stays strict otherwise: a "Fetch API cannot load" error still needs Chromium's own denial report, and every other existing limit still applies. - `apps/desktop/scripts/packaged-acceptance-csp-reload.test.mjs`: #3489's test for this exact failure, plus stricter negative checks. **Verification.** All 52 tests in `packaged-acceptance-csp-reload.test.mjs` pass, including the real-Chromium test that CI's axe-boundary job runs (`PROPR_DESKTOP_REAL_CHROMIUM_BOUNDARY=1`). I couldn't run the full packaged acceptance here, because the container has no Xvfb, packaged Electron app or gnome-keyring. The next CI run is the real check. Because the fix went missing from `main`, other PRs can hit this same linux-x64 failure until `main` gets it back. When this PR merges, it will restore the fix on `main`. There are no visual previews, since nothing a user sees has changed. PR: #3500 Comment by: @propr-dev[bot] (ID: 6853481432) Model: Claude Opus 5.5
AI Implementation Summary
Closes #3482
Branch:
3482/claude-opus-5-5-read-only-pull-request-re-20261112-1226-anvCommits: ✅ Changes committed (2a50b68)
AI Processing Completed
Execution Details:
Summary:
Issue #3482 is implemented: one read-only call returns a PR's readiness verdict plus a coded reason for every gate, through REST, MCP and the CLI. The new tests and every regression suite I ran pass, including
checkRunHandler(145/145) and theautoMerge*core suites, unchanged in behaviour.Core (
packages/core)getCiMergeReadinessnow uses a pure classifier,classifyCiMergeReadiness. A newreadCiMergeReadinessreads theauto-merge:head-observed:*key but never writes or deletes it. The merge path still records and clears that key exactly as before.evaluateAutoMergeEligibilityWithReasonreturns the eligibility plus a reason code. The oldevaluateAutoMergeEligibilityis now a thin wrapper, so its callers are untouched.readActiveTasksForPRthrows on a queue or database error, so the readiness read reportsactive_work_unavailableinstead of "idle".getActiveTasksForPRkeeps its old fail-open behaviour.evaluatePullRequestReadiness(owner, repo, number, deps)lives inwebhook/pullRequestReadiness.ts, with the per-gate logic as pure functions inpullRequestReadinessGates.ts. It runs as the GitHub App by default, and every dependency can be injected.getUltrafixLoopState.API and CLI
GET /api/pull-requests/:number/readiness?repository=owner/repois registered, documented witherrors: 'envelope', and has aPullRequestReadinesszod schema. Errors areINVALID_INPUT(400),PULL_REQUEST_NOT_FOUND(404) andGITHUB_UNAVAILABLE(502).get_pull_request_readiness(readscope,readOnly, argsrepositoryandnumber) first reads the PR with the caller's own GitHub access, asget_pull_requestdoes, then evaluates as the App.goal_reachedas a boolean or null.propr pr readiness <number> [-p owner/repo] [--json].npm run gen:openapioutput is regenerated, andgen:openapi:checkpasses.Docs:
docs/mcp.md,docs/mcp-coverage.mdand the API reference describe the verdict rule and every gate and reason code. The CLI page lists the new command, and the new doc tokens are in the allow-list inmcpObservableSurface.test.ts.Tests
goal_reached.mcpPullRequests,mcpIntegration,mcpMergePreconditions,mcpOperatorSurface,mcpDocs,mcpToolInputBudget,mcpObservableSurface,openapiRouteCoverage,openapiResponseConformance,epicMergeProgressHandlerandtaskIntentWithdrawal.Decisions to check in review
pull_request_open,not_draft,mergeable,approved/no_changes_requested,no_active_work,ultrafix_pending,ultrafix_not_requestedandauto_merge_not_requested. There are also three for unreadable data:review_state_unavailable,review_scores_unavailableandultrafix_state_unavailable. All are documented and tested.autoMergealso carries the eligibilityreason, which the issue's shape didn't include.branch_behind_basecounts as a failure.branch_protection_blockedonly waits while checks or a required review are still pending; otherwise it fails. This stops a PR whose CI is still running from showing asblocked./reviewuses the instanceultrafix_rating_goalas its goal and must have no blockers to count as reaching it.mcpPullRequestReadiness.test.ts, rather than extending the largemcpPullRequests.test.ts, and added it to thetest:mcplist inpackage.json.No visual previews: the change has no UI.
Detailed Logs:
ac7b5f07-f113-46e1-8049-c2b93c1b64faLog files stored at:
/usr/src/app/logs/executions/issue-3482-2026-11-12T13-01-32-041Z-conversation.json/usr/src/app/logs/executions/issue-3482-2026-11-12T13-01-32-041Z-output.txtLatest Conversation Messages
This PR was created automatically by ProPR after processing issue #3482.
💡 Need changes?
Comment on this PR to request refinements — the AI agent monitors comments and will update the implementation based on your feedback. Keep iterating until you're satisfied!