Skip to content

Seed rules whose own source files changed at distance 0#119

Merged
xytan0056 merged 2 commits into
mainfrom
tanx/seed-rules-with-changed-srcs
Jun 16, 2026
Merged

Seed rules whose own source files changed at distance 0#119
xytan0056 merged 2 commits into
mainfrom
tanx/seed-rules-with-changed-srcs

Conversation

@xytan0056

@xytan0056 xytan0056 commented Jun 16, 2026

Copy link
Copy Markdown
Contributor

A rule whose srcs include a changed source file is now promoted to a BFS seed (distance 0) instead of appearing at distance 1 behind the source-file node. This makes distance == 0 mean "this target's own inputs changed" rather than requiring consumers to look through the source-file indirection.

The fix adds hasChangedSourceFileDep(), called during Pass 2 seed classification, which checks whether any of a rule's direct dependencies is both changed and a source file.

Behavior change: downstream targets of such rules shift one hop closer in the BFS, so a given max_distance will include a slightly larger set. This is more correct since the semantic seed is the rule, not the file.

Test Plan:
Unit tested

  • Updated TestCompareTargetGraphs_SourceFileDirectAndPropagation and TestCompareTargetGraphs_HashOnlyChangePropagatesViaBFS to expect distance 0 for rules owning changed source files.
  • Added TestCompareTargetGraphs_SiblingRuleNotPromotedToSeed: verifies a rule depending on a sibling rule (not its own source file) stays at distance 1.

Issue

A rule whose srcs include a changed source file is now promoted to a
BFS seed (distance 0) instead of appearing at distance 1 behind the
source-file node. This makes distance == 0 mean "this target's own
inputs changed" rather than requiring consumers to look through the
source-file indirection.

The fix adds hasChangedSourceFileDep(), called during Pass 2 seed
classification, which checks whether any of a rule's direct
dependencies is both changed and a source file.

Behavior change: downstream targets of such rules shift one hop closer
in the BFS, so a given max_distance will include a slightly larger set.
This is more correct since the semantic seed is the rule, not the file.

Test Plan:
- Updated TestCompareTargetGraphs_SourceFileDirectAndPropagation and
  TestCompareTargetGraphs_HashOnlyChangePropagatesViaBFS to expect
  distance 0 for rules owning changed source files.
- Added TestCompareTargetGraphs_SiblingRuleNotPromotedToSeed: verifies
  a rule depending on a sibling rule (not its own source file) stays
  at distance 1.
@xytan0056 xytan0056 requested review from a team as code owners June 16, 2026 18:47
@CLAassistant

CLAassistant commented Jun 16, 2026

Copy link
Copy Markdown

CLA assistant check
All committers have signed the CLA.

@xytan0056 xytan0056 merged commit 370dadd into main Jun 16, 2026
7 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.

3 participants