Skip to content

Follow verified external filegroup inputs - #647

Merged
tinder-maxwellelliott merged 3 commits into
Tinder:masterfrom
tamird:codex/bazel-diff-observed-filegroup-inputs-20261110
Nov 10, 2026
Merged

tinder-maxwellelliott merged 3 commits into
Tinder:masterfrom
tamird:codex/bazel-diff-observed-filegroup-inputs-20261110

Conversation

@tamird

@tamird tamird commented Nov 10, 2026 •

Copy link
Copy Markdown
Contributor

Changing a compiler repository can select a genrule that only reads an unchanged copied file through an external filegroup. With --fineGrainedHashExternalRepos, follow verified filegroup and source inputs in the normal flat graph so that genrule stays out of the impact set.

Replace that operand's repository fallback only after strict queries match native filegroup and genrule definitions, confirm an empty toolchains attribute, and account for every direct child with verified source or filegroup inputs. Projected queries require matching synthetic attribute evidence from a fresh row under the same projection. Opaque or omitted inputs keep the #529 fallback, and compiler consumers without complete provider evidence can still be overselected. Repository definition nodes from #646 preserve target and package distances.

When an acquired rule’s package BUILD appears as a synthetic loading row, re-query the reached BUILD labels together and recover the evaluated list of loaded Starlark files. The resulting source hash tracks transitive load labels even when the BUILD bytes stay fixed.

Maintained product checks on stock Bazel 8.8.2:

  • //tests:e2e_test_external_returned_external_source_reaches_consumer: copied source, unrelated compiler edit, projected attributes, and an opaque tool hidden by --notool_deps.
  • //tests:e2e_test_external_fine_alias_to_a_source_tracks_its_contents_and_visibility: source and visibility changes plus repository distances.
  • //tests:e2e_test_regressions_extension_repo_patch_edit_impacts_toolchain_user: an SDK patch reaches its user, and renaming a transitive Starlark load changes the acquired SDK BUILD hash at fixed BUILD bytes.

Also validated with the instrumented Rust/CLI unit suite, rustfmt, and Clippy.

Assisted by OpenAI Codex.

@tamird tamird changed the title Follow verified external filegroup inputs in ordinary queries Follow verified external filegroup inputs Nov 10, 2026
Ordinary queries can name an external filegroup without returning its
body. The parent then inherits the repository's generated siblings, so
an unrelated sibling edit can change its hash.

Read missing native filegroups and sources through exact labels. Narrow
a genrule's forwarded operand only after its normal definition and input
list match a strict native record with an empty toolchains attribute and
every direct child has a verified source or filegroup path. Preserve the
fallback for opaque or incomplete inputs.

Extend internal repository definition paths through positively mapped
module dependencies at their original //external hops. Keep the original
aggregate nodes and their paths for unqualified operands.

Retain the typed BUILD package marker and recover omitted BUILD.bazel
load names with one bounded buildfiles query. Only returned .bzl packages
seed the existing checks. Invalidate cached graphs with fine repository
inputs and older partial recipes.
30c96aa compares a rule digest under the caller's projection with a
full declaration. Bazel's synthetic attribute hash depends on which
attribute encodings are emitted [1], so the digests differ under a
filtered projection. The repository fallback then selects an unrelated
reader of a copied file.

When the caller explicitly requests the synthetic hash, re-read the
candidate parent with the caller's projection in the existing
supplemental query. Accept that digest only when Bazel returns its
synthetic attribute, keeping the value opaque. Preserve the strict
class, input, and source checks, and retain the fallback when the
evidence is missing or malformed.

Cover projected attributes and an opaque tool omitted by
--notool_deps. Advance the cache version for fine inputs because the
flat graph changes.

[1]: https://github.com/bazelbuild/bazel/blob/8.8.2/src/main/java/com/google/devtools/build/lib/query2/query/output/SyntheticAttributeHashCalculator.java
@tamird
tamird force-pushed the codex/bazel-diff-observed-filegroup-inputs-20261110 branch from 5707d4e to 5f91299 Compare November 10, 2026 14:24
A buildfiles query can return a synthetic BUILD row for a loaded package at the same label as its evaluated BUILD. When an external alias brings in a rule from that package, accepting the synthetic row makes the BUILD hash insensitive to its transitive load labels.

Query the ambiguous BUILD labels for acquired rule packages together. Restore loads only from an evaluated, error-free SourceFile and advance the fine-input cache and partial recipe versions.

Rename a transitive Starlark load in the stock SDK fixture at fixed BUILD bytes. The old flat SourceFile hashes were identical across the edit.
@tamird
tamird marked this pull request as ready for review November 10, 2026 19:15
@tinder-maxwellelliott
tinder-maxwellelliott merged commit 60744d8 into Tinder:master Nov 10, 2026
19 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants