arXiv:2609.11332cs.SESep 2026

Manuscript Offprint

arXiv:2609.11332

CoSTAR: Data Synthesis-Driven Constraint-Aware COBOL Section Summarization for Legacy System Modernization

Hao Lin, He Jiang, Xiaochen Li, Weihong Sun, Yufu Wang, Zhilei Ren, Ang Jia

Hao Lin, He Jiang, Xiaochen Li, Weihong Sun, Yufu Wang, Zhilei Ren, and Ang Jia

Abstract—COBOL remains critical to governments, financial institutions, and large enterprises; yet, aging technologies, shrinking expertise, and missing documentation make modernization of COBOL-based legacy systems increasingly urgent. Before migration, code summarization is a common practice to support legacy system understanding. However, COBOL code summarization, especially on section-level, faces two key challenges: data scarcity and migration constraint preservation. To address these challenges, we propose CoSTAR, an integrated framework that combines execution-validated data synthesis with constraint-aware model training. CoSTAR repurposes general-purpose programming tasks to synthesize execution-validated COBOL code-summary data through LLM-based generation to overcome data scarcity. Based on the synthesized data, CoSTAR augments target sections with relevant data declarations and natural-language explanations, and uses constraint-guided structured rationales to train smaller base LLMs. The trained LLMs preserve the migration constraints for COBOL section summarization. We evaluate CoSTAR on both public and confidential enterprise COBOL systems. CoSTAR effectively synthesizes 3,764 execution-validated training instances. Based on these instances, CoSTAR built on 7B/8B base LLMs can improve these LLMs with average relative gains of 25.38% on ROUGE-L, 53.84% on METEOR, and 37.22% on chrF. In real-world enterprise evaluation, CoSTAR built on only Qwen3-8B, outperforms the enterprise-deployed Qwen3-235B in accuracy, completeness, and conciseness. These results show that CoSTAR enables small, locally deployable LLMs to achieve performance competitive with substantially larger LLMs for privacy-sensitive COBOL legacy systems.

Index Terms—COBOL, legacy systems, software modernization, code summarization, large language models

I. INTRODUCTION

For over six decades, COBOL has supported critical services across governments, financial institutions, and more than 40,000 enterprises [1], [2]. Over 800 billion lines of COBOL code remain in active use; these systems process 80% of financial transactions, 95% of ATM transactions, and approximately USD 3 trillion in daily commercial transactions [3]–[5]. However, the foundations sustaining these systems are becoming increasingly fragile. Decades of evolution have created intricate internal dependencies and incomplete or even misleading documentation [6], [7]. Even worse, the pool of experienced COBOL developers is shrinking dramatically, while technical support is also receding [8], [9]. As reported, nearly 40% of the most critical U.S. federal legacy systems relied on unsupported hardware or software, while 64% operated with known cybersecurity vulnerabilities [10]. For organizations that still depend on these systems, modernization is becoming increasingly urgent.

Legacy system modernization aims to improve the maintainability and evolvability of aging systems, typically requiring their business knowledge to be recovered and documented before migration [7]. A seemingly attractive shortcut is direct migration, which bypasses this understanding process by translating legacy code directly into a modern language. However, this direction is impractically. As reported, DOGE planned to use AI to migrate over 60 million lines of COBOL at the U.S. Social Security Administration (SSA) within months; but after nearly a year of effort, the initiative ultimately failed [11]–[13]. This is unsurprising. On the one hand, traditional rule-based translation often carries accumulated technical debt into the target language, producing verbose and difficult-to-maintain "JOBOL" code [14], [15]. On the other hand, LLM-based translation is likewise unreliable. Even on real-world projects in data-rich languages such as Java and Python, the best evaluated LLM succeeded on only 8.1% of translations. Worse still, human reviewers may overlook a substantial fraction of bugs in LLM-generated code [16]. Therefore, direct LLM translation cannot be trusted for mission-critical legacy systems, where behavioral deviations are unacceptable [17], [18].

Therefore, prior studies suggest that a more practical route is to understand legacy systems before migration [6], [19]. Code summarization supports this process by distilling program behavior, data transformations, and business rules into concise natural-language descriptions for subsequent code migration and data transformation [20], [21]. Despite substantial progress, code summarization studies remain concentrated on mainstream languages such as Java and Python, leaving legacy languages (e.g., COBOL) comparatively underexplored [22], [23]. However, applying existing techniques on COBOL code summarization pose two key challenges.

Challenge 1: Data scarcity. Existing LLM-based code summarization methods rely heavily on large-scale aligned code-summary training data [22], [23]. Despite its extensive use in mission-critical sectors (e.g., government and finance), as statistics in Fig. 1, COBOL accounts for only 0.0186% of programming-language tokens [24], since much production COBOL code remains confidential. Moreover, the limited public-available COBOL code lack human-written summary. Most projects contain only file level description. In COBOL,

