Repository navigation
build: fetch the corpus's big tier from an OCI image - #45
Merged
Merged
Conversation
Move the sidecar types, check_sidecar and the check that no two fixtures share a key out of tests/common/corpus.rs into tests/common/fixture.rs, so that a second loader of the corpus can use them. read_fixture reads a fixture and its sidecar and checks one against the other. A sidecar may now carry any version the loaders know, which is still only 2.
The corpus in tests/corpus/ is at the size the build doctrine allows. A bigger corpus now lives in one OCI image, ghcr.io/webern/deslag-blobs, pinned by digest in scripts/blobstore/blobs.lock. scripts/blobstore/blobs.sh is a copy of komp's blob store script. It fetches the image into .blobs/unpacked with crane, plans a publish, and publishes the tree as the next vN, one layer per batch. The copy now fetches without a login when gh has none, writes pax tars so that long names are kept, checks each tar against the tree before it is pushed, and checks for the tools each command needs in one pass. The build does not fetch. make test stays offline. make test-blobs fetches the image and runs the ignored tests in tests/blobs.rs, which load every batch and check it: each manifest line against its files and sidecar, each exclusion against an earlier batch, no fixture twice, every collected fixture of the tree in the big tier with the same bytes and sidecar, and no core fixture in it. make ci runs it, and CI caches .blobs on the hash of the lock. collect.py gains a pack stage that writes a tree's fixtures as a new batch with its manifest. v1 holds one batch: the 1200 collected fixtures of the tree.
docs/design/corpus.md is the approved design of the test corpus: what it is for, its two tiers, how a fixture earns its label, how the big tier is laid out in batches and grows, and what may read it. A fixture's origin is unique within its label, so a file's human revision and its later mixed revision may both be fixtures. docs/design/corpus.asbuilt.md says what is there today: the tree, the sidecar, the big tier's layout, collect.py and the loaders. The corpus parts of deslag.asbuilt.md move to it and leave a pointer. The build doctrine, AGENTS.md and deslag.toml learn about the blob store, test-blobs in make ci, and the new docs with their budgets.
The pin named v6.1.0 but held the v5.1.0 commit.
webern
marked this pull request as ready for review
September 27, 2026 01:53
5 tasks done
webern
added a commit
that referenced
this pull request
Sep 27, 2026
## Summary `docs/design/deslag.asbuilt.md` describes the code as it is. At a2d8ea1 it is 16378 bytes of its 16384 `max_size_bytes`, and it has been within 180 bytes of that budget since #23 (16352). Each of #44, #45 and #47 made room for its new paragraphs by cutting others, and #45 moved the corpus text out to `corpus.asbuilt.md`. The `deslag-design-docs` skill says a budget is not raised without the owner, so every change to the code has had to squeeze the doc. The budget was also kept by hand: `.agents/deslag.toml` did not select the doc. Selected at a2d8ea1, it fails `max_emphasis` (20 bold spans, 1.24% of its prose) and `density` (8 paragraphs over 500 characters). This PR splits the doc the way `corpus.asbuilt.md` already is: one as-built doc per subsystem, each with its own budget, and every one of them linted. - `deslag.asbuilt.md` is now the overview: what deslag is, a run, the modules at directory level and what calls what, an index of the subsystem docs, the command line and exit codes, other files, the tests and the build. Its budget drops from 16384 to 8192, so it cannot grow back into the place every detail goes. - `config.asbuilt.md`: the config, glob patterns, the walk and `deslag explain`. - `document.asbuilt.md`: the `Document` and frontmatter. It is named for `src/document/`, the module it holds. - `lints.asbuilt.md`: checking, marks, one section per lint in `Lint::ALL` order, reports and `--format`. A new lint is one new section. Each subsystem doc opens with its entry points and callers, then its `src/` tree, then one section per concern. `subsystems:` in each doc's frontmatter holds `src/` module names, each in exactly one doc: the one with its detail. | Doc | Bytes | Budget | `subsystems:` | |---|---|---|---| | `deslag.asbuilt.md` | 6786 | 8192 (was 16384) | `cli`, `instructions` | | `config.asbuilt.md` | 3889 | 5000 | `config`, `glob`, `explain` | | `document.asbuilt.md` | 2194 | 3000 | `document`, `parse` | | `lints.asbuilt.md` | 5884 | 7500 | `lint`, `output` | | `corpus.asbuilt.md` | 5998 | 8192 | `corpus` (unchanged) | ### Where each old section went | Section at a2d8ea1 | Now | |---|---| | intro, A run | `deslag.asbuilt.md`, as they were | | Modules | `deslag.asbuilt.md` keeps the tree at directory level and the paragraph on what calls what; each subsystem doc takes its file-level lines | | The document | `document.asbuilt.md`: Blocks; Tokens, sentences and locations | | Where a file's budget comes from | `lints.asbuilt.md`: max_size_bytes | | The config | `config.asbuilt.md`: The config, and Glob patterns for the `glob::Pattern` paragraph | | Frontmatter | `document.asbuilt.md`: Frontmatter | | Explaining a file | `config.asbuilt.md`: Explaining a file | | Walking the repo | `config.asbuilt.md`: Walking the repo | | Checking and reporting | `lints.asbuilt.md`: Checking, Marks, a section per lint, Reports, --format | | The command line, Other files, Tests, Build | `deslag.asbuilt.md`, as they were | ### Commits 1. `docs: split the as-built doc by subsystem`: the text moves as it was. New text is limited to each subsystem doc's opening sentences, the overview's index, the section headings, and short descriptions for the directories in the overview's tree, worded after the layout in `AGENTS.md`. `README.md` says the overview indexes the subsystem docs. 2. `docs: fix the lint findings in the as-built docs`: 8 paragraphs split at a sentence end, and 13 of 20 bold spans un-bolded. Each doc keeps its first two; the sentence that defines each of the others stays. No sentence is reworded. 3. `docs: correct the as-built docs against the code`: an ellipsis, U+2026, also ends a sentence (`src/document/sentences.rs:113`); `make clean` also runs `cargo clean` (`Makefile:98-99`); the trees now name `parse/mod.rs`, `ACKNOWLEDGEMENTS.md` and `.agents/skills/`; `explain` is in `subsystems:`, where no doc named it (`src/lib.rs:27`). 4. `test: lint every as-built doc and its subsystems`: - `.agents/deslag.toml` selects `/docs/design/*.asbuilt.md` in place of `corpus.asbuilt.md` alone. The glob does not select `deslag.desired.md`, which is written by hand and stays unlinted, and topic docs stay listed one by one. - A selected file with no budget is counted but never size-checked (`src/lint/max_size_bytes.rs:35-38`). An override on the same glob with `value = 4096` closes that: a frontmatter budget wins over it, and a doc that declares none fails at 4 KB. - `tests/asbuilt.rs` fails when a module under `src/` is named in no as-built doc's `subsystems:`, or in more than one, so a new module gets its doc on purpose. It finds the frontmatter with `Document` and reads it with `serde-saphyr`; no new dependency. ### Nothing lost in the move A script outside the repo cuts the a2d8ea1 doc into 177 units (each sentence, code line and heading) and 166 backticked names, and looks for each in the four new docs, with whitespace and bold markers ignored. After each commit: | After commit | Units missing | Names missing | |---|---|---| | 1 | 4 | 0 | | 2 | 4 | 0 | | 3 | 6 | 0 | | 4 | 6 | 0 | The six, each on purpose: - Three headings, `The document`, `Where a file's budget comes from` and `Checking and reporting`, replaced by the sections in the table above. - "Most specific first: the `max_size_bytes` key ..." now opens "A file's budget comes from, most specific first: ...". Its heading used to say what it was about; the section is now named for the lint. - The sentence rule now names the ellipsis (commit 3). - "`make clean` removes both directories" now adds "and runs `cargo clean`" (commit 3). The script proves each unit is somewhere, not that it is in the right place, so the trees were read by eye. ### Left as it was - The overview's paragraph on what calls what does not say that `explain` calls `config`, `glob` and `parse` too. It is not wrong, so it was not rewritten. - The tests stay in the overview; no doc owns them yet. - `corpus.asbuilt.md`, `corpus.md` and their lines in `.agents/deslag.toml` are untouched; the glob now selects `corpus.asbuilt.md` in place of its own line. ## Testing - [x] `make ci`: exit 0 - [x] `deslag check` on the repo: exit 0 with all five as-built docs selected; `deslag explain docs/design/deslag.desired.md` says it is not selected. - [x] A 5149-byte `docs/design/nofm.asbuilt.md` with no frontmatter fails at 4096 bytes; `deslag explain` shows the frontmatter budget winning over the override for `lints.asbuilt.md`. File removed after. - [x] `tests/asbuilt.rs` fails with `parse: in no doc` when `parse` is dropped from `document.asbuilt.md`, and with `lint: in corpus.asbuilt.md, lints.asbuilt.md` when `lint` is added to `corpus.asbuilt.md`, which also shows it reads a YAML block list. Both reverted. - [x] The residue script after each commit, as above. ## References - No issue. Related to #23, #44, #45 and #47, each of which squeezed the old doc.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
deslag's lints are decided and proven on a test corpus: Markdown quoted from public repositories, each file (a fixture) with a JSON sidecar that records where it came from, its licence, and whether its git history proves it
human,llmormixed. The corpus intests/corpus/is already as big as the build doctrine allows for git: about 400 fixtures per label. This PR adds a second tier, the big tier, that lives outside git and can keep growing, so that a lint's rule can be checked across thousands of repositories and not just the few hundred a maintainer has read. It also writes down the corpus design indocs/design/corpus.md(Status: APPROVED) and what is built indocs/design/corpus.asbuilt.md.The image and the lock
The big tier is one OCI image,
FROM scratch, atghcr.io/webern/deslag-blobs. Nothing runs it; it is a way to store versioned files in a registry.scripts/blobstore/blobs.lockpins it by digest. Its first line is the image, and each other line records one layer (a fingerprint of its content, the blob the registry holds for it, and its path) so that a publish can reuse unchanged layers byte for byte.blobs.shmoves the image withcrane, which it downloads into.tools/crane/at a pinned version and checks against a hash.layers.txtsays where layers split:corpus/andcorpus/batches/are listed, so each batch is its own layer and a publish uploads only the new batch.Layout
make fetch-blobsunpacks the image into.blobs/unpacked/, which git ignores:A manifest line repeats what a reader needs from the sidecar, so the batch can be filtered without opening every sidecar:
{"file": "human/nltk--nltk/README.md", "sha256": "ed157629...", "size_bytes": 1733, "label": "human", "host": "github.com", "repo": "nltk/nltk", "path": "README.md", "commit": "787575a4...", "sidecar_version": 2, "natural_language": "en", "kind": "readme", "ai_tools": []}Batches are append-only. A fixture found to be wrong is dropped by a later batch's
exclude.jsonl, and a later batch may add it again with a newer sidecar.Fetching and publishing
make fetch-blobsunpacks the pinned image. When.blobs/stampequals the lock, it is a file compare and nothing else.make test-blobsfetches, then runs the tests intests/blobs.rsthat are marked ignored.make cinow runstest-blobsaftertest.make build,make testandmake checkstay offline, with no login.make fetch-blobs, thencollect.py pack --from tests/corpus --corpus .blobs/unpacked/corpus --work DIR(or a later harvest) writes a new batch, thenmake test-blobs,scripts/blobstore/blobs.sh plan,make publish-blobs, and commitblobs.lockwithblobs.md.make clean-blobs(andmake clean) removes.blobs/and.tools/.Since git ignores
.blobs/, an edit under it that is not yet published is invisible togit status. When the lock changes (after a branch switch, pull or merge), fetch looks for such edits before it replaces the tree. If it finds any, it stops and says what they are and what to do, so a switch never silently throws away work.Access
The package is private for now.
ghlogin, which needsread:packages. Publishing needswrite:packages.blobs.shasksghfor the token each run and stores no login.ghlogin at all, fetch tries anonymously, which is all it will need once the package is public.webern/deslag, Write role. That grant is in place.GH_TOKENon the step,packages: readon the job, and the grant.make ci.CI
ci.ymlgetspackages: read,GH_TOKEN: ${{ github.token }}on themake cistep, and anactions/cachestep for.blobs, keyed onblobs-<os>-<hash of blobs.lock>, with no restore keys. A cache hit restores the tree and its stamp, so fetch does nothing and crane is not even downloaded.release.yml's verify job gets the same permission and token.What v1 holds
One batch,
2026-09-27-01: the 1200 collected fixtures oftests/corpus/, 400 each ofhuman,llmandmixed, byte for byte with their sidecars. That is 9,694,980 bytes of Markdown and 12,034,975 bytes in all, as one compressed layer of 4,804,592 bytes.core/is left out on purpose; it is hand-picked and has no proven label.ghcr.io/webern/deslag-blobs:v1@sha256:1fdc59d68fef2bc54f08f568fbd64117974c2b5203f6aba16b11b612e5803438v0in the registry was not pushed by this PR. It is a placeholder with one 116-byte layer, from when the package was set up.v1 is the tree and nothing more. A later change will harvest more.
The loader and its tests
tests/common/blobs.rshasload_blobs, which reads the batches in name order and checks each one:These rules are checked after every batch, not only the last, because every published version ends at some batch. The sidecar checks the two loaders share moved to
tests/common/fixture.rs, in their own commit.tests/blobs.rshas five offline tests that build small batches in a temp dir:It also has three ignored tests that
make test-blobsruns on the real image:core/fixture is in itcollect.pygains apackstage. It writes the tree's collected fixtures that the big tier does not hold yet into a new batch, with its manifest. It checks each fixture's bytes against its sidecar and refuses duplicates. Batches are namedYYYY-MM-DD-NNand must sort after every existing batch.Where the code came from
blobs.sh,layers.txtandblobs.mdare ported from an earlier private project of mine. What changed:ghlogin (anonymously); publish still needs one.bsdtaris called by name, so publishing on Linux needslibarchive-tools. Fetching works with anytar.curlonly, and hashes withsha256sumwhenshasumis missing.Choices worth a look
marko-js/htmljs-parserREADME.md,martinus/nanobenchREADME.md, andmldangelo/personal-sitedocs/adapting-guide.md. A rule of one fixture per host, repository and path would reject one of each pair, and then "every tree fixture is in the big tier" could not hold. Sopackand the loader key origin on label, host, repository and path. sha256 is still unique across all labels.ai_tools, so a reader can filter by tool without opening sidecars.Left for later
packreads exclusions but does not write them. For now an exclusion is written by hand into a new batch.publishdoes not refuse a tag that already exists in the registry (two publishes racing), or a published batch whose content changed. Batches are append-only by rule, not by check.Testing
make ci: exit 0, includingtest-blobs(fetched v1, 3 of 3 passed).blobs/:make testpasses (intests/blobs.rs, 5 passed and 3 ignored)make fetch-blobsthenmake test-blobs, 3 of 3 passed;make cleanremoved.blobs/and.tools/.blobs/unpacked/, switched to a branch whose lock differed, andmake fetch-blobsrefused, named the edit and left it in placeghhidden, fetch fails with the message for a person; withGITHUB_ACTIONS=true, the message for CIcrane registry serve): publish then fetch gives a byte-identical tree, long names included; a second publish reuses the first layer byte for byte; a batch holding only exclusions loads; excluding a tree fixture fails the superset testchecksums.txtcargo run -- check: the new docs lint clean within their budgetsmake cifails until the package is public.References
docs/design/corpus.mdcites for why deslag shows an agent no metric