feat(F-15): citation graph — PageRank, coupling, co-citation, CLI #11

Merged
user2595 merged 2 commits from feat/F-15-literature-graph into main 2026-06-15 03:18:23 +00:00
Owner

Summary

  • codex/graph.py (new): build_citation_graph (DiGraph from citations table, no schema change), citation_pagerank (graceful uniform fallback < 5 nodes + logger.warning), find_related (bibliographic coupling via shared references), find_co_cited, dangling_citations
  • codex/config.py: graph_cite_boost_alpha=0.3, graph_min_corpus_size=15
  • codex/cli.py: codex graph report [--top-n N] [--json] — hubs + dangling; codex graph related <paper-id> [--min-shared N]; codex search paper --cite-boost — PageRank score weighting (multiplicative, graceful on small corpus)
  • tests/graph/: 39 tests covering all graph functions + CLI commands

Test plan

  • uv run pytest tests/graph/ — 39 passed
  • uv run pytest --ignore=tests/integration — 326 passed (0 regressions)
  • uv run ruff check . && uv run ruff format --check . — clean
  • uv run mypy codex/ — 0 issues (25 source files)
  • Smoke on live DB: uv run codex graph report (needs ≥ 15 papers for meaningful PageRank)
  • Manual check: Springborn/Bobenko should appear as hub papers after full ingest

Note: R-46 (spike result ADR) marked todo — requires full corpus ingest to validate hub ranking.

🤖 Generated with Claude Code

## Summary - **`codex/graph.py`** (new): `build_citation_graph` (DiGraph from `citations` table, no schema change), `citation_pagerank` (graceful uniform fallback < 5 nodes + `logger.warning`), `find_related` (bibliographic coupling via shared references), `find_co_cited`, `dangling_citations` - **`codex/config.py`**: `graph_cite_boost_alpha=0.3`, `graph_min_corpus_size=15` - **`codex/cli.py`**: `codex graph report [--top-n N] [--json]` — hubs + dangling; `codex graph related <paper-id> [--min-shared N]`; `codex search paper --cite-boost` — PageRank score weighting (multiplicative, graceful on small corpus) - **`tests/graph/`**: 39 tests covering all graph functions + CLI commands ## Test plan - [x] `uv run pytest tests/graph/` — 39 passed - [x] `uv run pytest --ignore=tests/integration` — 326 passed (0 regressions) - [x] `uv run ruff check . && uv run ruff format --check .` — clean - [x] `uv run mypy codex/` — 0 issues (25 source files) - [ ] Smoke on live DB: `uv run codex graph report` (needs ≥ 15 papers for meaningful PageRank) - [ ] Manual check: Springborn/Bobenko should appear as hub papers after full ingest > Note: R-46 (spike result ADR) marked `todo` — requires full corpus ingest to validate hub ranking. 🤖 Generated with [Claude Code](https://claude.ai/claude-code)
user2595 added 1 commit 2026-06-15 01:31:55 +00:00
- codex/graph.py: build_citation_graph (DiGraph from DB), citation_pagerank
  (graceful uniform fallback < 5 nodes), find_related (bibliographic coupling),
  find_co_cited, dangling_citations
- codex/config.py: graph_cite_boost_alpha=0.3, graph_min_corpus_size=15
- codex/cli.py: graph report [--top-n] [--json], graph related <paper-id>
  [--min-shared]; search paper --cite-boost (PageRank score weighting)
- tests/graph/: 39 tests (graph functions + CLI) — 326 total green

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
user2595 added 1 commit 2026-06-15 01:40:42 +00:00
CRITICAL:
- cli.py: invert cite-boost formula: divide distance by (1 + alpha*pr)
  instead of multiply — high-PageRank papers now correctly rank higher
- cli.py: wire graph_min_corpus_size config into graph report; warning
  emitted to stderr so JSON stdout stays parseable

WARN:
- graph.py: document that damping is ignored in small-graph uniform branch
- cli.py: sort dangling citations before slicing for stable output
- cli.py: replace raise typer.Exit(0) with return in empty-graph path
- tests: fix *extra_args helper signatures; add cite-boost ordering test
  and small-corpus warning test

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
user2595 merged commit 2c476dc038 into main 2026-06-15 03:18:23 +00:00
user2595 deleted branch feat/F-15-literature-graph 2026-06-15 03:18:23 +00:00
Sign in to join this conversation.
No Reviewers
No Label
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: user2595/codex-py#11
No description provided.