File size: 43,431 Bytes
c4f91a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196f3aa
c4f91a4
 
196f3aa
c4f91a4
bbc317b
c4f91a4
 
 
c17887c
196f3aa
 
 
 
 
c4f91a4
196f3aa
c4f91a4
196f3aa
c4f91a4
 
 
ce000ed
c4f91a4
 
196f3aa
f6053c3
196f3aa
bbc317b
196f3aa
 
 
 
 
 
 
 
 
 
 
 
eb1f478
196f3aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
16375c7
ce000ed
a2f00c1
196f3aa
 
a2f00c1
196f3aa
 
 
00acb58
196f3aa
 
 
 
16375c7
4aee0e4
196f3aa
 
 
16375c7
b6b0c3b
2bca61a
2df5084
a2f00c1
 
c4f91a4
 
 
bbc317b
c4f91a4
 
 
 
 
 
 
196f3aa
c4f91a4
bbc317b
 
 
 
 
 
f6053c3
bbc317b
 
 
 
 
c4f91a4
 
bbc317b
 
 
 
 
 
 
 
 
c4f91a4
bbc317b
c4f91a4
bbc317b
 
c4f91a4
 
f6053c3
c4f91a4
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
196f3aa
c4f91a4
 
196f3aa
 
c4f91a4
 
196f3aa
c4f91a4
 
 
196f3aa
 
 
c4f91a4
 
196f3aa
 
 
 
c4f91a4
 
196f3aa
c4f91a4
196f3aa
c4f91a4
 
196f3aa
 
 
c4f91a4
 
196f3aa
c4f91a4
196f3aa
c4f91a4
196f3aa
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
c4f91a4
 
196f3aa
 
 
 
 
c4f91a4
196f3aa
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
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
# Selecting rows

Every table in this repository is Parquet. One row of `data/<source>/<batch>/part-*.parquet` is one downloadable item: a file, an archive member, a WARC record, a byte range or an API response. The tables under `meta/` are small and say which rows are worth using.

A batch still being collected also has `data/<source>/<batch>/part-tail.parquet`: the rows that do not yet fill a numbered part file. It is replaced as collection goes on and its rows move into the next `part-<number>.parquet` once that file fills, so for tail rows `row_file` and `row_index` are not stable. Globs such as `part-*.parquet` or `*/*.parquet` include it. A finished batch has no tail file: all of its rows are in numbered part files.

## Row fields

| Field | Meaning |
|---|---|
| `source` | Source name (see meta/sources.json). |
| `batch` | Batch inside the source (one snapshot or collection run). |
| `collection` | Collection name inside the source. |
| `ext` | File extension without the dot, as found at the source. |
| `uri` | Address to download from (HTTPS where the source offers it). |
| `range_offset, range_length` | Byte range inside the file at uri, for records stored inside a larger file. |
| `member_path, parent_pointer_id` | Path of a member inside an archive, and the archive's pointer. |
| `zip_local_header_offset, zip_compression_method, zip_compressed_size` | Where a zip member's bytes sit, so it can be read with range requests. |
| `size_bytes` | Size of the item in bytes (empty when the source does not say). |
| `media_type` | Media type when the source states one. |
| `sha256, sha1, md5, crc32` | Hashes as raw bytes; use lower(hex(sha256)) for the hex form. |
| `origin_url, origin_time` | The page the item was found on (with signature and credential parameters removed) and when it was captured. |
| `truncated` | Why stored content was cut short (empty when it was not). |
| `license_spdx, license_training_ok, license_redistribution_ok, license_notes` | The row's own license when it differs from the batch license. |
| `sensitive` | health or minors when the row's data is about health or about minors (empty otherwise); filter on it to leave such rows out. |
| `extra` | Anything else the full pointer carries, as JSON; fetch.py rebuilds the full pointer from it. |
| `row_file, row_index` | Where the row sits: the data file (source/batch/part file) and the row number in it, counting from 0. Not stored in the data files; tools/fetch.py adds them when reading. |

## Tables under meta/

