The states are made of:
- A textfile with the list of packages that should be activated
- A backup of the packages that were removed in the next state
This information is enough to get back from one state to the previous one. You can then repeat that process and get as far back as you need.
So, the simple solution here is to only remove the oldest states and never add “holes” in the history. This way we can always go back to any one of the remaining states if needed.
I think it makes sense to start by setting up this simple strategy, and integrate it in Haiku (maybe initially with a manual trigger, something like “pkgman clean-old-states”).
Then we can see about doing further things later:
- Merging states so we can keep an older one but delete intermediate versions,
- Triggering this automatically in some way.