The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test(sessions): pin that a disabled export guard skips its bare-path session scan
kshitijk4poor5448496864a0
diff --git a/tests/hermes_cli/test_sessions_export_backup_round_trip.py b/tests/hermes_cli/test_sessions_export_backup_round_trip.pyindex 3a03e3d767c..b708bb91855 100644--- a/tests/hermes_cli/test_sessions_export_backup_round_trip.py+++ b/tests/hermes_cli/test_sessions_export_backup_round_trip.py@@ -56,11 +56,15 @@ def test_jsonl_backup_round_trips_compaction_archived_turns(tmp_path, monkeypatcdst.close()[email protected]("selection", [("--session-id", SID), ("--source", "cli"), ()],- ids=["session-id", "filter", "bare"])-def test_jsonl_backup_refuses_a_session_over_max_export_messages(tmp_path, monkeypatch, capsys, selection):[email protected]("selection, disabled",+ [(("--session-id", SID), False), (("--source", "cli"), False), ((), False), ((), True)],+ ids=["session-id", "filter", "bare", "limit-0"])+def test_jsonl_backup_refuses_a_session_over_max_export_messages(tmp_path, monkeypatch, capsys, selection,+ disabled):"""Every selection path applies the per-session guard to the STORED row count the backup- materializes, so a small live tail over a large archive cannot slip past it."""+ materializes, so a small live tail over a large archive cannot slip past it. ``limit-0``: a+ disabled guard writes the backup without the guard's own full-session scan (export_all's is+ the only one)."""from hermes_cli.config import load_config, save_configsrc = _seed_compacted_session()@@ -69,13 +73,20 @@ def test_jsonl_backup_refuses_a_session_over_max_export_messages(tmp_path, monkesrc.end_session(SID, "user_exit") # bulk filters match ended sessionssrc.close()cfg = load_config()- cfg.setdefault("sessions", {})["max_export_messages"] = live + 1+ cfg.setdefault("sessions", {})["max_export_messages"] = 0 if disabled else live + 1save_config(cfg)assert stored > live + 1+ scans = []+ real_search = SessionDB.search_sessions+ monkeypatch.setattr(SessionDB, "search_sessions",+ lambda self, *a, **kw: scans.append(1) or real_search(self, *a, **kw))backup = tmp_path / "backup.jsonl"_export(monkeypatch, backup, *selection)+ if disabled:+ assert backup.exists() and len(scans) == 1+ returnassert not backup.exists()out = capsys.readouterr().outassert SID in out and "max_export_messages" in out