feat(config): add AllTargetsFiles to invalidate all targets on trigger file change - #286
Merged
Conversation
…r file change Some files affect the build globally but are invisible to the target graph (toolchain definitions, CI config, Bazel wrapper scripts). Add RepositoryConfig.AllTargetsFiles: file hashes for listed paths are computed from git ls-tree during graph computation, stored as sidecar data in Metadata.AllTargetsFileHashes, and compared at diff time. When any configured file's hash differs between the two revisions, GetChangedTargets reports every target in the second revision as changed (distance 0) instead of running the normal target-graph diff. This mirrors the Java TargetHasher/FastTargetComparer.resolveCTC pattern: hashes travel as sidecar data alongside the graph, checked post-fetch. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
SplitMetadata builds fresh Metadata chunks and never carried the sidecar map, so the AllTargetsFiles trigger silently never fired on graphs written via the orchestrator's real chunking path (only the direct ResultToTargetGraph call, used by tests, preserved it). Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
…rgethasher The hash extraction belongs in targethasher.FromProto where it has direct access to HashConfig.KnownSourceHashes, rather than in the graphrunner which was duplicating the lookup. AllTargetsFiles is now a field on HashConfig, and FromProto populates Result.AllTargetsFileHashes after the inner fromProto returns. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
gofmt had left ExcludedRegex/UseBzlmod/AllTargetsFiles misaligned. Also adds a unit test exercising the AllTargetsFileHashes extraction in FromProto directly (previously only covered indirectly via mapper tests).
sywhang
approved these changes
Aug 20, 2026
yushan8
added a commit
that referenced
this pull request
Aug 20, 2026
## Summary Adds TGB (Target Graph Binary) format support for `AllTargetsFileHashes`, stacked on #286. - New column 22 (`ALL_TARGETS_FILE_HASHES`) — length-prefixed key-value string pairs, zstd compressed - Forward/backward compatible: old readers skip unknown column IDs, new readers on old blobs get nil (no version bump needed) - `Reader.AllTargetsFileHashes()` lazy accessor decodes only column 22 (cheap, no full graph decode) - Controller TGB comparison path checks AllTargetsFileHashes before dispatching to normal TGB diff - `MergeChunks` propagates AllTargetsFileHashes from metadata chunks before TGB encoding ### Files changed - `internal/tgb/format.go` — column ID 22 - `internal/tgb/encode.go` — `encodeStringMap` + column emission - `internal/tgb/reader.go` — `decodeStringMap` + `AllTargetsFileHashes()` accessor + `DecodeGraph` integration - `internal/tgbdiff/adapt.go` — `MergeChunks` propagation fix - `controller/getchangedtargets.go` — `allTargetsChangedFromTGB()`, TGB path wiring - `controller/getchangedtargets_tgb_test.go` — trigger/no-trigger tests - `internal/tgb/tgb_test.go` — round-trip tests ## Test plan - [x] TGB round-trip tests — AllTargetsFileHashes survives encode/decode (present/absent/empty) - [x] TGB Reader.AllTargetsFileHashes() accessor test — lazy single-column decode - [x] TGB controller test — trigger fires → all targets changed, skips normal TGB diff - [x] TGB controller test — matching hashes → normal TGB diff proceeds - [x] All existing TGB tests pass **Stack:** depends on #286 --------- Co-authored-by: Claude Sonnet 5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
RepositoryConfig.AllTargetsFiles: a list of repo-relative file paths that, when their content hash differs between two revisions, causeGetChangedTargetsto report every target in the second revision as changed (distance 0)git ls-treeduring graph computation intargethasher.FromProto, stored as sidecar data inMetadata.AllTargetsFileHashes, and compared at diff time in the controllerData flow
Example config
Test plan
allTargetsFileChangedunit tests — nil/empty/matching/differing hash scenarios (table-driven)compareTargetGraphsgob-path test — trigger fires → all targets changedcompareTargetGraphsgob-path test — matching hashes → normal diffStack: TGB format support in PR #285