Skip to content

feat(tgb): add AllTargetsFileHashes column 22 support - #285

Open
yushan8 wants to merge 7 commits into
yushan/all-targets-config-basefrom
yushan/all-targets-config-v2
Open

feat(tgb): add AllTargetsFileHashes column 22 support#285
yushan8 wants to merge 7 commits into
yushan/all-targets-config-basefrom
yushan/all-targets-config-v2

Conversation

@yushan8

@yushan8 yushan8 commented Aug 19, 2026

Copy link
Copy Markdown
Contributor

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.goencodeStringMap + column emission
  • internal/tgb/reader.godecodeStringMap + AllTargetsFileHashes() accessor + DecodeGraph integration
  • internal/tgbdiff/adapt.goMergeChunks propagation fix
  • controller/getchangedtargets.goallTargetsChangedFromTGB(), TGB path wiring
  • controller/getchangedtargets_tgb_test.go — trigger/no-trigger tests
  • internal/tgb/tgb_test.go — round-trip tests

Test plan

  • TGB round-trip tests — AllTargetsFileHashes survives encode/decode (present/absent/empty)
  • TGB Reader.AllTargetsFileHashes() accessor test — lazy single-column decode
  • TGB controller test — trigger fires → all targets changed, skips normal TGB diff
  • TGB controller test — matching hashes → normal TGB diff proceeds
  • All existing TGB tests pass

Stack: depends on #286

yushan8 and others added 2 commits August 19, 2026 09:38
Add TGB support for the AllTargetsFileHashes sidecar so the
AllTargetsFiles feature works regardless of graph_format. Column 22
stores a length-prefixed sequence of (key, value) string pairs,
zstd-compressed. Old readers skip unknown column IDs; new readers on
old blobs get nil — no format version bump needed.

The TGB comparison path in the controller now checks
AllTargetsFileHashes via a cheap single-column decode before the full
columnar diff, matching the gob path's behavior.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
Verify that AllTargetsFileHashes survives TGB encode/decode via both
full Decode and the lazy Reader.AllTargetsFileHashes() accessor. Covers
present, absent, and empty-map cases. Also fixes canonicalise() to
preserve AllTargetsFileHashes so existing round-trip tests remain
correct when graphs carry the sidecar.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@yushan8
yushan8 force-pushed the yushan/all-targets-config-v2 branch from dc9447b to 45cd0c3 Compare August 19, 2026 16:49
MergeChunks was not merging AllTargetsFileHashes from metadata chunks,
so the field was silently dropped before TGB encoding. This caused the
AllTargetsFiles trigger to never fire on the TGB comparison path.

Also adds controller-level TGB tests for both trigger and no-trigger
cases, verifying end-to-end that AllTargetsFileHashes survives the full
write → read → compare pipeline.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@yushan8 yushan8 changed the title feat(config): add AllTargetsFiles to invalidate all targets on trigger file change feat(tgb): add AllTargetsFileHashes column 22 support Aug 19, 2026
@yushan8
yushan8 changed the base branch from main to yushan/all-targets-config-base August 19, 2026 17:28
yushan8 and others added 3 commits August 19, 2026 14:28
Map iteration order is random in Go, so the same logical
AllTargetsFileHashes could produce different byte sequences across
runs, violating the deterministic computation property and causing
spurious cache misses.

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).
- gofmt alignment in colNames map and a test's Params struct literal
- DecodeGraph now reuses Reader.AllTargetsFileHashes() instead of
  duplicating the column-decode logic inline
@yushan8
yushan8 marked this pull request as ready for review August 19, 2026 21:55
@yushan8
yushan8 requested review from a team as code owners August 19, 2026 21:55
Makes it clearer that all targets in the graph are reported as changed
when the trigger fires, not just the ones that happen to have different
hashes.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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