fix(disk-cleanup): protect cron output root from cleanup (salvage #49271) - #271
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 disposablecron-output. That includes thecron/outputroot directory itself — deleting it wholesale erases every job's retained run history at once, far broader than expiring one run artifact.The fix
str(base / "output")to_PROTECTED_CRON_PATHSin_is_protected_cron_path(for bothcronandcronjobsparents) — a hard block on deleting the output root.guess_category, tighten the gate fromlen(rel.parts) >= 2to>= 3:relis relative tohermes_home, socron/outputis('cron','output')(len 2) → no longer categorized deletable, while a real artifact atcron/output/<file>(len 3) or deeper stayscron-outputand 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/outputroot → 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 staletracked.jsonentry pointing at the root is dropped byquick()'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