Skip to content

fix(miner): bring extractLinkedIssueNumbers to parity with the host's code-span and URL handling - #7560

Closed
shin-core wants to merge 1 commit into
JSONbored:mainfrom
shin-core:fix/miner-extract-linked-issues-parity-7527-v2
Closed

fix(miner): bring extractLinkedIssueNumbers to parity with the host's code-span and URL handling#7560
shin-core wants to merge 1 commit into
JSONbored:mainfrom
shin-core:fix/miner-extract-linked-issues-parity-7527-v2

Conversation

@shin-core

Copy link
Copy Markdown
Contributor

What

extractLinkedIssueNumbers (miner self-review context) is a port of the host's extractLinkedIssueNumbersWithOverflow (src/db/repositories.ts). It had drifted from the host in two ways this PR fixes:

  1. Code-span exclusion was a string replace, not a byte-range skip. body.replace(/[^]*/g, "")*deletes* a span's characters, which can pull a bare#Nup against a preceding closing keyword that was **not** adjacent in the original text — e.g.Fixes `x` chore(deps): bump the npm-minor-and-patch group with 7 updates #45collapses toFixes chore(deps): bump the npm-minor-and-patch group with 7 updates #45 and spuriously links **#45**. The fix matches code-span byte ranges and skips any keyword hit overlapping one, preserving the original keyword→#N` adjacency the regex depends on.
  2. The full issue-URL closing form was unrecognized. GitHub's own linker also closes an issue referenced as Closes https://github.com/owner/repo/issues/N (a common paste from the browser address bar). The old regex required a literal #, so that form produced zero linked issues and could trip the "no linked issue" hard rule on a PR that genuinely had one. The regex now recognizes the URL form (http/https, optional www.) alongside the qualified owner/repo#N and bare #N forms.

Both the qualified and URL forms count only when owner/repo case-insensitively matches the repo being fetched; a reference to a different repo never spoofs a same-repo link. This mirrors the host exactly (match.groups!, owner && owner.toLowerCase() !== target, Number(...) + Number.isInteger && > 0).

Tests (regression + branch coverage)

Six REGRESSION (#7527) cases via the existing fetchSelfReviewContext + routedFetch/prPayload harness:

  • code-span-separated keyword (Fixes \x` chore(deps): bump the npm-minor-and-patch group with 7 updates #45) → **not** linked ([]) — **proven** to fail under the old string-replace ([45]`).
  • a real keyword elsewhere still links even when an unrelated code span is present → [7].
  • full issue-URL form (http + www.) same-repo → [88, 89].
  • full-URL form pointing at a different repo → [].
  • bare #N + qualified same-repo + qualified different-repo → [3, 4].
  • Closes #0 → rejected by the number > 0 guard, only #6 survives → [6] (covers that guard's false branch — proven to fail if > 0 is dropped).

Validation

  • npm run typecheck — exit 0 after a fresh @loopover/engine build.
  • test/unit/miner-self-review-context.test.ts — 44/44 pass.
  • npm run test:miner-pack passes; git diff --check clean. Generated .js/.d.ts regenerated by the miner build.

Closes #7527

… code-span and URL handling

extractLinkedIssueNumbers stripped inline code spans with a string replace
before matching, which could pull a bare #N up against a preceding closing
keyword that was not adjacent in the original text (e.g. "Fixes `x` JSONbored#45" ->
"Fixes  JSONbored#45"), spuriously linking JSONbored#45. It also missed GitHub's full issue-URL
closing form, so a contributor pasting the browser URL produced zero linked
issues and could trip the no-linked-issue hard rule on a PR that genuinely
had one.

Match the host's extractLinkedIssueNumbersWithOverflow: exclude code spans by
byte range (preserving the original keyword/#N adjacency the regex depends on)
and recognize the `https://github.com/owner/repo/issues/N` form alongside the
qualified and bare forms, counting the qualified and URL forms only when they
target this repo.

Closes JSONbored#7527
@shin-core
shin-core requested a review from JSONbored as a code owner July 20, 2026 22:05
@superagent-security superagent-security Bot added the contributor:flagged Contributor flagged for review by trust analysis. label Jul 20, 2026
@superagent-security

Copy link
Copy Markdown
Contributor

🚨 Contributor flagged. Click here for more info: Superagent Dashboard

@superagent-security

Copy link
Copy Markdown
Contributor

Superagent didn't find any vulnerabilities or security issues in this PR.

@JSONbored JSONbored left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Merge conflicts/issue already resolved.

This branch has conflicts that must be resolved
Use the [web editor](https://github.com/JSONbored/loopover/pull/7560/conflicts) or the command line to resolve conflicts before continuing.

packages/loopover-miner/lib/self-review-context.js
packages/loopover-miner/lib/self-review-context.ts

@JSONbored JSONbored closed this Jul 20, 2026
@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

contributor:flagged Contributor flagged for review by trust analysis. gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(miner): bring extractLinkedIssueNumbers to parity with the host's byte-range code-span exclusion and full-URL closing form

2 participants