Skip to content

fix(disk-cleanup): protect cron output root from cleanup (salvage #49271) - #271

Merged
hashbender merged 1 commit into
mainfrom
mirror/pr-56266
Jul 1, 2026
Merged

hashbender merged 1 commit into
mainfrom
mirror/pr-56266

Conversation

@hashbender

Copy link
Copy Markdown
Owner

Summary

Salvage of NousResearch#49271 by @martinramos002-bot (rebased onto current main). Stops the disk-cleanup plugin from deleting the cron output root (~/.hermes/cron/output) while still letting individual run artifacts below it be cleaned by retention policy.

The bug

The disk-cleanup plugin classifies anything under cron/output/ as disposable cron-output. That includes the cron/output root directory itself — deleting it wholesale erases every job's retained run history at once, far broader than expiring one run artifact.

The fix

  • Add str(base / "output") to _PROTECTED_CRON_PATHS in _is_protected_cron_path (for both cron and cronjobs parents) — a hard block on deleting the output root.
  • In guess_category, tighten the gate from len(rel.parts) >= 2 to >= 3: rel is relative to hermes_home, so cron/output is ('cron','output') (len 2) → no longer categorized deletable, while a real artifact at cron/output/<file> (len 3) or deeper stays cron-output and is still cleaned.

Two independent defenses for the same invariant (root not deletable): the category gate, and the protected-paths hard block as defense-in-depth.

Verification

Verified against current main (applied + behaviorally probed): cron/output root → protected; cron/output/run.md (len 3 file), cron/output/job_1/run.md (len 4), cron/output/job_1 (len 3 dir) all still deleted; a stale tracked.json entry pointing at the root is dropped by quick()'s re-validation and hard-blocked by _is_protected_cron_path (both canonicalize via .resolve()). No off-by-one, no over-broad protection, no residual deletion path.

Ran hermes-agent-dev + hermes-pr-review Phase 2c (4-part structured) on the final salvage.

Tests

tests/plugins/test_disk_cleanup_plugin.py — output-root-not-tracked, stale-entry-for-output-root-not-deleted, plus existing artifact-still-cleaned coverage. (CI runs the full suite.)

Supersedes NousResearch#49271. Full credit to @martinramos002-bot.


Mirror-of: NousResearch#56266
NousResearch#56266

@hashbender
hashbender merged commit 6a47d61 into main Jul 1, 2026
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant