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
Fig. 1: Architecture and workflow of SWHForest . (a) Our pipeline streams and parses remote files once (instantiated on 52.1M Stack-Edu/SWH files), releasing compact Parquet tables and a structural index with zero source code. (b) Users filter and query the local index first, downloading only matching candidate files.
Language
Files
Defs
Docs
Err
Tables
Index
(M)
(M)
(%)
(%)
(GB)
(GB)
Java
17.43
135.6
41
0.7
6.15
7.52
Python
9.48
43.4
23
1.4
2.82
3.16
C++
6.45
40.0
15
9.6
2.25
2.71
JavaScript
5.17
39.5
13
2.1
2.04
1.77
C#
4.56
30.5
24
1.3
1.65
1.81
TABLE I: Our public SWHForest release across the ten largest languages of Stack-Edu (40% uniform sample of 200 B–200 kB files). Files : unique files ( blob_id ); Defs : functions, methods, and classes; Docs : files with doc comments (Go has no distinct syntax); Err : files with syntax error nodes (mainly unexpanded C/C++ macros); Tables / Index : disk sizes.
Fig. 2: Percentage of non-trivial definitions ( ≥20 AST nodes) in each language whose exact syntax-tree structure ( shape ) repeats more than 100 times across the corpus. In our 100k-file Python/JS sample, 73% of these repeated definitions rename identifiers or literals and are missed by exact-text deduplication.
Fig. 3: Execution time for 14 representative structural queries out of 61 across all 10 languages (cached locally on one core; median of 3–5 runs), comparing a full scan with ast-grep against SWHForest index pruning followed by ast-grep verification on candidate files. Labels show the candidate percentage (or [exact] when answered directly by the index) and speedup; X { Y } : Y at any depth in X .
Lang.
Query Pattern
Cand.
Matches
Fetch
Total
Py
except { pass }
207,111
exact
0 s
<0.01 s
JS
for (..) { await }
15,959
exact
0 s
<0.01 s
Java
$X.forName(..)
149,572
exact
0 s
0.52 s
Rust
unsafe { ::transmute }
3,321
2,959
6 s
11.1 s
PHP
for (..) { curl_exec() }
6,355
523
11 s
28.5 s
TS
catch { console.error }
17,174
14,400
27 s
38.8 s
TABLE II: End-to-end search over the full 10-language release (52.1M files): warm index lookup (104 s cold load on Py/JS), live remote fetch (256 threads), and ast-grep verification ( exact : exact matching file set from index). X { Y } : Y at any depth in X .
Large Language Model (LLM) coding agents typically explore codebases through repeated file-reading and grep-searching, consuming thousands of tokens per query without structural understanding. We present Codebase-Memory, an open-source system that constructs a persistent, Tree-Sitter-based knowledge graph via the Model Context Protocol (MCP), parsing 66 languages through a multi-phase pipeline with parallel worker pools, call-graph traversal, impact analysis, and community discovery. Evaluated across 31 real-world repositories, Codebase-Memory achieves 83% answer quality versus 92% for a file-exploration agent, at ten times fewer tokens and 2.1 times fewer tool calls. For graph-native queries such as hub detection and caller ranking, it matches or exceeds the explorer on 19 of 31 languages.
Martin Vogel, Falk Meyer-Eschenbach, Severin Kohler +2
Independent Researcher, Berlin, Germany · Institute of Medical Informatics, Charité – Universitätsmedizin Berlin, Berlin, Germany · Clinical Study Center, Berlin Institute of Health, Berlin, Germany +3
LLM-based code agents treat repositories as unstructured text, applying edits through brittle string matching that frequently fails due to formatting drift or ambiguous patterns. We propose reframing the codebase as a structured action space where agents operate on named AST entities rather than text spans. Our framework, CODESTRUCT, provides readCode for retrieving complete syntactic units and editCode for applying syntax-validated transformations to semantic program elements. Evaluated on SWE-Bench Verified across six LLMs, CODESTRUCT improves Pass@1 accuracy by 1.2-5.0% while reducing token consumption by 12-38% for most models. Models that frequently fail to produce valid patches under text-based interfaces benefit most: GPT-5-nano improves by 20.8% as empty-patch failures drop from 46.6% to 7.2%. On CodeAssistBench, we observe consistent accuracy gains (+0.8-4.4%) with cost reductions up to 33%. Our results show that structure-aware interfaces offer a more reliable foundation for code agents.
Coding agents now interleave LLMs with retrieval over the working repository, and retrieval implementations vary widely across deployed harnesses. Inside a fixed coding-agent harness on a fixed model, does adding a structural codebase index actually change cost or resolve? We ran three arms (the harness with the index, the same harness without it, and an agentic-grep comparator) on SWE-PolyBench Verified and SWE-bench Pro with Claude Opus 4.7 held fixed throughout, across three seeds, inside a leak-audited per-task sandbox. The within-harness ablation produces a large localization gain and a statistically separated resolve gain, with no cost penalty per cell and lower cost per solve. The cross-harness check shows that the index does not regress against an agentic-grep baseline on resolve or localization, again at no cost penalty. We release the per-cell exclusion ledger, the leak-audit script, the localization extractor, and the results database. The deployment question for a structural codebase index is thus not whether it is too expensive to run (across seeds, the index lands at a lower $/solved than agentic grep) but whether the workload includes multi-file changes where structural ranking pays off.