Source-linked AI summary
FeatLens: Feature-Guided Dynamic Code Graph Construction and Retrieval for Repository-Level Code Generation
Xutian Li, Bo Xiong, Yifeng Zhu, Kunze Li, Xianlin Zhao, Runbang Yan, Yanzhen Zou, Lu Zhang, Bing Xie
TL;DR
Repository-level code generation needs repository dependencies, but current retrieval approaches and feature-oriented methods do not operationally bridge feature intent to code-level dependency retrieval. FeatLens builds feature-guided task graphs and filters them with semantic-structural reasoning; experiments report improved retrieval and dependency reuse alongside reduced graph and token costs.
Problem
Existing retrieval approaches provide repository context, but feature-oriented methods mainly support decomposition, planning, or editing rather than mapping feature intent to code dependencies.
Source: §1 · p. 2Method
FeatLens links natural-language feature descriptions to functions, constructs a task-specific seed graph, and applies semantic-structural reasoning with personalized PageRank to select a compact graph.
Source: §1 · pp. 2–3Results
On DevEval, FeatLens achieves DR@15 (0.501) and DIR@1 53.58% with GPT-5-mini, while reducing total token overhead by 45.9% versus CodexGraph.
Source: §1 · p. 3Takeaways & Limitations
Across DevEval and EvoCodeBench, FeatLens improves dependency retrieval and reuse while reducing graph size and token consumption with competitive functional correctness.
Source: §8 · p. 10FeatLens depends on offline feature summarization and static structural relations, which may weaken retrieval when clusters are inaccurate or runtime binding and framework conventions matter.
Source: §6.2 · p. 9
Abstract
from arXiv · showhide
Recent code generation research has moved from isolated function completion toward repository-level generation in existing codebases. To implement a target function correctly, an LLM must identify reusable repository dependencies such as existing functions, APIs, and cross-file definitions. Existing retrieval methods provide such context through code similarity search, persistent whole-repository graphs, or LLM-driven graph exploration, but often incur high graph construction, reasoning, and token costs. Feature-oriented methods offer a natural view of software functionality, yet they mainly support requirement decomposition, planning, or feature editing rather than code dependency retrieval. This paper presents \textbf{FeatLens}, a feature-guided dynamic code graph construction and retrieval approach for repository-level code generation. FeatLens builds a feature index that links natural-language feature descriptions to function-level code entities. Given a generation task, it dynamically constructs a task-specific seed graph from the feature index and applies semantic-structural graph reasoning with personalized PageRank to select a compact reasoning graph. This design replaces persistent whole-repository graph maintenance and LLM exploration with deterministic and lightweight dependency retrieval. Experiments on DevEval and EvoCodeBench show that FeatLens achieves the best DR@15 among sparse, dense, and graph-based baselines (0.501 and 0.460). On DevEval generation, it obtains the highest DIR@1, reaching 52.91\% with DeepSeek-V3.2 and 53.58\% with GPT-5-mini, while maintaining competitive Pass@1 and producing shorter code. Compared with the strongest graph-based baseline, FeatLens reduces graph nodes by 61.0\%, edges by 86.2\%, and total token overhead by 45.9\%, with no LLM tokens used during retrieval.
1 Introduction
Repository-level code generation requires task-relevant dependencies, but existing retrieval and feature-oriented methods do not operationally connect feature intent to code dependencies. FeatLens makes that connection with a feature-guided dynamic graph approach and reports stronger retrieval alongside lower overhead.
1 Introduction
- Feature-oriented approaches support decomposition, planning, or feature editing, but lack an operational mechanism mapping feature intent to reusable code dependencies on demand.Structured retrieval commonly maintains repository-wide representations, while agent exploration incurs online LLM interactions and can make localization less predictable.Source: §1 · p. 2
- FeatLens maps natural-language feature descriptions to function-level entities, builds a task-specific seed graph, and uses semantic-structural reasoning with personalized PageRank to select a compact graph.It materializes task-relevant regions rather than maintaining a full repository graph.Source: §1 · pp. 2–3
- On DevEval, FeatLens leads at DR@15 (0.501); on GPT-5-mini, it reaches DIR@1 53.58%, with competitive Pass@1 and 45.9% lower total token overhead than CodexGraph.It also reduces graph nodes by 61.0% and edges by 86.2% versus CodexGraph, with no retrieval-time LLM tokens.Source: §1 · p. 3
- The paper frames feature-guided dependency retrieval as a bridge between feature-level intent and code-level context for repository-level generation.The evaluation covers DevEval and EvoCodeBench.Source: §1 · p. 3
2 Motivation
Feature-guided dependency retrieval aims to map a requirement to compact reusable code context that preserves structural constraints. In the motivating example, FeatLens’s final reasoning graph preserves all ground-truth dependencies while filtering expanded candidates.
2.1 Feature-Guided Dependency Retrieval
- A feature is the functional unit described by a requirement and serves as a retrieval anchor linking task intent to reusable repository code.The motivating task is to implement a target function within an existing repository.Source: §2.1 · p. 3
- The retrieval target is a compact dependency context whose entities are reusable code and whose relations preserve structural constraints, rather than merely textually similar code.The task requires aligning a requirement with repository features, recovering lexically indirect dependencies, and avoiding excessive irrelevant context.Source: §2.1 · p. 3
2.2 Motivating Example
- BM25 Retrieval reaches P = 21.4% and DR = 50.0%, while UniXcoder Retrieval reaches P = 14.3% and DR = 33.3%, with text similarity missing structural dependencies.The Mrjob ground truth includes dependencies that are semantically related as well as structurally necessary but lexically indirect.Source: §2.2 · p. 3
- RepoGraph obtains P = 0.0% and DR = 0.0%, while CodexGraph obtains P = 7.7% and DR = 33.3%, as their entry point or search scope misses cross-file dependencies.The example attributes RepoGraph’s result to unsuitable search terms and CodexGraph’s to a scope too narrow to recover dependencies such as unique and _logs_exist.Source: §2.2 · p. 4
- P = 37.5% and DR = 100.0% for FeatLens’s final reasoning graph, which preserves all six ground-truth dependencies while filtering the expanded graph.The feature-guided seed graph has P = 26.7% and DR = 66.7%; expansion raises recall to 100.0% but drops precision to 17.1%.Source: §2.2 · p. 4
3 Approach
FeatLens indexes feature descriptions against functions, builds a task-specific seed graph, then expands and filters it into a compact reasoning graph for code generation. Its retrieval reasoning does not require LLM-driven repository exploration.
3 Approach
- FeatLens first builds a feature-oriented repository index, then dynamically constructs a task-specific seed graph, and finally expands and filters it into a reasoning graph used for generation.The selected reasoning graph is supplied with the task description and target function location as context for code generation.Source: §3 · p. 4, §3.3 · p. 5
3.1 Feature-Oriented Repository Indexing
- Static analysis records code entities and lightweight relations, while semantic analysis represents each function by its implementation semantics; clustering then groups functions and summarizes each cluster as a feature description.The index records each feature description with its associated function-level code entities.Source: §3.1 · pp. 4–5
3.2 Feature-Guided Dynamic Seed Graph Construction
- Semantically aligned feature clusters and target-location context select seed functions, whose repository dependencies are instantiated as a local task graph without materializing a fine-grained graph for the whole repository.The task description and target function location are available at generation time; the missing target implementation is not accessed.Source: §3.2 · p. 5
3.3 Semantic-Structural Graph Reasoning
- Dependency expansion recovers entities missed by feature retrieval but can add weakly related candidates; personalized PageRank ranks the expanded graph using task relevance and structural context to form a compact graph under budget.Retrieval reasoning does not require LLM-driven repository exploration.Source: §3.3 · p. 5
4 Experimental Settings
The evaluation tests FeatLens on repository-level benchmarks for dependency retrieval and code generation, with comparisons spanning retrieval methods, task settings, and measures of effectiveness. It also reports dataset coverage and offline feature-index construction costs.
4.1 Benchmarks and Data Preprocessing
- The study retains 90 DevEval projects and five EvoCodeBench projects; EvoCodeBench supports retrieval only, while DevEval also supports generation.Source: §4.1 · p. 5
- Offline index construction averages 5.5 functions per feature and 269.4–316.6 seconds, costing 0.21–0.30 USD per repository.Source: §4.1 · p. 5
4.2 Baseline Methods
- Comparisons span no-context, sparse and dense retrieval, and graph-based retrieval, including RepoGraph and LLM-driven CodexGraph.Source: §4.2 · p. 6
4.3 Evaluation Metrics
- DR@N and DIR@K measure retrieved and generated-code-invoked ground-truth dependencies; Pass@1 measures unit-test success, and code length assesses redundancy.Source: §4.3 · p. 6
4.4 Parameter Settings
- Generation uses DeepSeek-V3.2 and GPT-5-mini at temperature 0, with default remaining parameters and reasoning disabled; graph settings test Top-10, Top-15, and Top-20.Source: §4.4 · p. 7
5 Experimental Results
FeatLens improves dependency retrieval and downstream generation while using smaller graphs and lower token overhead than graph-based retrieval. Its results also show that recall remains high with smaller contexts and generated code reuses repository dependencies.
5.1.1 Dependency Retrieval
- DR@15 reaches 0.501 on DevEval and 0.460 on EvoCodeBench, exceeding UniXcoder RAG by 0.086 and 0.105, respectively.Source: §5.1.1 · p. 7
- At Top-10, DR is already 0.461 vs. CodexGraph’s 0.466 at Top-20 on DevEval and 0.428 vs. 0.407 on EvoCodeBench.Source: §5.1.1 · p. 7
- DR@15 0.501 beats CodexGraph 0.430, while GPT-5-mini DIR@1 is 53.58% vs. 46.27%, Pass@1 stays competitive, and code is 101.1 vs. 167.7 LOC.Source: Table 3 · p. 8, §5.1.2 · p. 8
5.1.2 Downstream Repository-Level Code Generation
- FeatLens achieves Pass@1 of 42.24% on DeepSeek-V3.2 and 55.03% on GPT-5-mini, outperforming No-context, BM25 RAG, and RepoGraph while remaining competitive with UniXcoder RAG.On GPT-5-mini, FeatLens’s 55.03% Pass@1 is slightly below CodexGraph’s 56.35%. FeatLens has DIR@1 of 53.58% and average code length of 101.1, versus CodexGraph’s 46.27% and 167.7.Source: §5.1.2 · p. 8
5.2 RQ2: Efficiency
- Compared with CodexGraph, FeatLens reduces graph nodes by 61.0% and edges by 86.2%, eliminates retrieval-time LLM tokens (0 vs. 3851.3), and lowers total token overhead by 45.9%.During retrieval reasoning, FeatLens uses static analysis and deterministic scoring, eliminating LLM calls.Source: §5.2 · pp. 8–9
6 Discussion
FeatLens connects feature requirements to repository dependencies, but its demonstrated effectiveness has boundaries in both task applicability and evaluation. The reported results do not isolate each stage’s contribution, and broader validity remains uncertain.
6.1 Effectiveness and Applicability Boundaries
- The retrieval and generation results support FeatLens overall, but do not isolate the contribution of each stage.Its intended use is tasks depending on reusable functions, class members, or cross-file definitions that are not lexically aligned with the requirement; effectiveness may be limited by incomplete feature descriptions or missed static dependencies.Source: §6.1 · p. 9
6.2 Threats to Validity
- The conclusions rely on DevEval and EvoCodeBench, which mainly target Python repository-level code generation.Generalization to other programming languages and industrial closed-source repositories remains to be verified.Source: §6.2 · p. 9
- Retrieval-method parameters, candidate sizes, prompt templates, and implementation differences may affect comparisons, despite shared generation models and comparable context budgets where possible.Pass@1 and DIR@1 capture functional correctness and dependency reuse, but not maintainability, security, or developer judgment.Source: §6.2 · p. 9
- FeatLens depends on offline feature summarization and static structural relations; inaccurate clusters, coarse descriptions, runtime binding, and implicit framework conventions may weaken retrieval.The paper identifies runtime traces, test feedback, and development history as possible ways to strengthen graph reasoning.Source: §6.2 · p. 9
7 Related Work
Prior work retrieves repository context through code similarity, repository structure, or LLM-driven exploration, while feature-oriented work mainly treats features as development tasks or edit targets. FeatLens instead uses feature-level intent as a signal for locating reusable code dependencies.
7.1 Retrieval-Augmented Repository-Level Code Generation
- Repository retrieval uses sparse matching, code search, learned retrievers, query rewriting, and structure-aware graphs, but graph methods can incur full-repository construction and maintenance overhead.Graph-based approaches also add long-range reasoning, multi-granularity structure, or architecture preservation; FeatLens uses features as retrieval anchors and builds a task-specific graph on demand.Source: §7.1 · p. 9
7.2 LLM-Based Repository Exploration
- LLM-based exploration ranges from autonomous tool use to graph-guided and multi-round reasoning, but long reasoning chains can increase latency and reduce controllability.FeatLens narrows the search space to a compact reasoning graph to avoid unnecessary interaction rounds and reasoning overhead.Source: §7.2 · pp. 9–10
7.3 Feature-Oriented Software Development
- Feature-oriented research links functionality to dispersed code entities and uses features for repository tasks, but generally treats them as task or edit targets rather than retrieval signals.FeatLens operationalizes feature intent to map it to dependency-level code context for reuse during implementation.Source: §7.3 · p. 10
8 Conclusion
FeatLens maps feature-level intent to function-level dependency context through a feature index, dynamic seed graph construction, and semantic-structural reasoning. Experiments report improved dependency retrieval and reuse with smaller graphs and lower token consumption, while future work targets harder dependency cases and broader evaluation.
8 Conclusion
- FeatLens maps feature-level intent to function-level dependency context through a feature index, dynamic seed graph construction, and semantic-structural graph reasoning.Experiments on DevEval and EvoCodeBench show improved dependency retrieval and reuse during generation, reduced graph size and token consumption, and competitive functional correctness.Source: §8 · p. 10
- Future work will strengthen graph reasoning for runtime binding, implicit framework conventions, and dependencies weakly aligned with feature clusters.The paper also calls for evaluation on more diverse repository-level code-generation benchmarks.Source: §8 · p. 10