poteto-mode watch-pr: PRs that are BLOCKED, BEHIND, UNKNOWN or REVIEW_REQUIRED come back as ready with mergeability "clear"

Open Beginner friendly
#1,053 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 1 day

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
85/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Active
Tech stack
github, typescript
Domain
tooling

Research direction

Start in scripts/watch-pr/policy.ts: read assessGitHubMerge at line 12, gateReason at line 167 and readyContribution at line 203, then run policy.test.ts (line 42 encodes current behavior). Use watch-pr/fakes.test-helper.ts to reproduce the BLOCKED/BEHIND/UNKNOWN/REVIEW_REQUIRED cases. Done means the truth-table tests expect a gate or waiting outcome for those states and mergeability: "clear" is no longer returned for them.

Written by the indexing model from the issue text.

Description

Found against pstack 0.15.34 at cursor/plugins 519d36aa98955bf680db01bcde5fdfba686dc901 (harness/pstack/claude-code/skills/poteto-mode/). Line numbers refer to that commit.

scripts/watch-pr/policy.ts decides readiness from CI and review threads, but not from GitHub's merge state or the
required review:

  • assessGitHubMerge (policy.ts:12): when mergeStateStatus is BLOCKED, the only refusal is a head rollup of
    ERROR or FAILURE. A SUCCESS rollup returns kind: "allowed", basis: "rollup". BEHIND, UNKNOWN and every
    other state fall through to allowed, basis: "merge-state" (:26).
  • gateReason (:167) turns only CHANGES_REQUESTED into a gate. REVIEW_REQUIRED is not a gate.
  • readyContribution (:203) then returns kind: "ready-pr" with proof.mergeability: "clear".

GitHub documents BLOCKED as "the merge is blocked" and REVIEW_REQUIRED as "a review is required before the pull
request can be merged" (schema,
review decision). This also contradicts
playbooks/babysit.md:12, which requires the forge to agree that the PR can merge. GitHub still enforces its own rules,
but the watcher reports false readiness, so a babysit, shipping or autopilot run tells the user that a PR is mergeable
when it isn't.

Repro: call readSnapshot then classifyPr with the shipped fake reader (watch-pr/fakes.test-helper.ts), using
passing CI, rollup SUCCESS, no threads, reviewDecision: "REVIEW_REQUIRED", and each merge state:

mergeStateStatus BLOCKED -> kind: ready, mergeability: clear
mergeStateStatus BEHIND  -> kind: ready, mergeability: clear
mergeStateStatus UNKNOWN -> kind: ready, mergeability: clear

The 18 existing tests in policy.test.ts pass. policy.test.ts:42 asserts the current behavior.

Suggested fix:

  • Make an outstanding required review (REVIEW_REQUIRED) and a BLOCKED merge state into merge gates (merge-gate
    blockers with their own reasons), whatever the rollup says.
  • Treat UNKNOWN (GitHub is still computing it) as waiting, not ready. Treat BEHIND as a gate, or as waiting when the
    repo doesn't require branches to be up to date.
  • Never emit mergeability: "clear" unless mergeStateStatus is CLEAN (or HAS_HOOKS / UNSTABLE, if those are
    deliberately accepted).
  • Update the truth-table tests to assert gate or waiting outcomes for each of these states.
Dominant language
TypeScript
Stars
18.2k
Forks
2k
Avg merge
3h 56m
Merged PRs (30d)
96

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from cursor/plugins

All issues in cursor/plugins

Similar issues

More TypeScript issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.