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

- 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>
This commit is contained in:
Tarik Moussa
2026-06-15 03:31:36 +02:00
parent 9647897173
commit fd51b70000
6 changed files with 747 additions and 0 deletions

View File

@@ -286,6 +286,30 @@ class Settings(BaseSettings):
),
)
# ------------------------------------------------------------------
# F-15 Literature Graph
# ------------------------------------------------------------------
graph_cite_boost_alpha: float = Field(
default=0.3,
ge=0.0,
le=1.0,
description=(
"Weight of the PageRank citation-boost in hybrid search. "
"Final score = dense_score * (1 + alpha * pagerank_score). "
"Set to 0.0 to disable the boost without removing the flag."
),
)
graph_min_corpus_size: int = Field(
default=15,
gt=0,
description=(
"Minimum number of ingested papers for citation_pagerank to yield "
"meaningful rankings. Below this threshold a warning is logged and "
"uniform scores are returned."
),
)
@lru_cache(maxsize=1)
def get_settings() -> Settings: