Skip to content

fix(cron): resolve jobs path dynamically to prevent profile fragmentation#29339

Open
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/25295-cron-profile-fragmentation
Open

fix(cron): resolve jobs path dynamically to prevent profile fragmentation#29339
Tranquil-Flow wants to merge 2 commits into
NousResearch:mainfrom
Tranquil-Flow:fix/25295-cron-profile-fragmentation

Conversation

@Tranquil-Flow

@Tranquil-Flow Tranquil-Flow commented May 20, 2026

Copy link
Copy Markdown
Contributor

What does this PR do?

Fixes #25295 - Cron jobs fail with profile fragmentation when CLI and gateway use different profiles. Module-level constants CRON_DIR, JOBS_FILE, OUTPUT_DIR are resolved once at import time from get_hermes_home(), so all cron operations silently read/write from the wrong profile directory.

Related Issue

Fixes #25295

Type of Change

  • Bug fix (non-breaking change that fixes an issue)

Changes Made

  • cron/jobs.py - Added _resolve_cron_dir(), _resolve_jobs_file(), _resolve_output_dir() helpers that call get_hermes_home() dynamically. All internal code updated. Module-level constants preserved for backward compat.
  • cron/scheduler.py - _build_job_prompt() updated to use _resolve_output_dir().
  • hermes_cli/web_server.py - _call_cron_for_profile() updated to monkeypatch both resolve* helpers AND legacy module-level constants.
  • tests/cron/test_cron_profile_fragmentation.py - 10 new tests
  • tests/cron/test_25295_fail_without_fix.py - 2 new tests
  • tests/cron/test_webserver_monkeypatch_compat.py - 4 new tests verifying web_server monkeypatch still works
  • tests/cron/test_file_permissions.py - 3 tests updated

How to Test

  1. Configure two profiles (default and alt)
  2. Create a cron job under the alt profile
  3. Start gateway with alt profile
  4. Verify the job is visible and runs correctly

Checklist

Code

  • I have read the Contributing Guide
  • My commit messages follow Conventional Commits
  • I searched for existing PRs to make sure this is not a duplicate
  • My PR contains only changes related to this fix
  • I have run pytest tests/cron/ -q and all 24 tests pass
  • I have added tests for my changes
  • I have tested on my platform: macOS (arm64)

Documentation and Housekeeping

  • I have updated docstrings for the new helpers
  • [N/A] cli-config.yaml.example - no config keys changed
  • [N/A] CONTRIBUTING.md / AGENTS.md - no architecture changes
  • Cross-platform impact: uses Path.mkdir(parents=True, exist_ok=True) - portable
  • [N/A] Tool descriptions/schemas - no tool behavior changed

@alt-glitch alt-glitch added type/bug Something isn't working comp/cron Cron scheduler and job management area/config Config system, migrations, profiles P2 Medium — degraded but workaround exists labels May 20, 2026
@Tranquil-Flow Tranquil-Flow force-pushed the fix/25295-cron-profile-fragmentation branch from 9b3cd54 to bcc6735 Compare May 25, 2026 09:12
…search#25295 refactor

The _resolve_* helpers bypass module-level constants, which broke
_call_cron_for_profile's temporary retargeting for the multi-profile
dashboard. Update web_server.py to monkeypatch both the resolve
helpers and the legacy constants. Add 4 regression tests.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/config Config system, migrations, profiles comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron jobs created via CLI silently fail to fire — profile fragmentation

2 participants