TraceCoder: Explainable and Auditable Code Generation with Position-Key Snippet Versioning
TraceCoder: Explainable and Auditable Code Generation with Position-Key Snippet Versioning
TraceCoder:基于位置键代码片段版本控制的可解释与可审计代码生成
Abstract: Contemporary LLM-based coding agents produce code as black-box outputs: the rationale behind each line is hidden, the evolution of the code through benchmark-driven repair is ephemeral, and post-hoc auditing is impossible.
摘要: 当代基于大语言模型(LLM)的编程智能体所生成的代码往往是“黑盒”输出:每一行代码背后的逻辑被隐藏,代码通过基准测试驱动的修复过程所产生的演变是短暂的,且事后审计几乎无法实现。
We present a code generation concept that addresses these shortcomings through three complementary mechanisms: (i) a relational snippet-history schema that records, per repair event, the benchmark reference, round number, failure text, and LLM explanation, enabling full provenance queries; (ii) a browser-based visualisation tool that renders this history as heat-mapped, hover-annotated source code; and (iii) a competitive fractional position-key indexing scheme with tree-node delimiters that assigns stable, lexicographically-ordered identifiers to each code snippet, enabling fine-grained tracking without disrupting surrounding lines.
我们提出了一种代码生成概念,通过三种互补机制解决了上述缺陷:(i) 一种关系型代码片段历史模式,记录每次修复事件的基准参考、轮次、失败文本及大模型解释,从而实现完整的溯源查询;(ii) 一种基于浏览器的可视化工具,将这些历史记录渲染为带有热力图和悬停注释的源代码;以及 (iii) 一种带有树节点分隔符的竞争性分数位置键索引方案,为每个代码片段分配稳定的、按字典顺序排列的标识符,从而在不干扰周围代码行的情况下实现细粒度的跟踪。
We evaluate TraceCoder on 30 algorithmic programming tasks spanning string processing, mathematical computation, and data-structure manipulation, across two provider configurations. Of these, 10 exhaust the 6-iteration budget on tasks with subtle edge-case behaviour. Mean Chg% reaches 30%, three in ten code snippets carry a traceable repair-event row, compared to 21% when using Gemini 2.0 Flash as sole provider on a 20-task subset.
我们在涵盖字符串处理、数学计算和数据结构操作的 30 个算法编程任务上,通过两种提供商配置对 TraceCoder 进行了评估。其中,有 10 个任务在处理微妙的边界情况时耗尽了 6 次迭代预算。平均变更率(Mean Chg%)达到 30%,十分之三的代码片段带有可追溯的修复事件记录;相比之下,在仅使用 Gemini 2.0 Flash 作为提供商的 20 个任务子集中,该比例仅为 21%。
Three detailed case studies demonstrate how the system explains which specific benchmark failures shaped each line of the final program. The proposed mechanism makes the internal “narrative” of automated code generation auditable and replayable, a property essential for trust and accountability in production deployments.
三项详细的案例研究展示了该系统如何解释具体的基准测试失败是如何塑造最终程序的每一行代码的。所提出的机制使得自动化代码生成的内部“叙事”变得可审计且可重现,这对于生产部署中的信任和问责至关重要。