Repository navigation
fix(ci): verify a queue-guard overlap hit actually cites the issue (#610) - #612
Conversation
) The overlap job reported any open PR whose text merely contained the digits of a cited issue number. Today it told #608 that #271 "also cites #607"; #271 is an fsync change opened five days before #607 existed, and its only occurrence of those digits is a benchmark figure — 6,607 appends/s. The extraction is not at fault: `/#\d+/g` yields `#607` correctly. The search query is. GitHub's tokenizer does not treat `#` as part of a word, so `"#607" in:title,body` is really a query for the token `607`. Confirmed against the live API — searching `"#607"` and `"607"` return the identical single result. `6,607` tokenizes on the comma, so the digits match exactly. Nothing re-checked the hit, so the search was both the prefilter and the verdict. It stays the prefilter — the API offers nothing more precise — and every hit is now confirmed against the title and body the response already carries, which costs no extra request. A literal `#N`, or an `issues/N` / `pull/N` URL tail, and not the prefix of a longer number so `#607` cannot answer for `#6071`. This matters more than one bad comment: PR bodies here routinely carry byte counts, timings and throughput numbers, so the false positive is the common case. A guard that fires on arithmetic trains reviewers to ignore it, and it then fails quietly on the collision it exists to catch. It also publicly mislabels the PR it names.
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
|
Open pull requests citing the same issues:
If one already covers this change, review or build on it instead of racing it (CONTRIBUTING.md "Overlapping work"). |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: df31a835cb
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| const n = ref.slice(1); | ||
| // '#N' or an issues/N | pull/N URL tail, and not the prefix of a longer | ||
| // number: #607 must not answer for #6071. | ||
| const rx = new RegExp('(#|(?:issues|pull)\\/)' + n + '(?!\\d)'); |
There was a problem hiding this comment.
Recognize GH-N issue references
When a newly opened PR cites #607 but an existing open PR uses GitHub’s supported GH-607 shorthand for the same issue, the search prefilter returns the existing PR but this regex rejects it, silently hiding a genuine overlap that the previous implementation reported. Accept the GH- prefix as another literal reference form.
AGENTS.md reference: AGENTS.md:L30-L31
Useful? React with 👍 / 👎.
Closes #610. Verified against
9da8f42.queue-guard's
overlapjob reported any open PR whose text merely contained the digits of acited issue number. It fired for real today, on the PR before this one.
The bug
#608 cites
#607. queue-guard commented that #271 "also cites #607". #271 isfix(store): fsync room directory entries, opened five days before #607 existed. Its onlyoccurrence of those digits:
Root cause — it is the query, not the extraction
/#\d+/gextracts#607correctly. The defect is the line after it:GitHub's search tokenizer does not treat
#as part of a word, so"#607"is searched as thebare token
607. Confirmed against the live API — the two queries are indistinguishable:6,607tokenizes on the comma, so607matches exactly. And nothing downstream re-checked thehit — the search was serving as both prefilter and verdict.
The fix
The search stays the prefilter; the API offers nothing more precise. What changes is that every
hit is now confirmed against the
titleandbodythe search response already returns — sono extra request, no added rate-limit cost:
A literal
#N, or anissues/N/pull/NURL tail, and not the prefix of a longer number so#607cannot answer for#6071. That puts the split in the right place: the API decides what ischeap to fetch, this workflow decides what is true.
Why it is worth fixing rather than tolerating
PR bodies in this repo routinely carry measurements — appends/s, byte counts, millisecond
timings, module counts. Every one is a chance to name an unrelated PR as overlapping work, so the
false positive is the common case, not a corner. A guard that fires on arithmetic teaches
reviewers to skip it, and it then fails quietly on the real collision it exists to catch. It also
publicly mislabels the innocent PR: #271 currently carries a comment implying it duplicates work
it has nothing to do with.
This PR demonstrates the bug on itself
queue-guard ran against this PR using the code on
main, and reported four overlaps:Three are spurious. Running the new
cites()filter over the real bodies:mcp.technocore…" — a real reference66,608 lines held, 7.8 M…66,608 lines6,607 appends/sThe #611 row is the important one: it is a genuine citation and the filter keeps it. This is a
precision fix, not a blanket mute.
End-to-end, against the live API
Replaying the whole job — real search calls for
#608and#607, then the new filter — on thisPR's own refs:
One genuine overlap survives; the three arithmetic matches are gone.
On the "no extra request" claim
Worth stating because the fix depends on it: the filter reads
item.bodyfrom the searchresponse, so it would be a false-negative machine if that field were truncated — a real
citation late in a long body would be dropped, which is the one failure this guard cannot afford.
Checked rather than assumed. Search-API bodies are byte-identical to the pulls API:
pullsNo truncation, including the 12.7 KB body — so the check is complete and genuinely free.
A contributor already diagnosed this by hand
The bug is not new, and it is already costing people time. #108 —
fix(http): validate a name before consulting its class— carries an "Overlapping work" section written to defend againstexactly this:
An independent contributor reached the same root cause unaided, then spent a paragraph proving a
negative to a reviewer. That is the cost this guard is currently imposing — and it lands on the
people doing the most careful queue triage, since they are the ones who check.
Verification
The workflow is not reachable from
pytest, so it was checked directly. Thecitesfunction wasextracted verbatim from the committed YAML and run against the real bodies of #271 and #608
plus twelve synthetic cases — all 14 pass:
6,607 appends/s)Closes #607)607bare /6,607/18,607 KiB/v1.607#607/see #607/Closes #607./ title-only#6071(longer number)issues/607,pull/607Also confirmed: the file still parses as YAML with both jobs intact, and both embedded scripts
pass
node --check. Theprotected-filesjob is untouched.Repo gates, all clean:
Note
I did not add a regression test. There is no harness in
tests/for workflow YAML, and buildingone for a single embedded function looked like more surface than the fix. If you would rather have
one — say a
tests/unit/test_queue_guard.pythat extracts the script from the YAML and exercisesthe regex through
node— I am happy to add it.Not addressed here
Post-filtering can only remove hits, so a genuine overlap that the fuzzy search pushed past
per_page: 10is still missed. That is pre-existing and unchanged by this PR; precision improves,recall does not. Worth a separate look if it ever bites.
Suggested release note