Skip to content

Add minutely recurrence period to cron --period syntax (SYN-11090)#4986

Merged
infime merged 4 commits into
masterfrom
SYN-11090
Jul 16, 2026
Merged

Add minutely recurrence period to cron --period syntax (SYN-11090)#4986
infime merged 4 commits into
masterfrom
SYN-11090

Conversation

@infime

@infime infime commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Problem

_parsePeriod (synapse/lib/stormtypes.py) only accepted yearly/hourly/daily/weekly/monthly, so there was no way to create or modify a minute-recurring cron job (incunit=minute, i.e. "run every N minutes") through $lib.cron.add(period=...) or $lib.cron.mod(period=...). Such jobs could previously only be created via the deprecated increment kwargs ($lib.cron.add(minute='+N'), EOL v3.0.0), and existing/migrated minute jobs could not have their schedule modified at all.

Change

Add a minutely[/N] periodicity to the --period grammar:

  • minutely -> incunit='minute', incval=1, empty reqdict
  • minutely/N -> every N minutes (via the existing _parseIncval, matching hourly/daily semantics)
  • A @time specifier is rejected (BadConfValu) since minute is the smallest unit
  • Out-of-range N is rejected by the existing ApptRec bounds (1 <= N <= 2_592_000)

No agenda.py change is needed; the data model already supports TimeUnit.MINUTE. Both cron.add and cron.mod funnel through _parsePeriod, so both are covered. Help text (addcrondescr/modcrondescr) updated; the command reference is auto-generated from it.

Tests

synapse/tests/test_lib_agenda.py: positive add cases (minutely, minutely/5), mod + round-trip (minutely/10 -> hourly -> minutely), and sad paths (minutely@:30, minutely/newp, minutely/0).

Test plan

  • python -m pytest synapse/tests/test_lib_agenda.py -v
  • ruff check synapse/lib/stormtypes.py synapse/lib/storm.py synapse/tests/test_lib_agenda.py

_parsePeriod only supported yearly/hourly/daily/weekly/monthly, so there
was no way to create or modify a minute-recurring cron job (incunit=minute)
via $lib.cron.add(period=...) / $lib.cron.mod(period=...).

Add a 'minutely[/N]' periodicity that yields incunit='minute', incval=N
(default 1), with an empty reqdict. A time-of-day specifier is rejected
since minute is the smallest unit. incval bounds are enforced by ApptRec.
@codecov

codecov Bot commented Jul 9, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.79%. Comparing base (3e403e7) to head (20eb4b9).

Additional details and impacted files
@@           Coverage Diff           @@
##           master    #4986   +/-   ##
=======================================
  Coverage   97.79%   97.79%           
=======================================
  Files         301      301           
  Lines       64345    64356   +11     
=======================================
+ Hits        62924    62935   +11     
  Misses       1421     1421           

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

…N-11090)

- Reject a time specifier on a minutely period before parsing it, so
  'minutely@blorp' reports the intended error instead of 'Invalid hour value'.
- Fix the hourly invalid-increment message to actually interpolate the value
  (missing f-string prefix).
@infime
infime requested review from OCBender and vEpiphyte July 10, 2026 14:30
@vEpiphyte vEpiphyte added this to the v2.248.0 milestone Jul 14, 2026
@infime
infime merged commit 5b2d1e0 into master Jul 16, 2026
6 checks passed
@infime
infime deleted the SYN-11090 branch July 16, 2026 17:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants