The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
fix(curator): age archived skills from archival time so purge honors the TTL
John Paul Solivabade8387c4b6
diff --git a/tests/hermes_cli/test_curator_archive_prune.py b/tests/hermes_cli/test_curator_archive_prune.pyindex 0ac5af6ecd3..8dd37dc8c10 100644--- a/tests/hermes_cli/test_curator_archive_prune.py+++ b/tests/hermes_cli/test_curator_archive_prune.py@@ -31,6 +31,34 @@ def test_archive_refuses_pinned(monkeypatch, capsys):assert "hermes curator unpin" in out+# ─── purge ──────────────────────────────────────────────────────────────────+++def test_purge_ages_an_archive_from_when_it_was_archived(tmp_path, monkeypatch):+ """The TTL counts from archival, not from the skill's last edit: a long-idle skill the+ curator archives today must survive `purge --days 30`."""+ import os+ import time++ import hermes_cli.curator as curator_cli+ from tools import skill_usage++ monkeypatch.setenv("HERMES_HOME", str(tmp_path))+ skill_dir = tmp_path / "skills" / "old-helper"+ skill_dir.mkdir(parents=True)+ (skill_dir / "SKILL.md").write_text(+ "---\nname: old-helper\ndescription: x\n---\n# body\n", encoding="utf-8")+ long_ago = time.time() - 100 * 86400+ for path in (skill_dir / "SKILL.md", skill_dir):+ os.utime(path, (long_ago, long_ago))+ skill_usage.record_created("old-helper", agent_created=True)+ ok, msg = skill_usage.archive_skill("old-helper")+ assert ok, msg++ assert curator_cli._cmd_purge(_ns(days=30, dry_run=False, yes=True)) == 0+ assert (tmp_path / "skills" / ".archive" / "old-helper" / "SKILL.md").is_file()++# ─── prune ──────────────────────────────────────────────────────────────────diff --git a/tools/skill_usage.py b/tools/skill_usage.pyindex f0147ad2428..8c244ea6bdb 100644--- a/tools/skill_usage.py+++ b/tools/skill_usage.py@@ -9,6 +9,7 @@ from __future__ import annotationsimport jsonimport logging+import osimport threadingfrom contextlib import contextmanager, suppressfrom datetime import datetime, timezone@@ -608,6 +609,11 @@ def _relocate(src: Path, dest: Path, skill_name: str, action: str, **capture_kwaexcept Exception as e:return False, f"failed to {action}: {e}"archiving = action == "archive"+ if archiving:+ # `curator purge` ages archives by mtime; a move keeps the skill's last-edit mtime, so an+ # idle skill archived today would already look older than any TTL.+ with suppress(OSError):+ os.utime(dest)if not archiving or is_bundled(skill_name): # pruning a built-in only sticks if the re-seeder skips it_toggle_suppressed_name(skill_name, add=archiving)set_state(skill_name, STATE_ARCHIVED if archiving else STATE_ACTIVE)