mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-05-08 03:01:47 +00:00
fix: update tests for resume_pending semantics + add AUTHOR_MAP entries
Tests updated to reflect suspend_recently_active now setting resume_pending=True (preserves session) instead of suspended=True (wipes session history). AUTHOR_MAP entries: millerc79 (#19033), shellybotmoyer (#18915)
This commit is contained in:
parent
1148c46241
commit
6f2dab248a
2 changed files with 17 additions and 13 deletions
|
|
@ -49,9 +49,10 @@ class TestSuspendRecentlyActive:
|
|||
count = store.suspend_recently_active()
|
||||
assert count == 1
|
||||
|
||||
# Re-fetch — should be suspended now
|
||||
# Re-fetch — should be resume_pending (preserved, not wiped)
|
||||
refreshed = store.get_or_create_session(source)
|
||||
assert refreshed.was_auto_reset
|
||||
assert refreshed.resume_pending
|
||||
assert refreshed.session_id == entry.session_id # same session preserved
|
||||
|
||||
def test_does_not_suspend_old_sessions(self, tmp_path):
|
||||
store = _make_store(tmp_path)
|
||||
|
|
@ -66,21 +67,22 @@ class TestSuspendRecentlyActive:
|
|||
count = store.suspend_recently_active(max_age_seconds=120)
|
||||
assert count == 0
|
||||
|
||||
def test_already_suspended_not_double_counted(self, tmp_path):
|
||||
def test_already_resume_pending_not_double_counted(self, tmp_path):
|
||||
store = _make_store(tmp_path)
|
||||
source = _make_source()
|
||||
entry = store.get_or_create_session(source)
|
||||
|
||||
# Suspend once
|
||||
# Mark resume_pending once
|
||||
count1 = store.suspend_recently_active()
|
||||
assert count1 == 1
|
||||
|
||||
# Create a new session (the old one got reset on next access)
|
||||
# Re-fetch returns the SAME session (preserved, not reset)
|
||||
entry2 = store.get_or_create_session(source)
|
||||
assert entry2.session_id == entry.session_id
|
||||
|
||||
# Suspend again — the new session is recent but not yet suspended
|
||||
# Second call skips already-resume_pending entries
|
||||
count2 = store.suspend_recently_active()
|
||||
assert count2 == 1
|
||||
assert count2 == 0
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
@ -180,11 +182,11 @@ class TestCleanShutdownMarker:
|
|||
else:
|
||||
store.suspend_recently_active()
|
||||
|
||||
# Session SHOULD be suspended (crash recovery)
|
||||
# Session SHOULD be resume_pending (crash recovery preserves history)
|
||||
with store._lock:
|
||||
store._ensure_loaded_locked()
|
||||
suspended_count = sum(1 for e in store._entries.values() if e.suspended)
|
||||
assert suspended_count == 1, "Session should be suspended after crash (no marker)"
|
||||
resume_count = sum(1 for e in store._entries.values() if e.resume_pending)
|
||||
assert resume_count == 1, "Session should be resume_pending after crash (no marker)"
|
||||
|
||||
def test_marker_written_on_restart_stop(self, tmp_path, monkeypatch):
|
||||
"""stop(restart=True) should also write the marker."""
|
||||
|
|
|
|||
|
|
@ -376,8 +376,8 @@ class TestSuspendRecentlyActiveSkipsResumePending:
|
|||
assert e.suspended is False
|
||||
assert e.resume_pending is True
|
||||
|
||||
def test_non_resume_pending_still_suspended(self, tmp_path):
|
||||
"""Non-resume sessions still get the old crash-recovery suspension."""
|
||||
def test_non_resume_pending_gets_resume_pending(self, tmp_path):
|
||||
"""Non-resume sessions are now marked resume_pending (not suspended)."""
|
||||
store = _make_store(tmp_path)
|
||||
source_a = _make_source(chat_id="a")
|
||||
source_b = _make_source(chat_id="b")
|
||||
|
|
@ -386,9 +386,11 @@ class TestSuspendRecentlyActiveSkipsResumePending:
|
|||
store.mark_resume_pending(entry_a.session_key)
|
||||
|
||||
count = store.suspend_recently_active()
|
||||
# entry_a is already resume_pending → skipped. entry_b gets marked.
|
||||
assert count == 1
|
||||
assert store._entries[entry_a.session_key].suspended is False
|
||||
assert store._entries[entry_b.session_key].suspended is True
|
||||
assert store._entries[entry_b.session_key].resume_pending is True
|
||||
assert store._entries[entry_b.session_key].suspended is False
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue