The agent that grows with you
Python aiai-agentai-agentsanthropicchatgptclaudeclaude-codecodexhermeshermes-agentllmnous-researchopenai
test: the auto-compact test seeds legacy fat rows so it is red on main
kshitijk4poor0f00cb1a9ec8
diff --git a/tests/tools/test_skill_ledger.py b/tests/tools/test_skill_ledger.pyindex f87b3d1199d..9b3b5de6510 100644--- a/tests/tools/test_skill_ledger.py+++ b/tests/tools/test_skill_ledger.py@@ -615,8 +615,11 @@ def _append_padded(skill_ledger, action: str, pad: str, n: int = 1) -> None:def test_auto_compact_triggers_at_threshold(ledger_env, monkeypatch):"""Crossing skills.ledger_max_bytes rewrites the ledger through the delta- dedup: identical before/after manifests shrink to nothing while ids and- entry order survive."""+ dedup: legacy rows that still carry identical before/after manifests (written+ before append-time ``_delta`` existed) shrink to nothing while ids and entry+ order survive, and nothing is trimmed when dedup alone reaches the cap."""+ import json+from tools import skill_ledgerimport hermes_cli.config as _cfg@@ -624,14 +627,23 @@ def test_auto_compact_triggers_at_threshold(ledger_env, monkeypatch):monkeypatch.setattr(_cfg, "load_config", lambda *a, **k: {"skills": {"ledger_max_bytes": 8192}})- for i in range(3): # pre-delta-style entries: identical fat manifests on both sides- fat = [{"path": f"my-skill/f{i}j{j}.md", "sha256": "a" * 64} for j in range(40)]- skill_ledger.append_entry("patch", "my-skill", before=fat, after=list(fat))+ first_id = skill_ledger.append_entry("patch", "my-skill", before=[], after=[])+ template = json.loads(skill_ledger.ledger_path().read_text().splitlines()[0])+ with skill_ledger.ledger_path().open("a", encoding="utf-8") as fh:+ for i in range(3): # legacy pre-delta rows: identical fat manifests on both sides+ fat = [{"path": f"my-skill/f{i}j{j}.md", "sha256": "a" * 64} for j in range(40)]+ row = dict(template, id=f"legacy{i}", before=fat, after=list(fat))+ fh.write(json.dumps(row) + "\n")+ assert skill_ledger.ledger_path().stat().st_size > 8192++ last_id = skill_ledger.append_entry("patch", "my-skill", before=[], after=[])- # the maintenance sweep fired mid-append: the file stays under the cap+ # the maintenance sweep fired on that append: the file is back under the capassert skill_ledger.ledger_path().stat().st_size <= 8192rows = skill_ledger.list_entries()- assert len(rows) == 3, "dedup alone must reach the cap — nothing trimmed"+ assert {r["id"] for r in rows} == {first_id, last_id, "legacy0", "legacy1", "legacy2"}, (+ "dedup alone must reach the cap — nothing trimmed, ids survive"+ )assert all(r["before"] == [] and r["after"] == [] for r in rows), ("identical manifests must be dropped by compaction")