Skip to content

fix(push): coerce equivalent schedules to the same value (#1119)#1155

Open
shahzad31 wants to merge 1 commit into
mainfrom
fix/schedule-coercion-1119
Open

fix(push): coerce equivalent schedules to the same value (#1119)#1155
shahzad31 wants to merge 1 commit into
mainfrom
fix/schedule-coercion-1119

Conversation

@shahzad31

Copy link
Copy Markdown
Contributor

Summary

Fixes #1119.

parseSchedule accumulated the duration into separate minutes and seconds buckets with inconsistent conversion:

  • a s value < 60 was added to seconds and then silently dropped by nearestSchedule whenever minutes were present
  • a s value >= 60 was instead Math.round-ed into minutes

As a result, two equal durations could coerce to different schedules:

parseSchedule('@every 1m59s'); // 1
parseSchedule('@every 119s');  // 2

This PR accumulates the whole duration as total seconds, then rounds to the nearest whole minute (breaking ties downward, so 2m30s stays at 2m and never overshoots the requested cadence) before matching against ALLOWED_SCHEDULES. Equivalent durations now always resolve to the same schedule.

Test plan

  • npx jest __tests__/push/monitor.test.ts -t "parse @every schedule format" passes
  • Added an assertion that @every 1m59s and @every 119s resolve to the same value, plus an explicit 119s -> 2 case
  • All pre-existing schedule assertions remain unchanged

Made with Cursor

parseSchedule accumulated minutes and sub-minute seconds in separate
buckets with inconsistent conversion, so equivalent durations such as
`@every 1m59s` and `@every 119s` resolved to different schedules.

Accumulate the whole duration as seconds and round to the nearest minute
(breaking ties downward) before matching against the allowed schedules.

Co-authored-by: Cursor <cursoragent@cursor.com>
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.

(push) Fix schedule coercion to allowed values

1 participant