Skip to content

fix(cron): resolve profile-scoped jobs storage dynamically - #60882

Draft
rerdi92 wants to merge 5 commits into
NousResearch:mainfrom
rerdi92:fix/cron-profile-scoped-jobs
Draft

fix(cron): resolve profile-scoped jobs storage dynamically#60882
rerdi92 wants to merge 5 commits into
NousResearch:mainfrom
rerdi92:fix/cron-profile-scoped-jobs

Conversation

@rerdi92

@rerdi92 rerdi92 commented Jul 8, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Add a regression test proving cron.jobs storage follows the active HERMES_HOME override without requiring importlib.reload().
  • Resolve the import-time JOBS_FILE/CRON_DIR profile-scoping leak by routing runtime cron IO through dynamic path helpers.
  • Extend the same runtime-path fix to cron.scheduler._build_job_prompt() so context_from reads upstream job output from the active profile's output directory.
  • Preserve backward compatibility for existing tests/dashboard code that monkeypatches public cron path globals.

Root cause

cron/jobs.py captured HERMES_DIR, CRON_DIR, JOBS_FILE, OUTPUT_DIR, and ticker marker paths at module import time. In a long-lived process, later profile-scoped work using set_hermes_home_override() could continue writing to the first profile's cron paths.

A follow-up review found one adjacent stale-path use in cron/scheduler.py: context_from prompt injection imported the public OUTPUT_DIR constant directly, so chained cron jobs could skip upstream output stored under the active profile after a runtime home override.

Test plan

  • RED before jobs fix: tests/cron/test_jobs.py::TestProfileScopedJobStorage::test_job_store_follows_active_hermes_home_without_module_reload failed because profile B's cron/jobs.json was not created.
  • GREEN after jobs fix: same regression test passed.
  • RED before scheduler fix: tests/cron/test_cron_context_from.py::TestBuildJobPromptContextFrom::test_context_from_follows_runtime_home_override_after_import failed because _build_job_prompt() did not inject profile-scoped upstream output.
  • GREEN after scheduler fix: same regression test passed.
  • Full context_from suite:
python -m pytest tests/cron/test_cron_context_from.py -q

22 passed
  • Profile-scoping focused slice:
python -m pytest tests/cron/test_jobs.py::TestProfileScopedJobStorage::test_job_store_follows_active_hermes_home_without_module_reload tests/cron/test_cron_profile_isolation.py -q

5 passed
python -m pytest tests/cron/test_jobs.py tests/cron/test_cron_profile_isolation.py tests/cron/test_jobs_crossprocess_lock.py tests/cron/test_rewrite_skill_refs.py tests/cron/test_cron_script.py tests/cron/test_cron_context_from.py tests/cron/test_cron_workdir.py -q -k 'not test_tilde_expands'

221 passed, 2 skipped, 1 deselected
  • Syntax/checks:
python -m py_compile cron/scheduler.py tests/cron/test_cron_context_from.py
git diff --check

Notes

While testing on Windows, two unrelated portability issues were observed outside this patch scope and split to #60888:

  • tests/cron/test_file_permissions.py expects strict POSIX mode bits on Windows/NTFS.
  • tests/cron/test_cron_workdir.py::test_tilde_expands assumes patched HOME controls Path("~").expanduser() on Windows.

@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 Jul 8, 2026

@tonydwb tonydwb left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review Summary

Verdict: Comment (token read-only)

PR 60882 resolves profile-scoped jobs storage dynamically in cron. Fixes a profile isolation issue. Well-scoped (1 file, 125 additions, 17 deletions). No security issues or debug artifacts detected.

LGTM - awaiting maintainer approval.

@teknium1

Copy link
Copy Markdown
Contributor

Thanks for the focused profile-storage investigation. The cron premise is confirmed on current main: cron/jobs.py:64-96 captures profile paths at import time and runtime operations still consume those globals (cron/jobs.py:373-378, 731-789); cron/scheduler.py:2216-2231 also imports and uses import-time OUTPUT_DIR for context_from.

Problems

  • This draft is no longer scoped to its stated cron fix. gh pr diff 60882 --name-only shows 45 changed files, including the unrelated clarify hard gate, core conversation-loop changes, messaging adapters, desktop UI, and Windows relaunch code. In particular, the PR's agent/conversation_loop.py hunk adds synthetic assistant/user retry messages in a cache- and transcript-sensitive core path; that needs independent review.

Suggested changes

  • Keep the cron repair isolated to commits 4720c8737f11 and 1eb725cea7ab with their focused cron regressions.
  • Split commits 062d68761364, 77a566bc4c7c, and 0b2f279bd9b4 into separately scoped work.

Automated hermes-sweeper review.

@teknium1 teknium1 added sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit labels Jul 10, 2026
@teknium1 teknium1 added the area/profiles Multi-profile isolation, HERMES_HOME scoping label Jul 19, 2026
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 area/profiles Multi-profile isolation, HERMES_HOME scoping comp/cron Cron scheduler and job management P2 Medium — degraded but workaround exists sweeper:blast-broad Sweeper blast radius: broad — a core path most sessions hit sweeper:risk-caching Sweeper risk: may break/degrade prompt caching or cache-key stability (invariant) sweeper:risk-compatibility Sweeper risk: may break existing users, config, migrations, defaults, or upgrades sweeper:risk-message-delivery Sweeper risk: may drop, duplicate, misroute, or suppress messages sweeper:risk-security-boundary Sweeper risk: may affect sandboxing, auth, credentials, or sensitive data sweeper:risk-session-state Sweeper risk: may lose/corrupt/mis-associate session or context state type/bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants