The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(curator): bound automatic transition days like curator prune
AhmetArif0342c29250d65
diff --git a/agent/curator.py b/agent/curator.pyindex f27b64e3ab5..d5482c9e20c 100644--- a/agent/curator.py+++ b/agent/curator.py@@ -114,12 +114,25 @@ def get_min_idle_hours() -> float:return _config_number("min_idle_hours", DEFAULT_MIN_IDLE_HOURS, float)+def _bounded_days(key: str, default: int) -> int:+ """*key* (a ``curator.<key>`` day count), floored at 1 like ``curator prune --days`` already+ refuses (hermes_cli/curator.py::_cmd_prune). A value < 1 collapses stale_cutoff/archive_cutoff+ onto or past "now" in apply_automatic_transitions(), mass-transitioning every skill with any+ past activity on the next automatic pass — unlike the manual prune path this runs unconfirmed,+ so it falls back to the default instead of acting on the bad value."""+ value = _config_number(key, default, int)+ if value < 1:+ logger.warning("curator.%s must be >= 1 (got %d); using the default of %d", key, value, default)+ return default+ return value++def get_stale_after_days() -> int:- return _config_number("stale_after_days", DEFAULT_STALE_AFTER_DAYS, int)+ return _bounded_days("stale_after_days", DEFAULT_STALE_AFTER_DAYS)def get_archive_after_days() -> int:- return _config_number("archive_after_days", DEFAULT_ARCHIVE_AFTER_DAYS, int)+ return _bounded_days("archive_after_days", DEFAULT_ARCHIVE_AFTER_DAYS)def get_consolidate() -> bool:diff --git a/tests/agent/test_curator.py b/tests/agent/test_curator.pyindex c7e277a9a6d..c15ca6b727f 100644--- a/tests/agent/test_curator.py+++ b/tests/agent/test_curator.py@@ -134,6 +134,35 @@ def test_set_paused_roundtrip(curator_env):[email protected]("bad_days", [0, -5])+def test_non_positive_archive_after_days_falls_back_to_default(curator_env, monkeypatch, bad_days):+ """``curator.archive_after_days: 0`` (or negative) collapses archive_cutoff onto or past "now",+ which would mass-archive every skill with any past activity on the very next automatic pass.+ ``hermes curator prune --days`` already refuses the same value; apply_automatic_transitions()+ runs unconfirmed on an idle tick, so it must fall back to the default instead."""+ c = curator_env["curator"]+ u = curator_env["usage"]+ skills_dir = curator_env["home"] / "skills"+ _write_skill(skills_dir, "just-used")+ _backdate(u, "just-used", 0)+ monkeypatch.setattr(c, "_load_config", lambda: {"archive_after_days": bad_days})++ counts = c.apply_automatic_transitions()++ assert counts["archived"] == 0+ assert u.load_usage()["just-used"]["state"] == u.STATE_ACTIVE+ assert c.get_archive_after_days() == c.DEFAULT_ARCHIVE_AFTER_DAYS++[email protected]("bad_days", [0, -5])+def test_non_positive_stale_after_days_falls_back_to_default(curator_env, monkeypatch, bad_days):+ """Same bound for ``stale_after_days`` — a non-positive value must not zero out the+ use_count==0 grace floor apply_automatic_transitions() relies on."""+ c = curator_env["curator"]+ monkeypatch.setattr(c, "_load_config", lambda: {"stale_after_days": bad_days})+ assert c.get_stale_after_days() == c.DEFAULT_STALE_AFTER_DAYS++def test_pinned_skill_is_never_touched(curator_env):c = curator_env["curator"]u = curator_env["usage"]