- `meta/batches.parquet`: one row per source and batch: license tiers (training_ok, redistribution_ok), the overall size cap used by tools/fetch.py (max_size_bytes), content categories, and the constants and rules used to rebuild full pointers.
- `meta/bench_overlap.parquet`: rows found in public benchmark tasks: scope row matches one row, scope container matches a whole collection; hit_class says how the match was made. When one row is a copy of benchmark data (benchmark_copy), its whole collection is listed only if the collection is one self-contained unit: one package, code repository, dataset or model repository (collection_kind "unit" in meta/sources.json, except the collections named in bucket_collections). Where collections are buckets (by file type, crawl, date, site and the like), only that row is listed. Every release compares every published data file with the benchmark list (the key version is in meta/projection.json, bench_keys); the table is sorted by source.
- `meta/bench_checked.parquet`: which data files were compared with the benchmark list: scope file has one row per published data file (row_file) with checked true and the file's SHA-256 (sha256). Every release compares every published data file, so a file this table does not list belongs to an older revision of the index and counts as not compared. Scope container lists collections whose name matches a benchmark and that await a ruling (reason pending_ruling). default_keep says whether the default filter keeps the rows; the table is sorted by source.
- `meta/tags.parquet`: the collection tags `campaign:<name>`: for each source, batch, collection, extension, metadata value and content category, the rows that belong to that collection, with row counts and the size cap of the batch (max_size_bytes); `tools/fetch.py --tag campaign:<name>` selects them. Subject and form of a source are not tags: they are the columns `domain` and `form` of `meta/catalog.parquet`.
- `meta/size_caps.json`: the reference size cap: the overall cap over all benchmark task files (the 99th percentile of their sizes), how it was derived (sample count, percentile, value) and how it is recalibrated; provisional. It does not remove rows: tools/fetch.py uses it when downloading.
- `meta/selecting.json`: the record of the last build of the tables under meta/ by the selection build (the accounting of that build, the benchmark list and date of its check, and when it ran); this page no longer shows per-source counts from it: meta/catalog.parquet is the list of sources, with their counts at every release.
- `meta/sources.json`: per-source details, including the layout used to rebuild full pointers.
- `meta/coverage.json`: totals by license tier, source, unit, size and collection tag.

