Skip to content

feat(rewind): add save/load for RewindStore persistence#23

Open
stemplong wants to merge 1 commit intoopen-compress:mainfrom
stemplong:feat/rewind-persistence
Open

feat(rewind): add save/load for RewindStore persistence#23
stemplong wants to merge 1 commit intoopen-compress:mainfrom
stemplong:feat/rewind-persistence

Conversation

@stemplong
Copy link
Copy Markdown

Summary

Adds save() and load() methods to RewindStore for persisting cache to disk.

Problem

In long-running agent sessions, a process restart wipes the in-memory RewindStore. Any [[REWIND:sha256:...]] markers in the conversation become unresolvable, breaking the reversible compression contract.

Solution

  • store.save("/tmp/rewind_cache.json") — writes all non-expired entries with their remaining TTL
  • store.load("/tmp/rewind_cache.json") — merges entries back into the live cache
  • Expired entries are pruned on save and skipped on load
  • Live entries are not overwritten during load
  • max_entries limit enforced after loading

Usage

engine = FusionEngine()
# ... compress some content ...

# Before shutdown
engine._rewind_store.save("/tmp/session_rewind.json")

# On next startup
engine._rewind_store.load("/tmp/session_rewind.json")
# Previously compressed markers are now resolvable again

Long-running agent sessions lose their Rewind cache when the process
restarts. This adds save() and load() methods to persist RewindStore
entries to a JSON file and restore them later.

- save() writes only non-expired entries with remaining TTL
- load() merges entries into the live cache without overwriting
- Entries that would be expired on load are skipped
- max_entries limit is enforced after loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant