MCP
arXivarXiv
Preprint
Published: July 30, 2026
cs.SE

Structural Validation of LLM-Generated Microservice Decompositions Using Source-Code Dependencies

Abstract
Decomposing monolithic systems into microservices is a key activity in software modernization. Although Large Language Models (LLMs) can generate semantically plausible decompositions from textual requirements, it remains unclear whether these proposals preserve the structural dependencies implemented in the source code. This paper evaluates the structural adherence of microservice decompositions generated by OpenAI o3 for the PetClinic and Bookstore systems. We propose an automated validation pipeline based on static dependency analysis and compare zero-shot and few-shot prompting using dependency preservation (TPD) and dependency violation (TVD) metrics. A robustness analysis was conducted to control for differences in class-to-service mapping coverage. After normalization, both prompting strategies produced equivalent structural adherence, achieving TPD values of 68.0% (PetClinic) and 83.3% (Bookstore). The findings demonstrate that structural evaluations of LLM-generated decompositions should explicitly control for mapping coverage, as apparent differences between prompting strategies may otherwise reflect methodological bias rather than genuine architectural quality.
0
AI overview
Reviews
Citation graph
References · 19
Structured
This preview uses generator v1; v2 is available

Overview

Targeting the microservice decomposition plans generated by OpenAI o3 for the PetClinic and Bookstore systems, this paper proposes an automated validation pipeline based on static source code dependency analysis. Through normalization that controls for class-to-service mapping coverage, it compares structural conformance differences of the decomposition results produced under zero-shot and few-shot prompting strategies.

Research Background and Open Problem in LLM-Generated Microservice Decomposition

Prior research has verified that large language models such as OpenAI o3 and Claude 3.5 Sonnet can achieve high conceptual accuracy in microservice identification tasks. Subsequent related work has further characterized the structural properties of LLM-generated architectures, observing behavioral differences across prompt strategies; for example, few-shot prompting tends to produce finer-grained splits, corresponding to more microservices and more detailed descriptions.

The vast majority of current related work evaluates only the semantic consistency of microservice splitting results, and has not systematically validated the core question of whether the service boundaries proposed by LLMs preserve real source code dependencies. This missing evaluation dimension constitutes a typical gap in existing research on LLM-generated microservice decomposition.

Core Approach: An Automated Validation Pipeline for Structural Conformance

The core methodological contribution of this study is an automated validation pipeline for LLM-generated microservice decomposition results. Built on static dependency analysis as its foundation, the pipeline performs structural conformance evaluation of the microservice decompositions generated by OpenAI o3 for the PetClinic and Bookstore systems.

Unlike conventional output-plausibility checks, the pipeline's core design introduces two dedicated quantitative metrics, dependency preservation (TPD) and dependency violation (TVD), which can directly compare the structural compliance of decomposition plans generated by the two mainstream prompt strategies, zero-shot and few-shot.

The work's key differentiator from existing research is the addition of a robust normalization control step for class-to-service mapping coverage, which removes evaluation bias caused by inconsistent mapping coverage across generated results. After normalization, the decomposition results from the two prompt strategies show comparable structural conformance, with TPD reaching 68.0% on PetClinic and 83.3% on Bookstore. This conclusion also highlights the core requirement that structural evaluation of LLM-generated microservice decompositions must explicitly control mapping coverage.

Validation Workflow and Definition of Structural Conformance Metrics

The entire automated validation process consists of four sequential steps. The first step is static extraction: Tree-sitter and a Java grammar parse the source code to build a real dependency graph, capturing code relationships such as inheritance, implementation, dependency injection, repository usage, and JPA relationships. The second step is class-to-service mapping: heuristic rules based on package and class names associate each source class with the generated microservices, with manual correction applied when ambiguity is detected. The third step is violation detection: the dependency graph is analyzed to identify edges crossing service boundaries, which correspond to structural violations introduced by the decomposition plan. The fourth step is metric computation: structural conformance metrics are computed from the outputs of the preceding steps. Refer to the figure immediately following to fully understand the execution logic and data flow of the four steps.

Fig. 1: Overview of the overall methodology of the automated validation pipeline proposed in this study

