fix: Keep default inputs when extending a task without inputs (#14902)
### Description
`$TURBO_EXTENDS$` is documented to **append** to the inherited value.
For `inputs`, that broke when the inherited task omits `inputs` (or sets
`"inputs": []`), which means "every file in the package checked into
source control":
```jsonc
// turbo.json
{ "tasks": { "build": {} } }
// apps/web/turbo.json
{ "extends": ["//"], "tasks": { "build": { "inputs": ["$TURBO_EXTENDS$", "../shared/**"] } } }
```
| Resolved `apps/web#build` inputs | before | after |
| --- | --- | --- |
| root `build` omits `inputs` | only `../shared/**` | package files +
`../shared/**` |
| root `build` has `"inputs": []` | only `../shared/**` | package files
+ `../shared/**` |
| child is `["$TURBO_EXTENDS$", { "mode": "jit", … }]` | no files hashed
at startup (`eager: false`) | package files at startup + JIT globs |
| root `build` has `["src/**"]` | `src/**` + `lib/**` | unchanged |
| child omits `$TURBO_EXTENDS$` | replaces | unchanged |
Before the fix, edits to the package's own sources (e.g. `src/`) did not
change the task hash, so they produced **false cache hits** that
restored stale outputs.
**Root cause:** in `ProcessedTaskDefinition::merge`, a missing parent
`inputs` copied the child's value as-is, and `ProcessedInputs::extend`
only kept `default` if the parent had `default: true` (set only by an
explicit `$TURBO_DEFAULT$`). An omitted or empty parent hashes
everything implicitly (empty globs → full package hash), but that
meaning was lost once the child's globs were appended.
**Fix:** when a child extends inputs, treat an omitted parent as empty
inputs, and set `default` if the parent includes the package's default
files (`default`, or no startup/JIT globs). Parents with explicit globs
or JIT-only inputs are unaffected. Also adds a sentence to the
`$TURBO_EXTENDS$` docs saying what is inherited for `inputs`.
### Testing Instructions
New engine builder tests in
`crates/turborepo-engine/src/builder/test/structured_inputs.rs` resolve
the full root + package `turbo.json` chain. Three of them fail on
`main`:
```
test ...::package_extends_keeps_default_files_when_root_has_no_inputs ... FAILED
test ...::package_extends_with_jit_input_keeps_startup_hashing_of_default_files ... FAILED
test ...::package_extends_keeps_default_files_when_root_inputs_are_empty ... FAILED
test ...::package_extends_explicit_root_globs_without_adding_defaults ... ok
test ...::package_inputs_without_extends_marker_replace_root_default ... ok
test result: FAILED. 4 passed; 3 failed
```
With the fix:
- `cargo test -p turborepo-engine --lib`: 182 passed
- `cargo test -p turborepo-turbo-json --lib`: 330 passed (includes 4 new
merge-level tests in `extend.rs`)
- `cargo clippy -p turborepo-turbo-json -p turborepo-engine
--all-targets -- -D warnings` and `cargo fmt --check`: clean
- Verified locally on macOS (Apple Silicon).
---------
Co-authored-by: Anthony Shew <anthony.shew@vercel.com>
Co-authored-by: Anthony Shew <anthonyshew@gmail.com>