arXiv:2605.18284cs.SEcs.AI2026-05

从代码仓库历史中提取可复用的知识,让开发者和AI更高效地利用过往经验。

CommitDistill: A Lightweight Knowledge-Centric Memory Layer for Software Repositories

  • 用正则表达式和关键词匹配,将提交记录转化为事实、技能、模式三类结构化知识。
  • 在25,000次提交中提取1,167个知识单元,检索准确率达0.750(对比BM25仅0.333)。
  • 完全本地运行、无需外部服务,结果可查可调,适合注重隐私与可控性的团队。

软件仓库积累了大量未结构化的知识,如提交信息、拉取请求讨论和问题线程,但开发者和AI编程助手很少有效重用这些历史内容。近期针对大模型智能体的有类型记忆架构(如MemGPT、生成代理及Yang等人的PlugMem模块)指出,智能体记忆应为提炼后的有类型知识,而非原始交互文本。本文将这一理念应用于本地git历史,在确定性、无依赖、纯本地、不使用嵌入的约束条件下提出CommitDistill:一个开源Python原型,通过确定性正则表达式将本地git历史提炼为三类有类型知识单元(事实、技能、模式),并通过基于TF-IDF的检索器结合校准的沉默阈值(theta = 2.5)对分布外查询主动回避。该系统构成一个可信任的记忆基底:确定性、无外部依赖、可检查的纯JSON存储、可调沉默策略。在涵盖Python、JavaScript、C和Java的五个公开仓库(共25,000次提交,提取1,167个知识单元)的案例研究中,40个双标注的Python知识单元实现0.525的有用精度与0.633的科恩κ一致性。关键发现是预算受限检索:在每查询256字符的预算下,CommitDistill在12次查询基准上达到0.750命中率,远超BM25的0.333和git log --grep的0.083。在包含200次时间旅行型缺陷修复的四臂配对评估(两评审员)中,所有条件均未在总体均值上产生统计显著提升,且CD-Hybrid与BM25头对头比较无差异。10,000次提交的提取可在笔记本电脑上于4秒内完成。论文附有源码、标注数据、基线与可复现脚本。

原文摘要 · Abstract (English)

Software repositories accumulate large amounts of unstructured knowledge in commit messages, pull-request discussions, and issue threads, but developers and AI coding assistants rarely reuse this history effectively. Recent work on typed-memory architectures for LLM agents (MemGPT, generative agents, and the PlugMem module of Yang et al.) argues that agent memory should be distilled, typed knowledge rather than raw interaction text. We adapt that stance to a software repository's own git history under a constrained regime: deterministic, dependency-free, local-only, no embeddings. We present CommitDistill, an open-source Python prototype that mines a local git history into typed knowledge units (Facts, Skills, Patterns) using deterministic regex and surfaces them through a TF-IDF retriever with a calibrated silence threshold (theta = 2.5) that abstains on out-of-distribution queries. The artefact is a trust-instrumented memory substrate: deterministic, no external service, inspectable plain-JSON store, tunable abstention. A case study on five public repositories spanning Python, JavaScript, C, and Java (25,000 commits, 1,167 extracted units) reports useful-precision 0.525 at Cohen's kappa = 0.633 on 40 dual-annotated Python units. The decisive finding is budget-constrained retrieval: at a 256-character per-query budget, CommitDistill reaches 0.750 hit-rate on a 12-query benchmark against BM25's 0.333 and git log --grep's 0.083. On a four-arm paired LLM-as-judge evaluation (n=200 time-travel bug-fixes, two judges) covering control, CommitDistill, a body-budget-matched CD-Hybrid, and BM25, no condition produces a statistically detectable lift over control on the headline mean and CD-Hybrid is indistinguishable from BM25 head-to-head. Extraction over 10,000 commits completes in under 4 seconds on a laptop. Source, annotations, baselines, and a reproducibility script accompany this paper.

代码理解知识提取本地推理记忆机制

Thank you to arXiv for use of its open access interoperability. PaperDance 不是 arXiv 官方产品;中文卡片由大模型生成,请以原文为准。