Skip to content

Storage keys need a structured (branch, period) scheme: str(period) is lossy and separators collide with branch names #526

Description

@MaxGhenis

#523 / #525 fix the crash where get_known_periods/get_known_branch_periods split storage keys on every colon, but the underlying key scheme has deeper, pre-existing structural problems (surfaced in cross-family review of #525):

  1. str(period) is lossy for day-anchored periods. Keys embed f"{branch_name}:{period}", and Period.__str__ drops the day for e.g. month:2027-11-15:2 / year:2027-11-15:2, so distinct valid periods can collide in the cache and the readers reconstruct date-shifted periods.
  2. Branch names have no enforced grammar. Simulation.get_branch accepts arbitrary names; a branch name containing : breaks split(":", 1) parsing in the readers and in delete.
  3. OnDiskStorage has the same defect class with _ as the separator ({branch}_{period} + unconstrained split("_")): a branch name like my_reform mis-parses, and complex-period colons produce awkward filenames.

The clean fix is structured keys — (branch_name, Period) tuples in memory and an escaped/encoded filename scheme on disk — rather than string round-trips. That is a storage-format refactor deserving its own design + review, hence this issue rather than a rider on #525.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions