[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M758AF71WYHV2S4BM0DJPT6E":3,"skill-same:01M758AF71WYHV2S4BM0DJPT6E":48},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":26,"commitSha":27,"skillDirectory":28,"forksCount":29,"repositoryHtmlUrl":30,"repositoryHomepageUrl":31,"ownerHtmlUrl":32,"ownerBlogUrl":31,"ownerDescription":33,"updatedAt":34,"install":35,"resources":47},"01M758AF71WYHV2S4BM0DJPT6E","rust-build",null,"Use when building or testing the nub Rust workspace inside a git worktree — `cargo build`\u002F`test`\u002F`clippy` for nub-cli\u002Fnub-core\u002Faube in a worktree off origin\u002Fmain. Explains how worktrees share ONE cargo target dir for fast incremental builds, the cross-worktree artifact-contamination hazard that sharing creates (the phantom `E0063: missing field` on correct source), and the wrapper (`scripts\u002Frust-build.sh`) that shares by default and auto-isolates the moment a worktree diverges a depended-on crate or `runtime\u002F`. Auto-triggers on a spurious cargo compile error that names a field\u002Fsymbol absent from your checkout, on \"worktree build contamination\", and on setting CARGO_TARGET_DIR for a worktree.","nubjs\u002Fnub","nubjs","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F6785695?v=4","01M7583N3EYYHSNB6FJQXCDMQH","Nub","01M7583N44MVMSN8385QEF3C8V",4440,"MIT","https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frust-build\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: rust-build\ndescription: >-\n  Use when building or testing the nub Rust workspace inside a git worktree —\n  `cargo build`\u002F`test`\u002F`clippy` for nub-cli\u002Fnub-core\u002Faube in a worktree off\n  origin\u002Fmain. Explains how worktrees share ONE cargo target dir for fast\n  incremental builds, the cross-worktree artifact-contamination hazard that\n  sharing creates (the phantom `E0063: missing field` on correct source), and the\n  wrapper (`scripts\u002Frust-build.sh`) that shares by default and auto-isolates the\n  moment a worktree diverges a depended-on crate or `runtime\u002F`. Auto-triggers on a spurious\n  cargo compile error that names a field\u002Fsymbol absent from your checkout, on\n  \"worktree build contamination\", and on setting CARGO_TARGET_DIR for a worktree.\nmetadata:\n  internal: true\n---\n\n# rust-build\n\nCross-worktree cache reuse wants a shared target dir; correctness wants isolation. `scripts\u002Frust-build.sh` resolves it — share by default, isolate automatically only when a worktree diverges a crate other crates link.\n\n## Use it\n\nDrop-in for `cargo`, from any worktree (or the main tree):\n\n```sh\nscripts\u002Frust-build.sh build -p nub-cli --profile fast\nscripts\u002Frust-build.sh test  -p nub-cli --test integration\nNUB_ALLOW_INCOMPLETE_RUNTIME=1 scripts\u002Frust-build.sh clippy --all-targets --all-features -- -D warnings\n```\n\nThat third line needs a staged `runtime\u002F` first, and opts out of the vendored-deps half because a lint ships nothing. The \"`--all-features` needs a staged addon AND the vendored runtime deps\" section below has the placeholder recipe and the two failure modes.\n\nIt prints which target dir it chose and why, then execs `cargo` with `CARGO_TARGET_DIR` set. Two default-on contention controls ride along:\n\n- **QoS clamp (darwin only):** cargo runs under `taskpolicy -c utility`, so interactive work preempts fleet builds; an uncontended build still gets all cores. `NUB_BUILD_FG=1` opts out.\n- **Job cap on big hosts (>8 cores):** `CARGO_BUILD_JOBS = ncpu-4` unless the caller already chose (pre-set `CARGO_BUILD_JOBS`, `NUB_BUILD_JOBS`, or an explicit `-j`\u002F`--jobs` — cargo's flag outranks the env var).\n\nThese cover builds going THROUGH the wrapper (or make). Direct `cargo` invocations are clamped by a machine-global control: `make qos-global` installs `scripts\u002Frustc-qos.sh` as the cargo `rustc-wrapper` in `~\u002F.cargo\u002Fconfig.toml`, so every rustc on the host compiles at utility QoS, at most TWO builds compile at a time (the rest queue first-come-first-served; `make build-status` shows the holders and the queue), and the compiling builds share `NUB_RUSTC_LIMIT` (default 6) rustc tokens (`install-dev` re-runs it, so it self-heals). `NUB_BUILD_FG=1` opts a HUMAN's foreground build out of the clamp and the queue (and, through this wrapper, out of the tokens too) — never set it from an agent; `NUB_BUILD_SLOTS=0` in a build's environment disables only the slot layer for that build. Toggling any of these does not invalidate fingerprints. Details: the `rust-build-hygiene` skill.\n\n## Why one shared target dir\n\nAll worktrees default to `~\u002F.cache\u002Fnub\u002Fshared-target`. A fresh worktree reuses the crates.io dependency rlibs a sibling already compiled and recompiles only the ~3 workspace crates — ~5s instead of a ~3-min cold build.\n\n**Relocation does NOT defeat reuse.** Cargo revalidates a relocated target dir in place: cloning a warm dir to a new path rebuilt 0 crates; an empty dir rebuilt all 13. (The \"path is baked into fingerprints\" claim is true of **sccache**, which keys on the rustc command line including absolute `--out-dir` \u002F `-L dependency=` paths — not of cargo.) So sharing a live path buys convergence; a CoW clone buys a warm start, which is why the wrapper seeds a fresh private dir from the matching bucket instead of cold-starting.\n\n## The hazard sharing creates\n\nCargo names a crate's output by **package id (name + version), not source content.** Two worktrees whose source for the same depended-on crate differs — classically `vendor\u002Faube` on divergent branches — write the same output slot and clobber each other. A dependent crate then links the stale rlib:\n\n```\nerror[E0063]: missing field `lockfile_legacy_basenames` in initializer of `aube_util::Embedder`\n```\n\n— a field that exists nowhere in your checkout. Only bites crates that **other crates link**; a divergent leaf binary (`nub-cli`) just rebuilds cleanly.\n\n## The rule the wrapper enforces\n\nSharers are grouped by the **content** of their depended-on crates, hashed into the bucket name (`shared-target-\u003Chash>`):\n\n- **Depended-on crate sources and `runtime\u002F` unmodified → share** that content's bucket. Everyone in it agrees by construction. The common case: feature work in `nub-cli`, integration tests, docs.\n- **Diverged a depended-on crate or `runtime\u002F` → isolate** to a private per-worktree `target\u002F` (removed with the worktree), CoW-seeded from the matching bucket so you rebuild only what differs. `runtime\u002F` is hashed for a different reason than the crates: a dev binary resolves `runtime\u002F*.cjs` from the tree that compiled `nub-core` (baked `CARGO_MANIFEST_DIR`), so a shared-bucket binary loads whichever sharer compiled last — a worktree with edited runtime files would silently test a sibling's copy.\n\n**Content, not merge-base:** a merge-base proves only that *this* worktree made no local changes against *its own* base, so two worktrees whose bases straddle a `nub-core`\u002F`aube` commit both pass while disagreeing on content. The key hashes the git **index**, which only matters on the shared branch (no local changes by definition), so it moves on rebase, never mid-edit.\n\nThe hashed set = every workspace\u002Fvendored crate **except leaf artifacts nothing links** — `crates\u002Fnub-cli` (bin), `crates\u002Fnub-native` (cdylib, own workspace), `crates\u002Fnub-phantom` (bin, own workspace) — **plus `runtime\u002F`**. So: `crates\u002Fnub-core`, `crates\u002Fnub-cache-key`, `crates\u002Fnub-phantom-core`, `crates\u002Fnub-phantom-scan`, all of `vendor\u002Faube`, and `runtime\u002F`. `nub-phantom-core`\u002F`nub-phantom-scan` are **not** leaves — `nub-cli` depends on both — and the pathspec `:(exclude)crates\u002Fnub-phantom` matches only that directory, not those siblings.\n\n## Letting the wrapper choose IS the caching strategy\n\n`export CARGO_TARGET_DIR` **overrides** the wrapper's resolution — it is how caching is LOST, not gained: you land in a cold dir, or a multi-tenant one you can clobber.\n\n**Never put an exported `CARGO_TARGET_DIR` in a dispatch prompt.** A sub-agent cannot know whether the value is the warm bucket, a cold path, or a dir a sibling is mid-build in; the wrapper does, and it prints which it chose and why.\n\n**Pin one only when seeding cannot fire** — a branch cut before seeding landed, or a filesystem without CoW:\n\n```sh\ngrep -c seed scripts\u002Frust-build.sh      # 0 → this branch has no seeding; pinning may pay\n```\n\nWhen you must pin for a **serial multi-phase epic**, point the whole chain at ONE dedicated private target so deps compile cold once:\n\n```sh\nexport CARGO_TARGET_DIR=~\u002F.cache\u002Fnub\u002F\u003Cepic>-target\n```\n\n- **Serial only** — cargo's target-dir lock serializes builds; never point two *concurrently-building* worktrees at it.\n- **Dedicated, NOT `shared-target`** — the shared dir is multi-tenant.\n- **A review\u002Fverify sub-agent reuses the implementer's already-warm target**, never a fresh one.\n\nFor a `orchestrator` run, pinning buys nothing: every lane edits ONE worktree and the orchestrator builds that same worktree.\n\n## Trade-offs and edges\n\n- **A worktree that edits aube pays a cold build even with no sibling diverging aube concurrently.** The invariant is \"match origin\u002Fmain,\" which doesn't depend on volatile sibling state — that's what makes it robust.\n- **Concurrent builds in two sharing worktrees serialize** on cargo's target-dir lock. A latency cost, never a correctness one. Need two at once? Isolate one.\n- **`NUB_SHARED_TARGET`** relocates the target dir and the path is used **exactly as given** — not content-keyed, because a caller naming a path is asking for that path (`make verify` relies on this to reach `$(CURDIR)\u002Ftarget`). The value must be **private to one checkout**; two worktrees on one relocated path recreates the phantom-`E0063` clobber. To relocate a cache several worktrees share, leave it unset and move `~\u002F.cache\u002Fnub` itself.\n- Cleanup: `git worktree remove \u003Cpath> --force` drops the worktree and its private `target\u002F`; the shared dir is intentionally left in place.\n- **A build script can pin an ABSOLUTE PATH into the shared dir** — a second contamination shape. A build script resolving inputs through compile-time `env!(\"CARGO_MANIFEST_DIR\")` bakes the compiling worktree's path into the cached build-script binary, which is cached per package id and survives into every sharing worktree. Symptom: `failed to read \u002F…\u002Fworktrees\u002F\u003Csome-other-tree>\u002F…` naming a directory absent from your checkout. Fixed at the source; for a stale one, `rm -rf \u003Ctarget-dir>\u002F*\u002Fbuild\u002F\u003Ccrate>-*` and rebuild. Note `cargo clean -p \u003Ccrate>` from the repo ROOT is a **silent no-op** for the aube crates — not root workspace members, so it reports `Removed 0 files` and exits 0.\n- **Running the vendored aube test suite from the repo root drops its serial-execution pin.** `vendor\u002Faube\u002F.cargo\u002Fconfig.toml` sets `RUST_TEST_THREADS = \"1\"` because some aube-util tests mutate process env, and cargo discovers config from the **CWD, not `--manifest-path`** — so `cargo test --manifest-path vendor\u002Faube\u002FCargo.toml …` from the root runs them in parallel and produces failures CI never sees. Run it as CI does: `(cd vendor\u002Faube && cargo test …)`.\n\n## The gates run on TWO profiles — budget for two dependency builds\n\n| Gate | Profile | CI line |\n| --- | --- | --- |\n| `cargo check --all-targets` | `fast` | 182 |\n| `cargo clippy --all-targets --all-features` | `fast` | 220 |\n| `cargo test` | **default (`dev`)** | 286, 790 |\n\n`fast` and `dev` are different target subdirectories, so clippy artifacts do not serve `cargo test`.\n\nDo not unify them: moving `cargo test` onto `fast` diverges from CI, and dropping `fast` from clippy drives a second full dependency build under `dev` (~26 GB of duplicated `target\u002Fdebug` + `target\u002Ffast`). `fast` inherits `dev` — identical debug-assertions, overflow checks and opt-level, differing only in debuginfo, which no lint reads.\n\n## A green gate run leaves NO runnable binary — build one explicitly\n\n| Command | What it writes | Leaves `target\u002Ffast\u002Fnub`? |\n| --- | --- | --- |\n| `cargo fmt --check` | nothing | no |\n| `cargo clippy --profile fast` | `.rmeta` only — clippy type-checks, does not link | **no** |\n| `cargo test` | test harness binaries under `target\u002Fdebug\u002F` | **no** |\n| `cargo build -p nub-cli --profile fast` | the linked CLI | yes |\n\nSo `fmt` + `clippy` + `test` can all be green while `target\u002Ffast\u002Fnub` is hours stale or absent — and it fails in the worst direction, because the old behavior usually still works, so the probe reads as a clean pass. Add an explicit `build` step whenever a gate run is followed by running the thing.\n\n**Bind the artifact to the source before trusting a fixture result.** An mtime newer than your last edit is necessary and not sufficient — a concurrent build can overwrite the path mid-run. Prove it positively by exercising a behavior only your change produces, and re-hash afterwards (or copy the binary aside and probe the copy).\n\n## Long cargo runs go in a BACKGROUND shell — never poll for them\n\nA cold build, `--all-targets` clippy or a full `cargo test` outlives the foreground timeout. Start\nit with the harness's background mechanism and let the completion notification wake you. **Do not\nwrite a wait loop**, and do not sleep on it: the harness already tracks it, so a poller is pure\nwaste and it can be WRONG in both directions.\n\nMeasured cost of getting this wrong: a loop polling `pgrep -f \"cargo|rustc\"` reported \"still\nbuilding\" for ten minutes AFTER the build had finished — `pgrep -f` matches the full command line\nINCLUDING the environment, so every process with `.cargo\u002Fbin` in its `PATH` matched. If you must\nask whether a compiler is running, match the executable name exactly:\n\n```sh\nps -Ao comm= | grep -cE '^(rustc|cargo)$'      # 0 = idle\n```\n\n## ANY cargo command REWRITES that profile's binary — with ITS features, not yours\n\n`cargo build -p nub-cli --profile fast --features nub-cli\u002Fbuild-jail-catalog-override` then\n`cargo test -p nub-cli --profile fast \u003Cfilter>` leaves `target\u002Ffast\u002Fnub` built **without** the\nfeature. `test` rebuilt the bin under the default feature set and clobbered it. Nothing warns;\nthe binary just quietly becomes a different one.\n\n**So re-arm the binary after ANY bare cargo invocation on the same profile**, before running a\nharness or a fixture against it:\n\n```sh\ncargo test -p nub-cli --profile fast \u003Cfilter>          # clobbers target\u002Ffast\u002Fnub\nscripts\u002Frust-build.sh build -p nub-cli --profile fast \\\n  --features nub-cli\u002Fbuild-jail-catalog-override        # re-arm before probing\n```\n\nCost when missed: a build-jail catalog probe reported `BROKEN-EVEN-WITH-EVERYTHING` for a package\nthat installs fine, because the featureless binary refused the override. It was diagnosable only\nbecause nub fails LOUD there (*\"NUB_BUILD_JAIL_CATALOG is set, but this binary was not built with\nthe build-jail-catalog-override feature… Refusing rather than running the compiled-in catalog\nunder an override's name\"*). A feature that degrades silently would have cost far more.\n\nRelated and distinct: `--features nub-sandbox\u002Fbuild-jail-catalog-override` enables it on the\nsandbox crate ONLY, so anything gated inside nub-cli compiles out while the sandbox-side banner\nstill prints — the override looks live and half of it is absent. `nub-cli` forwards the feature\n(`crates\u002Fnub-cli\u002FCargo.toml`), so the bare name and `nub-cli\u002F…` are equivalent; the `nub-sandbox\u002F…`\nform is the wrong one.\n\n## The gate's exit status must be CARGO's — three ways it silently isn't\n\n- **A pipe.** `cargo … | tail` gives you the PIPE's status.\n- **`| head -N`** additionally closes the pipe and SIGPIPE-kills cargo outright.\n- **Trailing commands.** `cargo … > log 2>&1; echo EXIT=$?; tail log` redirects correctly and still exits with **`tail`'s** status, so a harness reports 0 while cargo returned 101.\n\nThe habit that holds: redirect to a file, capture `RC=$?` immediately, and **end the command with `exit $RC`** so the shell's status IS cargo's. Read the log with `Read`\u002F`grep`, never `tail` in the same command whose status you care about. Confirm the recorded `RC=` line before believing a gate passed.\n\n## `--all-features` needs a staged addon AND the vendored runtime deps\n\n`--all-features` turns on `embed-runtime`, whose `build.rs` demands a complete runtime stage. Two separate pieces are absent in a fresh worktree, and each fails differently:\n\n| Missing | Failure |\n| --- | --- |\n| `runtime\u002Faddons\u002Fnub-native.node` (gitignored) | `cannot read entrypoint … for integrity hashing` |\n| `runtime\u002Fnode_modules\u002F` (the five vendored packages) | `missing vendored runtime packages: …` |\n\nThe vendored packages exist so a shipped binary can resolve its transpile helpers, which a lint never does. So for a lint, stage a placeholder addon and grant the opt-out rather than vendoring npm packages into your worktree — what CI's clippy job, `make verify` and `scripts\u002Fremote-build.ts` all do:\n\n```sh\nmkdir -p runtime\u002Faddons && printf 'placeholder-addon' > runtime\u002Faddons\u002Fnub-native.node\nNUB_ALLOW_INCOMPLETE_RUNTIME=1 scripts\u002Frust-build.sh clippy --all-targets --all-features -- -D warnings\n```\n\nThe digest only needs bytes to hash — a real addon is not required to lint. Never set `NUB_ALLOW_INCOMPLETE_RUNTIME` for a build whose binary you intend to run, install or ship: that is the case the check exists to stop.\n\n## Two crates are their OWN workspaces — `-p` from the root cannot see them\n\n`crates\u002Fnub-native` (panic-strategy split) and `crates\u002Fnub-launcher` (size-tuned release profile) each have their own `[workspace]`, so `cargo build -p nub-launcher` from the root fails with `package ID specification 'nub-launcher' did not match any packages`. Build from inside the crate, or with `--manifest-path`. CI lints each separately.\n\n## Build `nub-native` with `cd crates\u002Fnub-native`, NEVER `--manifest-path`\n\n`crates\u002Fnub-native\u002F.cargo\u002Fconfig.toml` sets `target-dir = \"..\u002F..\u002Ftarget\"` so the addon lands in the repo-root `target\u002F\u003Cprofile>\u002F` that the Makefile and CI copy from. Cargo discovers config by walking up from the CWD, not from the `--manifest-path` directory — so `cargo build --manifest-path crates\u002Fnub-native\u002FCargo.toml --release` silently writes to `crates\u002Fnub-native\u002Ftarget\u002F`, and the follow-on `cp target\u002Frelease\u002Flibnub_native.dylib runtime\u002Faddons\u002Fnub-native.node` copies a stale artifact or fails.\n\n## An \"unused import\" warning does NOT mean the import is unused — check `cfg(test)` first\n\nA non-test build warns `unused import: X` for an import only `mod tests` consumes through `use super::*`. Deleting it turns one warning into N compile errors in the test target. Before removing a flagged import, `grep` the symbol in the same file: if the hits are past the `#[cfg(test)]` line, move the import *into* `mod tests`.\n\n## Related skills\n\n`new-worktree.ts` creates the worktree and points you at this wrapper. `dev-loop` covers the fast-profile incremental loop; this skill owns the target-dir decision. When a build fails with a symbol\u002Ffield absent from your source, this is almost always the cause — rebuild through `rust-build.sh` and it isolates you.\n","# rust-build\n\nCross-worktree cache reuse wants a shared target dir; correctness wants isolation. `scripts\u002Frust-build.sh` resolves it — share by default, isolate automatically only when a worktree diverges a crate other crates link.\n\n## Use it\n\nDrop-in for `cargo`, from any worktree (or the main tree):\n\n```sh\nscripts\u002Frust-build.sh build -p nub-cli --profile fast\nscripts\u002Frust-build.sh test  -p nub-cli --test integration\nNUB_ALLOW_INCOMPLETE_RUNTIME=1 scripts\u002Frust-build.sh clippy --all-targets --all-features -- -D warnings\n```\n\nThat third line needs a staged `runtime\u002F` first, and opts out of the vendored-deps half because a lint ships nothing. The \"`--all-features` needs a staged addon AND the vendored runtime deps\" section below has the placeholder recipe and the two failure modes.\n\nIt prints which target dir it chose and why, then execs `cargo` with `CARGO_TARGET_DIR` set. Two default-on contention controls ride along:\n\n- **QoS clamp (darwin only):** cargo runs under `taskpolicy -c utility`, so interactive work preempts fleet builds; an uncontended build still gets all cores. `NUB_BUILD_FG=1` opts out.\n- **Job cap on big hosts (>8 cores):** `CARGO_BUILD_JOBS = ncpu-4` unless the caller already chose (pre-set `CARGO_BUILD_JOBS`, `NUB_BUILD_JOBS`, or an explicit `-j`\u002F`--jobs` — cargo's flag outranks the env var).\n\nThese cover builds going THROUGH the wrapper (or make). Direct `cargo` invocations are clamped by a machine-global control: `make qos-global` installs `scripts\u002Frustc-qos.sh` as the cargo `rustc-wrapper` in `~\u002F.cargo\u002Fconfig.toml`, so every rustc on the host compiles at utility QoS, at most TWO builds compile at a time (the rest queue first-come-first-served; `make build-status` shows the holders and the queue), and the compiling builds share `NUB_RUSTC_LIMIT` (default 6) rustc tokens (`install-dev` re-runs it, so it self-heals). `NUB_BUILD_FG=1` opts a HUMAN's foreground build out of the clamp and the queue (and, through this wrapper, out of the tokens too) — never set it from an agent; `NUB_BUILD_SLOTS=0` in a build's environment disables only the slot layer for that build. Toggling any of these does not invalidate fingerprints. Details: the `rust-build-hygiene` skill.\n\n## Why one shared target dir\n\nAll worktrees default to `~\u002F.cache\u002Fnub\u002Fshared-target`. A fresh worktree reuses the crates.io dependency rlibs a sibling already compiled and recompiles only the ~3 workspace crates — ~5s instead of a ~3-min cold build.\n\n**Relocation does NOT defeat reuse.** Cargo revalidates a relocated target dir in place: cloning a warm dir to a new path rebuilt 0 crates; an empty dir rebuilt all 13. (The \"path is baked into fingerprints\" claim is true of **sccache**, which keys on the rustc command line including absolute `--out-dir` \u002F `-L dependency=` paths — not of cargo.) So sharing a live path buys convergence; a CoW clone buys a warm start, which is why the wrapper seeds a fresh private dir from the matching bucket instead of cold-starting.\n\n## The hazard sharing creates\n\nCargo names a crate's output by **package id (name + version), not source content.** Two worktrees whose source for the same depended-on crate differs — classically `vendor\u002Faube` on divergent branches — write the same output slot and clobber each other. A dependent crate then links the stale rlib:\n\n```\nerror[E0063]: missing field `lockfile_legacy_basenames` in initializer of `aube_util::Embedder`\n```\n\n— a field that exists nowhere in your checkout. Only bites crates that **other crates link**; a divergent leaf binary (`nub-cli`) just rebuilds cleanly.\n\n## The rule the wrapper enforces\n\nSharers are grouped by the **content** of their depended-on crates, hashed into the bucket name (`shared-target-\u003Chash>`):\n\n- **Depended-on crate sources and `runtime\u002F` unmodified → share** that content's bucket. Everyone in it agrees by construction. The common case: feature work in `nub-cli`, integration tests, docs.\n- **Diverged a depended-on crate or `runtime\u002F` → isolate** to a private per-worktree `target\u002F` (removed with the worktree), CoW-seeded from the matching bucket so you rebuild only what differs. `runtime\u002F` is hashed for a different reason than the crates: a dev binary resolves `runtime\u002F*.cjs` from the tree that compiled `nub-core` (baked `CARGO_MANIFEST_DIR`), so a shared-bucket binary loads whichever sharer compiled last — a worktree with edited runtime files would silently test a sibling's copy.\n\n**Content, not merge-base:** a merge-base proves only that *this* worktree made no local changes against *its own* base, so two worktrees whose bases straddle a `nub-core`\u002F`aube` commit both pass while disagreeing on content. The key hashes the git **index**, which only matters on the shared branch (no local changes by definition), so it moves on rebase, never mid-edit.\n\nThe hashed set = every workspace\u002Fvendored crate **except leaf artifacts nothing links** — `crates\u002Fnub-cli` (bin), `crates\u002Fnub-native` (cdylib, own workspace), `crates\u002Fnub-phantom` (bin, own workspace) — **plus `runtime\u002F`**. So: `crates\u002Fnub-core`, `crates\u002Fnub-cache-key`, `crates\u002Fnub-phantom-core`, `crates\u002Fnub-phantom-scan`, all of `vendor\u002Faube`, and `runtime\u002F`. `nub-phantom-core`\u002F`nub-phantom-scan` are **not** leaves — `nub-cli` depends on both — and the pathspec `:(exclude)crates\u002Fnub-phantom` matches only that directory, not those siblings.\n\n## Letting the wrapper choose IS the caching strategy\n\n`export CARGO_TARGET_DIR` **overrides** the wrapper's resolution — it is how caching is LOST, not gained: you land in a cold dir, or a multi-tenant one you can clobber.\n\n**Never put an exported `CARGO_TARGET_DIR` in a dispatch prompt.** A sub-agent cannot know whether the value is the warm bucket, a cold path, or a dir a sibling is mid-build in; the wrapper does, and it prints which it chose and why.\n\n**Pin one only when seeding cannot fire** — a branch cut before seeding landed, or a filesystem without CoW:\n\n```sh\ngrep -c seed scripts\u002Frust-build.sh      # 0 → this branch has no seeding; pinning may pay\n```\n\nWhen you must pin for a **serial multi-phase epic**, point the whole chain at ONE dedicated private target so deps compile cold once:\n\n```sh\nexport CARGO_TARGET_DIR=~\u002F.cache\u002Fnub\u002F\u003Cepic>-target\n```\n\n- **Serial only** — cargo's target-dir lock serializes builds; never point two *concurrently-building* worktrees at it.\n- **Dedicated, NOT `shared-target`** — the shared dir is multi-tenant.\n- **A review\u002Fverify sub-agent reuses the implementer's already-warm target**, never a fresh one.\n\nFor a `orchestrator` run, pinning buys nothing: every lane edits ONE worktree and the orchestrator builds that same worktree.\n\n## Trade-offs and edges\n\n- **A worktree that edits aube pays a cold build even with no sibling diverging aube concurrently.** The invariant is \"match origin\u002Fmain,\" which doesn't depend on volatile sibling state — that's what makes it robust.\n- **Concurrent builds in two sharing worktrees serialize** on cargo's target-dir lock. A latency cost, never a correctness one. Need two at once? Isolate one.\n- **`NUB_SHARED_TARGET`** relocates the target dir and the path is used **exactly as given** — not content-keyed, because a caller naming a path is asking for that path (`make verify` relies on this to reach `$(CURDIR)\u002Ftarget`). The value must be **private to one checkout**; two worktrees on one relocated path recreates the phantom-`E0063` clobber. To relocate a cache several worktrees share, leave it unset and move `~\u002F.cache\u002Fnub` itself.\n- Cleanup: `git worktree remove \u003Cpath> --force` drops the worktree and its private `target\u002F`; the shared dir is intentionally left in place.\n- **A build script can pin an ABSOLUTE PATH into the shared dir** — a second contamination shape. A build script resolving inputs through compile-time `env!(\"CARGO_MANIFEST_DIR\")` bakes the compiling worktree's path into the cached build-script binary, which is cached per package id and survives into every sharing worktree. Symptom: `failed to read \u002F…\u002Fworktrees\u002F\u003Csome-other-tree>\u002F…` naming a directory absent from your checkout. Fixed at the source; for a stale one, `rm -rf \u003Ctarget-dir>\u002F*\u002Fbuild\u002F\u003Ccrate>-*` and rebuild. Note `cargo clean -p \u003Ccrate>` from the repo ROOT is a **silent no-op** for the aube crates — not root workspace members, so it reports `Removed 0 files` and exits 0.\n- **Running the vendored aube test suite from the repo root drops its serial-execution pin.** `vendor\u002Faube\u002F.cargo\u002Fconfig.toml` sets `RUST_TEST_THREADS = \"1\"` because some aube-util tests mutate process env, and cargo discovers config from the **CWD, not `--manifest-path`** — so `cargo test --manifest-path vendor\u002Faube\u002FCargo.toml …` from the root runs them in parallel and produces failures CI never sees. Run it as CI does: `(cd vendor\u002Faube && cargo test …)`.\n\n## The gates run on TWO profiles — budget for two dependency builds\n\n| Gate | Profile | CI line |\n| --- | --- | --- |\n| `cargo check --all-targets` | `fast` | 182 |\n| `cargo clippy --all-targets --all-features` | `fast` | 220 |\n| `cargo test` | **default (`dev`)** | 286, 790 |\n\n`fast` and `dev` are different target subdirectories, so clippy artifacts do not serve `cargo test`.\n\nDo not unify them: moving `cargo test` onto `fast` diverges from CI, and dropping `fast` from clippy drives a second full dependency build under `dev` (~26 GB of duplicated `target\u002Fdebug` + `target\u002Ffast`). `fast` inherits `dev` — identical debug-assertions, overflow checks and opt-level, differing only in debuginfo, which no lint reads.\n\n## A green gate run leaves NO runnable binary — build one explicitly\n\n| Command | What it writes | Leaves `target\u002Ffast\u002Fnub`? |\n| --- | --- | --- |\n| `cargo fmt --check` | nothing | no |\n| `cargo clippy --profile fast` | `.rmeta` only — clippy type-checks, does not link | **no** |\n| `cargo test` | test harness binaries under `target\u002Fdebug\u002F` | **no** |\n| `cargo build -p nub-cli --profile fast` | the linked CLI | yes |\n\nSo `fmt` + `clippy` + `test` can all be green while `target\u002Ffast\u002Fnub` is hours stale or absent — and it fails in the worst direction, because the old behavior usually still works, so the probe reads as a clean pass. Add an explicit `build` step whenever a gate run is followed by running the thing.\n\n**Bind the artifact to the source before trusting a fixture result.** An mtime newer than your last edit is necessary and not sufficient — a concurrent build can overwrite the path mid-run. Prove it positively by exercising a behavior only your change produces, and re-hash afterwards (or copy the binary aside and probe the copy).\n\n## Long cargo runs go in a BACKGROUND shell — never poll for them\n\nA cold build, `--all-targets` clippy or a full `cargo test` outlives the foreground timeout. Start\nit with the harness's background mechanism and let the completion notification wake you. **Do not\nwrite a wait loop**, and do not sleep on it: the harness already tracks it, so a poller is pure\nwaste and it can be WRONG in both directions.\n\nMeasured cost of getting this wrong: a loop polling `pgrep -f \"cargo|rustc\"` reported \"still\nbuilding\" for ten minutes AFTER the build had finished — `pgrep -f` matches the full command line\nINCLUDING the environment, so every process with `.cargo\u002Fbin` in its `PATH` matched. If you must\nask whether a compiler is running, match the executable name exactly:\n\n```sh\nps -Ao comm= | grep -cE '^(rustc|cargo)$'      # 0 = idle\n```\n\n## ANY cargo command REWRITES that profile's binary — with ITS features, not yours\n\n`cargo build -p nub-cli --profile fast --features nub-cli\u002Fbuild-jail-catalog-override` then\n`cargo test -p nub-cli --profile fast \u003Cfilter>` leaves `target\u002Ffast\u002Fnub` built **without** the\nfeature. `test` rebuilt the bin under the default feature set and clobbered it. Nothing warns;\nthe binary just quietly becomes a different one.\n\n**So re-arm the binary after ANY bare cargo invocation on the same profile**, before running a\nharness or a fixture against it:\n\n```sh\ncargo test -p nub-cli --profile fast \u003Cfilter>          # clobbers target\u002Ffast\u002Fnub\nscripts\u002Frust-build.sh build -p nub-cli --profile fast \\\n  --features nub-cli\u002Fbuild-jail-catalog-override        # re-arm before probing\n```\n\nCost when missed: a build-jail catalog probe reported `BROKEN-EVEN-WITH-EVERYTHING` for a package\nthat installs fine, because the featureless binary refused the override. It was diagnosable only\nbecause nub fails LOUD there (*\"NUB_BUILD_JAIL_CATALOG is set, but this binary was not built with\nthe build-jail-catalog-override feature… Refusing rather than running the compiled-in catalog\nunder an override's name\"*). A feature that degrades silently would have cost far more.\n\nRelated and distinct: `--features nub-sandbox\u002Fbuild-jail-catalog-override` enables it on the\nsandbox crate ONLY, so anything gated inside nub-cli compiles out while the sandbox-side banner\nstill prints — the override looks live and half of it is absent. `nub-cli` forwards the feature\n(`crates\u002Fnub-cli\u002FCargo.toml`), so the bare name and `nub-cli\u002F…` are equivalent; the `nub-sandbox\u002F…`\nform is the wrong one.\n\n## The gate's exit status must be CARGO's — three ways it silently isn't\n\n- **A pipe.** `cargo … | tail` gives you the PIPE's status.\n- **`| head -N`** additionally closes the pipe and SIGPIPE-kills cargo outright.\n- **Trailing commands.** `cargo … > log 2>&1; echo EXIT=$?; tail log` redirects correctly and still exits with **`tail`'s** status, so a harness reports 0 while cargo returned 101.\n\nThe habit that holds: redirect to a file, capture `RC=$?` immediately, and **end the command with `exit $RC`** so the shell's status IS cargo's. Read the log with `Read`\u002F`grep`, never `tail` in the same command whose status you care about. Confirm the recorded `RC=` line before believing a gate passed.\n\n## `--all-features` needs a staged addon AND the vendored runtime deps\n\n`--all-features` turns on `embed-runtime`, whose `build.rs` demands a complete runtime stage. Two separate pieces are absent in a fresh worktree, and each fails differently:\n\n| Missing | Failure |\n| --- | --- |\n| `runtime\u002Faddons\u002Fnub-native.node` (gitignored) | `cannot read entrypoint … for integrity hashing` |\n| `runtime\u002Fnode_modules\u002F` (the five vendored packages) | `missing vendored runtime packages: …` |\n\nThe vendored packages exist so a shipped binary can resolve its transpile helpers, which a lint never does. So for a lint, stage a placeholder addon and grant the opt-out rather than vendoring npm packages into your worktree — what CI's clippy job, `make verify` and `scripts\u002Fremote-build.ts` all do:\n\n```sh\nmkdir -p runtime\u002Faddons && printf 'placeholder-addon' > runtime\u002Faddons\u002Fnub-native.node\nNUB_ALLOW_INCOMPLETE_RUNTIME=1 scripts\u002Frust-build.sh clippy --all-targets --all-features -- -D warnings\n```\n\nThe digest only needs bytes to hash — a real addon is not required to lint. Never set `NUB_ALLOW_INCOMPLETE_RUNTIME` for a build whose binary you intend to run, install or ship: that is the case the check exists to stop.\n\n## Two crates are their OWN workspaces — `-p` from the root cannot see them\n\n`crates\u002Fnub-native` (panic-strategy split) and `crates\u002Fnub-launcher` (size-tuned release profile) each have their own `[workspace]`, so `cargo build -p nub-launcher` from the root fails with `package ID specification 'nub-launcher' did not match any packages`. Build from inside the crate, or with `--manifest-path`. CI lints each separately.\n\n## Build `nub-native` with `cd crates\u002Fnub-native`, NEVER `--manifest-path`\n\n`crates\u002Fnub-native\u002F.cargo\u002Fconfig.toml` sets `target-dir = \"..\u002F..\u002Ftarget\"` so the addon lands in the repo-root `target\u002F\u003Cprofile>\u002F` that the Makefile and CI copy from. Cargo discovers config by walking up from the CWD, not from the `--manifest-path` directory — so `cargo build --manifest-path crates\u002Fnub-native\u002FCargo.toml --release` silently writes to `crates\u002Fnub-native\u002Ftarget\u002F`, and the follow-on `cp target\u002Frelease\u002Flibnub_native.dylib runtime\u002Faddons\u002Fnub-native.node` copies a stale artifact or fails.\n\n## An \"unused import\" warning does NOT mean the import is unused — check `cfg(test)` first\n\nA non-test build warns `unused import: X` for an import only `mod tests` consumes through `use super::*`. Deleting it turns one warning into N compile errors in the test target. Before removing a flagged import, `grep` the symbol in the same file: if the hits are past the `#[cfg(test)]` line, move the import *into* `mod tests`.\n\n## Related skills\n\n`new-worktree.ts` creates the worktree and points you at this wrapper. `dev-loop` covers the fast-profile incremental loop; this skill owns the target-dir decision. When a build fails with a symbol\u002Ffield absent from your source, this is almost always the cause — rebuild through `rust-build.sh` and it isolates you.\n",{"name":5,"metadata":24,"description":7},{"internal":25},true,"main","9b734566fd36ceed8379f67a92291bc68af60801",".claude\u002Fskills\u002Frust-build",71,"https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub","https:\u002F\u002Fnubjs.com","https:\u002F\u002Fgithub.com\u002Fnubjs","The all-in-one Node.js toolkit","2026-11-14 14:11:35",{"source":8,"skillName":5,"commands":36,"prompt":46,"zipAvailable":25},[37,40,43],{"tool":38,"command":39},"npx","npx skills add nubjs\u002Fnub --skill rust-build",{"tool":41,"command":42},"bunx","bunx skills add nubjs\u002Fnub --skill rust-build",{"tool":44,"command":45},"pnpm","pnpm dlx skills add nubjs\u002Fnub --skill rust-build","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Frust-build\u002FSKILL.md",[],[49,55,61,68,75,82],{"skillNo":50,"name":51,"nameZh":6,"description":6,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":52,"categories":53,"keywords":54,"publishedAt":19},"01M758BSH88RVXBG8TPCT427TY","nub","https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub\u002Fblob\u002Fmain\u002Fskills\u002Fnub\u002FSKILL.md",[],[],{"skillNo":56,"name":51,"nameZh":6,"description":57,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":58,"categories":59,"keywords":60,"publishedAt":19},"01M758BKPRHXS5MS27WG908PBG","This project uses nub, a single Rust CLI that runs on the project's installed Node and replaces the everyday Node toolchain. ALWAYS prefer nub over node, bun, npm, npx, pnpm, and yarn for: executing JS\u002FTS files, running package.json scripts, the npx-equivalent, installing dependencies, watch mode, and Node version management. Surfaces whenever you would otherwise reach for node\u002Fbun\u002Fnpm\u002Fnpx or a package manager.","https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub\u002Fblob\u002Fmain\u002Fsite\u002Fpublic\u002Fskill.md",[],[],{"skillNo":62,"name":63,"nameZh":6,"description":64,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":65,"categories":66,"keywords":67,"publishedAt":19},"01M758BCR8A21H8P4TQ0YRHTC7","worktree","Create and manage isolated git worktrees for parallel build\u002Ftest\u002Flanding work on the nub repo. Invoke (via the Skill tool) whenever you need a fresh worktree to land a change, when you want to know what `.worktreeinclude` does or how to add an entry, or when cleaning up after a merge. Encodes the one-command setup (`nub scripts\u002Fnew-worktree.ts \u003Cslug>` or `node …`) that bakes in the proven recipe — worktree off origin\u002Fmain (vendor\u002Faube is plain in-tree files now, no submodule init), the shared CARGO_TARGET_DIR (`~\u002F.cache\u002Fnub\u002Fshared-target`) that all worktrees reuse, and applying `.worktreeinclude` — plus the eagerly-pull-the-shared-tree discipline and the safe cleanup path. Pairs with the `dev-loop` build skill.","https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fworktree\u002FSKILL.md",[],[],{"skillNo":69,"name":70,"nameZh":6,"description":71,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":72,"categories":73,"keywords":74,"publishedAt":19},"01M758B9NZ1GQMD1A6B25NK0D9","windows-vm-test","Run ad-hoc Nub tests and debugging probes in the maintainer's existing local Windows 11 ARM64 QEMU\u002FHVF VM when its external disk and runbook are present. Use for interactive win32-arm64 or Windows-on-ARM x64-emulation checks; use ci-adhoc-test for true x64-native behavior or when the local VM is unavailable.","https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fwindows-vm-test\u002FSKILL.md",[],[],{"skillNo":76,"name":77,"nameZh":6,"description":78,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":79,"categories":80,"keywords":81,"publishedAt":19},"01M758B2JHMBB6YJTGYSJR65S4","visual-review","Verify UI\u002Flayout\u002Fstyling changes are correct by computing occlusion, clipping, and alignment from the browser's resolved paint order via the chrome-devtools MCP `evaluate_script` tool — instead of eyeballing a flat screenshot. Invoke BEFORE declaring any UI, site, or styling\u002Flayout change correct. Screenshots have no depth buffer, so z-index\u002Focclusion\u002Fclip bugs are exactly where \"just look at it\" fails; the `evaluate_script` routines below turn those fuzzy visual judgments into deterministic measurements — including optical center-of-mass, which measures the glyph ink's true visual center so differently-sized labels can be aligned by more than eye.","https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fvisual-review\u002FSKILL.md",[],[],{"skillNo":83,"name":84,"nameZh":6,"description":85,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":86,"categories":87,"keywords":88,"publishedAt":19},"01M758AWPM7CE440NBAYJHD44J","type-declarations","Add, audit, or update @nubjs\u002Ftypes declarations for Nub runtime APIs. Use whenever Nub adds or changes a user-visible global, built-in method, module loader type, or TC39 proposal; when TypeScript or @types\u002Fnode gains an overlapping declaration; and before every release to reconcile runtime changes since the previous tag. Covers conflict-safe global augmentation, compiler-version routing, fixture matrices, and package verification.","https:\u002F\u002Fgithub.com\u002Fnubjs\u002Fnub\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Ftype-declarations\u002FSKILL.md",[],[]]