@convesoft/nx-rust 1.0.0-rc.1 → 1.0.0-rc.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (78) hide show
  1. package/PLUGIN.md +106 -0
  2. package/README.md +8 -4
  3. package/docs/artifacts.mara.md +374 -0
  4. package/docs/caching.mara.md +999 -0
  5. package/docs/ci.mara.md +308 -0
  6. package/docs/configuration.mara.md +508 -0
  7. package/docs/decisions.mara.md +3267 -0
  8. package/docs/execution.mara.md +533 -0
  9. package/docs/index.mara.md +51 -0
  10. package/docs/product.mara.md +366 -0
  11. package/docs/release.mara.md +493 -0
  12. package/docs/setup.mara.md +486 -0
  13. package/docs/targets.mara.md +704 -0
  14. package/docs/testing.mara.md +431 -0
  15. package/docs/verification.mara.md +465 -0
  16. package/docs/workspaces.mara.md +445 -0
  17. package/package.json +1 -1
  18. package/src/cargo/build-settings.d.ts +8 -1
  19. package/src/cargo/build-settings.js +21 -11
  20. package/src/cargo/build-settings.js.map +1 -1
  21. package/src/cargo/metadata.d.ts +2 -0
  22. package/src/cargo/metadata.js.map +1 -1
  23. package/src/cargo/redirections.d.ts +4 -1
  24. package/src/cargo/redirections.js +7 -2
  25. package/src/cargo/redirections.js.map +1 -1
  26. package/src/cargo/warnings-setting.d.ts +24 -0
  27. package/src/cargo/warnings-setting.js +81 -0
  28. package/src/cargo/warnings-setting.js.map +1 -0
  29. package/src/executors/cargo/schema.json +4 -0
  30. package/src/executors/cargo-output.d.ts +8 -2
  31. package/src/executors/cargo-output.js +20 -6
  32. package/src/executors/cargo-output.js.map +1 -1
  33. package/src/executors/command.d.ts +13 -0
  34. package/src/executors/command.js +37 -7
  35. package/src/executors/command.js.map +1 -1
  36. package/src/executors/denied-warnings.d.ts +99 -0
  37. package/src/executors/denied-warnings.js +188 -0
  38. package/src/executors/denied-warnings.js.map +1 -0
  39. package/src/executors/group-run.d.ts +1 -1
  40. package/src/executors/group-run.js +23 -13
  41. package/src/executors/group-run.js.map +1 -1
  42. package/src/executors/groups.d.ts +7 -2
  43. package/src/executors/groups.js +22 -3
  44. package/src/executors/groups.js.map +1 -1
  45. package/src/executors/nextest.d.ts +6 -2
  46. package/src/executors/nextest.js +12 -6
  47. package/src/executors/nextest.js.map +1 -1
  48. package/src/executors/task-guards.js +7 -2
  49. package/src/executors/task-guards.js.map +1 -1
  50. package/src/executors/task.js +10 -3
  51. package/src/executors/task.js.map +1 -1
  52. package/src/executors/test-mode.d.ts +4 -1
  53. package/src/executors/test-mode.js +7 -1
  54. package/src/executors/test-mode.js.map +1 -1
  55. package/src/executors/test-steps.d.ts +20 -8
  56. package/src/executors/test-steps.js +45 -14
  57. package/src/executors/test-steps.js.map +1 -1
  58. package/src/graph/caching.js +5 -0
  59. package/src/graph/caching.js.map +1 -1
  60. package/src/graph/clippy-input.d.ts +53 -0
  61. package/src/graph/clippy-input.js +107 -0
  62. package/src/graph/clippy-input.js.map +1 -0
  63. package/src/graph/collisions.d.ts +7 -0
  64. package/src/graph/collisions.js.map +1 -1
  65. package/src/graph/discovery.d.ts +15 -0
  66. package/src/graph/discovery.js +5 -0
  67. package/src/graph/discovery.js.map +1 -1
  68. package/src/graph/inputs.d.ts +3 -1
  69. package/src/graph/inputs.js +11 -1
  70. package/src/graph/inputs.js.map +1 -1
  71. package/src/graph/projects.js +13 -2
  72. package/src/graph/projects.js.map +1 -1
  73. package/src/graph/rustfmt-config.d.ts +42 -0
  74. package/src/graph/rustfmt-config.js +173 -0
  75. package/src/graph/rustfmt-config.js.map +1 -0
  76. package/src/graph/targets.d.ts +11 -7
  77. package/src/graph/targets.js +12 -8
  78. package/src/graph/targets.js.map +1 -1
@@ -0,0 +1,465 @@
1
+ # Verification
2
+
3
+ How we establish that nx-rust meets its requirements and goals. Each definition
4
+ says what to check and what to expect. A definition is not a result: results
5
+ come from actual test runs, cited when an issue is closed.
6
+
7
+ ## How the plugin is tested
8
+
9
+ - **Fixture workspaces.** Small Cargo workspaces under version control, each
10
+ built to show one situation: a workspace in a subfolder, two workspaces, a
11
+ standalone crate, an excluded member, a path dependency across workspaces, a
12
+ vendored crate that is excluded and used by path, a name collision, a
13
+ dev-dependency cycle, workspaces with different toolchains, crate folders
14
+ that also are JS projects, workspaces in nested folders, a crate whose build
15
+ script and macros read files outside its folder.
16
+ - **Graph tests** load a fixture through the plugin and compare projects,
17
+ targets, inputs and edges with the expected graph. They need `cargo` but
18
+ compile nothing.
19
+ - **The cache-key matrix** is a table of pairs of states with a verdict: "keys
20
+ must differ" or "keys must not differ". A test computes the task hashes for
21
+ both states with the real Nx hasher and checks the verdict.
22
+ - **End-to-end tests** install the built plugin into a fresh Nx workspace
23
+ together with a fixture and run real `nx` commands against a real toolchain,
24
+ counting cargo invocations and reading cache hits from Nx's output.
25
+
26
+ A check of an Nx or Cargo version that the machine does not have fakes the
27
+ version where the plugin reads it, and runs the real Nx and cargo otherwise: a
28
+ copy of the installed Nx whose `package.json` gives another version, and a
29
+ cargo wrapper that reports an older version and leaves `build_directory` out of
30
+ its `cargo metadata` report, as every stable Cargo before 1.91 does
31
+ ([[EVD-CARGO-DIRECTORIES]]). No test installs a toolchain.
32
+
33
+ Checks that need an optional tool (nextest, cargo-affected, cargo-hakari,
34
+ `wasm-bindgen`) run only where that tool is installed, and CI installs all of
35
+ them, with the `wasm32-unknown-unknown` target and the `llvm-tools` component
36
+ of the toolchain the tests' cargo uses. CI pins each tool to the version that
37
+ the evidence in the docs was gathered with, and `wasm-bindgen` to the version
38
+ that the `wasm-packages` fixture locks; it takes prebuilt releases, and builds
39
+ only cargo-affected, which publishes none, where the cache of GitHub Actions
40
+ has no entry for that version, and restores it otherwise. Each tool sits in a
41
+ folder of its own outside the Cargo home, so that the cases about a missing
42
+ tool can hide it by dropping its folder from `PATH` while `cargo`, `rustc` and
43
+ `sh` stay reachable. The napi CLI is a dev dependency of this repository, which
44
+ the tests link into a fixture's `node_modules`, and the napi crates of the
45
+ fixtures come from a local Cargo registry in the fixture, so those checks need
46
+ no network and always run.
47
+
48
+ CI runs on Linux only for the moment. The macOS runs are deferred until
49
+ GitHub's macOS runners are usable again ([[ADR-CI-LINUX-ONLY]]), so no check on
50
+ this page has been run on macOS.
51
+
52
+ ## Requirement checks
53
+
54
+ :::mara verification VER-GRAPH
55
+ :mid: 01M78FHG7FRWN7AJA7BVM1E4AE
56
+ :title: Build the expected graph from fixture workspaces
57
+ :status: accepted
58
+ :methods: test
59
+ :verifies: REQ-INFERRED-PROJECTS
60
+ :verifies: REQ-MULTI-WORKSPACE
61
+ :verifies: REQ-CROSS-WORKSPACE-DEPS
62
+ :verifies: REQ-SKIP-CRATES
63
+ :verifies: REQ-PROJECT-NAMES
64
+ :verifies: REQ-WORKSPACE-PROJECT
65
+ :verifies: REQ-DEPENDENCY-EDGES
66
+
67
+ Load each fixture through the plugin and compare the graph with the expected one. Every member is a project rooted at its crate, and no file appears in any crate. A repository with a workspace at the root, one in a subfolder and a standalone crate yields all their members, with one cargo invocation per workspace, counted, when one plugin entry receives every manifest. Two entries of a stand-in that runs the plugin's hooks, and that the plugin does not take for its own entries, split one workspace's manifests, the first receiving the root manifest and the second the members: they cost one invocation for the first and two for the second when Nx runs them in separate processes, and one in all when they share a process, which shows that the entries of one process share the reports of a graph computation. Two entries of the plugin with different options that split the manifests of two workspaces give each entry's projects that entry's target names and each entry's edges, in plugin workers, in Nx's own process and with the daemon, with its plugins in workers and in its own process, there also in a second graph computation. A later hook called other than as a method of an entry's copy of the plugin, or with another entry's options, and a `createNodes` call of one copy with other options than its first, fail with a message that says the plugin cannot tell which entry Nx called it for. Two `createNodes` calls of one entry that overlap, the second starting in the same turn as the first, before the first computation's later hooks, succeed, and `createDependencies` and `createMetadata` then answer from the second. One entry that receives a workspace's members but not its root manifest reads the workspace once in the folder of the shallowest member manifest and once more in the workspace's root folder. An excluded member is a standalone crate. A crate used by path from a second workspace is one project, with an edge from its consumer, and its targets address its home workspace. A crate under a path ignored by `.gitignore` or `.nxignore`, or matched by `exclude`, has no project. Two crates with one name fail graph creation with an error containing both manifest paths; a `name` override or a workspace prefix resolves it, and the generated commands still select the crate by its package ID specification, or by its package name for `cargo fmt`. Each workspace has exactly one workspace project that depends on every member, and a workspace whose root manifest defines a crate has no extra project. Normal, build and dev-dependencies each produce an edge. A fixture with a dev-dependency cycle keeps both edges, and `nx run-many -t test` on it runs without a task-cycle error. A crate that depends by path on an excluded crate has no edge to it and has that crate's folder among its inputs. A crate that reaches a crate with a project only through excluded crates, as through its own dev-dependency on one that build-depends on another that depends on the crate with a project, has an edge to it, and none to a crate that only an excluded crate's dev-dependency names; behind an excluded crate whose folder holds `.cargo-checksum.json` it has none. Where such an edge closes a cycle through a dev-dependency, both edges stay and the `test` tasks of both crates hash, and a dev-dependency that leads back to the crate itself through an excluded crate gives no edge. A path dependency written through a symbolic link to a crate's folder gives the edge to that crate's project, without a report of its own and without the crate's folder among the inputs, and `nx show projects --affected` for a change in that crate lists its dependent. When a path dependency without a project lies in the folder of a workspace that does not list it as a member, or names in `package.workspace` a manifest without `[workspace]` or a missing folder, with cargo 1.91 and with the latest stable, graph creation succeeds and warns, naming the manifest and carrying cargo's message, and saying that the crates behind it are not followed and that cargo's report or `fileInputs` would cover them, and no report is requested for the path dependencies behind it. When the report of a path dependency without a project fails for another reason, graph creation fails with an error that names the path dependency: so it does for a manifest that cargo rejects behind it, for a workspace whose folder holds the crate and that lists a missing member, for the crate's own manifest that cargo cannot read, and for a crate that takes a key from a workspace whose manifest has no `[workspace]` or is missing, where cargo gives those reasons only as the cause. With an empty Cargo home and Cargo set to offline, a fixture that has registry dependencies still yields its graph. A configuration file that the plugin reads for redirections and cannot parse fails graph creation with a message that names the file; cargo rejects such a file first, so the message asks for a report where cargo accepts it.
68
+
69
+ A workspace project whose root manifest defines no crate is named after its folder, with each `/` replaced by `-` and punctuation and case otherwise unchanged: `rust` for a workspace in `rust/`, `services-billing` for one in `services/billing/`, `apps-Billing.API-rust_v2` for one in `apps/Billing.API/rust_v2/`, and `cargo-workspace` for one at the root of a fixture repository that has no root `project.json`, no `nx` key in its root `package.json` and no package-manager workspace pattern that includes the root. A workspace name prefix leaves that name unchanged, and a `name` in `[workspace.metadata.nx.project]` replaces it. In the root fixture with a root `project.json` that sets a name, with a root `project.json` without one, with an `nx` key in the root `package.json`, and with a workspace pattern that includes the root, the folder holds one project, named by that `project.json` or else by the root `package.json`. It has the workspace project's targets and depends on every member, also when `[workspace.metadata.nx.project]` sets a `name`, which then has no effect. A workspace in a subfolder that holds a `project.json` without a name and no `package.json` keeps the default name, or the `name` set in `[workspace.metadata.nx.project]`. A workspace project named like a crate, and two workspace projects with one name, such as workspaces in `services/billing/` and `services-billing/`, fail graph creation with Nx's error followed by the plugin's, which contains both manifest paths and the remedy for each: the `name` in `[workspace.metadata.nx.project]` for a workspace project, and the `name` override or the workspace prefix for a crate. Workspaces at the root and in `cargo-workspace/` fail graph creation with Nx's error. A workspace project named like a JS project in another folder fails graph creation with Nx's own error. Two crates with one name, in one plugin entry or in two entries that receive different workspaces, fail graph creation with Nx's error followed by the plugin's, which contains both manifest paths, two entries with plugin isolation on and off, and one entry, whose crates all come from one process in either mode, with it off. A `project.json` that gives one of the two crates another name lets graph creation succeed, and removing it brings the error back. A project that is not the plugin's with the same name as the two crates makes graph creation fail with Nx's error. So do two crates that `project.json` files give one new name, three crates with one name from three entries, and two crates with one name in one entry together with a third in another. An edge appears when a crate gets a project without any manifest changing, such as when it is removed from `.nxignore`.
70
+
71
+ A workspace whose root manifest's `[patch]` redirects to one of its members, to a member of another workspace and to a crate without a project gives every member with a registry or git dependency, of its own or behind a path crate, also a path crate of another workspace, an edge to the two crates with projects, but not to itself or to the crate without a project, which costs one report requested from that workspace's root folder. A member without such a dependency gets none, unless it reaches a path crate without a report, which gives it the edge as well. Where such an assumed use points the opposite way of another edge between the two projects, as from a member whose only path dependency is a crate of a directory source to a member that may use it through a registry crate, or to a patched member whose dev-dependency on an excluded crate leads to the first member, the other edge stays, `nx affected` for a change in its target still selects its source, and the assumed use becomes a file input of its member. Where the patched member reaches a member through a normal dependency, that member has no edge to it; where only through a dev-dependency, the edge closes a cycle and stays. A member whose dependency a patched crate's version satisfies keeps its edge to that crate even when the crate declares a registry dependency of the member's name that the member's version does not satisfy, and `nx affected` for a change in the patched crate selects the member; two patched members with registry dependencies that do not depend on each other get no edge between them. A patch whose path passes a symbolic link gives the same edges as the real path. A git dependency patched to a crate of the repository gives its member an edge that `nx affected` follows. A crate with a project that a patched crate without a project depends on by path, directly, through another crate without a project or through a symbolic link, gets an edge from every member that uses the patched crate, directly, possibly or by assumption, and `nx show projects --affected` for a change in it lists them; so it does where `[replace]` or `paths` redirects to the crate without a project, which costs one report for `paths` as for `[patch]`, and where that crate lies deeper below the folder of a `paths` entry, which costs one report for each crate without a project that cargo takes from there. So it does where that crate lies in `node_modules`, in a folder that cargo tagged as its cache directory or in the workspace's artifact or build directory below the folder, and where it lies outside the folder and a crate below the folder names it by path, also only as a dev-dependency. A manifest below such a folder that is no valid TOML gives a warning that names it and what to do, and fails nothing; so does a crate in a virtual workspace below the folder that does not list it, and the warning says that the crates behind it are not followed and that cargo's report or `fileInputs` would cover them. The crates in a hidden folder get no report. A virtual workspace in the folder of a `paths` entry gives the members edges to the crates cargo takes from it and none to its workspace project. With the Nx daemon, a crate without a project added below the folder after the daemon created the graph, which depends by path on a crate with a project, makes `nx show projects --affected` for a change in that crate list every member that may use it. Looking for the crates below a `paths` folder finds what cargo takes: every crate to any depth, also below another crate, in a nested workspace, in `node_modules`, in an artifact directory and in a `target` folder without a manifest beside it, through a link given as the folder; and none in a hidden folder, in a folder holding `.git`, in a `target` folder beside a manifest, behind a link below the folder or in a folder it cannot read. With `paths` naming one member, the members with registry dependencies get edges to that member's path dependencies too, also to one it names only as a dev-dependency. Where the crate with a project reaches such a member through normal dependencies, the member has no edge to it and has its folder among its inputs, while a member that uses the patched crate directly keeps its edge. Where a member's use of a crate with a project is left out, because the two may only possibly use each other, whether the crate is patched itself or lies behind a patched crate without a project, or because an assumed use behind such a crate yields to the crate's dev-dependency on the member, the member has among its inputs the folders of that crate and of a crate it depends on by path, and `nx show projects --affected` for a change in the latter lists the member. The same edges come from `[patch]` in the workspace's `.cargo/config.toml`, in one above it and in a file such a configuration includes, from `[replace]` and from `paths`, while a `[patch]` in a member's manifest adds none. A `[patch]` in the Cargo home's configuration gives the same edges and a warning that names the file and the tables it sets and gives the remedy, which the tasks of the projects of both workspaces print again, also with the Nx daemon, whose log holds it. So does a `[patch]` in a `.cargo/config.toml` that `.gitignore` or `.nxignore` leaves out, whose warning adds that not ignoring the file makes Nx hash it, and the root manifest's `[patch]` where `.nxignore` leaves out that manifest, whose warning says to stop ignoring the file or to run `nx reset` after changing it; a task of a member of `rust` prints either warning again and a task of `shared`'s member does not, and the same `.cargo/config.toml` that Nx reads gives no warning. A redirection to a folder without a crate fails nothing, and an edge reaches a crate that another plugin entry creates. Graph creation succeeds, with a warning naming the manifest and cargo's message, for a patched crate without a project that cargo refuses to report because it lies in the workspace's folder without being its member; it succeeds with cargo 1.91 for an included configuration file that is no valid TOML, and for a `.cargo/config.toml` that is no valid TOML beside the `.cargo/config` that cargo reads. For each form of version requirement the plugin evaluates, whether it counts a patched crate's version as satisfying matches whether cargo resolves the dependency to it. Every crate with a project that `cargo tree` shows for a member is reachable from it in the graph, and `nx show projects --affected` for a change in a patched crate lists every member that may use it.
72
+
73
+ A registry outside the repository holds two crates, and `cargo vendor` writes both into a folder inside a workspace's folder, and into one outside every workspace's folder whose manifests lie higher than the root manifest of the workspace that uses them. With the `[source]` tables that `cargo vendor` prints in the workspace's `.cargo/config.toml`, and without any configuration, no vendored crate gets a project or a cargo call; with the tables, `nx show projects` lists none of them and cargo builds the workspace from them offline with an empty Cargo home. So it is with a second plugin entry that receives only the vendor folder. With a vendored crate's `.cargo-checksum.json` removed, the folder inside the workspace's folder fails graph creation with cargo's message, and a crate without that file beside the vendored ones in the outside folder gets its project. A vendored crate that a member depends on by path is a member with a project and edges; where the workspace excludes the vendor folder, it gets neither and no cargo call. A `[source]` table whose `directory` names another workspace's folder, directly, through a symbolic link or from the Cargo home's configuration, or the repository root, changes no project, edge or cargo call.
74
+
75
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
76
+ :::
77
+
78
+ :::mara verification VER-CONFIGURATION
79
+ :mid: 01M78FHG7FNJ8YXT3BC2KGEXDK
80
+ :title: Apply overrides from Cargo metadata and plugin options
81
+ :status: accepted
82
+ :methods: test
83
+ :verifies: REQ-METADATA-OVERRIDES
84
+ :verifies: REQ-TARGET-NAMES
85
+
86
+ In a fixture, `[package.metadata.nx]` sets a project name, tags, an option of an inferred target and an extra target, and `[workspace.metadata.nx]` sets defaults. The graph shows the overridden name, the tags, the option on the inferred target and the extra target. A value set for a crate replaces the workspace default for that crate only, except tags, implicit dependencies and added inputs, `fileInputs`, `envInputs` and `runtimeInputs`: a crate has the workspace's and its own. No file other than Cargo manifests is involved. With default options a crate has `lint`, `test` and `build` targets, and `nx run-many -t lint` in a mixed fixture runs both a JS lint target and clippy. With a renaming in the plugin options, the target appears under the new name and not under the default one, for each inferred target, the artifact targets and the targets of the workspace project included. With `targetNames` set to `{ "test": "build" }`, graph creation fails with a message that names the project, `test`, `build`, the resulting name `build` and `targetNames`. With `{ "clippy": "lint" }`, graph creation fails with a message that names `targetNames` and `clippy` and lists the names that can be renamed, while `{ "bench": "benchmark" }` passes in a fixture without bench targets. A `targetNames` that is no object, and one that gives a target a number or an empty string, fail graph creation with a message that names `targetNames`, the target where there is one, and what the value has to be. With `check` renamed to `typecheck`, a `targets.typecheck` table in a crate's metadata overrides the renamed target.
87
+
88
+ For each setting of [[DES-PLUGIN-OPTIONS]], a fixture sets it at each place the reference gives for it, and the graph and the generated cargo commands show its effect. `testRunner` set in the plugin options and to another value in a workspace table takes the workspace's value in that workspace and the plugin options' value in another, and a target option set in a workspace table and to another value in a crate's table takes the crate's value. `implicitDependencies`, `fileInputs`, `envInputs` and `runtimeInputs` set in the plugin options, where the reference allows it, in a workspace table and in a crate's table all apply to the crate. With `namePrefix = "be-"`, a member `api` is the project `be-api`, a member that sets `name = "backend"` is `backend`, the workspace project of a root manifest without a `[package]` table has no prefix, and a root manifest that defines the crate `tool` makes it the project `be-tool`. A `targets.test` table with `inputs = ["...", { env = "X" }]` keeps every inferred input and adds `X`, and an `options` key replaces only that option. Each of these fails graph creation with a message that names the file and the key, the target or the entry concerned: an unknown key at the top level of a package table, of a workspace table, of its `project` sub-table and of the plugin options, among them a misspelt `testrunner`, `namePrefix` in a package table and `root` in a workspace table; `inputs` without `"..."` on an inferred target; a different `executor` or a `command` on an inferred target; a field of a target table whose type is not the one Nx gives it, among them `options = "broken"`, `outputs = 3` and `continuous = "false"`; `affectedTests = true` among the options of `test` in a workspace without the `affectedTests` setting; and an `implicitDependencies` entry starting with `!`, one naming a Cargo dependency and one naming none. A `targets.test` table that repeats the inferred executor is accepted and keeps the inferred inputs. A `targets.bench` table in a workspace table that repeats the inferred executor applies to a member with a bench target and gives a member without one no `bench` target, while a workspace table under a name that no inferred target has gives every member an extra target. With `profile` set to a custom Cargo profile on `test`, the cargo runner passes `--profile <name>` to `cargo test`, and the nextest runner passes `--cargo-profile <name>` to `cargo nextest run` and `--profile <name>` to the doctest step, `cargo test --doc`, each building into that profile's folder of the artifact directory. In `shared-executables`, with plugin isolation on, with it off and through the Nx daemon, a plain entry of the plugin beside one whose `include` is `rust/**` makes `nx show projects` fail with a message that names the workspace in `rust/`, both entries by their place with a manifest of the workspace that each receives, and the remedy, printed once for each of the two entries; with an `exclude` of `rust/**` on the first entry, the graph has every project once and equals the graph of a single entry, so that no list in the metadata of a project or a target holds an item twice. Graph creation fails in the same way for entries that split the workspace, as where an `exclude` of `rust/crates/**` leaves the first entry the root manifest, for an `exclude` that leaves out one member only or matches no manifest, such as `rust/**/*.rs`, for two identical entries, for three entries, which the message names all, and for a workspace at the repository root, which it names so. It succeeds for an `exclude` of `rust/Cargo.toml` and `rust/crates/**`, for an `include` of `**` and `!rust/**`, and for one of `!rust/**` alone, from which Nx starts with every file. With plugin isolation on and off, it succeeds beside the entry for `rust/` for an entry whose narrow `include` is `rust/[[:upper:]]argo.toml` and `tools/Cargo.toml`, which Nx's native glob keeps away from `rust/Cargo.toml` although minimatch matches it there, and fails for one whose narrow `include` is `rust/crates/*/Cargo.toml` and `tools/Cargo.toml`; the first fails where the plugin applies `findMatchingConfigFiles` to every `Cargo.toml` instead of Nx's whole choice of an entry's files. Nx 24.0.6 itself fails graph creation for an `exclude` given as a string instead of a list, before it calls the plugin; the plugin's `createNodes`, called with such entries, fails with a message that names the entry and says that the plugin could not apply its patterns to tell which manifests it receives, and with entries of which none gets exactly the manifests that it was handed, with a message that names a manifest that differs. With a fake `nx` whose `retrieveProjectConfigurationPaths` returns no list of paths, the plugin fails with a message that names that part and its module. A standalone crate whose manifest has a `[workspace.metadata.nx]` table takes the workspace settings from it.
89
+
90
+ In a workspace whose root manifest defines no crate, `[workspace.metadata.nx.project]` sets a name, tags, an option of an inferred target of the workspace project and an extra target. The graph shows them on the workspace project, whose tags also include those of the workspace table, while a target set under `[workspace.metadata.nx.targets]` appears on the members and not on the workspace project. A `[workspace.metadata.nx.project]` table in a root manifest that defines a crate fails graph creation with an error that names the manifest and `[package.metadata.nx]`.
91
+
92
+ In a fixture whose crate folder also has a `package.json` that Nx reads, the project has the name from that file whatever `name` the crate's metadata sets, and the tags of both.
93
+
94
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
95
+
96
+ In `mixed-folders`, where `libs/rust/crates/addon` holds a `project.json` and a `package.json` beside the crate's manifest and `libs/rust` a `project.json` beside the workspace's root manifest, which defines no crate: a `targets.e2e` table in the crate's `[package.metadata.nx]` and one in `[workspace.metadata.nx.project]` each give their project an extra target `e2e`. A `project.json` target `e2e` with another command, and a `package.json` script `e2e`, each replace it, so that the merged target runs that command or the script. A `project.json` target with only `inputs`, `check` for the crate and `doc` for the workspace project, keeps the plugin's executor, options, `dependsOn` and `cache` and takes those inputs, and graph creation succeeds without a message. A `project.json` target `lockfile` with a command, and a `package.json` script `lockfile`, in `libs/rust` replace the workspace's lockfile task, and graph creation succeeds.
97
+ :::
98
+
99
+ :::mara verification VER-UNKNOWN-OPTIONS
100
+ :mid: 01M7A93PSW34W2D2S2H4MD3R8X
101
+ :title: Ignore and report options the executor does not know
102
+ :status: accepted
103
+ :methods: test
104
+ :verifies: REQ-UNKNOWN-OPTIONS
105
+ :verifies: REQ-UNKNOWN-METADATA-OPTIONS
106
+
107
+ In a mixed fixture whose `nx.json` has the entry `test: { options: { passWithNoTests: true } }` under `targetDefaults`, `nx run-many -t test build --coverage` with an empty cache succeeds for every Rust task, and the cargo wrapper logs the same invocations as for the run without the entry and the flag. The output of each Rust `test` task has two lines. One names `passWithNoTests` and the task, says that the option comes from the workspace's configuration, names `nx show target <project>:test --json` and `sourceMap`, and suggests a `filter` and an empty entry keyed by the target's executor. The other names `coverage` as passed on the command line. The output of each Rust `build` task has only the second line. A second identical run restores every Rust task from the cache and prints the same lines, and a run with `passWithNoTests: false` restores no Rust task. With an empty entry keyed by the executor of `test` beside the `test` entry, or with that entry narrowed by a `filter` that excludes the crates, no line names `passWithNoTests`. With `--batch=false` the lines are the same.
108
+
109
+ Only flags typed on the command line get the line that says so: `--coverage` also after `--`, and on a dependency that a `dependsOn` entry with `params: "forward"` reaches. Each of the following gets the line that names the workspace's configuration:
110
+
111
+ - a `build` task that receives `passWithNoTests` from a dependent `test` through `options: "forward"`;
112
+ - `passWithNoTests: false` in a crate folder's `project.json`, beside the `test` entry, beside an empty entry keyed by the executor of `test`, and with the `test` entry narrowed by a `filter` that excludes the crates;
113
+ - under `-c ci`, the option in the entry's `configurations.ci` while the `project.json` sets it in `options`;
114
+ - an option under `nx.targets.test.options` in the `package.json` of a crate's folder that the package manager's workspaces list;
115
+ - the entry `run: { options: { watch: true } }`, for each `run` task.
116
+
117
+ With `test` configured with `coverage`, `nx run <crate>:test -- -- --coverage` keeps the configured value, and no line names `coverage` as passed on the command line. Positional words count as passed on the command line: `nx run <crate>:test -- 3000 serve` gives a line that names `3000` and `serve` as such, and so does `-- -- --coverage` for `--coverage`.
118
+
119
+ For a target started in code, a caller target starts `build` through `runExecutor` with its own context and `fromCode: true`, an option that the executor of `build` does not know. The started `build` runs, ignores the option, writes a line, and does not fail because of it, and neither does the caller. This holds whether the caller depends on `build` with `params: "forward"`, with `params: "ignore"` or not at all, and whether the caller runs as a single task or in a batch. The check asserts nothing about the form of the line or about what `run` forwards in such an invocation.
120
+
121
+ Two crates of one group whose `project.json` files give the option different values still form one group and share its cargo commands.
122
+
123
+ `nx run <crate>:test --targetTriple=<host triple>` and `nx run <crate>:build --allTargets` run cargo without `--target` and without `--all-targets`, and each gives a line that names the option and says that the target does not take it.
124
+
125
+ `nx run <crate>:run --coverage` gives a line that names `coverage` as passed on the command line, `nx run <crate>:run serve` gives one that names `serve` as a positional argument passed there, each also naming the two ways to pass it to the binary, and in both the binary gets no argument. With the daemon on and off:
126
+
127
+ - `nx run <crate>:run -- --port 3000` passes exactly `--port 3000` to the binary and gives no line, and a task that this `run` depends on through a `dependsOn` entry without `params: "forward"`, also a continuous one, passes nothing to its binary;
128
+ - `nx run <crate>:run --args="--port 3000"` passes `--port 3000`;
129
+ - `nx run <crate>:run --bin <name> --args="--port 3000"` starts that binary with `--port 3000`, while `nx run <crate>:run --bin <name> -- --port 3000` starts cargo without `--bin`;
130
+ - `nx run <crate>:run -- --profile` fails with Nx's message that `profile` does not match the schema, and `--args="--profile"` passes `--profile` to the binary.
131
+
132
+ A key under `[package.metadata.nx.targets.test.options]` that is no option of the executor of `test` fails graph creation with a message that names the manifest, the target `test` and the key. So does the same key in each of these tables, whose messages also name the configuration where there is one:
133
+
134
+ - `[workspace.metadata.nx.targets.test.options]`;
135
+ - `[package.metadata.nx.targets.test.configurations.ci]`;
136
+ - `[workspace.metadata.nx.targets.test.configurations.ci]`;
137
+ - `[workspace.metadata.nx.project.targets.doc.options]` and `[workspace.metadata.nx.project.targets.doc.configurations.ci]`, in a root manifest that defines no crate.
138
+
139
+ With known keys only, graph creation succeeds. A key that the executor declares and the inferred target does not take, such as `targetTriple` under `targets.test.options`, fails in the same way, with a message that says that the target does not take it and lists the options it takes. So does `pluginVersion` under `options` or a configuration of a target table, with a message that names the manifest, the table and the option and says to remove it.
140
+
141
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
142
+ :::
143
+
144
+ :::mara verification VER-TARGETS
145
+ :mid: 01M78FHG7F71BA7Q5ACKA99V9M
146
+ :title: Infer targets and no task dependencies
147
+ :status: accepted
148
+ :methods: test
149
+ :verifies: REQ-INFERRED-TARGETS
150
+ :verifies: REQ-NO-RUST-TASK-DEPS
151
+
152
+ For fixture crates of each shape (library only, binary, with benches, producing a wasm package, producing a Node addon, `publish = false`), the inferred targets are exactly the expected set: `run` only with a binary target, `bench` only with a bench target, an artifact target only on crates that produce that artifact, and no release targets with `publish = false`. No inferred target of any Rust crate has a `dependsOn` entry that resolves to a target of another Rust crate other than the lockfile task of its workspace and, for `test`, the `build` of each crate of its workspace with a binary and an integration test or a bench that `cargo test` builds ([[ADR-WORKSPACE-TEST-EXECUTABLES]]), the crate's own among them, so that in the fixture with one crate of each shape every `test` depends on the `build` of the four crates of that shape, also in `nx run` of the `test` of a crate without a binary, in `nx affected`, under the names that `targetNames` gives and in a configuration that `build` has or lacks; and the task graph of `nx run-many -t build test lint` over a workspace with dependencies between crates, none of which has a binary beside an integration test, has no edges between Rust tasks other than those from each crate task to that lockfile task. The same holds in a workspace whose root manifest is a package, where the lockfile task is a target of the root crate's project. The plugin adds no `dependsOn` entry to any JS project. In a mixed fixture where a JS target declares `^build` and its project depends on a crate, the task graph holds the `build` of that crate and no `build` of the crates behind it.
153
+
154
+ In a fixture with one crate of each shape of the rule of [[DES-TARGETS]], the task graph of `nx run-many -t build test` has an edge from `test` to the same crate's `build`, beside the one to the lockfile task, exactly for a binary with an integration test that runs `CARGO_BIN_EXE_<bin>`, a binary with a `[[test]]` without harness, a binary with a bench with `test = true`, a binary with `required-features` beside an integration test, and a binary with a `[[test]]` with `test = false`, which the `test` option can run, and none for a binary with an example only, with unit tests only, or with a bench without `test`, for a library with an integration test, or for a `cdylib` and `staticlib` with one. The edge is there for `nx run <crate>:test`, for `nx affected -t test` after a change to the crate, for `--exclude-task-dependencies` with both targets named, and under the names that `targetNames` gives both targets; `--exclude-task-dependencies` with `test` alone gives `test` alone. With `-c` naming a configuration that both targets have, `test` in that configuration depends on `build` in it, and where only `test` has it, on `build` without one. With the binary whose integration test runs `CARGO_BIN_EXE_<bin>` and expects what the dev-dependency's feature makes it print, a build directory warmed by plain cargo and an empty Nx cache, and the `cargo build` of `build` held by the wrapper, `nx run-many -t build test -p <crate>`, with and without `--exclude-task-dependencies`, starts no `cargo test` while that call waits, runs `cargo build` and then `cargo test`, and passes the integration test as plain `cargo test -p` passes it; after a normal run, the executable that a cache hit of `build` restores prints what `cargo build -p` makes it print and is byte for byte the file that `cargo build -p` writes. `nx run <crate>:test` runs `cargo build` and then `cargo test`, a second run restores both tasks with no cargo call, and the `test` of a crate without the edge runs alone. A `project.json` that replaces the `dependsOn` of `test` with the lockfile task alone makes `test` fail before cargo runs in `nx run-many -t build test -p <crate>`, with the message of [[DES-DIAGNOSTICS]], also with renamed targets, while `nx run <crate>:test` passes. One that replaces it with the lockfile task and a continuous helper that depends on `build` lets `nx run <crate>:test` pass, with `cargo build` before `cargo test`; one whose continuous helper does not depend on `build` makes `test` fail before cargo runs in `nx run-many -t build test -p <crate>`; and one that makes `build` continuous and uncached makes `test` fail before cargo runs in `nx run <crate>:test`. In a workspace without a lockfile task, a `targetDefaults` entry that sets the `dependsOn` of `test` to an empty list is reported as an error for exactly the crates with the edge.
155
+
156
+ Through a cargo wrapper that logs invocations, each per-crate target runs the command of [[DES-TARGET-COMMANDS]] and selects the crate as [[DES-INVOCATION]] says, with `-p` and the specification that `cargo pkgid` prints for its manifest and in `fmt-check` and `fmt` with its package name: `check` and `lint` with `--all-targets`, and without it for a crate whose metadata switches the option off; `fmt-check`, `fmt` and `bench` with nothing more; `run` with `--bin` when the option names a binary, and with the arguments given after `--` passed on to the binary. The function that splits the value of `args` splits it as `DES-TARGET-COMMANDS` says: `--port 3000 --log a,b` gives those four words; `a '' b` gives the three words `a`, an empty word and `b`; `a\ b "c d" e` gives `a b`, `c d` and `e`; `a | b; c > d && e` gives the words `a`, `|`, `b;`, `c`, `>`, `d`, `&&` and `e`; `$HOME "$PATH" *.rs #x` gives the words `$HOME`, `$PATH`, `*.rs` and `#x`, with nothing expanded; and a value with an unterminated quote or one that ends in a backslash is an error. Through Nx, `nx run <crate>:run --args="a | b; c > d && e $HOME"` passes exactly those words to the binary, `--args="'open"` and `--args='a\'` each fail the task with a message that names `args` and start no binary, `--args=3000` fails with Nx's message that `args` does not match the schema, and `--args=" 3000"` and `-- 3000` pass the one word `3000`. With `args` set in the crate's metadata and `-- --verbose` on the command line, the binary gets the words of `args` and then `--verbose`. Given together with `--`, `--bin` and `--args` before it do not reach the task, and `-- --profile`, the name of one of `run`'s options, fails with Nx's message that `profile` does not match the schema. No command carries `-D warnings` or another flag that denies warnings. `nx run-many -t run` over two crates with binaries starts two cargo invocations, and `bench` has `parallelism: false`. A crate whose metadata makes `run` continuous with a `readyWhen` check is started before a dependent that waits for it, and without that override a dependent of `run` starts after the binary has exited.
157
+
158
+ Each workspace project has `doc`, `audit`, `update` and `lockfile`, and `deny` only in a fixture with `deny.toml`, `.deny.toml` or `.cargo/deny.toml` in its workspace root. `coverage-baseline` exists on the workspace project of `affected-tests`, uncached, without `dependsOn` and on the lockfile executor, on no crate, and not once `affectedTests` is removed; `targetNames` renames it, and a name that another target of the project has fails graph creation with the message of the collision check. `lockfile` is not cached and never joins a batch: through the cargo wrapper and a log of the batch executor's calls, `nx run-many -t test` over a workspace runs it once per run, as `cargo update --workspace` in the workspace root, with `--locked` under `NX_RUST_LOCKED=true`, before any other cargo invocation, and the crate tasks then run, with the default runner, in one cargo invocation per group. `fmt` and `fmt-check` do not depend on it. With cargo-audit and cargo-deny removed from `PATH`, the graph has the same projects and targets. `doc` runs `cargo doc --no-deps --workspace`, `audit` runs `cargo audit`, `deny` runs `cargo deny check` and `update` runs `cargo update`, each in the workspace root. With `doc`'s option for `--no-deps` switched off, `doc` runs `cargo doc --workspace`. `fmt`, `bench`, `run`, `audit`, `deny` and `update` are never restored from the cache. After a change to `Cargo.lock` alone, `nx affected` selects `audit`, `deny` and `update` of that workspace; after a change to `.cargo/audit.toml`, it selects `audit`; after a change to the cargo-deny configuration file or to a member's manifest, it selects `deny`. With cargo-audit or cargo-deny removed from `PATH`, `audit` or `deny` fails with the message [[DES-DIAGNOSTICS]] gives for a missing tool, naming the tool and how to get it.
159
+ :::
160
+
161
+ :::mara verification VER-TARGET-DEFAULT-GUARD
162
+ :mid: 01M7AT4WJM1BAH6G5R8Y0SNF9G
163
+ :title: Report target defaults that change Rust targets
164
+ :status: accepted
165
+ :methods: test
166
+ :verifies: REQ-TARGET-DEFAULT-GUARD
167
+
168
+ Through Nx's own graph creation over fixture workspaces whose `nx.json` has `targetDefaults`, each case of [[DES-TARGET-DEFAULT-GUARD]] is checked as follows.
169
+
170
+ Each case runs with the plugin in Nx's own process, except the one named below that runs in a plugin worker alone. A plugin worker, Nx's default, puts process boundaries between the plugin and Nx: the guard's error and its warnings leave the worker, `nx.json` as Nx read it, with the file it extends, and the projects that the plugins listed before and after nx-rust give reach it, and what `createNodes` recorded reaches `createDependencies` only inside it. The cases that cross one of these boundaries run in a plugin worker as well, which this verification marks with "in both modes": the entry filtered to the tag `extra` that turns on caching where `api`'s Cargo metadata leaves `check` uncached, an error that rests on that metadata; the entry filtered to a plugin listed before nx-rust that replaces the inputs of `check`; the entry keyed `check` that adds `^check` beside a plugin that only tags `api`, a warning; the plugin listed after nx-rust that replaces the inputs of `api`'s `check` without `targetDefaults`; and the entry in a file that `nx.json` extends, filtered to a plugin listed before nx-rust. `cache: true` keyed `build` in a workspace whose Cargo configuration sets `build.target` runs in a plugin worker alone, where the error rests on what `createNodes` recorded. The other cases are permutations of rules and messages, and run in Nx's own process alone.
171
+
172
+ An entry keyed `build` with `dependsOn: ["...", "^build"]`, or with `"..."` and `{ "target": "build", "dependencies": true }`, creates the graph and prints a warning that names the key, the target, each crate with its manifest and the ways to narrow the entry. Without `"..."`, each replaces the dependency on the lockfile task and fails graph creation with the error below, which names the added dependency as well. Each of these fails graph creation with an error that names the key, the targets, the projects with their manifests and the ways to narrow the entry: `cache: true` keyed `fmt` and keyed `@convesoft/nx-rust:cargo`, which reaches exactly the targets that the plugin leaves uncached; `cache: true` keyed `build` in a workspace whose Cargo configuration sets `build.target`, and in one whose artifact directory lies outside the repository, where the plugin leaves `build` uncached in those projects; and `inputs` without `"..."` keyed by a target that declares inputs, such as `update` and `test`, or keyed by the plugin's executor. On a target that declares outputs, such as the `build` of a crate with an executable, or a dependency on the lockfile task, a list of `outputs` or of `dependsOn` without `"..."` fails in the same way. An entry keyed `test` whose `dependsOn` writes out the dependency on the lockfile task as an object differs from it when it names another target, names the workspace project by its name, takes the crate's dependencies instead of the workspace project, forwards the command's arguments or the task's options, or leaves the dependency out; each fails as one that replaces the `dependsOn`. In `binary-tests`, the entry that writes out exactly that dependency fails only as one that replaces the `dependsOn` of the crates whose `test` also depends on their `build`, and names no other crate and no added dependency. For an entry whose value is a list, the message names the elements that apply. A `project.json` in a crate's folder that turns on caching for `build` where the artifact directory lies outside the repository creates the graph, and the task fails before cargo runs with the reason and the command that shows where the setting comes from.
173
+
174
+ Nothing is reported, and nothing is printed, for a repository without `targetDefaults` in which no other layer changes a Rust target. Nothing is reported for `cache: true` keyed `build`, `check`, `lint`, `test`, `fmt-check` or `doc`, which the plugin caches itself, for a list with `"..."` that keeps the declared inputs or outputs, for an entry keyed `test` whose `dependsOn` is exactly the dependency on the lockfile task that the plugin declares for it, for an entry whose key matches no Rust target, for an entry with a `filter` on `projects` that leaves the crates out or on another executor, for an entry keyed `build` beside an empty entry keyed by the plugin's executor, or for a `project.json` in a crate's folder that turns on caching for the crate's `build` while an entry keyed `build` sets only `options`.
175
+
176
+ The layer that made a change is the one reported. With an entry keyed by the plugin's executor and filtered to the plugin, beside `fmt: { cache: true }`, and a `project.json` in a crate's folder that declares the executor of that crate's `fmt`, the error names the entry keyed `fmt` and that crate only. An entry keyed `update` whose `inputs` are exactly the declared ones is not reported when the workspace folder's `project.json`, or its `package.json` that Nx reads, replaces those inputs. An entry that replaces them is reported when that `project.json` keeps what lies below it with `"..."`. It is reported as well when that `project.json` lists other inputs before an object-level `"..."`, for which Nx keeps the value below. An entry whose list holds `{ cache: true }` and then `{ cache: false, "...": true }` is reported with both elements, and one whose list holds `{ dependsOn: ["...", "^lint"] }` and then `{ dependsOn: [], "...": true }` draws the warning. A `dependsOn` object after `"..."` whose `projects` pattern matches only the project itself, such as `api*` on `api`, draws no warning, and one whose pattern matches another project does. Where entries keyed by the executor and by the name both match, only the one keyed by the executor is reported. With `targetNames` renaming `lint` to `clippy`, an entry keyed `clippy` is reported and one keyed `lint` is not. An entry that adds `^build` and keeps the rest with `"..."` draws the warning. Another plugin, registered after nx-rust, that adds the tag `extra` to a crate and contributes that crate's `fmt` with the cargo executor makes the rebuild differ from what Nx merged. Where the other plugin turns on caching and an entry excludes `tag:extra`, the crate's `fmt` gets a warning that names the project, the target and `cache`, says that the plugin cannot tell which configuration changed it and names `nx show target <project>:<target> --json`, and no entry is blamed for it. An entry filtered to `tag:extra` that turns on caching fails graph creation with the error that names it and the crate, and an entry keyed by the executor that excludes `tag:extra`, beside one keyed `fmt`, leaves the error to the entry keyed `fmt`, for every crate, the tagged one included. With the other plugin turning on caching and no `targetDefaults`, graph creation warns in the same way. Where a crate's Cargo metadata sets `cache = false` for `check` and the other plugin gives the crate the tag, an entry filtered to `tag:extra` that turns on caching for `check` fails graph creation with the error that names it and the crate, in both modes, and one that sets `cache: true` before an object-level `"..."` draws nothing; where the other plugin itself caches that `check` and the entry excludes the tag, graph creation warns, and `nx run` of the crate's `check` fails before cargo runs, with the reason that names the table and the manifest, twice in a row. A plugin listed before nx-rust that gives a crate's `check` the cargo executor first makes an entry filtered to that plugin apply to it: one that replaces the inputs fails graph creation with the error that names it and the crate, in both modes, and one whose filter on the executor leaves `check` out, or that keeps the inputs with `"..."`, draws nothing. Beside an entry keyed `check` and filtered to the crate that replaces the inputs in the same way, an entry keyed by the cargo executor and filtered to that plugin is reported too, since either may be the one that Nx applied; where only the entry keyed by the executor gives the inputs that Nx merged, only it is reported; and where it keeps the inputs with `"..."`, which Nx applies in place of the entry keyed `check`, nothing is reported. Where another plugin only tags `api`, an entry keyed `check` that adds `^check` after `"..."` draws the warning that names it for `api` as for the other crates, and no warning that the plugin cannot tell which configuration changed the target, in both modes. For an extra target `e2e` that `api`'s Cargo metadata defines with the executor `nx:run-commands`, nothing is reported for an entry keyed `e2e` that turns on caching, which Nx then caches, for one that replaces the `inputs` and `outputs` that the table sets, which Nx lays over the table, or where another plugin turns on its caching and no entry applies. A `targets.update` table in the workspace's Cargo metadata that keeps the inputs with `"..."` and adds one is part of what the plugin declares: an entry that replaces those inputs is reported, and one that keeps them with `"..."` is not. Where `model`'s `project.json` names it `model-rs` and `api` declares for `check` a `dependsOn` on `model`'s `check`, as a list of projects, as a `projects` string or as `model:check`, an entry keyed `check` and filtered to `api` that replaces the inputs fails graph creation with the error that names the entry and `api`, and no warning about `api:check`; an entry that sets only options draws nothing, while the merged `dependsOn` names `model-rs`. The same entry with `dependsOn: []` fails in the same way where `api` declares inputs that name `model`, and in `binary-tests`, where `app` declares for `build` a `dependsOn` on `library:check` and `library`'s `project.json` names it `library-rs`, so does an entry filtered to `app` that replaces the outputs of `build`. A reference to a project that its `package.json` names `web` and its `project.json` renames `web-app` stays a difference: with an entry that sets only options, and with no `targetDefaults`, graph creation fails with the error of another layer that names `api`'s `check`, its `dependsOn` and the lost reference to `web`, and says to name the project as the merged graph has it; naming `web-app` in the table instead creates the graph; and an entry filtered to `api` whose list replaces the inputs of `check` and names `web` fails as one that replaces them. An entry filtered to the tag `extra`, which another plugin gives `api`, that replaces the inputs of `check` fails graph creation with the error that names it and `api`.
177
+
178
+ Another layer that takes away what the plugin declares fails graph creation. A plugin listed after nx-rust whose node gives `api`'s `check` the inputs `["default"]` and no executor fails it with the error that names `api`, `check`, `inputs`, lost entries such as `^default` and the plugin, with no `targetDefaults`, in both modes, and with the empty entries that `nx add` writes, so that `nx run api:check` fails before any task runs; so does such a plugin that gives the target the cargo executor with those inputs, one whose `dependsOn: []` loses the dependency on the lockfile task, and, in `binary-tests`, one whose `outputs: []` loses the executable of `app`'s `build`. Each fix that the message names creates the graph and prints nothing: an `exclude` of `rust/crates/api/**` on the plugin's entry, `"..."` at the head of the plugin's list, and those inputs written into the `project.json` in `api`'s folder. The same inputs from a `project.json` in `api`'s folder, or from the `nx` property of a `package.json` there that the root `package.json`'s `workspaces` enrols, create the graph and print nothing, and so does the node of such a plugin listed before nx-rust, after which `api:check` keeps the plugin's inputs. A plugin that gives `api`'s `test` the command `jest`, as Nx's Jest plugin does for a folder with a Jest configuration, replaces the whole target, which then runs `nx:run-commands`, and nothing is reported.
179
+
180
+ A later layer that narrows what a list means fails graph creation in the same way: a plugin listed after nx-rust that gives `api`'s `check` the inputs `["...", "!{projectRoot}/src/**/*"]` fails it with the error that names the negated pattern, so that `nx run api:check` fails before any task runs; so does such a plugin that defines `api`'s named input `default` anew as `["{projectRoot}/Cargo.toml"]`, with the error that names that named input and what its definition loses. The same negated pattern, or the same definition, in the `project.json` in `api`'s folder creates the graph and prints nothing, and so does an `exclude` of `rust/crates/api/**` on that plugin's entry. A plugin listed after nx-rust that adds `"{workspaceRoot}/extra.txt"` to `api`'s `check` with `"..."`, or defines a named input that no inferred target reads, creates the graph and prints nothing. With `@nx/js/typescript`, `@nx/jest/plugin` and `@nx/oxlint` listed after nx-rust for a crate folder that has a `package.json` that the workspaces enrol, a `tsconfig.json`, a Jest configuration and an Oxlint configuration, the graph is created and nothing is printed: they define no named input for the folder, replace `lint` and `test` whole and leave `build` and `check` with the plugin's inputs.
181
+
182
+ `init` judges `nx.json` with the empty entries it adds for the plugin's executors. With `cache: true` keyed `fmt` or keyed `build`, the replaced inputs of `update`, or `cache`, `dependsOn` and `inputs` keyed `build`, it adds those entries after the existing ones, registers the plugin and reports none of these entries. With `cache: true` keyed by the plugin's executor, it fails with that error, which names that key and not `build` beside it, and leaves `nx.json` unchanged. With `dependsOn: ["...", "^build"]` keyed by the plugin's executor, it registers the plugin, adds the entries for `@convesoft/nx-rust:run` and `@convesoft/nx-rust:lockfile`, prints the warning and leaves the entry as it was. The warning appears when the graph is created with `NX_DAEMON=false`, in the output of a task of the target concerned with the daemon on, and in the output of `init`. In `patched-workspaces`, with an entry keyed `fmt-check` that adds `^fmt-check` after `"..."`, `api:fmt-check` run alone with the daemon on prints the paragraph that graph creation prints without the daemon exactly once, and `api:fmt` does not print it. Without the daemon, after `api:fmt-check` was cached without the entry, adding it makes the task run and print the warning, a second run restores it with the warning, and removing the entry restores the first result without it; after `nx reset`, a task cached with the entry runs again without the warning once the entry is removed. With the same entry in a file that `nx.json` extends, the keys of `fmt-check` of `api` and `plain` change against that file without `targetDefaults`, through the projects' configuration alone, and with an entry there that adds only the project's own `check` they do not change. With an entry there filtered to the tag `extra`, which another plugin gives `api`, the keys of `api:fmt-check`, `api:check` and `plain:fmt-check` change through the projects' configuration alone, and that of the workspace project's `lockfile` does not; the same holds where no plugin gives the tag. In that setup, adding the entry after `api:fmt-check` was cached makes it run and print the warning that names the entry, and removing it restores the result without the warning, or, after `nx reset`, makes the task run again without it. The same holds, in both modes, for an entry in that file filtered to a plugin listed before nx-rust that gives `api`'s `fmt-check` the cargo executor first. Where another plugin adds `^fmt-check` to `api`'s `fmt-check` and an entry keyed `fmt-check` sets only options, the warning that the plugin cannot tell which configuration changed `api`'s `fmt-check` appears once when the graph is created without the daemon, once in the output of `api:fmt-check` run alone with the daemon on, and not in the output of `plain:fmt-check`. With an Nx whose `nx/src/devkit-internals` lacks `createTargetDefaultsResults`, an entry that changes a Rust target fails graph creation with a message that names the installed Nx version and the supported ones, and an entry that changes none leaves graph creation as it is.
183
+
184
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
185
+ :::
186
+
187
+ :::mara verification VER-CACHE-KEYS
188
+ :mid: 01M78FHG7FR5BWJMDVC9GHC213
189
+ :title: Check the cache-key matrix
190
+ :status: accepted
191
+ :methods: test
192
+ :verifies: REQ-INPUT-FILES
193
+ :verifies: REQ-ENV-ALLOWLIST
194
+ :verifies: REQ-TOOLCHAIN-KEY
195
+ :verifies: REQ-EXTERNAL-DEPS
196
+ :verifies: REQ-TEST-MODE-KEY
197
+ :verifies: REQ-ARTIFACT-CACHE
198
+ :verifies: REQ-BUILD-SCRIPT-INPUTS
199
+ :verifies: REQ-FILE-INPUTS-HASHABLE
200
+
201
+ Compute task hashes with the real Nx hasher for pairs of states and check the verdict. Unless a row says otherwise, cargo calls `Cargo.lock` current in both states.
202
+
203
+ Keys must differ after: a change in any file of the crate's folder, such as a source file, `build.rs`, `Cargo.toml`, a README or a template, other than the `Cargo.lock` of a crate at the root of its workspace; a change in a normal, build or dev-dependency crate, also two edges away, and in a crate with a project that the crate reaches only through a path dependency without a project, in a source file or in a file that crate declares, also where the paths pass a symbolic link to that crate, directly and through the crate without a project; a change in an excluded crate that the crate depends on by path, directly or through another crate, also one without a report of its own, such as a crate whose folder holds `.cargo-checksum.json` or one whose report cargo refuses because it is no member of the workspace whose folder holds it; a change in the root `Cargo.toml`, in a `rust-toolchain.toml` at crate or workspace level, or in a `.cargo/config.toml` or `.cargo/config` at crate level, workspace level or a folder in between, or in a file inside the repository that such a configuration includes; a change in the root `Cargo.toml` of a dependency's workspace, also another workspace, such as an edition that the dependency inherits; a change of an entry of the repository's own `default` named input other than a pattern under `{projectRoot}`, such as an `env`, a `runtime` command or a file under `{workspaceRoot}` that `sharedGlobals` names, and of a file of the crate that such a pattern negates; a change in a file outside the crate's folder that a `fileInputs` pattern of the crate's package table or of its workspace table declares, also one that Git ignores, and in one that a dependency's pattern declares, also one that a path dependency without a project declares in its own table or its workspace's, also behind another crate without a project, that a redirected crate without a project declares and that a redirected crate declares whose edge is left out; a change in a `clippy.toml` for `lint`, in a `rustfmt.toml` for `fmt-check`, and in `.config/nextest.toml` for a `test` that nextest runs; with `CLIPPY_CONF_DIR` naming a folder outside the repository, absolutely or relative to the workspace root, a change in the `clippy.toml` or `.clippy.toml` there, and in the `clippy.toml` of the folder above where the named folder holds none, for `lint` and for no other target, while with the variable unset the runtime input prints nothing; with the variable unset and `CLIPPY_CONF_DIR` under `[env]` naming a folder, in the workspace's `.cargo/config.toml` outside the repository and, with `relative = true`, inside it, and in the Cargo home's configuration, a change in the `clippy.toml` there, for `lint`, where a real clippy then runs again instead of a restored result, and the Cargo home's file draws the warning about Cargo configuration that Nx does not hash; a change of each environment variable in the list, `CARGO_BUILD_WARNINGS` among them for every target that compiles, and of any variable whose name starts with `CARGO_PROFILE_` or `CARGO_TARGET_`, other than `CARGO_TARGET_DIR`, or, for a `test` that nextest runs, with `NEXTEST_`, also in a crate's `.env` for that crate's tasks, and of any line of such a variable whose value spans lines, and of whitespace at the end of the last one; for a `test` that nextest runs, another version of nextest, or nextest missing, while the key of a `test` that cargo runs stays the same; `CARGO_TARGET_DIR` set in a crate's `.env`, for that crate's `build`, whose artifact folder input prints the artifact directory that cargo will use; a change of a variable, or of the output of a command, that `envInputs` or `runtimeInputs` adds in the plugin options, in the workspace table or in the crate's own table, for that crate and for every crate that depends on it, also in another workspace, while the workspace's additions still count for a crate that adds its own; a toolchain update, and another toolchain chosen through `RUSTUP_TOOLCHAIN`, also through one set in a crate's `.env`, for that crate's tasks, and also while `RUSTC` names a compiler; the compiler at the path that `RUSTC`, `CARGO_BUILD_RUSTC` or `build.rustc` names replaced by another version while the path and every file and variable stay the same, for `build.rustc` in the workspace's configuration, in a folder above the repository and as a path relative to the folder that holds `.cargo`, and for `RUSTC` in a crate's `.env`, for that crate's tasks; for `doc` and `test`, the rustdoc at the path that `RUSTDOC` names replaced the same way; without the daemon, `build.rustc` set in the Cargo home's configuration, and then the compiler it names replaced; a change of features, profile or target triple; a locked version bump of an external crate the crate depends on, directly or transitively, also one it reaches only through a path dependency without a project, through a crate of another workspace, as its own workspace's lockfile resolves it, or through a `replace` entry of the lockfile; a change in a crate that the workspace's `[patch]`, `[replace]` or `paths` redirects to, for every member with a registry or git dependency, also where that crate has no project and where its edge is left out to avoid a cycle or because the use rests only on a crate without a report; a change in a crate with a project that such a crate without a project depends on by path, directly, through another crate without a project or through a symbolic link, for every member that uses the redirected crate directly, possibly or by assumption, through `[patch]`, `[replace]` or `paths`, also where its edge is left out to avoid a cycle and where the redirected crate lies deeper below the folder of a `paths` entry, also in `node_modules`, in a folder that cargo tagged as its cache directory or in the workspace's artifact or build directory below it, or outside the folder as a dev-dependency of a crate below it; a change of a variable, or of the output of a command, that `envInputs` or `runtimeInputs` adds in the own table or the workspace table of a crate whose folder is among a crate's inputs in place of an edge, for that crate: a path dependency without a project, also behind another crate without a project and where Nx cannot see its files, a redirected crate without a project, a redirected crate whose edge is left out to avoid a cycle, and a crate whose edge is left out because two crates may only possibly use each other, or a crate behind that one, also in another workspace; a change in a crate that a redirected crate with a project, or a crate with a project behind a redirected crate without one, depends on by path, for a member whose use of that crate is left out, because the two may only possibly use each other or because an assumed use yields to an edge in the opposite direction; a change of only the checksum of such a crate, and of only the commit of such a git dependency; such a bump in a `Cargo.lock` that git ignores; under the `cargo` and `workspace-build` strategies, a change in the manifest of any other member of the workspace, such as a feature it switches on in a shared dependency; under the same strategies, for every member, a locked version bump or a new commit of a package that only another member reaches, as `cargo update -p` of another member's git dependency, and a change in the folder of a path crate outside the workspace that only another member reaches, by path, also behind another such crate, or through a redirection that it may use, in the root manifest of that crate's workspace, in a file that such a crate declares, and of a variable or of the output of a command that it adds, also for one whose files Nx cannot see, whose manifest only such a command hashes; under `hakari`, for every member, a change of the hack crate's manifest, as after `cargo hakari generate`, and of `.config/hakari.toml`; a change that makes a workspace with a cargo-hakari configuration pass or fail a check of [[DES-UNIFICATION]], such as a member's manifest that starts or stops asking another member for a feature, or a triple added to or removed from `platforms`, for every crate of that workspace, also with the Nx daemon; for a crate whose resolved dependencies change when the lockfile task brings a stale lockfile up to date, also when nothing else of the crate changes: a requirement that a sibling adds and that moves a shared version, a feature that adds packages to the crate's dependencies, and a `[replace]` added to the root manifest; a stale lockfile, identical in both states, that the lockfile task resolves to a version published to the registry between the two runs; two current lockfiles that lock the same packages and differ only in a dependency of one entry, as when a `wrapper` that depends on `zzlib >=1, <3` is locked to `zzlib` 1.0.0 in one state and to 2.0.0 in the other while the crate uses both versions directly; another version of the plugin, installed from a registry and named in the JS lockfile, and also with the plugin loaded by path and with Nx's lockfile analysis off, where no task fails to hash; where Rust targets name the plugin's package, a change in the JS lockfile to that package or to a package it depends on; a switch of test mode between `full` and `affected`, and between two baseline commits; for artifact targets, another target triple or another version of a post-processing tool.
204
+
205
+ Keys must not differ after: `CARGO_TARGET_DIR` set in a crate's `.env`, for the crate's targets other than `build` and for the other crates; a change of an input that only a named input which the plugin's targets do not use, such as `production`, names; a change in a crate that is not a dependency, other than, under the `cargo` and `workspace-build` strategies, a change to a member's manifest or to a path crate outside the workspace that a member reaches, and one that changes the crate's resolved dependencies when the lockfile task brings the lockfile up to date; under `hakari`, a change in a redirected crate, for a member without registry or git dependencies; a change of an environment variable outside the list, also one whose value holds a line that looks like a variable whose name starts with `CARGO_PROFILE_`; under `hakari`, a locked version bump of an external crate outside the crate's resolved dependencies, also for the crate at the root of its workspace and for the crates that depend on it; under every strategy, a bump in the lockfile of a standalone crate, for the crates of another workspace that depend on it, and a bump in their workspace's lockfile, for the standalone crate; a change in the JS lockfile outside the plugin's package and the packages it depends on, such as a new version of an unrelated npm package, for the tasks of every project that neither lies at the repository root nor depends on a crate there, and for the lockfile task of a project at the repository root; a toolchain update for a toolchain the crate does not use, in a fixture where two workspaces use different toolchains; another toolchain chosen through `RUSTUP_TOOLCHAIN` in one crate's `.env`, for the crates of the same workspace that do not depend on that crate; a change in a file that an artifact target generates in the source tree; a change in the lockfile or toolchain file of another workspace; a change in a file of the crate's folder that a negated pattern in the crate's own `inputs` leaves out, by the repository's choice; a change in a file outside the crate's folder that none of the task's inputs covers. These rows hold where `nx.json` and the configuration of the projects whose named inputs a key holds, such as their targets' options, stay the same, because Nx hashes both into every key beside the declared inputs ([[DES-INPUTS]]).
206
+
207
+ Where a crate or a workspace project lies at the repository root, as in `two-workspaces` and in that fixture with a package added to its root manifest, also with a member that depends on that package, a change in the JS lockfile outside the plugin's package, or in the root `package.json`, changes the keys of `doc` on the workspace project there, of every cached target of the crate at the root and of the crates that depend on it, and leaves those of the lockfile task there and of the crates that do not depend on the crate at the root unchanged: the accepted limit of [[DES-INPUTS]], checked so that a change of it is noticed.
208
+
209
+ End to end, in a fixture with two workspaces: after a commit that changes only one workspace's `Cargo.lock`, `nx affected -t test` selects the `test` tasks of that workspace's crates and none of the other workspace, runs those whose resolved dependencies changed and restores the others from the cache where that workspace uses `hakari`, and runs them all under `workspace-build`. After a commit that changes only the JS lockfile, outside the plugin's package and what it depends on, `nx affected -t test` selects no task of a workspace outside the repository root where the Rust targets declare `externalDependencies: []`, and none where they name the plugin's package and `projectsAffectedByDependencyUpdates` is `auto`. Where they name the plugin's package, under Nx's default of `all`, it selects every Rust task of both workspaces: the crate tasks are restored from the cache, and the lockfile tasks among them run, because they are not cached. For the virtual workspace at the repository root it selects, in every case, the `test` tasks of its crates and its lockfile task, the limit of [[DES-LOCKFILE-HASHING]]: the crate tasks are restored and the lockfile task runs. With a manifest edited so that the lockfile is stale, or with `Cargo.lock` missing, the lockfile task updates or creates it, byte for byte as `cargo build` would, and every crate whose resolved dependencies changed runs. In that run no crate task is restored with a result for the old lockfile. In locked mode the lockfile task fails instead with cargo's message, `Cargo.lock` stays unchanged, and no crate task of the workspace runs. A cached task whose crate's digest no longer matches `Cargo.lock` after its cargo call, because a manifest was edited while the run went on, fails, and Nx, with `NX_CACHE_FAILURES` unset, stores nothing for it. Under `workspace-build`, so too does a task whose own digest stays the same while another member's changes during the run: in the workspace of [[EVD-HAKARI-UNIFICATION]], "A sibling's lockfile change", where `cargo update -p g --precise <commit>` between the hashing of `a:build` and its cargo call moves only `b`'s digest, `a:build` fails, Nx stores nothing for it by default and, with `NX_CACHE_FAILURES=true`, the failure ([[ADR-CACHED-FAILURES]]), and the next run builds `a` under a new key. Under `hakari`, in a workspace that passes every check, a task that shared its command fails in the same way when a change during the run moves only another member's digest, and a task that ran in a group of one crate passes. So does a task whose key holds another lockfile's digest because another `nx` command updated `Cargo.lock` and ran its lockfile task between the hashing of the task and its cargo call; afterwards, with the first lockfile back, the task runs again instead of being restored. Two commands that run at the same time on an unchanged lockfile both pass, and each removes its private digests when it ends. `fmt` and `fmt-check` run without the lockfile task, and with a stale lockfile they leave `Cargo.lock` unchanged. With `--exclude-task-dependencies`, `--excludeTaskDependencies` or `--exclude-task-dependencies=true`, in `nx run`, `nx run-many` and `nx affected`, every cached crate task that depends on the lockfile task runs, also when it ran with the same files before and after a change to `Cargo.lock`. A normal run afterwards restores the results of the normal run before. These results hold with the Nx daemon on and off. A cached crate task whose `project.json` takes away its dependency on the lockfile task fails before cargo runs, with a message that names the task and the workspace and says how to find the configuration that replaced the dependency. Where a `project.json` target in the workspace's folder replaces the lockfile task itself, `nx run` of a crate's `check` fails, and Nx stores no result for it. The lockfile task runs in every run, also after `nx reset`; with a current lockfile it leaves `Cargo.lock` unchanged, and after the digest folder is deleted or a digest in it is overwritten, the run writes correct digests and restores every crate task.
210
+
211
+ With the toolchain that a workspace pins missing after the graph was created, a cached task of that workspace runs, and a second run does not restore the first run's result. Keys never repeat while `RUSTC` or `CARGO_BUILD_RUSTC` is empty or names a missing program, or `build.rustc` names one, on which cargo fails too; for `doc` and `test` also while `RUSTDOC` names one. Where no setting names a compiler or a rustdoc, the toolchain command prints what it printed before these settings counted, so those keys stay the same. With `RUSTC` naming a compiler, a run of a cached `build` followed by a replacement of the compiler at that path and the deletion of the binary builds again with the new compiler and restores nothing; so does a run, without the daemon, after `build.rustc` is set in the Cargo home's configuration.
212
+
213
+ A runtime input of the plugin that runs one of its Node scripts, for the artifact folders, the test mode or the napi CLI, prints what the script prints and nothing of its standard error where the script succeeds; where the script throws or does not exist, it prints the line of a failure on a line of its own, also after output without a final line break, and a value that no other evaluation prints, and ends with status 0. With a `PATH` that lists cargo, Node and the shell but not awk, not `od`, or neither, and with the artifact folder script failing and `od` missing, two hashings of one state give different keys of `build`, and with only `od` missing the key repeats and follows a change of a target variable. The executor's warning about such an input says that the command failed when the executor ran it for the task, names its command and what the script wrote to standard error, runs no runtime input without that line, and running the mode command again adds nothing to the command's record ([[DES-INPUTS]], "Failing runtime inputs").
214
+
215
+ A commit, or a `--files` list, that changes only a declared file makes `nx affected` select the cached tasks of the crate that declares it, of the crates that depend on it and the `doc` of their workspace project. For a declared file that is ignored or linked:
216
+
217
+ - Ignored by the root `.gitignore` and added with `git add -f`: the keys differ, and no task is selected.
218
+ - Ignored by the root `.nxignore`: the keys differ, and no task is selected.
219
+ - Ignored only by a `.gitignore` in a subfolder: the keys differ, and the tasks are selected.
220
+ - Covered only by Nx's fixed exclusions, such as a `node_modules` folder: the keys differ, and the tasks are selected, through `--files` as through a commit.
221
+ - A symbolic link to a file declared in place of that file, and a pattern whose part before the first glob character runs through a link to a folder inside the repository: after a change to the file, the keys of `check`, `lint`, `test`, `build` and the workspace's `doc` differ, and the tasks are selected. The same holds after a commit that only replaces the link by one that points elsewhere, and after a change to the new target.
222
+ - A file that a path dependency without a project declares, after a commit or with `--files`: the keys of the crates that depend on it differ, and their tasks are selected.
223
+
224
+ For a pattern that names files of other crates, from a crate of a workspace whose folder is the workspace project's: for each of `../app/src/main.rs`, `../app/**`, `../*/**`, `../*/**/*`, `../*/src/**`, `../*/src/main.rs` and `../a*/src/main.rs`, after a commit that changes a source of a crate that the declaring crate does not depend on, and, for those that name it, a file of a folder that the workspace excludes, and for `../../../*/banner.txt` a file of the workspace project and one of no project, the keys of the declaring crate's `check`, `lint`, `test` and `build` and of its workspace's `doc` differ, and `nx affected` selects the cached tasks of the crate, of its dependents and the `doc` of their workspace project, after the commit and with `--files`. The same holds for `../**` with a source of a crate that the declaring crate does not depend on and a file of no crate. The crate's named input holds the pattern's own fileset and one for each folder of the plugin's projects below where it starts, none for a pattern that starts at the repository root. With the Nx daemon, a crate added later in a folder that a pattern names gets its fileset in the next graph. Once the manifest declares the pattern for the folder of a project that a `project.json` creates there, a change to a file of that project changes the keys and selects the tasks. The same keys differ and the same tasks are selected for a file of a member two folders below `other` that `../{app,other}/`, `../other/`, `../other` and `../*/` name, for a source of `other` that `../*/src` names, and for a file of a project from a `project.json` beside the crates that an alternative of `../{app,web}/src/**` starts in; for that project's file, `../@(app|other)/src/**` leaves the keys unchanged and fails no graph creation. For each of 24 patterns with braces, nested ones included, classes, the extended groups `@(…)`, `+(…)`, `*(…)`, `?(…)` and `!(…)`, `**` between segments, folders and the repository root, every file that Nx's own glob finds for the pattern, with `/**` after it where it names folders, is among the files of the declaring crate's key, and graph creation fails exactly for the patterns that reach the folder of that project, and passes once the manifest adds the patterns that the message gives. For a pattern whose fixed part runs through a symbolic link to a folder named `real[1]`, `gen{x}` or `old(1)`, a change to a file in that folder changes the keys of `check`, `lint`, `test`, `build` and `doc` and selects the tasks. With `../../**` or `../../..`, whose folders hold the workspace's `target`, a `cargo build` that writes there changes none of the keys of the declaring crate's `check`, `lint`, `test` and `build`, of its dependent's `test` or of its workspace's `doc`.
225
+
226
+ A commit, or a `--files` list, that changes a source file or a declared file of a crate with a project that a crate reaches only through a path dependency without a project changes that crate's keys, and `nx affected` selects its cached tasks. So does a change to a crate behind a crate with a project that both the crate and a crate without a project name through a symbolic link.
227
+
228
+ Graph creation fails, with a message naming the manifest and the pattern, for a `fileInputs` pattern that resolves outside the repository, also through a symbolic link to a folder or a file, where the message points to `runtimeInputs`; for one that resolves into the build or artifact directory of the workspace, also through a link; and for one with a `..` segment after a glob character, also in an alternative of braces. A pattern of a path dependency without a project fails the same way, naming that crate's manifest. Graph creation fails as well for a pattern that names files in the folder of a project that a `project.json` creates below where the pattern starts inside another project's folder, a crate's pattern and a workspace table's, with a message that names the manifest, the pattern, the alternative of its braces where it has one, the crates whose keys it is for, the project and the pattern to add, also when the `project.json` appears while the Nx daemon runs.
229
+
230
+ Where the plugin's version is in `pluginVersion`, graph creation fails with a message that names where another value comes from and the targets it reaches, by project: a `targetDefaults` entry keyed by the plugin's executors, with every inferred target of every project; an element of a `targetDefaults` list that sets the option in a configuration, with the element and the configuration; a `project.json` beside a crate, with the file for its targets while a `targetDefaults` entry for the same target is named for the other crates; a `package.json` that the package manager's workspaces list; and another plugin, with the `nx show target` command for the target. Where Nx has a node for the plugin's package, a `targetDefaults` entry that sets the option fails graph creation as well, and a `project.json` that repeats the plugin's own value fails nothing. `nx run <crate>:check --pluginVersion=0.0.0` fails before cargo runs, with a message that names the option and the command line, while the plugin's own value runs cargo, and `nx run <crate>:run -- --pluginVersion=0.0.0` passes the word to the binary.
231
+
232
+ A variable or command that crates whose folders stand in for edges add appears once among the inputs of a crate's targets and named input, also where several of those crates add it, the crate adds it itself or its targets hash it already.
233
+
234
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
235
+ :::
236
+
237
+ :::mara verification VER-BUILD-INPUT-CHECK
238
+ :mid: 01M7ACMK1QE541D0CPTPKKBHSC
239
+ :title: Fail a build that read an undeclared file
240
+ :status: accepted
241
+ :methods: test
242
+ :verifies: REQ-BUILD-INPUT-CHECK
243
+
244
+ In an end-to-end fixture, a crate's build script names a repository file outside the crate with `cargo::rerun-if-changed` and a folder outside it, its library includes another file outside it with `include_str!`, and nothing declares them. `nx run <crate>:build` fails. The message names the crate, each file relative to the repository root and the folder, and shows a `fileInputs` line with each file relative to the crate's folder. By default a second run executes and fails again, also when its cargo call compiles nothing; with `NX_CACHE_FAILURES=true` it replays the failure instead. In neither case is a success cached. After the line is added to the crate's `[package.metadata.nx]`, `build` succeeds, also with `NX_CACHE_FAILURES=true`, and the next run is a cache hit. `build` succeeds as well when the files are declared in the workspace table instead, or by a crate that the crate depends on, and when the library includes a file of a crate that it does not depend on through a pattern that starts in the folder that holds both crates, inside the workspace project's folder. The check still finds an undeclared file with `build.dep-info-basedir` set, and for a file whose name contains a space. When the library includes a file through a symbolic link and only a wildcard pattern that matches the link is declared, `build` fails and names the link and the file it points to; with that file or the link itself declared, it succeeds.
245
+
246
+ The check reads the records that `cargo build -p <crate>` exports for the task's features, profile and triple, whatever Nx caches, and no record it cannot name with certainty:
247
+
248
+ - A crate that has only a library, built as an `rlib`, fails in the same way.
249
+ - A crate with a library and two binaries fails when only one binary's record names an undeclared file, and the message names that file.
250
+ - A binary whose required feature is off is not checked: after a build with the feature, whose binary read an undeclared file, a build without it succeeds although the binary's old record is still there. A record left by a build with another feature set, profile or target triple is not read either: a build in `release`, and one for the host triple named with `--target`, check their own records and not those in `target/debug`.
251
+ - A binary that requires the implicit feature of an optional dependency, and reads an undeclared file, fails `build` when `--features` names a feature of the crate that names a feature of that dependency, a feature of the dependency, or the dependency itself. After those builds, a build with a feature of the crate that names the dependency's feature in the weak form `<dependency>?/<feature>`, which leaves the dependency off, succeeds although the binary's record still names the file.
252
+ - A proc macro whose library includes an undeclared file fails without a triple, with the host triple named as the task's triple, and with `build.target` set in `.cargo/config.toml`: each time the check reads its record in the host profile folder, where cargo writes it whatever the triple.
253
+ - `build` refuses the profiles `test` and `bench` before cargo runs ([[DES-OUTPUTS]]), so for those two the record names, in `debug` and in `release`, are checked against what a real `cargo build --profile test` and `cargo build --profile bench` write. A custom profile that inherits from `test` or `bench` is checked end to end: the check reads the records in the folder of the custom profile's own name.
254
+ - A crate that was an `rlib` including an undeclared file, built for the host triple named as the task's triple, and that then becomes a proc macro including only declared files, succeeds when built the same way, although the record of its earlier kind in the triple folder still names the undeclared file.
255
+ - With `CARGO_BUILD_TARGET` set to the host triple and no triple in the task, and with `build.target` set to it in `.cargo/config.toml` instead, the check reads the records in that triple's folder and fails. With `build.target = "host-tuple"`, whose folder the plugin cannot name, an undeclared file fails nothing, because a record of the same name lies in a triple folder; it does fail once the setting and that folder are gone.
256
+ - In a workspace where two crates have a binary of one name, an undeclared file read only by such a binary fails neither task, while one read by the library of either crate still fails that crate's task.
257
+ - On a file system that ignores case, a file declared with a pattern whose case differs from the name on disk counts as covered exactly when Nx's key includes the file. This case needs macOS and does not run while CI runs on Linux only ([[ADR-CI-LINUX-ONLY]]).
258
+
259
+ A file that the build script generates in `OUT_DIR`, a path outside the repository that it names with `rerun-if-changed`, and the files of a registry dependency fail nothing, also where `CARGO_BUILD_BUILD_DIR` in the crate's `.env`, which graph creation does not see, puts `OUT_DIR` into a build directory inside the repository. There the build script also names the generated file with `rerun-if-changed`, so that the record names it in that build directory with every supported Cargo, also with Cargo 1.91, whose record names the included file below the artifact directory instead ([[EVD-CARGO-DEP-INFO]]). Where that folder holds the folders of crates that the crate does not depend on, the failure names their files, and `build` succeeds once the crate declares the pattern for the folder that the message shows. A build script that names a parent folder with `rerun-if-changed`, such as the workspace folder that holds `target`, fails nothing for the files in Cargo's directories or in folders that Nx ignores, such as `node_modules`, and fails for an undeclared file elsewhere under that folder. `check`, `lint` and `test` of the crate succeed while the files are undeclared. With an installed Nx that lacks `HashPlanInspector`, `build` of a crate that reads an undeclared file succeeds and prints one warning line that the check did not run, and the next run is a cache hit.
260
+
261
+ With the batch executor, `nx run-many -t build` over a workspace where one crate reads an undeclared file and two others do not runs the group as one cargo call: the task of that crate fails, and the other two succeed and are restored from the cache on the next run. When two crates of one group depend on a path dependency whose build script reads a file outside every crate, and only one of the two declares that file, the task of the other fails and the first succeeds. When another crate of the group turns on the feature that a binary of the crate requires, an undeclared file read only by that binary fails nothing, while an undeclared file that the other crate reads itself still fails its task. When two crates of one workspace each give their `build` a feature set of their own, so that one batch process runs a group for each, one after the other, and each crate's build script writes a file during its own build: a file written into a folder that the script names with `rerun-if-changed`, which nothing declares, fails both tasks, and each failure names its own file, also that of the group that ran second; a file written into the crate's own folder and included by its library fails neither. The same holds in one staged whole-workspace group of three crates, where a dependent that declares every file it reads passes beside the crate whose included file its build script wrote. A task run on its own with `--batch=false` fails for such a file in a named folder as well. With an installed Nx that lacks `resetWorkspaceContext`, `build` of such a crate succeeds in a batch and with `--batch=false`, and prints one warning line that the check did not run.
262
+
263
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
264
+ :::
265
+
266
+ :::mara verification VER-CARGO-UNCHANGED
267
+ :mid: 01M78FHG7FWJHMH4NRBANQ4A87
268
+ :title: Leave cargo, its directories and the manifests alone
269
+ :status: accepted
270
+ :methods: test
271
+ :methods: inspection
272
+ :verifies: REQ-CARGO-UNCHANGED
273
+ :verifies: REQ-CACHE-OUTPUTS
274
+ :verifies: REQ-NO-MANIFEST-WRITES
275
+ :verifies: REQ-VERBOSE-COMMAND
276
+
277
+ In an end-to-end fixture, run `nx run-many -t build test lint` and then the equivalent plain cargo commands, which under `workspace-build` select the whole workspace, as the plugin's commands do (`cargo build --workspace`, `cargo test --workspace` and `cargo clippy --all-targets --workspace`): cargo reports nothing to compile. In the other order, the Nx tasks compile nothing either, apart from what the test binaries' step of [[DES-TEST-RUN]] builds otherwise than plain `cargo test`: in the fixture, `codegen`, a member that `api` uses as a build-dependency, and `api`. After a full cycle of Nx commands, `git status` shows no new or changed file inside any crate and no change to `Cargo.toml`, `Cargo.lock` or `.cargo/config.toml`. With the build directory configured outside the repository, the Nx cache entry of each task contains no file from it, and a `build` entry contains only the named final artifacts. Delete the artifact and restore `build` from the cache: the artifact is back, and the modification times of files in the build directory are unchanged. For a crate whose `test` waits for its `build` ([[DES-TARGETS]]), after `nx run-many -t build test` the artifact directory holds the executable that `cargo build` wrote, which the `test` batch put back ([[DES-BATCH]], "Files that a test batch puts back"), and with `--batch=false` the one that `cargo test` wrote, as plain `cargo build -p` followed by `cargo test -p` leaves it. After the batched command, plain `cargo test --workspace --no-run` compiles nothing and links its executable into place again, and plain `cargo build --workspace` compiles nothing and links its own back. The executable that a cache hit of `build` restores is the one that `cargo build -p` writes ([[VER-TARGETS]]). Inspect the declared outputs of every inferred target and confirm that none names a path inside the build directory. The `build` entry of a `cdylib` or `staticlib` crate contains the library file, and no entry contains an `rlib`. With the artifact directory outside the repository, `build` and `doc` are not cached, graph creation says so, and `test` is still cached. With `build.target` set to the host triple as a string in the workspace's `.cargo/config.toml`, and with `CARGO_BUILD_TARGET` set to it in the environment of the `nx` command, `build` and `doc` are cached with outputs in that triple's folder: delete the binary and the doc folder, and the next run restores both without a cargo build, each file as cargo wrote it. Where a second target is installed, a list of the host triple and that triple does the same in both folders; the graph names the folders of each triple of a list, the folder of a triple that a list names twice once, the folders of `CARGO_BUILD_TARGET` over a string and beside a list, and no triple's folder for an empty list unless the run names one, also without that target. The triples that the plugin reads from Cargo's configuration hold each triple once, where one file's list names it twice and where the lists of several files name it. A triple that only a configuration the run does not select names, and a configuration that clears the triple that the options name, leave `build` cached in the configured triple's folder, and a deleted artifact is restored. With `CARGO_BUILD_TARGET` set only in a dotenv file that Nx loads for the task, a cached `build` or `doc` fails before cargo runs with a message that names the triple, what picks it and the `targetTriple` option, and `--targetTriple` with the same triple builds and is restored from the cache with its artifact. Where that dotenv file sets `CARGO_BUILD_TARGET=host-tuple`, the cached `build` fails in the same way, with a message that names the value and says to give the triple as the `targetTriple` option. With the Nx daemon on and `build.target` set to the host triple in the Cargo home's configuration, or in a configuration file in a folder above the repository, run `build` and `doc`, then change the setting to another triple, or remove it, and delete the artifact directory: the next run of each is no cache hit, puts back no artifact of the old triple, runs no cargo build and fails with a message that says that Cargo's configuration changed after Nx created the project graph and to run `nx reset` or stop the daemon. Once the daemon is stopped, `build` and `doc` build into the folder of the new triple, or of none, and a deleted artifact is restored from there. The same holds for `build.target-dir` set in either file to a folder inside the ignored artifact directory and then set to another such folder, or removed, with the first folder deleted: the next run of each builds nothing, puts nothing back into the first folder and fails with that message, and once the daemon is stopped, `build` and `doc` build into the new folder and a deleted artifact is restored from there. With `CARGO_TARGET_DIR`, `CARGO_BUILD_TARGET_DIR` or `CARGO_HOME` set only in a dotenv file that Nx loads for the task, a crate's `.env`, the workspace folder's `.env`, a root `.env.build` or `.env.doc`, or the `.env.<configuration>` of a configuration that the run selects, so that cargo would write to another folder, a cached `build` or `doc` fails before cargo builds with a message that names both folders and the variable and says where to set it instead, and Nx, with `NX_CACHE_FAILURES` unset, stores nothing: after a `build` stored without the file, a run with it, a change of the source and a run without it and without the artifact directory, the binary is that of the new source. Set in the repository's root `.env`, the variable leaves `build` and `doc` cached in that folder, and deleted artifacts are restored. Where the crate's `.env` names a Cargo home whose `config.toml` cargo cannot read, a cached `build` fails before cargo builds with cargo's message and says to correct what cargo reports. A cached `build` or `doc` whose `targetTriple` option is `host-tuple` fails before cargo runs with a message that names the option and the host's triple to pass instead, and `--targetTriple` with that triple builds; one whose option names a target specification file fails with a message that says to build with a built-in triple or uncached; with `cache = false` on `build`, `host-tuple` reaches cargo. With `build.target = "host-tuple"`, `build` and `doc` are not cached, graph creation names the file, the value and the `targetTriple` option, and a second run of `build` runs cargo again; with the triple in the target's own options, `build` is cached and a deleted artifact is restored, and a run whose configuration clears the triple fails before cargo runs with a message that names the file and the option. For each way of picking the host triple that [[EVD-CARGO-TRIPLE-FOLDERS]] covers, the folders that the plugin names are those that `cargo build` and `cargo doc` write to, and it names none for a value it cannot name. The profiles `dev`, `test` and `bench` fail `build` and `doc` before cargo runs with a message that names the profile to use. A `targetDefaults` entry with `cache: true` on `build` fails the task, with the reason, where the plugin leaves `build` uncached for that project, as with the artifact directory outside the repository, and fails nothing where it caches it.
278
+
279
+ Every cargo command the plugin runs starts in the root folder of its workspace: in a fixture with a `rust-toolchain.toml` inside a member crate, the Nx tasks of that crate use the workspace's toolchain. In a fixture where a member depends on a path package outside the workspace that has its name and another version, and in one where a member, in a folder with another name, depends on a registry package with its name and version, plain `cargo check -p <name>` and `-p <name>@<version>` fail as ambiguous, while `build`, `check`, `lint`, `test` and, where the crate has them, `bench` and `run` succeed and select the crate with `-p` and the specification that `cargo pkgid` prints, `path+file://<folder>#<version>` with `<name>@` before the version for the folder of another name, and `fmt-check` with `-p <name>`. Two copies of the first fixture in different folders give each task of the crate the same hash after their runs, while their commands name each copy's folder. In the first fixture, `nx run-many -t build test` over that crate without Nx's verbose mode prints no line of the plugin's about its command and no specification. With a failing unit test and `--verbose`, `test`, `build` and, under `nx run-many --verbose`, the lockfile task each print their command's lines once, before cargo's output, where cargo's own hint `-p good --lib` fails as ambiguous: the `cd` line and the command line, run by hand in `sh` from the repository root, exit with the status of cargo in the task, 101 for the failing test and 0 for the build and the lockfile task, and the cargo wrapper logs the same call as for the task. The lines are printed with `NX_VERBOSE_LOGGING=true` and with `--verbose` beside `NX_VERBOSE_LOGGING=false`, and not without either or with `--verbose=false` beside `NX_VERBOSE_LOGGING=true`, with the Nx daemon off and on. Where the root `.env` sets `NX_VERBOSE_LOGGING=false` and the crate's `.env` sets it to `true`, `check` prints no lines without the flag and with `--verbose=false`, and prints them with `--verbose`, with the daemon off and on. Nx's hasher gives `build`, `test` and the lockfile task the same keys with `NX_VERBOSE_LOGGING=true` as without it, and a run of `test` without the flag after a verbose one restores the result. In batches, `nx run-many -t check build` over the fixture's two crates with `--batch --verbose` prints each cargo command's lines exactly once, and each pair of lines, run by hand, exits with 0 and makes the cargo wrapper log the same call as the batch; a later run without the flag that restores every task prints none of them. With `--verbose=false` beside `NX_VERBOSE_LOGGING=true` a batch prints no lines, and where the root `.env` sets `NX_VERBOSE_LOGGING=false` and a crate's `.env` sets it to `true`, a batch prints none without the flag and with `--verbose=false`, and every command's with `--verbose`, with the daemon off and on. The command of a group of several crates is printed once, with a first line that names every task of the command, and goes into no task's output. The function that quotes the words gives words that sh, and bash and zsh with `extendedglob` where installed, read back as they are, for words with spaces, quotes, `#`, `%20`, `$`, glob characters, `~`, a leading `=`, backslashes, tabs and line breaks. Where a crate's `.env` names a Cargo home whose `config.toml` cargo cannot read, its `check` fails before cargo runs with cargo's message, names the crate and says to correct what cargo reports. After a manifest edit that needs a lockfile update, a task updates `Cargo.lock` as plain cargo would; with the `locked` option, or with `NX_RUST_LOCKED=true`, the task fails instead and `Cargo.lock` is unchanged. A `locked` option that is neither `true` nor `false` fails graph creation, and an `NX_RUST_LOCKED` that is neither fails the task before cargo runs, each with a message that names the setting and its value and says that it has to be `true` or `false`; the one for the variable also says to unset it to use the option. In locked mode `deny` fails in the same way, while `update` updates `Cargo.lock`, and `fmt` and `fmt-check` run, pass `--locked` to no command and give the same results as without locked mode. Creating the graph for a workspace that has no `Cargo.lock` creates none.
280
+
281
+ In a fixture whose crate depends by path on a crate outside its workspace, and whose workspace has a member that Nx excludes, `nx run-many -t fmt` changes files of the crates that have projects and of no other crate. A `doc` cache hit restores the workspace's whole `doc` folder. With two workspaces that share one artifact directory, set at the repository root, reached by one of them through `..` in its own configuration or through a symbolic link to a folder that does not exist yet, `doc` is not cached and graph creation says so for both, naming the folder that the system reaches, while their `build` and `test` stay cached, with the `build` outputs of both in that folder. Where one workspace's configuration spells the directory through a symbolic link followed by `..`, delete the binary that `build` wrote and restore `build` from the cache: the binary is back where cargo writes it. A symbolic link inside the repository that leads the artifact directory outside leaves `build` and `doc` uncached, and graph creation names the folder outside; one outside the repository that leads it inside caches them, with outputs in the folder inside.
282
+
283
+ In a fixture whose workspace has two crates with a binary of one name, one of them with an integration test, graph creation succeeds and leaves the `build` of both and the `test` of the one with the integration test uncached, that `test` still depending on the crate's `build`, while their other targets and the `build` of a third crate stay cached; it prints one warning before the tasks, which is among the warnings of both crates and names both crates and the file. `nx run-many -t build` runs both builds in every run and restores neither, while the third crate's `build` is restored; with the executable deleted, one crate's `build` runs cargo and leaves that crate's executable, and its `test` runs its `build` and itself in every run. The same holds for a crate of that workspace and a standalone crate that a configuration at the repository root gives one artifact directory. After one binary is renamed, both builds are cached and restored, without the warning. Two `cdylib` files, two `staticlib` files, a `cdylib` file whose name a package name with `-` gives beside one that `[lib]` names, and binaries whose names differ only in case count as one name; a `cdylib` beside a `dylib` or a proc macro of its name leaves only the `build` of the `cdylib` crate uncached; a `cdylib` beside an `rlib` of its name, examples of one name and two binaries of one crate whose names differ only in case leave every `build` cached. A `project.json` that caches such a `build` makes its task fail before cargo runs, with the reason, and a `targetDefaults` entry that does fails graph creation ([[DES-OUTPUTS]], "Files of one name"). With two entries of the plugin in `nx.json`, one for each workspace, and a configuration at the repository root that gives both workspaces one artifact directory, with plugin isolation on and off, both crates' `build` and the `test` that runs the executable are uncached, the warning is among both crates' warnings and printed once, both `doc` targets are uncached, and `nx run-many -t build` runs both builds in every run and restores neither, while a crate's `build` run alone after its executable is deleted leaves its own. The same holds, with one entry, where one workspace's artifact directory is the folder of the host's triple in the other's and the other crate's `build` names that triple in its `project.json`, both binaries then being written to one path. Each of these checks fails where graph creation leaves out the other entries' workspaces, or counts only equal directories. With a second installation of the plugin, a copy of its package registered under another name for one workspace beside the plugin's entry for the other, the two workspaces having one artifact directory, graph creation leaves both builds cached, and a cached `build` and the `test` that runs the executable fail before cargo runs, naming the other project's `build` and the file, while the builds of crates without such a file run and are restored; this fails without the check when the task starts. With two entries of the plugin, one for each workspace, and one artifact directory for both, `nx show projects` prints the warning about the crates of both workspaces once, with plugin isolation on and off; this fails where every entry that finds the warning prints it.
284
+
285
+ Where the entry of the plugin receives a workspace's members but not its root manifest, and a member's `.cargo/config.toml` or a relative `CARGO_TARGET_DIR` gives another artifact directory in the folder of the first member manifest read, graph creation names the directory that applies in the workspace's root folder in its warnings, after reading the workspace again in that folder.
286
+
287
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
288
+ :::
289
+
290
+ :::mara verification VER-BATCHING
291
+ :mid: 01M78FHG7FRB1N8C3QP3YJZZAM
292
+ :title: Run each group with one cargo command per step and stable features
293
+ :status: accepted
294
+ :methods: test
295
+ :verifies: REQ-BATCHING
296
+ :verifies: REQ-STABLE-FEATURES
297
+
298
+ Through a cargo wrapper that logs invocations, `nx run-many -t test` with the default runner over a workspace of several crates starts, per group and without `--batch`, the cargo commands of its target's steps and none per crate: one where the group selects its crates with `-p`, as under `hakari` and `cargo`, and three under `workspace-build`, the build, the test binaries and the doctests, two where no crate of the group has a library; with nextest, the steps that `VER-TESTING` counts. Each task has its own status and terminal output, and a second run restores every task from the cache with no cargo invocation. After a change to one crate, only that crate and its dependents run, in one invocation. A failing test in one crate fails that crate's task and no other. A compile error in one crate's tests fails that crate's task, and fails every other task of the group with a message that names that crate and says that their tests were not run; nothing of the step is stored for any of them. In a `check` run, a compile error in one crate and a failing build script in another fail the tasks of those crates and of the crates that depend on them, with a message that names the failed crates, and the tasks of unrelated crates in the same invocation still succeed. Under `workspace-build`, a compile error in a `check` run in a crate that is outside the selection and that no selected crate depends on fails no task and is reported as a warning, while in a `test` run a compile error in that crate's tests fails every task of the group, with a message that names the crate and says that it is outside the selection. Tasks of two kinds, two workspaces, two profiles or two feature sets form separate invocations, which run one after another, and so do the `check` tasks of two crates of one workspace whose metadata sets `--all-targets` differently; there both tasks succeed when the crate without the flag has a bench that stable rejects under it. With `RUSTFLAGS`, or `RUSTUP_TOOLCHAIN` naming another installed toolchain, set in one crate's `.env`, that crate's task runs in an invocation of its own with that value, and the other tasks run without it.
299
+
300
+ For each feature-unification strategy that can be set up in a fixture: build a subset of crates, then a different subset that shares a third-party dependency whose features differ between the subsets. The second run does not recompile that dependency, and the hash and result of a crate present in both runs are identical. Under `cargo`, the cargo wrapper shows `-Zfeature-unification` and `--config 'resolver.feature-unification="workspace"'` on the command line of every step, and with a stable toolchain every task fails with cargo's error that `-Z` flags need the nightly channel, and nothing is stored. For `hakari`, fixtures with cargo-hakari, set up as `cargo hakari init`, `generate` and `manage-deps` leave them with the host's triple in `platforms`, as [[EVD-HAKARI-UNIFICATION]] built them; the test harness writes the files as cargo-hakari 0.9.39 generates them, which a case with the real cargo-hakari checks through `hakari-check`, so that the cases whose point is not the drift check run without the tool, with a `cargo-hakari` on `PATH` that succeeds, while the drift cases skip where the real one is missing:
301
+
302
+ - **All checks pass.** In a workspace where the members `a` and `b` ask a shared third-party crate for different features, also through a build dependency, a dev-dependency and a `cfg(unix)` table, and no member asks a feature of another, `nx run-many -t build -p a`, and then `nx run-many -t build -p a,b --skip-nx-cache`, start cargo calls that select only those crates. The second call compiles neither the shared crate nor `a` again, `a`'s binary prints the same features of the shared crate after both runs, and `a:build` has the same hash in both. This is the spike's central experiment. The workspace has `hakari-check`, which runs before the crate tasks in each run, and no warning. A crate's key holds the hack crate's manifest and `.config/hakari.toml` and no other member's manifest.
303
+ - **A check fails.** Each of these makes the workspace use `workspace-build`: graph creation, with `NX_DAEMON=false`, `init` and the start of each task of its projects print one warning that names the check and the crate, entry or setting, the workspace has no `hakari-check`, a group builds the whole workspace, and the keys of its crates differ from those under `hakari`. For the members: a dependency of one member on another with a `features` list, one with `default-features = false` on a member that has a default feature, and one with `default-features = false` on a member that declares `default = []`, where `cargo build -p a -p c` would otherwise give `c` the feature `default` that `cargo build -p a` does not; `c/f` and `c?/f` in a member's `[features]`, each through a renamed and optional dependency, one inherited with `workspace = true`, one under a `cfg` table and a dev-dependency; and a member's dev-dependency on itself with a `features` list. A dependency with default features on a member, and one with `default-features = false` on a member whose `features` table has no `default`, pass. For the platforms: the empty list that `cargo hakari init` writes, and a list with other triples but not the host's. For crates outside the workspace: a path crate outside it that depends on a member through a normal dependency, also behind another such crate, while one that reaches a member only through a dev-dependency passes; a `[patch.crates-io]` entry whose path is a member's folder; and a path crate outside the workspace whose folder holds `.cargo-checksum.json`. A configuration without `hakari-package`, or one that names no member, falls back too. So does each setting of the configuration that the fourth check does not accept: a `traversal-excludes` or `final-excludes` with a member or with a third-party crate, `workspace-hack-line-style = "version-only"`, a non-empty `registries` and an unknown key, with the key and its value in the warning; while each accepted value of `resolver`, `unify-target-host`, `dep-format-version`, `exact-versions`, `output-single-feature` and `workspace-hack-line-style` keeps `hakari`. Undoing the change makes the workspace use `hakari` again with the earlier keys, also with the Nx daemon, for a member's manifest and for `.config/hakari.toml`. With `featureUnification = "workspace-build"` in the workspace table, the workspace is not checked and prints no warning, and with `featureUnification = "hakari"` in a workspace without a configuration, it falls back with the warning.
304
+ - **A stale hack crate.** With `b` asking `x` for another feature and the hack crate not generated again, with a new member without the dependency on the hack crate, and with `a` no longer asking for a feature that the hack crate gives, `nx run-many -t test` fails `hakari-check` with cargo-hakari's output, starts no cargo call for the crate tasks, as the cargo wrapper shows, and stores nothing: after `cargo hakari generate` and `cargo hakari manage-deps`, the crates' keys differ from before and their tasks run. Without cargo-hakari on `PATH`, `hakari-check` fails with the message for a missing tool. Offline with an empty Cargo home, it fails with cargo-hakari's output.
305
+ - **Feature flags.** In that workspace, with `b` depending on the member `a` and `a` asking a third-party crate for another feature under one of its own features, `nx run-many -t build -p a,b -c all-features` starts one cargo command per crate, as the cargo wrapper shows, and none that selects both. `b`'s hash, and the features of the `a` that `b` links, which its rustc line shows, are the same in a run that includes `a`'s task, in one where `a:build` is restored from the cache, and in `nx run b:build -c all-features` alone. Running `a` before `b` and `b` before `a` in two artifact directories compiles the same crates, and running both again compiles nothing. The same holds for `noDefaultFeatures` and for a `features` option, unqualified and as `crate/feature`, while the default features start one command for both crates.
306
+ - **Triples.** With an installed non-host triple listed in `platforms`, `nx run-many -t build -p a,b --targetTriple=<triple>` starts one cargo command for both crates. With one that `platforms` does not list, given only on the command line, it starts one per crate, fails no task and prints no warning. With such a triple set by `build.target`, or as a `targetTriple` in a member's metadata table, the workspace keeps `hakari` and its `hakari-check`, graph creation with `NX_DAEMON=false`, `init` and the start of each task print one warning that names the triple and `platforms`, the tasks for that triple start one cargo command per crate and the host's tasks share one, and adding the triple to `platforms` and generating the hack crate again removes the warning and lets them share a command. In a workspace without cargo-hakari, so under `workspace-build`, the same run with a non-host triple starts one command per crate, while the host's build starts one for the whole workspace.
307
+ - **Denied warnings.** With a real cargo, in a workspace whose members `a` and `b` both depend on the member `shared` and not on each other, and whose member `d` neither uses, with `CARGO_BUILD_WARNINGS=deny`, a warning in `a` fails both `a:check` and `b:check`, and both `a:lint` and `b:lint`, in a group that selects the whole workspace, each with a message that names `a` and what denies warnings; a warning in `d` fails both as well. Without the variable both pass. In a group of `lint` that selects `dep` and `indep` with `-p`, `build.warnings = "deny"` in the workspace's `.cargo/config.toml` and a warning in `base`, outside the group, fail both, with a message that names the file, and `CARGO_BUILD_WARNINGS=warn` over that file passes both. In a group of `build` of several crates, a warning in a member that one of them uses fails both. Through Nx, `nx run a:check` with the warning passes, and with `CARGO_BUILD_WARNINGS=deny` it is not restored and fails; in a workspace that patches a crate's registry dependency to a member, a warning in that member fails the crate's `check`. On a Cargo older than 1.97, which ignores the setting, every one of these tasks passes, as plain cargo does. The Cargo home whose configuration counts is the one that `CARGO_HOME`, or else `HOME`, in the command's environment names. In the test steps, where cargo applies the setting itself ([[DES-TEST-RUN]], "Denied warnings in a test step"): through Nx, `nx run-many -t test -p a,b --skip-nx-cache` with `CARGO_BUILD_WARNINGS=deny`, a warning in `d`, and cargo's progress and colours forced on, fails `a:test` and `b:test`, each with a message that names `d`, says that it is outside the selection and names the variable, and with `d`'s warning in its output; with `build.warnings = "deny"` in the workspace's `.cargo/config.toml` and a warning in `a`, both fail, each with a message that names `a` and the file. In a group of `test` that selects `dep` and `indep` with `-p`, the file and a warning in `base` fail both, each with a message that names `base` as outside the selection and the file. On a Cargo older than 1.97 every one of these tasks passes. From cargo's output with the denial lines, the readings of the build step, of a `cargo test` with `-p` and of a nextest build that failed name the packages of cargo's summaries, those outside the group as outside the selection, and what denies them, and where cargo names no package, say so; they read the lines of denied warnings after cargo's progress bar and a carriage return, while a line that a test prints with a carriage return stays with its test in the nextest reading, give every task a denied warning located in another crate's folder, name a crate whose build script failed besides the warnings, and say that cargo reported further errors where another error names no crate; without the denial line, the message names only the crates that did not compile.
308
+ - **Tests under `workspace-build`.** A workspace without cargo-hakari has the members `a` and `b`, which ask a shared member for different features, `c`, whose unit test, integration test and doctest fail when a variable is set, and one of whose tests then sleeps longer than the run may take, `d` with doctests in edition 2021, a crate with a binary only, and in `a` an example without `test = true`. `nx run-many -t test -p a,b` with the variable set starts, as the cargo wrapper shows, `cargo test --workspace --no-run`, then `cargo test --workspace --tests --no-fail-fast --message-format=json-render-diagnostics` with the plugin's runner on its command line, then `cargo test --workspace --doc --no-fail-fast` without it. Both tasks succeed; no unit or integration test of `c` runs, so that a file that they would write stays absent and the run ends before the sleep would; `c`'s doctest runs and fails, and each task's output holds a warning that names `c`. The output of `a:test` and `b:test` holds their own tests and doctests and no line of another crate's blocks. After `cargo test --no-run --workspace`, the run compiles nothing, nor does a following `nx run-many -t test -p c --skip-nx-cache` without the variable, nor `cargo test --no-run --workspace` after both. With `a`'s example made not to compile, `a:test` and `b:test` fail, as `cargo test -p a` does. A `should_panic` doctest that calls `std::process::exit(3)`, and one that panics under `RUSTDOCFLAGS="-C panic=abort"`, pass, as under plain cargo; and in a crate in edition 2024 whose merged doctests include one that calls `std::process::exit(0)` before one that fails, the crate's task fails, as under plain cargo. With `testRunner = "nextest"`, the run starts one `cargo nextest run --workspace` with `--no-tests=pass`, the filterset `package(=a) | package(=b)` and the plugin's tool configuration file, without a runner, and one `cargo test --doc --workspace` without one; the tests of `c` do not run, a failing test of `a` fails `a:test` alone through the JUnit report, and a group whose only crate has no test succeeds.
309
+ - **Evidence for test binaries.** In a workspace whose members `a` and `b` have passing unit and integration tests, `c` a failing unit test and `h` a passing integration test with `harness = false`, `nx run-many -t test -p a,b,h` fails all three tasks, writes no marker and stores nothing, so that the next run runs them again, in each of these cases: the runner's list replaced by `bad` through a seam of the tests; the Node runner unable to start, under `NODE_OPTIONS=--not-a-real-node-option`; the runner ending with 0 before it records anything, under a preload in `NODE_OPTIONS` that exits, also with `CARGO_TERM_QUIET=true` and with `CARGO_TERM_VERBOSE=true`; the record folder unreadable or unwritable; and the runner killed after it records its start, through a seam. A test linked against a `dylib` member, built with `RUSTFLAGS="-C prefer-dynamic"` and the toolchain's library folder on `LD_LIBRARY_PATH`, fails its task with the status 127 where a seam removes `LD_LIBRARY_PATH` in the runner's process, as cargo reports too. Without the seams the same runs pass, also with `CARGO_TERM_QUIET=true` and `CARGO_TERM_VERBOSE=true`. `h` runs a nested `cargo test` of another workspace whose test fails, with inherited output, and prints a `Doc-tests` header, a list of failed targets naming `b` and a JSON `compiler-artifact` line, and `a`, `b` and `h` still pass; with `c` selected, only `c` fails.
310
+ - **Lines that are not cargo's.** A member `pm` is a proc macro that prints `{"reason":"build-finished","success":true}` while it is expanded, and a member `b` uses it, has a build script that prints `cargo:rerun-if-changed=never-exists`, so that the test binaries' step compiles `b` again after the build step, and has a failing integration test. With the runner ending with 0 before it records anything, through a preload in `NODE_OPTIONS`, `nx run-many -t test -p b` fails `b:test` and stores nothing, as `cargo test -p b` fails, although the forged line comes before the artifact message of `b`'s test executable and cargo exits with 0. With the test made to pass and the runner working, `b:test` succeeds with the forged line in the stream. A forged `compiler-artifact` line for an executable of `b` fails `b:test`, and a forged `build-finished` with `success: false` fails every task of the step, each although cargo exits with 0.
311
+ - **The runner and the check.** Started directly, the runner records its start before anything else; exits with 125 and starts nothing without `NX_RUST_TEST_PACKAGES`, with a value that is not of the form `:a:b:`, without `CARGO_PKG_NAME`, with an empty one and where it cannot record; records the end with the program's status or signal and ends the same way, a signal that does not dump core being sent to a real program and the runner, and every signal that dumps core being checked with a fake program whose end the runner records and whose signal it raises through a function the test passes in, so that the suite leaves no crash record on the host; and passes its environment on unchanged, so that a test sees `SHELLOPTS` and other variables that `[env]` of `.cargo/config.toml` sets, `BASHOPTS` and a variable named `odd-name` as under plain cargo. In tests of the check, against cargo's messages and the record of the test binaries' step, a test executable without a record, with two records, with a record of another package, without an end, with another status than 0, with a signal or with an error entry, a missing `build-finished`, any one that reports a failure, also among others that report success, an artifact message whose `package_id` is no member's, an unreadable record folder, and a failed exit of cargo that nothing in the record explains each fail the task, also where cargo exited with 0; artifact messages after a `build-finished` count as well. For the doctest step, only the last list on cargo's standard error decides, only where cargo exits with another status than 0 and only where it ends cargo's standard error, every task failing where it does not; a list that a failing doctest prints, also under `RUST_TEST_NOCAPTURE=1`, a list from a nested cargo in a test binary, and the quiet and verbose terminal settings change nothing, and an entry without `-p` names the only member.
312
+ - **A group left with one task.** In a workspace where `a` depends on `shared` without its feature `x`, `b` switches `x` on and a test of `a` asserts that `x` is off, `nx run-many -t test -p a,b` fails `a:test`. After `nx run b:test`, which stores `b:test`, `nx run-many -t test -p a,b` restores `b:test` and fails `a:test` the same way, and so does `nx test a`; the cargo wrapper shows `--workspace` with the plugin's runner in both, and no `-p`.
313
+ - **Files that a batch stores.** The binary crates `pa` and `pb` print whether their feature `extra` and the cfg `nx_rust_flag` are on. With `allFeatures = true` in the `build` options of `pb`'s table, `nx run-many -t build -p pa pb --parallel=2` passes, and after each executable is removed, `nx run <crate>:build` restores `pa` printing `plain` and `pb` printing `extra`; with the table on `pa` instead, the reverse holds. The cargo wrapper shows `cargo build --workspace` with a stage and then `cargo build -p` with the crate's specification and `--all-features`, without one. With `RUSTFLAGS=--cfg nx_rust_flag` in `pb`'s `.env` instead, the run passes, Nx reports one batch and starts one batch process, the wrapper shows two whole-workspace builds, each with a stage of its own, and the restored `pa` prints `plain` and `pb` `plain flag`. The same holds in the styles `stream` and `stream-without-prefixes` and under GitHub Actions' grouping, and on Linux under the terminal UI in a terminal of 120 by 35 through util-linux's `script`, where the terminal UI starts and closes by itself, Nx prints that both builds succeeded, and the stages of the two builds carry the process id of one batch process. The terminal UI shows only its list of tasks there, so what the batch shows of cargo's output under it is checked by the unit test of the batch's choice of live output, not on the screen. With a third binary crate `pc` that depends on `pb`, and a target default that adds `^build` to `build`, the wrapper shows three whole-workspace builds, for `pa`, `pb` and `pc` in that order, in one batch process, and each restored executable prints what its own command built. A JS task that depends on both builds runs after them and runs `pa` without the flag and `pb` with it, and in `nx run-many -t build test` every cargo command of the `test` batch comes after both builds. With a compile error in `pa`, the run fails `pa:build` and stores `pb:build` as its own command built it, also with `--nx-bail`, since both groups belong to one batch process. A copy of `pa`'s `build` target under another name, which depends on `pa:build` and whose `.env` sets the flag, fails both tasks before cargo runs with the message of [[DES-DIAGNOSTICS]], in a batch and with `--batch=false`, while `pb:build` of the same command runs. The check at the end of a batch fails a task that the batch did not report. In tests of the grouping, a task whose own options set a feature set shares no group with a task to which a configuration gives the same flags.
314
+ - **Staged builds.** In that fixture, a cached JS target `pack` depends only on `pa:build`, with `pa` as an implicit dependency and the inputs `default` and `^default`, and writes what `pa` prints to a file. `nx run-many -t build pack -p pa pb pack --parallel=3` passes and stores `plain` for `pack`, also where `nx run pa:build` stored `pa` before, so that Nx restores it and the batch runs only `pb`'s whole-workspace build. Afterwards `pa` prints `plain`, `pb` `plain flag`, and no stage is left in the artifact directory. After the file is deleted, `nx run pack:pack` restores `plain` beside a `pa` that prints `plain`, and plain `cargo build --workspace` with `pb`'s flags compiles nothing. Through a cargo wrapper that holds `pb`'s build once cargo has ended and before the call exits, `pa` prints `plain` while it waits, as a task that runs meanwhile, such as a continuous one, reads it. `pack` stores `plain` where `pa:build` declares its output as the glob `{workspaceRoot}/rust/target/debug/p[a]`, and where it declares no outputs, and with `--batch=false`, `pack` depending on both builds, which then build in stages too, at `--parallel=1` and at `--parallel=3`, after which each build restores its own executable (nxr-fpc72j). Where `pb`'s build script runs `pa`, `pb` declares `{ "dependentTasksOutputFiles": "**/pa" }` and a variable in `pa`'s key alone decides what `pa` prints, a run with that variable changed, the executables deleted and the cache kept builds `pb` again, which then prints the new value (nxr-f04xen). Each case but the last stores or reads the other build's file where builds are not staged. In tests of the stage: the flags, with the build directory as a TOML string; which targets and selections stage; a stage made, marked and removed, and nothing removed that is no stage; the stages of processes that no longer run removed, and of a process id now used by a process that started at another time, while a live process's stage stays, also unmarked; a leftover of an earlier process of the same id replaced; the final artifacts of the group's own packages and the records of all their targets named, an `rlib`, a proc macro's library and files outside the stage not; files moved by rename into folders that the artifact directory lacks; nothing taken from outside the stage or written outside the artifact directory; and a file that cannot be moved reported by its package. In `napi-addons` and `wasm-packages`, `napi-build` and `wasm-build` leave every file of the artifact directory as it was and post-process the library and check the records from the stage. A `build` that reads a file that its inputs do not cover still fails the input check with its records moved, also with `build.dep-info-basedir` set and with `CARGO_BUILD_BUILD_DIR` in a crate's `.env`. A verbose run of a `build` on its own prints `--target-dir` with the stage and `--config` with the build directory, and the printed lines run by hand make the same cargo call. On Cargo 1.91, through the end-to-end suite, staged builds pass and plain cargo afterwards compiles nothing ([[DES-BATCH]], "Staged builds").
315
+ - **Files that a test batch puts back.** In `binary-tests`, a cached JS target `pack` depends on `app:build` and `app:test`, with `app` as an implicit dependency and the inputs `default` and `^default`, and writes what `app` prints to a file. `nx run-many -t build test pack` passes, the integration test runs the executable of `cargo test`, `pack` stores `plain`, and afterwards `app` prints `plain` and no stage is left in the artifact directory; after the file and the executable are deleted, `nx run pack:pack` restores `plain` and `app:build` beside it, and `app` prints `plain`. With the first `cargo test` held by the wrapper, the group's stage holds the executables of `app`, `benched` and `harnessless`, the crates whose binary `cargo test` builds for their tests and whose files exist; a write into the kept executable, and the removal of its link in the stage, each fail every `test` task of the group, each with the message of [[DES-DIAGNOSTICS]] that names the problem, the file and `app:build`, `pack` does not run, no stage is left, and, with `NX_CACHE_FAILURES` unset, `app:test` runs again in the next command. With batching on, `nx run-many -t build test`, also with `--parallel=1`, with the targets in the other order, with `test` alone and with `--exclude-task-dependencies`, leaves the executable of `cargo build`; with `--batch=false`, that of `cargo test`. With `build.target = "host-tuple"` in Cargo's configuration and the host's triple as the `targetTriple` of `app`'s `build`, `nx run-many -t build test -p app` leaves the executable of `cargo build` in the host triple's folder. Unit tests check that a `test` group's candidates are the final files of the crates with a binary and an integration test or bench, of every member for a group of the whole workspace and of its own crates for one that selects them, in the folders of its triple and profile, every kind of final file included, `host-tuple` in the option and in Cargo's configuration standing for the host's triple and a target specification file giving none, and a `bench` group's those of every crate with a binary in the folder of the bench profile; that a candidate is kept where a cached `build` stores it through an output that names it or a folder above it, a glob, an exclusion or an absolute path inside the repository, or an output that is the repository root, and not for an uncached build, empty outputs, an output outside the repository or one spelled through a symbolic link; that no directory report is asked for where the command has no cached build that the group may keep files of with an output inside the repository, or the group no crate that links files again; that a glob output whose matcher cannot be loaded and a failed report of the directories fail the group; and that the stage holds a replaced or removed file and puts it back, leaves an untouched one as it is, keeps no missing file, folder or symbolic link and makes no stage for nothing, reports a file written in place or whose permissions changed, one that it cannot look at, keep or put back, and that a stage that a process left when it ended before putting back is removed by the next keeping (nxr-nbdazw).
316
+
317
+ `build` and `doc` run as `@convesoft/nx-rust:cargo-outputs` and every other batched target as `@convesoft/nx-rust:cargo`, and `nx run-many -t build test` shows a batch of each. With batching off, through `--batch=false`, `nx run-many -t build test` over that fixture starts no `test` before the `build` of every crate whose executables its whole-workspace `cargo test` replaces has been stored, as a held `cargo test` shows, and every stored `build` entry restores the executable that `cargo build` wrote; with batching on, the same holds ([[ADR-WORKSPACE-TEST-EXECUTABLES]]). In the fixture of [[VER-TARGETS]] with one crate of each shape of the rule of [[DES-TARGETS]], with a build directory warmed by plain cargo and an empty Nx cache, `nx run-many -t build test` and `nx run-many -t test`, at the default parallelism and with `--parallel=1`, with the targets in both orders and with `--exclude-task-dependencies`, store for every `build` the executable that `cargo build -p` writes and pass every test as `cargo test -p` passes it, and with the `cargo test` of the `test` batch held by the wrapper, the cache holds the entries of the `build` batch already. A `project.json` that replaces the `dependsOn` of `test` makes that crate's `test` task of the batch fail before cargo runs, with the message of [[DES-DIAGNOSTICS]], and leaves the other tasks of the batch their own results.
318
+
319
+ Every check that a task run on its own makes before and after cargo fails the task in a batch as well, through `--batch`, each with its own run: an executor that does not run the target, caching turned on for an uncached target, the profiles `dev`, `test` and `bench` and a `targetTriple` of `host-tuple` on a cached `build` or `doc`, triples that Cargo's configuration or a task's dotenv file picks and that the outputs cannot name or do not name, project metadata without a Cargo workspace, an `NX_RUST_LOCKED` that is neither `true` nor `false`, a `pluginVersion` given for one run, a `test` without its order after `build`, a missing dependency on the lockfile task, a missing cargo-audit or cargo-deny, an artifact directory that a dotenv file moves, `cargo metadata` failing for the specifications or for Cargo's directories, the lockfile's digests changing between the key and the end of cargo's call, by a manifest edit during the run, by another `nx` command and, with cargo held after the key is computed, by `cargo update -p zzlib --precise 1.0.1 --offline`, a `build` that reads a file that its inputs do not cover, and a cached `build` of a crate whose artifacts share a file name with another installation's crate in one artifact directory; the warnings of the task's project and the line for a skipped input check are in its own output.
320
+
321
+ An integration test and a build script that write their whole environment, with dotenv files in the crate's folder and at the root that define `FORCE_COLOR` and refer to one another and to a variable of the command, run alone and in a batch, each in the styles `static`, `stream` and `static` with `--verbose`, and on Linux in a pseudo-terminal through util-linux's `script` in the styles `static`, `stream-without-prefixes`, `dynamic-legacy`, `dynamic` and the terminal UI, without the daemon and, for `static`, `stream-without-prefixes` and the terminal UI, with it, `dynamic` and the terminal UI in a terminal of 120 by 35, where Nx starts its terminal UI, which no other way starts, and every way with `TERM=xterm-256color`; a run counts as one of the terminal UI only where Nx switched to the terminal's alternate screen, and every run asserts that Nx printed no warning that the terminal UI is not enabled. On Nx 24.0.6 `--output-style=dynamic` in a terminal with a size opens the terminal UI as `--tui` does, so these two ways differ in the flag and not in the renderer. These runs are made while the command's environment holds `NX_SET_CLI`, `FORCE_COLOR=0` and `NX_TASK_TARGET_CONFIGURATION`, which Nx's pseudo-terminal would give back. Every one sees the same environment apart from the variables that differ between any two `nx` commands, `NX_INVOCATION_ANCESTOR_PIDS`, `NX_RUST_COMMAND_ID` and `NX_RUST_NX_COMMAND`, with the dotenv values, `NX_TASK_TARGET_TARGET`, `NX_FORKED_TASK_EXECUTOR` and `NX_CLI_SET` among them and without `NX_TASK_TARGET_PROJECT`, `LERNA_PACKAGE_NAME`, `NX_TASK_TARGET_CONFIGURATION` and any variable that [[DES-BATCH]] leaves out. A root `.env` with Nx's own settings, `NX_DAEMON=false`, `NX_VERBOSE_LOGGING=true`, `NX_PARALLEL=3`, `NX_SKIP_NX_CACHE=true`, `NX_NO_CLOUD=true` and `NX_TUI=false`, beside a variable of its own that a task's `.env.test` refers to, passes alone and in a batch, in `static` and, on Linux, in `stream-without-prefixes` in a terminal, with one environment, and so it does with `NX_LOAD_DOT_ENV_FILES=false` in the command, where no run has the root file's variables. With `NX_FORKED_TASK_EXECUTOR=true` and `NX_CLI_SET=true` in the root `.env` and both `false` in the task's `.env.test`, the task gets `true` for both alone and in a batch; a `.env.test` that refers to one variable fourteen times passes alone and in a batch. A task whose dotenv file makes Nx look up `FORCE_COLOR`, as in `REVIEW_COLOR=${FORCE_COLOR-unset}`, or `NX_FORKED_TASK_EXECUTOR`, and one whose dotenv files define `NX_LOAD_DOT_ENV_FILES`, as a root `.env` with `true` and the task's `.env.test` with `false` beside `REVIEW_COLOR`, fails before cargo runs, on its own and in a batch, with the message of [[DES-DIAGNOSTICS]], which for `NX_LOAD_DOT_ENV_FILES` says to remove the definition from the task's `.env.test` and to set `NX_LOAD_DOT_ENV_FILES=false` in the environment of the `nx` command to switch the loading off; it fails so also with `NX_LOAD_DOT_ENV_FILES=false` in the command. Without a plain dotenv file, with a root `.env.vault` that decrypts to `REVIEW_VAULT=secret` and with `DOTENV_KEY` and `REVIEW_VAULT=secret` in the command, the task fails before cargo runs alone in `static`, on Linux in `stream-without-prefixes` in a terminal, and in a batch, saying that `DOTENV_KEY` is set and `.env.vault` exists. A `.env.test` with 257 references to `HOST` of the command, `http://${HOST}:8000` to `http://${HOST}:8256`, passes alone and in a batch with one environment. A root `.env.local` with `NX_ORIGINAL_FORCE_COLOR=${CMD}z`, under `FORCE_COLOR=0` and `CMD=x${CMD}` in the command, passes alone in `static` and, on Linux, in `stream-without-prefixes` in a terminal, and in a batch, with one environment, in which `CMD` is the command's and `NX_ORIGINAL_FORCE_COLOR` is absent. Against files in a temporary folder and the dotenv of the repository's Nx (with no run-time pin on a `dotenv-expand` version): each variable that can differ between the processes fails the check in every form of reference, `$NAME`, `${NAME}`, with each operator and in another reference's default or alternative (also when that branch would not be taken, as `${UNSET_TOO:+$NX_TUI}` and `${SET:-$FORCE_COLOR}` with `SET=x`), through `$$NAME` indirection (with `NAME` defined in a file, in a quoted multiline CRLF value or in the command's environment), and through `dotenv-expand`'s `split(null)` on literal `"null"` (`${NX_FORKED_TASK_EXECUTORnull}`, `${Anull$FORCE_COLOR}`); so does such a variable reached through a value of the command's environment, through another file's variable, or through a cycle; dynamic or ambiguous `$` forms fail statically — dynamic names (`${FORCE_${PART}}`, `${X${Y}}`), a top-level unclosed `${` followed by a matched reference (`${FORCE_${PART}` with `PART=COLOR}`), `$${NAME}` / `$${Z}` / `$$$A` / `$$SELECTED` with `SELECTED={FORCE_COLOR}`, unclosed `${` and empty `${}` inside a referenced value or default, `$&`/`$'`/`` $` `` replacement patterns (including after `\`, as `\$&`, `\$'`, `` \$` ``) and joinable trailing `$` in a referenced value or default body (`${DOLLAR}NX_VERBOSE_LOGGING`, `${A}{FORCE_COLOR}`, `${A:-$}FORCE_COLOR`), and trailing unbraced `$NAME` or `$$NAME` that can join adjacent text or an earlier escaped copy (`${A:-$FORCE_}COLOR`, `PASSWORD=pa$$FORCE_` with `USE=${PASSWORD}COLOR`, chained `A=$FORCE_` -> `B=${A}` -> `C=${B}COLOR`, `NAME=x$NX_FORKED_TASK_` with `VALUE=\$NAMEEXECUTOR $NAME`, `A=x$NX_FORKED_TASK_` + `B=$A` with `VALUE=\$AEXECUTOR ${B}`, `VALUE=\${A}COLOR ${A}` with `A=x$FORCE_`, and `VALUE=\${A}COLOR ${B}` with `B="p${A} "` and `A=x$FORCE_`), and no diagnostic of the check ever prints any character from a file or environment value (including nested lookups reached via a non-identifier key such as `${1}`); self-append idioms (`RUSTFLAGS=${RUSTFLAGS} --cfg tokio_unstable`, `RUSTFLAGS="$RUSTFLAGS -C target-cpu=native"`, `PATH=${PATH}:./bin`, `CARGO_BUILD_RUSTFLAGS=${CARGO_BUILD_RUSTFLAGS:-} -C debuginfo=0`, `RUSTFLAGS="-C target-cpu=native $RUSTFLAGS"`, each unset and set), non-identifier literal braced names and unknown operators kept literal by `dotenv-expand` (`${APP.VERSION}`, `${1}`, `${SET:?error}` including with `SET="$FORCE_COLOR"` in the command), top-level unclosed `${` with no following matched reference (`${UNCLOSED`) and top-level `${}`, files that define a run-dependent variable, any backslash escape immediately before `$` (`\$FORCE_COLOR`, `\\$FORCE_COLOR`, `\\\$FORCE_COLOR`, `\\\\$FORCE_COLOR`, `\\${FORCE_COLOR}`), `PASSWORD=pa$$word` with `VALUE=${PASSWORD}` (including with post-expansion `PASSWORD="pa$"` in `env`, while `USE=${PASSWORD}COLOR` fails), non-special `$!` / `$$!` values (`DUMMY_TOKEN="$!SAMPLE_SECRET_DO_NOT_USE"`, `PASSWORD=pa$$!DUMMY_TOKEN`), top-level literal `$` (`REGEX=^foo$`), cycles without run-dependent variables (`B=x${B}` with `VALUE=${B}z` under `B=x`, `A=${B}` and `B=${A}` with `VALUE=x${A}` under `A=hi`), long literal expansions (`VALUE=${HUGE}${HUGE}z`), a task without dotenv files and one where Nx loads none all pass; a source-text tripwire test asserts that the installed Nx's `dotenv-expand` `lib/main.js` equals the recorded source that the check follows, failing with instructions to re-read its matching, splitting, escaping and replacing if it changes; a file that defines `NX_LOAD_DOT_ENV_FILES` fails whatever its value and whether or not Nx loads the files; a vault that dotenv would read with `DOTENV_KEY` set fails, a root vault without any plain dotenv file included, whether or not Nx loads the files, and the same files without `DOTENV_KEY` pass; the message for `NX_LOAD_DOT_ENV_FILES` names the files, says to remove the definition and, to switch the loading off, to set `NX_LOAD_DOT_ENV_FILES=false` in the environment of the `nx` command, in the shell or the CI settings; where the check passes, Nx's own loader gives every other variable the same value whatever those variables hold; fourteen references to one variable of a file, 257 references to one of the command and twenty variables of the files ending in a run-dependent reference are handled linearly. The plugin's environment for cargo leaves out what the pseudo-terminal gives back, gives `NX_SKIP_NX_CACHE`, `NX_TASK_TARGET_CONFIGURATION` and `NX_READY_URL` as Nx's per-task layer gives them, sets `NX_FORKED_TASK_EXECUTOR` and `NX_CLI_SET` after a batch task's own variables, and removes the root files' values again only where Nx loads no dotenv files.
322
+
323
+ A seeded test of 2,500 random cases, which prints the seed of a failing one, writes dotenv files with definitions, references with every operator, nesting, quotes, odd- and even-backslash escapes, variables defined in several files, Nx's own variables, variable-name literals and explicit `$$HOST`/`$$CMD` indirection (in files and in the command's environment), lists of 150 to 400 references to one variable, self-append idioms on `RUSTFLAGS`, and root vaults, alone and beside plain files, with and without `DOTENV_KEY`, beside a random command environment, and builds the nx process's environment and both paths with Nx's own loader and the plugin's functions: the nx process starts from the command's environment with `FORCE_COLOR=0` replaced by `NX_ORIGINAL_FORCE_COLOR=0` and `NO_COLOR=1`, as Nx replaces it; the task run on its own gets its dotenv layer from Nx's own `getTaskSpecificEnv` in a process with the nx process's environment, and has its output piped, written to a file or in Nx's pseudo-terminal, laid over the nx process's environment; and the task in a batch gets its dotenv layer from the plugin's, with the batch's own values for Nx's variables that its files define. References written in the generated files follow a strict acyclic topological order (plus the leaf `RUSTFLAGS` self-append), while references that only come into being by substitution (such as through `$$NAME` indirection, dynamic `${...}` assembly or adjacent text joining) are not restricted by that order; on the 2,500 default seeds every generated case terminates in Nx's own loader with zero skips and without keeping a second model of `dotenv-expand` in the test; fixed cases beside the seeded loop compare terminating multi-variable cycles (`A=${B}` with `B=${A}`, `A=${B}` and `B=${A}` with `VALUE=x${A}` under `A=shell`), a cycle with an unsafe branch, `$$NAME` indirection, `PASSWORD=pa$$word` with `VALUE=${PASSWORD}`, `split(null)` (`${NX_FORKED_TASK_EXECUTORnull}`, `${Anull$FORCE_COLOR}`), earlier-escaped `replace` targets (`\$NAMEEXECUTOR $NAME`, `\${A}COLOR ${B}`), top-level unclosed `${` with and without a following matched reference (`${FORCE_${PART}` vs `${UNCLOSED`), top-level `${}`, `\\$FORCE_COLOR`, and `${SET:?error}` across `piped`, `file` and `terminal` runs. For every case the check decides the same in both paths, and for every case it lets through both environments are equal, with zero mismatches. Of the 2,500 default cases, 716 pass the check and 1,784 are refused ([[EVD-DOTENV-STATIC-CHECK]]); the test asserts those exact default-seed counts alongside its thresholds (more than 20 % passing, more than 25 % refused) and requires cases of each kind (root vaults alone and beside plain files, long lists, self-append idioms, `$$NAME` indirection and `FORCE_COLOR=0`).
324
+
325
+ The dotenv layer that the batch builds for a task equals the one that Nx's `getTaskSpecificEnv` builds in a process with the batch process's environment, where that environment has `NX_LOAD_DOT_ENV_FILES` set to `true`, to `false` or not at all, for a task with and without a configuration, and for a task whose target belongs to a target group with an atomized target, for which Nx reads the files of the atomized target and of its non-atomized one instead of the task's own: root values are removed, a changed one is kept, the task's files expand over what is left, and a variable that the batch shields has its shield's value in both. While the batch builds every environment of a task whose files have no vault beside them, its process's environment, an object that records every write, sees none, and no variable of the environment that cargo gets has the shield's value. The source text of Nx's `getTaskSpecificEnv`, `unloadDotEnvFiles` and `loadDotEnvFilesForTask` in the installed Nx equals the text recorded for the three facts that the batch repeats from them; a difference fails with a message that says to re-read them, bring the batch's layer in line and record the new text.
326
+
327
+ A `test` that depends on a plain continuous task, and one that waits for a continuous task with a `port` check, run in the batch and see no `NX_READY_URL`; one that waits for a continuous task whose `readyWhen` is `signal` fails in the batch before cargo runs, with the message of [[DES-DIAGNOSTICS]], and on its own, with `--batch=false`, sees the URL that the server reported. In a `static` run, the batch prints one line for each cargo command that it starts, naming the command, the crates and the step, which no task's stored output holds and no run from the cache shows; with `NX_TUI=true` in its environment it writes cargo's lines as they arrive, without JSON messages, to its own standard error and no such line, and each task's output is the same in either case and without either. The terminal UI's own screen is checked through that test and the runs of [[EVD-NX-24-BATCHES]] ("Terminal output"), not through a captured screen. With an unexpected error in the preparation of one task, the other task of the batch runs and succeeds. A group of two `test` tasks whose cargo prints that one target failed and is then stopped by `SIGTERM` fails both tasks, and so does a list of failed targets that is shorter than its first line announces, malformed or followed by another line, and a JSON step whose messages end without `build-finished`, hold a line cut short or contradict cargo's status. A list of failed targets that a passing test prints, on standard output and on standard error, before cargo's own list changes no task's result.
328
+
329
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
330
+ :::
331
+
332
+ :::mara verification VER-TESTING
333
+ :mid: 01M78FHG7F4RZ7Y316GEAW105Y
334
+ :title: Run tests with either runner and select affected tests safely
335
+ :status: accepted
336
+ :methods: test
337
+ :verifies: REQ-TEST-RUNNER
338
+ :verifies: REQ-DOCTESTS
339
+ :verifies: REQ-AFFECTED-TESTS
340
+ :verifies: REQ-TEST-MODE-KEY
341
+ :verifies: REQ-SELECTION-SAFETY
342
+ :verifies: REQ-BASELINE
343
+
344
+ With the default runner, a crate's `test` task runs `cargo test`; with `testRunner = "nextest"` it runs nextest, and the crate has no additional test target in either case. With nextest, a fixture whose only failing test is a doctest fails its `test` task.
345
+
346
+ With the `test` option, in the `workspace-tests` fixture with the real cargo and Nx and a cargo wrapper that logs invocations: `nx run a:test --test=it` runs `cargo test -p <spec> --test it`, passes, and shows the target's test and no unit test, other test target or doctest, although each of those fails; run again it is restored with no test command, and the following `nx run a:test` without the option runs the crate's tests and fails on its unit test. With `--profile=release` the command adds `--profile release` and passes; `--test=other`, whose test fails, fails the task, and so does `--test=nosuch`, with cargo's error. `nx run-many -t test -p a,b,h --test=it` runs one command per crate and fails only `h`, which has no target `it`, with cargo's error. Under `workspace-build`, `nx run-many -t test -p a,b,h` with `test = "it"` in `a`'s table runs `a`'s command beside the three steps of the whole-workspace group of `b` and `h`; `a` passes, `b`, whose unit test fails, fails, and `h` passes. In `binary-tests`, with `test = "skipped"` in the table of `untested`, whose only test target has `test = false`, `nx build untested` and then `nx run-many -t build,test -p untested --parallel=1` restores `untested:build`, runs `cargo test -p <spec> --test skipped`, and leaves the executable that the build stored. Where cargo-nextest is installed, with the nextest runner, `nx run a:test --test=it --profile=release` runs `cargo nextest run --no-tests=pass -p <spec> --test it --cargo-profile release` and no doctest step and passes, `--test=other` and `--test=nosuch` fail the task; and with `affectedTests`, a baseline and the stand-in for cargo-affected of the affected specs, `nx run a:test --test=it` in mode `affected` prints the line that it runs the named target as in mode `full`, runs that one command, and never starts cargo-affected, and the following `nx run a:test` runs the crate's tests in mode `affected` and fails on its unit test. With Nx's own hasher, the key of `a:test` with `--test=it` differs from its key without the option and from its key with `--test=other`, and the keys of `a:test`, `a:test:it` and `a:test:other` differ where the configurations `it` and `other` in `a`'s table set the option. In-process, without running the planned test commands: the commands that the plugin builds for both runners, that a test task with the option forms a group of one crate under `workspace-build`, `hakari` with the host among its platforms and `cargo` beside crates without the option, and, with a stand-in that answers `cargo nextest --version`, that such a task in mode `affected` does not select while a crate without the option does.
347
+
348
+ `affectedTests` with the `cargo` runner fails graph creation with a message that names both options. In a workspace with `affectedTests`, a run without `NX_RUST_TEST_MODE` is in mode `affected` when no CI variable is set and in mode `full` when `CI` is set; with the variable set to `affected` or `full` it is in that mode in both places, and any other value fails the task. With `affectedTests` off, the variable changes nothing. With nextest, cargo-affected and a baseline, in mode `affected`: a change in one function runs only the tests that cover it, and the output says that a subset ran. A change to `build.rs`, to any source file of a proc-macro crate that has unit tests of its own, to a file that a `fileInputs` pattern names or to a non-Rust file read by a test runs every test of each crate whose `test` inputs hold it and of the crates that depend on them; a declared file outside the workspace folder counts like one inside it, a changed file that is an input of no crate of the group adds nothing, and a change to a toolchain file or `.cargo/config.toml` runs every test of the group. After a change in a library that only a binary calls, the binary's crate runs all its integration tests and a crate that depends on the binary's crate runs all its tests. A baseline collected without a feature that the run enables, one collected with another value of an `envInputs` variable, and one without the plugin's record of its context run the full suite and say which option or variable differs, or that the record is missing. The changed files count against every collection that the report rests on and the working tree: a change committed after an older collection while a newer one equals `HEAD`, both paths of a rename, a deleted file and an untracked file that git does not ignore are each seen, and a changed submodule or a declared input that git ignores runs the full suite. The same fixture in a subfolder of its git repository selects the same tests as at the top. A `default-filter` of the repository that leaves out a selected test keeps it from running, and a selection whose filterset exceeds 128 KiB runs every selected test. Without a usable baseline the full suite runs and the output gives the reason. `--affectedTests=false` runs the full suite, and a crate whose `[package.metadata.nx.targets.test.options]` sets `affectedTests = false` always runs all its tests. `affectedTests = true` there, in a workspace without the `affectedTests` setting, fails graph creation with a message that names the manifest and the option. In the same workspace, `nx test <crate> --affectedTests=true` fails the task with the same message, once as a single task and once in a batch, and a cargo wrapper that logs invocations records no cargo call. A result stored in affected mode is not restored for a run in mode `full` or against another baseline, while a full-mode result is restored for a full-mode run with equal inputs. Results of one nextest run are attributed to the right crates: a failure in one crate leaves the other crates' tasks successful. Through the cargo wrapper, a batched nextest `test` run starts, per group, one `cargo nextest run` and one `cargo test --doc`, plus one `cargo affected status` in affected mode and one `cargo nextest list` after a run in which nextest exited with 100, and none per crate, and each of them receives the same package selection and the same feature flags. A group in which no crate has a library runs no doctest command. With either runner, a failing test or doctest in one crate of a batch fails only that crate's task, also where another package of the group has the same library name: with the packages `good` and `other`, whose library is also named `good`, a failing doctest in `other` fails the task of `other` and the task of `good` succeeds, and the other way round. With `NX_RUST_TEST_MODE=full` in a root `.env.test` and nothing in the shell, a batched `test` run on a developer machine runs the full suite and stores it under the `full` key.
349
+
350
+ Under `workspace-build`, where a runner for the host is configured, `nx run-many -t test -p a,b` starts one cargo command per crate and step, none of them with the plugin's runner, as the cargo wrapper shows, and each task's output names where the runner is set. That holds for every case that the plugin detects: a runner under `[target.<host>]` in the workspace's `.cargo/config.toml`, under `[target.'cfg(unix)']`, under a `cfg` table that does not match the host, only in a file that `include` adds, in the `config.toml` of the Cargo home that `CARGO_HOME` names, and in `CARGO_TARGET_<HOST>_RUNNER` in a root `.env`; and, in a test of the reader, for a configuration file that cannot be parsed. Where cargo applies the runner, a runner that logs its calls logs every test binary and doctest of `a` and `b` and none of another crate: under `[target.<host>]`, under `[target.'cfg(unix)']`, in the Cargo home, in the variable, and in the included file with Cargo 1.100. Under the `cfg` table that does not match the host, and in the included file with Cargo 1.91, cargo does not apply it and it logs nothing, as under plain cargo. A runner only under `[target.<another triple>]` leaves the group in one command with the plugin's runner.
351
+
352
+ With the nextest runner, the repository's nextest configuration applies as for a plain `cargo nextest run`. With `default-filter = "not test(=t::must_run)"` in `[profile.default]` of `.config/nextest.toml` and a failing test `t::must_run`, the crate's `test` task passes, as plain `cargo nextest run` does, and its output shows nextest's line that one test was skipped through `profile.default.default-filter` and that the crate had the other tests run; with `NEXTEST_PROFILE=ci`, where the profile `ci` sets `default-filter = "all()"`, the task fails, as plain nextest does. Changing the filter in `.config/nextest.toml`, and setting `NEXTEST_PROFILE`, each change the task's key. Where the repository's profile sets its own `junit.path`, a run with a failing test fails every task of the group with the message that names the reason, and a run where every test passes succeeds. The command that the cargo wrapper logs holds no `--profile` and no `--ignore-default-filter`. Where nextest ends the run before every test has run, through `global-timeout` with one test thread and `a`'s tests first, or through an interrupt that a test of `a` sends to nextest, `b:test` fails with a message that says that the run was not complete and names `b`'s tests, although none of them failed. With `fail-fast = true`, or `max-fail = 1`, in the repository's profile and a failing test of `a` first, `b`'s tests still run and `b:test` passes. With a setup script that passes for every test, both tasks pass; with one that fails, both fail, and the message names the script.
353
+
354
+ The baseline target, on a workspace with an earlier database, re-collects only affected and new tests; with no database, or with one further behind than the threshold, it collects everything, into an empty database that afterwards holds only the current fingerprint's rows. A collection, full or `--diff`, in which a test fails, so that cargo-affected stores coverage and then exits with a failure status, or which is killed while it runs, leaves no context record, also where an earlier collection had left one; a following run in mode `affected` runs the full suite and says that the record is missing. That holds in particular for a checkout with a baseline and record collected without a feature, whose full collection with the feature then fails: the following run without the feature does not select from that coverage.
355
+
356
+ With the real cargo-affected, the target collects the baseline of `affected-tests` into an empty database, and an affected run then selects the tests of one changed function; the same change runs the full suite, naming what differs, with another value of an environment input that the workspace declares, another output of a declared runtime input, `--features=extra` and `CARGO_BUILD_TARGET` set to the host's triple. After the change is committed, the target re-collects with `--diff` and writes the record again; after a commit that breaks a test, it fails and leaves no record, and the next affected run takes the full suite. With a stand-in for cargo-affected: the record that the target writes equals the one that the plugin's functions compute for the `test` tasks in the same environment; the collection gets git's `diff.relative` and no `CARGO_BUILD_BUILD_DIR` unless `separateBuildDir` is set; the target's `features` reach `status` and `collect`; the choice between `--diff` and a full collection follows recorded reports of every cache status, a failed `status`, a report of another schema and collections beyond and within `fullCollectThreshold`; `fullCollect` collects everything without `status`; `diffOnly` collects nothing where a full collection would be needed and keeps the record; a full collection starts with no database, `-wal`, `-shm` or record, a `--diff` with the database and no record, and nothing else in `target` is removed; a collection stopped with `SIGTERM` leaves no record and no lock; a second collection while the lock is held by a running process fails without calling cargo-affected and leaves the record; and a `test` task whose record changes during its `status` runs its full suite and says why. Where cargo-affected, cargo-nextest or `llvm-cov` and `llvm-profdata` are missing, the target fails before it calls cargo-affected, with a message that names the tool and how to get it. With the stand-in, a record of the last collection that is missing, unreadable, of version 1, different in an option, or holding a runtime input that this collection lacks gives a full collection without `status`, with the reason in the output, and with `diffOnly` nothing collected and the record and database unchanged; an equal record gives `--diff`. With the real cargo-affected, in `affected-tests` with `envInputs = ["REVIEW_MODE"]` and a test `double_works` that asserts the value `a`: after a full collection with `REVIEW_MODE=a`, a collection with `b` runs a full collection, naming the variable, which fails on `double_works`, and an affected run with `b` then runs `double_works` and fails. Two contenders that read the same stale lock, with one taking it over between the other's reading and its takeover, end with exactly one holder, in both orders, and a takeover marker left behind beside a stale lock makes the next contender fail, naming both files, while a marker beside no lock lets the next contender take the lock and stays where it is.
357
+ :::
358
+
359
+ :::mara verification VER-MIXED-PROJECTS
360
+ :mid: 01M7J4QHA8T11C79B8E9J4MZFK
361
+ :title: Merge a crate and a JS package in one folder
362
+ :status: accepted
363
+ :methods: test
364
+ :verifies: REQ-MIXED-PROJECTS
365
+
366
+ In `mixed-folders`, with a root `package.json` and a `pnpm-workspace.yaml` that enrol the folder of the crate `napi-addon`, whose `package.json` names it `@mixed/napi-addon` and which has no `project.json`, and a JS package `web` that depends on `@mixed/napi-addon` with `workspace:*` and whose `build` declares `^build`: the graph has the project `@mixed/napi-addon` with the plugin's targets and an edge from `web` to it, and the task graph of `web:build` holds the crate's cargo `build` and the workspace's lockfile task and no other task of a crate. A change to a source file of `engine`, which the crate depends on, changes the key of `web:build`. With the scripts `build` and `test` in the crate's `package.json`, both targets run the scripts, the crate's other targets keep the plugin's executor, graph creation succeeds without a message, and the task graph of `web:build` holds the script `build` and no task of a crate; with the empty entries keyed by the plugin's executors that `init` writes and `build: { dependsOn: ["^build"] }` under `targetDefaults`, it also holds the cargo `build` of `engine` and the lockfile task, and nothing more. With `nx.includedScripts` set to a list without `build` and `test`, the crate keeps the plugin's `build` and `test`. [[VER-CONFIGURATION]] checks the settings of such a folder, and [[VER-ARTIFACTS]] a JS project that depends on an artifact target.
367
+ :::
368
+
369
+ :::mara verification VER-ARTIFACTS
370
+ :mid: 01M78FHG7FQF8SPHQVG92FZBN7
371
+ :title: Build and cache napi and wasm artifacts
372
+ :status: accepted
373
+ :methods: test
374
+ :verifies: REQ-ARTIFACT-TARGETS
375
+ :verifies: REQ-ARTIFACT-CACHE
376
+
377
+ A fixture crate that produces a wasm package has `wasm-build` and no `napi-build`, a Node addon crate the reverse, and an ordinary crate neither. A `cdylib` crate without a dependency on `napi` or `wasm-bindgen` has neither target. `artifacts = []` in a crate's metadata removes an inferred artifact target, and `artifacts = ["wasm"]` adds `wasm-build` where the rule does not infer it. `wasm-build` produces the `.wasm` file and JS glue for each JS flavour, and the result loads in a browser-like runner. `napi-build` produces a `.node` file with JS and type definitions for the host triple, and Node can load it. For a fixture with two addon crates built in one batch, one of which depends on a library with `#[napi]` items, each crate's `index.d.ts` and `index.js` equal what `napi build --platform` writes for it, so that they hold the dependency's items and not the other addon's. After the crate is built with another feature set that changes its exports, or after plain cargo renamed an export of the library, the next `napi-build` writes them right again. `napi-build` of only the addon whose library has no task of its own still declares the library's items. Where the library's last `#[napi]` item is removed, or its build script does not call `napi_build::setup()`, `napi-build` of the addon fails with a message that names the library, instead of declaring an export the binary lacks or missing one it has. Two addon crates with one `[lib] name` and different binary names both fail before cargo runs, with a message that names both. After `napi-build`, a plain `cargo build` compiles the napi crates and an ordinary crate that depends on the library again, and nothing else. A JS project whose build depends on the artifact target builds it first and is affected by a change to the crate. With the artifact's outputs as a `dependentTasksOutputFiles` input, its key changes where only `RUSTFLAGS` changes, which changes the artifact, while without that input it does not. The generated files are restored from the cache on a second run, and changing them by hand does not change the target's hash. The compile step of an artifact target shares a cargo invocation with other builds of its group. A `wasm-bindgen` CLI whose version differs from the crate's fails with a message that names both versions.
378
+ :::
379
+
380
+ :::mara verification VER-SETUP
381
+ :mid: 01M78FHG7F2C09346B53ZGK2EZ
382
+ :title: Set up, generate and diagnose
383
+ :status: accepted
384
+ :methods: test
385
+ :methods: demonstration
386
+ :verifies: REQ-COMPATIBILITY
387
+ :verifies: REQ-INIT
388
+ :verifies: REQ-CRATE-GENERATORS
389
+ :verifies: REQ-DIAGNOSTICS
390
+
391
+ The end-to-end suite runs on Linux against the oldest supported Nx and Cargo and the latest of each. The same runs on macOS are deferred ([[ADR-CI-LINUX-ONLY]]); until they exist, this verification establishes [[REQ-COMPATIBILITY]] for Linux only. The package's peer dependency range on `nx` names exactly the majors the suite has passed on. With an older Cargo or Nx, the plugin stops with an error that names the version found and the version required. With an Nx major newer than the supported ones, graph creation fails with an error that names the major found and the supported majors, also in a repository without a crate. With `NX_RUST_ALLOW_UNSUPPORTED_NX=true` it succeeds instead and warns, naming the major found and the supported majors and saying that the plugin has not been checked on that major, also while the Nx daemon creates the graph, where setting and then removing the variable between commands to one running daemon turns the error into the warning and back, and a task prints the warning again at its start, with the daemon on and off, where every project's warnings, and so the named input that holds their digest, include it, so that the project's configuration in the key of a task differs between the supported Nx and two versions of a newer major; with an older Nx the variable changes nothing. With a supported Cargo, the version check adds no cargo invocation to the one per workspace that [[VER-GRAPH]] counts; with an older one, the error adds a single `cargo --version`.
392
+
393
+ `nx add` in a fresh workspace with a Cargo workspace installs the package. Its root holds `README.md`, `LICENSE-APACHE`, `LICENSE-MIT` and `PLUGIN.md`, each equal to the repository's file, and a `docs/` folder whose files equal those of `nx-rust/docs/`, with `index.mara.md` among them ([[ADR-BUNDLED-DOCS]]). `init` adds the plugin entry and the empty `targetDefaults` entries keyed by `@convesoft/nx-rust:cargo`, `@convesoft/nx-rust:cargo-outputs`, `@convesoft/nx-rust:run`, `@convesoft/nx-rust:lockfile` and `@convesoft/nx-rust:release-publish` to `nx.json`, says that it added them and why, and changes no other file: no crate, no Cargo manifest and no `.cargo/config.toml`. The schema of `init` declares no options. For each row of the table of tools in [[DES-GENERATORS]], a fixture that meets the row's condition and lacks the tool gets a warning that names the tool, what needs it and how to get it, and a fixture that does not meet it lists the absent tool on the one line marked "not needed by your settings". So a missing cargo-audit is always on that line, and a missing cargo-deny is on it unless a workspace root holds a cargo-deny configuration file. `init` names each workspace whose build directory is inside the repository together with the suggested `build.build-dir` setting, and it prints the fixture's graph-time warnings. Run a second time on a `nx.json` whose plugin entry carries options and that has all five empty entries, `init` leaves `nx.json` exactly as it is and prints its report again. Where the plugin entry is there and one of the empty entries is missing, `init` adds only that entry. Where the plugin entry is there and the empty entries are missing, a manifest that `cargo metadata` rejects stops `init` as it stops a first run, and no file changes. Where `nx.json` extends a file that alone has `targetDefaults`, `nx.json` gets those entries together with the added ones.
394
+
395
+ For each way that graph creation can fail, through a problem in a manifest, a problem between projects, a problem in the options of the plugin's entry, cargo itself, or a check of the configuration that Nx has merged over the inferred targets, such as a `targetDefaults` entry, `init` fails, says that it did not add the plugin, prints what graph creation prints for the same files and changes no file of the repository. What each error of [[DES-DIAGNOSTICS]] says, and what it says the user can do, is checked where that error's own case is. A problem in the options of the plugin's entry is checked on a `nx.json` that registers the plugin with those options, as a second run of `init` finds it, and `init` then says that Nx cannot create the graph with the plugin as `nx.json` registers it. A Cargo older than 1.91 and an installed Nx whose version cannot be read stop `init` with the plugin's message and change no file. An Nx major older or newer than the supported ones stops `init` also in a workspace without a `Cargo.toml`, and after a workspace that pins a toolchain that is not installed has stopped it, no toolchain has been installed. A crate that has the name of a JS project in another folder stops `init` as well, with Nx's error. Through a real `nx add`, beside an entry keyed `build` that sets `cache: true`, `dependsOn: ["^build"]` and `inputs`, `init` adds the empty entries, registers the plugin and reports nothing about the `build` entry, which then reaches the `build` of a JS project and of no crate, and a second `nx add` changes nothing. Through the init generator of the plugin that the first `nx add` installed, run as `nx g @convesoft/nx-rust:init` with the options that `nx add` gives it, which are none: beside entries keyed only by other executors, it adds the empty entries as well; and an entry keyed by `@convesoft/nx-rust:cargo` stays exactly as it is and is judged as before, so one that adds `^build` and keeps the declared dependencies with `"..."` draws the warning while `init` adds the entries for `@convesoft/nx-rust:run` and `@convesoft/nx-rust:lockfile` and registers the plugin. Through a real `nx add` again, an entry keyed by `@convesoft/nx-rust:cargo` that turns on caching stops `init` with `nx.json` unchanged. Beside an entry keyed `build` that turns on caching, a manifest that `cargo metadata` rejects still stops `init` with that error and `nx.json` unchanged. With a newer Nx major and `NX_RUST_ALLOW_UNSUPPORTED_NX=true`, `init` registers the plugin and warns. When the installed Nx lacks one of the internal parts of Nx through which `init` runs those checks, or one of them returns its result in another shape, `init` fails with a message that names the installed Nx version and the supported ones, and changes no file. In a workspace without a `Cargo.toml` and with a supported Nx, `init` registers the plugin, runs no cargo and says how to create a crate.
396
+
397
+ The `library` and `binary` generators create crates that equal the output of `cargo new --vcs none` with the same options, also when only `directory` is given and folders on the way to the crate do not exist yet, and no crate contains a `.git` folder. Their schemas declare `directory`, `name` and `edition` and no other option, and only `directory` is required, as the first positional argument. Run from a subfolder of the repository, a relative `directory` is resolved against that subfolder, as for Nx's own generators. The workspace manifest lists each crate as a member exactly once, whether a glob covers it or not, and gets a `members` list when it had none; where the manifest changes, cargo's output says that cargo added the member. `name` and `edition` reach the manifest, and without `edition` the crate takes the edition that `[workspace.package]` sets, or cargo's default where it sets none. In a workspace with `[workspace.lints]` and further fields of `[workspace.package]`, the crate still equals the output of `cargo new`, which inherits them. A folder that the enclosing workspace's `exclude` matches fails with a message that names the manifest and the entry, nothing is created and `cargo new` does not run. Where a workspace lies in the folder of another, the nearer one encloses the crate: an `exclude` entry of the outer one that matches the folder stops nothing, and the crate joins the inner workspace only. Outside every workspace the crate is standalone, and the output says that it has its own `Cargo.lock` and build directory. With `--dry-run`, the output names the cargo command, Nx lists no change to its file tree and no file changes. Into a folder that exists already, the generator fails with cargo's message and changes nothing.
398
+
399
+ Each message that this verification names also says what the user can do, and no diagnostic carries an error code. For each tool the plugin can need, removing it from `PATH` and running a task that needs it fails with a message that names the tool, the feature that needs it and a way to get it; nothing is installed. A target in a crate folder's `project.json` that names `@convesoft/nx-rust:cargo` and that the plugin did not infer fails its task before cargo runs, with a message that names the task and says to run another cargo command through a target with a `command`. In a workspace with `affectedTests`, a `test` run in mode `full` without cargo-affected succeeds and warns that the tool is missing. Contradictory options fail when the graph is created, with a message that names the options and the manifest. With cargo removed from `PATH`, and with a manifest that cargo rejects, graph creation fails with a message that names the manifest and carries cargo's error, and no project of any workspace is left out instead. A workspace that pins a toolchain that is not installed fails graph creation with a message that names the toolchain and the workspace. So does a workspace whose root folder pins one where the plugin receives its members but not its root manifest, also when the folder of the first member manifest read pins an installed toolchain; the message names the root folder as the one where `cargo metadata` has to succeed. No toolchain gets installed, and the cargo commands that tasks run get no `RUSTUP_AUTO_INSTALL` setting from the plugin. In a workspace whose root manifest the plugin receives and whose root folder pins no toolchain, while one member and one path dependency without a project each pin a toolchain that is not installed in their own folder, the graph is created and no toolchain gets installed. Through a cargo wrapper that logs invocations, every cargo call of graph creation in that fixture starts in the workspace's root folder and has `RUSTUP_AUTO_INSTALL=0`, also when the environment of `nx` lacks the variable.
400
+
401
+ A path dependency on a crate whose files Nx cannot see, such as one under a git-ignored path, produces a warning that names the crate and the dependency. A build directory inside the repository that Nx does not ignore, by any of its rules, produces a warning that names the directory and advises adding it to `.gitignore`, and so does such an artifact directory. Such a directory is judged by the folder that its path reaches: one that a symbolic link inside the repository leads outside draws no warning, one spelled outside the repository that a link leads inside draws it, and one that a link leads to another folder inside the repository is judged by that folder's ignore rules, not by those of the path as text, and its warning names that folder, adds the reported path in brackets and advises the line for that folder. `init` lists such a build directory by the folder that it reaches as well. In that fixture, neither `.gitignore` nor `.nxignore` covers the directory, and it lies under no folder that Nx always ignores. The same directory produces no warning when only `.gitignore` or only `.nxignore` excludes it, nor when it lies under a folder that Nx always ignores, such as `.nx/cache` or `node_modules`, while neither ignore file covers it ([[EVD-NX-24-SETUP]]). In a git repository, it still produces the warning when only `.git/info/exclude` or only the user's global git excludes file covers it, although Nx then leaves the directory out on that machine. Two workspaces whose `cargo metadata` reports name the same artifact directory produce a warning that names the directory and both workspaces and says that their `doc` targets are not cached. Two whose artifact directories lie one inside the other produce one that also says that a first build, while these directories do not exist yet, can fail in cargo with "No such file or directory", and to run the command again, also where both lie outside the repository, where the warning names the other directory; the warning for the same directory, inside the repository or outside it, does not say so. Each of these warnings, and the warning for an artifact directory outside the repository, appears when the graph is created with `NX_DAEMON=false`, appears in the output of a task of the crate or workspace concerned with the daemon on, whose graph has it, and is printed by `init`. The warnings about an included file that is no valid TOML and a redirected crate that `cargo metadata` fails for reach every project of the workspaces they concern and no other. A rustfmt configuration file in the home folder or in `rustfmt` of `XDG_CONFIG_HOME`, in a repository that holds none, produces a warning that names the file when the graph is created and at the start of the `fmt-check` and `fmt` tasks of the crates and of no other task, none once a `rustfmt.toml` lies at the repository root, and changes no key. A crate whose folder holds a `rustfmt.toml` while `[lib] path` places its library beside none gets the warning, and a crate covered from every target's file does not. A per-user file that `XDG_CONFIG_HOME` places in one crate's folder gets the warning for the other crates, saying that their keys do not hold it, and none for that crate. The warning about Cargo configuration that Nx does not hash appears in the output of every task of the projects of each workspace it concerns and of no other, also in that of `nx run plain:build` with the daemon on and the default output style, with `CI` false and true, when the task runs and when the cache restores it. In locked mode, a stale or missing `Cargo.lock` fails the lockfile task with cargo's message, which names the file, and no crate task of that workspace runs. A workspace whose root manifest Nx hands to no entry of the plugin produces a warning that names the root manifest, at graph creation and at the start of its crates' tasks; their `build`, `check`, `lint` and `test` are uncached, keep `Cargo.lock` as an input and run.
402
+
403
+ The warnings reach the keys of a project's tasks as [[DES-DIAGNOSTICS]] says under "Warnings where they are seen". In `two-workspaces` and `subfolder-workspace`, which have no warnings, no project has a named input besides `default`. In `cross-workspace-path`, with `model` no member of its workspace and left out of the plugin, only `server` warns, and only `server` has the named input, whose entry holds the digest of the warnings in its metadata. The digest writes the paths inside the repository relative to its root and keeps those outside, also where an outside folder only begins or ends like the root, and depends on neither the order of the warnings nor their repetition. Two checkouts of one repository in different folders get the same key for every task through Nx's own hasher, without warnings, with that warning of `server`, whose text names files of each checkout by their absolute paths, with a `CARGO_TARGET_DIR` outside both, which the warning names, and with a Cargo directory reached through a link inside the repository, whose warning names in brackets the path that cargo reports, absolute and inside each checkout. In `subfolder-workspace`, the warning about Cargo's directory in `cache/cargo`, which Nx does not ignore, changes the keys of every cached target of `api` and of `rust:doc` against the same directory that `cache/.gitignore` leaves out, through the projects' configuration alone. In `patched-workspaces`, a `.gitignore` without `target/` changes the keys of `fmt-check` of `api` and `model` through their projects' configuration. A `[patch]` of `model` in the Cargo home's `config.toml` changes the key of `api:check`, whose crate may use `model`, and leaves those of `plain:check`, `plain:fmt-check`, `types:fmt-check` and `rust:lockfile` unchanged: its warning reaches no key. Two checkouts of `patched-workspaces`, one with a private Cargo home whose `config.toml` sets `[build]` and one with an empty one, get the same key for every task, while the first warns. In `cross-workspace-path`, where `server` depends on a crate without a project in the folder of a crate `p`, a missing folder named in `p`'s `package.workspace`, which makes cargo refuse the report of `server`'s dependency, changes the keys of `server:fmt-check` and `server:build` through `server`'s configuration alone. With the real Nx, and without the daemon, for the `.gitignore` without `target/`: after `api:fmt-check` was cached without the warning, adding the cause makes the task run and print the warning, a second run restores it with the warning, and removing the cause restores the first result without it; after `nx reset`, a task cached with the warning runs again without it once the cause is removed, and a second run restores that. So it is for `server:fmt-check` with the missing folder in `p`'s `package.workspace`. With an ignored `rust/.cargo/config.toml` whose `[env]` sets a value that `plain` reads, the lockfile task and `plain:build` print the warning about that file, its remedy and that not ignoring the file makes Nx hash it, in every run of `plain:build`, also when the cache restores it. After the value changes, `plain:build` is restored from the cache; a run with `--skip-nx-cache` runs it, the next run without the flag restores it again, and after `nx reset` it runs. An ignored `.cargo/config.toml` that sets only `[alias]` and a Cargo home whose `config.toml` sets only `[net]` give no warning, and one whose `config.toml` sets `[build]` gives the warning, which names the file, says that it lies outside the repository and gives the remedy, from graph creation and from `api:fmt-check`. None of the three changes a key.
404
+ :::
405
+
406
+ :::mara verification VER-RELEASE
407
+ :mid: 01M7DBRA91BFN6ZT26YC6HPMGD
408
+ :title: Version and publish crates through Nx release against a local registry
409
+ :status: accepted
410
+ :methods: test
411
+ :verifies: REQ-RELEASE
412
+
413
+ End-to-end, with the real Nx and the real cargo, on cargo 1.91 and the latest stable, in fixture repositories whose crates are configured for Nx release in `nx.json` and whose history holds the commits that the run versions. A local sparse registry with a publish endpoint, started by the test harness, stands in for crates.io: a private Cargo home replaces crates.io with it through `[source.crates-io] replace-with`, names it in `registry.default` and makes it the HTTP proxy, which refuses every other host, because `cargo publish --registry crates-io` does not follow the replacement. Environment variables pin the proxy, the registry and its token against configuration files above the working folder, and cargo fetches git repositories only through the git command line restricted to local files, because git and SSH transports go around an HTTP proxy ([[EVD-CARGO-PUBLISH]]). It can delay when its index shows an upload. A cargo wrapper logs every cargo call, and no test reaches a real registry. Unless a case says otherwise, each dependency entry on a crate of the repository names the harness's registry with `registry`, as **Where a dependency points** in [[DES-RELEASE]] requires, and the variable `CARGO_REGISTRY_DEFAULT` that the harness pins chooses the target registry, so that the executor runs no probe (**Target registry**); only group 9 has cases that leave it unset. Unless a case says otherwise, the fixture's `nx.json` sets `release.version.git` to `{ "commit": true, "tag": true }`, so that `nx release version` commits and tags; a case that runs `nx release` sets `release.git` instead, which `nx release version` refuses ([[EVD-NX-24-VERSION-ACTIONS]]). Groups 1 to 5 use the fixture `release-crates`, whose entries name no registry and whose lockfiles lock path packages only. The cases of groups 1 to 3 and 5 start no registry: they give each copy an empty Cargo home of its own and set `CARGO_NET_OFFLINE=true`, so that the lockfile step reaches no registry. Group 4 gives copies of it registry dependencies, locked against a harness registry that the case finds empty: the server that the spec file's cases share, emptied before each case, or a new one after a case that stopped it. Every command runs with that registry's variables. Cargo refuses a manifest whose `registry` key no configuration names, so a fixture whose entries name the harness's registry, as those of groups 6 to 9 do, runs every cargo command with the harness's Cargo home, graph creation included, and `release-crates` would need that home too if its entries took the key; the version actions match a dependency by its path and leave its `registry` key as it is.
414
+
415
+ 1. **Bumps.** `nx release version` with a given specifier writes a crate's own version into its `[package]` table and an inherited one once into `[workspace.package]`, for crates that inherit it in one fixed group. A configuration that puts crates inheriting one version into different groups, and a run that would version only some of them, fail before any file changes, with a message that names the crates. The current version is read from the manifest, also an inherited one, and with `git-tag` from the tag. A crate without a `version` in the release fails with a message that names its manifest.
416
+ 2. **Dependents.** Every edge of the fixture's graph is `implicit`. A crate that depends on a bumped crate through a normal dependency with a version requirement, through a build dependency with one, through a renamed, optional or target-specific one, and from another Cargo workspace, gets a patch bump. No crate gets one through a dev-dependency, through a dependency without a version requirement, through the edges that `[patch]` gives every member with a registry dependency, through a crate without a project between it and the bumped crate, or as the workspace project. A dependency with the requirement `*` in a target table whose header spells the platform with spaces, as `cfg( unix )`, still makes a dependent. With release groups that take their bumps from version plans: a fixed group without a bump of its own whose crate has a dev-dependency on a crate of a group bumped before it is bumped, and the output names the group, the edge and that it is a dev-dependency; a crate of an independent group whose requirement on a crate of a fixed group the run would rewrite without a bump stops the run before any file changes, with a message that names the crate and its group, and with a version plan of its own the same run succeeds.
417
+ 3. **Requirements.** Requirements on a bumped crate are rewritten in member tables, `[target.*]` tables, renamed and optional entries, `[workspace.dependencies]`, a member of another workspace, a crate outside the release and a crate with `publish = false`, each as the table of [[DES-RELEASE]] says for its operator. A bare, `^`, `~` or `=` requirement that the new version satisfies is kept, and rewritten with `preserveMatchingDependencyRanges: false`. A comparison requirement such as `>=0.1, <0.2` and a wildcard such as `0.1.*` that the new version 0.1.4 satisfies are kept unchanged, also with `preserveMatchingDependencyRanges: false`, and the output names each with its manifest. The same requirements with the new version 0.2.0 fail before any file changes, with a message that names the manifest. Apart from the version strings, each manifest is unchanged byte for byte, comments and layout included, and cargo resolves every workspace afterwards. A `[patch]` entry in the root manifest, and one in a `.cargo/config.toml` inside the repository, that name the bumped crate by path with a version requirement are rewritten as that table says, and cargo resolves every workspace afterwards; one that the new version leaves, of a form that is not rewritten, fails before any file changes, and so does one in a Cargo configuration outside the repository that would have to change, naming its file. A `[replace]` entry whose path names the bumped crate, a registry requirement that a `[patch]` redirects to it and that the new version leaves, and a profile's package table that names it with a version that the new version leaves fail before any file changes, each with a message that names it. The redirected registry requirement fails in the same way whether the `[patch]` key is the registry's name from the workspace's `[registries]`, its `sparse+` index URL or, for a git dependency, the repository's URL, and the profile's specification does whether it names the crate as `file://` or `path+file://` with its folder. A manifest that the run would change and that cannot be written fails the run before any file changes, naming the manifest, and so does a `.cargo/config.toml` or a member's folder that a symbolic link leads outside the repository, naming the file and where it leads, while the file outside stays unchanged. Where a member's `Cargo.toml` and a `.cargo/config.toml` are symbolic links to files elsewhere in the repository, the files they lead to change in their version strings only and are in Nx's commit, the links stay as they were, and the tree is clean afterwards.
418
+ 4. **Lockfile.** In copies of `release-crates` that a case gives registry dependencies, with lockfiles generated against a harness registry that the case finds empty and every command run with its variables. In the `Cargo.lock` of each workspace whose manifests changed, no locked package other than the bumped members changes its version or source, and the references that name a bumped member change with it, also in a lockfile that locks a member and a registry crate of the same name. A registry dependency locked at an older version stays although a newer one is in the registry; `cargo update --workspace --locked` passes afterwards; and the lockfile and the manifests are part of Nx's release commit. A workspace whose manifests did not change keeps its lockfile untouched, and the cargo wrapper logs no `cargo update` there, unless its lockfile locks a bumped crate by path, as where its member depends on it by path without a version requirement: then its lockfile is updated and committed while its manifests stay as they are. A workspace without a `Cargo.lock` gets none. With the `locked` option or `NX_RUST_LOCKED=true` the update still runs, without `--locked`. With the registry stopped and an empty Cargo home, and with `CARGO_NET_OFFLINE=true` and an empty Cargo home, where only the second of two workspaces asks the registry, the release fails with a message that names that workspace and carries cargo's, the first lockfile is updated, the manifests are written and nothing is staged, Nx makes no commit or tag, and `git checkout --` with the files that the message lists gives a clean tree. Without git settings, `nx release version` leaves the manifests and the lockfile staged and uncommitted. A lockfile that git ignores is updated and not committed. A lockfile that a symbolic link leads outside the repository fails the run before any file changes, naming it. A lockfile that a link leads elsewhere in the repository: the file it leads to is updated and in Nx's commit, `cargo update --workspace --locked` passes, the link stays, and the tree is clean. A lockfile without read permission, and one with the markers of a merge conflict, fail the run before any file changes, with a message that names it, and the wrapper logs no `cargo update`. With a workspace folder whose name holds a space, a member's `Cargo.toml` linked to a file elsewhere in the repository and a lockfile that git does not track, the commands of the failure message run in `sh` as printed: going on updates that workspace's lockfile, after which `cargo update --workspace --locked` passes there, and going back takes back every file that Nx wrote, the file that the link leads to included, while the message names the untracked lockfile to take back by hand.
419
+ 5. **Version dry run.** `nx release version --dry-run` changes no file, and the wrapper logs no `cargo update`.
420
+ 6. **Publish dry run.** After a version run that bumped a crate and its dependent in one workspace, `nx release publish --dry-run` succeeds for both, although neither new version is in the registry. The wrapper logs one `cargo publish --dry-run --locked --registry nx-rust-test` per workspace and no probe, and the registry receives no upload. Where the dependent lies in another Cargo workspace, and where it lies in another release group than the crate it depends on, both crates having versions of their own, the dependent's task succeeds without a `cargo publish` that verifies it and says that it was not verified, naming the dependency, its version and `<project>:nx-release-publish` of the dependency, while the dependency is verified. Manifests, lockfiles and every other tracked file outside the build directory are byte for byte unchanged after a dry run, and after a run that fails: with a bump committed beside a stale `Cargo.lock`, publishing, dry or real, fails each task of the workspace before any upload, with cargo's message and the line that points to `nx release version`. Where a crate's `.env.nx-release-publish` gives `CARGO_REGISTRY_DEFAULT` a value built from `NX_TASK_TARGET_CONFIGURATION`, with nothing else choosing a registry, the crate's task fails with a batch and with `NX_BATCH_MODE=false`, with the message of the dotenv check that names the file, the variable it expands and the variable it looks up, no diagnostic shows the expanded value, and the wrapper logs no cargo call besides those of graph creation and the version actions' report of each Cargo workspace; where the file's value refers only to a variable whose value does not depend on how the task runs, the dry run verifies the crate in both ways, against the registry that the file names ([[DES-RELEASE]], "Dotenv files"). Where that crate depends on another crate of the repository and the batch also holds a crate that it does not depend on and a crate in another Cargo workspace that depends on it, the batch verifies the unrelated crate with a call of its own, fails the dependent before its call with a message that names the failed task, and does not stop the run; without a batch, the task of the unrelated crate stops with the message that names the crate whose environment it cannot rebuild.
421
+ 7. **Publishing.** `nx release publish` uploads the crates in dependency order, with one `cargo publish --registry nx-rust-test` per workspace, a workspace after the one whose crate its crates depend on. With `a` 0.1.0 in the registry, `a` bumped to 0.1.1 and its dependent `b` keeping the requirement `0.1.0`, publishing `b` while `a` 0.1.1 is not in the registry, with `--projects` naming `b` only, with `--groups` naming only `b`'s release group where `a` is in another, and with `NX_BATCH_MODE=false`, fails `b`'s task before any upload, with a message that names `a`, 0.1.1 and `b` and says to publish `a` first; the registry receives no upload, and after `a` 0.1.1 is published, publishing `b` succeeds. With `NX_BATCH_MODE=false` and both selected, a second run publishes whatever the first left out. Crates with `publish = false` have no `nx-release-publish` and are not uploaded. A version that the registry already has is left out with a message that names it, and after a run that published only part of the crates, a second run publishes the rest. Each task's result follows what cargo's output shows for its crate: where a dry-run call fails on a dependent's compile error after cargo verified its dependency, the dependency's task succeeds and only the dependent's fails, and where a real call fails after its first upload, the uploaded crate's task succeeds, the others fail, and a second run leaves out the uploaded version and uploads the rest. With an index that shows an upload only after more than 60 seconds, no crate that depends on the delayed one is uploaded and its task fails. No cargo call carries a token or `--allow-dirty`. Whether an uncommitted change stops publishing is cargo's own check, which the plugin leaves alone and to which it adds none, so the case records what cargo does in the fixture, whose Cargo workspaces lie in subfolders of the git repository, not a promise of the plugin: with the latest stable cargo, an uncommitted change fails the task with cargo's message and the line that says to commit the new versions first, also after `nx release version` without git settings, which leaves its changes staged and uncommitted; with Cargo 1.91.0, the same changes are uploaded to the harness registry ([[EVD-CARGO-PUBLISH]], [[RISK-UNCOMMITTED-PUBLISH]]). `--tag`, `--access` and `--otp` are each ignored with a line, and `--first-release` changes nothing; `--registry` is in group 9. With `NX_BATCH_MODE=false`, each task publishes its own crate with one `cargo publish`. An unreachable registry fails the tasks with cargo's message before any upload. Each crate's `nx-release-publish` has no `dependsOn` and is not cached, and `targetNames` with the key `nx-release-publish` fails graph creation with a message that says that Nx release runs the target only under that name.
422
+ 8. **Unpublished dependencies.** A crate that depends with a version requirement on a crate of the repository with `publish = false`, and one that depends on a crate whose `publish` list leaves out the fixture's registry, fail before cargo uploads anything, and the wrapper logs no `cargo publish` for them, with a message that names both crates; this holds also where the registry has an unrelated crate of the dependency's name and version, and the registry receives no upload. The same holds with a batch, without one and in a dry run, and a crate of the same cargo call that depends on such a crate is left out with it, while the rest of the call is uploaded. In a workspace with a cargo-hakari configuration, the hack crate has no `nx-release-publish`, also without `publish = false`, under a `featureUnification` that chooses another strategy and with the configuration in `.guppy/hakari.toml`, while a crate that no configuration names keeps it. Where it has `publish = false`, publishing a crate that depends on it fails in the same way, and the message also gives cargo-hakari's two ways; a case lets the real cargo-hakari write the hack crate and the members' dependencies and skips, saying why, where cargo-hakari is not installed. Where the hack crate has no `publish = false`, its dependents fail, saying to publish the stub, until it is in the registry as a stub, and then publish.
423
+ 9. **Registries.** Beside its own registry, the harness serves two more, named `alpha` and `beta` in the Cargo home, each with an index, a publish endpoint and a log of uploads that records the registry each upload gives each dependency ([[EVD-CARGO-PUBLISH-REGISTRIES]]), and a third in the same way that nothing names, for a case that configures a name of its own for an index: cargo refuses an upload where two names configure one index. Where a case sets `CARGO_REGISTRY_DEFAULT`, the environment chooses the target: the wrapper logs no probe and every `cargo publish` and `cargo info` with `--registry <name>`. Where a case leaves it unset, the wrapper logs one probe, `cargo publish --dry-run --no-verify --locked -p <crate>` without `--registry`, per workspace and distinct `publish` value, and every other `cargo publish` and `cargo info` with `--registry <name>`. With `CARGO_REGISTRY_DEFAULT=alpha`, `nx release publish` uploads every crate of a fixture whose dependency entries name `alpha` to `alpha`, and a crate of it with `publish = ["beta"]` fails before any upload with a message that names its list and `alpha`, while the others publish. With the variable unset, in a Cargo home that replaces crates.io and sets no default, a workspace with two crates with `publish = ["alpha"]`, one depending on the other through an entry that names `alpha`, and one crate with `["beta"]` publishes with two calls, the first two to `alpha`, the dependency first, and the third to `beta`, and the dry run of the same succeeds; a crate without a `publish` list in that workspace fails before any upload with cargo's message that crates.io is replaced and the guidance to publish from a job whose configuration does not replace crates.io, and the others publish. With `registry.default = "beta"` in the fixture's `.cargo/config.toml` instead, a crate without a list goes to `beta`, and the crate with `["alpha"]` fails before any upload with cargo's message that `beta` is not listed. With files that the fixture tracks under `target/package`, named like the packaged crate, and with `build.build-dir` set to a folder of tracked files, the probe leaves every tracked file unchanged, and its folder is gone afterwards. A crate published to `alpha` whose dependency on a crate of the repository, published to `alpha` by the same call, has no `registry` key fails before any upload with a message that names the dependency, its manifest, `alpha`, crates.io and the key to add, also where the Cargo configuration puts `alpha` in place of crates.io, the dependency's task fails with a message that says that nothing of the run is uploaded, and the registry receives no upload at all; with `registry = "alpha"` in the entry both publish, the dependency first, and the log shows the dependency in the same registry. A crate published to `beta` whose dependency's entry names `alpha` publishes after its dependency, and the log shows `alpha`'s index for it. With `CARGO_REGISTRIES_ALPHA_TOKEN` unset and only `CARGO_REGISTRY_TOKEN` set, publishing to `alpha` fails with cargo's message that names `CARGO_REGISTRIES_ALPHA_TOKEN`. `nx release publish --registry https://npm.example.com/`, also with `--dry-run`, fails each crate's task before cargo runs, the wrapper logs no `cargo` call for those tasks and the registries receive no upload, with a message that names the option, the value, that it was passed to `nx release publish`, the three settings of Cargo, the `registry` key for dependencies and how to give npm packages alone a registry. A `registry` in a `targetDefaults` entry keyed by `nx-release-publish` fails each crate's task in the same way, with the message that names the workspace's configuration, `nx show target` and the empty entry keyed by `@convesoft/nx-rust:release-publish`; with that entry in `nx.json`, the crates publish. With `alpha` replaced by `beta` in the Cargo home, through a `[source]` table with `alpha`'s index and `replace-with = "beta"`, and a dependency's new version in `beta` only, a crate published to `alpha` that depends on it fails before any upload, with a message that says that the lookup asked `beta`, and the registries receive no upload. With a second name, `alias`, given `alpha`'s index in the environment, cargo shows `alpha` in every line of the probe and the lookups in the harness ([[EVD-CARGO-PUBLISH-REGISTRIES]], fourth session), and a crate with `publish = ["alpha"]` fails before any upload with cargo's message that two registries are configured with one index. That a lookup that shows another name than the one passed fails the crate, as where cargo showed `alias` for `alpha` and `alpha-src` for a replaced `alpha`, that a probe's line selects the entry that it names from a `publish` list of several entries, and that a line that names none of them fails the crate, is checked with those lines of cargo's. With `shared` configured with the index of the harness's third registry in one workspace and with `beta`'s in another, a crate of the second whose entry names `shared` for its dependency in the first fails before any upload, also where `beta` has a copy of the dependency's version, with a message that says that the two could not be established as one registry and to give the index in the environment or keep both crates in one workspace, and nothing of the run is uploaded, also not the crates of the first workspace, whose call would come first; with `CARGO_REGISTRIES_SHARED_INDEX` set to the first index, both publish there, the dependency first. With `registry.default = "alpha"` in the configuration of `rust/` and `CARGO_REGISTRY_DEFAULT` unset, where a `.env` in the dependency's folder sets `CARGO_REGISTRY_DEFAULT=beta` and its dependent's entry names `alpha`, which holds another copy of the dependency's version, `nx release publish` of both, with a batch and with `NX_BATCH_MODE=false`, fails both tasks, the wrapper logs no `cargo publish` and no registry receives an upload; with a batch, the dependent's message names both crates, `alpha`, `beta`, `CARGO_REGISTRY_DEFAULT` in the environment of the dependency's task and the `.env` file, and without one, both messages say that the other task's environment cannot be rebuilt and name the setting and the file. Where the dependent's entry names `beta` instead, a batch publishes the dependency to `beta` first and the dependent to `alpha`, whose upload gives `beta`'s index for the dependency, while without a batch the same release fails before any upload; and without the `.env`, both crates go to `alpha`, with a batch and without one. Where the dependency's `nx-release-publish` has the configuration `production` as its `defaultConfiguration` and `.env.production` in its folder sets `CARGO_REGISTRY_DEFAULT=beta`, with the dependent's entry naming `alpha`, which holds another copy, publishing the two in two release groups and in two commands of one crate each, with a batch and without one, uploads the dependency to `beta` and nothing to `alpha`, and the dependent's message names the dependency's task and the two configurations that differ, `production` and none, the setting and the file; a dependency whose other configuration `staging` alone sets `beta` refuses its dependent in the same way, naming `staging`; and where the dependent's entry names `beta`, one batch publishes the dependency to `beta` and the dependent to `alpha`, and two commands publish both to `beta` where every configuration of the dependency's target, and none, and the dependent's dotenv file set `beta`. With `CARGO_NET_OFFLINE=true` in place of the harness's `false`, after a run that filled the Cargo home's cache, every task fails before any upload, with a message that says that the lookups did not show which registry they asked and that publishing needs Cargo online, and the wrapper logs no `cargo publish`. Under `CARGO_REGISTRY_DEFAULT=crates-io`, in the harness's Cargo home, which replaces crates.io, every crate fails before any upload, because the lookup on crates.io shows the replacement, with the message to publish from a job whose configuration does not replace crates.io. No case publishes to crates.io. No test passes `--registry crates-io` to cargo, and no cargo call that the wrapper logs carries it, because under a replacement of crates.io `cargo publish --registry crates-io` goes to crates.io itself.
424
+
425
+ Each message of [[DES-DIAGNOSTICS]] that this verification names also says what the user can do.
426
+ :::
427
+
428
+ ## Outcome checks
429
+
430
+ :::mara validation VAL-MIXED-REPO
431
+ :mid: 01M78FHG7FNP9RYQ1PNN0KTGR3
432
+ :title: Run a real mixed repository through one set of commands
433
+ :status: accepted
434
+ :methods: demonstration
435
+ :validates: GOAL-ONE-MONOREPO
436
+ :validates: GOAL-FAST-FEEDBACK
437
+ :exercises: SCN-ADOPT
438
+ :exercises: SCN-MIXED-CHANGE
439
+
440
+ Adopt the plugin in a real Nx monorepo that has JS/TS projects and at least one Cargo workspace with a crate consumed from JS. Its pipeline uses the same `nx affected` command for both languages and contains no Rust-specific step other than tool installation and the build directory cache. Over at least twenty pull requests, compare with the previous setup: Rust tasks ran only for pull requests that could affect them, the wall-clock time of the Rust part of a typical pull request is no worse than a tuned plain cargo pipeline with a warm build directory, and no pull request needed manual help to get the right tasks to run. Record shortfalls as issues or as changes to this knowledge.
441
+ :::
442
+
443
+ :::mara validation VAL-CARGO-PARITY
444
+ :mid: 01M78FHG7FAY110WZM8PBA7NSX
445
+ :title: Rust developers work as before
446
+ :status: accepted
447
+ :methods: demonstration
448
+ :methods: inspection
449
+ :validates: GOAL-CARGO-NATIVE
450
+ :exercises: SCN-ADOPT
451
+
452
+ In the repository of [[VAL-MIXED-REPO]], developers who work only on Rust continue to use plain `cargo` and rust-analyzer. After adoption there is no `project.json` or generated file in any crate and no setting that exists only for Nx outside the `nx` metadata tables and `nx.json`. Switching between `nx` and `cargo` commands on the same crate triggers no rebuild of unchanged code, and rust-analyzer's check on save does not invalidate the Nx-driven build. Ask those developers whether anything about their workflow changed; record what did.
453
+ :::
454
+
455
+ :::mara validation VAL-CACHE-TRUST
456
+ :mid: 01M78FHG7FYW60Y8SGM0JTPGBF
457
+ :title: Cached results match uncached runs
458
+ :status: accepted
459
+ :methods: test
460
+ :methods: analysis
461
+ :validates: GOAL-TRUSTED-CACHE
462
+ :exercises: SCN-AFFECTED-TESTS-PR
463
+
464
+ In the repository of [[VAL-MIXED-REPO]], run a scheduled job that executes every cached Rust target with the cache disabled on the current main commit and compares each result with what the cache would have restored. Over at least thirty days, no task that the cache reports as successful fails when it really runs, apart from tests already known to be flaky. Each mismatch is analysed down to the input that the key missed, and recorded as an issue and, where it shows a gap in [[DES-INPUTS]], as a change to this knowledge.
465
+ :::