Skip to content

Use observed files for literal external aliases - #646

Merged
tinder-maxwellelliott merged 5 commits into
Tinder:masterfrom
tamird:tamird/fine-alias-source-inputs
Nov 10, 2026
Merged

tinder-maxwellelliott merged 5 commits into
Tinder:masterfrom
tamird:tamird/fine-alias-source-inputs

Conversation

@tamird

@tamird tamird commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

In ordinary Bzlmod queries, #529 makes an imported repository depend on extension siblings that no module imports. A fine-grained hub can forward to a single file in that repository. The alias already hashes the file bytes, but its extra repository dependency can select the consumer when only a sibling changes. Changing a public export to private can leave the consumer’s hash equal even though Bazel rejects the build.

This uses the native alias binding and SourceFile returned by the supplementary query from #630 and #643. For a freshly read regular file, bazel-diff checks the open file against Bazel’s reported location and includes the effective visibility in the alias hash. When the generated source repository has no other dependencies, this operand points to an internal hash row for its definition, even before the extension generates its first hidden sibling. Keeping the definition one dependency away preserves the reported target and package distances. The original repository row still carries the siblings for every other operand. Unresolved bindings, package-group visibility, source overrides, and platforms without the file identity check retain the conservative path.

The regression builds a payload reader and a reader of the generated BUILD file. Changing the payload selects its reader. Changing another spoke, or adding or removing the first hidden sibling, leaves that reader out. Changing the export to private selects the reader and fails its build. Adding an unused rule to the same BUILD file selects the BUILD-file reader alone among those two consumers. Changing an unused attribute of the source repository leaves both products intact and still reports the alias at distance one and its consumer at distance two.

Assisted by Codex.

Query mode adds an imported extension repository's hidden siblings to
its hash. When a fine-grained alias forwards to a source file in that
repository, the file's bytes already enter the alias hash. Its
repository dependency still makes an unrelated sibling edit reach the
alias. Conversely, a visibility edit can leave the file contents and
repository definition unchanged while the alias consumer stops building.

Keep the source location and effective visibility returned by the strict
alias closure. For an observed regular file, retain the selected
repository definition and the visibility in the alias hash. Suppress the
shared sibling group only for this operand. Keep the usual repository
input when its other dependencies, source identity, or visibility cannot
be established.

Assisted by Codex.
@tamird
tamird marked this pull request as draft November 9, 2026 23:33
Folding the repository definition into an observed alias moved a real
RepoSpec change one dependency level closer to its consumers. Keep the
original aggregate for unqualified inputs and route a verified alias
through an internal definition node in the external package.

Retain that internal kind in hash files for distance traversal and omit
it from reported targets. A conflicting helper name keeps the original
repository input.

Assisted by Codex.
Change an unused repository rule attribute while the exported file, BUILD
file and consumer outputs stay identical. Check the ordinary target and
package distances for the source alias and its consumer alongside the
payload, sibling and visibility cases.
@tamird
tamird marked this pull request as ready for review November 10, 2026 00:16
@tamird
tamird marked this pull request as draft November 10, 2026 01:33
An observed source alias used the original repository node until the
extension generated its first unimported sibling, then switched to the
definition-only node. The change in the dependency label alone made the
alias look directly changed, even with identical file bytes, visibility
and repository attributes.

Mark the lowering of generated repositories whose only inputs are hidden
siblings, including an empty group. A qualified alias can use the same
definition node at both revisions. Keep the existing aggregate hashes for
other readers and check the roster transition in the existing alias test.
@tamird
tamird marked this pull request as ready for review November 10, 2026 01:51
@tinder-maxwellelliott
tinder-maxwellelliott merged commit a49a4ba 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