mustafaabdullahk commited on
Commit
674bec1
·
verified ·
1 Parent(s): 19b3030

git-jit-defects v1: 48 repos, 360K commits, SZZ labels + git features

Browse files
Files changed (5) hide show
  1. README.md +131 -0
  2. benchmark.py +42 -0
  3. build.py +101 -0
  4. commits.parquet +3 -0
  5. repos.txt +72 -0
README.md ADDED
@@ -0,0 +1,131 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ ---
2
+ license: cc-by-4.0
3
+ task_categories:
4
+ - tabular-classification
5
+ language:
6
+ - en
7
+ tags:
8
+ - software-engineering
9
+ - defect-prediction
10
+ - just-in-time
11
+ - szz
12
+ - git
13
+ - mining-software-repositories
14
+ size_categories:
15
+ - 100K<n<1M
16
+ pretty_name: git-jit-defects
17
+ ---
18
+
19
+ # git-jit-defects
20
+
21
+ **360,463 commits from 48 open-source repositories (C/C++, Rust, Go, Python, TypeScript/JavaScript), each labelled
22
+ bug-inducing or not by SZZ, with 15 features derivable from local `git` alone.** Snapshot: April 2026.
23
+
24
+ Built for just-in-time (JIT) defect prediction that works on *unseen* repositories without any API access:
25
+ every feature here can be computed from a local clone at `pre-push` time, and the labels came from `git blame` only.
26
+ No GitHub/GitLab API, no issue tracker, no rate limits. The full pipeline (`build.py`) is included and reproducible.
27
+
28
+ ## What is in the box
29
+
30
+ | file | content |
31
+ |---|---|
32
+ | `commits.parquet` | one row per labelled commit: 18 columns (below), zstd, ~21 MB |
33
+ | `build.py` | the labelling + feature pipeline (bare clone → SZZ → parquet) |
34
+ | `benchmark.py` | baseline: LA rule vs LightGBM, 5-fold repo-level cross-validation |
35
+ | `repos.txt` | the repositories scanned (72 requested; 48 met the ≥2000-commit / clone criteria) |
36
+
37
+ ### Columns
38
+
39
+ | column | type | meaning |
40
+ |---|---|---|
41
+ | `repo` | str | `owner/name` on GitHub |
42
+ | `sha` | str | full commit hash |
43
+ | `t` | int | author timestamp (unix seconds) |
44
+ | `author` | str | sha1 of author email (pseudonymous, stable within and across repos) |
45
+ | `subj` | str | commit subject line |
46
+ | `nfiles` | int | files touched |
47
+ | `la` / `ld` | int | lines added / deleted |
48
+ | `hunks` | int | diff hunks |
49
+ | `ndirs` / `nexts` | int | distinct top-level directories / file extensions touched |
50
+ | `test_ratio` | float | share of touched files that are test files |
51
+ | `a_prior_n` | int | author's prior commits in this repo |
52
+ | `a_prior_rate` | float | author's prior bug-inducing rate in this repo (Laplace-smoothed, past only) |
53
+ | `a_days` | float | days since the author's first commit in this repo |
54
+ | `msg_len` | int | subject length (chars) |
55
+ | `msg_ref` | int | 1 if subject references an issue/PR (`#123`) |
56
+ | `y` | int | **label**: 1 = bug-inducing (SZZ), 0 = clean |
57
+
58
+ `benchmark.py` derives the remaining model inputs on the fly (log1p of counts, hour/day-of-week from `t`, and
59
+ `repo_rate` = the repo's own expanding past bug rate), so every input is legal to compute at inference time from
60
+ local git history.
61
+
62
+ The diff text and added lines are **not** included (licensing, size). `build.py` regenerates them from the public repos.
63
+
64
+ ## How labels were made (read this before trusting them)
65
+
66
+ Plain SZZ on `git blame -w`, with a few filters, no refactoring-aware step:
67
+
68
+ 1. **Fix commits** = subject matches
69
+ `\b(fix(es|ed)?|bug|bugfix|hotfix|regression|crash|segfault|leak|race|deadlock|overflow)\b`
70
+ and does *not* match a noise list (typo, lint, format, style, docs, ci, build, tests, chore, revert, merge, bump, deps, …);
71
+ ≤10 files, 1–200 removed lines; test files excluded.
72
+ 2. For each fix, the removed lines are blamed (`-w`); the blamed commits are **bug-inducing candidates**.
73
+ 3. A commit gets `y = 1` if the earliest fix blaming it lands within **365 days** of the commit.
74
+ 4. Only commits inside the *labelable window* are kept: after the oldest scanned fix and at least **180 days** before
75
+ the newest commit (so every commit had a fair chance of being fixed).
76
+ 5. Repos with fewer than 2000 commits were dropped.
77
+
78
+ Overall inducing rate is **11.7%**, per-repo from 1% (ValveSoftware/Proton) to 35% (dragonflydb/dragonfly).
79
+
80
+ **Known limitations.** SZZ labels are noisy; manual studies put precision of basic SZZ around 50–70%
81
+ (Herbold et al., [arXiv:1911.08938](https://arxiv.org/abs/1911.08938)). Fix detection is regex-based on the subject
82
+ line only. There is no refactoring or cosmetic-change filter. Big-bang / squash-merge commits are not treated
83
+ specially. No manual validation sample was taken. Treat this as a *large, cheap, multi-language* JIT dataset, not a
84
+ high-confidence one; for a curated C/C++ benchmark see ReDef ([arXiv:2509.09192](https://arxiv.org/abs/2509.09192)).
85
+
86
+ ## Baseline results (unseen repositories)
87
+
88
+ 5-fold cross-validation **by repository** (a repo is either entirely train or entirely test), early stopping on a
89
+ temporal split inside the training repos. Metric: ROC-AUC per test repo.
90
+
91
+ | method | pooled AUC | median repo AUC | repos beating LA rule by ≥0.02 |
92
+ |---|---|---|---|
93
+ | LA rule (rank by lines added) | 0.778 | 0.770 | – |
94
+ | Logistic regression, size only | 0.777 | 0.772 | 0% |
95
+ | **LightGBM, 15 git features** (`benchmark.py`) | **0.834** | **0.813** | **83%** |
96
+ | Hashed TF-IDF on diff text, LR | 0.745 | 0.737 | 8% |
97
+ | LightGBM, git features + TF-IDF | 0.830 | 0.811 | 85% |
98
+ | LightGBM, git features + UniXcoder-base embedding of the diff | 0.837 | 0.813 | 88% |
99
+
100
+ Take-aways we found while building it:
101
+
102
+ - Nearly all the gain over the LA rule comes from the interaction of change size with **author / repo history**
103
+ (`a_prior_rate`, `repo_rate`); ablating history drops the median to 0.795.
104
+ - Code semantics (TF-IDF, or a 768-d pre-trained code-change embedding) add **nothing** on unseen repos, consistent
105
+ with Zeng et al. 2021 and ReDef 2025.
106
+ - Pooled calibration looks perfect (ECE 0.005) but per-repo it is not: median ECE 0.024, p90 0.073, max 0.109; the
107
+ model over-predicts in low-rate repos. Calibrate per repo before using probabilities.
108
+
109
+ ## Reproduce / extend
110
+
111
+ ```bash
112
+ pip install polars lightgbm scikit-learn
113
+ python benchmark.py commits.parquet # ~5 min on a 12-core CPU
114
+ python build.py repos.txt 6 # rebuild from scratch (bare clones, ~1 GB disk peak per worker)
115
+ ```
116
+
117
+ `build.py` only needs `git`; add any public repository to `repos.txt` to extend the dataset.
118
+
119
+ ## Citation
120
+
121
+ ```
122
+ @misc{gitjitdefects2026,
123
+ title = {git-jit-defects: SZZ-labelled commits with git-only features from 48 repositories},
124
+ author = {Kus, Mustafa Abdullah},
125
+ year = {2026},
126
+ url = {https://huggingface.co/datasets/amazeng-co/git-jit-defects}
127
+ }
128
+ ```
129
+
130
+ Commit metadata belongs to the respective repositories and their authors; this derived dataset (features, labels,
131
+ scripts) is released under CC BY 4.0.
benchmark.py ADDED
@@ -0,0 +1,42 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Baseline for the git-jit-defects dataset: LA rule vs LightGBM on 15 git-derived features, 5-fold *repo-level* CV.
2
+ Usage: python benchmark.py commits.parquet
3
+ """
4
+ import hashlib, sys
5
+ import numpy as np, polars as pl, lightgbm as lgb
6
+ from sklearn.metrics import roc_auc_score
7
+
8
+ HAND = ["l_nfiles", "l_la", "l_ld", "l_hunks", "ndirs", "nexts", "test_ratio", "l_a_prior_n", "a_prior_rate", "l_a_days",
9
+ "msg_len", "msg_ref", "hour", "dow", "repo_rate"]
10
+ PARAMS = dict(objective="binary", learning_rate=0.05, num_leaves=63, min_data_in_leaf=100, feature_fraction=0.8,
11
+ bagging_fraction=0.8, bagging_freq=1, verbose=-1)
12
+
13
+
14
+ def load(path):
15
+ df = pl.read_parquet(path).sort(["repo", "t"])
16
+ # repo base rate from the repo's OWN past only (expanding mean, shifted): computable from local git at inference
17
+ df = df.with_columns(repo_rate=((pl.col("y").cum_sum().shift(1, fill_value=0) + 1) / (pl.int_range(pl.len()) + 4)).over("repo"))
18
+ return df.with_columns(
19
+ **{f"l_{c}": pl.col(c).cast(pl.Float64).log1p() for c in ["nfiles", "la", "ld", "hunks", "a_prior_n", "a_days"]},
20
+ hour=(pl.col("t") // 3600) % 24, dow=(pl.col("t") // 86400) % 7,
21
+ fold=pl.col("repo").map_elements(lambda r: int(hashlib.md5(r.encode()).hexdigest(), 16) % 5, return_dtype=pl.Int64))
22
+
23
+
24
+ if __name__ == "__main__":
25
+ df = load(sys.argv[1])
26
+ X, y, t = df.select(HAND).to_numpy(), df["y"].to_numpy(), df["t"].to_numpy()
27
+ folds, repos, la = df["fold"].to_numpy(), df["repo"].to_numpy(), df["la"].to_numpy().astype(float)
28
+ p = np.zeros(len(y))
29
+ for k in range(5):
30
+ te = folds == k; tr_all = ~te
31
+ cut = np.quantile(t[tr_all], 0.85); tr = tr_all & (t < cut); va = tr_all & (t >= cut) # temporal early-stop split
32
+ m = lgb.train(PARAMS, lgb.Dataset(X[tr], y[tr]), 2000, valid_sets=[lgb.Dataset(X[va], y[va])],
33
+ callbacks=[lgb.early_stopping(50, verbose=False)])
34
+ p[te] = m.predict(X[te])
35
+ ok = [r for r in set(repos) if 0 < y[repos == r].mean() < 1]
36
+ a_la = {r: roc_auc_score(y[repos == r], la[repos == r]) for r in ok}
37
+ a_m = {r: roc_auc_score(y[repos == r], p[repos == r]) for r in ok}
38
+ print(f"{len(y)} commits, {len(ok)} repos, inducing rate {y.mean():.1%}")
39
+ print(f"{'method':<12}{'pooled AUC':>11}{'median repo AUC':>17}{'repos beating LA by 0.02':>26}")
40
+ print(f"{'LA rule':<12}{roc_auc_score(y, la):>11.3f}{np.median(list(a_la.values())):>17.3f}")
41
+ print(f"{'GBM hand':<12}{roc_auc_score(y, p):>11.3f}{np.median(list(a_m.values())):>17.3f}"
42
+ f"{np.mean([a_m[r] > a_la[r] + 0.02 for r in ok]):>26.0%}")
build.py ADDED
@@ -0,0 +1,101 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ """Multi-repo SZZ dataset from git alone. Per repo: clone -> labels + features + diff text -> parquet -> delete clone.
2
+
3
+ Label: commit is bug-inducing if a later fix commit's removed lines blame to it (SZZ, ag-szz style w/o refactoring filter).
4
+ Labelable window: [oldest scanned fix, newest commit - CENSOR_DAYS] (all fixes after the commit were scanned).
5
+ Usage: python build.py repos.txt [parallel]
6
+ """
7
+ import hashlib, re, subprocess, sys, tempfile, time
8
+ from collections import defaultdict
9
+ from multiprocessing import Pool
10
+ from pathlib import Path
11
+ import polars as pl
12
+
13
+ FIX = re.compile(r"\b(fix(es|ed)?|bug|bugfix|hotfix|regression|crash|segfault|leak|race|deadlock|overflow)\b", re.I)
14
+ NOISE = re.compile(r"\b(typo|lint|format|formatting|style|whitespace|docs?|readme|comments?|spelling|ci|build|compile|"
15
+ r"warnings?|tests?|flaky|chore|revert|merge|bump|deps?|dependenc\w+|upgrade|version)\b", re.I)
16
+ HUNK = re.compile(r"^@@ -(\d+)(?:,(\d+))? \+(\d+)(?:,(\d+))? @@", re.M)
17
+ TEST = re.compile(r"(^|/)(tests?|spec|__tests__|testing)(/|$)|[._-](test|spec)\.|_test\.go$", re.I)
18
+ CAP_FIX_FILES, CAP_FIX_DEL, CAP_TEXT, CENSOR_DAYS, MIN_COMMITS, LABEL_DAYS = 10, 200, 8000, 180, 2000, 365
19
+ is_fix = lambda subj: bool(FIX.search(subj)) and not NOISE.search(subj)
20
+ OUT = Path(__file__).parent / "data"
21
+
22
+
23
+ def git(d, *a):
24
+ return subprocess.run(["git", "-C", d, *a], capture_output=True, text=True, errors="replace", timeout=900).stdout
25
+
26
+
27
+ def build(repo: str):
28
+ out = OUT / (repo.replace("/", "__") + ".parquet")
29
+ if out.exists():
30
+ return f"{repo}: cached"
31
+ d = tempfile.mkdtemp(); t0 = time.time()
32
+ try:
33
+ for attempt in range(2):
34
+ c = subprocess.run(["git", "clone", "-q", "--bare", f"https://github.com/{repo}", d], capture_output=True, text=True, timeout=1800)
35
+ if c.returncode == 0:
36
+ break
37
+ subprocess.run(["rm", "-rf", d]); time.sleep(30)
38
+ else:
39
+ return f"{repo}: CLONE FAILED: {c.stderr.strip()[:200]}"
40
+ raw = git(d, "log", "--all", "--no-merges", "--format=%x00%H%x01%ae%x01%at%x01%s", "--name-only")
41
+ commits = []
42
+ for rec in raw.split("\x00")[1:]:
43
+ head, _, files = rec.partition("\n")
44
+ sha, email, at, subj = head.split("\x01", 3)
45
+ commits.append((sha, email, int(at), subj, [f for f in files.split("\n") if f]))
46
+ if len(commits) < MIN_COMMITS:
47
+ return f"{repo}: skipped ({len(commits)} commits)"
48
+ commits.sort(key=lambda c: c[2])
49
+ fixes = [c for c in commits if is_fix(c[3]) and 0 < len(c[4]) <= CAP_FIX_FILES]
50
+ inducing = {} # sha -> earliest fix time
51
+ for sha, _, ft, _, files in fixes:
52
+ hunks = []
53
+ for f in files:
54
+ if TEST.search(f):
55
+ continue # fixes to tests don't blame production bugs
56
+ hunks += [(f, int(m.group(1)), int(m.group(2) or 1)) for m in HUNK.finditer(git(d, "diff", "-U0", f"{sha}^", sha, "--", f))]
57
+ if not 0 < sum(n for _, _, n in hunks) <= CAP_FIX_DEL:
58
+ continue # pure additions carry no blame; huge deletions are refactors, not fixes
59
+ for f, a, n in hunks:
60
+ if n:
61
+ blame = git(d, "blame", "--porcelain", "-w", "-L", f"{a},{a + n - 1}", f"{sha}^", "--", f)
62
+ for l in blame.split("\n"):
63
+ if re.match(r"^[0-9a-f]{40} ", l):
64
+ b = l.split()[0]; inducing[b] = min(inducing.get(b, ft), ft)
65
+ t_lo, t_hi = fixes[0][2], commits[-1][2] - CENSOR_DAYS * 86400
66
+ rows, seen = [], defaultdict(lambda: [0, 0, None]) # author -> [n, n_inducing, first_t]
67
+ for sha, email, at, subj, files in commits:
68
+ n, p, first = seen[email]
69
+ labelable = t_lo <= at <= t_hi and bool(files) and not is_fix(subj)
70
+ y = int(sha in inducing and inducing[sha] - at <= LABEL_DAYS * 86400)
71
+ if labelable:
72
+ diff = git(d, "show", "--format=", "-U0", "--no-color", sha)
73
+ added = [l[1:] for l in diff.split("\n") if l.startswith("+") and not l.startswith("+++")]
74
+ deleted = sum(1 for l in diff.split("\n") if l.startswith("-") and not l.startswith("---"))
75
+ rows.append(dict(
76
+ repo=repo, sha=sha, t=at, author=hashlib.sha1(email.encode()).hexdigest()[:16], subj=subj,
77
+ nfiles=len(files), la=len(added), ld=deleted, hunks=len(HUNK.findall(diff)),
78
+ ndirs=len({f.rsplit("/", 1)[0] if "/" in f else "" for f in files}),
79
+ nexts=len({f.rsplit(".", 1)[-1] if "." in f.rsplit("/", 1)[-1] else "" for f in files}),
80
+ test_ratio=sum(bool(TEST.search(f)) for f in files) / len(files),
81
+ a_prior_n=n, a_prior_rate=(p + 1) / (n + 4), a_days=(at - first) / 86400 if first else 0.0,
82
+ msg_len=len(subj), msg_ref=int(bool(re.search(r"#\d+", subj))),
83
+ text=(subj + "\n" + " ".join(files) + "\n" + "\n".join(added))[:CAP_TEXT], y=y))
84
+ seen[email] = [n + 1, p + y, first or at]
85
+ if not rows:
86
+ return f"{repo}: skipped (no labelable commits)"
87
+ pl.DataFrame(rows).write_parquet(out)
88
+ ys = sum(r["y"] for r in rows)
89
+ return f"{repo}: {len(commits)} commits, {len(fixes)} fixes, {len(rows)} labeled, {ys} inducing ({ys / max(len(rows), 1):.1%}), {time.time() - t0:.0f}s"
90
+ except Exception as e:
91
+ return f"{repo}: ERROR {e!r}"
92
+ finally:
93
+ subprocess.run(["rm", "-rf", d])
94
+
95
+
96
+ if __name__ == "__main__":
97
+ OUT.mkdir(exist_ok=True)
98
+ repos = [r.strip() for r in open(sys.argv[1]) if r.strip()]
99
+ with Pool(int(sys.argv[2]) if len(sys.argv) > 2 else 4) as pool:
100
+ for msg in pool.imap_unordered(build, repos):
101
+ print(msg, flush=True)
commits.parquet ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ version https://git-lfs.github.com/spec/v1
2
+ oid sha256:0463ed5ee01ec3b5ba68a986f37fbaaa9fe14ad5c818ace7778b6585e7b1e80d
3
+ size 20707108
repos.txt ADDED
@@ -0,0 +1,72 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ boykopovar/AnyPS5
2
+ AdguardTeam/AdGuardHome
3
+ microsoft/WSL
4
+ gitroomhq/postiz-app
5
+ SerenityOS/serenity
6
+ date-fns/date-fns
7
+ ValveSoftware/Proton
8
+ drizzle-team/drizzle-orm
9
+ dragonflydb/dragonfly
10
+ agentscope-ai/QwenPaw
11
+ facebook/folly
12
+ lissy93/web-check
13
+ gabime/spdlog
14
+ NginxProxyManager/nginx-proxy-manager
15
+ dmlc/xgboost
16
+ pear-devs/pear-desktop
17
+ taichi-dev/taichi
18
+ Yeachan-Heo/oh-my-codex
19
+ microsoft/winget-cli
20
+ immutable-js/immutable-js
21
+ changkun/modern-cpp-tutorial
22
+ floating-ui/floating-ui
23
+ Niko1221/Strata
24
+ refined-github/refined-github
25
+ simdjson/simdjson
26
+ codex-team/editor.js
27
+ Tencent/ncnn
28
+ ReactiveX/rxjs
29
+ pqrs-org/Karabiner-Elements
30
+ nanocoai/nanoclaw
31
+ catchorg/Catch2
32
+ VectifyAI/PageIndex
33
+ RPCS3/rpcs3
34
+ sqlmapproject/sqlmap
35
+ swoole/swoole-src
36
+ searxng/searxng
37
+ wled/WLED
38
+ PDFMathTranslate/PDFMathTranslate
39
+ doitsujin/dxvk
40
+ babysor/MockingBird
41
+ lapce/lapce
42
+ hankcs/HanLP
43
+ firecracker-microvm/firecracker
44
+ microsoft/graphrag
45
+ jdx/mise
46
+ geekcomputers/Python
47
+ fish-shell/fish-shell
48
+ dgtlmoon/changedetection.io
49
+ google/comprehensive-rust
50
+ huggingface/diffusers
51
+ zeroclaw-labs/zeroclaw
52
+ python-poetry/poetry
53
+ lbjlaq/Antigravity-Manager
54
+ nicolargo/glances
55
+ jj-vcs/jj
56
+ 0xAX/linux-insides
57
+ ankitects/anki
58
+ agentscope-ai/agentscope
59
+ iced-rs/iced
60
+ fishaudio/fish-speech
61
+ influxdata/influxdb
62
+ hsliuping/TradingAgents-CN
63
+ sunface/rust-course
64
+ openai/openai-python
65
+ BloopAI/vibe-kanban
66
+ Lightning-AI/pytorch-lightning
67
+ xai-org/grok-build
68
+ encode/django-rest-framework
69
+ clockworklabs/SpacetimeDB
70
+ Genesis-Embodied-AI/genesis-world
71
+ uutils/coreutils
72
+ SagerNet/sing-box