Skip to content

fix(mcp): align linked-issue extraction with server after #4039 - #4057

Closed
RealDiligent wants to merge 1 commit into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-mcp-linked-issue-extractor-parity
Closed

fix(mcp): align linked-issue extraction with server after #4039#4057
RealDiligent wants to merge 1 commit into
JSONbored:mainfrom
RealDiligent:fix/critical-issue-mcp-linked-issue-extractor-parity

Conversation

@RealDiligent

Copy link
Copy Markdown
Contributor

Summary

Ports the canonical server-side linked-issue extractor from repositories.ts (#4039 inline code-span stripping + #3862 qualified owner/repo#N scoping) into:

  • packages/gittensory-mcp/lib/local-branch.js extractLinkedIssues(text, repoFullName)
  • packages/gittensory-engine/src/signals/predicted-gate-engine.ts extractLinkedIssueNumbers

Root cause

The MCP local-branch analyzer and predicted-gate engine still scanned raw PR body text. This repo's own PR template checklist contains (e.g. Closes #123), so every local branch analysis that keeps that line spuriously reports linkedIssues: [123]. Those values are POSTed to /v1/local/branch-analysis and merged server-side, corrupting predicted-gate verdicts and collision signals.

Fix

Mirror extractLinkedIssueNumbersWithOverflow logic: strip inline code spans before scanning, honor qualified refs only when owner/repo matches, dedupe, pass repoFullName from collectLocalBranchMetadata.

Impact

Local MCP users and miners running gate prediction no longer get false linked-issue matches from template boilerplate; predictedGate aligns with server preflight.

Tracking issue (needed before merge)

No contributor-eligible upstream issue exists yet (maintainer #4039 merged without one; CreateIssue denied for external contributors). Fork tracking: RealDiligent#4. Please create/associate a gittensor:bug upstream issue so this PR can add Closes #… per CONTRIBUTING.

Supersedes closed #4054 (rebased onto latest main, squashed, codecov tests expanded).

Test plan

  • npm run typecheck
  • npm run build:mcp
  • npx vitest run test/unit/local-branch.test.ts test/unit/predicted-gate-engine-branch-coverage.test.ts test/unit/db-parsers.test.ts (107/107)

@RealDiligent
RealDiligent requested a review from JSONbored as a code owner July 7, 2026 18:27
@superagent-security

Copy link
Copy Markdown
Contributor

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

@loopover-orb loopover-orb Bot added the gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier. label Jul 7, 2026
@loopover-orb

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Caution

🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥🟥

🛑 Gittensory review result - reject/close recommended

Review updated: 2026-07-07 18:32:11 UTC

4 files · 1 AI reviewer · 2 blockers · readiness 100/100 · CI pending · blocked

🛑 Suggested Action - Reject/Close

  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
  • AI reviewers agree on a likely critical defect: Per this repo's contribution policy, an external contributor PR must close or clearly link an eligible upstream issue, and the description itself states no such issue exists yet (only a fork-tracked issue at fix(mcp): port #4039 linked-issue extractor parity to MCP + predicted-gate RealDiligent/gittensory#4, which isn't in this repo) — this needs a real `gittensor:bug` issue linked before merge. — Resolve the flagged defect, or override if the AI reviewers are mistaken, then re-run the gate.

Review summary
This ports the server-side extractLinkedIssueNumbersWithOverflow logic (inline code-span stripping + qualified owner/repo#N scoping) into both the MCP local-branch.js extractor and the engine's predicted-gate-engine.ts extractor, fixing a real false-positive where this repo's own PR template line `(e.g. \`Closes #123\`)` was being parsed as a linked issue #123. The regex and dedup logic in both files are now identical and correctly gate qualified refs on a case-insensitive repoFullName match, and the added tests (template-boilerplate stripping, cross-repo qualified refs, dedup) exercise the real fix rather than a fabricated scenario. One unannounced behavior change: the client extractor previously allowed a closing keyword without a literal `#` (e.g. `Closes 12`), and the new regex now mandates `#` after every keyword — likely correct for true server alignment, but not called out in the description.

Blockers

Nits — 5 non-blocking
  • The new regex in both local-branch.js and predicted-gate-engine.ts now requires a literal `#` after the closing keyword, dropping the previously-supported hash-optional form (`Closes 12`) that the old code and its removed comment explicitly called out as intentional client-side behavior — worth a one-line note in the description confirming this is an intended alignment change, not a side effect.
  • Confirm `repoFullName` is actually in scope at the `collectLocalBranchMetadata` call site in local-branch.js:59 (the diff hunk references it but the variable's origin isn't shown) — if it's undefined there, qualified-ref scoping silently degenerates to `owner: undefined` comparisons.
  • The description says this mirrors `extractLinkedIssueNumbersWithOverflow`, but the ported code doesn't show any overflow/oversized-number guard implied by that name (e.g. rejecting a huge digit string as a fake issue number) — worth confirming the server function's overflow behavior is actually replicated here, since `repositories.ts` isn't included in the visible diff.
  • Add a short changelog/description note explicitly calling out the hash-now-required behavior change so reviewers aren't left inferring it from the diff.
  • Since both extractors now share byte-for-byte identical regex/dedup logic, consider factoring the shared implementation into one exported helper (e.g. in a small shared util) that both packages import, to avoid this exact drift happening again next time either side changes independently.

Why this is blocked

  • Per this repo's contribution policy, an external contributor PR must close or clearly link an eligible upstream issue, and the description itself states no such issue exists yet (only a fork-tracked issue at fix(mcp): port #4039 linked-issue extractor parity to MCP + predicted-gate RealDiligent/gittensory#4, which isn't in this repo) — this needs a real `gittensor:bug` issue linked before merge.
  • No linked issue detected — If this PR is intended to solve an issue, link it explicitly in the PR body.
Signal Result Evidence
Code review ❌ 2 blockers 1 reviewer
Linked issue ✅ Linked #123, #4054
Related work ✅ No active overlap found No same-issue or scoped active PR overlap found.
Change scope ✅ 20/20 Low review scope from cached public metadata (2 linked issues).
Validation posture ✅ 25/25 PR body includes validation/test evidence.
Contributor workload ✅ 10/10 Author activity: 266 registered-repo PR(s), 81 merged, 0 issue(s).
Contributor context ✅ Confirmed Gittensor contributor RealDiligent; Gittensor profile; 266 PR(s), 0 issue(s).
Gate result ❌ Blocking Repo-configured hard blocker found.
Review context
  • Author: RealDiligent
  • Role context: outside_contributor
  • Public audience mode: oss maintainer
  • Lane context: Repository is configured for direct PR review.
  • Public profile languages: JavaScript, Ruby, Svelte, TypeScript, Cuda, Markdown
  • Official Gittensor activity: 266 PR(s), 0 issue(s).
  • PR-specific overlap: none found.
Contributor next steps
  • Keep the PR focused and include validation evidence before maintainer review.
Signal definitions
  • Related work = same linked issue, overlapping active PRs, or title/path similarity.
  • Change scope = cached public metadata such as size labels, draft state, and review-burden hints.
  • Validation posture = whether the PR provides enough public validation/test evidence for maintainer review.
  • Contributor workload = public contributor activity and cleanup pressure, not a repo-wide quality failure.
  • Contributor context = public GitHub/Gittensor identity context; non-Gittensor status is not a blocker.

🟩 Safe / merged · 🟦 Advisory · 🟨 Held for review · 🟥 Blocked / closed


💰 Earn for open-source contributions like this. Gittensor lets GitHub contributors earn for the work they already do — register to start earning →.

Checked by Gittensory, a quiet PR intelligence layer for OSS maintainers.

  • Re-run Gittensory review

Port inline code-span stripping and qualified owner/repo#N scoping from
repositories.ts (JSONbored#4039/JSONbored#3862) into the MCP local-branch mirror and the
predicted-gate engine so template checklist text does not spuriously link
issue JSONbored#123 and branch-analysis gate predictions match server preflight.

Co-authored-by: Cursor <cursoragent@cursor.com>
@loopover-orb

loopover-orb Bot commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Gittensory is closing this pull request on the maintainer's behalf (No linked issue detected; AI reviewers agree on a likely critical defect: Per this repo's contribution policy, an external contributor PR must close or clearly link an eligible upstream issue, and the description itself states no such issue exists yet (only a fork-tracked issue at RealDiligent#4, which isn't in this repo) — this needs a real `gittensor:bug` issue linked before merge.; duplicate of another open PR). This is an automated maintenance action — to pursue this change, please open a new pull request with the issues resolved. Closed PRs may be analyzed later to improve review accuracy, but they are not automatically reopened or re-reviewed.

@loopover-orb loopover-orb Bot closed this Jul 7, 2026
@codecov

codecov Bot commented Jul 7, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 93.59%. Comparing base (0d1af9a) to head (4d25168).

Additional details and impacted files
@@           Coverage Diff           @@
##             main    #4057   +/-   ##
=======================================
  Coverage   93.59%   93.59%           
=======================================
  Files         379      379           
  Lines       35584    35591    +7     
  Branches    13050    13051    +1     
=======================================
+ Hits        33304    33311    +7     
  Misses       1618     1618           
  Partials      662      662           
Files with missing lines Coverage Δ
...ensory-engine/src/signals/predicted-gate-engine.ts 100.00% <100.00%> (ø)
🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@RealDiligent

Copy link
Copy Markdown
Contributor Author

CI is fully green on the rebased squashed commit (validate-code pass, codecov/patch 100%). Fix is ready to merge once a contributor-eligible upstream tracking issue exists — please create a \gittensor:bug\ issue and reopen with \Closes #…, or manually associate this PR. Fork tracking: RealDiligent#4.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

gittensor:bug Gittensor-scored bug fix — scores a 0.05x multiplier.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant