refactor: remove legacy history and proxy migrations (#6518)
This commit is contained in:
1 parent
1c28b20c7e
commit
cb3ba45317
47 files changed
+207
-1925
No files matched your search
@@ -146,7 +146,6 @@ async def test_recovery_continuation_runs_without_a_sustained_goal(
|
||||
async def test_recovery_preserves_turn_origin_until_the_next_user_turn(
|
||||
tmp_path: Path, monkeypatch: pytest.MonkeyPatch, late_result: bool,
|
||||
) -> None:
|
||||
monkeypatch.setattr("nanobot.webui.history.get_webui_dir", lambda: tmp_path / "webui")
|
||||
bus = MessageBus()
|
||||
provider = MagicMock(aclose=AsyncMock())
|
||||
provider.get_default_model.return_value = "test-model"
|
||||
|
||||
@@ -1,16 +1,15 @@
|
||||
"""Session keys remain distinct even when their display filenames collide."""
|
||||
"""Session keys with punctuation and Unicode remain distinct in storage."""
|
||||
|
||||
from nanobot.session.manager import Session, SessionManager
|
||||
|
||||
|
||||
def test_colliding_display_names_roundtrip_independently(tmp_path):
|
||||
def test_distinct_keys_roundtrip_independently(tmp_path):
|
||||
manager = SessionManager(tmp_path)
|
||||
keys = ("telegram:a_b", "telegram:a:b", "telegram:a/b", "telegram:你好")
|
||||
for key in keys:
|
||||
session = Session(key=key)
|
||||
session.add_message("user", key)
|
||||
manager.save(session)
|
||||
assert manager.safe_key(keys[0]) == manager.safe_key(keys[1])
|
||||
assert len(manager.list_sessions()) == len(keys)
|
||||
for key in keys:
|
||||
assert manager.read_session_file(key)["messages"][0]["content"] == key
|
||||
|
||||
@@ -59,9 +59,7 @@ async def test_session_tools_find_old_matches_in_full_session(
|
||||
|
||||
@pytest.mark.asyncio
|
||||
@pytest.mark.parametrize("state", ["canonical", "transcript", "mixed"])
|
||||
async def test_session_tools_use_canonical_records_after_restart(history, tmp_path, monkeypatch, state):
|
||||
webui_dir = tmp_path / "webui"
|
||||
monkeypatch.setattr("nanobot.webui.history.get_webui_dir", lambda: webui_dir)
|
||||
async def test_session_tools_use_canonical_records_after_restart(history, state):
|
||||
manager = history.sessions
|
||||
key = "websocket:history"
|
||||
if state != "transcript":
|
||||
@@ -75,16 +73,10 @@ async def test_session_tools_use_canonical_records_after_restart(history, tmp_pa
|
||||
})
|
||||
history.append(key, {"event": "turn_end", "chat_id": "history"})
|
||||
|
||||
def durable_files():
|
||||
return {
|
||||
path: path.read_bytes()
|
||||
for root in (manager.sessions_dir, webui_dir)
|
||||
for path in root.rglob("*.jsonl")
|
||||
}
|
||||
|
||||
original = durable_files()
|
||||
original_messages = manager.read_session_file(key)["messages"]
|
||||
original_display_facts = manager.project_history(key, lambda reader: reader.all_facts())
|
||||
for _ in range(2):
|
||||
manager = history.sessions
|
||||
manager = SessionManager(history.sessions.workspace)
|
||||
with request_context(RequestContext(
|
||||
channel="websocket", chat_id="current", session_key="websocket:current",
|
||||
)):
|
||||
@@ -99,4 +91,6 @@ async def test_session_tools_use_canonical_records_after_restart(history, tmp_pa
|
||||
assert search["results"][0]["excerpts"][0]["content"] == "canonical needle"
|
||||
assert [item["content"] for item in json.loads(read)["messages"]] == ["canonical needle"]
|
||||
assert display_search["results"] == []
|
||||
assert durable_files() == original
|
||||
assert manager.read_session_file(key)["messages"] == original_messages
|
||||
assert manager.project_history(key, lambda reader: reader.all_facts()) == original_display_facts
|
||||
await manager.state.aclose()
|
||||
Reference in new issue
Block a user