fix: Scope root JavaScript dependencies to JavaScript and root tasks (#15053)
## Why
In a repository with both JavaScript and Cargo packages, a change to a
package that the root `package.json` depends on missed cache for every
Rust task, even with explicit `inputs`. Bumping a root `devDependency`
did the same thing. Root dependencies are JavaScript dependencies, so
only JavaScript tasks and root tasks consume them.
## What changed
- The run computes two global hashes. Each task picks one from its
package's toolchain.
```diff
TaskHashable
- global_hash: self.global_hash
+ global_hash: self.global_hashes.for_task(package_context)
+ JavaScript, root, or unknown toolchain: today's hash
+ Rust, Python, or Go: the same hash without the root dependency hashes
```
- `RootDependencyInputs::for_namespace` is the one place that makes this
decision. The change mapper, the relationship projections, task-level
affected detection, and `turbo query affectedTasks` all read it, so
`--affected` selects the same tasks that hashing invalidates.
- A new `PackageInclusionReason::RootInternalDepChanged` maps to the
existing GraphQL type, so the schema doesn't change.
## Scope
- This covers root internal dependencies and root external dependencies.
`engines`, `globalDependencies`, and `globalEnv` still apply to every
task.
- JavaScript-only repositories take the same code path as before.
## Blast radius
JavaScript and root task hashes are byte-identical. Rust, Python, and Go
task hashes change once on upgrade. `--filter=...<root dependency>`,
`turbo query` dependents, and `boundaries` no longer count Cargo crates
as dependents of root JavaScript packages, which keeps the package graph
consistent with the projections.
## Verification
- In a pnpm and Cargo repository, `turbo run build --dry=json` gave
`app#build` the hash `a6c679637d3a9982`. After a root dependency edit,
it gave `c97e95a72589b89c`. With this change, it stays
`41242c1b88114c45` across the same edit, and both JavaScript task hashes
change.
- The new tests in `cargo_workspace_test.rs` fail against the parent
commit and pass on this branch. `final_hash_contract` and the `dry_json`
snapshots pass with no snapshot changes.
- Not tested: watch mode now receives a partial package list instead of
all packages for a root dependency edit in mixed repositories.