Fix citations: OpenAlex replaces Semantic Scholar (Phase 0+1)#49
Fix citations: OpenAlex replaces Semantic Scholar (Phase 0+1)#49
Conversation
Widens npm 'test' script to include tests/golden/*.test.ts (was an allowlist that silently skipped this directory).
There was a problem hiding this comment.
Pull request overview
This PR addresses the academic-citations 429 production issue by introducing an OpenAlex-backed academic provider and routing logic, while preserving the legacy Semantic Scholar path for explicitly configured users.
Changes:
- Added an OpenAlex provider client (
oaSearch) and registered it as an academic provider option. - Introduced
openalexMailtoconfig/env wiring and provider resolution routing foracademic → openalex. - Added unit/integration/golden tests covering OpenAlex behavior and Semantic Scholar regression baseline.
Reviewed changes
Copilot reviewed 18 out of 18 changed files in this pull request and generated 5 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/integration/academic-openalex.test.ts | Live OpenAlex integration test (skipped unless enabled via env). |
| tests/golden/academic-ss-baseline.test.ts | Golden regression test to preserve SS output shape. |
| tests/golden/academic-ss-baseline.json | Captured SS baseline fixture. |
| src/skills/academic.ts | Routes academic enrichment to OpenAlex vs Semantic Scholar based on resolved provider. |
| src/skills/academic.test.ts | Adds routing tests ensuring OpenAlex is used when configured. |
| src/providers/types.ts | Adds openalex to the provider ID union. |
| src/providers/types.test.ts | Type-level test asserting openalex is a valid ProviderId. |
| src/providers/resolve.ts | Routes academic via legacy map when openalexMailto is present. |
| src/providers/resolve.test.ts | Tests new academic routing behaviors. |
| src/providers/registry.ts | Registers OpenAlex metadata under the academic skill. |
| src/providers/registry.test.ts | Tests registry lookup for OpenAlex metadata. |
| src/providers/openalex.ts | Implements oaSearch() returning Semantic Scholar–shaped paper objects. |
| src/providers/openalex.test.ts | Unit tests for URL shaping and response mapping behavior. |
| src/config.ts | Adds openalexMailto and loads it from OPENALEX_MAILTO. |
| src/config.test.ts | Adds env-loading tests for OPENALEX_MAILTO. |
| package.json | Adds tests/golden/*.test.ts to the default test script. |
| README.md | Updates docs to describe OpenAlex and configuration. |
| .env.example | Documents OPENALEX_MAILTO. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: bfb4f37356
ℹ️ 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".
- Mirror OpenAlex entry in dashboard/src/lib/providers.ts (parity CI guard + Settings → Providers UI now offers OpenAlex for Academic Citations). - Golden fixture generation now requires UPDATE_GOLDEN=1 — missing fixture fails loudly instead of silently writing and passing. - README wording: 'recommended' instead of 'default' to match actual routing (skill is skipped without OPENALEX_MAILTO unless an explicit providers.academic is set).
Addresses PR #49 review comment: re-uses src/testing/mock-fetch.ts instead of re-implementing global fetch mocking. Also adds: - 429 rate-limit test (explicit coverage of the bug-driving scenario) - dx.doi.org DOI normalization test (regex already supported it).
Resolve README skills table conflict: keep 'disabled by default' framing from #50 for Grammar/Academic/Self-Plagiarism (matches DEFAULT_SKILLS) but update Academic engine label to OpenAlex (default) / Semantic Scholar (legacy) from #49. Bump version 1.3.0 → 1.3.1 and move CHANGELOG entry to a dated 1.3.1 section.
Summary
Fixes the production bug where users get HTTP 429 errors on every academic-citations call. Semantic Scholar's free tier is effectively unreachable from shared IPs; OpenAlex is a free drop-in replacement with the same API shape.
openalexprovider (type + client + registry)openalexMailtotoConfigresolveProviderroutesacademic → openalexwhen mailto is configuredAcademicSkilldispatches tooaSearchor legacyssSearchbased on resolverproviders.academic = semantic-scholar(legacy fallback)Test plan
bun run test— 354 pass, 0 fail, 3 skip (357 total across 57 files)OPENALEX_INTEGRATION=1 OPENALEX_MAILTO=... bun test tests/integration/academic-openalex.test.ts— 2/2 pass against live APIOPENALEX_MAILTODeployment action
Set
OPENALEX_MAILTO=sharon.spirit@gmail.comin production.envafter merge.References
🤖 Generated with Claude Code