Search papers, labs, and topics across Lattice.
This paper introduces a Petri-net-guided methodology for generating executable tests for concurrent stateful Rust APIs, addressing the limitations of existing large language model (LLM) approaches that often produce invalid or shallow test cases. By modeling API resources and their lifecycle states as colored tokens and transitions, the method generates legal and near-legal concurrent scenarios that serve as a structured foundation for LLM-based code synthesis. The key result is a robust testing framework that maintains semantic fidelity and enhances concurrency exploration, significantly improving the quality of generated tests compared to traditional methods.
LLMs can now generate high-quality concurrent tests for Rust APIs, preserving semantic intent while exploring complex interleavings.
Concurrent stateful library APIs expose behavior through evolving resource ownership, lifecycle states, and competing interleavings. Large language models can synthesize executable Rust tests, but their outputs often violate API preconditions, remain shallow, or reduce concurrency to accidental sequential traces. Conversely, model-based and systematic testing techniques provide semantic control but commonly require substantial handwritten code to turn abstract scenarios into executable tests. This paper addresses the gap between formal scenario design and low-cost test concretization. We present a Petri-net-guided methodology for test generation over concurrent stateful Rust APIs. The method represents API resources, lifecycle conditions, and causal dependencies as colored tokens and transitions; derives legal deep-state, near-legal, and partial-order concurrent scenarios; and uses these scenarios as a constrained intermediate representation for LLM-based code synthesis. A local-faithfulness contract and structural repair loop preserve the modeled intent during concretization, while Petri-guided schedule shaping prioritizes high-conflict concurrency skeletons for systematic exploration. A layered semantic oracle then distinguishes synthesis failures from violations of the target API's expected behavior.