The study uses three complementary metrics to evaluate the generated microservice decompositions, quantifying their structural conformance with the original monolithic system. TVD, the total violation degree of dependencies, is the proportion of all extracted dependencies that cross the service boundaries defined by the decomposition plan; a higher TVD indicates greater structural divergence between the decomposition and the original monolith. TPD, the total preservation degree of dependencies, is the complement of TVD, equal to 1 minus TVD numerically, and represents the proportion of all extracted dependencies that are preserved within the same microservice.

Formally, let EE be the set of all extracted dependencies and s(c)s(c) the mapping function that assigns class cc to its corresponding microservice. Then for any dependency (ci,cj)∈E(c_i, c_j) \in E, the dependency is judged as preserved when s(ci)=s(cj)s(c_i) = s(c_j), and otherwise classified as a structural violation. The corresponding TVD formula is the number of cross-boundary dependencies divided by the total number of dependencies, and TPD is simply 1 minus TVD. Note that TVD and TPD only quantify structural conformance and do not represent the overall architectural quality of the decomposition plan.

Analysis of Controlled Experimental Results After Normalization

After normalization of mapping coverage, the final evaluation results for the two tested systems fully converged. In the PetClinic scenario, both zero-shot and few-shot prompting yielded a TVD of 32.0% and a TPD of 68.0%; in the Bookstore scenario, both strategies yielded a TVD of 16.7% and a TPD of 83.3%. These results show that the performance differences between the two prompt strategies observed in the initial analysis can be fully explained by differences in mapping coverage.

After controlling for the confounding variable of mapping coverage, no difference in structural conformance was observed between zero-shot and few-shot prompting in either tested system. The categories of structural violations in the decomposition results produced by the two strategies were also identical, indicating that the remaining structural inconsistencies are mainly related to the limited structural information available in the textual requirements, rather than to properties of the prompt strategies themselves.

This result demonstrates the core methodological value of the study: directly comparing the decomposition effectiveness of different prompt strategies using raw, unnormalized metrics can easily lead to misleading conclusions. When different generated plans cover different subsets of the source code, differences in raw metrics cannot be directly equated to true differences in structural conformance.

Research Implications and Notes on Applicability Boundaries

For academic research, the results of this study show that in benchmark evaluations of LLM-based architecture synthesis, structural conformance metrics such as TVD and TPD should serve as a complementary dimension to semantic evaluation metrics. Evaluating only the conceptual quality of generated decomposition plans may overlook critical structural inconsistencies with the underlying implementation. Furthermore, the study's robustness analysis shows that comparative experiments between prompt strategies must explicitly report class-to-service mapping coverage; when coverage differs, evaluation results need to be normalized, as raw structural metrics can exhibit significant bias due to differences in the analyzed set of classes.

For industrial practice, the automated validation pipeline proposed in this study can serve as an architectural audit mechanism before microservice migration decisions. Rather than adopting LLM-generated decomposition results directly as the final architecture design, practitioners can use the structural violations identified by the pipeline to locate coupling hotspots, estimate migration effort, and prioritize manual architectural review of high-risk parts. This structural validation capability can naturally fit into system modernization workflows such as architectural review and migration planning, providing objective evidence of the structural impact of candidate decomposition plans and allowing architects to focus their effort on the relatively small share of necessary adjustments.

The external validity of this study has clear boundaries: the evaluation covers only two Java monolithic systems and one large language model, OpenAI o3. Although the two selected test systems differ in scale and architectural complexity, the current conclusions cannot be directly generalized to other programming languages, application domains, industrial-scale systems, other architectural styles, or newly released large language models. Further replication work covering more systems and more LLMs is needed to verify the broader applicability of this validation pipeline and the associated methodological conclusions.

The core observations of this study also provide a clear corrective reference for the experimental design of future evaluations of the same kind: although LLM-generated microservice decompositions preserve a considerable proportion of the original dependency structure, they still introduce structural violations that require architectural adaptation during migration. The previously observed performance advantages between prompt strategies disappear entirely after controlling for class-to-service mapping coverage; after normalization, zero-shot and few-shot prompting show comparable structural conformance, and results originally attributed to differences in prompt strategy effectiveness are essentially caused by methodological bias.

Rating
No ratings yet
Rate
Community rating
—
/ 5
No ratings yet
Rating
—
Soundness
—
Presentation
—
Contribution
—
Confidence
—
Discussion
Top
Newest
Questions
Replication
Author
No comments yet — be the first