Problem
Index is currently hashable and can be used as a Dict/Set key, but it stores tags as Vector{String}. The Index struct itself is immutable, while part of the hashed equality state is mutable. If tag metadata is mutated after an Index has been used as a hash key, hash table behavior can become invalid.
This also makes it easier for internal code to accidentally avoid full Index equality and compare only id(index), which collapses distinct indices such as site and prime(site) or indices with different tags.
Desired direction
Introduce hash-safe immutable tag metadata for Index, for example an immutable/canonical tag string representation or an immutable tag set type, and make Index equality/hash semantics consistently include:
Tags should be semantic metadata and should match for Index == unless an operation explicitly documents that it ignores or rewrites tags.
Notes
- Current
Index == already includes tags and plev.
- Current
Index is a struct, but tags::Vector{String} is mutable.
- Regression tests should include:
- same
id, different plev
- same
id and plev, different tags
- using
Index values as Set/Dict keys
This issue is about the longer-term hash-safety/API cleanup. Immediate migration work should prefer existing Index == comparisons over ad hoc id(index) comparisons.
Problem
Indexis currently hashable and can be used as aDict/Setkey, but it stores tags asVector{String}. TheIndexstruct itself is immutable, while part of the hashed equality state is mutable. If tag metadata is mutated after anIndexhas been used as a hash key, hash table behavior can become invalid.This also makes it easier for internal code to accidentally avoid full
Indexequality and compare onlyid(index), which collapses distinct indices such assiteandprime(site)or indices with different tags.Desired direction
Introduce hash-safe immutable tag metadata for
Index, for example an immutable/canonical tag string representation or an immutable tag set type, and makeIndexequality/hash semantics consistently include:dimidtagsplevTags should be semantic metadata and should match for
Index ==unless an operation explicitly documents that it ignores or rewrites tags.Notes
Index ==already includestagsandplev.Indexis astruct, buttags::Vector{String}is mutable.id, differentplevidandplev, differenttagsIndexvalues asSet/DictkeysThis issue is about the longer-term hash-safety/API cleanup. Immediate migration work should prefer existing
Index ==comparisons over ad hocid(index)comparisons.