mirror of
https://github.com/NousResearch/hermes-agent.git
synced 2026-11-17 04:11:35 +00:00
Move retention, orphan pruning, status and clear operations into a topical sibling and route callers and tests directly to their defining module. Keep the shared store paths and git execution in checkpoint_manager; shorten the local child-env WHAT docstring.
39 lines
1.7 KiB
Python
39 lines
1.7 KiB
Python
"""``checkpoint_footprint_notice``: tells a user their /rollback store is on and large.
|
||
|
||
Checkpoints were on by default Mar–May 2026 and that ``enabled: true`` persisted into user
|
||
configs after the default flipped back, so a GB-scale store can sit under a feature the user
|
||
never invokes. The notice fires only when checkpoints are enabled AND the store is at/over
|
||
``max_total_size_mb``; it names the opt-out.
|
||
"""
|
||
|
||
import os
|
||
|
||
import hermes_yaml as yaml
|
||
|
||
from hermes_constants import get_hermes_home
|
||
from tools.checkpoint_manager import CheckpointManager
|
||
from tools.checkpoint_maintenance import checkpoint_footprint_notice
|
||
|
||
def _write_config(enabled: bool, cap_mb: int) -> None:
|
||
home = get_hermes_home()
|
||
home.mkdir(parents=True, exist_ok=True)
|
||
(home / "config.yaml").write_text(
|
||
yaml.safe_dump({"checkpoints": {"enabled": enabled, "max_total_size_mb": cap_mb}}), encoding="utf-8")
|
||
|
||
def test_notice_only_when_enabled_and_over_cap(tmp_path, monkeypatch):
|
||
base = get_hermes_home() / "checkpoints"
|
||
monkeypatch.setattr("tools.checkpoint_manager.CHECKPOINT_BASE", base)
|
||
work = tmp_path / "proj"
|
||
work.mkdir()
|
||
(work / "blob.bin").write_bytes(os.urandom(2 * 1024 * 1024)) # incompressible → store > 1 MB
|
||
_write_config(enabled=True, cap_mb=1)
|
||
assert CheckpointManager(enabled=True, max_total_size_mb=1).ensure_checkpoint(str(work), "seed")
|
||
|
||
notice = checkpoint_footprint_notice()
|
||
assert notice
|
||
|
||
_write_config(enabled=True, cap_mb=500) # under the cap: no nag for a healthy store
|
||
assert checkpoint_footprint_notice() is None
|
||
|
||
_write_config(enabled=False, cap_mb=1) # off: the store's size is irrelevant
|
||
assert checkpoint_footprint_notice() is None
|