`cards/<source>.yaml` is a source card: what the files of one source are (types, structure, what a task could be built from, risks), how a sample was drawn and read, and for every field `evidence.<field>.fill`: auto (computed from the index when the card was built; `checked_at` is that day), judgment (from sample files that were downloaded and read, with the basis and the files used), derived (a fixed rule over other fields) or unfilled (no evidence yet). Cards are not rebuilt with every upload. Read the evidence before relying on a field; ratios count the sample, not the whole source. [How far to trust each card field](#how-far-to-trust-each-card-field) says more.

## The default filter

The default subset only contains rows of data files that were compared with the benchmark list (AA-Briefcase-Lite, Agents' Last Exam, Aider Polyglot, AndroidWorld, AutomationBench, BrowseComp, BrowseComp-Plus, COCO, CyberGym, DeepSWE, EnterpriseOps-Gym, Finance Agent, FrontierSWE v2, GDPval, Harvey LAB, LHTB, LibriSpeech, MCP Atlas, MCPMark, Multi-SWE-bench, NL2Repo, OSWorld, OSWorld 2, ProofNet, PutnamBench, SWE-bench Multilingual, SWE-bench Multimodal, SWE-bench Pro, SWE-bench Verified, SciCode, Terminal-Bench, Toolathlon, WideSearch, miniF2F, tau2-bench), as of 2026-10-24, minus the copies of benchmark data found there and duplicate copies of the same file. Every published data file is compared at every release (the release builds meta/bench_overlap.parquet and meta/bench_checked.parquet over all of them), so meta/bench_checked.parquet lists every data file of this revision; a file it does not list belongs to an older revision of the index and counts as not compared. Rows of collections awaiting a ruling are left out too. License tiers, sizes and versions do not remove rows; the queries below choose by them. Truncated rows and empty files stay in; the reference counts below count them. A row passes when all of these hold:

- `not_in_benchmark_row / not_in_benchmark_container`: the row and its collection are not in meta/bench_overlap.parquet with hit class benchmark_copy, task_file, data_address (copies of benchmark data found in the rows that were compared, including collections derived from a benchmark).
- `checked_for_benchmarks`: the row's data file is listed in meta/bench_checked.parquet as compared with the benchmark list (checked true), and its collection is not listed there as awaiting a ruling; every published data file is listed, so only rows read from an older revision of the index fail this rule.
- `not_duplicate`: the row is not a duplicate copy of another row that the rules above keep, among the rows the query reads: of rows that share a natural key (source, uri, range_offset, member_path) only the newest version is kept, by collection time: the latest batch, then the latest part file of the batch (part files are numbered in the order they are written and part-tail.parquet holds the newest rows; a row corrected later is written into a new part file while its old version stays), then the last row of the file (natural_key_conflict true); rows of a snapshot that a newer batch replaces are removed (stackexchange-dump by source_meta.site); of rows with the same sha256, sha1 or md5 (md5 also the same size_bytes) and the same hash scope one copy is kept, the first by the source's registry_order in meta/batches.parquet, then source, batch, uri, range_offset, member_path, row_file and row_index. It is resolved over the rows of the query itself with window functions, so the copy kept is one the query returns: a query of one source keeps its rows whose copy is in another source.

`tools/fetch.py` applies it as three criteria of its default profile (benchmark, rows that matched a benchmark; not compared, rows not compared with the benchmark list yet, counted apart; duplicate, judged last over the units every other criterion keeps), which also removes rows whose license does not let the files be shipped, rows recorded in a language other than English, rows of sources or rows marked as carrying personal data, and rows above 20 MB; it prints how many units each criterion removed. `--all` turns the profile off, and each criterion has its own option (`--keep-duplicates`, `--allow-benchmark`, `--allow-not-compared`, `--any-license`, `--any-language`, `--allow-personal-data`, `--any-size`). Size caps apply only when downloading: by default the overall cap of meta/size_caps.json (the 99th percentile of all benchmark task files), and under the profile at most 20 MB, guards against huge files, and `--max-size N` uses N bytes. A row above its cap is recorded as too_large and not downloaded; a row of unknown size is downloaded up to the cap. `--max-size` limits downloads only: rows above the cap stay in the selection and in `_meta/fetch_manifest.jsonl`.

## Units, answers and companion files

Rows of a collection (batch name `<name>`, tag `campaign:<name>`) carry their place in a task in `source_meta` (inside `extra`; `tools/fetch.py` copies them into its manifests):

| Field | Meaning |
|---|---|
| `role` | `unit` (the material of a task), `answer` (its answer or expected result, kept apart from the material) or `companion` (a file of the source, such as its README or LICENSE, or a file written for a package). |
| `unit_group` | The unit the row belongs to: a test case, one workbook, one package. A unit's files and its answers share it; a companion of the whole source has none. |
| `answer_for` | On an answer row: the address (uri) of the unit file it answers. |
| `pool_path`, `pool_leaf`, `pool_domain` | Where the file goes in the task layout and the domain leaf of its unit. |

A unit is one `unit_group`; files are counted apart. A source without unit groups (a raw corpus) has one unit per row. `meta/catalog.parquet` gives every source's counts in the columns `units`, `answers` (units that have an answer) and `files` (files of every role); it is the list of sources, and this page keeps no per-source table. To list the units of one source:

```sql
SELECT json_extract_string(p.extra, '$.source_meta.unit_group') AS unit_group,
       list(json_extract_string(p.extra, '$.source_meta.role')) AS roles, count(*) AS files
FROM p WHERE p.source = '<source>' GROUP BY ALL ORDER BY 1;
```

## Batches still being collected

These batches had status `collecting` in meta/batches.parquet when this page was built, so their counts above will grow. A batch that stays in this list from one build of this page to the next is a long-running collection.

| Source | Batch | Rows so far |
|---|---|---:|
| asciinema | all | 5 |
| bioinformatics-public-archives | all | 278,202 |
| fedora-copr-build-results | all | 34,053 |
| fedora-koji-build-logs | all | 566,630 |
| gerrit-code-review | all | 1,026,897 |
| github-release-assets | all | 200,503 |
| harvard-dataverse | all | 1,191,607 |
| hf-training-records | all | 219,376 |
| internet-archive-open-licensed | all | 4,228,665 |
| kaggle-file-listings | all | 239,737 |
| launchpad-ubuntu-bugs | all | 174,719 |
| mendeley-data | all | 16,104,595 |
| modelscope | all | 8,726,153 |
| mozilla-treeherder-ci-logs | all | 37,531 |
| npm | all | 61,099,255 |
| nuget | all | 1,559,773 |
| openqa-os-test-results | all | 6,839 |
| pmc-open-access | all | 15,762,475 |
| reddit-threads-arctic-shift | all | 318,856 |
| rubygems | all | 1,019,540 |
| solver-benchmark-instances | all | 215,670 |
| fedora-koji-build-logs | inc | 73,818 |
| harvard-dataverse | inc | 43,624 |
| hf-training-records | inc | 967 |
| mendeley-data | inc | 56,360 |
| npm | inc | 30,905,829 |
| pmc-open-access | inc | 3,180,108 |

## Querying with DuckDB

Run these statements once (DuckDB 1.1 or newer reads `hf://` paths; set `HF_TOKEN` for higher rate limits). They define the views used below: `p` rows, `b` batches, `o` benchmark overlap, `c` benchmark check coverage, `t` collection tags. Duplicates have no table: the view `selected` finds them among its own rows.

```sql
CREATE OR REPLACE VIEW p AS SELECT * EXCLUDE (filename, file_row_number), regexp_extract(replace(filename, '\', '/'), '[^/]+/[^/]+/[^/]+$') AS row_file, file_row_number AS row_index FROM read_parquet('hf://datasets/Battam/agentic-env-index/data/*/*/*.parquet', union_by_name = true, filename = true, file_row_number = true);
CREATE OR REPLACE VIEW b AS SELECT * FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/batches.parquet');
CREATE OR REPLACE VIEW o AS SELECT * FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/bench_overlap.parquet');
CREATE OR REPLACE VIEW t AS SELECT * FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/tags.parquet');
CREATE OR REPLACE VIEW c AS SELECT * FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/bench_checked.parquet');
CREATE OR REPLACE VIEW s AS SELECT source, domain, form, pii.level AS pii_level, license.spdx AS spdx, files FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/catalog.parquet');
CREATE OR REPLACE VIEW selected AS
SELECT * EXCLUDE (duplicate_reason) FROM (
SELECT * EXCLUDE (dup_scope, dup_sha256, dup_sha1, dup_md5, dup_unit, dup_ord, dup_date, dup_sdate, dup_rev, dup_sup, dup_nk_rank, dup_nk_n, dup_r_sha256, dup_r_sha1, dup_r_md5),
  CASE WHEN dup_nk_rank > 1 THEN 'natural_key' WHEN dup_sup THEN 'superseded' WHEN dup_r_sha256 > 1 THEN 'same_sha256' WHEN dup_r_sha1 > 1 THEN 'same_sha1' WHEN dup_r_md5 > 1 THEN 'same_md5' END AS duplicate_reason,
  dup_nk_n > 1 AND dup_nk_rank = 1 AS natural_key_conflict
FROM (SELECT *,
  CASE WHEN dup_sha256 IS NOT NULL THEN row_number() OVER (PARTITION BY dup_scope, dup_sha256 ORDER BY dup_sup, dup_nk_rank > 1, dup_ord, source, batch, uri, range_offset, member_path, row_file, row_index) END AS dup_r_sha256, CASE WHEN dup_sha1 IS NOT NULL THEN row_number() OVER (PARTITION BY dup_scope, dup_sha1 ORDER BY dup_sup, dup_nk_rank > 1, dup_ord, source, batch, uri, range_offset, member_path, row_file, row_index) END AS dup_r_sha1, CASE WHEN dup_md5 IS NOT NULL THEN row_number() OVER (PARTITION BY dup_scope, dup_md5, size_bytes ORDER BY dup_sup, dup_nk_rank > 1, dup_ord, source, batch, uri, range_offset, member_path, row_file, row_index) END AS dup_r_md5
FROM (SELECT *, row_number() OVER (PARTITION BY source, uri, range_offset, member_path ORDER BY dup_sup, dup_date DESC, dup_rev DESC, batch DESC, row_file DESC, row_index DESC) AS dup_nk_rank,
  count(*) OVER (PARTITION BY source, uri, range_offset, member_path) AS dup_nk_n
FROM (SELECT *, dup_unit IS NOT NULL AND batch <> arg_max(batch, struct_pack(d := dup_sdate, r := dup_rev, b := batch)) OVER (PARTITION BY source, dup_unit) AS dup_sup
FROM (SELECT * REPLACE (CASE WHEN length(dup_sha256) = 64 AND regexp_full_match(dup_sha256, '[0-9a-f]+') THEN dup_sha256 END AS dup_sha256, CASE WHEN length(dup_sha1) = 40 AND regexp_full_match(dup_sha1, '[0-9a-f]+') THEN dup_sha1 END AS dup_sha1, CASE WHEN length(dup_md5) = 32 AND regexp_full_match(dup_md5, '[0-9a-f]+') AND size_bytes IS NOT NULL THEN dup_md5 END AS dup_md5),
  contains(lower(batch), 'revised') AS dup_rev
FROM (SELECT p.*, (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.pointer_id') WHEN coalesce(json_contains(json_extract(p.extra, '$._absent'), '"pointer_id"'), false) THEN NULL WHEN json_type(p.extra, '$.pointer_id') IS NOT NULL THEN json_extract_string(p.extra, '$.pointer_id') WHEN json_type(p.extra, '$.pid') IS NOT NULL THEN p.source || ':' || p.collection || ':' || json_extract_string(p.extra, '$.pid') WHEN p.parent_pointer_id IS NOT NULL AND p.member_path IS NOT NULL THEN CASE WHEN length(p.parent_pointer_id) - length(replace(p.parent_pointer_id, ':', '')) >= 2 THEN p.source || ':' || p.collection || ':' || substr(p.parent_pointer_id, strpos(p.parent_pointer_id, ':') + strpos(substr(p.parent_pointer_id, strpos(p.parent_pointer_id, ':') + 1), ':') + 1) || '!/' || p.member_path END WHEN b.pid_segments IS NOT NULL THEN p.source || ':' || p.collection || ':' || array_to_string(list_slice(string_split((CASE WHEN b.uri_swap_to IS NOT NULL AND json_extract_string(p.extra, '$._uri_orig') IS NULL THEN CASE WHEN starts_with(p.uri, b.uri_swap_to) AND ends_with(p.uri, b.uri_swap_suffix) AND length(p.uri) >= length(b.uri_swap_to) + length(b.uri_swap_suffix) THEN b.uri_swap_from || substr(p.uri, length(b.uri_swap_to) + 1, length(p.uri) - length(b.uri_swap_to) - length(b.uri_swap_suffix)) END ELSE p.uri END), '/'), -b.pid_segments, -1), '/') || CASE WHEN b.pid_at_offset THEN '@' || CAST(p.range_offset AS VARCHAR) ELSE '' END END) AS pointer_id, p.size_bytes IS NULL AS size_unknown,
  (CASE WHEN coalesce(nullif(CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.license_override.training_ok') WHEN json_type(p.extra, '$.license_override') IS NOT NULL THEN json_extract_string(p.extra, '$.license_override.training_ok') WHEN (p.license_spdx IS NOT NULL OR p.license_training_ok IS NOT NULL OR p.license_redistribution_ok IS NOT NULL OR p.license_notes IS NOT NULL) THEN p.license_training_ok WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"license_override"'), false) THEN b.const_training_ok END, ''), b.training_ok) IN ('yes', 'conditional', 'no') THEN coalesce(nullif(CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.license_override.training_ok') WHEN json_type(p.extra, '$.license_override') IS NOT NULL THEN json_extract_string(p.extra, '$.license_override.training_ok') WHEN (p.license_spdx IS NOT NULL OR p.license_training_ok IS NOT NULL OR p.license_redistribution_ok IS NOT NULL OR p.license_notes IS NOT NULL) THEN p.license_training_ok WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"license_override"'), false) THEN b.const_training_ok END, ''), b.training_ok) ELSE 'unknown' END) AS training_tier,
  (CASE WHEN coalesce(nullif(CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.license_override.redistribution_ok') WHEN json_type(p.extra, '$.license_override') IS NOT NULL THEN json_extract_string(p.extra, '$.license_override.redistribution_ok') WHEN (p.license_spdx IS NOT NULL OR p.license_training_ok IS NOT NULL OR p.license_redistribution_ok IS NOT NULL OR p.license_notes IS NOT NULL) THEN p.license_redistribution_ok WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"license_override"'), false) THEN b.const_redistribution_ok END, ''), b.redistribution_ok) IN ('yes', 'conditional', 'no') THEN coalesce(nullif(CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.license_override.redistribution_ok') WHEN json_type(p.extra, '$.license_override') IS NOT NULL THEN json_extract_string(p.extra, '$.license_override.redistribution_ok') WHEN (p.license_spdx IS NOT NULL OR p.license_training_ok IS NOT NULL OR p.license_redistribution_ok IS NOT NULL OR p.license_notes IS NOT NULL) THEN p.license_redistribution_ok WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"license_override"'), false) THEN b.const_redistribution_ok END, ''), b.redistribution_ok) ELSE 'unknown' END) AS redistribution_tier,
  coalesce((SELECT bool_and(c.checked) FROM c WHERE c.scope = 'file' AND c.row_file = p.row_file), false) AND NOT EXISTS (SELECT 1 FROM c WHERE c.scope = 'container' AND NOT c.checked AND c.source = p.source AND c.collection = split_part(p.collection, '@', 1)) AS checked_for_benchmarks,
  coalesce((CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.hash_scope') WHEN json_type(p.extra, '$.hash_scope') IS NOT NULL THEN json_extract_string(p.extra, '$.hash_scope') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"hash_scope"'), false) THEN b.const_hash_scope END), 'file') AS dup_scope,
  (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.hashes.sha256') WHEN json_type(p.extra, '$.hashes.sha256') IS NOT NULL THEN json_extract_string(p.extra, '$.hashes.sha256') WHEN coalesce(json_contains(json_extract(p.extra, '$._hx'), '"sha256"'), false) THEN NULL ELSE lower(hex(p.sha256)) END) AS dup_sha256,
  (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.hashes.sha1') WHEN json_type(p.extra, '$.hashes.sha1') IS NOT NULL THEN json_extract_string(p.extra, '$.hashes.sha1') WHEN coalesce(json_contains(json_extract(p.extra, '$._hx'), '"sha1"'), false) THEN NULL ELSE lower(hex(p.sha1)) END) AS dup_sha1,
  (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.hashes.md5') WHEN json_type(p.extra, '$.hashes.md5') IS NOT NULL THEN json_extract_string(p.extra, '$.hashes.md5') WHEN coalesce(json_contains(json_extract(p.extra, '$._hx'), '"md5"'), false) THEN NULL ELSE lower(hex(p.md5)) END) AS dup_md5,
  CASE p.source WHEN 'stackexchange-dump' THEN nullif((CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'site') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'site') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'site') END), '') END AS dup_unit,
  b.registry_order AS dup_ord,
  replace(regexp_extract(coalesce(p.batch, ''), '[0-9]{4}-?[0-9]{2}-?[0-9]{2}'), '-', '') AS dup_date,
  CASE WHEN p.source IN ('stackexchange-dump') THEN coalesce(nullif(replace(regexp_extract(coalesce(p.batch, ''), '[0-9]{4}-?[0-9]{2}-?[0-9]{2}'), '-', ''), ''), replace(regexp_extract(coalesce((CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'batch') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'batch') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'batch') END), ''), '[0-9]{4}-?[0-9]{2}-?[0-9]{2}'), '-', '')) ELSE '' END AS dup_sdate
FROM p JOIN b ON b.source = p.source AND b.batch = p.batch
WHERE NOT EXISTS (SELECT 1 FROM o WHERE o.scope = 'row' AND o.hit_class IN ('benchmark_copy', 'task_file', 'data_address') AND o.source = p.source AND o.uri = p.uri AND o.range_offset IS NOT DISTINCT FROM p.range_offset AND o.member_path IS NOT DISTINCT FROM p.member_path)
  AND NOT EXISTS (SELECT 1 FROM o WHERE o.scope = 'container' AND o.hit_class IN ('benchmark_copy', 'task_file', 'data_address') AND o.source = p.source AND o.collection = split_part(p.collection, '@', 1))
  AND coalesce((SELECT bool_and(c.default_keep) FROM c WHERE c.scope = 'file' AND c.row_file = p.row_file), false) AND NOT EXISTS (SELECT 1 FROM c WHERE c.scope = 'container' AND NOT c.default_keep AND c.source = p.source AND c.collection = split_part(p.collection, '@', 1)))))))
) WHERE duplicate_reason IS NULL;
```

The query reads the row tables remotely and only the columns it needs; a full pass over every source moves a few gigabytes. Add `p.source IN (...)` or read `data/<source>/*/*.parquet` to stay small; the duplicates are then resolved among the rows read. The view adds training_tier and redistribution_tier (yes, conditional, no or unknown), checked_for_benchmarks (true when the row was compared with the benchmark list and its collection is not awaiting a ruling) and natural_key_conflict (true when other rows with the same natural key were removed as duplicates and this one, the newest version by collection time, was kept).

## Ready-made queries

Each query runs on the `selected` view above.

1. Only rows that may be used for training (training tier yes or conditional):

```sql
SELECT p.source, p.uri, p.size_bytes, p.training_tier FROM selected p
WHERE p.training_tier IN ('yes', 'conditional') LIMIT 20;
```

   `python tools/fetch.py --tier yes,conditional --limit 20 --dry-run`

2. Only the latest version of each package. Latest means the version released last (by release time, so a fix released later for an older line counts as the latest); all files of that version are kept, and rows without a version or a release time are left out. Package ecosystems and the release time used:

| Source | Release time |
|---|---|
| pypi | `source_meta.upload_time` |
| npm | `source_meta.published` |
| crates-io | `source_meta.created_at` |
| cran | none (the snapshot lists only the current version of each package) |
| conda-forge-packages | `source_meta.timestamp` |
| ansible-galaxy-collections | `source_meta.published` |
| artifact-hub-helm-charts | `source_meta.created` |
| go-module-proxy-zips | `source_meta.index_timestamp` |
| hackage-packages | `source_meta.uploaded` |

   Not ordered by this query:

- debian-sources: rows carry no release time, and Debian versions need the dpkg ordering rules, which plain SQL does not have; each suite lists one version per source package, so choose a suite with `source_meta.suite` instead.
- nuget, rubygems: no release-time field is defined for these rows yet; every version is kept.

```sql
CREATE OR REPLACE VIEW latest_version AS
WITH v AS (
  SELECT p.*, concat_ws('/', p.collection, (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'chart') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'chart') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'chart') END)) AS package, (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'version') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'version') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'version') END) AS version,
    try_cast(CASE p.source WHEN 'pypi' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'upload_time') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'upload_time') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'upload_time') END) WHEN 'npm' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'published') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'published') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'published') END) WHEN 'crates-io' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'created_at') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'created_at') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'created_at') END) WHEN 'cran' THEN '1970-01-01T00:00:00Z' WHEN 'conda-forge-packages' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'timestamp') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'timestamp') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'timestamp') END) WHEN 'ansible-galaxy-collections' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'published') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'published') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'published') END) WHEN 'artifact-hub-helm-charts' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'created') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'created') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'created') END) WHEN 'go-module-proxy-zips' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'index_timestamp') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'index_timestamp') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'index_timestamp') END) WHEN 'hackage-packages' THEN (CASE WHEN starts_with(coalesce(p.extra, ''), '{"_row":') THEN json_extract_string(p.extra, '$._row.source_meta.' || 'uploaded') WHEN json_type(p.extra, '$.source_meta') IS NOT NULL THEN json_extract_string(p.extra, '$.source_meta.' || 'uploaded') WHEN NOT coalesce(json_contains(json_extract(p.extra, '$._absent'), '"source_meta"'), false) THEN json_extract_string(b.const_source_meta, '$.' || 'uploaded') END) END AS TIMESTAMPTZ) AS released
  FROM selected p JOIN b ON b.source = p.source AND b.batch = p.batch
  WHERE p.source IN ('pypi', 'npm', 'crates-io', 'cran', 'conda-forge-packages', 'ansible-galaxy-collections', 'artifact-hub-helm-charts', 'go-module-proxy-zips', 'hackage-packages')
), best AS (
  SELECT source, package, arg_max(version, released) AS version FROM (
    SELECT source, package, version, max(released) AS released FROM v
    WHERE version IS NOT NULL AND released IS NOT NULL GROUP BY ALL)
  GROUP BY ALL
)
SELECT v.* FROM v JOIN best ON best.source = v.source AND best.package = v.package AND best.version = v.version;
SELECT source, package, version, count(*) AS files FROM latest_version GROUP BY ALL ORDER BY 1, 2 LIMIT 20;
```

3. Only rows within the size cap of their batch (max_size_bytes in meta/batches.parquet, the cap `tools/fetch.py` uses by default; rows of unknown size stay in, and the script stops their download at the same cap):

```sql
SELECT p.source, p.uri, p.size_bytes, b.max_size_bytes FROM selected p JOIN b ON b.source = p.source AND b.batch = p.batch
WHERE p.size_bytes IS NULL OR p.size_bytes <= b.max_size_bytes LIMIT 20;
```

   `python tools/fetch.py --limit 20 --out ./files` (rows above the cap are recorded as too_large and not downloaded)

## Examples

`meta/catalog.parquet` has one row per source. Its column `domain` lists the subject codes of the source: a top-level code (D1 to D10) or a leaf below it (such as D1.6), or `multi` when the content spans many subjects, or `unclassified`. Its column `form` names the form of the items (for example `document-collections`). `meta/tags.parquet` holds the collection tags `campaign:<name>`.

1. Rows of the sources whose subject is D1 or one of its leaves, smallest first:

```sql
SELECT p.source, p.uri, p.size_bytes FROM selected p
WHERE p.source IN (SELECT source FROM (SELECT source, unnest(domain) AS code FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/catalog.parquet'))
                   WHERE code = 'D1' OR starts_with(code, 'D1.'))
ORDER BY p.size_bytes LIMIT 20;
```

   `python tools/fetch.py --domain D1 --limit 20 --dry-run`

2. CSV files of the sources of one form:

```sql
SELECT p.source, p.uri, p.size_bytes FROM selected p
WHERE lower(p.ext) = 'csv' AND p.source IN (SELECT source FROM read_parquet('hf://datasets/Battam/agentic-env-index/meta/catalog.parquet') WHERE form = 'document-collections')
LIMIT 20;
```

   `python tools/fetch.py --form document-collections --ext csv --limit 20 --out ./files`

3. The rows of one collection:

   `python tools/fetch.py --tag campaign:<name> --limit 20 --dry-run`

4. Three units of every source of one domain and form, with their answers, laid out for building tasks:

   `python tools/fetch.py --domain D3 --form spreadsheets-with-answers --sample 3 --out ./data`

`python tools/fetch.py --print-sql ...` prints the exact query the script runs, so any selection can be repeated in DuckDB. The script writes the files under `--out` as `<domain>/<source>/...` (units and companion files) and `answer/<source>/...` (answers and expected results), `_meta/manifest.jsonl` with one line per file (source, path, url, sha256, bytes, license, role, unit_group, answer_for and more), `_meta/sizes.tsv`, and `_meta/fetch_manifest.jsonl` with one line per selected row. It checks each download against the row's stated size and the hashes the row carries, and which hashes those are depends on the kind of row:

- Whole files and byte ranges: md5, sha1 and sha256 (and sha512 or a git blob sha1 when `extra` carries one; an S3 ETag of a single-part upload counts as md5). crc32 is not compared for them.
- Archive members (zip, other packages, 7z): size, crc32, md5, sha1 and sha256; zip members are also checked against the CRC32 in their local header. sha512 and git blob sha1 are not compared for them.
- WARC and ARC records: the payload size and md5, sha1 and sha256 of the payload.
- gzip members: the CRC32 and length in the gzip trailer, plus the row's crc32, md5, sha1 and sha256 when present.
- Rows with no hash are checked by size only, and rows marked `rolling` may differ from the index without failing (see below).

With `--check-content` it also flags downloads that are hard to use (scanned PDFs, error pages saved as files, extensions that do not match the content) in the manifest field `content_check`; this needs the `file` command and poppler-utils, which then parse the downloaded files (files from the internet) on your machine, and a check whose tool is missing is skipped and named there.

## How far to trust each card field

Each field of a card has `evidence.<field>.fill`, which says where its value came from:

- `auto`: computed by a program from the rows and the collection headers of the source when the card was built (`checked_at` is that day). Cards are built separately from the data and are not rebuilt with every upload.
- `judgment`: read from sample files that were downloaded and read, with `basis` (why) and `files` (which files). Some carry `second_judge`, an independent second reading. An `auto` value that was corrected after reading the sample is also recorded as `judgment`, with the reason in `basis`.
- `derived`: a fixed rule over other fields of the same card.
- `unfilled`: no evidence yet. The field is left empty on purpose; do not read an empty field as no or none.

A card whose `audit.status` is `draft` has not been reviewed as a whole. Before relying on a card, compare `snapshot.rev` with the commit you are reading and compare `size.files` with the source's count in meta/coverage.json.

| Field group | Fields | Usual fill | How far to trust it |
|---|---|---|---|
| Snapshot | `snapshot.rev`, `snapshot.rev_at`, `snapshot.at` | auto | Which data the card describes: `snapshot.rev` is the commit of the newest data file of the source when the card was built. If it is older than the commit you read, every count on the card is out of date. |
| Counts and file types | `size.files`, `size.bytes`, `unit.batches`, `form.by_ext`, `form.size_quantiles`, `form.over_cap`, `form.date_years` | auto | Exact for the rows that existed at `snapshot.rev`. For current numbers use meta/coverage.json or query the rows; the README totals are recounted at every upload. |
| License | `provenance.licence`, `provenance.licence_tiers`, `provenance.spdx_top` | auto | Copied from the source's own license statement and the rows' license columns. tools/fetch.py does not read the card: it uses the license columns and meta/batches.parquet. `provenance.licence_sample_check` is a judgment from the sample. |
| Benchmark overlap | `risk.contamination`, `risk.overlap_check` | auto, or unfilled when the source was not scanned | The result of the overlap scan at card build time. The default filter does not use it; meta/bench_overlap.parquet and meta/bench_checked.parquet are newer and are what counts. |
| What the files are | `unit.pointer_level`, `unit.usable_unit`, `form.artifact`, `form.source_origin`, `form.parse_cost`, `form.parse_quirks`, `structure.*`, `ships.*`, `subject.*` | judgment or unfilled | Read from a sample of downloaded files; `files` lists them. A share such as `ships.reference_solution.share` is k of the n files read. Treat it as a description of the sample. |
| Risks read from samples | `risk.pii`, `risk.pii_evidence`, `risk.malware` | judgment or unfilled | An empty value means nobody has looked, not that the source is clean. Card text shows email addresses and phone numbers as `[withheld]`, but a ten-digit number written with spaces and no plus sign (such as 555 123 4567) is not treated as a phone number, because it cannot be told apart from counts. |
| Access | `access.credential`, `access.range_supported`, `access.drift` | judgment or unfilled | Whether a row needs a login is in the row's `access.needs_auth` (see the README), not here. |
| Rules | `class`, `unit.state`, `risk.ship_bytes` | derived | `class` is a rule over `ships.*` and `structure`, `unit.state` follows `unit.pointer_level`, and `risk.ship_bytes` equals the redistribution tier. Only as good as the fields they read. |
| Retired | `access.reachable.index_flag` | auto | Retired: it counted whether one machine, since retired, could reach the files; it is now always `(none)` and will be removed in the next card version. |

## Rebuilding a batch from a collection tag

Collections are published in the repository `Battam/agentic-env-index`, together with `tools/to_pool.py`; the commands below read that repository and use the tools from it.

A collection is a set of rows chosen together for one task pool. Its rows carry the tag `campaign:<name>` and the batch name `<name>`, and record where each file goes in the pool (domain, path, role, answer) in `source_meta`. Its small files (the README, the LICENSE and the answers written for it) are placed under `campaign_files/<name>/`; their rows point there with a relative uri, which `tools/fetch.py` reads at the same commit as the tables. All other rows point to the upstream files.

Two commands rebuild the batch. Pin the commit so that a later run gets the same rows:

```
python tools/fetch.py --data hf://datasets/Battam/agentic-env-index --tag campaign:<name> --all --revision <commit> --out ./fetched
python tools/to_pool.py ./fetched --out ./pools --name <batch-folder>
```

`--revision <commit>` reads the tables at that commit. The same pin can be given as the root instead: `--data hf://datasets/Battam/agentic-env-index@<commit>`.

`--all` keeps every row of the collection: the rows were selected for the pool, and the default profile would drop some of them (for example rows above 20 MB). `tools/fetch.py` already writes the files in the pool's layout (`<domain>/<source>/<path>`, answers under `answer/<source>/`, `_meta/manifest.jsonl` and `_meta/sizes.tsv`), copies the pool fields of each row into `_meta/fetch_manifest.jsonl` and writes `_meta/fetch_run.json` with the repository, the commit and its arguments. `tools/to_pool.py` (Python standard library only, next to `tools/transform.py`) adds what the fetch tool does not do: it extracts the units that need `transform` steps, unpacks the units marked `expand`, checks that every source has its README.md and LICENSE and writes `<batch-folder>/<domain>/<source>/<path>`, with the answers under `answer/`, and `_meta/manifest.jsonl`, `_meta/sizes.tsv` and `_meta/delivery.json`. It writes nothing when a row was not downloaded.

Some upstream files change in place (live endpoints). Their rows are marked `rolling`: a size or sha256 that differs from the index is not an error, and the manifest keeps the bytes, sha256 and date actually downloaded with `differs_from_index`. Every other row must match the index exactly.

A unit stored upstream inside an archive or a compressed file has `transform` steps in its row: `unzip:<member>`, `untar:<member>`, `bunzip2`, `gunzip`, `unxz`, `unxxd`, `uudecode`, `uncompress` and `gzip` (level 9, modification time 0, no file name, so the output is the same on every machine). Only the named member is taken out of an archive and it must be a regular file; links and names that leave the output folder are refused. `unxxd` turns a hex dump written by `xxd` or `xxd -a` back into bytes (16 bytes per line in groups of two, a `*` line standing for lines of zero bytes) and refuses any other layout. `uudecode` decodes the lines between the first `begin <mode> <name>` line and its `end` line, never uses that name as a path, and refuses a file with no `begin` line, a second `begin` line or a line that does not decode. `uncompress` decompresses a `.Z` file of Unix `compress` (LZW, magic `1f 9d`, codes of 9 up to at most 16 bits read in groups of eight as `compress` writes them) and refuses a wrong magic, a maximum width outside 9 to 16 and a code that is not yet in the table. The output of `unxz`, `untar`, `unxxd`, `uudecode` and `uncompress` stops at 256,000,000 bytes (a sparse tar member counts at its full size). `tools/fetch.py` downloads and checks the upstream original; `tools/to_pool.py` runs the steps and checks the result against the sha256 recorded in the index (`unit_sha256`), or, when the last step is `gzip` (whose bytes depend on the zlib build), against `content_sha256`, the hash of the bytes before that step.