Skip to content

ops(004): the mutation seeds start from the job's dependency artifacts - #565

Merged
bartekus merged 4 commits into
mainfrom
ci/seeds-warm-cache
Nov 8, 2026
Merged

bartekus merged 4 commits into
mainfrom
ci/seeds-warm-cache

Conversation

@bartekus

@bartekus bartekus commented Nov 8, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Each crates/rustev-eval/mutation/seeds.sh call gave its first worker an empty target directory, so every call cold-built rustev-eval's dependencies (1 to 2.5 minutes per call on the runner in #558's queue run) that the acceptance job had just restored from the cache. Eight calls run per merge-queue entry (selection: 029 061 064 065; runtime-evidence: 023 and live-comparison; integrations-base: 040; cli-backends: 041), plus spec 004's full run and 035/036/037/066.

Change (crates/rustev-eval/mutation/seeds.py)

  • Before the seeds run, the job's own tree builds (or finds fresh) the selected packages' tests in the job's target directory (CARGO_TARGET_DIR or target), with --message-format=json. Exactly the units cargo reports (by file-name digest: deps, .fingerprint, build entries) are copied, with their modification times, into the first worker's empty target directory. Incremental state is not copied, and the job's directory is never shared with the seed trees (their builds would overwrite its artifacts).
  • The seed trees are byte-for-byte copies of the job's tree with its modification times, so every copied unit is fresh until a seed edits a file; the edit makes the file newer, so cargo recompiles that crate and every crate depending on it.
  • A seed's verdict now also requires cargo to report the seeded crate compiled in that build (a compiler-artifact with fresh: false for the seeded file's crate). An artifact of the unseeded source can never stand in for a seed: such a seed is BROKEN ... not rebuilt, never detected.
  • A failed job build or copy (full disk) removes the partial copy and the run builds the units itself, as before.
  • The run prints the copied size and the work directory's size at the end (targets only grow, so this is the peak; hard links counted once).

Unchanged: the seeds, anchors, filters, required categories, verdict rules, the warm build and the per-worker copy for the second worker.

A first version copied only registry dependencies; locally that saved about 7 s per call, because the cost is the workspace crates (51 of 94 units), not the dependencies. Probe of this version: all 94 units fresh after the copy (3.8 GiB, 12 s); a seeded rustev-eval edit recompiles 47 units, a rustev-core edit 50.

Spec: spec 004 (owner of crates/rustev-eval/mutation) implementation record, 2026-11-07 line; derived shards refreshed.

Evidence

Local, interleaved before (origin/main seeds.py) and after (this head) per call, lane 5 on the shared 10-core Mac, SEEDS_JOBS=2 (the runner's worker count), CARGO_BUILD_JOBS=3, after cargo test -p rustev-eval --no-run in the job tree (as the acceptance leaves it). Other lanes were building at the same time, so single numbers are noisy.

Call Seeds Before After Detected after
spec 029 8 386 s 290 s 8/8
spec 061 7 537 s 400 s 7/7
spec 064 5 214 s 160 s 5/5
spec 065 5 328 s 288 s 5/5
spec 023 8 506 s 504 s 8/8
live-comparison 2 240 s 145 s 2/2
spec 040 7 319 s 299 s 7/7
spec 041 8 550 s 689 s 8/8
total 50 3,080 s 2,775 s 50/50

Every seed detected before is detected after (50/50; before was also 50/50), and no seed reported not rebuilt. The copy takes 8 to 9 s for 3.76 GiB and replaces the first worker's build of 94 units. The 041 "after" outlier came with heavier concurrent load on the machine; per-seed rebuilds are unchanged by design, so the saving per call is the first worker's cold build, which #558's runner logs put at 1 to 2.5 minutes per call.

Disk: the copy holds exactly the units the first worker would otherwise build (3.76 GiB here with full debuginfo; the runner uses line-tables-only). Work directory at the end (the peak), locally: 11.1 to 13.1 GiB across the eight calls. The runner figure is printed by each call in the queue run.

make gate and spec-spine couple pass.

Each `seeds.sh` call gave its first worker an empty target directory, so
every call cold-built rustev-eval's dependencies (1 to 2.5 minutes on the
runner) that the acceptance job had just restored from the cache and
built. Eight calls run per merge-queue entry.

The first worker's target directory is now seeded with a copy of the
registry and git dependency artifacts the selected packages build, taken
from the job's own target directory. No workspace crate's artifact,
fingerprint or incremental state is copied, and the job's directory is
never shared with the seed trees. A seed's verdict now also requires
cargo to report the seeded crate compiled in that build, so an artifact
of the unseeded source can never stand in for a seed. A failed copy falls
back to building the dependencies. The run prints the copied size and the
work directory's size at the end. Spec 004's implementation record has a
line for the change.
@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the two changed files: a Python mutation-testing harness (seeds.py) and its owning spec's implementation record.

crates/rustev-eval/mutation/seeds.py

crate_manifest correctly walks up from the file's directory and stops at src using os.path.realpath comparisons. rebuilt correctly parses cargo's JSON messages and identifies a fresh compile via m.get("fresh") is False -- json.loads maps false to Python False, so the identity check is sound.

dependency_names traverses the dependency graph carefully: dev deps are excluded for non-root packages, workspace members are banned from the allow-list, and the hyphen-to-underscore conversion for target names matches how cargo names artifacts on disk.

seed_dependencies filters using stem_ok and dir_ok. The stem_ok digest check (all(c in "0123456789abcdef" for c in digest)) is vacuously true for an empty digest (a file named foo-), but cargo never produces such artifact names, so this cannot misbehave on real inputs. The follow_symlinks=False guards in is_dir/is_file mean symlinks in deps/ are silently skipped; cargo would rebuild those dependencies as a safe fallback. The OSError / ValueError / KeyError catch on failure calls shutil.rmtree(dest) and returns None, causing the caller to proceed without the seed — correct.

The ordering in main is: seed dependencies into trees[0]'s target → (if n > 1) warm build → distribute to workers. For n == 1, no warm build occurs; rebuilt() will correctly require the mutated crate to compile afresh. The packages variable is hoisted before the try block so it's available to both the seeding call and the warm build.

The new rebuilt gate in try_seed closes a real correctness gap: previously a seed that cargo served from a stale cached artifact could pass or fail based on a prior (unseeded) binary. Now such a seed is marked BROKEN: not rebuilt rather than producing a spurious verdict.

specs/004-evaluation-and-replay/spec.md

The implementation record entry accurately reflects the code change (dependency seeding, rebuilt gate, fallback behavior, printed sizes). The spec is 004 which owns the eval harness; the update is correctly scoped to its own implementation record section.

No concrete defects found.

{"head": "d2b29e0150f14265ecf14a96438e7da0ea7b60e6", "verdict": "no-findings", "findings": []}

Subject: c575145...d2b29e0, diff digest 20839de70a2b8a6249fec5dcd7fa53a3dec101d3de82f3edd1645fb872657746, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the two changed files for bugs, security issues, and inconsistencies.

crates/rustev-eval/mutation/seeds.py

crate_manifest(src, path): walks up from os.path.join(src, path) checking for Cargo.toml, stops at src via realpath comparison. Correct.

rebuilt(stdout, manifest): parses cargo's --message-format=json stream and checks "reason" == "compiler-artifact" and "fresh" is False. The manifest_path in cargo's output is an absolute path under the seed tree (src), and crate_manifest likewise returns realpath under src, so they match. Correct.

try_seed changes: crate_manifest is called before the mutation is written (file exists, tree is intact). The rebuilt check is correctly placed after a successful --no-run build to ensure the seeded crate was actually recompiled. Correct.

dependency_names: BFS from workspace roots; dev-dependency exclusion (kinds <= {"dev"}) applies only when i not in roots — meaning dev deps of transitive dependencies are skipped, dev deps of the packages under test are followed. The kinds set uses None for normal deps (cargo's JSON encoding), so {"dev"} <= {"dev"} correctly identifies pure dev deps. allowed_pkgs - banned and allowed_stems - banned already exclude workspace crate names before returning.

stem_ok: fname.split(".", 1)[0].rpartition("-") correctly parses cargo artifact names like librustev_eval-abc123def.rlib; empty name (no - in stem) returns False; empty digest passes all(...) vacuously, but cargo never emits zero-length hashes in practice. The not names & banned guard is a correct redundant safety check since stems already excludes banned names.

seed_dependencies: copies only registry/git artifacts into an empty target directory; workspace crate artifacts and fingerprints are excluded both by stem_ok/dir_ok and by the banned set. Hard link accounting in tree_bytes via (dev, ino) pairs is correct. The OSError / CalledProcessError / ValueError / KeyError catch followed by shutil.rmtree(dest) and returning None safely falls back to a cold build.

main changes: seed_dependencies is called on trees[0]'s target before the warm build (if n > 1), so the warm build adds workspace artifacts on top of the pre-seeded dependencies. Copies to other workers then get both. The rebuilt check in try_seed ensures correctness regardless of what was pre-seeded.

specs/004-evaluation-and-replay/spec.md

The addition is an implementation record entry (non-normative), accurately describing the code changes. No normative text is modified; no authority or lifecycle fields are touched.

No bugs, security problems, or governance inconsistencies found.

{"head": "8f43ae882e5a2eddef78586692c3e2edf57fb388", "verdict": "no-findings", "findings": []}

Subject: c575145...8f43ae8, diff digest 6138765f6aae9b680d30b2169aceb865c84c21124c226e75a9ab3fe73e45cf49, 1 call(s). An AI comment is not an approval.

@github-actions

github-actions Bot commented Nov 8, 2026

Copy link
Copy Markdown

AI review (no-findings)

Reviewing the two changed files: crates/rustev-eval/mutation/seeds.py (new artifact-seeding logic for mutation testing) and specs/004-evaluation-and-replay/spec.md (implementation record addition).

crate_manifest: Termination is correct. The while not checks for Cargo.toml before comparing to src, so src itself is handled, and d cannot walk above src.

rebuilt: Uses is False (identity) for the boolean from JSON parsing. m.get("manifest_path", "") falls back to "" when absent; os.path.realpath("") returns cwd, but since manifest is an absolute path to a file, the cwd can't equal it. No false positive.

job_units: Uses cwd=ROOT with CARGO_TARGET_DIR=base; base is computed with os.path.abspath in main() so the absolute path is propagated correctly. Digest extraction (split(".", 1)[0].rpartition("-")[2]) correctly handles multi-hyphen crate names like rustev-backend-embed-linear. The build-script-executed branch's second condition (os.path.basename(os.path.dirname(os.path.dirname(path))) == "build") evaluates to False for the paths it generates (parent is build/, grandparent basename is debug), so it's dead code for that branch but harmless.

seed_target: Copies only deps, .fingerprint, build — incremental state (incremental/) is correctly excluded. Hard-link safety in tree_bytes via (st_dev, st_ino) is correct. The if not digests branch catches both None (build failed) and set() (build succeeded with no artifacts); the error message says "failed" for both but the fallback behavior (return None, build fresh) is correct either way. Minor message imprecision, not a code defect.

try_seed change: The manifest is None → BROKEN path is correct — if the owning Cargo.toml cannot be found, the verdict cannot be validated and broken is the right classification.

main() ordering: seed_target runs before the warm build for n > 1, seeding trees[0]'s target from the job's pre-existing artifacts. The warm build then runs in trees[0] (mostly cached), and its result is copied to trees[1:]. Correct.

Spec change: The addition to the ## Implementation record section of spec 004 is a historical note, not normative text. It accurately describes the new seeding behavior. No lifecycle or authority concern.

No concrete defects found.

{"head": "cdf3f4dfaf429ec2a64c2d58bad8c38510f11de8", "verdict": "no-findings", "findings": []}

Subject: c575145...cdf3f4d, diff digest da839bb58f94dc57b0a164c8a7b728b83c720ed084c6d6d6807f390ac0ddcbdd, 1 call(s). An AI comment is not an approval.

@bartekus
bartekus added this pull request to the merge queue Nov 8, 2026
Merged via the queue into main with commit d25f544 Nov 8, 2026
60 of 65 checks passed
@bartekus
bartekus deleted the ci/seeds-warm-cache branch November 8, 2026 06:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant