nested-build-isolation
Skill1 starsChanged 30 days agoMITView on GitHub
Keep nested builds and coverage sessions out of each other. Use when a test, spike, or script spawns cargo, nextest, or the built binary inside a temporary sandbox; when tests pass under `cargo test` but fail under `cargo llvm-cov` or another instrumented run; when a coverage or benchmark sensor reports the same deficit on every run; or when instrumented children leave `*.profraw` files in the tree. Triggers: "nested cargo build", "cargo llvm-cov", "instrumentation", "coverage sensor", "os error 11", "EAGAIN", "profraw", "sandbox test".
- Reads credentials
1 other project uses a version of this.
Adopted by
Most recently taken up by
- d-o-hub/github-template-ai-agentstheir own version, first seen Nov 1, 2026
Other versions1 project uses a version of this.
Word for word · 0
None found.
Edited · 0
None found.
Wrote their own version · 1
- d-o-hub/github-template-ai-agents★ 2same name
How matches are found. Word for word: the exact same text. Edited: shares passages with this file (“99% same” means 99% of its five-word phrases also appear here; 10% or more counts). Their own version: similar meaning, or, weakest, the same name. We can’t tell which project had it first. Projects are counted among the 200 most-starred candidates, and mentions are links to the repository we found, up to 50 per site, so both counts are a floor.
In this repository20 other files it gives its agents.
- AGENTS.mdAGENTS.md
- codacy-analysis-cliSkill
- codacy-cloud-cliSkill
- codacy-code-reviewSkill
- configure-codacy-cloudSkill
- configure-codacySkill
- crates-io-name-checkSkill
- event-modelerSkill
- fail-closed-proxySkill
- harnessSkill
- htn-plannerSkill
- issue-to-prSkill
- move-only-decompositionSkill
- npm-github-publishSkill
- pr-triageSkill
- setup-coverageSkill
- skill-creatorSkill
- skill-distillerSkill
- spike-runnerSkill
- tokio-performanceSkill
The file
We split this skill into the rules it gives an agent
1 rule. About 0 are common, 1 is distinctive, and 0 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
0
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Distinctive: line 35
Every test/sensor spawn of a nested build goes through one helper that removes the inherited toolchain state.
≈ “Common” is an estimate: at least 1 in 5 of the 408,460 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
Nested Build Isolation
A nested build is any build or binary launch started from inside a test, sensor, or script. Two failure modes make it lie about the code:
- Inherited launcher state. The child re-enters the session that started it.
cargo llvm-covinstruments throughRUSTC_WRAPPER, aims builds at its ownCARGO_TARGET_DIR, and writes profiles throughLLVM_PROFILE_FILE; a nested coverage run that inherits them dies withResource temporarily unavailable (os error 11). The sandbox's own coverage sensor fails, itsverify --strictfails, and the assertions flip only under instrumentation — the plaincargo testrun stays green. - Metrics parsed from stdout. A wrapper's printed summary is not its
artifact.
cargo llvm-cov nextest --lcovprints no total table at all, so a parser that scans stdout matches nothing and reports a phantom finding on every run — long enough for the sensor to be quarantined while the real number is healthy.
Rule 1 — strip the launcher's state in the spawn helper
Every test/sensor spawn of a nested build goes through one helper that removes the inherited toolchain state. Child modules may access the parent's private items, so the helper stays private and the call sites stay unchanged:
fn isolated_command(program: &str) -> Command {
let mut command = Command::new(program);
for key in [
"CARGO_TARGET_DIR",
"CARGO_INCREMENTAL",
"CARGO_ENCODED_RUSTFLAGS",
"CARGO_LLVM_COV",
"CARGO_LLVM_COV_TARGET_DIR",
"RUSTC_WRAPPER",
"CARGO_BUILD_RUSTC_WRAPPER",
"RUSTC",
"RUSTDOC",
"RUSTFLAGS",
"RUSTDOCFLAGS",
] {
command.env_remove(key);
}
// Redirect rather than remove: without a profile path an instrumented child
// writes `default_*.profraw` into its working directory (the crate root).
command.env("LLVM_PROFILE_FILE", "/dev/null");
command
}RUSTC_WRAPPER is the load-bearing key: it is how the coverage session injects
instrumentation, so leaving it in place is what produces the os error 11
re-entry. Removing LLVM_PROFILE_FILE without redirecting it trades the failure
for litter.
Rule 2 — derive metrics from the artifact
Parse the report the tool writes, never the text it prints:
- lines:
LH(hit) overLF(found) in the lcov report; - branches:
BRHoverBRF, printed only when the report carries them.
Branch records are opportunistic: collecting them needs a nightly toolchain
(cargo +nightly llvm-cov nextest --branch …; the flag is unstable). A stable
channel writes none, so a line-only verdict is the expected output — and a
report with no line counts must keep the WARN … FINDINGS: 1 contract instead
of passing silently.
Rule 3 — prove it under the instrumented run
The plain suite cannot see this class of defect. Run the same tests through the coverage session and check the tree afterwards:
cargo llvm-cov nextest --no-fail-fast --lcov --output-path lcov.info
find . -name '*.profraw' | wc -l # 0: nothing leaked out of the profile pathGreen here plus an empty litter check is the evidence; a green cargo test is
not.
Anti-patterns
- Ignoring or deleting the test that only fails under instrumentation. The test is the only witness that the sandbox is hermetic; skipping it hides a real product bug in the nested build. Fix the spawn helper instead.
- Removing
LLVM_PROFILE_FILEinstead of redirecting it. The instrumented child then writesdefault_*.profrawbeside the sources it ran in. - Adding
--branchto obtain a branch number. It is unstable: on a stable toolchain it fails the build witherror: the option Z is only accepted on the nightly compiler, which kills the sensor rather than omitting branch data. - Reading a quarantined or
SKIP:-ing sensor as green. Both mean "not measured"; the phantom-finding case above reached quarantine precisely because the warn was read as noise.
Gotchas
- The symptom is environment-dependent by construction: if a failure appears
only under
cargo llvm-cov, suspect inherited state before code. - A sanitized child that still fails is a real failure — the isolation is what made it visible, not what caused it.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

