arXiv:2610.30016cs.SEOct 2026

Manuscript Offprint

arXiv:2610.30016

Code Comprehensor: Hierarchical Documentation and Cross-Modal Retrieval for Large Repositories

Sujoy Roychowdhury, Joseph H. R. Isaac, Jiangning Gao, Martin Klitte, Diarmuid Corcoran

Open access. PaperVantage converted this article to text, so layout and figures may differ from the original.

Sujoy Roychowdhury*, Joseph H. R. Isaac†, Jiangning Gao‡, Martin Klitte§ and Diarmuid Corcoran¶

Ericsson R&D

Email: {*sujoy.roychowdhury, †joseph.isaac, ‡jiangning.gao, §martin.klitte, ¶diarmuid.corcoran}@ericsson.com

Abstract—Understanding large, complex, and rapidly evolving code bases remains a core challenge for software engineering at scale, hindering onboarding, maintenance, refactoring, and impact analysis. Providing this information to a Large-Language Model (LLM) is another hurdle, as the LLM must understand not only the required code method but also its associated methods in the grand scheme of the repository. We propose Code Comprehensor, a hybrid retrieval–reasoning framework combining (i) a code dependency callgraph, (ii) CodeScribe, which uses code-aware LLMs to generate hierarchical documentation across repository call graphs, and (iii) CodeContrast, a CLIP-style dual-encoder model trained on CodeScribe output to learn aligned text-code embeddings. CodeContrast enables fast, semantically precise retrieval of relevant code-context neighborhoods, which serve as grounded evidence for an MCP-based LLM orchestrator answering domain-specific queries. Evaluation on OpenCV and a proprietary 5M-LOC repository shows that CodeScribe-derived supervision significantly improves cross-modal retrieval in text-to-code accuracy over baseline approaches. Richer textual supervision (hierarchical documentation, parent/sibling context, and LLM-generated synthetic questions) consistently enhances performance across both repositories. LLM-as-a-judge evaluation using the popular RAGAS of the Code Comprehensor output yields above 90% faithfulness scores.

Index Terms—Large Language Models (LLMs), Code comprehension, Semantic code retrieval, Contrastive learning, CLIP-style encoders, Software repository analysis, Program analysis, Hybrid retrieval-reasoning frameworks

I. INTRODUCTION

Enterprises typically have large code repositories that have been developed and maintained over the years. The ability to document and understand such complex repositories has been a challenge [1], [2]. Code complexity creates dependencies on senior engineers' expertise to understand and navigate such repositories, and introduces inefficiencies in the Software Development Life Cycle (SDLC) [3]. The growth of Large Language Models (LLM) in recent years and their ability to understand and explain code introduce the possibility of making this process more efficient [4]. This growth will lead to greater productivity in developing new features and maintaining and debugging existing ones.

However, the ability to use LLMs to document and understand large repositories in a reliable, replicable fashion requires careful design and consideration. Despite the large context window of many modern LLMs [5], code repositories often will consume a much larger number of tokens. For example, [6] gives Lines of Code (LOC) for some public repositories, and token sizes will be much larger. Proprietary code repositories are often large in terms of LOC. For example, one of the repositories mentioned in this paper is larger than most listed in [6]. More importantly, just because an LLM can process a large number of tokens does not mean an LLM should access the entire repository for every question. In addition to cost implications, large context sizes are known to give poorer results [7], [8].

Additionally, code repositories often contain identical or very similar files, methods, and variables across different parts of the code base, and using probabilistic machinery like an LLM is unlikely to be reliable or replicable. In view of this, it is important to design systems that enable LLMs to navigate code repositories more consistently and deterministically. Regarding this issue, some studies discuss using the inherent structure of code, as captured in the call graph, to drive documentation. Work by [9] discusses using a static-analysis-based call tree to generate documentation for large-scale repositories recursively. A similar approach to generate initial and incremental documentation has been followed by other works [10]. A hierarchical engine for document generation and querying has also been studied [11]. Recently, Google released a repository to document code [12]; however, to the best of our knowledge, the system's design has not been disclosed. The common aspect of these repositories is the use of either the Abstract Syntax Tree (AST) [13] or the call-graph. However, if one wants to build more than just static documentation, a broader and more comprehensive approach is needed. Previous work [14], [15] has looked at cross-modal contrastive learning for code search; however, without deep domain-level documentation mapping methods to domain and code structure, the effectiveness of such cross-modal retrieval on large, complex repositories is limited.

References (34)