Skip to content

[Refactor] Move external issue-link parsing onto a provider registry#718

Merged
daniel-lxs merged 1 commit into
developfrom
feature/external-issue-provider-registry
Jul 23, 2026
Merged

[Refactor] Move external issue-link parsing onto a provider registry#718
daniel-lxs merged 1 commit into
developfrom
feature/external-issue-provider-registry

Conversation

@daniel-lxs

Copy link
Copy Markdown
Member

What changed

Follow-up to #693 / #716. parseExternalIssueReferences hardcoded the GitHub and Linear URL shapes, and fetchExternalIssueContext hardcoded each provider's MCP call sequence. Both now read from a declarative registry — new external-issue-providers.ts — where each provider states:

  • the hostnames it owns (github.com, linear.app),
  • the pathname pattern that identifies one of its issues (named capture groups),
  • how a match becomes ordered MCP fetch attempts ({serverId, toolName, args}[]), preserving GitHub's issue_readget_issue fallback chain.

fetchExternalIssueContext walks 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.ts allowlist. Note the serverId field is typed as RouterMcpServerId, 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

  • New 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.
  • Existing external-issue-context.test.ts and router-service.test.ts untouched and green — 13 files, 98 tests passing; pnpm knip clean; tsc --noEmit clean.

🤖 Generated with Claude Code

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>
@roomote-roomote

roomote-roomote Bot commented Jul 23, 2026

Copy link
Copy Markdown
Contributor

No code issues found. See task

Reviewed 0eafda7

@daniel-lxs
daniel-lxs merged commit 3359e0e into develop Jul 23, 2026
16 checks passed
@daniel-lxs
daniel-lxs deleted the feature/external-issue-provider-registry branch July 23, 2026 16:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant