coredd-bench
收藏资源简介:
CoReDD Bench是一个用于评估代码缺陷检测器性能的基准测试数据集,专注于代码审查场景下的缺陷行定位任务。该数据集通过重构代码仓库历史中后续的修正记录,自动生成缺陷标签,并引入人工审核来量化标签噪声与不确定性。数据来源于六个经过筛选的Python开源GitHub仓库的拉取请求,这些仓库具有可观察的评审和集成工作流。数据集包含三个核心文件:`labels.jsonl` 记录了每个评审案例(即存在缺陷且后来被修正的拉取请求)及其候选语法节点(包括被标记为缺陷的节点);`audits.jsonl` 存储了人工审核样本的结果,用于估计标签错误率;`noise.json` 则提供了基于审核结果的后验错误率分布,用于在评估时进行蒙特卡洛扰动,从而为所有性能指标(如F1分数)生成带有置信区间的报告。评估协议模拟了事前(ex ante)审查设置,检测器只能基于代码合并前的信息(如规范diff、评审上下文)进行预测,且预测范围仅限于diff中发生变更的Python代码行。该数据集旨在衡量检测器在标签存在固有噪声的情况下,准确识别引入缺陷的代码行的能力,适用于代码审查自动化、软件缺陷检测、标签噪声建模及不确定性量化等研究领域。
CoReDD Bench is a benchmark dataset for evaluating the performance of code defect detectors, focusing on defect line localization tasks in code review scenarios. The dataset automatically generates defect labels by reconstructing subsequent correction records in the code repository history and introduces manual audits to quantify label noise and uncertainty. The data is sourced from pull requests of six selected Python open-source GitHub repositories with observable review and integration workflows. The dataset includes three core files: `labels.jsonl` records each review case (i.e., a pull request with defects that were later corrected) and its candidate syntactic nodes (including those marked as defective); `audits.jsonl` stores the results of manually audited samples to estimate label error rates; `noise.json` provides a posterior error rate distribution based on audit results, used for Monte Carlo perturbations during evaluation to generate reports with confidence intervals for all performance metrics (such as F1 scores). The evaluation protocol simulates an ex ante review setting, where detectors can only make predictions based on pre-merge information (e.g., canonical diff, review context), and the prediction scope is limited to Python code lines changed in the diff. The dataset aims to measure the detectors ability to accurately identify code lines that introduce defects in the presence of inherent label noise, and is applicable to research fields such as automated code review, software defect detection, label noise modeling, and uncertainty quantification.
数据集概述
CoReDD Bench 是一个用于评估代码审查中缺陷检测能力的数据集与基准测试框架,核心目标是衡量审查者能否在代码变更合并前准确识别出存在缺陷的代码行。
核心任务与评估设定
- 任务类型:文本分类(text-classification),具体为代码审查中的缺陷检测。
- 评估场景:前瞻性(ex ante)设定。检测器只能看到待合并的代码变更及审查上下文,后续的修正信息仅作为标签证据(label evidence),不作为输入。
- 评估目标:对于每一个已被后续修正证实存在缺陷的变更,检测器需标记出引发该缺陷的具体代码行。每个案例(case)本身已被确认存在缺陷,因此问题不在于“是否存在缺陷”,而在于“缺陷位于何处”。
数据来源与标签生成
- 来源:从 GitHub 上六个 Python 仓库(具备可观察的审查与集成工作流)中提取,并非随机样本,结论仅适用于该范围。
- 标签生成方式:基于仓库历史进行机器重构(reconstruction),非人工标注的 ground truth。通过搜索历史提交,找出引入缺陷的变更并标记其中的缺陷行。
- 标签不确定性:重构过程随机且不完美。通过人工审计(audit)抽样检查标签错误率,并以后验概率分布(posterior distributions)的形式提供。所有评估分数均带有置信区间,区间宽度反映标签误差导致的基准分辨率(resolution κ)。
数据集规模与配置
- 规模:小于 1000 个案例(n<1K)。
- 配置(configs):
labels:标签数据文件data/labels.jsonlaudits:审计记录文件data/audits.jsonlcohort:仓库群体描述文件data/cohort.jsonl
- 语言:英语(en)。
- 许可证:CC BY 4.0。
数据文件与结构
| 文件 | 内容 |
|---|---|
data/labels.jsonl |
每个案例(审查中的 Pull Request)的标签数据,包含候选节点(candidate nodes)、节点范围、缺陷来源(provenance)及置信度分层(bin) |
data/noise.json |
标签错误率的后验参数,按置信度分层给出 |
data/audits.jsonl |
人工审计的原始记录,包含案例标识、审计分类及标注者选定的行 |
data/cohort.jsonl |
六个基准仓库的来源群体(65 个仓库)描述,包含仓库选择漏斗的各个限制条件及描述性统计指标 |
评估协议
- 规范差异比较(Canonical diffs):必须使用与标签生成一致的差异比较(Myers 算法,特定配置),确保坐标兼容。
- 信息截止点(information cutoff):每个案例记录一个
cutoff时间点,检测器只能使用该时间点之前的信息,不得使用后续修正数据。 - 有效预测范围:仅限规范差异比较中发生变更的 Python 代码行,且需区分删除行(base 侧)和新增行(after 侧)。上下文行、差异外文件、非 Python 文件均不属于预测域。
- 评分方式:将提交的行投影到语法节点(syntax nodes),与标签节点进行精确跨度(span)对比,计算分类指标(如 F1)。默认对所有案例的候选节点进行池化(pooled)评估,部分指标(如 MRR)按案例单独计算并平均。
仓库群体(Cohort)选择流程
基准仓库从 65 个仓库的群体中分层抽样得到,该群体源于一个严格的构建漏斗:
| 阶段 | 筛选条件 |
|---|---|
| 平台事件 | GitHub 平台(9,345 个候选) |
| 仓库选择 | 保留 1,090 个 |
| 集成分支重构 | 保留 812 个 |
| 审查纪律画像 | 保留 130 个 |
| 集成门禁执行 | 保留 65 个 |
| 审计样本 | 按讨论率分层,每层抽取 2 个仓库(共 6 个) |
单个仓库记录包含:审查合规分数、稳定审查概率、绕过合并比例、合并与审查者统计、仓库规模(源代码行数、核心贡献者数、仓库月龄)、参与率与分层信息。
相关资源
- CoReDD Corpus(https://huggingface.co/datasets/witrin/coredd-corpus):包含冻结的仓库历史及 GitHub 审查上下文,提供标签重构和评估所需的原始数据与规范差异比较文件。




