🐛 Fix pr-review mispair after issue transfer (closes #105)#109
Merged
Conversation
Two defects in `_find_linked_pr_number` caused `askcc pr-review` to repeatedly
post on the wrong PR after an issue was transferred between repositories:
- The body fallback used Python `in` for `#{N}`, so `#5` matched `#52`.
- No awareness of the GitHub Timeline `transferred_event`, so the real
fix-PR (referencing the pre-transfer coordinates) was never recovered.
Changes:
- Replace substring body checks with `CLOSE_KEYWORD_RE` — a word-boundary
regex that requires an explicit close keyword
(Closes/Fixes/Resolves and inflections) followed by `#N` or
`owner/repo#N`.
- Add `_resolve_transferred_predecessors` — queries the issue timeline
and returns prior `(owner, repo, number)` coordinates so PRs filed
against the pre-transfer issue can still be paired after transfer.
Errors are logged and yield an empty list, never raised.
- Drop the unconditional substring fallback. A PR is returned only on
a positive match (branch convention, close keyword, or `/issues/N`
with a digit boundary). `fetch_pr_content` already treats `None` as
"no link" and aborts the run.
- Sync `handle-github-issue/SKILL.md` PR-lookup prose with the new
rules (word boundaries, close keyword preference, timeline lookup).
- Six new tests covering the regression, substring collisions, the
word-boundary positive path, transfer-aware branch + body matches,
and the timeline parser's happy/empty/error paths.
Closed
8 tasks
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
_find_linked_pr_numberused a Pythoninsubstring check on the PR body.f"#{5}" in "Closes weyucou/task-management#52"isTrue, so issue Add explore and diagnose commands #5 was paired with the wrong PR — daily cron then re-posted the same misplaced review 7 times.transferred_event, so the real fix-PR (branchchore/25-yaml-event-schema-v1, bodyCloses weyucou/task-management#25) referenced only the pre-transfer coordinates and was never recoverable.Changes
CLOSE_KEYWORD_RE— a word-boundary regex that requires an explicitCloses/Fixes/Resolves(and inflections) keyword followed by#Norowner/repo#N._resolve_transferred_predecessors(askcc/functions.py) — queriesgh api repos/{owner}/{repo}/issues/{N}/timeline, extractstransferredevents, and returns[(prior_owner, prior_repo, prior_number), …]. All errors are logged and yield[], never raised./issues/Nfallback retains a digit boundary.fetch_pr_contentalready treatsNoneas "no link" and aborts the run (so cron becomes a no-op when matching is ambiguous).askcc/skills/handle-github-issue/SKILL.mdPR-lookup prose with the new rules.Tests
Six new tests in
tests/test_askcc.py:Closes weyucou/task-management#52does not pair withissue_number=5.#51/#500againstissue_number=5.Fixes #5pairs withissue_number=5.(weyucou, task-management, 25)+ branchchore/25-yaml-event-schema-v1pairs with currentissue_number=5.Closes weyucou/task-management#25pairs with currentissue_number=5._resolve_transferred_predecessorsparses one synthetic event, returns[]on a clean timeline, returns[](with a logged warning) onghand bad-JSON errors.Plus
_make_pr_responsesinTestFetchPrContentnow includes the additional timeline response.Out of scope
Mitigation #3 — per-PR dedup on the review-comment side (
(action, repo, target_number)key) — is enforced by the cron caller, not askcc. Flagged in the issue summary so the cron operator can coordinate that defense-in-depth layer. With this fix, askcc itself becomes a no-op when no PR is positively matched, which removes the source of the repeat posts.Test plan
uv run poe checkpasses.uv run poe testpasses — 265 tests, including the 6 new ones.askcc pr-reviewagainstweyucou/issue-tracker#5and confirm no comment is posted to PR#6.