Skip to content

Make Index tag metadata hash-safe with immutable tag storage #84

@shinaoka

Description

@shinaoka

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:

  • dim
  • id
  • tags
  • plev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions