Datasets:
Ingot v1.2: human Zig pushed 2026-10-15..11-28 (verified 187M -> 437M tokens); decontam vs zig.valid; misses fixed (see changelog)
Browse files- README.md +37 -14
- data/built/train-00000-of-00001.parquet +2 -2
- data/compiled/train-00000-of-00001.parquet +2 -2
- data/langref/train-00000-of-00001.parquet +1 -1
- data/ore/train-00000-of-00001.parquet +2 -2
- data/repo/train-00000-of-00001.parquet +2 -2
- data/slag/train-00000-of-00001.parquet +2 -2
- data/std/train-00000-of-00001.parquet +1 -1
- data/tested/train-00000-of-00001.parquet +2 -2
- repos.json +0 -0
- stats.json +133 -103
- tools/collect_gh.py +30 -0
- tools/d2s.py +1 -1
- tools/d2s_run.sh +3 -1
- tools/ingot_harvest.py +46 -18
- tools/package.py +28 -1
- tools/package_pools.py +52 -19
- tools/pool_bench_filter.py +16 -0
- tools/run_delta.sh +20 -0
- tools/v11_input.py +12 -0
- tools/watchdog.sh +8 -0
README.md
CHANGED
|
@@ -46,9 +46,9 @@ Zig's API changes with every release, so most Zig on the web no longer compiles.
|
|
| 46 |
|
| 47 |
| pool | quality | configs | ≈ tokens | use it for |
|
| 48 |
|---|---|---|---:|---|
|
| 49 |
-
| **Ingot** | ✅ **Verified** on Zig 0.17.0 | `tested` `built` `compiled` `std` `langref` (+ `repo`) | **
|
| 50 |
-
| **Ore** | ⚠️ **Unverified**. Probably modern Zig, but could not be checked | `ore` |
|
| 51 |
-
| **Slag** | ❌ **Known broken** on 0.17, compiler error attached | `slag` |
|
| 52 |
|
| 53 |
The pools never overlap. No Ore or Slag row duplicates an Ingot row. All three share the same license, cleaning and benchmark hold-out rules.
|
| 54 |
|
|
@@ -69,28 +69,48 @@ Each file passed one of these checks on Zig 0.17.0 (x86_64-linux). They are list
|
|
| 69 |
|
| 70 |
| config | check passed | rows | repos | ≈ tokens |
|
| 71 |
|---|---|---:|---:|---:|
|
| 72 |
-
| `tested` | the repo builds **and** its own tests pass (`zig build test`) |
|
| 73 |
-
| `built` | the repo builds (`zig build`) |
|
| 74 |
-
| `compiled` | the repo's build failed, but this file **and every file it imports** pass a per-file type check |
|
| 75 |
| `std` | the official Zig 0.17.0 standard library | 538 | 1 | 5M |
|
| 76 |
| `langref` | the official language-reference examples, each behaving exactly as documented (passes, or fails with the stated error) | 285 | 1 | — |
|
| 77 |
-
| `repo` | the three tiers above, regrouped into one document per repo with files in import order (same text, so not counted twice) |
|
| 78 |
|
| 79 |
## Ore: unverified
|
| 80 |
|
| 81 |
These files come from repos whose build failed, and the per-file check could not analyse them. The `gate` field says why:
|
| 82 |
-
- `env`: the file needs a module defined in the repo's `build.zig`, that the check could not supply (
|
| 83 |
-
- `unchecked`: the file imports a file that fails to parse (
|
| 84 |
-
- `dep`: the file imports a repo file that did not pass (
|
|
|
|
| 85 |
|
| 86 |
-
Most of this is likely valid modern Zig, but it is **not proven**.
|
| 87 |
|
| 88 |
## Slag: known broken
|
| 89 |
|
| 90 |
-
The type check **proved** these do not compile on 0.17.0. Most were written for older Zig, using APIs such as `Build.args`, `root_source_file` and managed `ArrayList`. Each row's `gate_error` holds the compiler's error message. That makes the pool raw material for migration work, such as teaching a model to port old Zig to 0.17. Do not train on it as ordinary code: it teaches stale APIs.
|
| 91 |
|
| 92 |
## Changelog
|
| 93 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 94 |
- **v1.1 (2026-10-29):** verified pool 175M → 187M tokens (+7%).
|
| 95 |
- 49 repos whose builds had failed on dependency downloads now build. The causes were a `.zip` archive saved under the wrong extension, git dependencies not fetched at their pinned commit, and submodules that broke the declared hash. Those repos moved up whole into `built`/`tested`.
|
| 96 |
- The per-file check now supplies modules declared in each repo's `build.zig`: 1,049 more files verified, and 1,106 files proven broken that had been hidden as unverified. Some `compiled` files moved to `built` or `slag` as a result.
|
|
@@ -129,19 +149,22 @@ Most failures are 0.17 API changes, which is exactly what Ingot targets. The tas
|
|
| 129 |
|
| 130 |
## How it was built
|
| 131 |
|
| 132 |
-
1. **Sources.** About 2,900 permissively licensed Zig repos from GitHub, Codeberg and GitLab, each cloned fresh at a pinned commit.
|
| 133 |
2. **Build check.** Each repo was run through `zig build` and, when it has tests, `zig build test` with Zig 0.17.0.
|
| 134 |
3. **Per-file type check**, for repos that don't build. Nothing is executed. It parse-checks every file, then type-checks each one together with the containers declared inside it. A planted error in every compile proves the type check actually ran. An error Zig reports inside std is charged to the file that caused it. A file passes only if every repo file it imports also passes.
|
| 135 |
4. **Cleaning.** This removes generated code, data tables, vendored copies (including forks found by content), fixtures written to fail, secrets, files over 400 KB, files using std APIs removed in 0.17, and overlap with the benchmark. Exact and near duplicates go too.
|
| 136 |
5. **License.** Only permissive licenses are kept, with every license text re-checked. Files whose own header says GPL, or that were ported from GPL code, are dropped. MPL-2.0 and UPL-1.0 are kept and labelled.
|
| 137 |
|
| 138 |
-
Three independent adversarial audits tried to break these checks and the grader. Everything they found is fixed. The scripts in `tools/` rebuild the whole dataset for any Zig release (`ZIG=/path/to/zig ./tools/resmelt.sh`).
|
| 139 |
|
| 140 |
## Limits
|
| 141 |
|
| 142 |
- Everything was checked on x86_64-linux only, so some OS-specific files may be missing from `compiled`.
|
| 143 |
- `built` means the repo's default build step compiled. Files the build never touches are not individually proven.
|
| 144 |
- The per-file check does not force private declarations, uninstantiated generics or non-generic `inline fn` bodies.
|
|
|
|
|
|
|
|
|
|
| 145 |
- File headers keep their authors' names and e-mail addresses as written.
|
| 146 |
- Run graded answers in a sandbox; they are untrusted code.
|
| 147 |
|
|
|
|
| 46 |
|
| 47 |
| pool | quality | configs | ≈ tokens | use it for |
|
| 48 |
|---|---|---|---:|---|
|
| 49 |
+
| **Ingot** | ✅ **Verified** on Zig 0.17.0 | `tested` `built` `compiled` `std` `langref` (+ `repo`) | **437M** | training and fine-tuning |
|
| 50 |
+
| **Ore** | ⚠️ **Unverified**. Probably modern Zig, but could not be checked | `ore` | 617M | extra pretraining volume, mixed in carefully |
|
| 51 |
+
| **Slag** | ❌ **Known broken** on 0.17, compiler error attached | `slag` | 230M | migration research (old → new). **Not** for plain training |
|
| 52 |
|
| 53 |
The pools never overlap. No Ore or Slag row duplicates an Ingot row. All three share the same license, cleaning and benchmark hold-out rules.
|
| 54 |
|
|
|
|
| 69 |
|
| 70 |
| config | check passed | rows | repos | ≈ tokens |
|
| 71 |
|---|---|---:|---:|---:|
|
| 72 |
+
| `tested` | the repo builds **and** its own tests pass (`zig build test`) | 30,153 | 1,277 | 119M |
|
| 73 |
+
| `built` | the repo builds (`zig build`) | 41,208 | 874 | 207M |
|
| 74 |
+
| `compiled` | the repo's build failed, but this file **and every file it imports** pass a per-file type check | 33,224 | 2,215 | 106M |
|
| 75 |
| `std` | the official Zig 0.17.0 standard library | 538 | 1 | 5M |
|
| 76 |
| `langref` | the official language-reference examples, each behaving exactly as documented (passes, or fails with the stated error) | 285 | 1 | — |
|
| 77 |
+
| `repo` | the three tiers above, regrouped into one document per repo with files in import order (same text, so not counted twice) | 4,228 | 4,228 | — |
|
| 78 |
|
| 79 |
## Ore: unverified
|
| 80 |
|
| 81 |
These files come from repos whose build failed, and the per-file check could not analyse them. The `gate` field says why:
|
| 82 |
+
- `env`: the file needs a module defined in the repo's `build.zig`, that the check could not supply (38.5k rows; the check wires in modules declared in the repo's own `build.zig`, so most remaining cases need an external package)
|
| 83 |
+
- `unchecked`: the file imports a file that fails to parse (23.1k rows)
|
| 84 |
+
- `dep`: the file imports a repo file that did not pass (27.2k rows)
|
| 85 |
+
- `timeout`: the check ran out of time on this file or its whole repo (32.8k rows; v1.2 caps the check at 240 s per compile and 600 s per repo, so most of these come from a few very large repos)
|
| 86 |
|
| 87 |
+
Most of this is likely valid modern Zig, but it is **not proven**. 121,602 rows from 2,384 repos.
|
| 88 |
|
| 89 |
## Slag: known broken
|
| 90 |
|
| 91 |
+
The type check **proved** these do not compile on 0.17.0. Most were written for older Zig, using APIs such as `Build.args`, `root_source_file` and managed `ArrayList`. Each row's `gate_error` holds the compiler's error message. That makes the pool raw material for migration work, such as teaching a model to port old Zig to 0.17. Do not train on it as ordinary code: it teaches stale APIs. 28,278 rows from 2,400 repos.
|
| 92 |
|
| 93 |
## Changelog
|
| 94 |
|
| 95 |
+
- **v1.2 (2026-11-30):** human Zig written since v1.1 harvested. Verified pool 187M → 437M tokens (×2.3); Ore 199M → 617M; Slag 79M → 230M.
|
| 96 |
+
- Sources: every GitHub repo with `language:Zig` pushed between 2026-10-15 and 2026-11-28 (6,556, found by half-day search slices, none at the 1,000-result cap). Of those, 3,466 have a permissive licence in metadata and aren't archived. 234 repos already in v1.1 that hadn't moved were skipped, which left 3,232 to harvest. 86 Codeberg/GitLab repos from v1.1 had moved, so 3,318 were harvested in total. Every row still records host, repo and pinned commit.
|
| 97 |
+
- When a repo moved since v1.1, a newer verified copy of a file replaces its v1.1 row (3,463 v1.1 rows superseded). Files that are unchanged keep their v1.1 row. A delta copy of a v1.1 file loses deduplication to the v1.1 row.
|
| 98 |
+
- Decontamination now also covers the 204 documents of Babel's `zig.valid` and ZigEval-lite, alongside Ingot-Bench, using the same rare-13-gram rule. Ingot-Bench v1 is unchanged.
|
| 99 |
+
- **Misses found and fixed:**
|
| 100 |
+
- **126 v1.1 Ingot rows** (and 34 Ore, 30 Slag) overlapped an eval set. Most overlapped Babel's held-out `zig.valid`; v1.1 had not checked against it. They are removed.
|
| 101 |
+
- **78 Ingot rows and 62 pool rows** contained an Ingot-Bench reference body verbatim. A new rule drops them.
|
| 102 |
+
- **Harvester bugs** that silently dropped repos or failed their builds:
|
| 103 |
+
- a `licenses/` directory crashed the copy step;
|
| 104 |
+
- dangling `.zig` symlinks crashed it;
|
| 105 |
+
- repos with no `.zig` file at the root crashed the licence copy;
|
| 106 |
+
- parallel jobs raced on a shared dependency cache.
|
| 107 |
+
- **Zig 0.17.0/0.17.1 bug worked around.** `zig fetch` of a tarball with one top-level directory stores the cache entry unstripped, so every later build hash-mismatches. The harvester now unpacks tarball dependencies itself, prefetches every declared dependency up front, and deletes poisoned cache entries.
|
| 108 |
+
- **Not done in v1.2:**
|
| 109 |
+
- 2,130 repos with no licence in metadata and 309 marked NOASSERTION were not harvested.
|
| 110 |
+
- New Codeberg repos are missing: the search API returned 429 during the harvest.
|
| 111 |
+
- 23 repos over 300 MB were recorded but not cloned.
|
| 112 |
+
- 20 repos hit the 8-minute harvest cap.
|
| 113 |
+
- Builds and tests were capped at 120 s each for the last ~1,900 repos (240/300 s before that). A slow repo can land in `compiled`/Ore instead of `built`/`tested`.
|
| 114 |
- **v1.1 (2026-10-29):** verified pool 175M → 187M tokens (+7%).
|
| 115 |
- 49 repos whose builds had failed on dependency downloads now build. The causes were a `.zip` archive saved under the wrong extension, git dependencies not fetched at their pinned commit, and submodules that broke the declared hash. Those repos moved up whole into `built`/`tested`.
|
| 116 |
- The per-file check now supplies modules declared in each repo's `build.zig`: 1,049 more files verified, and 1,106 files proven broken that had been hidden as unverified. Some `compiled` files moved to `built` or `slag` as a result.
|
|
|
|
| 149 |
|
| 150 |
## How it was built
|
| 151 |
|
| 152 |
+
1. **Sources.** About 2,900 permissively licensed Zig repos in v1.0/v1.1, plus 3,318 repos pushed between 2026-10-15 and 2026-11-28 in v1.2, from GitHub, Codeberg and GitLab, each cloned fresh at a pinned commit.
|
| 153 |
2. **Build check.** Each repo was run through `zig build` and, when it has tests, `zig build test` with Zig 0.17.0.
|
| 154 |
3. **Per-file type check**, for repos that don't build. Nothing is executed. It parse-checks every file, then type-checks each one together with the containers declared inside it. A planted error in every compile proves the type check actually ran. An error Zig reports inside std is charged to the file that caused it. A file passes only if every repo file it imports also passes.
|
| 155 |
4. **Cleaning.** This removes generated code, data tables, vendored copies (including forks found by content), fixtures written to fail, secrets, files over 400 KB, files using std APIs removed in 0.17, and overlap with the benchmark. Exact and near duplicates go too.
|
| 156 |
5. **License.** Only permissive licenses are kept, with every license text re-checked. Files whose own header says GPL, or that were ported from GPL code, are dropped. MPL-2.0 and UPL-1.0 are kept and labelled.
|
| 157 |
|
| 158 |
+
Three independent adversarial audits tried to break these checks and the grader in v1.0. Everything they found is fixed. v1.2 was self-audited, not independently. Re-running the per-file check from scratch on 10 random repos reproduced all 187 verdicts. Seeded reads, licence-text scans and a bench-body leak scan were also run. An independent audit of v1.2 is still open. The scripts in `tools/` rebuild the whole dataset for any Zig release (`ZIG=/path/to/zig ./tools/resmelt.sh`).
|
| 159 |
|
| 160 |
## Limits
|
| 161 |
|
| 162 |
- Everything was checked on x86_64-linux only, so some OS-specific files may be missing from `compiled`.
|
| 163 |
- `built` means the repo's default build step compiled. Files the build never touches are not individually proven.
|
| 164 |
- The per-file check does not force private declarations, uninstantiated generics or non-generic `inline fn` bodies.
|
| 165 |
+
- Builds and tests ran as root inside the disposable harvest VM. One repo's test suite bind-mounted a file there; nothing ran outside the VM.
|
| 166 |
+
- A repo that moved since v1.1 can have rows from two commits: v1.2 files at the new commit, plus v1.1 files that no longer exist upstream at the old one. Each row's `commit` says which. The `repo` document of such a repo mixes both commits.
|
| 167 |
+
- Token counts are estimates from bytes (3.27 bytes/token of the 4,096-entry Zig BPE), not a tokenizer pass.
|
| 168 |
- File headers keep their authors' names and e-mail addresses as written.
|
| 169 |
- Run graded answers in a sandbox; they are untrusted code.
|
| 170 |
|
data/built/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:bfd41470e4a14f2e7e15853f6f090ca398e068411ca6cf2e19846dc3e3cb80c2
|
| 3 |
+
size 164257245
|
data/compiled/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:054d3fbacdec73fe53378f1da6535d7b015fb18097f4a33237e1ecc4aa8f102c
|
| 3 |
+
size 89847839
|
data/langref/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 70542
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:4386abc8a9069f848a4249ddf9cd4ea3e474379bea0a3e75d186030b6c8af7e1
|
| 3 |
size 70542
|
data/ore/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1924956189d30ea6443b64ce6d56e3b0b0acb05b4e39e6e20a2175cb119a0879
|
| 3 |
+
size 465895408
|
data/repo/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:9dc5761b05377e76f8e78736df3c37eac08353dfeb1ff61de68e8abb977ebe6a
|
| 3 |
+
size 337340487
|
data/slag/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:da819bb4caf9edd1ab3f1261921427c2701f9a991ce8d31063ab5702a11f54ad
|
| 3 |
+
size 173152339
|
data/std/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
size 3438704
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:d4268028b35bef043ef1145d33bb41e4f5536c632e41e810dde3d864a0b45218
|
| 3 |
size 3438704
|
data/tested/train-00000-of-00001.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:251a8fbfdff662ff70045b622ee478803e44aaddad03da1f3550a8a8913627b2
|
| 3 |
+
size 90999365
|
repos.json
CHANGED
|
The diff for this file is too large to render.
See raw diff
|
|
|
stats.json
CHANGED
|
@@ -1,66 +1,78 @@
|
|
| 1 |
{
|
| 2 |
"compiled": {
|
| 3 |
-
"files":
|
| 4 |
-
"repos":
|
| 5 |
-
"MB":
|
| 6 |
"licenses": {
|
| 7 |
-
"MIT":
|
| 8 |
-
"Apache-2.0":
|
| 9 |
-
"
|
| 10 |
-
"
|
| 11 |
-
"
|
| 12 |
-
"
|
| 13 |
-
"
|
| 14 |
-
"
|
| 15 |
-
"
|
| 16 |
-
"
|
| 17 |
-
"
|
|
|
|
| 18 |
"BSD-3-Clause AND MIT": 37,
|
| 19 |
-
"MIT OR Apache-2.0":
|
| 20 |
"MIT AND Zlib": 11,
|
| 21 |
"Apache-2.0 AND BSD-3-Clause AND MIT AND Zlib": 11,
|
| 22 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 23 |
}
|
| 24 |
},
|
| 25 |
"built": {
|
| 26 |
-
"files":
|
| 27 |
-
"repos":
|
| 28 |
-
"MB":
|
| 29 |
"licenses": {
|
| 30 |
-
"MIT":
|
| 31 |
-
"Apache-2.0":
|
| 32 |
-
"BSD-3-Clause":
|
| 33 |
-
"Apache-2.0 AND MIT":
|
| 34 |
-
"
|
| 35 |
-
"
|
| 36 |
-
"
|
| 37 |
-
"
|
| 38 |
-
"
|
| 39 |
-
"
|
|
|
|
|
|
|
|
|
|
|
|
|
| 40 |
"BSD-3-Clause AND MIT": 11,
|
|
|
|
| 41 |
"ISC": 5,
|
| 42 |
"MIT AND Zlib": 3
|
| 43 |
}
|
| 44 |
},
|
| 45 |
-
"tested": {
|
| 46 |
-
"files": 15604,
|
| 47 |
-
"repos": 736,
|
| 48 |
-
"MB": 198.3,
|
| 49 |
-
"licenses": {
|
| 50 |
-
"MIT": 12598,
|
| 51 |
-
"Apache-2.0": 2001,
|
| 52 |
-
"Apache-2.0 AND MIT": 278,
|
| 53 |
-
"BSD-3-Clause": 266,
|
| 54 |
-
"MPL-2.0": 136,
|
| 55 |
-
"Unlicense": 101,
|
| 56 |
-
"Apache-2.0 AND BSD-3-Clause AND MIT": 68,
|
| 57 |
-
"0BSD": 67,
|
| 58 |
-
"BSD-2-Clause": 37,
|
| 59 |
-
"ISC": 37,
|
| 60 |
-
"Zlib": 10,
|
| 61 |
-
"ISC OR 0BSD": 5
|
| 62 |
-
}
|
| 63 |
-
},
|
| 64 |
"std": {
|
| 65 |
"files": 538,
|
| 66 |
"repos": 1,
|
|
@@ -78,29 +90,40 @@
|
|
| 78 |
}
|
| 79 |
},
|
| 80 |
"repo": {
|
| 81 |
-
"files":
|
| 82 |
-
"repos":
|
| 83 |
-
"MB":
|
| 84 |
"licenses": {
|
| 85 |
-
"MIT":
|
| 86 |
-
"Apache-2.0":
|
| 87 |
-
"BSD-3-Clause":
|
| 88 |
-
"Apache-2.0 AND MIT":
|
| 89 |
-
"
|
| 90 |
-
"
|
| 91 |
-
"BSD-2-Clause":
|
| 92 |
-
"
|
| 93 |
-
"
|
| 94 |
-
"
|
| 95 |
-
"
|
| 96 |
-
"
|
|
|
|
| 97 |
"MIT AND Zlib": 6,
|
|
|
|
|
|
|
| 98 |
"BSD-3-Clause AND MIT": 2,
|
| 99 |
"MIT AND MPL-2.0": 1,
|
| 100 |
"(ISC OR 0BSD)": 1,
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 101 |
"Apache-2.0 AND BSD-3-Clause AND MIT AND Zlib": 1,
|
|
|
|
|
|
|
| 102 |
"Apache-2.0 AND BSD-3-Clause AND MIT": 1,
|
| 103 |
-
"
|
|
|
|
| 104 |
"0BSD AND BSD-3-Clause AND MIT AND MPL-2.0": 1
|
| 105 |
}
|
| 106 |
},
|
|
@@ -108,57 +131,64 @@
|
|
| 108 |
"tasks": 790
|
| 109 |
},
|
| 110 |
"ore": {
|
| 111 |
-
"files":
|
| 112 |
-
"repos":
|
| 113 |
-
"MB":
|
| 114 |
"licenses": {
|
| 115 |
-
"MIT":
|
| 116 |
-
"Apache-2.0":
|
| 117 |
-
"
|
| 118 |
-
"
|
| 119 |
-
"
|
| 120 |
-
"
|
| 121 |
-
"
|
| 122 |
-
"
|
| 123 |
-
"
|
| 124 |
-
"
|
| 125 |
-
"ISC":
|
| 126 |
-
"
|
| 127 |
-
"MIT OR Apache-2.0":
|
|
|
|
| 128 |
"MIT AND Zlib": 47,
|
| 129 |
"Apache-2.0 AND BSD-3-Clause AND MIT AND Zlib": 35,
|
| 130 |
-
"
|
|
|
|
| 131 |
},
|
| 132 |
"gate": {
|
| 133 |
-
"env":
|
| 134 |
-
"
|
| 135 |
-
"dep":
|
| 136 |
-
|
|
|
|
|
|
|
| 137 |
},
|
| 138 |
"slag": {
|
| 139 |
-
"files":
|
| 140 |
-
"repos":
|
| 141 |
-
"MB":
|
| 142 |
"licenses": {
|
| 143 |
-
"MIT":
|
| 144 |
-
"Apache-2.0":
|
| 145 |
-
"
|
| 146 |
-
"Unlicense":
|
| 147 |
-
"
|
| 148 |
-
"Apache-2.0 AND MIT":
|
| 149 |
-
"
|
| 150 |
-
"
|
| 151 |
-
"
|
| 152 |
-
"
|
| 153 |
-
"
|
| 154 |
"MIT AND Zlib": 27,
|
| 155 |
-
"
|
|
|
|
| 156 |
"Apache-2.0 AND BSD-3-Clause AND MIT AND Zlib": 5,
|
| 157 |
-
"
|
|
|
|
| 158 |
"MIT OR Apache-2.0": 1
|
| 159 |
},
|
| 160 |
"gate": {
|
| 161 |
-
"fail":
|
| 162 |
-
}
|
|
|
|
| 163 |
}
|
| 164 |
}
|
|
|
|
| 1 |
{
|
| 2 |
"compiled": {
|
| 3 |
+
"files": 33224,
|
| 4 |
+
"repos": 2215,
|
| 5 |
+
"MB": 346.4,
|
| 6 |
"licenses": {
|
| 7 |
+
"MIT": 23144,
|
| 8 |
+
"Apache-2.0": 6817,
|
| 9 |
+
"Apache-2.0 AND MIT": 723,
|
| 10 |
+
"MPL-2.0": 459,
|
| 11 |
+
"Zlib": 385,
|
| 12 |
+
"CC0-1.0": 313,
|
| 13 |
+
"BSD-2-Clause": 294,
|
| 14 |
+
"UPL-1.0": 287,
|
| 15 |
+
"Unlicense": 279,
|
| 16 |
+
"ISC": 214,
|
| 17 |
+
"BSD-3-Clause": 187,
|
| 18 |
+
"0BSD": 42,
|
| 19 |
"BSD-3-Clause AND MIT": 37,
|
| 20 |
+
"MIT OR Apache-2.0": 15,
|
| 21 |
"MIT AND Zlib": 11,
|
| 22 |
"Apache-2.0 AND BSD-3-Clause AND MIT AND Zlib": 11,
|
| 23 |
+
"mit-0": 5,
|
| 24 |
+
"bsl-1.0": 1
|
| 25 |
+
}
|
| 26 |
+
},
|
| 27 |
+
"tested": {
|
| 28 |
+
"files": 30153,
|
| 29 |
+
"repos": 1277,
|
| 30 |
+
"MB": 388.4,
|
| 31 |
+
"licenses": {
|
| 32 |
+
"MIT": 23766,
|
| 33 |
+
"Apache-2.0": 3607,
|
| 34 |
+
"BSD-3-Clause": 509,
|
| 35 |
+
"Apache-2.0 AND MIT": 486,
|
| 36 |
+
"MPL-2.0": 394,
|
| 37 |
+
"BSD-2-Clause": 375,
|
| 38 |
+
"Unlicense": 286,
|
| 39 |
+
"BSL-1.0": 178,
|
| 40 |
+
"Zlib": 135,
|
| 41 |
+
"CC0-1.0": 131,
|
| 42 |
+
"0BSD": 122,
|
| 43 |
+
"ISC": 76,
|
| 44 |
+
"Apache-2.0 AND BSD-3-Clause AND MIT": 68,
|
| 45 |
+
"mit-0": 7,
|
| 46 |
+
"UPL-1.0": 7,
|
| 47 |
+
"ISC OR 0BSD": 5,
|
| 48 |
+
"MIT AND CC0-1.0": 1
|
| 49 |
}
|
| 50 |
},
|
| 51 |
"built": {
|
| 52 |
+
"files": 41208,
|
| 53 |
+
"repos": 874,
|
| 54 |
+
"MB": 676.3,
|
| 55 |
"licenses": {
|
| 56 |
+
"MIT": 31578,
|
| 57 |
+
"Apache-2.0": 5479,
|
| 58 |
+
"BSD-3-Clause": 1653,
|
| 59 |
+
"Apache-2.0 AND MIT": 929,
|
| 60 |
+
"Zlib": 598,
|
| 61 |
+
"MPL-2.0": 384,
|
| 62 |
+
"0BSD": 200,
|
| 63 |
+
"Apache-2.0 AND BSD-3-Clause": 100,
|
| 64 |
+
"BSD-2-Clause": 88,
|
| 65 |
+
"Unlicense": 73,
|
| 66 |
+
"CC0-1.0": 31,
|
| 67 |
+
"UPL-1.0": 28,
|
| 68 |
+
"MIT OR Apache-2.0": 22,
|
| 69 |
+
"mit-0": 16,
|
| 70 |
"BSD-3-Clause AND MIT": 11,
|
| 71 |
+
"BSL-1.0": 10,
|
| 72 |
"ISC": 5,
|
| 73 |
"MIT AND Zlib": 3
|
| 74 |
}
|
| 75 |
},
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 76 |
"std": {
|
| 77 |
"files": 538,
|
| 78 |
"repos": 1,
|
|
|
|
| 90 |
}
|
| 91 |
},
|
| 92 |
"repo": {
|
| 93 |
+
"files": 4228,
|
| 94 |
+
"repos": 4228,
|
| 95 |
+
"MB": 1415.4,
|
| 96 |
"licenses": {
|
| 97 |
+
"MIT": 3201,
|
| 98 |
+
"Apache-2.0": 550,
|
| 99 |
+
"BSD-3-Clause": 90,
|
| 100 |
+
"Apache-2.0 AND MIT": 68,
|
| 101 |
+
"MPL-2.0": 63,
|
| 102 |
+
"Unlicense": 55,
|
| 103 |
+
"BSD-2-Clause": 51,
|
| 104 |
+
"Zlib": 38,
|
| 105 |
+
"CC0-1.0": 25,
|
| 106 |
+
"ISC": 20,
|
| 107 |
+
"0BSD": 18,
|
| 108 |
+
"BSL-1.0": 11,
|
| 109 |
+
"UPL-1.0": 10,
|
| 110 |
"MIT AND Zlib": 6,
|
| 111 |
+
"mit-0": 4,
|
| 112 |
+
"(MIT OR Apache-2.0)": 2,
|
| 113 |
"BSD-3-Clause AND MIT": 2,
|
| 114 |
"MIT AND MPL-2.0": 1,
|
| 115 |
"(ISC OR 0BSD)": 1,
|
| 116 |
+
"Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND MIT": 1,
|
| 117 |
+
"Apache-2.0 AND BSD-3-Clause": 1,
|
| 118 |
+
"BSD-3-Clause AND Zlib": 1,
|
| 119 |
+
"bsl-1.0": 1,
|
| 120 |
+
"0BSD AND ISC": 1,
|
| 121 |
"Apache-2.0 AND BSD-3-Clause AND MIT AND Zlib": 1,
|
| 122 |
+
"BSD-2-Clause AND BSD-3-Clause": 1,
|
| 123 |
+
"BSL-1.0 AND CC0-1.0": 1,
|
| 124 |
"Apache-2.0 AND BSD-3-Clause AND MIT": 1,
|
| 125 |
+
"Apache-2.0 AND MPL-2.0": 1,
|
| 126 |
+
"CC0-1.0 AND MIT": 1,
|
| 127 |
"0BSD AND BSD-3-Clause AND MIT AND MPL-2.0": 1
|
| 128 |
}
|
| 129 |
},
|
|
|
|
| 131 |
"tasks": 790
|
| 132 |
},
|
| 133 |
"ore": {
|
| 134 |
+
"files": 121602,
|
| 135 |
+
"repos": 2384,
|
| 136 |
+
"MB": 2017.4,
|
| 137 |
"licenses": {
|
| 138 |
+
"MIT": 74246,
|
| 139 |
+
"Apache-2.0": 33742,
|
| 140 |
+
"Apache-2.0 AND MIT": 3880,
|
| 141 |
+
"MPL-2.0": 2881,
|
| 142 |
+
"Unlicense": 1869,
|
| 143 |
+
"UPL-1.0": 1323,
|
| 144 |
+
"BSD-3-Clause": 961,
|
| 145 |
+
"BSD-2-Clause": 942,
|
| 146 |
+
"CC0-1.0": 782,
|
| 147 |
+
"Zlib": 512,
|
| 148 |
+
"ISC": 153,
|
| 149 |
+
"0BSD": 104,
|
| 150 |
+
"MIT OR Apache-2.0": 61,
|
| 151 |
+
"BSD-3-Clause AND MIT": 54,
|
| 152 |
"MIT AND Zlib": 47,
|
| 153 |
"Apache-2.0 AND BSD-3-Clause AND MIT AND Zlib": 35,
|
| 154 |
+
"mit-0": 9,
|
| 155 |
+
"bsl-1.0": 1
|
| 156 |
},
|
| 157 |
"gate": {
|
| 158 |
+
"env": 38522,
|
| 159 |
+
"timeout": 32815,
|
| 160 |
+
"dep": 27198,
|
| 161 |
+
"unchecked": 23067
|
| 162 |
+
},
|
| 163 |
+
"bench_body_dropped": 49
|
| 164 |
},
|
| 165 |
"slag": {
|
| 166 |
+
"files": 28278,
|
| 167 |
+
"repos": 2400,
|
| 168 |
+
"MB": 753.2,
|
| 169 |
"licenses": {
|
| 170 |
+
"MIT": 19374,
|
| 171 |
+
"Apache-2.0": 6483,
|
| 172 |
+
"MPL-2.0": 615,
|
| 173 |
+
"Unlicense": 341,
|
| 174 |
+
"BSD-2-Clause": 318,
|
| 175 |
+
"Apache-2.0 AND MIT": 310,
|
| 176 |
+
"Zlib": 187,
|
| 177 |
+
"UPL-1.0": 182,
|
| 178 |
+
"CC0-1.0": 164,
|
| 179 |
+
"BSD-3-Clause": 142,
|
| 180 |
+
"ISC": 87,
|
| 181 |
"MIT AND Zlib": 27,
|
| 182 |
+
"0BSD": 24,
|
| 183 |
+
"BSD-3-Clause AND MIT": 16,
|
| 184 |
"Apache-2.0 AND BSD-3-Clause AND MIT AND Zlib": 5,
|
| 185 |
+
"bsl-1.0": 1,
|
| 186 |
+
"mit-0": 1,
|
| 187 |
"MIT OR Apache-2.0": 1
|
| 188 |
},
|
| 189 |
"gate": {
|
| 190 |
+
"fail": 28278
|
| 191 |
+
},
|
| 192 |
+
"bench_body_dropped": 13
|
| 193 |
}
|
| 194 |
}
|
tools/collect_gh.py
ADDED
|
@@ -0,0 +1,30 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# Collect Zig repos pushed in a window from GitHub search, slicing by day (and half-day if a slice nears the 1000 cap).
|
| 2 |
+
import json,subprocess,sys,time,datetime as dt,urllib.parse
|
| 3 |
+
start,end,out=sys.argv[1],sys.argv[2],sys.argv[3]
|
| 4 |
+
def get(q,page):
|
| 5 |
+
u='https://api.github.com/search/repositories?'+urllib.parse.urlencode(dict(q=q,per_page=100,page=page))
|
| 6 |
+
for a in range(6):
|
| 7 |
+
r=subprocess.run(['curl','-s','-H','Accept: application/vnd.github+json',u],capture_output=True,text=True)
|
| 8 |
+
try: d=json.loads(r.stdout)
|
| 9 |
+
except Exception: time.sleep(10); continue
|
| 10 |
+
if 'items' in d: return d
|
| 11 |
+
time.sleep(15) # secondary rate limit
|
| 12 |
+
raise SystemExit('failed '+q)
|
| 13 |
+
def slices(a,b):
|
| 14 |
+
t=a
|
| 15 |
+
while t<b:
|
| 16 |
+
n=min(t+dt.timedelta(hours=12),b); yield t,n; t=n
|
| 17 |
+
seen={}
|
| 18 |
+
a=dt.datetime.fromisoformat(start); b=dt.datetime.fromisoformat(end)
|
| 19 |
+
for s,e in slices(a,b):
|
| 20 |
+
q='language:Zig pushed:%s..%s'%(s.strftime('%Y-%m-%dT%H:%M:%SZ'),e.strftime('%Y-%m-%dT%H:%M:%SZ'))
|
| 21 |
+
d=get(q,1); tot=d['total_count']
|
| 22 |
+
if tot>1000: print('WARN cap',q,tot,file=sys.stderr)
|
| 23 |
+
items=d['items']
|
| 24 |
+
for p in range(2,min(10,(tot+99)//100)+1): items+=get(q,p)['items']; time.sleep(2)
|
| 25 |
+
for it in items:
|
| 26 |
+
seen[it['full_name']]=dict(host='github',repo=it['full_name'],license=(it.get('license') or {}).get('spdx_id') or '',
|
| 27 |
+
pushed=it['pushed_at'],created=it['created_at'],size_kb=it['size'],stars=it['stargazers_count'],fork=it['fork'],archived=it['archived'],branch=it['default_branch'])
|
| 28 |
+
print(q,tot,len(seen),file=sys.stderr,flush=True); time.sleep(2.2)
|
| 29 |
+
json.dump(list(seen.values()),open(out,'w'))
|
| 30 |
+
print('total',len(seen))
|
tools/d2s.py
CHANGED
|
@@ -134,7 +134,7 @@ def compile_(root, files, astbad, sub='', mods=None, host=None):
|
|
| 134 |
for n, mp in mods.items(): margs += [a for o in mods if o != n for a in ('--dep', o)] + ['-M%s=%s' % (n, mp)]
|
| 135 |
try:
|
| 136 |
p = subprocess.run([Z, 'test', '-lc', '-fno-emit-bin', '-freference-trace=32', '--global-cache-dir', GC, '--cache-dir', os.path.join(S, 'ingot', 'lcache_d2s', os.path.basename(root))] + margs,
|
| 137 |
-
cwd=root, capture_output=True, text=True, timeout=900)
|
| 138 |
except subprocess.TimeoutExpired: return 'timeout', None
|
| 139 |
finally:
|
| 140 |
try: os.remove(wp)
|
|
|
|
| 134 |
for n, mp in mods.items(): margs += [a for o in mods if o != n for a in ('--dep', o)] + ['-M%s=%s' % (n, mp)]
|
| 135 |
try:
|
| 136 |
p = subprocess.run([Z, 'test', '-lc', '-fno-emit-bin', '-freference-trace=32', '--global-cache-dir', GC, '--cache-dir', os.path.join(S, 'ingot', 'lcache_d2s', os.path.basename(root))] + margs,
|
| 137 |
+
cwd=root, capture_output=True, text=True, timeout=int(os.environ.get('D2S_TIMEOUT','900')))
|
| 138 |
except subprocess.TimeoutExpired: return 'timeout', None
|
| 139 |
finally:
|
| 140 |
try: os.remove(wp)
|
tools/d2s_run.sh
CHANGED
|
@@ -4,5 +4,7 @@ S=/work/ingot; cd $S; O=${OUT:-d2s_b}; L=${LIST:-d2s_list_b.txt}; mkdir -p $O
|
|
| 4 |
while read d; do
|
| 5 |
[ -f "$O/$d.jsonl" ] && continue
|
| 6 |
while [ "$(jobs -rp | wc -l)" -ge ${J:-2} ]; do sleep 1; done
|
| 7 |
-
( python3 -I tools/d2s.py "$d" > "$O/$d.tmp"
|
|
|
|
|
|
|
| 8 |
done < $L; wait; echo ALLDONE > DONE_$O
|
|
|
|
| 4 |
while read d; do
|
| 5 |
[ -f "$O/$d.jsonl" ] && continue
|
| 6 |
while [ "$(jobs -rp | wc -l)" -ge ${J:-2} ]; do sleep 1; done
|
| 7 |
+
( if timeout ${D2S_REPO_TIMEOUT:-1200} python3 -I tools/d2s.py "$d" > "$O/$d.tmp"; then mv "$O/$d.tmp" "$O/$d.jsonl"
|
| 8 |
+
else python3 -I -c "import os,sys,json;n=sys.argv[1];r=os.path.join('/work/ingot/harvest',n)
|
| 9 |
+
[print(json.dumps(dict(dir=n,path=os.path.relpath(os.path.join(a,f),r),d2s='timeout',err='repo-timeout'))) for a,_,fs in os.walk(r) for f in fs if f.endswith('.zig')]" "$d" > "$O/$d.jsonl"; rm -f "$O/$d.tmp"; fi ) & # v1.2: whole-repo cap; every file of a capped repo is gate=timeout (Ore), never passed
|
| 10 |
done < $L; wait; echo ALLDONE > DONE_$O
|
tools/ingot_harvest.py
CHANGED
|
@@ -1,20 +1,20 @@
|
|
| 1 |
# harvest2: harvest1 + GitHub archive-tarball deps fetched via git (codeload is 403 behind the proxy).
|
| 2 |
# Clone one GitHub repo, build it with Zig 0.17 (prefetching deps via git/curl when zig's fetcher is blocked),
|
| 3 |
# and if `zig build` succeeds keep its .zig files + LICENSE under harvest/<owner>__<repo>/. Repo dir is always deleted.
|
| 4 |
-
import sys,subprocess,re,os,shutil,json,hashlib
|
| 5 |
Z=os.environ.get('ZIG','/work/zig/zig') # any Zig release: the whole pipeline is version-parametric
|
| 6 |
S='/work/ingot'
|
| 7 |
-
env=dict(os.environ,ZIG_GLOBAL_CACHE_DIR=S+'/gcache')
|
| 8 |
host,full,lic,keep_failed=sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4]=='1'; name=host+'__'+full.replace('/','__'); d=os.path.join(S,'work2',name); dd=os.path.join(S,'deps')
|
| 9 |
os.makedirs(dd,exist_ok=True); shutil.rmtree(d,ignore_errors=True)
|
| 10 |
res=dict(host=host,repo=full,license=lic)
|
| 11 |
def done(**k):
|
| 12 |
-
res.update(k); shutil.rmtree(d,ignore_errors=True); print(json.dumps(res),flush=True); sys.exit(0)
|
| 13 |
BASE={'github':'https://github.com/','codeberg':'https://codeberg.org/','gitlab':'https://gitlab.com/'}[host]
|
| 14 |
try: subprocess.run(['git','clone','-q','--depth','1','--recurse-submodules','--shallow-submodules',BASE+full,d],check=True,timeout=300,capture_output=True)
|
| 15 |
except Exception: done(stage='clone-fail')
|
| 16 |
res['commit']=subprocess.run(['git','-C',d,'rev-parse','HEAD'],capture_output=True,text=True).stdout.strip()
|
| 17 |
-
zf=[os.path.join(r,f) for r,_,fs in os.walk(d) if '/.git' not in r and '.zig-cache' not in r for f in fs if f.endswith('.zig')]
|
| 18 |
res['zig_files']=len(zf); res['zig_bytes']=sum(os.path.getsize(f) for f in zf)
|
| 19 |
zon=open(os.path.join(d,'build.zig.zon')).read() if os.path.exists(os.path.join(d,'build.zig.zon')) else ''
|
| 20 |
m=re.search(r'minimum_zig_version\s*=\s*"([^"]+)"',zon); res['min_zig']=m.group(1) if m else ''
|
|
@@ -24,15 +24,31 @@ def gh(url):
|
|
| 24 |
m=re.match(r'https://(?:codeload\.)?github\.com/([^/]+)/([^/]+)/(?:archive|tar\.gz|zip)/(?:refs/(?:heads|tags)/)?(.+?)(?:\.tar\.gz|\.zip|\.tgz)?$',url)
|
| 25 |
return (m.group(1),m.group(2),m.group(3)) if m else None
|
| 26 |
seen=[]; rc=None; out=''
|
| 27 |
-
for
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 36 |
try:
|
| 37 |
if url.startswith('git+'):
|
| 38 |
u=url[4:]; commit=u.split('#')[1] if '#' in u else None; base=u.split('#')[0].split('?')[0]
|
|
@@ -53,10 +69,21 @@ for rnd in range(0 if nobuild else 10):
|
|
| 53 |
shutil.rmtree(os.path.join(tgt,'.git'),ignore_errors=True)
|
| 54 |
src=tgt
|
| 55 |
else:
|
| 56 |
-
|
| 57 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 58 |
subprocess.run([Z,'fetch',src],cwd=dd,env=env,capture_output=True,timeout=300)
|
| 59 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 60 |
res['deps_prefetched']=len(seen)
|
| 61 |
built = rc==0
|
| 62 |
if not built:
|
|
@@ -66,7 +93,7 @@ else: # tests: the repo's own `zig build test` if the step exists
|
|
| 66 |
try:
|
| 67 |
st=subprocess.run([Z,'build','-l'],cwd=d,env=env,capture_output=True,text=True,timeout=120).stdout
|
| 68 |
if re.search(r'^\s*test\b',st,re.M):
|
| 69 |
-
tp=subprocess.run([Z,'build','test'],cwd=d,env=env,capture_output=True,text=True,timeout=900)
|
| 70 |
res['tests']='pass' if tp.returncode==0 else 'fail'
|
| 71 |
else: res['tests']='none'
|
| 72 |
except subprocess.TimeoutExpired: res['tests']='timeout'
|
|
@@ -75,6 +102,7 @@ for f in zf:
|
|
| 75 |
rel=os.path.relpath(f,d)
|
| 76 |
if rel.startswith('zig-pkg/'): continue
|
| 77 |
os.makedirs(os.path.dirname(os.path.join(h,rel)),exist_ok=True); shutil.copy2(f,os.path.join(h,rel))
|
|
|
|
| 78 |
for lf in os.listdir(d):
|
| 79 |
-
if lf.upper().startswith(('LICENSE','LICENCE','COPYING','UNLICENSE')): shutil.copy2(os.path.join(d,lf),os.path.join(h,lf))
|
| 80 |
done(stage='built' if built else ('no-build-kept' if nobuild else 'build-failed-kept'))
|
|
|
|
| 1 |
# harvest2: harvest1 + GitHub archive-tarball deps fetched via git (codeload is 403 behind the proxy).
|
| 2 |
# Clone one GitHub repo, build it with Zig 0.17 (prefetching deps via git/curl when zig's fetcher is blocked),
|
| 3 |
# and if `zig build` succeeds keep its .zig files + LICENSE under harvest/<owner>__<repo>/. Repo dir is always deleted.
|
| 4 |
+
import sys,subprocess,re,os,shutil,json,hashlib,fcntl,time; T0=time.time()
|
| 5 |
Z=os.environ.get('ZIG','/work/zig/zig') # any Zig release: the whole pipeline is version-parametric
|
| 6 |
S='/work/ingot'
|
| 7 |
+
env=dict(os.environ,ZIG_GLOBAL_CACHE_DIR=S+'/gcache') # (v1.2 tried a shared local cache: 9 GB in 35 min, no measurable speedup; reverted)
|
| 8 |
host,full,lic,keep_failed=sys.argv[1],sys.argv[2],sys.argv[3],sys.argv[4]=='1'; name=host+'__'+full.replace('/','__'); d=os.path.join(S,'work2',name); dd=os.path.join(S,'deps')
|
| 9 |
os.makedirs(dd,exist_ok=True); shutil.rmtree(d,ignore_errors=True)
|
| 10 |
res=dict(host=host,repo=full,license=lic)
|
| 11 |
def done(**k):
|
| 12 |
+
res.update(k); res['secs']=round(time.time()-T0); shutil.rmtree(d,ignore_errors=True); print(json.dumps(res),flush=True); sys.exit(0)
|
| 13 |
BASE={'github':'https://github.com/','codeberg':'https://codeberg.org/','gitlab':'https://gitlab.com/'}[host]
|
| 14 |
try: subprocess.run(['git','clone','-q','--depth','1','--recurse-submodules','--shallow-submodules',BASE+full,d],check=True,timeout=300,capture_output=True)
|
| 15 |
except Exception: done(stage='clone-fail')
|
| 16 |
res['commit']=subprocess.run(['git','-C',d,'rev-parse','HEAD'],capture_output=True,text=True).stdout.strip()
|
| 17 |
+
zf=[os.path.join(r,f) for r,_,fs in os.walk(d) if '/.git' not in r and '.zig-cache' not in r for f in fs if f.endswith('.zig') and os.path.isfile(os.path.join(r,f))] # v1.2: skip dangling symlinks
|
| 18 |
res['zig_files']=len(zf); res['zig_bytes']=sum(os.path.getsize(f) for f in zf)
|
| 19 |
zon=open(os.path.join(d,'build.zig.zon')).read() if os.path.exists(os.path.join(d,'build.zig.zon')) else ''
|
| 20 |
m=re.search(r'minimum_zig_version\s*=\s*"([^"]+)"',zon); res['min_zig']=m.group(1) if m else ''
|
|
|
|
| 24 |
m=re.match(r'https://(?:codeload\.)?github\.com/([^/]+)/([^/]+)/(?:archive|tar\.gz|zip)/(?:refs/(?:heads|tags)/)?(.+?)(?:\.tar\.gz|\.zip|\.tgz)?$',url)
|
| 25 |
return (m.group(1),m.group(2),m.group(3)) if m else None
|
| 26 |
seen=[]; rc=None; out=''
|
| 27 |
+
pre=[] if nobuild else [u for u,h in re.findall(r'\.url\s*=\s*"([^"]+)"[^}]*?\.hash\s*=\s*"([^"]+)"',zon) if not os.path.exists(os.path.join(S,'gcache','p',h+'.tar.gz'))] # v1.2: prefetch every declared dep up front (one build round per dep was 59% of VM time)
|
| 28 |
+
for rnd in range(0 if nobuild else 10+len(pre)):
|
| 29 |
+
isp=bool(pre)
|
| 30 |
+
if isp: url=pre.pop(0)
|
| 31 |
+
else:
|
| 32 |
+
try: p=subprocess.run([Z,'build'],cwd=d,env=env,capture_output=True,text=True,timeout=int(os.environ.get('BUILD_TIMEOUT','600'))); rc=p.returncode; out=p.stdout+p.stderr
|
| 33 |
+
except subprocess.TimeoutExpired:
|
| 34 |
+
if not keep_failed: done(stage='build-timeout')
|
| 35 |
+
rc=-1; out='error: build-timeout'; break
|
| 36 |
+
if rc==0: break
|
| 37 |
+
hm=re.search(r'^(\S+?\.zon):\d+:\d+: error: hash mismatch: manifest declares (\S+) but the fetched package has',out,re.M)
|
| 38 |
+
if hm: # v1.2: Zig 0.17.0/0.17.1 caches a tarball dep with its top-level dir unstripped (p/<hash>.tar.gz), so every later use mismatches: drop the poisoned entry, prefetch from an unpacked dir
|
| 39 |
+
try: zt=open(os.path.join(d,hm.group(1))).read()
|
| 40 |
+
except Exception: zt=''
|
| 41 |
+
um=re.search(r'\.url\s*=\s*"([^"]+)"[^}]*?\.hash\s*=\s*"%s"'%re.escape(hm.group(2)),zt)
|
| 42 |
+
if not um or um.group(1) in seen: break
|
| 43 |
+
try: os.remove(os.path.join(S,'gcache','p',hm.group(2)+'.tar.gz'))
|
| 44 |
+
except OSError: pass
|
| 45 |
+
url=um.group(1)
|
| 46 |
+
else:
|
| 47 |
+
mm=re.search(r'\.url = "([^"]+)",?\s*\n\s*\^',out)
|
| 48 |
+
if not mm or not re.search(r'remote git server|HTTP response|ConnectionRes|ReadFailed|unable to connect',out) or mm.group(1) in seen: break
|
| 49 |
+
url=mm.group(1)
|
| 50 |
+
seen.append(url); tgt=os.path.join(dd,hashlib.sha1(url.encode()).hexdigest()[:12])
|
| 51 |
+
lk=open(os.path.join(dd,'.lock'),'w'); fcntl.flock(lk,fcntl.LOCK_EX) # v1.2: serialize prefetch; concurrent jobs fetching one URL poisoned the shared cache (hash mismatch)
|
| 52 |
try:
|
| 53 |
if url.startswith('git+'):
|
| 54 |
u=url[4:]; commit=u.split('#')[1] if '#' in u else None; base=u.split('#')[0].split('?')[0]
|
|
|
|
| 69 |
shutil.rmtree(os.path.join(tgt,'.git'),ignore_errors=True)
|
| 70 |
src=tgt
|
| 71 |
else:
|
| 72 |
+
if not os.path.isdir(tgt): # v1.2: unpack ourselves (single top-level dir stripped) and fetch the dir; fetching the archive itself hits the 0.17 cache-layout bug above
|
| 73 |
+
arc=tgt+'.arc'; tmp=tgt+'.x'; shutil.rmtree(tmp,ignore_errors=True); os.makedirs(tmp)
|
| 74 |
+
subprocess.run(['curl','-sSL','-m','300','-o',arc,url],check=True,capture_output=True)
|
| 75 |
+
if subprocess.run(['unzip','-tq',arc],capture_output=True).returncode==0: subprocess.run(['unzip','-q',arc,'-d',tmp],check=True,capture_output=True)
|
| 76 |
+
else: subprocess.run(['tar','xf',arc,'-C',tmp],check=True,capture_output=True)
|
| 77 |
+
ents=os.listdir(tmp); root=os.path.join(tmp,ents[0]) if len(ents)==1 and os.path.isdir(os.path.join(tmp,ents[0])) else tmp
|
| 78 |
+
os.rename(root,tgt); shutil.rmtree(tmp,ignore_errors=True); os.remove(arc)
|
| 79 |
+
src=tgt
|
| 80 |
subprocess.run([Z,'fetch',src],cwd=dd,env=env,capture_output=True,timeout=300)
|
| 81 |
+
shutil.rmtree(src,ignore_errors=True) # v1.2: the package now lives in gcache/p; keeping the unpacked copy filled 9 GB
|
| 82 |
+
except Exception:
|
| 83 |
+
lk.close()
|
| 84 |
+
if isp: continue
|
| 85 |
+
break
|
| 86 |
+
lk.close()
|
| 87 |
res['deps_prefetched']=len(seen)
|
| 88 |
built = rc==0
|
| 89 |
if not built:
|
|
|
|
| 93 |
try:
|
| 94 |
st=subprocess.run([Z,'build','-l'],cwd=d,env=env,capture_output=True,text=True,timeout=120).stdout
|
| 95 |
if re.search(r'^\s*test\b',st,re.M):
|
| 96 |
+
tp=subprocess.run([Z,'build','test'],cwd=d,env=env,capture_output=True,text=True,timeout=int(os.environ.get('TEST_TIMEOUT','900')))
|
| 97 |
res['tests']='pass' if tp.returncode==0 else 'fail'
|
| 98 |
else: res['tests']='none'
|
| 99 |
except subprocess.TimeoutExpired: res['tests']='timeout'
|
|
|
|
| 102 |
rel=os.path.relpath(f,d)
|
| 103 |
if rel.startswith('zig-pkg/'): continue
|
| 104 |
os.makedirs(os.path.dirname(os.path.join(h,rel)),exist_ok=True); shutil.copy2(f,os.path.join(h,rel))
|
| 105 |
+
os.makedirs(h,exist_ok=True) # v1.2: root may hold no .zig file
|
| 106 |
for lf in os.listdir(d):
|
| 107 |
+
if os.path.isfile(os.path.join(d,lf)) and lf.upper().startswith(('LICENSE','LICENCE','COPYING','UNLICENSE')): shutil.copy2(os.path.join(d,lf),os.path.join(h,lf)) # v1.2: a licenses/ dir crashed the harvest (repo silently lost)
|
| 108 |
done(stage='built' if built else ('no-build-kept' if nobuild else 'build-failed-kept'))
|
tools/package.py
CHANGED
|
@@ -101,6 +101,8 @@ LR = os.path.join(I, 'langref', 'langref.jsonl')
|
|
| 101 |
if os.path.exists(LR):
|
| 102 |
for x in map(json.loads, open(LR)):
|
| 103 |
x.update(license_text=zlic, repo_tests='', min_zig_declared='', dropped_copies=0, **signals(x['text'])); rows['langref'].append(x)
|
|
|
|
|
|
|
| 104 |
# whitespace-normalised copies of std / langref files inside repos are vendored copies (audit: 54 in compiled)
|
| 105 |
_norm = lambda s: re.sub(r'\s+', ' ', s).strip()
|
| 106 |
STDN = {_norm(x['text']) for x in rows['std'] + rows['langref']}
|
|
@@ -180,6 +182,26 @@ TIER_RANK = {'tested': 0, 'built': 1, 'compiled': 2}
|
|
| 180 |
_M = json.load(open(os.path.join(I, 'repos_master.json'))) + (json.load(open(os.path.join(I, 'repos_round2.json'))) if os.path.exists(os.path.join(I, 'repos_round2.json')) else [])
|
| 181 |
SRC_ORDER = {}
|
| 182 |
for _i, _r in enumerate(_M): SRC_ORDER.setdefault((_r['host'], _r['repo']), _i)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 183 |
allx = [x for tt in ('tested', 'built', 'compiled') for x in rows[tt]]
|
| 184 |
W_ = [wins(x['text']) for x in allx]
|
| 185 |
inv = collections.defaultdict(list)
|
|
@@ -251,12 +273,17 @@ def write_config(t, it):
|
|
| 251 |
w.write_table(tab); buf = []
|
| 252 |
for x in it:
|
| 253 |
buf.append(x); n += 1; nb += x['bytes']; reps.add((x['host'], x['repo'])); lic[x['license']] += 1
|
| 254 |
-
if len(buf) >= 2000: flush()
|
| 255 |
flush(); w and w.close()
|
| 256 |
stats[t] = dict(files=n, repos=len(reps), MB=round(nb / 1e6, 1), licenses=dict(lic.most_common()))
|
| 257 |
for t in [k for k in rows if k != 'repo']:
|
| 258 |
rows[t].sort(key=lambda x: (x['host'], x['repo'], x['path'])); write_config(t, rows[t])
|
| 259 |
write_config('repo', repo_docs())
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 260 |
os.makedirs(os.path.join(OUT, 'bench'), exist_ok=True)
|
| 261 |
with open(os.path.join(OUT, 'bench', 'ingot_bench_v1.jsonl'), 'w') as o: # same license rules as the training rows
|
| 262 |
# audit 10-26 filters: tasks an empty body passes (bench/empty_graded.jsonl), trivial references (<30 non-space
|
|
|
|
| 101 |
if os.path.exists(LR):
|
| 102 |
for x in map(json.loads, open(LR)):
|
| 103 |
x.update(license_text=zlic, repo_tests='', min_zig_declared='', dropped_copies=0, **signals(x['text'])); rows['langref'].append(x)
|
| 104 |
+
elif os.environ.get('V11_DIR'): # v1.2: langref is unchanged from v1.1 (same Zig 0.17.0 release)
|
| 105 |
+
rows['langref'] = pq.read_table(os.path.join(os.environ['V11_DIR'], 'langref.parquet')).to_pylist()
|
| 106 |
# whitespace-normalised copies of std / langref files inside repos are vendored copies (audit: 54 in compiled)
|
| 107 |
_norm = lambda s: re.sub(r'\s+', ' ', s).strip()
|
| 108 |
STDN = {_norm(x['text']) for x in rows['std'] + rows['langref']}
|
|
|
|
| 182 |
_M = json.load(open(os.path.join(I, 'repos_master.json'))) + (json.load(open(os.path.join(I, 'repos_round2.json'))) if os.path.exists(os.path.join(I, 'repos_round2.json')) else [])
|
| 183 |
SRC_ORDER = {}
|
| 184 |
for _i, _r in enumerate(_M): SRC_ORDER.setdefault((_r['host'], _r['repo']), _i)
|
| 185 |
+
# v1.2: merge the published v1.1 rows (they passed every audit above in v1.1) before the cross-repo copy rule and the
|
| 186 |
+
# repo config. clean.py saw them first in priority order, so a delta copy of a v1.1 file was already dropped as a dup;
|
| 187 |
+
# v1.1 rows the v1.2 decontamination flags (eval:overlap) are left out.
|
| 188 |
+
if os.environ.get('V11_DIR'):
|
| 189 |
+
V11X = set()
|
| 190 |
+
for m in map(json.loads, open(os.path.join(I, 'd3out', 'manifest_full.jsonl'))):
|
| 191 |
+
if m['repo'].startswith('v11~') and m['verdict'] == 'eval:overlap': V11X.add(tuple(m['path'].split('/', 1)))
|
| 192 |
+
nv = collections.Counter()
|
| 193 |
+
NEWK = {(x['host'], x['repo'], x['path']) for tt in ('tested', 'built', 'compiled') for x in rows[tt]} # a newer verified version of the same file supersedes the v1.1 one
|
| 194 |
+
for tt in ('tested', 'built', 'compiled'):
|
| 195 |
+
for x in pq.read_table(os.path.join(os.environ['V11_DIR'], tt + '.parquet')).to_pylist():
|
| 196 |
+
if ('v11~%s__%s' % (x['host'], x['repo'].replace('/', '__')), x['path']) in V11X: nv['eval-overlap'] += 1; continue
|
| 197 |
+
if (x['host'], x['repo'], x['path']) in NEWK: nv['superseded'] += 1; continue
|
| 198 |
+
for k_ in ('license_text', 'verify', 'license', 'host', 'repo', 'commit', 'zig_version', 'tier'): x[k_] = sys.intern(x[k_] or '') # 7 GB VM: one copy of each repeated string
|
| 199 |
+
rows[tt].append(x); nv[tt] += 1; SRC_ORDER[(x['host'], x['repo'])] = -1
|
| 200 |
+
print('v1.1 rows merged', dict(nv))
|
| 201 |
+
if os.environ.get('BENCH_COPY'): # v1.2 leak rule: no training row may contain an Ingot-Bench reference body verbatim (whitespace-normalised, >= 60 chars)
|
| 202 |
+
_refs = [r_ for r_ in (_norm(json.loads(l)['ref_body']) for l in open(os.path.join(os.environ['BENCH_COPY'], 'ingot_bench_v1.jsonl'))) if len(r_) >= 60]
|
| 203 |
+
for tt in ('tested', 'built', 'compiled'):
|
| 204 |
+
n0 = len(rows[tt]); rows[tt] = [x for x in rows[tt] if (lambda n_: not any(r_ in n_ for r_ in _refs))(_norm(x['text']))]; A3['bench-body'] += n0 - len(rows[tt])
|
| 205 |
allx = [x for tt in ('tested', 'built', 'compiled') for x in rows[tt]]
|
| 206 |
W_ = [wins(x['text']) for x in allx]
|
| 207 |
inv = collections.defaultdict(list)
|
|
|
|
| 273 |
w.write_table(tab); buf = []
|
| 274 |
for x in it:
|
| 275 |
buf.append(x); n += 1; nb += x['bytes']; reps.add((x['host'], x['repo'])); lic[x['license']] += 1
|
| 276 |
+
if len(buf) >= 2000 or sum(y['bytes'] for y in buf) > 150_000_000: flush() # v1.2: repo docs are large; cap a row group by bytes too
|
| 277 |
flush(); w and w.close()
|
| 278 |
stats[t] = dict(files=n, repos=len(reps), MB=round(nb / 1e6, 1), licenses=dict(lic.most_common()))
|
| 279 |
for t in [k for k in rows if k != 'repo']:
|
| 280 |
rows[t].sort(key=lambda x: (x['host'], x['repo'], x['path'])); write_config(t, rows[t])
|
| 281 |
write_config('repo', repo_docs())
|
| 282 |
+
if os.environ.get('BENCH_COPY'): # v1.2: Ingot-Bench v1 is published unchanged
|
| 283 |
+
import shutil; os.makedirs(os.path.join(OUT, 'bench'), exist_ok=True)
|
| 284 |
+
for f in ('ingot_bench_v1.jsonl', 'ingot_bench_v1.parquet'): shutil.copy(os.path.join(os.environ['BENCH_COPY'], f), os.path.join(OUT, 'bench', f))
|
| 285 |
+
stats['bench'] = dict(tasks=sum(1 for _ in open(os.path.join(OUT, 'bench', 'ingot_bench_v1.jsonl'))))
|
| 286 |
+
json.dump(stats, open(os.path.join(OUT, 'stats.json'), 'w'), indent=1); sys.exit(0)
|
| 287 |
os.makedirs(os.path.join(OUT, 'bench'), exist_ok=True)
|
| 288 |
with open(os.path.join(OUT, 'bench', 'ingot_bench_v1.jsonl'), 'w') as o: # same license rules as the training rows
|
| 289 |
# audit 10-26 filters: tasks an empty body passes (bench/empty_graded.jsonl), trivial references (<30 non-space
|
tools/package_pools.py
CHANGED
|
@@ -16,7 +16,11 @@ exec(_pk[_pk.index("def multi_license"):_pk.index("for tt in ('tested', 'built',
|
|
| 16 |
import subprocess
|
| 17 |
ZIG = subprocess.run([os.environ.get('ZIG', os.path.join(S, 'zig', 'zig')), 'version'], capture_output=True, text=True).stdout.strip()
|
| 18 |
_norm = lambda s: re.sub(r'\s+', ' ', s).strip()
|
|
|
|
| 19 |
def lic_text(d):
|
|
|
|
|
|
|
|
|
|
| 20 |
root = os.path.join(I, 'harvest', d); t = []
|
| 21 |
for f in sorted(os.listdir(root)):
|
| 22 |
if f.upper().startswith(('LICENSE', 'LICENCE', 'COPYING', 'UNLICENSE')) and os.path.isfile(os.path.join(root, f)):
|
|
@@ -27,20 +31,46 @@ def wins(s):
|
|
| 27 |
return {h for h in (zlib.crc32('\n'.join(L[i:i + 6]).encode()) for i in range(max(len(L) - 5, 0))) if h % 4 == 0}
|
| 28 |
|
| 29 |
# reference set: every released ingot row (tiers + std + langref)
|
| 30 |
-
ref_norm,
|
| 31 |
for t in ('tested', 'built', 'compiled', 'std', 'langref'):
|
| 32 |
for k, x in enumerate(pq.read_table(os.path.join(OUT, 'data', t, 'train-00000-of-00001.parquet'), columns=['text']).column('text').to_pylist()):
|
| 33 |
ref_norm.add(hashlib.sha256(_norm(x).encode()).digest())
|
| 34 |
-
for h in wins(x):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 35 |
REASON = collections.Counter()
|
|
|
|
| 36 |
KEEP_CLEAN = {'ore': {'keep'}, 'slag': {'keep', 'gate:ast-check', 'B:stale-std-ref'}} # slag is broken by definition
|
| 37 |
DESC = {'ore': "not verified: whole-repo build failed and the per-file check could not analyse this file (%s)",
|
| 38 |
'slag': "does not compile on Zig %s: %s"}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 39 |
pool_rows = {}
|
| 40 |
for pool in ('ore', 'slag'):
|
| 41 |
repos = {r['repo']: r for r in map(json.loads, open(os.path.join(I, 'd3in_%s_repos.jsonl' % pool)))}
|
| 42 |
meta = {(f['dir'], f['path']): f for f in map(json.loads, open(os.path.join(I, 'd3in_%s_files.jsonl' % pool)))}
|
| 43 |
-
out =
|
| 44 |
for m in map(json.loads, open(os.path.join(I, 'd3out_%s' % pool, 'manifest.jsonl'))):
|
| 45 |
if m['verdict'] not in KEEP_CLEAN[pool]: REASON[(pool, m['verdict'])] += 1; continue
|
| 46 |
d, p = m['path'].split('/', 1); r = repos[d]; f = meta[(d, p)]
|
|
@@ -64,32 +94,35 @@ for pool in ('ore', 'slag'):
|
|
| 64 |
if hn in ref_norm: REASON[(pool, 'dup-of-ingot')] += 1; continue
|
| 65 |
w = wins(text)
|
| 66 |
if len(w) >= 8:
|
| 67 |
-
c =
|
| 68 |
if c and c.most_common(1)[0][1] / len(w) >= 0.9: REASON[(pool, 'copy-of-ingot')] += 1; continue
|
| 69 |
why = f.get('gate_error') or f.get('d2s') or ''
|
| 70 |
if pool == 'slag' and m['verdict'] != 'keep': why = (m['verdict'] + ': ' + (m.get('reason_detail') or '')).strip()
|
| 71 |
-
out.
|
| 72 |
tier=pool, verify=(DESC['ore'] % f.get('d2s')) if pool == 'ore' else (DESC['slag'] % (ZIG, why[:200])),
|
| 73 |
gate=f.get('d2s') or '', gate_error=why[:300], zig_version=ZIG, min_zig_declared=r.get('min_zig') or '',
|
| 74 |
bytes=len(text.encode()), sha256=hashlib.sha256(text.encode()).hexdigest(), dropped_copies=0, **signals(text)))
|
| 75 |
ref_norm.add(hn) # also dedups slag against ore (ore is built first)
|
| 76 |
-
|
| 77 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 78 |
|
| 79 |
stats = json.load(open(os.path.join(OUT, 'stats.json')))
|
| 80 |
for pool, R in pool_rows.items():
|
| 81 |
-
|
| 82 |
-
path = os.path.join(OUT, 'data', pool, 'train-00000-of-00001.parquet'); w = None
|
| 83 |
-
for i in range(0, len(R), 2000):
|
| 84 |
-
tab = pa.Table.from_pylist(R[i:i + 2000])
|
| 85 |
-
if w is None:
|
| 86 |
-
sch = pa.schema([pa.field(f.name, pa.list_(pa.string())) if f.name == 'imports' else pa.field(f.name, pa.string()) if pa.types.is_null(f.type) else f for f in tab.schema])
|
| 87 |
-
w = pq.ParquetWriter(path, sch, compression='zstd', use_dictionary=['host', 'repo', 'license', 'license_text', 'tier', 'zig_version', 'commit', 'gate'])
|
| 88 |
-
w.write_table(tab.cast(w.schema))
|
| 89 |
-
w and w.close()
|
| 90 |
-
stats[pool] = dict(files=len(R), repos=len({(x['host'], x['repo']) for x in R}), MB=round(sum(x['bytes'] for x in R) / 1e6, 1),
|
| 91 |
-
licenses=dict(collections.Counter(x['license'] for x in R).most_common()),
|
| 92 |
-
gate=dict(collections.Counter(x['gate'] for x in R).most_common()))
|
| 93 |
json.dump(stats, open(os.path.join(OUT, 'stats.json'), 'w'), indent=1)
|
| 94 |
print('dropped', {('%s %s' % k): v for k, v in sorted(REASON.items())})
|
| 95 |
print({p: {k: v for k, v in stats[p].items() if k not in ('licenses',)} for p in pool_rows})
|
|
|
|
| 16 |
import subprocess
|
| 17 |
ZIG = subprocess.run([os.environ.get('ZIG', os.path.join(S, 'zig', 'zig')), 'version'], capture_output=True, text=True).stdout.strip()
|
| 18 |
_norm = lambda s: re.sub(r'\s+', ' ', s).strip()
|
| 19 |
+
_LT = {}
|
| 20 |
def lic_text(d):
|
| 21 |
+
if d in _LT: return _LT[d]
|
| 22 |
+
_LT[d] = sys.intern(_lic_text(d)); return _LT[d]
|
| 23 |
+
def _lic_text(d):
|
| 24 |
root = os.path.join(I, 'harvest', d); t = []
|
| 25 |
for f in sorted(os.listdir(root)):
|
| 26 |
if f.upper().startswith(('LICENSE', 'LICENCE', 'COPYING', 'UNLICENSE')) and os.path.isfile(os.path.join(root, f)):
|
|
|
|
| 31 |
return {h for h in (zlib.crc32('\n'.join(L[i:i + 6]).encode()) for i in range(max(len(L) - 5, 0))) if h % 4 == 0}
|
| 32 |
|
| 33 |
# reference set: every released ingot row (tiers + std + langref)
|
| 34 |
+
ref_norm, _H, _R = set(), [], [] # v1.2: window index as sorted numpy arrays (the dict of sets OOM-killed the 8 GB VM at 2x Ingot)
|
| 35 |
for t in ('tested', 'built', 'compiled', 'std', 'langref'):
|
| 36 |
for k, x in enumerate(pq.read_table(os.path.join(OUT, 'data', t, 'train-00000-of-00001.parquet'), columns=['text']).column('text').to_pylist()):
|
| 37 |
ref_norm.add(hashlib.sha256(_norm(x).encode()).digest())
|
| 38 |
+
for h in wins(x): _H.append(h); _R.append(len(ref_norm)) # row id: position of this row's entry (unique per Ingot row up to identical texts)
|
| 39 |
+
import numpy as _np
|
| 40 |
+
_H = _np.array(_H, dtype=_np.uint32); _R = _np.array(_R, dtype=_np.int32); _o = _np.argsort(_H, kind='stable'); _H, _R = _H[_o], _R[_o]; del _o
|
| 41 |
+
def _cnt(w): # per Ingot row, how many of this file's windows it shares; windows shared by > 5,000 rows are idioms and skipped (speed)
|
| 42 |
+
hs = _np.fromiter(w, dtype=_np.uint32, count=len(w)); a = _np.searchsorted(_H, hs, 'left'); b = _np.searchsorted(_H, hs, 'right')
|
| 43 |
+
m = (b - a) <= 5000; a, b = a[m], b[m]
|
| 44 |
+
if not len(a): return collections.Counter()
|
| 45 |
+
ids = _np.concatenate([_np.unique(_R[i:j]) for i, j in zip(a.tolist(), b.tolist()) if j > i]) if (b > a).any() else _np.array([], dtype=_np.int32)
|
| 46 |
+
if not len(ids): return collections.Counter()
|
| 47 |
+
u, n = _np.unique(ids, return_counts=True); k = n.argmax()
|
| 48 |
+
return collections.Counter({int(u[k]): int(n[k])})
|
| 49 |
REASON = collections.Counter()
|
| 50 |
+
INGOT_KEYS = {(h, r, p) for t in ('tested', 'built', 'compiled') for h, r, p in zip(*[pq.read_table(os.path.join(OUT, 'data', t, 'train-00000-of-00001.parquet'), columns=[c]).column(0).to_pylist() for c in ('host', 'repo', 'path')])}
|
| 51 |
KEEP_CLEAN = {'ore': {'keep'}, 'slag': {'keep', 'gate:ast-check', 'B:stale-std-ref'}} # slag is broken by definition
|
| 52 |
DESC = {'ore': "not verified: whole-repo build failed and the per-file check could not analyse this file (%s)",
|
| 53 |
'slag': "does not compile on Zig %s: %s"}
|
| 54 |
+
class _Sink: # v1.2: rows stream to Parquet as they are accepted (a list of all ore rows OOM-killed the 8 GB VM)
|
| 55 |
+
def __init__(s, pool):
|
| 56 |
+
s.pool, s.w, s.buf, s.keys, s.n, s.nb, s.reps, s.lic, s.gate = pool, None, [], set(), 0, 0, set(), collections.Counter(), collections.Counter()
|
| 57 |
+
os.makedirs(os.path.join(OUT, 'data', pool), exist_ok=True); s.path = os.path.join(OUT, 'data', pool, 'train-00000-of-00001.parquet')
|
| 58 |
+
def add(s, x):
|
| 59 |
+
s.buf.append(x); s.keys.add((x['host'], x['repo'], x['path'])); s.n += 1; s.nb += x['bytes']; s.reps.add((x['host'], x['repo'])); s.lic[x['license']] += 1; s.gate[x['gate']] += 1
|
| 60 |
+
if len(s.buf) >= 1000: s.flush()
|
| 61 |
+
def flush(s):
|
| 62 |
+
if not s.buf: return
|
| 63 |
+
if s.w is None:
|
| 64 |
+
tab = pa.Table.from_pylist(s.buf)
|
| 65 |
+
sch = pa.schema([pa.field(f.name, pa.list_(pa.string())) if f.name == 'imports' else pa.field(f.name, pa.string()) if pa.types.is_null(f.type) else f for f in tab.schema])
|
| 66 |
+
s.w = pq.ParquetWriter(s.path, sch, compression='zstd', use_dictionary=['host', 'repo', 'license', 'license_text', 'tier', 'zig_version', 'commit', 'gate'])
|
| 67 |
+
s.w.write_table(pa.Table.from_pylist(s.buf, schema=s.w.schema)); s.buf = []
|
| 68 |
+
def close(s): s.flush(); s.w and s.w.close()
|
| 69 |
pool_rows = {}
|
| 70 |
for pool in ('ore', 'slag'):
|
| 71 |
repos = {r['repo']: r for r in map(json.loads, open(os.path.join(I, 'd3in_%s_repos.jsonl' % pool)))}
|
| 72 |
meta = {(f['dir'], f['path']): f for f in map(json.loads, open(os.path.join(I, 'd3in_%s_files.jsonl' % pool)))}
|
| 73 |
+
out = _Sink(pool)
|
| 74 |
for m in map(json.loads, open(os.path.join(I, 'd3out_%s' % pool, 'manifest.jsonl'))):
|
| 75 |
if m['verdict'] not in KEEP_CLEAN[pool]: REASON[(pool, m['verdict'])] += 1; continue
|
| 76 |
d, p = m['path'].split('/', 1); r = repos[d]; f = meta[(d, p)]
|
|
|
|
| 94 |
if hn in ref_norm: REASON[(pool, 'dup-of-ingot')] += 1; continue
|
| 95 |
w = wins(text)
|
| 96 |
if len(w) >= 8:
|
| 97 |
+
c = _cnt(w)
|
| 98 |
if c and c.most_common(1)[0][1] / len(w) >= 0.9: REASON[(pool, 'copy-of-ingot')] += 1; continue
|
| 99 |
why = f.get('gate_error') or f.get('d2s') or ''
|
| 100 |
if pool == 'slag' and m['verdict'] != 'keep': why = (m['verdict'] + ': ' + (m.get('reason_detail') or '')).strip()
|
| 101 |
+
out.add(dict(text=text, host=r['host'], repo=r['full'], commit=r['commit'], path=p, license=lab, license_text=lt,
|
| 102 |
tier=pool, verify=(DESC['ore'] % f.get('d2s')) if pool == 'ore' else (DESC['slag'] % (ZIG, why[:200])),
|
| 103 |
gate=f.get('d2s') or '', gate_error=why[:300], zig_version=ZIG, min_zig_declared=r.get('min_zig') or '',
|
| 104 |
bytes=len(text.encode()), sha256=hashlib.sha256(text.encode()).hexdigest(), dropped_copies=0, **signals(text)))
|
| 105 |
ref_norm.add(hn) # also dedups slag against ore (ore is built first)
|
| 106 |
+
if os.environ.get('V11_DIR'): # v1.2: carry the v1.1 pool rows forward unless decontaminated, superseded or now verified
|
| 107 |
+
V11X = {tuple(m['path'].split('/', 1)) for m in map(json.loads, open(os.path.join(I, 'd3out_%s' % pool, 'manifest_full.jsonl')))
|
| 108 |
+
if m['repo'].startswith('v11~') and m['verdict'] == 'eval:overlap'}
|
| 109 |
+
NEWK = out.keys | INGOT_KEYS
|
| 110 |
+
for x in (y for bt in pq.ParquetFile(os.path.join(os.environ['V11_DIR'], pool + '.parquet')).iter_batches(batch_size=1000) for y in bt.to_pylist()): # streamed: 8 GB VM
|
| 111 |
+
if ('v11~%s__%s' % (x['host'], x['repo'].replace('/', '__')), x['path']) in V11X: REASON[(pool, 'v11-eval-overlap')] += 1; continue
|
| 112 |
+
if (x['host'], x['repo'], x['path']) in NEWK: REASON[(pool, 'v11-superseded')] += 1; continue
|
| 113 |
+
hn = hashlib.sha256(_norm(x['text']).encode()).digest()
|
| 114 |
+
if hn in ref_norm: REASON[(pool, 'v11-dup-of-ingot')] += 1; continue
|
| 115 |
+
w = wins(x['text'])
|
| 116 |
+
if len(w) >= 8:
|
| 117 |
+
c = _cnt(w)
|
| 118 |
+
if c and c.most_common(1)[0][1] / len(w) >= 0.9: REASON[(pool, 'v11-copy-of-ingot')] += 1; continue
|
| 119 |
+
for k_ in ('license_text', 'verify', 'license', 'host', 'repo', 'commit', 'zig_version', 'tier', 'gate'): x[k_] = sys.intern(x[k_] or '')
|
| 120 |
+
ref_norm.add(hn); out.add(x); REASON[(pool, 'v11-kept')] += 1
|
| 121 |
+
out.close(); pool_rows[pool] = out
|
| 122 |
|
| 123 |
stats = json.load(open(os.path.join(OUT, 'stats.json')))
|
| 124 |
for pool, R in pool_rows.items():
|
| 125 |
+
stats[pool] = dict(files=R.n, repos=len(R.reps), MB=round(R.nb / 1e6, 1), licenses=dict(R.lic.most_common()), gate=dict(R.gate.most_common()))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
json.dump(stats, open(os.path.join(OUT, 'stats.json'), 'w'), indent=1)
|
| 127 |
print('dropped', {('%s %s' % k): v for k, v in sorted(REASON.items())})
|
| 128 |
print({p: {k: v for k, v in stats[p].items() if k not in ('licenses',)} for p in pool_rows})
|
tools/pool_bench_filter.py
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# v1.2: the verbatim Ingot-Bench reference-body rule (package.py) applied to the ore and slag pools, streamed.
|
| 2 |
+
import json, os, re, sys, pyarrow as pa, pyarrow.parquet as pq
|
| 3 |
+
OUT = '/work/ingot/release'; norm = lambda s: re.sub(r'\s+', ' ', s).strip()
|
| 4 |
+
refs = [r for r in (norm(json.loads(l)['ref_body']) for l in open(os.path.join(OUT, 'bench', 'ingot_bench_v1.jsonl'))) if len(r) >= 60]
|
| 5 |
+
st = json.load(open(os.path.join(OUT, 'stats.json')))
|
| 6 |
+
for pool in ('ore', 'slag'):
|
| 7 |
+
src = os.path.join(OUT, 'data', pool, 'train-00000-of-00001.parquet'); dst = src + '.tmp'; pf = pq.ParquetFile(src); w = None; drop = kept = nb = 0
|
| 8 |
+
for bt in pf.iter_batches(batch_size=1000):
|
| 9 |
+
rows = [x for x in bt.to_pylist() if (lambda n: not any(r in n for r in refs))(norm(x['text']))]
|
| 10 |
+
drop += bt.num_rows - len(rows); kept += len(rows); nb += sum(x['bytes'] for x in rows)
|
| 11 |
+
if rows:
|
| 12 |
+
w = w or pq.ParquetWriter(dst, pf.schema_arrow, compression='zstd', use_dictionary=['host', 'repo', 'license', 'license_text', 'tier', 'zig_version', 'commit', 'gate'])
|
| 13 |
+
w.write_table(pa.Table.from_pylist(rows, schema=pf.schema_arrow))
|
| 14 |
+
w.close(); os.replace(dst, src)
|
| 15 |
+
st[pool]['files'] = kept; st[pool]['MB'] = round(nb / 1e6, 1); st[pool]['bench_body_dropped'] = drop; print(pool, 'dropped', drop, 'kept', kept)
|
| 16 |
+
json.dump(st, open(os.path.join(OUT, 'stats.json'), 'w'), indent=1)
|
tools/run_delta.sh
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# v1.2 delta harvest: like run.sh, but keep_failed=1 for every repo (failed builds go straight to the per-file gate). Resumable.
|
| 3 |
+
S=/work/ingot; cd $S; touch results.jsonl; PAR=${PAR:-3}; LIMIT=${LIMIT:-999999}
|
| 4 |
+
python3 -c "
|
| 5 |
+
import json
|
| 6 |
+
done={(json.loads(l)['host'],json.loads(l)['repo']) for l in open('results.jsonl') if l.strip()}
|
| 7 |
+
n=0
|
| 8 |
+
for r in json.load(open('repos_master.json')):
|
| 9 |
+
if (r['host'],r['repo']) in done: continue
|
| 10 |
+
n+=1
|
| 11 |
+
if n>$LIMIT: break
|
| 12 |
+
print('|'.join([r['host'],r['repo'],r['license'] or '-',str(r.get('size_kb',0))]))
|
| 13 |
+
" | while IFS='|' read -r h r l sz; do
|
| 14 |
+
# v1.2: repos over 300 MB on the forge (model weights, assets) are recorded, not cloned; a job killed by the 900 s cap is recorded too, so it is not retried forever
|
| 15 |
+
if [ "${sz:-0}" -gt 300000 ]; then echo "{\"host\": \"$h\", \"repo\": \"$r\", \"license\": \"$l\", \"stage\": \"too-big\", \"size_kb\": $sz}" >> results.jsonl; continue; fi
|
| 16 |
+
while [ "$(jobs -rp | wc -l)" -ge "$PAR" ]; do sleep 1; done
|
| 17 |
+
( timeout 480 python3 tools/ingot_harvest.py "$h" "$r" "$l" 1 > "work2_$$_${r//\//__}.out" 2>/dev/null; rc=$?; if [ $rc -eq 124 ]; then echo "{\"host\": \"$h\", \"repo\": \"$r\", \"license\": \"$l\", \"stage\": \"harvest-timeout\"}" >> results.jsonl; rm -rf "work2/${h}__${r//\//__}"; else cat "work2_$$_${r//\//__}.out" >> results.jsonl; fi; rm -f "work2_$$_${r//\//__}.out" ) &
|
| 18 |
+
[ "$(du -sm gcache 2>/dev/null | cut -f1)" -gt 9000 ] 2>/dev/null && { wait; rm -rf gcache lcache; }
|
| 19 |
+
[ "$(df -m / | awk 'NR==2{print $4}')" -lt 6000 ] && { wait; rm -rf gcache lcache deps work2; }
|
| 20 |
+
done; wait
|
tools/v11_input.py
ADDED
|
@@ -0,0 +1,12 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
# v1.2: write v1.1 Ingot-pool rows (tested, built, compiled, std) as a priority-first input tree so clean.py's dedup
|
| 2 |
+
# keeps the v1.1 copy and drops delta re-copies. Rows are written under d3in/v11~<host>__<owner>__<repo>/<path>.
|
| 3 |
+
import pyarrow.parquet as pq, os, json, sys
|
| 4 |
+
S='/work/ingot'; POOL=os.environ.get('POOL',''); OUT=os.path.join(S,'d3in'+('_'+POOL if POOL else '')); rep=[]; seen=set(); n=0 # POOL=ore|slag: the v1.1 pool rows instead
|
| 5 |
+
for c in ((POOL,) if POOL else ('tested','built','compiled')): # std is caught by clean.py's own embedded-std rule
|
| 6 |
+
t=pq.read_table('/work/v11/%s.parquet'%c, columns=['text','host','repo','path','license']).to_pylist()
|
| 7 |
+
for r in t:
|
| 8 |
+
name='v11~%s__%s'%(r['host'] or 'zig', (r['repo'] or 'std').replace('/','__'))
|
| 9 |
+
p=os.path.join(OUT,name,r['path']); os.makedirs(os.path.dirname(p),exist_ok=True)
|
| 10 |
+
with open(p,'w',encoding='utf-8') as f: f.write(r['text']); n+=1
|
| 11 |
+
if name not in seen: seen.add(name); rep.append(dict(repo=name,license=r['license']))
|
| 12 |
+
json.dump(rep,open(os.path.join(S,'v11_repos%s.json'%('_'+POOL if POOL else '')),'w')); print('v11 files',n,'repos',len(rep))
|
tools/watchdog.sh
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env bash
|
| 2 |
+
# kill orphaned repo processes (test binaries, servers) older than 20 min that outlived their harvest job
|
| 3 |
+
while true; do
|
| 4 |
+
for p in $(ps -eo pid,etimes,args | awk '($2>1200 && $3 ~ /work2|zig-cache|zig-out|cache\/o/) || ($2>1500 && $3 ~ /^\/work\/zig/) {print $1}'); do kill -9 $p 2>/dev/null; echo "$(date +%T) killed $p" >> /work/ingot/watchdog.log; done
|
| 5 |
+
find /work/ingot/gcache/p -type f -mmin +60 -delete 2>/dev/null; find /work/ingot/deps -mindepth 1 -maxdepth 1 -mmin +30 -exec rm -rf {} + 2>/dev/null # v1.2: disk budget ~43 GB
|
| 6 |
+
find /work/ingot/gcache/tmp /work/ingot/lcache_d2s -mindepth 1 -maxdepth 1 -mmin +30 -exec rm -rf {} + 2>/dev/null # killed fetches and d2s runs leave these behind
|
| 7 |
+
sleep 60
|
| 8 |
+
done
|