SPEC2CODE: Mapping software specification to function-level code implementation

Publication Type

Conference Proceeding Article

Publication Date

11-2025

Abstract

Software specifications, such as protocol standards defined in RFCs, play a critical role in ensuring the correctness of software systems. To check consistency, specification–implementation pairs are essential for testing and verification. However, existing efforts in specification-to-code mapping remain largely manual and are typically limited to the file level, lacking the fine-grained granularity needed for function-level analysis, which is crucial for effective consistency checking. To address this gap, we present Spec2Code, the first LLM-driven framework that automates fine-grained mapping from specifications to function implementations.Given a specification document and a software codebase, Spec2Code first performs preprocessing to extract structured SRs and function-level code representations, along with contextual and dependency information. To ensure scalability, Spec2Code employs a two-stage process comprising relevance filtering and clustering-based SR organization to reduce the candidate pairs. For accuracy, Spec2Code performs fine-grained constraint-level matching on each candidate SR–function pair using LLMs, leveraging enriched context to determine whether a function fully, partially, or does not relate to an SR.We evaluate Spec2Code on real-world implementations of HTTP and TLS protocols, including \textit{Apache Httpd}, \textit{Nginx}, \textit{OpenSSL}, and \textit{BoringSSL}. Experimental results show that Spec2Code outperforms three state-of-the-art baselines, achieving up to 49%, 66%, and 66% improvement in precision, recall, and F1, respectively. Additionally, Spec2Code successfully recovers the mappings for 12 known inconsistency bugs and discovers 11 previously unreported inconsistencies using an integrated lightweight consistency verifier, 5 of which have been confirmed by project developers.

Discipline

Software Engineering

Research Areas

Intelligent Systems and Optimization

Publication

Proceedings of the 40th IEEE/ACM International Conference on Automated Software Engineering, Seoul, Korea, November 16-20

City or Country

Korea

Additional URL

https://conf.researchr.org/details/ase-2025/ase-2025-papers/198/SPEC2CODE-Mapping-Software-Specification-to-Function-Level-Code-Implementation

This document is currently not available here.

Share

COinS