Chiosa
Software & Code

Reusable code components adapt themselves to build full repositories

Large-scale Repository Engineering via Agent-Native Reusable Code Primitives · arXiv:2610.09079

3 min
Updated
From Code Primitives to complete repositories. Left: real-world repositories are mined into component-level Code Primitives, each carrying its interface, dependencies, tests, configuration, and…
From Code Primitives to complete repositories. Left: real-world repositories are mined into component-level Code Primitives, each carrying its interface, dependencies, tests, configuration, and documentation, and organized in CodeFace. Right: a user request activates the…Figure 1 · Large-scale Repository Engineering via Agent-Native Reusable Code Primitives · Haibo Jin et al. · CC BY 4.0

In plain words

The paper introduces LEGO, a system for building complete software packages with reusable code components. Each component can adjust its code and connections to fit a target package; LEGO then runs tests and uses failures to guide revisions.

On 522 Python package tasks, LEGO scored higher on average than a system that built packages with test feedback but no reusable component library. The score reflects how many original package tests the reconstruction passed, relative to a task-specific reference.

The research

Can reusable code help language models build complete software packages, where modules must fit together and pass the package’s own tests? On LEGO-REPO, the strongest of 13 systems building from scratch with execution feedback scored zero on 41% of tasks. The paper tests whether components that adapt to a target repository can address that difficulty.

The authors introduce Code Primitives and LEGO, which retrieve reusable components, adapt them to a target repository, then use executed tests to guide integration and revision.

With GPT-5.6-terra, LEGO averaged 0.5134 on the 522 tasks, versus 0.3180 for construction with execution feedback but no library or diagnosis.

Each task score reflects native tests passed between that package’s empty-package floor and original-source result, and the reported value is the mean across tasks.

The comparison keeps the task set, grading, feedback, and attempt budget the same. The higher mean supports an improvement for this setup, while not implying that every package improved.

These results concern Python package reconstruction under fixed native test suites; passing those tests does not establish complete correctness or design quality. The authors also note that their provenance checks cannot rule out all source overlap.

What the evidence shows

  • Why package building is hard

    The paper asks whether reusable code can help language models build complete software packages. In LEGO-REPO, models reconstruct Python packages from public interfaces and are graded against the packages’ original tests.

    The strongest of 13 systems building from scratch with execution feedback averaged 0.3180 on the task-level score and scored zero on 41% of tasks, showing how often these reconstructions struggled on this evaluation.

  • Reusable code that adapts

    The authors introduce Code Primitives, reusable executable components that carry their interfaces, dependencies, and validation tests. They also introduce LEGO, a framework that retrieves relevant primitives, has each adapt the component it owns to the target package, and integrates the results with task-specific code.

    This addresses a central package-building challenge: reused code must fit the target’s interfaces and dependencies, rather than merely be available as a reference.

  • A higher mean on the same tasks

    The benchmark scores each package by comparing its passed native tests with an empty-package floor and the original package’s result, then averages task scores across all 522 tasks. With GPT-5.6-terra, LEGO averaged 0.5134, compared with 0.3180 for the execution-feedback system without a library or diagnosis.

    Both used the same tasks, grading procedure, and five attempts per module; LEGO added retrieval, primitive adaptation, and diagnosis-guided revision.

  • What reuse contributes

    Controls help distinguish adaptation from merely finding reusable code. With retrieval and diagnosis shared, read-only components averaged 0.3544 and unchanged components that were copied and invoked averaged 0.3430, compared with LEGO’s 0.5134.

    A scoped generic-editing control averaged 0.4093. These results associate adaptation with a substantial part of the improvement, but the generic-editing comparison changes several component features together.

  • Reach and outside tests

    An offline audit found candidate primitives for 61.4% of target modules, but availability does not establish that a component was selected, adapted successfully, or integrated. On three external repository-construction tests, LEGO also scored higher than its matched execution-feedback baseline under each test’s own protocol.

    Because their metrics differ from LEGO-REPO’s, this supports improvement in direction, not a shared estimate of gain size.

Deep

Next paperGenerated tests can preserve bugs as expected behavior