fix(dream): restore cursor with memory state
Track the Dream cursor in memory versioning so restores do not skip history after rolling back Dream commits. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
committed by
Xubin Ren
co-authored by
Cursor
parent
ac18a8baad
commit
44a341335a
@@ -5,7 +5,7 @@ from datetime import datetime
|
||||
|
||||
import pytest
|
||||
|
||||
from nanobot.agent.memory import MemoryStore, _HISTORY_ENTRY_HARD_CAP
|
||||
from nanobot.agent.memory import _HISTORY_ENTRY_HARD_CAP, MemoryStore
|
||||
|
||||
|
||||
@pytest.fixture
|
||||
@@ -241,6 +241,26 @@ class TestDreamCursor:
|
||||
store2 = MemoryStore(store.workspace)
|
||||
assert store2.get_last_dream_cursor() == 3
|
||||
|
||||
def test_git_restore_rolls_back_dream_cursor(self, tmp_path):
|
||||
store = MemoryStore(tmp_path)
|
||||
store.write_memory("before")
|
||||
store.set_last_dream_cursor(1)
|
||||
assert store.git.init() is True
|
||||
|
||||
store.write_memory("after")
|
||||
store.set_last_dream_cursor(2)
|
||||
dream_sha = store.git.auto_commit("dream: update")
|
||||
assert dream_sha is not None
|
||||
|
||||
store.write_memory("newer")
|
||||
store.set_last_dream_cursor(3)
|
||||
|
||||
restore_sha = store.git.revert(dream_sha)
|
||||
|
||||
assert restore_sha is not None
|
||||
assert store.read_memory() == "before"
|
||||
assert store.get_last_dream_cursor() == 1
|
||||
|
||||
|
||||
class TestLegacyHistoryMigration:
|
||||
def test_read_unprocessed_history_handles_entries_without_cursor(self, store):
|
||||
|
||||
Reference in New Issue
Block a user