Skip to content

fix(cron): re-validate stale cron-output entries before deletion - #39067

Merged
teknium1 merged 1 commit into
mainfrom
hermes/hermes-de8f5c66
Jun 4, 2026
Merged

fix(cron): re-validate stale cron-output entries before deletion#39067
teknium1 merged 1 commit into
mainfrom
hermes/hermes-de8f5c66

Conversation

@teknium1

@teknium1 teknium1 commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

disk-cleanup quick() can no longer delete the live cron scheduler registry (cron/jobs.json) via stale tracked.json entries.

Root cause: guess_category() was fixed in #34840 to only classify cron/output/** as cron-output, but tracked.json entries written before that fix still carry category: "cron-output" for control-plane paths like cron/jobs.json and .tick.lock. quick()/dry_run() trusted the stored category at delete time and would wipe the live registry.

Changes

  • plugins/disk-cleanup/disk_cleanup.py:
    • quick() + dry_run(): re-run guess_category() for cron-output entries at delete time; stale entries that no longer match are skipped and dropped from tracking.
    • New _is_protected_cron_path() defense-in-depth guard — never deletes cron/, cronjobs/, jobs.json, or .tick.lock regardless of stored category.
  • tests/plugins/test_disk_cleanup_plugin.py: 5 regression tests (TestStaleCronEntryMigration).

The contributor's guess_category() hunk was already on main (#34840), so this salvage keeps only the genuinely-new delete-time re-validation + protected-path guard.

Validation

Stale cron-output entry for… Before After
cron/jobs.json (live registry) deleted skipped, kept
cron/.tick.lock deleted skipped, kept
cron/output/run.md (real artifact) deleted deleted (unchanged)

Verified live: ran quick() against a real stale tracked.json mislabeling cron/jobs.json as cron-output — registry survived with content intact (important-daily-report job preserved), while a genuine cron/output/ artifact was still cleaned (deleted: 1). 46/46 test_disk_cleanup_plugin.py pass.

Fixes #37721.

Salvaged from #37868 by @kyssta-exe — authorship preserved via cherry-pick.

Infographic

cron-registry-guard

)

quick() and dry_run() previously trusted the stored category from
tracked.json without re-validating at delete time. Stale entries from
before #34840 could carry category="cron-output" for cron control-plane
paths (e.g. cron/jobs.json), causing quick() to delete the live
scheduler registry.

Fix:
- Fix guess_category() to only classify cron/output/** as cron-output
  (was classifying ALL cron/* paths, missing the #34840 fix).
- Re-validate cron-output entries via guess_category() at delete time
  in quick() and dry_run(); stale entries that are no longer classified
  as cron-output are skipped and removed from tracked.json.
- Add _is_protected_cron_path() as a hard defense-in-depth guard that
  blocks deletion of cron/cronjobs directories and known control-plane
  files (jobs.json, .tick.lock) regardless of stored category.
- Update test_cron_subtree_categorised to match fixed guess_category
  (only cron/output/* is cron-output, not all of cron/).

Tests: add 5 regression tests in TestStaleCronEntryMigration.
@github-actions

github-actions Bot commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

🔎 Lint report: hermes/hermes-de8f5c66 vs origin/main

ruff

Total: 0 on HEAD, 0 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 0 pre-existing issues carried over.

ty (type checker)

Total: 9804 on HEAD, 9804 on base (➖ 0)

🆕 New issues: none

✅ Fixed issues: none

Unchanged: 5088 pre-existing issues carried over.

Diagnostics are surfaced as warnings — this check never fails the build.

@alt-glitch alt-glitch added type/bug Something isn't working comp/cron Cron scheduler and job management comp/plugins Plugin system and bundled plugins P1 High — major feature broken, no workaround labels Jun 4, 2026
@teknium1
teknium1 merged commit 30412a9 into main Jun 4, 2026
30 of 31 checks passed
@teknium1
teknium1 deleted the hermes/hermes-de8f5c66 branch June 4, 2026 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/cron Cron scheduler and job management comp/plugins Plugin system and bundled plugins P1 High — major feature broken, no workaround type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Bug]: disk-cleanup can still delete cron/jobs.json from stale tracked.json entries

3 participants