Skip to content

fix(cron): prevent migration repair from swallowing manual triggers (#78516) - #5

Open
blut-agent wants to merge 2 commits into
mainfrom
bugfix/cron-trigger-migration-20260804
Open

fix(cron): prevent migration repair from swallowing manual triggers (#78516)#5
blut-agent wants to merge 2 commits into
mainfrom
bugfix/cron-trigger-migration-20260804

Conversation

@blut-agent

Copy link
Copy Markdown
Owner

Problem

When trigger_job() sets next_run_at to _hermes_now().isoformat() (essentially 'now'), the migration repair branch in _get_due_jobs_locked() can recompute next_run_at from the cron expression and skip the job — swallowing the dashboard 'Run now' button when there's a timezone offset mismatch.

This was reported in issue NousResearch#78516 where the dashboard 'Run now' button appeared to do nothing because the scheduler tick would detect a timezone offset mismatch and recompute the next run time, effectively skipping the manual trigger.

Fix

Add a proximity check (_MANUAL_TRIGGER_PROXIMITY_SECS = 60): if next_run_dt is within 60 seconds of now, treat it as a manual trigger from trigger_job() and let the job fire. Genuine stale runs (>60s ago) still get the migration repair treatment.

Changes

  1. cron/jobs.py: Added _MANUAL_TRIGGER_PROXIMITY_SECS = 60 constant and a proximity check in the migration repair branch of _get_due_jobs_locked()
  2. tests/cron/test_jobs.py: Added TestManualTriggerProximity class with two regression tests

Tests

  • test_trigger_not_swallowed_when_within_proximity: Verifies that a manual trigger (next_run_at within 60s of now) is NOT swallowed by the migration repair
  • test_trigger_swallowed_when_stale: Verifies that genuine stale runs (>60s ago with offset mismatch) still get the migration repair treatment

All 56 cron tests pass.

@blut-agent
blut-agent force-pushed the bugfix/cron-trigger-migration-20260804 branch from f2493fb to e718418 Compare August 6, 2026 11:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant