ExecRetrieval: Measuring the Functional-Correctness Gap in Code-Embedding Retrieval

Aaryan Kapoor, Md Abdullah Al Hafiz Khan


Abstract
Embedding-based code retrieval is a core component of coding agents and retrieval-augmented code generation, where retrieving *correct* code matters more than retrieving lexically similar code. Existing code-retrieval benchmarks do not plant controlled, execution-verified single-edit variants of each query’s canonical implementation in the search pool, leaving the question of whether embeddings can functionally discriminate correct from near-clone-but-incorrect code unanswered in a retrieval setting. Resolving this requires a benchmark whose search pool itself contains the relevant counterfactuals — execution-verified buggy variants near-identical to each canonical — so that a retriever’s rank ordering can be directly tested for functional discrimination rather than topical or identity overlap. We introduce ExecRetrieval, 939 Python tasks each paired with one execution-verified canonical implementation and up to four execution-verified buggy distractors, each generated by a mechanical mutation making a single targeted edit, and evaluate 23 dense embedding configurations plus BM25 under provider-native invocation with paired McNemar tests and query-level bootstrap intervals. With near-clone counterfactuals in the pool, the top hosted system reaches exec@10 = 1.00 but only exec@1 = 0.331; rank-1 misses are paired buggy variants 91.5–99.4% of the time across the four leading systems, and the canonical scores below at least one of its four paired distractors in 67–78% of queries on the leading systems. The full dataset, execution oracle, embedding matrices, environment snapshot, and pairwise statistical tests are released at the URL in Appendix D.
Anthology ID:
2026.emnlp-main.2448
Volume:
Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing
Month:
October
Year:
2026
Address:
Budapest, Hungary
Editors:
Hung-Yi Lee, Sunipa Dev, Jessy Li, Desmond Elliott
Venue:
EMNLP
SIG:
SIGDAT
Publisher:
Association for Computational Linguistics
Note:
Pages:
55517–55533
Language:
URL:
https://aclanthology.org/2026.emnlp-main.2448/
DOI:
Bibkey:
Cite (ACL):
Aaryan Kapoor and Md Abdullah Al Hafiz Khan. 2026. ExecRetrieval: Measuring the Functional-Correctness Gap in Code-Embedding Retrieval. In Proceedings of the 2026 Conference on Empirical Methods in Natural Language Processing, pages 55517–55533, Budapest, Hungary. Association for Computational Linguistics.
Cite (Informal):
ExecRetrieval: Measuring the Functional-Correctness Gap in Code-Embedding Retrieval (Kapoor & Khan, EMNLP 2026)
Copy Citation:
PDF:
https://aclanthology.org/2026.emnlp-main.2448.pdf