cs.SENov 8, 2026

SWHForest: A Structural Curation and Search Layer for Large-Scale Code Corpora

Authors: Federico Pennino, Andrea Gurioli, Maurizio Gabbrielli, Paolo Ferragina

Organizations: Department of Computer Science and Engineering, University of Bologna, Italy · Sant’Anna School of Advanced Studies, Pisa, Italy

Abstract

Pre-training code language models relies on massive code corpora usually streamed over the internet. However, researchers rarely need a multi-terabyte archive in its entirety; instead, their workflow centers on curated subsets: selecting well-documented files, filtering out repetitive boilerplate, auditing for benchmark contamination, or retrieving specific code patterns. Yet, because modern corpora are typically published as file pointers and basic attributes rather than source text, no general structural layer exists to select which files to download: curating a subset requires downloading and parsing millions of files first just to discard most of them. We present SWHForest, an open-source framework and public dataset that provides this missing structural layer for any pointer-based corpus without redistributing source code. A single pass over the archive parses each file into an AST and immediately discards the source text, keeping only its structural summary. Queried locally or exposed by archive providers as a server-side filtering API, SWHForest selects matching files first (via SQL or index intersection) and downloads only surviving candidates. Across the ten largest languages of Stack-Edu (52.1M unique files, 341M definitions), SWHForest answers curation queries in milliseconds while cutting downloads by 46-72%, reducing live structural searches from hours of per-language streaming to seconds or minutes.

Figures & tables

Explore similar work

CardsList
  1. Codebase-Memory: Tree-Sitter-Based Knowledge Graphs for LLM Code Exploration via MCP

    Mar 28, 2026Martin Vogel, Falk Meyer-Eschenbach, Severin Kohler +2AI Coding AgentsGraph-Based Agent Memory

  2. CODESTRUCT: Code Agents over Structured Action Spaces

    Apr 7, 2026Myeongsoo Kim, Joe Hsu, Dingmin Wang +3AI Coding AgentsCode Generation

  3. Code Isn't Memory: A Structural Codebase Index Inside a Coding Agent

    Jun 21, 2026Ishaan Bhola, Adithyan Krishnan, Sravanth Kurmala +1Software Engineering AgentsCode Generation Evaluation