File size: 9,340 Bytes
907001b
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
---
license: other
license_name: mixed-permissive-per-row
license_link: https://huggingface.co/datasets/BlazingCustoms/pybytecode-csn-3.12-licensed/blob/main/NOTICES.md
task_categories:
  - text-generation
language:
  - en
tags:
  - decompilation
  - python
  - bytecode
  - code
  - reverse-engineering
size_categories:
  - n<1K
configs:
  - config_name: default
    data_files: bench.jsonl
---

# Data card — CSN-3.12-licensed decompilation benchmark

600 real Python functions from GitHub, compiled to Python 3.12 bytecode, each paired with the
source that produced it. Every row carries full provenance and a licence resolved at the exact
commit. Built 2026-08-04 by `tools/build_csn_licensed.py`.

**Redistributable**, provided `NOTICES.md` ships alongside. That file is not optional: MIT, BSD
and Apache-2.0 require the notice to travel with the copy.

---

## The set

| | |
|---|---|
| Rows | **600** |
| Source repositories | **117** |
| Max rows from any one repo | **6 (1.00%)** |
| Median rows per repo | 6 |
| Distinct commit SHAs | 117 |
| Rows with complete provenance | 600 / 600 |
| Rows with a resolved SPDX identifier | 600 / 600 |
| Disassembly length | mean 87.3 lines, median 59, max 1,622 |
| Rows with annotations | 63 |
| Python | 3.12, `optimize=0` |

Licences, all resolved at the row's own commit:

| SPDX | rows | share |
|---|---:|---:|
| MIT | 391 | 65.2% |
| BSD-3-Clause | 118 | 19.7% |
| Apache-2.0 | 64 | 10.7% |
| BSD-2-Clause | 15 | 2.5% |
| ISC | 12 | 2.0% |

### Why this replaces the previous 400-row set

The first CSN benchmark drew 400 rows from **24** repositories with **15% from one**
(`Karaage-Cluster/python-tldap`), recorded no commit SHA, and captured no licence. Auditing it
afterwards: **180 of its 400 rows (45%) cannot be redistributed** — 83 GPL-3.0 (including all 60
from that top repository) and 97 from repositories publishing no licence at all. Concentration at
that level also means per-repository idiosyncrasy was a large fraction of what the benchmark
measured. Details in `../../LICENSING-DETERMINATION.md` §2.

The cap was set at 6 rows per repo — about 1% of the set — chosen so that no single codebase can
move the headline number by more than a rounding error, while still admitting enough rows per
repo to be worth resolving a licence for. At n=600 the 95% confidence interval on an accuracy
near 93% is roughly ±2.0 points, against ±2.5 at n=400.

---

## Per-row fields

```jsonc
{
  "i": 0,
  "input":  "CODE <module>()\n  RESUME 0\n ...",   // model input: normalised disassembly
  "expected": "def f(x):\n    ...",                 // reference source
  "src_path": "src/00000.py",                       // RELATIVE to this directory
  "pyc_path": "pyc/00000.pyc",
  "provenance": {
    "repo": "owner/name",
    "repo_url": "https://github.com/owner/name",
    "file_path": "pkg/module.py",                   // path within the repo
    "commit_sha": "1b38e7cd...",                    // the commit the function was taken at
    "func_name": "Class.method",
    "line_start": 323, "line_end": 372,
    "permalink": "https://github.com/.../blob/<sha>/pkg/module.py#L323-L372",
    "dataset": "code-search-net/code_search_net (python, train split)"
  },
  "license": {
    "spdx": "BSD-3-Clause",
    "file": "LICENSE", "blob_sha": "3d9cc0c2...",
    "resolved_at_commit": "1b38e7cd...",
    "resolved_via": "GitHub GET /repos/{repo}/license?ref={sha}"
  },
  "n_instr": 49, "has_annotation": false
}
```

Paths are relative, so the set works from any checkout location. Nothing points at `/tmp`.

## How rows were selected

Source: `code-search-net/code_search_net`, python train split, read in file order from a local
parquet copy (`tools/fetch_csn.sh`; sha256
`ad9e3a4ab10c2c1d8926d2b26ca2bfcc3aadda1477ba29a933391f93806b9fed`).

3,138 rows were read to keep 600. In order:

| Gate | Effect |
|---|---|
| Repo cap (6) | 1,838 rows skipped — the mechanism that spreads the set across 117 repos |
| Repo blacklisted on licence | 668 rows skipped, from the 25 repos rejected below |
| **Licence not permissive / not resolvable** | **25 repos rejected** |
| Train-contamination (identifier-blind fingerprint) | 3 rows dropped |
| Unparseable | 4 rows dropped |

Repos rejected on licence: GPL-3.0 ×8, no licence file at that commit ×7, AGPL-3.0 ×3,
LGPL-3.0 ×2, GPL-2.0 ×2, `NOASSERTION` ×2, LGPL-2.1 ×1.

