Skip to content

fix(itg): wire bzlmod external-target collapse into incremental graph updates - #323

Merged
yushan8 merged 2 commits into
yushan/bzlmod-apparent-repo-collapsefrom
yushan/itg-bzlmod-collapse
Oct 2, 2026
Merged

yushan8 merged 2 commits into
yushan/bzlmod-apparent-repo-collapsefrom
yushan/itg-bzlmod-collapse

Conversation

@yushan8

@yushan8 yushan8 commented Oct 2, 2026

Copy link
Copy Markdown
Contributor

Summary

Stacked on #322.

core/itg/graph.UpdateGraph (the incremental/ITG graph update path) always
called the legacy targethasher.HashExternalTargets helper regardless of
UseBzlmod. That helper filters on //external:* rule names, which don't
exist under bzlmod, so it silently did nothing for bzlmod repos — every
bzlmod external source/generated file target then fell through to
computeAvailableHashes, which unconditionally re-hashed it from disk. This
reintroduces the per-file hashing cost that #312's marker-based collapse
fixed for the full-graph (fromProto) path.

Changes

  • UpdateGraphInput gains ExcludedRegex, RepoMarkerHashes, and
    RepoMapping, mirroring targethasher.HashConfig.
  • UpdateGraph branches on UseBzlmod: legacy WORKSPACE repos keep calling
    HashExternalTargets; bzlmod repos call targethasher.HashExternalTargetsBzlmod
    with the marker hashes, same as the full-graph path.
  • computeAvailableHashes now skips re-hashing a SourceFileType target that
    already has a hash set (e.g. by the bzlmod collapse), instead of
    unconditionally overwriting it with a disk-based hash.
  • Extracted targethasher.CompileExcludedRegex (shared by FromProto and the
    new itg call site) to avoid duplicating the regex-compile-with-wrapped-error
    logic.

Test plan

  • go test ./core/itg/graph/... ./core/targethasher/...
  • Added TestUpdateGraph_BzlmodCollapsesExternalFiles, an end-to-end test
    that fails loudly (via a hasher returning an error) if the itg path ever
    falls back to disk hashing for a bzlmod external file.
  • Added a computeAvailableHashes subtest asserting a pre-set hash isn't
    clobbered.

yushan8 and others added 2 commits October 2, 2026 15:36
…collapse

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
… updates

core/itg/graph.UpdateGraph always called the legacy HashExternalTargets
helper, which matches on //external:* rule names and is a no-op for bzlmod
repos (no such rules exist under bzlmod). Every bzlmod external source file
then fell through to computeAvailableHashes, which unconditionally re-hashed
it from disk, reintroducing the per-file hashing cost that #312's marker-based
collapse was meant to eliminate for the full-graph path.

Branch on UseBzlmod and call targethasher.HashExternalTargetsBzlmod with the
repo marker hashes/mapping, and make computeAvailableHashes skip source files
that already have a hash (e.g. from the collapse) instead of overwriting it.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@yushan8
yushan8 merged commit 0d14495 into yushan/bzlmod-apparent-repo-collapse Oct 2, 2026
10 checks passed
@yushan8
yushan8 deleted the yushan/itg-bzlmod-collapse branch October 2, 2026 22:56
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