SGCR: A Specification-Grounded Framework for Trustworthy LLM Code Review
Kai Wang, Bingcheng Mao, Shuai Jia, Yujie Ding, Dongming Han, Tianyi Ma, Bin Cao
TL;DR
The paper tackles unreliable and context-insensitive LLM code reviews by grounding reasoning in explicit, human-authored specifications. It introduces SGCR, a dual-pathway framework with an explicit specification injection path for deterministic rule enforcement and an implicit specification discovery path for heuristic issue discovery, connected by a robust result aggregation stage and optional spec-guided code generation. In a production deployment at HiThink Research, SGCR achieved a 42% adoption rate, a 90.9% relative improvement over a vanilla LLM baseline, and strong developer trust, with ablation showing explicit guidance as the key driver and the implicit path offering complementary gains. These results demonstrate that specification-grounding can bridge the gap between LLM capabilities and enterprise reliability requirements in automated code review.
Abstract
Automating code review with Large Language Models (LLMs) shows immense promise, yet practical adoption is hampered by their lack of reliability, context-awareness, and control. To address this, we propose Specification-Grounded Code Review (SGCR), a framework that grounds LLMs in human-authored specifications to produce trustworthy and relevant feedback. SGCR features a novel dual-pathway architecture: an explicit path ensures deterministic compliance with predefined rules derived from these specifications, while an implicit path heuristically discovers and verifies issues beyond those rules. Deployed in a live industrial environment at HiThink Research, SGCR's suggestions achieved a 42% developer adoption rate-a 90.9% relative improvement over a baseline LLM (22%). Our work demonstrates that specification-grounding is a powerful paradigm for bridging the gap between the generative power of LLMs and the rigorous reliability demands of software engineering.
