Skip to content

Commit 2530d7f

Browse files
authored
Merge landing batch t40: 1 pull requests (#635)
One merge for a batch of independent pull requests. Each was reviewed in its own lane. The tip merges every head below, and one end-to-end run plus the fast checks passed on that exact tree. - #635 test(setup): compare install trees file by file, so porting setup to Rust cannot change what gets installed unnoticed E2E evidence: https://github.com/GeiserX/OwnGenome/actions/runs/46044783604
2 parents 5b3cc9d + 72c75fd commit 2530d7f

11 files changed

Lines changed: 4466 additions & 2 deletions

File tree

‎CHANGELOG.md‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ Each release's notes. From 1.0.0 on, a major or minor release has hand-written n
44

55
## Unreleased
66

7+
- A new check compares two setup installs file by file, so the move of `scripts/setup.sh` to Rust cannot change what gets installed unnoticed. `og dev install-manifest` lists an install tree with each file's size, sha256 and permission bits, and compares two such lists. A file whose bytes change from run to run is compared by its kind: gzip content and container (BGZF or plain gzip), VCF with the dates masked, an index by its names, record counts and fit to the data, jellyfish counts with the host, folder and time of the header masked, or numbers rounded to 4 significant digits. Stamps are always compared byte for byte, and logs for their presence only. `tests/setup/ab.sh` installs one component with bash and with og and compares the trees, exit codes, logs, missing list, images, `NXF_HOME`, `bin/.og` and who owns what each side wrote, with a planted-byte control in a file the component wrote in every run; a side A that fails, or a run that installs nothing, is not green (`docs/testing.md`). Developer tooling only; nothing a user runs changes.
78
- A Locityper killed for memory (step 53) is now retried with twice the memory. The `LOCITYPER` task caught Locityper's exit code and wrote it into the table, so the task ended green and Nextflow never retried it: every locus read "not called". Now a kill (exit 137 or 143) on the first attempt ends the task with that code, and the retry writes the table, as before. `scripts/53-locityper.sh` has no retry engine, so it keeps writing the exit code into the table; its container already gets 16 GB. `tests/e2e/t3-run-fixes-1-memory-retry.sh` runs the module's real script with a stand-in Locityper that is killed once, every time, or never.
89
- CPSR (step 17) now asks for 16 GB, in the pipeline and in `scripts/17-cpsr.sh`. On a whole genome it was killed under process_medium's 8 GB, so every run paid a first attempt that could not finish, and on a host whose `--max_memory` is 8 GB both attempts died. Our end test had already measured a peak of 12.3-15.6 GB. `--max_memory` still caps the task; the same e2e case checks both the 16 GB and the cap. No other step's whole-genome peak in `docs/hardware-requirements.md` is above its request.
910
- `validate-setup.sh` now sees a resume whose work directory was given with `-w`. `run-all.sh` passes the work directory of its run (`-w`, `-work-dir`, `NXF_WORK`, or `<sample>/nextflow/work`) to it as `NXF_WORK`. A resume there is a warning under the 200 GB minimum, not a failure that stops the run. It counts as a resume only when the work directory holds tasks, the sample's `nextflow/` folder holds the Nextflow cache that `-resume` reads, and the sample's last Nextflow log (`nextflow/.nextflow.log`) names that work directory. So a work directory that other samples share is no resume of a fresh sample, nor of a sample that ran before in another work directory. When the work directory is on another disk, that disk's free space is checked too: under 200 GB it fails a fresh run. A disk with 0 GB free, either one, now fails too, also on a resume; the sample's disk at 0 GB used to pass with no line. `tests/fake-docker/t3-run-fixes-validate-work-dir.sh` covers both disks, a full disk on a resume, a shared work directory, a sample that ran before in another work directory, the same directory reached through a link, and `run-all.sh` with `-w` and with `NXF_WORK`.

‎docs/run-state.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ When `run-all.sh` ends, however it ends, a `planned` row gives way to the step's
2626

2727
`assets/steps.tsv` has one row per step: its number, its label as `run-all.sh` prints it, its `--tools` name, whether `run-all.sh` records it in `run_status.tsv`, its Nextflow processes, the report sections it feeds, the steps whose output it reads, and its usual hours. The hours are the upper end of the step's time in the [runtime table](hardware-requirements.md#runtime-per-step); `hours_from` says whether that figure was measured or is the page's estimate, and is empty when the table has no time for the step. On a measured row, `hours_low` is the lower end of the same measured time, always below `hours`; a part that runs once per reference, such as building an index, is left out of it.
2828

29-
`og dev steps-check` keeps the catalogue true (`cargo test -p og-dev` runs it on the checkout): every step `run-all.sh` plans has its row with the same label and tool, the recorded steps are the ones `og summary collect` checks for stale results, every report section belongs to the row of its step, every process in `modules/local` belongs to a step, and the tools are the ones `main.nf` accepts.
29+
`og dev steps-check` keeps the catalogue true (`cargo test -p og-dev` runs it on the checkout; build og first with `cargo build -p og`, as the same package's install-manifest tests run the og binary): every step `run-all.sh` plans has its row with the same label and tool, the recorded steps are the ones `og summary collect` checks for stale results, every report section belongs to the row of its step, every process in `modules/local` belongs to a step, and the tools are the ones `main.nf` accepts.
3030

3131
## What a step's state means
3232

‎docs/testing.md‎

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,6 +248,45 @@ How long `scripts/setup.sh --og` takes to build both binaries:
248248

249249
The cold build downloads the crates once; pulling `OG_BUILDER` the first time adds about 1 GB. The Rust workflow's `images` job prints both times for `ubuntu-latest` in its summary.
250250

251+
## Comparing setup installs
252+
253+
`scripts/setup.sh` moves to `og setup install` one component at a time. A full install takes about 19 hours, so a slice cannot be proven by running the whole setup again. Each slice runs [`tests/setup/ab.sh`](https://github.com/GeiserX/OwnGenome/blob/main/tests/setup/ab.sh) instead. It installs one component twice into the same empty folder, with bash (side A, `OG_SETUP=bash scripts/setup.sh --<component>`) and with og (side B, `OG_SETUP=og og setup install --<component>`), and compares what each run left:
254+
255+
- the install trees, file by file, with `og dev install-manifest` (below);
256+
- the exit codes;
257+
- the two logs, with times, durations, speeds, curl progress and image pull progress masked (a date inside a file name, such as `release-2026-11-26.tar.gz`, is part of the name and is not masked), and the missing list (`Missing (...)`, each item and its `retry:` line) line by line, unmasked, so a retry path that differs only by a date still counts;
258+
- the images and tags each side added or removed, `localhost/pgp-pinned/` tags included. Before side B, ab.sh removes the tags side A added for images side A's log names, each by its full name and tag, never by the image name alone, so side B starts from the images side A started from and must pull and pin them again. A pinned tag goes only when the log prints one digest reference, `NAME[:TAG]@sha256:HEX`, that gives that tag: its name and its digest must come from the same image. A tag another job added meanwhile is left alone;
259+
- each side's own `NXF_HOME`, where setup puts the nf-schema plugin;
260+
- `bin/.og`. Both sides start from the `bin/.og` that was there before side A: ab.sh restores it before side B, so side B cannot inherit a file side A added there.
261+
262+
Side B calls og itself and never `setup.sh`, so it cannot run bash in og's place. A bash-versus-og run therefore needs an og built from a checkout that has `og setup install`: ab.sh checks for that verb first and stops with exit 2 before side A when og lacks it (its automatic og build comes after this check). `--bash-vs-bash` skips the check. It runs side A's command twice, finds what changes from one run to the next with no code change, and its result says that no og side ran.
263+
264+
A run proves something only when the component did something, so ab.sh refuses three kinds of vacuous run. Side A must exit 0, or the code `AB_EXPECT_EXIT` names for a component meant to stop short; any other exit is red, and a side B that fails the same way does not make it green. Tree A must hold at least one entry the seed did not; a run that installs nothing exits 2. Every run ends with a control: ab.sh flips one bit of the smallest file that the component wrote (not a file the seed put there) and that the compare reads byte for byte in tree B, and the compare must turn red and name that file. A run whose control stays green, or that has no such file, exits 2.
265+
266+
ab.sh also lists every entry each side left that the user running it does not own (`find ! -user`), as a container run without `--user` writes root-owned files that the next setup run cannot rewrite or delete. Any such entry is red. The check can fail only where WORK_DIR keeps file owners, so ab.sh first gives a probe file there another group (as root, another owner) and reads it back. A volume that ignores owners, such as a macOS volume mounted `noowners`, takes the change and still shows every file as the user's: there ab.sh prints `[SKIP] foreign-files: this filesystem does not keep file owners` in place of a verdict, and its last line says `foreign-files skipped`. A user in one group only cannot run the probe, and gets `[SKIP] foreign-files: cannot tell whether this filesystem keeps file owners`. On macOS the container engine's file share also gives every file a container writes the host user as its owner, whatever the folder, so the owner evidence for a slice comes from a run on Linux. When a manifest cannot be taken (an unreadable file, say), ab.sh prints its error, kept in `<side>.manifest.err`, and exits 2.
267+
268+
A component that needs another one first, as most need the reference, gets it from `AB_SEED`. That folder is put into each side's empty folder before the side runs: as hard links on Linux, as APFS clones on macOS, never as symlinks, which a container cannot follow out of `GENOME_DIR`. Everything in it must belong to the user running ab.sh, and the seed must be unchanged at the end. That check compares a `*.log` file by its presence only, as every manifest does, so it cannot see a component rewrite a seeded log in place; through a hard link, such a rewrite reaches the seed and so side B. Seed from a throwaway copy unless the component never rewrites a seeded file in place. A component that writes a new file and renames it over the old one leaves the seed alone. `OG_DOWNLOADS` is shared by both sides, so side B reuses side A's downloads where setup reads that folder. Other variables exported before the call, such as `ARCHAIC_REGIONS`, reach both sides.
269+
270+
Only one ab.sh run may use a checkout at a time, as each run puts `bin/.og` back before its side B: a second run stops with exit 2 while `bin/.og.ab-lock` exists. Before side A, ab.sh builds og when it is missing or stale, so neither side builds it. Run ab.sh on a container engine that nothing else uses while it runs: the image check sees every change on the engine, so another job that pulls or pins an image turns it red.
271+
272+
### The manifest and its compare modes
273+
274+
`og dev install-manifest DIR` lists every file, folder and symlink under DIR with its type, size, sha256 and permission bits, by path relative to DIR. It leaves out the `downloads` folder at the top (a file of that name is listed). A `*.log` file is listed for its presence only, with `-` for its size, sha256 and mode: a log that one side writes and the other does not is red, and its bytes, with times and hosts in them, are not compared. A manifest has no comment lines, so a path may start with `#`, and a row that names one digest kind twice, or holds a digest value the manifest never writes, is refused. A file that changes while it is read (its size, modification time or identity) stops the manifest with exit 2, as its row would describe neither version. A file of at most 16 MiB is read whole and a larger one in chunks, its decompressed content always in chunks, and no read goes further than one byte past the size the walk saw. So a file that grows while it is read stops the manifest at once, and the memory one file takes stays bounded whatever its size. The manifest keeps one row per entry until it writes them out, sorted. A file of a kind with volatile bytes also gets the digest of what its compare mode reads, so a manifest can be compared after its tree is gone. `og dev install-manifest --compare A.tsv B.tsv --allow tests/setup/install-manifest-allow.tsv` prints one `DIFF` line per difference and exits 1 when there is one.
275+
276+
By default every file is compared byte for byte. A row of [`tests/setup/install-manifest-allow.tsv`](https://github.com/GeiserX/OwnGenome/blob/main/tests/setup/install-manifest-allow.tsv) names a path pattern, a compare mode, the component that writes the file and the reason. A row lets through only the bytes its mode is for:
277+
278+
| Mode | What is compared |
279+
|---|---|
280+
| `gzip` | the decompressed content, and the container: BGZF (every member a BGZF block, back to back to the end, each member ending where its block header says and decoding to at most 64 KiB) or plain gzip, since tabix and region reads need BGZF. The header's time and OS byte are ignored |
281+
| `vcf` | the VCF with the value of `##fileDate=` and the `Date=` part of each `##bcftools_<cmd>Command=` line masked, and its container (BGZF, plain gzip or none); the bcftools version and command lines still count. A header line over 16 MiB, its newline included, is compared as it is |
282+
| `index` | a `.tbi` or `.csi`: its header, its sequence names, and per sequence what does not move with the data file's bytes: the record counts of htslib's pseudo-bin and, for a `.tbi`, the length of the linear index (the last 16 kb window with a record); then the count of records with no position, and no other bytes after it. So an index of other sequence names, or with other record counts, is red. The mode does not prove that two indexes cover the same regions: two indexes with the same names and counts whose chunks fit the data compare equal, even if one lacks the bins of a region. The index must also fit the data file beside it, which must be a regular file and not a link (the manifest compares a link by its text, never its target): every chunk ends inside that file, and every chunk start and end points into a BGZF block that decodes whole, to at most 64 KiB, with a matching CRC and length, no further than the block's decoded length (at the end of the file, only at offset 0). The index parser reads at most 64 MiB: a larger index gets `index=invalid` and never compares equal under an `index` row. Offsets and bin numbers are not compared: they move with any byte of the data file, which has its own row. htslib merges a bin into its parent when its chunks span less than 64 KiB of the compressed file, so even the set of bins moves with the compressed sizes |
283+
| `jellyfish` | the JSON header with the values of `hostname`, `pwd` and `time` masked, then the counts. Jellyfish 2.3.1 pads the header with NUL bytes to its alignment and counts them in its 9-digit length; the NULs are left out, because a longer host name needs fewer of them. The rest of the header (the layout fields such as `counter_len`, the hash matrix and the command line) is compared, because it decides how the counts are read. A header over 16 MiB is compared byte for byte |
284+
| `numeric` | the lines and words of a text file; a word with a decimal point or an exponent is rounded to 4 significant digits, every other word is compared as it is. For a multithreaded float program such as smartpca. A value on a rounding edge makes the compare red, never green. Only a file of at most 16 MiB gets a numeric digest: a larger one is compared byte for byte, and a `numeric` row cannot let it through |
285+
| `skip` | nothing; the row must also say, in `cannot_compare`, why no other mode can compare the file. Every other row has `-` there |
286+
| `perm` | added to any mode, or alone: the permission bits may differ |
287+
288+
A stamp (`DONE`, `INSTALLED`, `RELEASE`, `version.txt`, `pins.tsv`, `*.stamp`, `*.installed`, `*.release`, `*.sha256`) is always compared byte for byte, because its bytes decide whether the next setup run installs the component again or reuses what is there. A row whose last segment can match any stamp name (`foo*`, `*.st?mp`, `*.tsv`) is refused. Each mode has a test with a real change inside a file of its kind that must turn the compare red (`rust/crates/og-dev/tests/install_manifest.rs`). Those tests and ab.sh's own tests run the og binary the same cargo build made, so build it first: `cargo build -p og && cargo test -p og-dev`. A workspace run (`cargo test`) builds it by itself.
289+
251290
## The parity harness
252291

253292
[`scripts/ci/oracle-diff.sh`](https://github.com/GeiserX/OwnGenome/blob/main/scripts/ci/oracle-diff.sh) runs the cases in [`tests/parity/cases.tsv`](https://github.com/GeiserX/OwnGenome/blob/main/tests/parity/cases.tsv) and compares their exit codes, stdout, stderr, named outputs, and new files with frozen goldens. It compares an input changed in place only when the case names it as an output. The goldens capture archived outputs and deliberate changes in the Rust ports. See the [parity case guide](https://github.com/GeiserX/OwnGenome/blob/main/tests/parity/README.md).

‎rust/Cargo.lock‎

Lines changed: 2 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

‎rust/crates/og-dev/Cargo.toml‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@ og-browser.workspace = true
2121
flate2.workspace = true
2222
indexmap.workspace = true
2323
png = "0.18"
24+
sha2 = "0.11"
25+
rustix.workspace = true
2426
fancy-regex = "=0.16.2"
2527
regex-syntax = "=0.8.11"
2628
regex = { version = "1", default-features = false, features = ["std", "perf", "unicode"] }

‎rust/crates/og-dev/src/build/mod.rs‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -343,6 +343,10 @@ mod fetch_tests {
343343
while !stop.load(Ordering::Relaxed) {
344344
match server.accept() {
345345
Ok((mut stream, _)) => {
346+
// On macOS an accepted socket inherits the
347+
// listener's O_NONBLOCK; a read before curl's
348+
// request arrives would fail with WouldBlock.
349+
stream.set_nonblocking(false).unwrap();
346350
stream.set_read_timeout(Some(Duration::from_secs(5))).unwrap();
347351
let mut reader = BufReader::new(&stream);
348352
let mut line = String::new();

0 commit comments

Comments
 (0)