**A licence is resolved, never guessed.** `GET /repos/{owner}/{repo}/license?ref={sha}` must
return a concrete SPDX identifier on the allowlist (`tools/resolve_licenses.py:ALLOWED_SPDX`).
`NOASSERTION` and `Other` count as unresolved and the row is dropped. We never infer a licence
from a README, a `setup.py` classifier, or a package index.

## Normalisation

Each function is reduced to a normal form before compiling: every docstring is replaced by the
literal `'pass'`, then the tree is re-emitted with `ast.unparse`. Idempotence is checked per row
and a row that is not a fixed point is dropped.

This build uses `tools/normalize.py`, a stdlib-only implementation. **The GPL-3.0 tool that built
the previous benchmark is not in this pipeline.** The two agree byte-for-byte on 400/400 rows of
the previous benchmark (`tools/verify_equivalence.py`); the reasoning is in
`../../LICENSING-DETERMINATION.md` §1.

Because docstrings are normalised away, **this benchmark measures nothing about docstring
recovery**`samples_with_real_docstring` is 0 by construction. Use the held-out set for that.

## Compilation

`py_compile` at `optimize=0` for the reference `.pyc`, and `compile(..., dont_inherit=True,
optimize=0)` for the model's input. `dont_inherit` is deliberate: the training corpus was
compiled with PEP-563 stringised annotations inherited, and real `.pyc` files are not. Handing
the model its training-time distribution would flatter it, so we do not. See
`../../DATA-CARD-training-corpus.md` §7.

## Harness soundness on this set

`grade.py --self-test-only`: pre-flight **600/600 = 100%**, mutation kill rate **116/116 = 100%**,
0 survivors. Both are prerequisites for quoting any score — but note that **pre-flight is trivial
by construction and proves nothing about soundness** (it compares `compile(x)` with `compile(x)`).
See `../../ORACLE-LIMITS.md` §1.

## Unit size — read this before comparing scores against another benchmark

An aggregate on this set is largely a statement about **small units**, so the size distribution is
part of the result rather than a footnote to it. Size is measured in **representation lines** —
the number of lines in the `input` field, i.e. the disassembly text a model is actually given.

| min | p25 | median | p75 | p90 | p99 | max |
|---|---|---|---|---|---|---|
| 19 | 39 | **59** | 101 | 167 | 478 | 1,622 |

Certification falls off sharply with size (v3 greedy, this set; intervals omitted below 30 rows /
10 repositories rather than printed at a misleading width):

| rep lines | rows | v3 greedy | 95% CI | v3 best-of-32 | 95% CI |
|---|---|---|---|---|---|
| 0–49 | 224 | 95.98% | [93.01, 98.51] | 98.21% | [96.31, 99.58] |
| 50–99 | 224 | 89.73% | [85.17, 93.93] | 98.21% | [96.26, 99.57] |
| 100–199 | 112 | 65.18% | [55.36, 74.14] | 85.71% | [77.57, 92.98] |
| 200–299 | 27 | 51.85% | — | 77.78% | — |
| 300–399 | 5 | 60.00% | — | 100.00% | — |
| 400–599 | 5 | 0.00% | — | 0.00% | — |
| 600+ | 3 | 0.00% | — | 0.00% | — |

**96.64%** of v3's greedy certifications on this set (95.37% at best-of-32) come from units under
200 rep lines, and above ~400 rep lines nothing certified even at 32 samples. The
300–399 bucket reading above the one below it is n=5 noise, not a recovery. Recompute all of it
with `harness/size_curve.py`; the stored output is `../../results/size_curve_csn600.json`.

## Limitations

- **Measured scores (2026-08-04, L1 strict oracle):** PyBytecode v3 greedy
  **506/600 = 84.33%**, repo-clustered 95% CI [80.48, 87.94]; verified best-of-32
  **562/600 = 93.67%**, CI [90.86, 96.08]. Untuned `Qwen2.5-Coder-1.5B-Instruct` control:
  **4/600 = 0.67%**, CI [0.16, 1.35]. Per-row verdicts: `../../results/rows_with_base.jsonl`.
- GitHub's licence detection is repository-level. A repository can vendor third-party files under
  other terms; we do not detect that, and no automated tool reliably does.
- A licence resolved at a commit is the licence *of that repository snapshot*. It does not prove
  the specific file was contributed under it.
- CodeSearchNet is a 2019-era snapshot, so the code skews toward pre-3.7 idiom. It contains no
  `match` statements, no walrus operators, and few modern typing constructs.
- Rows are capped, not sampled uniformly at random: the set is the first 6 admissible functions
  per repository in dataset order. That is reproducible and unbiased with respect to difficulty,
  but it is not a random sample of Python.
- 117 repositories is enough to defeat single-repo dominance; it is not a representative sample
  of the language ecosystem.

## Provenance and licence of this benchmark

Derived from CodeSearchNet (`code-search-net/code_search_net`). The underlying functions remain
under their original licences and copyright, listed per row and reproduced in full in
`NOTICES.md` (117 repositories, 272 KB of licence text). The assembly, normalisation and
disassembly are ours.