Revert "refactor: remove legacy history and proxy migrations (#6518)"

This reverts commit cb3ba45317.

Keep JSONL history and legacy proxy migration available throughout 0.4.x. Mark their removal for 0.5.0 in code and release guidance, preserving later context graph, archive and recovery changes.
This commit is contained in:
chengyongru authored and chengyongru committed 2026-11-06 10:58:10 +08:00
1 parent 3918ece17f
commit 812b92d734
47 files changed
+1932 -204

No files matched your search

+1
View File
@@ -147,6 +147,7 @@ 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"
+2 -1
View File
@@ -1,13 +1,14 @@
from nanobot.session.manager import Session, SessionManager
def test_distinct_keys_roundtrip_independently(tmp_path):
def test_colliding_display_names_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
+13 -7
View File
@@ -57,7 +57,9 @@ 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, state):
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)
manager = history.sessions
key = "websocket:history"
if state != "transcript":
@@ -71,10 +73,16 @@ async def test_session_tools_use_canonical_records_after_restart(history, state)
})
history.append(key, {"event": "turn_end", "chat_id": "history"})
original_messages = manager.read_session_file(key)["messages"]
original_display_facts = manager.project_history(key, lambda reader: reader.all_facts())
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()
for _ in range(2):
manager = SessionManager(history.sessions.workspace)
manager = history.sessions
with request_context(RequestContext(
channel="websocket", chat_id="current", session_key="websocket:current",
)):
@@ -89,6 +97,4 @@ async def test_session_tools_use_canonical_records_after_restart(history, state)
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 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()
assert durable_files() == original