Skip to content

feat(kanban): make worker log retention configurable#25639

Closed
qWaitCrypto wants to merge 1 commit into
NousResearch:mainfrom
qWaitCrypto:feat/kanban-worker-log-retention
Closed

feat(kanban): make worker log retention configurable#25639
qWaitCrypto wants to merge 1 commit into
NousResearch:mainfrom
qWaitCrypto:feat/kanban-worker-log-retention

Conversation

@qWaitCrypto

@qWaitCrypto qWaitCrypto commented May 14, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Adds configurable Kanban worker log retention while preserving the existing default behavior.

Today worker logs rotate at a hard-coded 2 MiB and keep only one backup generation (.log.1). That is fine as a default, but long-running workers can overwrite early failure evidence before an operator has a chance to inspect it. This PR keeps the default 2 MiB + one backup, and lets operators tune retention for heavier workloads.

Related Issue

#25641

Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 🔒 Security fix
  • 📝 Documentation update
  • ✅ Tests (adding or improving test coverage)
  • ♻️ Refactor (no behavior change)
  • 🎯 New skill (bundled or hub)

Changes Made

  • Added kanban.worker_log_rotate_bytes to configure the per-file rotation threshold.
  • Added kanban.worker_log_backup_count to configure how many rotated worker log generations are kept.
  • Preserved the historical defaults:
    • worker_log_rotate_bytes: 2097152
    • worker_log_backup_count: 1
  • Updated worker spawn log rotation to use the resolved config.
  • Extended _rotate_worker_log() to shift multiple backup generations (.log.1, .log.2, ...).
  • Added tests for default config resolution, override config resolution, and multi-generation rotation.

Reproduction

Before the fix, rotation only accepted a byte threshold and always replaced .log.1:

signature = (log_path: 'Path', max_bytes: 'int') -> 'None'
active_exists = False
backup_1 = new-run
backup_2_exists = False

After the fix, rotation accepts a backup count and preserves older generations when configured:

signature = (log_path: 'Path', max_bytes: 'int', backup_count: 'int' = 1) -> 'None'
active_exists = False
backup_1 = new-run
backup_2 = previous-run
config_override = (10, 2)

How to Test

python -m py_compile hermes_cli/kanban_db.py hermes_cli/config.py tests/hermes_cli/test_kanban_core_functionality.py

Result: passed.

/tmp/hermes-provider-refresh-venv/bin/python -m pytest -o addopts= tests/hermes_cli/test_kanban_core_functionality.py -k 'worker_log_rotation or read_worker_log_tail or gc_worker_logs'

Result: 5 passed, 151 deselected in 12.90s.
Latest local rerun: 5 passed, 151 deselected in 8.05s.

git diff --check

Result: passed.

Checklist

Code

  • I've read the Contributing Guide
  • My commit messages follow Conventional Commits (fix(scope):, feat(scope):, etc.)
  • I searched for existing PRs to make sure this isn't a duplicate
  • My PR contains only changes related to this fix/feature (no unrelated commits)
  • I've run pytest tests/ -q and all tests pass
  • I've added tests for my changes
  • I've tested on my platform: Linux (WSL-style dev environment)

Documentation & Housekeeping

  • I've updated relevant documentation (README, docs/, docstrings) — or N/A
  • I've updated cli-config.yaml.example if I added/changed config keys — or N/A
  • I've updated CONTRIBUTING.md or AGENTS.md if I changed architecture or workflows — or N/A
  • I've considered cross-platform impact (Windows, macOS)
  • I've updated tool descriptions/schemas if I changed tool behavior — or N/A

Screenshots / Logs

See reproduction and test logs above.

@alt-glitch alt-glitch added type/feature New feature or request comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have labels May 14, 2026
@teknium1

Copy link
Copy Markdown
Contributor

Merged via #27867 onto current main. Your commit was cherry-picked with authorship preserved. Thanks!

@teknium1 teknium1 closed this May 18, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

comp/plugins Plugin system and bundled plugins P3 Low — cosmetic, nice to have type/feature New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants