Skip to content

feat: harvest a big corpus with sidecar v3 - #52

Merged
webern merged 3 commits into
mainfrom
m/deslag-harvest
Sep 27, 2026
Merged

webern merged 3 commits into
mainfrom
m/deslag-harvest

Conversation

@webern

@webern webern commented Sep 27, 2026

Copy link
Copy Markdown
Owner

Summary

This grows the corpus's big tier from 1,200 fixtures to 21,891 live ones. It adds a second batch, 2026-09-27-02, with 21,075 fixtures from a new harvest: 11,473 human, 9,003 llm and 599 mixed. The same batch excludes the 384 fixtures of the first batch that recheck (#46) no longer proves. The tree is resampled so each label still holds 400.

To get there, collect.py changed in five places:

  • discover is now a list of named samplers. Each says whether it needs a gh login and skips itself without one. The new ones search Sourcegraph for agent files and for topics, some outside software, and search GitHub commits for the marks agents write.
  • harvest asks GitHub's GraphQL API about every candidate first, 100 at a time, so forks, bad licences and huge histories are never cloned. It clones in parallel, reads each history in one pass, checks a nearer LICENSE than the root one, logs failures and retries them on the next run, and asks GitHub about squash-merges as recheck does. It keeps up to 50 files of each label from a repository, at random, and always keeps a mixed file's human twin. --limit and --deadline bound a run.
  • stage is new, and it is the one writer of sidecars. It writes version 3 sidecars and the batch's repos.jsonl, the ledger of every repository the harvest tried.
  • pack checks that every before names a live human twin.
  • select samples the tree from the big tier, keeps what is still live, and refills each label.

Sidecar version 3 adds the raw evidence behind a label: each mark as written (text, tool, kind, place, commits), each marked commit's change to the file with its blob ids (edits), truncated, and the committer dates. A mixed sidecar may add before, which names its human twin (the same file at the last commit before 2022) and the commits between that are not an agent's. The loaders accept versions 2 and 3, check the ledger against the manifest, and check that every before names a live human fixture.

The big tier now holds files of 128KB at most; the tree stays at 64KB.

docs/design/corpus.md has a new Register section (there is no baseline label; register is a facet of human, tagged sg-register:), the twin rule, and the per-repository cap. docs/design/corpus.asbuilt.md and scripts/blobstore/blobs.md describe the new batch, the ledger and the discovery samplers. blobs.md now gives the image a budget of 250MB unpacked.

Discovery

discover found 70,418 distinct repositories, 67,878 of them on GitHub. A repository found by several samplers counts once in the total and once for each sampler below.

Sampler Token Repositories Seconds Notes
sourcegraph-agent-files no 31,390 about 900 8 patterns: CLAUDE.md, AGENTS.md, GEMINI.md, .github/copilot-instructions.md, .claude/ commands, agents and skills, .cursor/rules/, .kiro/, .windsurfrules
sourcegraph-topics no 21,510 software, 4,510 register 11,320 about a minute per query
github-commit-marks yes 11,695 2,215 18 searches, each on 20 random days
crates.io no 2,645 113 by downloads
gitlab-stars no 1,000 16
huggingface no 1,000 3
codeberg-stars no 497 59
npm no 244 33

Limits:

  • Sourcegraph searches only the repositories it indexes, a slice of public GitHub, and each query asks only for repositories with a permissive licence file at the root. A topic query takes the first 300 or 500 results. It needs no token, which is why it leads.
  • GitHub commit search returns at most 1,000 results per query, so each search is cut into single days. Its secondary rate limit fired at 3 seconds between searches, so the pace is now 6 seconds. It interleaves the searches by day, in random order, so a run cut short still covers every tool.
  • The topic search is slow and coarse. The register topics (books, courses, essays, law, recipes, wikis, curated lists and the like) gave 337 repositories that the harvest tried.
  • GitLab, Codeberg and Hugging Face gave almost nothing: under one human file per repository, and no llm.
  • crates.io failed at page 215 with HTTP 400, so it now reads pages under 200.

Pilot

200 repositories in sources order took 127 seconds. 39 more were skipped on GitHub's metadata before any clone. They gave 724 human, 116 llm and 13 mixed files, 11 of the mixed with their twin.

  • Repositories with agent files took 8.6 seconds each and gave 6.0 human, 2.9 llm and 0.38 mixed each.
  • 24 of 30 commit-search repositories were skipped for having no licence GitHub recognises.
  • Topic repositories gave 8.6 human files each; Hugging Face nearly none.
  • A fixture came to about 6.2KB of Markdown and 2.5KB of sidecar.

