Skip to content

test: reproducer for #401 (undeclared workspace reads get stable hashes)#402

Merged
tinder-maxwellelliott merged 1 commit into
masterfrom
claude/reproducer-issue-401
Jul 2, 2026
Merged

test: reproducer for #401 (undeclared workspace reads get stable hashes)#402
tinder-maxwellelliott merged 1 commit into
masterfrom
claude/reproducer-issue-401

Conversation

@tinder-maxwellelliott

Copy link
Copy Markdown
Collaborator

What

Adds an E2E reproducer for #401 — a feature request for "always-affected" hashing of targets that perform undeclared workspace reads (non-hermetic targets).

  • New fixture cli/src/test/resources/workspaces/always_affected_external/:
    • //:scanner — a genrule tagged external whose action reads scanned_data.txt but does not declare it as a src (the undeclared / non-hermetic read). Stands in for a buildifier_test that scans every .bzl in the repo without declaring them.
    • //:hermetic — a normal genrule that declares declared_src.txt, for contrast.
  • New test testUndeclaredWorkspaceReadIsNotImpacted_reproducerForIssue401 in E2ETest.kt.

Why

bazel-diff derives a target's hash purely from its declared graph (srcs / deps / attributes). A target that reads files it never declares therefore keeps a stable hash even when one of those files changes, so get-impacted-targets skips it — even though the target would behave differently if actually run. This is the gap #401 asks to close.

Behaviour pinned

The test edits both the undeclared read (scanned_data.txt) and the declared src (declared_src.txt) between two checkouts, then asserts the current behaviour:

  • //:hermetic is reported as impacted (declared its changed source ✅)
  • //:scanner is not reported as impacted (undeclared read → stable hash ❌)

If an --alwaysAffectedTags-style feature later lands, the scanner should start appearing in the impacted set and the final assertion will flag that the behaviour changed.

Notes for reviewers

  • Passes locally on Bazel 8.5.1 (~16s).
  • Fixture is intentionally minimal — no committed MODULE.bazel.lock (matches the keep_going_repo_failure fixture); Bazel regenerates it in the copied temp workspace.
  • Reproducer only; no production code changed.

🤖 Generated with Claude Code

A target that reads files it does not declare as inputs (a non-hermetic /
"undeclared workspace read", e.g. a buildifier_test scanning every .bzl in
the repo) gets a stable hash from bazel-diff, because hashing is derived
purely from the declared graph. Editing an undeclared input therefore leaves
the target's hash unchanged and get-impacted-targets skips it, even though
the target would behave differently if run.

Adds the always_affected_external fixture (an `external`-tagged genrule that
reads an undeclared file, plus a hermetic genrule for contrast) and an E2E
test pinning the current behaviour: the hermetic target is reported impacted
while the external-tagged scanner is not.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
@tinder-maxwellelliott tinder-maxwellelliott merged commit 22d4b5f into master Jul 2, 2026
15 checks passed
@tinder-maxwellelliott tinder-maxwellelliott deleted the claude/reproducer-issue-401 branch July 2, 2026 00:22
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.

1 participant