Skip to content

fix: make ctxFact gob encoding deterministic#31

Draft
DerekTBrown wants to merge 1 commit into
kkHAIKE:masterfrom
DerekTBrown:codex/deterministic-ctxfact-gob
Draft

fix: make ctxFact gob encoding deterministic#31
DerekTBrown wants to merge 1 commit into
kkHAIKE:masterfrom
DerekTBrown:codex/deterministic-ctxfact-gob

Conversation

@DerekTBrown
Copy link
Copy Markdown

@DerekTBrown DerekTBrown commented May 15, 2026

Summary

  • Add deterministic gob serialization for ctxFact
  • Sort fact map keys before encoding to avoid Go map iteration order in analysis fact bytes
  • Decode the stable entry representation back into the existing map shape
  • Add regression tests for byte-stable encoding and round-trip decode

Why

ctxFact is exported as a Go analysis fact. Raw gob encoding of map[string]resInfo can produce different byte streams for the same fact, which is problematic for Bazel/rules_go nogo .facts outputs and content-addressed caches.

Fixes #30

Validation

Red/green evidence:

  • Unpatched upstream origin/master / v1.1.6 at 6e20d9954cd54de0d21c93ddc3b98d1fb0493187: standalone regression test failed with gob encoding changed on iteration 0
  • Patched branch at 6939d14b5a5f7da390bf88d2c68bf193e94088b2: same standalone regression test passed

Existing validation:

  • go test -run 'TestCtxFactGob' -count=1 -v
  • go test ./...
  • go test -run TestCtxFactGobEncodingIsDeterministic -count=50

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.

ctxFact analysis fact gob encoding is nondeterministic

1 participant