Closing the Loop: Universal Repository Representation with RPG-Encoder

Closing the Loop: Universal Repository Representation with RPG-Encoder
Notice: This research summary and analysis were automatically generated using AI technology. For absolute accuracy, please refer to the [Original Paper Viewer] below or the Original ArXiv Source.

Current repository agents encounter a reasoning disconnect due to fragmented representations, as existing methods rely on isolated API documentation or dependency graphs that lack semantic depth. We consider repository comprehension and generation to be inverse processes within a unified cycle: generation expands intent into implementation, while comprehension compresses implementation back into intent. To address this, we propose RPG-Encoder, a framework that generalizes the Repository Planning Graph (RPG) from a static generative blueprint into a unified, high-fidelity representation. RPG-Encoder closes the reasoning loop through three mechanisms: (1) Encoding raw code into the RPG that combines lifted semantic features with code dependencies; (2) Evolving the topology incrementally to decouple maintenance costs from repository scale, reducing overhead by 95.7%; and (3) Operating as a unified interface for structure-aware navigation. In evaluations, RPG-Encoder establishes state-of-the-art localization performance on SWE-bench Verified with 93.7% Acc@5 and exceeds the best baseline by over 10% in localization accuracy on SWE-bench Live Lite. These results highlight our superior fine-grained precision in complex codebases. Furthermore, it achieves 98.5% reconstruction coverage on RepoCraft, confirming RPG’s high-fidelity capacity to mirror the original codebase and closing the loop between intent and implementation.


💡 Research Summary

The paper tackles a fundamental limitation of current repository‑level software engineering agents: a reasoning gap caused by fragmented representations that separate semantic intent (e.g., API documentation) from structural connectivity (e.g., dependency graphs). The authors argue that repository comprehension (compressing implementation back to intent) and generation (expanding intent into code) are inverse processes that should be unified within a single reasoning cycle. To achieve this, they extend the Repository Planning Graph (RPG)—originally a static generative blueprint—into a high‑fidelity, bidirectional intermediate representation called RPG‑Encoder.

RPG‑Encoder consists of three tightly coupled mechanisms:

  1. Encoding – Raw source code is lifted into a graph where each node carries a semantic feature f (capturing functional meaning) and metadata m (code‑level attributes such as type and file path). Nodes are divided into high‑level “directory” nodes (V_H) and low‑level “implementation” nodes (V_L). Two edge types are introduced: functional edges (E_feature) that encode hierarchical intent relationships, and dependency edges (E_dep) that capture imports, calls, and other execution‑time relationships. This dual‑view graph simultaneously provides semantic richness and structural precision.

  2. Evolution – Instead of rebuilding the entire graph on every change, the system parses commit diffs and applies three atomic update operations (add, modify, delete). Semantic changes are detected via a lightweight LLM check; only when the functional intent shifts does the hierarchy get re‑organized. This incremental strategy reduces maintenance overhead by 95.7 % and prevents semantic drift.

  3. Operation – The RPG is exposed as a unified reasoning substrate with three core tools: SearchNode (global intent‑based retrieval), FetchNode (metadata‑driven extraction), and ExploreRPG (graph traversal). Agents can therefore query “which function handles authentication?” or drill down to the exact call site using the same underlying structure, effectively closing the “browse‑edit‑run” loop.

The authors evaluate RPG‑Encoder on two fronts:

  • Repository Understanding – Using Claude‑4.5‑Sonnet on SWE‑bench Verified, RPG‑Encoder achieves 93.7 % Acc@5, surpassing prior state‑of‑the‑art by more than 10 % on the Live Lite variant. The results demonstrate that coupling dense semantic features with a rigorously maintained topology dramatically improves fine‑grained localization.

  • Repository Reconstruction – On the RepoCraft benchmark, the system reconstructs 98.5 % of the original code (a 24.3 % improvement over the best baseline) and attains an 86 % pass rate on downstream tests. In contrast, documentation‑only approaches recover only ~17 % of the code, underscoring the importance of explicit structural guidance.

Key contributions include: (i) a theoretical grounding that treats comprehension and generation as a unified reasoning cycle, (ii) the design of a semantic lifting protocol and incremental maintenance pipeline that decouple cost from repository scale, and (iii) empirical evidence of superior performance in both navigation and reconstruction tasks.

In summary, RPG‑Encoder provides a scalable, high‑fidelity representation that bridges intent and implementation, enabling more capable, long‑horizon, structure‑aware AI agents for software engineering. Future work may extend the approach to massive multi‑module ecosystems, integrate runtime profiling for dynamic dependencies, and explore collaborative multi‑agent workflows built on the same unified graph.


Comments & Academic Discussion

Loading comments...

Leave a Comment