[Refactor] Move external issue-link parsing onto a provider registry#718
Merged
Merged
Conversation
parseExternalIssueReferences hardcoded the GitHub and Linear URL shapes and fetchExternalIssueContext hardcoded each provider's MCP call sequence. Both now read from a declarative registry (external-issue-providers.ts): each provider states its hostnames, the pathname pattern that identifies one of its issues, and the ordered MCP fetch attempts a match produces (preserving GitHub's issue_read -> get_issue fallback chain). Adding SCM support becomes one registry entry alongside the MCP server itself and its mcp-policy allowlist. Pure internal refactor: URL extraction, the 2-issue and 8k-char caps, the shared 8s fail-open deadline, the untrusted-context output format, and the model-never-picks-fetch-targets boundary are all unchanged. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
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.
What changed
Follow-up to #693 / #716.
parseExternalIssueReferenceshardcoded the GitHub and Linear URL shapes, andfetchExternalIssueContexthardcoded each provider's MCP call sequence. Both now read from a declarative registry — newexternal-issue-providers.ts— where each provider states:github.com,linear.app),{serverId, toolName, args}[]), preserving GitHub'sissue_read→get_issuefallback chain.fetchExternalIssueContextwalks the attempts generically under the existing shared 8-second fail-open deadline.What did not change
Pure internal refactor — no behavior change. URL extraction from message text,
MAX_EXTERNAL_ISSUES=2,MAX_EXTERNAL_CONTEXT_CHARS=8000, the[EXTERNAL ISSUE CONTEXT - UNTRUSTED REFERENCE MATERIAL]format, all fail-open semantics, and the design boundary that the model never chooses fetch targets or arguments (parsing and fetching stay in deterministic server code).Why
Adding SCM support (GitLab, Bitbucket, Azure DevOps) previously meant editing parser internals. Now it's one registry entry next to the MCP server integration and its
mcp-policy.tsallowlist. Note theserverIdfield is typed asRouterMcpServerId, so the type system forces a new provider to also register its MCP server and policy — the registry can't silently point at an unregistered backend. No real new provider is added here; the extensibility is proven by a fake GitLab entry in the new test.Tests
external-issue-providers.test.ts: GitHub mapping incl. fallback chain, Linear mapping, unclaimed-URL rejection (PR links, unknown hosts), and a single-entry fake GitLab provider.external-issue-context.test.tsandrouter-service.test.tsuntouched and green — 13 files, 98 tests passing;pnpm knipclean;tsc --noEmitclean.🤖 Generated with Claude Code