H. Lin, H. Jiang, X. Li, Y. Wang, Z. Ren, and A. Jia are with the School of Software, Dalian University of Technology, Dalian, China. H. Jiang is also with the DUT Artificial Intelligence Institute, Dalian, China. W. Sun is with Hi-Think Technology, Corp., Dalian, China.

Corresponding author: He Jiang. E-mail: jianghe@dlut.edu.cn.

Figure

Fig. 1. Programming-language token distribution in The Stack v3.

section is the natural functional unit for understanding business logic [25], yet section-level summaries are practically absent from public data. This scarcity not only hinders developers from understanding section-level code, but also makes training summarization models at this granularity difficult.

Challenge 2: Migration constraint preservation. Modernization-oriented summaries should not only describe section behavior but also preserve the constraints needed to reproduce that behavior after migration. This is difficult for two reasons. First, as illustrated in Fig. 2, COBOL separates executable logic in the procedure division from identifier definitions in the data division. When taking only section itself as input for summarization, it misses key properties such as PIC and VALUE; while simply retrieving these definitions is insufficient: their behavioral effects depend on how identifiers participate in comparisons, arithmetic, assignments, and state updates. Second, a concise summary cannot report every recovered constraint. The model must identify and prioritize constraints that materially affect migration, such as numeric precision, overflow, boundary conditions, and state effects. Effective modernization-oriented summarization therefore requires both reliable constraint recovery and interpretation, and selective preservation of migration-critical constraints.

In this paper, we present CoSTAR, an integrated framework for modernization-oriented COBOL section summarization that addresses both challenges through execution-validated data synthesis and constraint-aware model training. We target COBOL section-level summarization, since this level organizes related paragraphs into a more complete unit of procedural logic, providing a natural granularity for developer-facing documentation [25]. To address data scarcity, CoSTAR repurposes the extensive natural-language descriptions and executable tests in general-purpose programming tasks; it uses the former to guide COBOL program generation and the latter to validate and refine the generated programs, thereby enabling execution-validated code-summary supervision without existing COBOL summaries. To preserve migration-critical constraints, CoSTAR transfers the required capabilities to

Figure

Fig. 2. An example of COBOL code. COBOL separates data definitions from executable logic. The target section comprises multiple paragraphs but depends on data constraints defined separately in the data division.

two smaller task-specific models, model-explain and model-summary. Model-explain is fine-tuned on teacher-generated identifier explanations to interpret relevant data definitions and construct expanded context. Model-summary is fine-tuned on judge-validated structured rationales to learn which constraints are important for modernization and how to reflect them in the final summary. At inference, the two smaller models run sequentially and locally. They first recover relevant identifier semantics and then generate a constraint-aware summary from the expanded context, without invoking the large teacher LLMs, thereby supporting the data-privacy requirements of enterprise legacy-system modernization.

We evaluate CoSTAR on datasets from both open-source and real-world enterprise COBOL systems (dubbed Stack-120 and Industrial-200). The synthesis stage produces 3,764 execution-validated COBOL code-summary instances for subsequent model training. Built on four base LLMs (with 7B or 8B parameters), CoSTAR improves COBOL summarization performance, with average relative gains of 25.38%, 53.84%, and 37.22% on ROUGE-L, METEOR, and chrF, respectively. Its best configurations, built on these small models, also remain competitive with substantially larger LLMs (with over 284B parameters). In real-world enterprise evaluation, CoSTAR, built on only Qwen3-8B, outperforms the enterprise-deployed Qwen3-235B by 4.35%, 8.06%, and 4.21% in accuracy, completeness, and conciseness, respectively. In ablation experiment, both execution-validated data synthesis and constraint-aware model improves the effective-ness of CoSTAR significantly. These results confirms that constraint-aware reasoning with synthesized data by CoSTAR enables small, locally deployable LLMs for privacy-sensitive COBOL modernization.

The main contributions of this study are as follows.

• We present CoSTAR, an integrated framework for modernization-oriented COBOL section summarization that combines execution-validated data synthesis with constraint-aware reasoning. It constructs training supervision without existing COBOL summaries and explicitly recovers and incorporates data constraints that affect section behavior.

• We conduct extensive experiments on open-source and real-world enterprise COBOL systems, demonstrating the effectiveness of CoSTAR and its key designs.

• We release replication artifacts to support reproducibility and future research on low-resource legacy languages 1^{1}.

The remainder of this paper is organized as follows. Section II reviews related work. Section III presents the CoSTAR framework. Section IV describes the experimental setup and reports the evaluation results. Section V discusses threats to validity. Finally, Section VI concludes the paper.

References (53)