fix(curator): key purge's archived_at lookup by the skill's frontmatter name

The legacy-archive rescue looked up the usage record by the archive dir
name. Older archives were flattened under the DIRECTORY name (`accelerate`
for skill `huggingface-accelerate`, as restore_skill already documents), so
the lookup found no archived record, fell back to the stale dir mtime and
purged a skill the record says was archived today.

Resolve the record key with skill_usage._read_skill_name (the same
frontmatter reader restore_skill uses), falling back to the dir name when
SKILL.md is missing or has no name.
This commit is contained in:
kshitijk4poor
2026-09-26 23:11:13 +05:30
committed by kshitij
parent 167a2d00ed
commit ad3d4719ce

View File

@@ -443,7 +443,9 @@ def _cmd_purge(args) -> int:
# The NEWER of the record's archived_at and the dir mtime: archives made before
# archive_skill stamped the mtime carry the skill's last-edit mtime, and a stale
# archived_at survives a manual un-archive + re-archive. Never purge before either says so.
rec = skill_usage.get_record(p.name)
# Key by the SKILL.md frontmatter name: older archives were flattened under the directory
# name (`accelerate` for `huggingface-accelerate`), which is not the usage-record key.
rec = skill_usage.get_record(skill_usage._read_skill_name(p / "SKILL.md", fallback=p.name))
at = skill_usage._parse_iso_timestamp(rec.get("archived_at")) if rec.get("state") == skill_usage.STATE_ARCHIVED else None
return max(at.timestamp(), p.stat().st_mtime) if at else p.stat().st_mtime