arXiv:2610.09079cs.SEOct 2026

Manuscript Offprint

arXiv:2610.09079

Large-scale Repository Engineering via Agent-Native Reusable Code Primitives

Haibo Jin, Peng Kuang, Xucheng Yu, Jerry Wang, Dehao Wu, Haohan Wang

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

ABSTRACT

Large language models (LLMs) equipped with development environments have moved code generation toward repository-scale construction, yet building complete repositories remains difficult because interacting modules, interfaces, configurations, tests, and dependencies must work together. We introduce Code Primitives, agent-native reusable executable components that carry their own interface contracts, dependency closures, validation tests, and provenance. Each primitive uses a resident LLM as a natural-language interface to assess relevance and adapt its implementation, interfaces, and dependencies to the target repository, and we organize 1,424 validated primitives in CodeFace, a searchable library for repository construction. Each primitive adapts the component it owns. We introduce LEGO (Large-scale repository Engineering via aGent-native reusable cOde primitives), which activates the primitives a task requires, integrates their adapted implementations with task-specific code while resolving constraints that cross component boundaries, and revises the result against executed tests. To measure construction end to end we build LEGO-REPO, a benchmark of 522 executable reconstruction tasks spanning seven software domains, 22 capability tracks, and five difficulty levels, each scored against the package's native test suite between an empty-package floor and an original-source ceiling. The strongest of 13 evaluated backbones reaches a delivery score of 0.318 and scores zero on 41.0% of tasks; LEGO improves all 13 by 0.1474 on average and raises GPT-5.6-terra from 0.3180 to 0.5134 (+61.4%). In controlled comparisons, adapted primitives achieve higher delivery scores than retrieved code supplied as context or vendored unchanged. The effect persists against independent repository agents, across three external benchmarks, and with a disjointly re-mined CodeFace, and using GPT-OSS-20B for adaptation and diagnosis retains 95.1% of the homogeneous score at 24.0% lower cost.

1 INTRODUCTION

Large language models with development environments have moved code generation from isolated programs toward repository-scale construction (OpenAI, 2025; Anthropic, 2025; GitHub, 2025; Peng et al., 2026; Ding et al., 2025), a setting requiring complete projects whose modules, interfaces, configurations, tests and dependencies work together. This shift raises three high-level design questions about how such repositories can be reliably constructed.

(1) How reliably can frontier models construct a complete repository end to end? Existing evaluations confirm the difficulty: on RepoZero-Py2JS, Claude Sonnet 4.6 with mini-SWE-agent reaches a 54.7% pass rate (Zhang et al., 2026b), with similar results elsewhere (Luo et al., 2026; Chen et al., 2026). On our benchmark, the strongest of 13 LLMs reaches a delivery score of 0.318, where 0 denotes the empty-package floor and 1 the behaviour of the original source, and scores zero on 41.0% of 522 tasks; Claude Opus 5 reaches 0.237 and matches the original behaviour on 5.9%; and the mean score across backbones falls 10.3×10.3 \times from the smallest to the largest difficulty band. These results motivate approaches that reuse and coordinate existing software capabilities.

(2) What reusable abstraction can better support repository construction? Prior work encapsulates reusable capabilities as agent-native behaviors and executable tools (Jin et al., 2026a;b), which are typically invoked externally and remain fixed during use. Repository construction requires a

*Corresponding Author: haohanw@illinois.edu different form of reuse: the reused artifact becomes part of the delivered source, so its interfaces, dependencies, and configuration must be reconciled with the target repository. This form of reuse combines retrieval with adaptation. We introduce Code Primitives, reusable executable components that carry their own interface contracts, dependency closures, validation tests, and provenance. Each primitive uses a resident LLM as its natural-language interface to assess relevance and adapt its implementation, interfaces, and dependencies to the target. We then mine and validate these primitives from real-world repositories and organize them into CodeFace, a library of 1,424 Code Primitives.

(3) What construction pipeline can better leverage reusable software capabilities? We treat repository construction as resolving a specification against existing capabilities and integrating reusable components with task-specific code. We introduce LEGO (Large-scale repository Engineering via aGent-native reusable cOde primitives), which coordinates Code Primitives through three mechanisms: retrieval and activation decomposes a request into required capabilities and activates only the primitives that cover them; primitive collaboration lets activated primitives adapt their implementations while propagating interface and dependency requirements to connected components; and diagnosis and verification executes available and synthesized tests, localizes failures to components or their interactions, and reactivates affected primitives for revision. This loop integrates retrieval, adaptation, and verification until validation succeeds or the construction budget is exhausted. To evaluate LEGO, we introduce LEGO-REPO, a benchmark of 522 executable reconstruction tasks drawn from real GitHub projects across seven software domains, 22 capability tracks, and five measured difficulty levels (D1–D5). Each task reconstructs a Python package from its public interface and evaluates it against the package's native test suite.

We evaluate the aforementioned questions through six empirical RQs spanning from-scratch construction, reusable capabilities, construction mechanisms, model substitution, cost, and transfer. Across LEGO-REPO, LEGO improves all 13 evaluated backbones, with a mean absolute gain of 0.1474 (+76.5% relative). Under GPT-5.6-terra, the delivery score rises from 0.3180 to 0.5134 (+61.4%), with fewer zero-score tasks and more repositories reproducing original-source behavior. The gains persist against independent repository agents, on three external benchmarks, and with a disjointly re-mined CodeFace. Adapted primitives also outperform retrieved code used as read-only context or vendored unchanged. Finally, GPT-OSS-20B adaptation and diagnosis retain 95.1% of the homogeneous GPT-5.6-terra score at 24.0% lower cost. Our main contributions are as follows:

• We design Code Primitives, agent-native reusable software components that carry their own interface contracts, dependencies, validation tests, and provenance, and adapt themselves to target repositories through their natural-language interfaces. We further build CodeFace, a library of 1,424 validated Code Primitives for retrieval and reuse.

• We introduce LEGO, a repository-construction framework built on CodeFace that makes this abstraction usable at repository scale: it activates only the primitives a task requires, delegates adaptation to the component that owns each implementation, and uses executed tests to guide integration and revision across component boundaries.

• Experiments on LEGO-REPO, our benchmark of 522 repository-reconstruction tasks, show that LEGO improves all 13 evaluated LLMs by 0.1474 on average and raises GPT-5.6-terra from 0.3180 to 0.5134 (+61.4%). With matched backbones, LEGO outperforms OpenHands (GPT-5.6-terra) by 57.3% and Claude Code (Claude Sonnet 5) by 56.2%, while GPT-OSS-20B adaptation and diagnosis retain 95.1% of the homogeneous GPT-5.6-terra score at 24.0% lower cost.