arXiv:2611.06525cs.SENov 2026

Manuscript Offprint

arXiv:2611.06525

Construction Contracts for Generated Embedded Domain-Specific Language Programs: A Measurement Protocol and a Conditional Effect

Haowen Guo, Yangzhao Huang

Abstract

A generated domain-specific program can be accepted by its host and still miss the reference construction. We measure the two events separately and test a short construction contract.

The vehicle is Open Quantum Assembly Language (OpenQASM) 3. One 3-billion-parameter generator is run under seven conditions on 100 quantum approximate optimization (QAOA) and 100 variational quantum eigensolver (VQE) instances. Eighty of 100 QAOA signatures appear in some training split. Exact McNemar tests and 95% paired bootstrap intervals are used. The contract, a card, lists structural decisions, enters the prompt, and is checked without a simulator.

Parse rates are 0.55 to 0.97 and full structural match is 0.02 to 0.87. On QAOA, at fixed weights, the card moves full match by +32.0 percentage points on card-trained weights (interval +22 to +42) and by -13.0 (-23 to -3) without that training. The +45.0-point difference is not a deployment contrast. The same-step plan-free gain is +23.0 (+13 to +33); the primary distributional score does not separate it. Against the earlier checkpoint the gain is +27.0 (+17 to +37), and the checkpoint also changes. A rule card is not separated from the learned planner, nor is a predicted-card compiler (0.760 vs. 0.780). On 20 QAOA rows outside every training split, the interval includes zero. Under this card, VQE adherence is 0.020 and full match stays near 0.03.

Report the two checks separately. Insert a card only into a generator trained to read it, and only where a pilot shows adherence.

Keywords: code generation, domain-specific languages, software measurement, large language models, empirical software engineering

1. Introduction

Tool chains increasingly delegate a fragment of work to a large language model: a query, a constraint, a configuration unit, a circuit description. Each is an embedded domain-specific program. Its text means little on its own and much relative to an interface the host has already fixed, and the interface decides whether the fragment is accepted. Acceptance is weaker than correctness, because a fragment that parses can still violate the construction the host expects: the terms it covers, the symbols it shares, the order in which it commits to them. A consumer downstream can reject a fragment the parser accepted.

Software engineering has met this gap before, under other names. Text-to-SQL reports exact match beside execution accuracy, because the two disagree on queries that are right in different ways (Yu et al., 2018), and the oracle problem says the same thing more generally: what decides correctness is the criterion the check applies, not a property

of the program alone (Barr et al., 2015). Code-synthesis metrics add a syntax-level term to string similarity for the same reason (Ren et al., 2020). What these leave open is the operational question. Can a reference construction be recovered from the text by a walk over it, reported field by field, computed without a simulator, and then used as a design target? That is the middle object this paper measures, and it sits between the two numbers that evaluations of generated code usually report.

The measurements come from one such interface. A fine-tuned generator writes parameterized quantum circuits in OpenQASM 3 (Cross et al., 2022), and a fixed host interface decides what it may declare and how many lines it may use. Across the 200 evaluation instances of the main comparison the parser accepts most of what it is given; far less of it matches the reference. In the most divergent cell 0.810 of the outputs parse and 0.020 match all six structural fields. The host can accept the artifact even though the circuit encoded in it differs structurally from the reference.

We then place a specification between the instance and the artifact and ask whether it moves that second number. We call it a construction contract (a card): a finite product

*Corresponding author. Email addresses: 2025091203013@std.uestc.edu.cn (Haowen Guo), yangzhao_se2025@163.com (Yangzhao Huang) of constant-size structural decisions. A walk extracts the card from a reference artifact, and a forward pass predicts it from the instance text. The word is narrower than design by contract (Meyer, 1992). There is no precondition, no postcondition, and no runtime assertion. The card records a reference construction. We score it as prompt content and as a text-walk predicate, and the prompt block is its serialized form. Seven conditions and one relevance control separate slot content from slot presence, from prompt format, from extra training, and from the weights that read the card. The two families differ in construction, so the boundary can be measured rather than assumed.

Three findings organize what follows. Parse rate and full structural match move apart on the same texts. On QAOA the card raises full match only after card-conditioned training, and that estimate is conditional on the constructed set. On VQE, under this card, adherence stays near zero and full match does not rise. After a shared refit, the primary distributional measure does not separate the matched-step control (Sections 5.5 and 5.8). Circuits are the vehicle. Section 6.3 states the transfer test, and Section 7 records the limits.

References (30)