Skip to content

Ignore cross-repository pull requests when ending a Claim - #1858

Merged
JacobStephens2 merged 3 commits into
mainfrom
issue-1857
Nov 8, 2026
Merged

JacobStephens2 merged 3 commits into
mainfrom
issue-1857

Conversation

@JacobStephens2

@JacobStephens2 JacobStephens2 commented Nov 8, 2026 •

Copy link
Copy Markdown
Owner

Summary

Claim.end
  git ls-remote refs/heads/<Issue branch>
  gh pr list --head <Issue branch> --state all --limit 1000
    --json number,isCrossRepository
  published = any row whose isCrossRepository is false
  if no Issue branch on origin and the list is full of fork rows
    leave the Claim; the list may hide a same-repository pull request
  if no Issue branch on origin and not published
    put the labels back as they were before the Claim

A fork pull request can reuse the Issue branch name. Claim ending counted every listed row as this repository's pull request, so a Ticket run that published nothing left the issue in-progress. A row counts only when isCrossRepository is false. gh pr list returns 30 rows unless --limit is set, so the list asks for 1000, the same bound Delivery already uses. A shorter page of fork rows cannot hide a later same-repository pull request. A full page does not prove this repository has none, so Claim ending leaves the Claim in place.

Seam: Ticket run Claim ending, observed as the issue's labels after a session that publishes nothing.

Evidence

Execution evidence

  • Before: bun test tests/ticket.test.ts -t "Claim ending counts" from prototypes/typescript, on the unfiltered Claim.end that asked gh pr list for number only.
Expected to contain: "isCrossRepository"
Received: [ "number" ]
✗ Claim ending counts a pull request only when it is in this repository (fork: true)
✗ Claim ending counts a pull request only when it is in this repository (fork: false)
2 fail

The page-limit tests, run before --limit 1000, failed the same way the review described. gh pr list --help reports -L, --limit default 30.

-     "name": "in-progress",
+     "name": "ready-for-agent",
✗ a same-repository pull request past gh's default page still keeps the Claim
✗ Claim ending still counts a same-repository pull request after a default page of fork pull requests
2 fail

After: bun test tests/ticket.test.ts -t "Claim ending counts|same-repository pull request|nothing on origin" from prototypes/typescript.

✓ a session with no commits fails Delivery and releases its Claim with nothing on origin
✓ Claim ending counts a pull request only when it is in this repository (fork: true)
✓ Claim ending counts a pull request only when it is in this repository (fork: false)
✓ a same-repository pull request past gh's default page still keeps the Claim
✓ Claim ending still counts a same-repository pull request after a default page of fork pull requests
5 pass

A full page of fork rows, with a same-repository pull request past --limit, released the Claim. After the guard, bun test tests/ticket.test.ts -t "past the list limit|Claim ending counts|same-repository pull request|nothing on origin" passed, including a same-repository pull request past the list limit still keeps the Claim. bun test tests/ticket.test.ts passed: 51 tests, 0 fail. bun run typecheck (tsc --noEmit) passed. The earlier full bun test from prototypes/typescript passed: 61 tests, 0 fail.

Visual evidence

This change does not touch rendered UI, HTML, CSS, templates, or visual layout. No browser captures.

Merge Danger

Door: two-way

The TypeScript prototype is not the Rust executable. Reverting this branch restores the previous Claim ending.

Blast Radius: prototype Claim ending

A Ticket run in this prototype that publishes nothing releases its Claim when the only pull requests for the Issue branch are from a fork and that list is not full. A same-repository pull request, including one past gh's default page of 30, still keeps the Claim. A full page of fork rows keeps it too. The Rust Claim ending already filters isCrossRepository in pull_requests_with_head_prefix.

Unaddressed findings

Standards

  • Duplicated Code (judgement call), part of finding 2. Claim.end and Delivery.findPR both list pull requests and skip rows whose isCrossRepository is true. Extracting one helper was not done. Claim.end (prototypes/typescript/src/claim.ts) only needs whether any row has isCrossRepository === false, then restores labels in the existing empty-list block. findPR (prototypes/typescript/src/delivery.ts) collects numbers, rejects more than one with "Ambiguous pull request for Issue branch", and views that pull request, with the error "Invalid pull request number". Those are different decisions. The behaviour the finding's test showed, a default page of fork rows hiding a same-repository pull request, is fixed by --limit 1000 on Claim ending's gh pr list. That test passes: bun test tests/ticket.test.ts -t "default page of fork pull requests".

Spec

None.

Security

None.

The review read every changed file: prototypes/typescript/README.md, prototypes/typescript/src/claim.ts, and prototypes/typescript/tests/ticket.test.ts. No changed file was left unread.

Closes #1857

Built with grok grok 1.0.70 (f50904eaee6c) [stable] · default model · default effort

Security review outcome

No unaddressed introduced findings.

A fork pull request can reuse the Issue branch name. The TypeScript prototype's Claim ending treated any listed pull request with that name as this repository's work, so a run that published nothing left the issue in-progress. Count a row only when isCrossRepository is false.
gh pr list returns 30 rows unless --limit is set. A page of fork pull requests hid a later same-repository pull request, so Claim ending released the Claim. Ask for 1000 rows, as Delivery already does.
…request

gh pr list stops at --limit and does not say whether more rows exist. Claim ending treated a full page of fork pull requests as proof that this repository had none, and released the Claim while a same-repository pull request could sit past that page. A full page now fails the ending and leaves the Claim in place.
@JacobStephens2
JacobStephens2 merged commit ef1367c into main Nov 8, 2026
4 checks passed
@JacobStephens2
JacobStephens2 deleted the issue-1857 branch November 8, 2026 10:17
@JacobStephens2 JacobStephens2 mentioned this pull request Nov 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Ignore cross-repository pull requests when ending a Claim

1 participant