Description
The footer's event index is built by iterating over a Go map, which has intentionally randomized iteration order. This means the event index section of the footer will have different ordering between writes of the same data, making tape files non-reproducible.
Evidence
File: pkg/codec/tape.go:114-121
// Writing the footer event index:
for eventType, offsets := range w.eventIndex {
// map iteration order is randomized in Go
// footer bytes differ between identical writes
}
Go's map iteration order is randomized by design (since Go 1.12). Two identical tape files written from the same data will produce different footer bytes.
Impact
Non-reproducible output. Byte-for-byte comparison of tape files fails even with identical input. This affects:
- Checksumming / integrity verification
- Diffing tape files
- Test determinism
Suggested Fix
Sort the event types before writing:
types := make([]string, 0, len(w.eventIndex))
for t := range w.eventIndex {
types = append(types, t)
}
sort.Strings(types)
for _, t := range types {
offsets := w.eventIndex[t]
// write in deterministic order
}
🤖 Filed by Metis
Description
The footer's event index is built by iterating over a Go map, which has intentionally randomized iteration order. This means the event index section of the footer will have different ordering between writes of the same data, making tape files non-reproducible.
Evidence
File:
pkg/codec/tape.go:114-121Go's map iteration order is randomized by design (since Go 1.12). Two identical tape files written from the same data will produce different footer bytes.
Impact
Non-reproducible output. Byte-for-byte comparison of tape files fails even with identical input. This affects:
Suggested Fix
Sort the event types before writing:
🤖 Filed by Metis