Citation discipline in SDD: study of determinism and hallucination detection

Discover how citation discipline in SDD affects determinism and hallucination detection in LLM code. Empirical study with Claude and GLM.

miércoles, 1 de julio de 2026 • 3 min read • Q2BSTUDIO Team

Citations in LLM code: determinism vs hallucination detection

Code generation assisted by large language models (LLMs) is transforming software development, but it introduces a critical challenge: how to ensure that the generated code truly meets requirements without veering into unwanted inventions, the so-called hallucinations. A recent study on specification-driven development (SDD) frameworks sheds light on this tension, revealing a fundamental trade-off between two key properties: determinism —the ability to obtain consistent results in independent sessions— and verifiability, that is, the possibility of automatically detecting when the model invents content. The authors compared three approaches: one that requires citations per line of hierarchical requirements, another that uses user stories and acceptance criteria at the artifact level, and a third that relied on external post-hoc traceability maps. The results are clear: explicit references on each line reduce lexical consistency between runs, but they are the only mechanism that enables automatic hallucination detection with rates above 86% and a false positive rate of 0%. This implies that, while citations add a disciplinary burden, they are indispensable when reliability is critical.

For companies developing custom applications or custom software, this finding has immediate practical implications. In environments where code correctness is vital —for example, in financial, medical, or infrastructure systems— prioritizing verifiability over speed or aesthetic variability of the output becomes a strategic decision. Fine-grained traceability not only allows auditing each generated line, but also becomes the foundation for integrating cybersecurity practices, since any uncontrolled deviation can hide vulnerabilities. At Q2BSTUDIO, we understand that automatic code generation must be complemented with robust validation processes. That is why we combine the use of artificial intelligence with agile development methodologies, ensuring that each component meets the agreed specifications. Our teams apply these disciplines both in aws and azure cloud services projects and in business intelligence solutions, where data integrity and transformations are crucial.

The study also highlights that the observed trade-off is consistent across model architectures, suggesting that it is not an artifact of a specific LLM, but rather an inherent property of the interaction between specifications and generation. This reinforces the need to design development systems that know when to require explicit citations and when to be flexible to gain determinism. For example, in rapid prototyping tasks, sacrificing line-by-line traceability may be acceptable; however, in the production of AI for businesses or in the orchestration of AI agents, the ability to automatically detect hallucinations becomes a non-negotiable requirement. In this context, tools such as Power BI integrated into analysis processes require that each data transformation be correctly referenced to its source, something that can only be achieved with a disciplined citation approach.

At Q2BSTUDIO, we apply these lessons in every customized project. By offering development services, we not only generate code, but we also implement verification layers that allow our clients to trust that the delivered software is faithful to what was requested. Whether building a management system with millions of lines or a specific microservice, the combination of detailed specifications and anomaly detection mechanisms —such as those suggested by the study— is part of our methodology. This allows us to offer robust solutions in regulated environments, where auditing each requirement is as important as the performance of the final product. Citation discipline, far from being unnecessary bureaucracy, proves to be an investment in quality and security.

A BREAK?

Play for a moment before you go

OUR SERVICES

How we can help you

Do you have a project in mind?

Tell us your vision and we'll turn it into a software solution. Whatever the scope, we make your idea real.