The pilot showed that time would not bind the run; bytes would. At the rate the whole run went, 4 to 6 hours of harvest would have come to 350 to 500MB, well past the 250MB budget.

The run

The harvest ran in legs, to steer toward the rarer sources, and one leg was a retry:

Leg Order and filter Limit Seconds human llm mixed
pilot sources 200 127 724 116 13
1 priority 500 1,019 5,726 1,234 343
2 priority 250 441 2,720 518 79
3 priority, commit search for every tool but Claude Code 1,000 621 905 3,586 74
3b the same, the 309 that failed in leg 3 309 5,072 673 3,418 108
4 priority, register topics 150 1,056 432 619 14
5 sources, register topics 150 165 631 284 7
all 8,501 11,811 9,775 638

priority order takes first the repositories an agent was found in that began before 2022, since only they can give mixed files; then the other agent repositories; then the rest. Within each, the sources take turns, a repository standing for the rarest source that found it. Discovery ran for about 4 hours alongside the legs.

Leg 3b was slow because its repositories lean on squash-merges, and the harvest asks GitHub about those at most 4,800 times an hour, under its limit.

What the ledger says about the 3,232 repositories tried:

  • 2,238 harvested, 989 skipped on GitHub's metadata (801 with no licence GitHub recognises, 67 GPL-3.0, 27 AGPL-3.0, and so on), 4 gone, and 1 with 60,361 commits, past the limit.
  • 4 more failed on network errors and are left for the next run.
  • 1,388 gave a fixture to the batch.
  • Files that qualified: 59,724 human, 64,039 llm and 739 mixed. Kept: 11,473, 9,003 and 599. Past the cap of 50, 3,938 llm files were not asked about.
  • Dropped while reading: 12,692 whose text may be older than their history (8,565 of those from one repository, tmorin/plantuml-libs), 2,879 under a nearer licence that is not allowed, and 1,792 whose bytes a merge commit changed.

stage then left out 1,022 files whose bytes another fixture already has, 68 whose origin the first batch holds, and 59 over 128KB.

The batch

human llm mixed
Fixtures 11,473 9,003 599
Repositories 873 677 238
  • 474 mixed fixtures have their human twin. 6 lost it in stage, where the twin was left out, and 119 never had one: no human revision of the file qualified at the cutoff. For most of those, the repository had no licence GitHub recognises at the cutoff.
  • llm by tool: Claude Code 5,254, Copilot 1,516, Cursor 752, Codex 620, Amp 352, Devin 331, Jules 205, OpenHands 190, opencode 136, Kiro 77, Aider 48. Six tools have 300 or more.
  • mixed by tool: Claude Code 412, Copilot 116, Cursor 73, Codex 20, and 4 each for Jules, Amp and Devin.
  • By first source: agent files 13,592, commit search 6,165, software topics 680, register topics 263, crates.io 210, npm 127, GitLab 22, Codeberg 16. Counted by any source in the ledger, register repositories gave 1,545 human, 967 llm and 81 mixed.
  • 17,834 in English, 3,108 in another language, 133 with no prose to tell.
  • 21,037 from GitHub, 22 from GitLab, 16 from Codeberg.

Bytes: 142,677,577 of Markdown and 203,442,958 in all (sidecars about 50MB, the manifest 9.3MB, the ledger 1.2MB). With the first batch the image is 215MB of its 250MB budget.

Sizes and the cap

Every file the harvest read has its size recorded, 22,261 in all: median 3,305 bytes, p90 15,551, p99 77,728, p99.9 367,767, largest 2,574,278.

Cap Files over it Their share of bytes
64KB 1.31% 27.1%
128KB 0.43% 17.6%
256KB 0.17% 11.9%

By label at 128KB: human 0.57% of files and 24.7% of bytes, llm 0.15% and 7.4%, mixed 2.18% and 37.4%. At 64KB, mixed would lose 5.3% of its files. So the cap is 128KB: it costs few files, and mixed files, which tend to be long, keep most of theirs. Many of the files over it are changelogs and link lists.

Exclusions

The batch excludes the 384 fixtures recheck found in #46: 204 llm and 180 mixed, none human. 339 of them rest on a squash of several commits, which cannot say who wrote one file. Most of the other 45 rest on a commit whose mark the rules of section 3 no longer accept, 2 on a bot's commit and 3 on text older than its history. Each line of exclude.jsonl gives the reason.

The tree

human llm mixed
Before 400 400 400
Dropped 0 204 180
Added 0 204 180
After 400 400 400

select kept every fixture still live and filled from the big tier. select --check passes. The floors hold: 400 in each label (the floor is 350), 18 layouts (the floor is 10), and the character test's llm >= 4 * human at 248 against 4 * 57 = 228 (it was 241 before). The tree now holds 204 llm and 180 mixed sidecars at version 3, and 147 of those mixed name a twin.

Golden files

make fix-golden moved only llm and mixed lines. Every changed line is a fixture dropped or added; no fixture that stayed changed its measurement, and core and human did not move.

Lint Fails before Fails after
banned_chars 469 (llm 241, mixed 165) 494 (llm 248, mixed 183)
banned_phrases 221 (llm 29, mixed 121) 207 (llm 32, mixed 104)
density 279 (llm 92, mixed 126) 294 (llm 104, mixed 129)
max_emphasis 491 (llm 230, mixed 173) 499 (llm 244, mixed 167)
max_size_bytes 166 (llm 25, mixed 106) 173 (llm 31, mixed 107)
repo_layout 2 (mixed 1) 3 (mixed 2)

The deslag fix tally

tests/corpus.rs pins what deslag fix does to the tree (#51), so the numbers are pinned again:

Before After
Banned characters 6,399 in 469 fixtures 7,423 in 494 fixtures
Fixed 5,400 6,443
Fixtures fixed whole 350 358
Left: replacement holds letters or digits 737 732
Left: the edit changes how the file reads 153 143
Left: in HTML 71 56
Left: in frontmatter 23 40
Left: default for a range of characters 14 6
Left: in a URL 1 1
Left: drawn as one with the character beside it 0 2

The last row is new: a corpus edit now reaches the grapheme check and is refused there.

Precision

A sample of the batch was checked against GitHub's own record, not the clone the harvest read. For each fixture: GitHub's list of the commits that touched the file up to the quoted commit, labelled again from their authors, committers and messages with the same rules and the same squash-merge questions; the bytes GitHub serves at that commit; for human, that no commit is late or marked; and for llm, that GitHub says the oldest commit added the file rather than renamed it. One fixture per repository in each stratum, 30 where there were 30 repositories. human is split by register, and llm and mixed by the kind of evidence: an agent's identity, a session trailer only, or a squash-merge GitHub proved.

Stratum Checked Label wrong Precision, 95% Wilson Commit list differs
human, register 30 0 1.000 [0.886, 1.000] 0
human, software 30 0 1.000 [0.886, 1.000] 0
llm, identity 30 0 1.000 [0.886, 1.000] 0
llm, session 30 0 1.000 [0.886, 1.000] 1
llm, squash-merge 30 0 1.000 [0.886, 1.000] 0
mixed, identity 30 0 1.000 [0.886, 1.000] 5
mixed, session 9 0 1.000 [0.701, 1.000] 2
mixed, squash-merge 30 0 1.000 [0.886, 1.000] 3

All 239 labels hold, and GitHub serves the same bytes for every one. In 11 the commits differ, though the label GitHub's list gives is the same:

  • In 9, GitHub lists fewer commits than the sidecar counts (for example 129 against 784 for cksystemsteaching/selfie/README.md). The harvest reads the whole history in one pass, so a file's history holds every commit that changed it on any branch. GitHub's list for a path leaves out a side branch whose changes a merge did not take.
  • In 2, a marked commit of the sidecar is not in GitHub's list. In valve-tech/reth, GitHub lists a copy of it instead, with the same change, author date and message under another hash; in tui-cs/Terminal.Gui, it is an ancestor of the quoted commit that changed the file, on a branch GitHub's list leaves out.

The image

v2 is published and pinned: ghcr.io/webern/deslag-blobs:v2@sha256:33d0d99e2d588f31d7d69563d62599486bcd1e89fe8efcfed6fcdf047d6fca00. It reuses the first batch's layer as it is, and adds one layer, corpus/batches/2026-09-27-02, which holds only the batch's 21,075 fixtures, their 21,075 sidecars, and its manifest.jsonl, exclude.jsonl and repos.jsonl.

From a cold cache (.blobs/ moved aside), make fetch-blobs unpacked v2 in 26 seconds, the unpacked tree was identical to the one published, and make test-blobs passed.

Other changes

  • The corpus tests place fixtures at their real paths, and the walk honours the global git excludes file. A new fixture sits under .vscode/, which some machines' global excludes ignore, so those machines walked a different corpus. place_real now writes a .ignore of !*, which takes precedence over the global file, so every machine walks the same files.
  • tests/blobs.rs builds its small batches from fixtures with no before, since the tree now holds some, and turns a sidecar into version 2 where a test needs one.
  • The pace file that the harvest's processes share for GitHub questions could be left holding two times run together, since a write was flushed after its lock was let go. It is now flushed first, and a bad value is read as "now".
  • In corpus.md, the example commit links in the marks table are cut to 10 hex characters, to keep the doc in its 16384-byte budget.

Deviations

  • The run was 7 legs, not one command, and it stopped at 8,501 seconds of harvest, not 4 to 6 hours. Bytes bound it, not time.
  • 474 mixed fixtures have a twin, a little under the 500 hoped for. The last priority leg gave 79 mixed files along with about 3,200 others, some 30MB, so more would have spent the budget's headroom.
  • 309 repositories of leg 3 failed on the pace-file bug above. They were retried in leg 3b, and 3 of them failed again on the network.
  • qualified in the ledger counts, for llm and mixed, the files whose commits prove the label. The check for text older than its history runs only on files that are read, so qualified overstates llm by what that check would drop.
  • A sidecar's found_by is the repository's first source only; the ledger lists all of them. So a register analysis should read the ledger: 263 fixtures carry sg-register: in their sidecar, while register repositories gave 2,593.
  • The full-history reading above means a mixed label may rest on an agent's commit on a side branch whose change a merge did not take. GitHub's list agreed on the label for all 69 mixed fixtures checked, but a later change could read the history as the file's own line of descent instead.

Left for later

  • A byte budget for a harvest run, in place of --deadline, and maybe a lower cap for human: it has 11,473 fixtures, well past the 3,000 to 5,000 hoped for, and the image has 35MB of budget left.
  • The 4 repositories that failed on the network are retried on the next run.
  • 3,938 llm files past the cap were not asked about. A later run can take them if a repository is worth more than 50.

Testing

  • make ci: exit 0
  • From a cold cache: make fetch-blobs unpacks v2 byte for byte as published, then make test-blobs passes
  • make test-blobs: every fetched batch keeps the rules, every tree fixture is in the big tier with the same sidecar
  • collect.py select --check: the tree is the sample it would take
  • scripts/blobstore/blobs.sh plan: the first batch is the same layer, the second is new; it took 10 seconds over both batches
  • Precision against GitHub's own record, per stratum (above)

References

harvest now keeps up to 50 files of each label from a repository,
picked at random, and asks GitHub about squash-merges as recheck does.
It asks GitHub's GraphQL API about every candidate first, so forks,
bad licences and huge histories are not cloned. It clones in parallel,
reads each history in one pass, checks nearer LICENSE files, and logs
failures to retry on the next run. --limit and --deadline bound a run.
The big tier holds files up to 128KB, the tree still 64KB.

discover is a list of named samplers. Each says if it needs a gh
login. New ones search GitHub commits for the marks agents write, and
Sourcegraph topics outside software.

stage is the one writer of sidecars. Version 3 adds the raw marks,
each marked edit with its blob ids, truncation and committer dates.
A mixed file names its human twin in before. Each batch may carry
repos.jsonl, the ledger of every repository tried.

select now samples the tree from the big tier and keeps what is
there. pack checks every before. The loaders read versions 2 and 3,
check the ledger, and check each before names a live human fixture.
The second batch of the big tier holds 21,075 fixtures from the
harvest: 11,473 human, 9,003 llm and 599 mixed. It also excludes the
384 fixtures of the first batch whose label recheck no longer proves,
204 llm and 180 mixed.

select drops those from the tree and fills each label back to 400
from the big tier. human does not change. The golden files move by
the fixtures dropped and added, and by nothing else.

The tally of deslag fix over the corpus is pinned again: 6,443 of
7,423 banned characters fixed, 358 fixtures fixed whole. Two are now
left because the character is drawn as one with the one beside it.

A new llm fixture sits under .vscode/, which a global git excludes
file may ignore. The corpus tests now write a .ignore that ignores
nothing, so every machine walks the same files.
v2 adds the layer for batch 2026-09-27-02 and reuses the layer of
the first batch as it is.
@webern webern added enhancement New feature or request ai Primarily authored by AI (whether PR, Issue, Whatever) labels Sep 27, 2026
@webern
webern merged commit 991c3d3 into main Sep 27, 2026
2 checks passed
@webern
webern deleted the m/deslag-harvest branch September 27, 2026 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ai Primarily authored by AI (whether PR, Issue, Whatever) enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant