Skip to content

Fix citations: OpenAlex replaces Semantic Scholar (Phase 0+1)#49

Merged
sharonds merged 11 commits intomainfrom
feat/plan3-phase-0-1-openalex-swap
Apr 22, 2026
Merged

Fix citations: OpenAlex replaces Semantic Scholar (Phase 0+1)#49
sharonds merged 11 commits intomainfrom
feat/plan3-phase-0-1-openalex-swap

Conversation

@sharonds
Copy link
Copy Markdown
Owner

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.

  • Adds openalex provider (type + client + registry)
  • Adds openalexMailto to Config
  • resolveProvider routes academic → openalex when mailto is configured
  • AcademicSkill dispatches to oaSearch or legacy ssSearch based on resolver
  • Preserves SS path for users with explicit providers.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 API
  • Golden-file test confirms SS-path behavior unchanged for users without OPENALEX_MAILTO
  • Dashboard tests: 88/88 pass

Deployment action

Set OPENALEX_MAILTO=sharon.spirit@gmail.com in production .env after merge.

References

  • Plan: `poc-replacement/plans/2026-04-22-phase-0-1-openalex-swap.md`
  • POC data: `poc-replacement/03-academic-citations/RESULTS.md`
  • Decision rationale: `poc-replacement/DECISION-MATRIX.md`

🤖 Generated with Claude Code

Copilot AI review requested due to automatic review settings April 22, 2026 18:00
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

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

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 openalexMailto config/env wiring and provider resolution routing for academic → 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.

Comment thread src/providers/registry.ts
Comment thread src/providers/types.ts
Comment thread README.md Outdated
Comment thread tests/golden/academic-ss-baseline.test.ts
Comment thread src/providers/openalex.test.ts Outdated
Copy link
Copy Markdown

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Choose a reason for hiding this comment

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

💡 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".

Comment thread src/providers/registry.ts
- 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).
@sharonds sharonds merged commit dec9bf4 into main Apr 22, 2026
4 checks passed
sharonds added a commit that referenced this pull request Apr 22, 2026
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.
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.

2 participants