Skip to content

fix(automations): repair cron step expansion and day restriction [HELD — semantic half] - #20202

Merged
nwparker merged 1 commit into
mainfrom
fix/cron-dialect
Sep 15, 2026
Merged

nwparker merged 1 commit into
mainfrom
fix/cron-dialect

Conversation

@nwparker

@nwparker nwparker commented Sep 12, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 4 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​279 $\color{#cf222e}{\Huge{\mathbf{−}}}$​1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​278
Prod 7 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​210 $\color{#cf222e}{\Huge{\mathbf{−}}}$​38 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​172

HELD — do not merge. This is the semantic half of the cron repair, split out of #20152 so the safe half could ship without waiting on this decision. It changes what already-saved user schedules do, in both directions. It needs an explicit owner sign-off, not a normal review pass.

#20152 merged as 8759b25e072. This branch is now rebased directly onto main, so its diff is exactly the semantic change and its Fixes trailers will auto-close on merge.

ELI5

Orca was misreading two kinds of cron schedule, so a schedule that said one thing was doing another.

If you asked for "every 15 minutes, starting at 5 past" (5/15 * * * *), Orca threw away the "every 15 minutes" part and ran it once an hour — four times less often than you asked. And if you combined a day-of-month with a day-of-week, Orca got confused about when to treat that as "either day" versus "only when both match", so those automations ran on the wrong days.

This fixes both. The catch: schedules you already saved will start running on a different cadence — that is the bug being fixed, but it is a real change that happens under you at upgrade. Some fire more often, some less. Schedules Orca itself created for you (Hourly, Daily, Weekdays, Weekly) are completely unaffected — only a hand-written "Custom cron" can change.

The two defects

These two cannot be split from each other

0 9 1/1 * 1, matching days over a 730-day window:

old parser = 124      #15723 alone = 104      #15723 + #15896 = 730

Shipping the step fix without the dialect fix produces a third behaviour matching neither, because the old cardinality-based day flags react to the corrected expansion. They ship together or not at all. #16303 and #15895 had no such dependency, which is why they are in #20152.

Declared dialect, and the vixie divergence

A day field is restricted iff no comma-term of it ranges over a star. So 1-31 and 1,15 restrict; *, */2 and */3,5 do not. When both day fields are restricted the day matches on either; otherwise on both.

This resolves an open question flagged during implementation. The original implementation used the stricter rule "restricted iff the field is not the literal *", which makes */2 restricted. That reading has real support — crontab(5) says:

If both fields are restricted (ie, are not *), the command will be run when either field matches the current time.

But vixie's own entry.c sets DOM_STAR/DOW_STAR from the field's first character, so vixie itself treats */2 as a star, contradicting its own man page. robfig/cron does the same and pins it in its test suite (parser_test.go:31 asserts */2 carries starBit).

We follow the implementations over the prose. Measured against robfig/cron v1.2.0, the stricter reading was the only source of disagreement, and it diverged badly in the over-firing direction:

Expression strict "not literal *" vixie / robfig
0 9 */2 * 1 246 days/yr 30 days/yr 8.2x over-fire
0 9 */1 * 1 424 days/yr (every day) 60 days/yr (Mondays) 7.1x over-fire

*/1 is also a regression against shipped Orca behavior — the old cardinality rule expanded it to 31 days and therefore already treated it as unrestricted (AND). Since Orca automations launch agents that consume tokens and create worktrees, silently firing a persisted */2 schedule 8x more often is the worst available failure mode.

Note the reported #15896 defect — 1-31 reading as unrestricted — is fixed either way; the two candidate rules agree on it.

One knowing divergence remains: the star test is applied per comma term, so 5,*/2 is unrestricted here and in robfig, while vixie's first-character test would call it restricted. Nobody writes that, and the per-term rule is explicable in one sentence where vixie's positional accident is not.

Verification

Differential proof against an independent oracle. Expectations were not computed with the code under test. robfig/cron v1.2.0 (Go) was driven as the oracle over 22 expressions x 424 days (2026-01-01..2027-02-28) plus 60 minutes each: zero divergences.

EXPRESSION          ORCA min          ORACLE min        min   ORCA days  ORACLE days  day
--------------------------------------------------------------------------------------------
5/15 * * * *        [5,20,35,50]      [5,20,35,50]      OK    424        424          OK
5-59/15 * * * *     [5,20,35,50]      [5,20,35,50]      OK    424        424          OK
*/15 * * * *        [0,15,30,45]      [0,15,30,45]      OK    424        424          OK
*/90 * * * *        [0]               [0]               OK    424        424          OK
5/90 * * * *        [5]               [5]               OK    424        424          OK
0 9 1-31 * 1        [0]               [0]               OK    424        424          OK
0 9 * * 1           [0]               [0]               OK    60         60           OK
0 9 1,15 * 1        [0]               [0]               OK    84         84           OK
0 9 1,15 * *        [0]               [0]               OK    28         28           OK
0 9 */2 * 1         [0]               [0]               OK    30         30           OK
0 9 */1 * 1         [0]               [0]               OK    60         60           OK
0 9 */2 * *         [0]               [0]               OK    216        216          OK
0 9 * MAY MON       [0]               [0]               OK    4          4            OK
0 9 * MAR/3 *       [0]               [0]               OK    122        122          OK
0 9 5/10 * *        [0]               [0]               OK    42         42           OK
0 9 * * 0           [0]               [0]               OK    61         61           OK
0 9 * * SUN         [0]               [0]               OK    61         61           OK
0 9 29 2 *          [0]               [0]               OK    0          0            OK
0 9 * * FRI         [0]               [0]               OK    61         61           OK
0 9 13 * 5          [0]               [0]               OK    72         72           OK
0 9 * JAN-MAR 1-5   [0]               [0]               OK    105        105          OK
0 9 1-31 * SUN      [0]               [0]               OK    424        424          OK

robfig/cron caps day-of-week at 6 and cannot express Sunday-as-7, so that class was anchored by equivalence against oracle-validated forms:

ORCA EXPR       ORACLE ANCHOR     days   verdict  meaning
0 9 * * 7       0 9 * * 0         61     MATCH   Sunday written as 7 == Sunday written as 0
0 9 * * SUN     0 9 * * 0         61     MATCH   Sunday written as a name == 0
0 9 * * 0-7     0 9 * * 0-6       424    MATCH   0-7 covers the whole week
0 9 * * 1-7     0 9 * * 0-6       424    MATCH   1-7 covers the whole week (7 aliases Sunday)
0 9 * * 5-7     0 9 * * 5-6,0     183    MATCH   Fri-Sun via the 7 alias

Real end-to-end scheduler run. The actual AutomationService was driven against a real Store with real JSON persistence, with a poison cron row sorted before a healthy one:

  persisted: A poison cron    rrule=0 9 32 * *   nextRunAt=2026-05-13T16:00:00.000Z
  persisted: B healthy cron   rrule=0 9 * * *    nextRunAt=2026-05-13T16:00:00.000Z

  console.error seen during the tick:
    [automations] failed to evaluate automation: 315ee119-... Error: Invalid cron day of month.

  IPC dispatches sent: 1
    -> automations:dispatchRequested  automation="B healthy cron" id=3d5f6d05-...

  A poison cron:
      status=skipped_unavailable    error=Orca could not evaluate this automation and skipped the occurrence.
  B healthy cron:
      status=dispatching            error=<none>

  VERDICT: healthy automation dispatched = true
  VERDICT: poison automation isolated    = true

DST / timezone, America/New_York, real boundaries:

== SPRING FORWARD: 2026-03-08 loses 02:00-03:00 ==   expression: 30 2 * * *
    fire #1: 2026-03-06 02:30 (UTC-5)
    fire #2: 2026-03-07 02:30 (UTC-5)
    fire #3: 2026-03-09 02:30 (UTC-4)     <- 03-08 correctly skipped
== FALL BACK: 2026-11-01 repeats 01:00-02:00 ==      expression: 30 1 * * *
    fire #1: 2026-11-01 01:30 (UTC-4)
    fire #2: 2026-11-01 01:30 (UTC-5)     <- both repeats fire, 1h apart
== STEPPED HOURS across spring forward ==            expression: 0 2/6 * * *
    2026-03-07 14:00 (UTC-5), 20:00 (UTC-5), 2026-03-08 08:00 (UTC-4), 14:00, 20:00, 03-09 02:00

Tests, oxlint, oxfmt --check and pnpm tc all pass (265 tests across the 29 affected files).

Why this changes when existing automations fire

Because the parser was misreading saved expressions. A schedule that said one thing was doing another. Correcting the reading necessarily changes the doing — there is no way to fix the misreading and leave the behaviour alone, because the behaviour was the misreading.

This is not a redefinition of cron. Nothing about the cron language changed. Orca is starting to obey what the user already wrote, the way every other cron implementation already does — verified against robfig/cron v1.2.0 across 22 expressions x 424 days with zero divergences.

Three expression shapes change. Nothing else does.

1. A value carrying a step — 5/15 (#15723)

What the user wrote "every 15 minutes, starting at :05"
What it did fired at :05 only — once an hour. The parser kept the start value and silently dropped the step.
What it does now fires at :05, :20, :35, :50
Which is what they asked for the new one. 5/15 means 5-59/15 in every cron implementation.

Same shape in any field: 9/4 (hours), 1/7 (day-of-month), MAR/3 (months), 1/2 (weekday).

2. A full range spelled out next to a specific weekday — 0 9 1-31 * 1 (#15896)

What the user wrote "9am, on days 1-31, on Mondays"
What it did Mondays only. The parser counted the expanded days, saw all 31, and concluded no day-of-month restriction had been given — so it required both conditions to match.
What it does now every day 1-31 or every Monday — so, every day
Which is what they asked for the new one. They did write a day-of-month restriction. Cron's rule is that when both day fields are restricted, either matching fires the job — that is what crontab(5) documents.

3. A stepped star in a day field next to a specific weekday — 0 9 */2 * 1 (#15896)

What the user wrote "9am, every other day, on Mondays"
What it did every other day or every Monday (~212 runs/year) — the parser counted 16 expanded days, saw 16 ≠ 31, and called it a restriction
What it does now every other day and Monday (~27 runs/year)
Which is what they asked for the new one. */2 is still a star: they asked for a stride across all days, not a list of particular days. vixie cron and robfig/cron both read it this way.

This is the only shape where the correction makes an automation fire less often, and it is the one worth reviewing by hand.

Schedules Orca created are not affected

All 256 expressions Orca's own preset builder can generate — Hourly, Daily, Weekdays, Weekly, across every hour/minute/weekday — were run through the drift detector: zero drift. Only a hand-written "Custom cron" expression in one of the three shapes above can change. A user who never opened the advanced cron field sees no change at all.

Detection shipped with this PR

describeAutomationScheduleDrift reads a saved expression under the pre-repair semantics and under the current ones and reports the ones that moved. It needs no second parser: pre-repair reading is reproduced by rewriting a bare stepped term to its value (5/15 -> 5) and deriving the day flags from set cardinality, then re-using the current parser. Cost is a parse plus a 730-day day-match walk — trivially affordable at startup.

It compares what a schedule fires, not how it parsed: the restriction flags move on several expressions whose firing days do not (0 9 * * 0-6, 0 9 */2 * *, 0 9 1-31 * *, 0 9 * * */2), and naming those would train the reader to ignore the report. Classification is tested against behaviour recorded from the real pre-repair build.

The service names each affected record once at startup. A user-visible one-time notice is tracked in #20195, which needs a persisted-UI-state field and copy across 7 locale catalogs.

⚠️ RELEASE MANAGERS AND REVIEWERS READ THIS FIRST — saved automations change when they run

This is not a pure bug fix. Automations users already saved will fire on a different schedule after upgrade, in both directions, with no migration and no prompt. Measured by running the same expressions through the real parent build and this branch:

Saved expression Was Now Change
5/15 * * * * ~8,760 runs/yr ~35,040 runs/yr 4× MORE
0 9 1-31 * 1 ~52 runs/yr ~365 runs/yr 7× MORE
0 9 1/7 * * ~12 runs/yr ~59 runs/yr ~5× more
0 9 */2 * 1 ~212 runs/yr ~27 runs/yr 7.9× FEWER
0 9 */3 * 1 ~161 runs/yr ~18 runs/yr 8.9× FEWER

Two distinct hazards, and the second is the one that will not get reported:

  1. Firing more often costs money. These automations launch agents. 4× the runs is 4× the token spend and, in new_per_run mode, 4× the worktrees — starting the moment a user upgrades.
  2. Firing less often fails silently. An automation that drops from 212 runs a year to 27 has stopped running most of the days it used to. Nobody notices a job that did not fire. There is no error, no failed run, no alert — the work just quietly stops happening.

Both behaviours are correct — the old readings were the bugs in #15723 and #15896, and preserving them would mean preserving the bugs. This section is not asking for a compatibility shim; it is asking for an explicit, informed sign-off that this is shipped knowingly.

What this PR does about it. Affected records are detected and named once at startup, so both directions are findable instead of silent:

[automations] 2 saved schedule(s) changed meaning when the cron parser was repaired; review them:
[automations]   "Every 15 minutes from :05" (87ca135b-...) "5/15 * * * *" now runs more: about 35040/year, was about 8760/year
[automations]   "Odd days and Mondays" (5dbee8dc-...) "0 9 */2 * 1" now runs fewer: about 27/year, was about 212/year

That is real output from the running app. Detection is exact about which schedules it names: it compares what a schedule fires, not how it parsed, because the day-restriction flags move on several expressions whose firing days do not change (0 9 * * 0-6, 0 9 */2 * *, 0 9 1-31 * *, 0 9 * * */2) — naming those would train people to ignore the report. The classification is tested against behaviour recorded from the real pre-repair build.

What it does not do: there is no in-product notice yet. That needs a persisted-UI-state field and copy across 7 locale catalogs, which is its own change — tracked in #20195, which already has the detector to build on.

Things a user will notice that are not in the table:

  • A schedule with an oversized step (*/90 * * * *, 0 */25 * * *, 0 9 * * */8) is now refused as new input. Already-saved ones keep running and stay editable, but an older client or script that submits one to an updated host gets a validation error where it previously succeeded.
  • 5/15-style schedules now read "Custom schedule" instead of "Hourly at :05". The old label was wrong, but it is a readability downgrade.
  • 0 9 */1 * 1 is unchanged — it fired on Mondays before and fires on Mondays now. An earlier draft of this description claimed otherwise; that was measured against an intermediate dialect that was overturned and never shipped.

Visual proof

Captured against the real Electron app via CDP on a hidden renderer (ORCA_BACKGROUND_LAUNCH=1), same seeded automations on both sides. The sidebar in each shot self-identifies the build.

#15723 in the automations list — parent 729491597f3 vs this branch

An automation saved as 5/15 * * * *, meaning "every 15 minutes starting at :05". On the parent, Orca labels it "Hourly at :05" and schedules the next run 36 minutes out. On this branch the same row is a genuine 15-minute cadence with the next run 3 minutes out. Both next-run values were computed by the build in the screenshot, not seeded.

Before — parent commit (sidebar: Detached HEAD @ 7294915)

proof-list-BEFORE.png

After — this branch (sidebar: fix/cron-parser)

proof-list-AFTER.png

Saved expression Parent This branch
5/15 * * * * "Hourly at :05", next run Sep 11 8:05 PM (in 36m) "Custom schedule", next run Sep 11 7:20 PM (in 3m)
0 9 */2 * 1 next run Sep 13 (a Sunday — OR) next run Sep 21 (a Monday — AND)
0 9 * * 1-5 "Weekdays at 9:00 AM", Sep 14 unchanged — "Weekdays at 9:00 AM", Sep 14

The middle row is the #15896 dialect change made visible: the same expression moves off Sunday and onto Monday.

Legacy oversized-step schedule stays editable

A row holding */90 * * * *, written into persistence directly to stand in for one saved by an older build. Opening it must not demand re-authoring a schedule that is still firing.

The first screenshot is the second commit of this PR, where the save gate was fixed but AutomationSchedulePicker still ran the strict validator directly — the field is red and reads "Enter a valid five-field cron before saving." This screenshot is what caught that gap; the unit tests had not. The third commit routes the picker through the same gate.

Before — red field, "Enter a valid five-field cron before saving."

proof-legacy-editor-BEFORE.png

After — normal field, status reads "Hourly at :00" (aria-invalid measured as true -> false)

proof-legacy-editor-fixed.png

Renaming that row was then exercised over the real automation.update RPC against the running app: updateOk: true, name changed, rrule still */90 * * * * — the strict AutomationSchedule param never rejects it, because the save transaction omits an unchanged rrule.

Gap, stated rather than papered over: the rename was driven through the RPC and through the gate's unit tests, not by typing into the editor's name field and clicking Save. I could not reliably drive that React input through CDP. What is proven in the real UI is that the editor opens with the schedule intact, raises no warning, and leaves Save Changes enabled (measured disabled: false).

Known limitation, pre-existing and not fixed here

nextAutomationOccurrenceAfter cannot advance past the second repeat of an ambiguous fall-back hour. floorToMinute decomposes to local wall-clock fields, and local 01:30 on a fall-back date maps to two instants; reconstruction picks the earlier (EDT) one, so the forward scan lands back on the EST repeat and returns the input unchanged. Because advanceAutomationNextRun computes nextRunAt from now, an automation scheduled inside the repeated hour can have nextRunAt <= now and re-fire once per tick until local time leaves that hour — roughly once a year, for schedules landing in 01:00-02:00 local.

This is pre-existing and untouched by this PR (the occurrence math changes by one comment; for 30 1 * * * the parsed sets are byte-identical before and after). It is now pinned by an explicit test so a future DST fix has to update it deliberately.

Tracked as #20154, which carries the full repro, the floorToMinute cause, the proof it is not a regression, and the policy question a fix must settle first (should a fall-back repeat fire once or twice?).

Fixes #15723
Fixes #15895
Fixes #15896
Fixes #16303

Fixes #15723
Fixes #15896

@pullfrog pullfrog Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

ℹ️ No code issues found — one release-sequencing note below.

Reviewed changes

This run reviewed the semantic half of the cron repair (diff against fix/cron-parser): the field parsing change, the day-restriction rule, schedule classification, and the new drift detector/report.

  • Open-ended N/step expansion — parseCronField now reads a bare value carrying a step as N-max/step in every field, so 5/15 expands to [5,20,35,50] instead of collapsing to [5] (src/shared/automation-cron-field-parsing.ts:112).
  • Lexical day restriction — isCronDayFieldRestricted decides restriction per comma term from the field text rather than from expanded set cardinality, and parseCronExpression uses it for both day fields (src/shared/automation-cron-field-parsing.ts:145, src/shared/automation-schedule-parsing.ts:115). A star step stays a star, so */1 and */2 do not flip the day rule to OR.
  • Occurrence and classification — the OR/AND branch is unchanged but now keyed off the lexical flags (src/shared/automation-cron-occurrence.ts:33), and classifyParsedCronSchedule derives hourly/daily labels from matched-day coverage and gates weekdays/weekly on !matchesEitherDayField (src/shared/automation-schedules.ts:91).
  • Startup drift report — describeAutomationScheduleDrift reconstructs the pre-repair reading and compares firing days plus clock sets; reportAutomationScheduleDrift logs each affected saved automation once from AutomationService.start() (src/shared/automation-schedule-drift.ts, src/main/automations/service.ts:114).
  • Tests — an independent hand-calendar oracle for the dialect, a drift corpus recorded from the parent build, and a report/spy test. I ran the five related files (48 tests) green and oxlint clean on all 11 changed files.

I independently checked the drift detector's pre-repair reconstruction against main:src/shared/automation-schedule-parsing.ts (which used end = start for a bare stepped value and cardinality-based day flags). The rewrite-then-reparse approach reproduces that parser exactly, so the detector's classification is faithful by construction, not only for the recorded corpus.

ℹ️ Persisted cadence changes while the user-visible notice is still deferred

The repair is correct, but it changes when already-saved custom cron schedules fire — up to roughly 4x more for 5/15-style steps, and roughly 8x fewer for */2-style day fields paired with a weekday — with no migration and no prompt. The only in-product mitigation in this PR is a console.warn at startup; the notice tracked in #20195 is not included. That is the author's release gate rather than a code defect, so no change is requested — flagging it only so the hold is lifted deliberately rather than by a routine review pass.

Technical details
# Deferred user-visible notice for persisted cadence changes

## Affected sites
- `src/main/automations/schedule-drift-report.ts:20` — the startup `console.warn` is the only signal; packaged builds surface it only in logs.
- `src/shared/automation-schedule-drift.ts:90` — detector is correct and already available for #20195 to build on.

## Required outcome
- Ship the semantic repair only with an explicit owner sign-off, and land #20195 (persisted-UI-state notice across 7 locale catalogs) for affected users.

Pullfrog  | Fix it ➔ | View workflow run | Using openrouter/deepseek/deepseek-v4.1-flash (free via Pullfrog for OSS) | 𝕏

@nwparker
nwparker changed the base branch from fix/cron-parser to main September 13, 2026 05:58
@nwparker nwparker closed this Sep 13, 2026
@nwparker nwparker reopened this Sep 13, 2026
@coderabbitai

coderabbitai Bot commented Sep 15, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

📝 Walkthrough

Walkthrough

The change updates cron parsing for bare stepped values and lexical day-field restrictions. Schedule classification now uses parsed day coverage with the corresponding OR or AND semantics. New drift detection compares current schedules with pre-repair interpretations over a 730-day scan. Automation startup reports affected schedules and their changed annual frequencies. Tests cover parsing, classification, drift detection, and warning output.

Priority: ➖ Normal

Severity of issue fixed: Medium

Merge Risk: 🔵 Low · up to daa2a

Startup drift reporting can regress silently without failing current service tests. Add a service-level assertion before merging.

🚥 Pre-merge checks | ✅ 3 | ❌ 2

❌ Failed checks (2 warnings)

Check name Status Explanation Resolution
Linked Issues check ⚠️ Warning #15723 is addressed. parseCronField expands a bare N/step to N-max/step and keeps bare N unchanged. The added tests cover these cases. #15896 is addressed. isCronDayFieldRestricted uses lexi… Implement scheduler isolation for #16303. Catch failures for each automation, record the failed run, advance or otherwise quarantine the failing schedule, and continue evaluating later automations. Ensure dispatch or precheck failures canno…
Docstring Coverage ⚠️ Warning Docstring coverage is 50.00% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 12 functions across 11 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the primary changes: cron step expansion and day-restriction semantics. The held semantic-change note is also relevant to the pull request.
Description check ✅ Passed The description is comprehensive and covers the change, rationale, linked issues, behavior impact, testing, visual proof, limitations, and release risk. Several template headings and checklist items a…
Out of Scope Changes check ✅ Passed The changed parser, schedule classification, drift reporting, and tests support #15723, #15895, and #15896. Startup drift reporting is directly related to the persisted schedule behavior changes. No u…
Full details: Linked Issues check

Explanation

#15723 is addressed. parseCronField expands a bare N/step to N-max/step and keeps bare N unchanged. The added tests cover these cases. #15896 is addressed. isCronDayFieldRestricted uses lexical star terms, and parseCronExpression passes those flags to day matching. The tests cover OR/AND behavior, full-range terms, stepped stars, and names. #15895 is addressed by retaining the input-time rejectOversizedStep gate while leaving the default parser path permissive for persisted rows. The tests cover unchanged legacy behavior for oversized steps. #16303 is not addressed. The service diff only adds startup drift reporting. It does not add per-automation failure isolation, failure recording, next-run advancement, or protection against a blocked inline dispatch starving later automations.

Resolution

Implement scheduler isolation for #16303. Catch failures for each automation, record the failed run, advance or otherwise quarantine the failing schedule, and continue evaluating later automations. Ensure dispatch or precheck failures cannot leave a run pending or block the scheduler tick.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 81215c0a-5bd5-4fd0-adea-74340d730813

📥 Commits

Reviewing files that changed from the base of the PR and between 99062ed and e5c9c49.

📒 Files selected for processing (11)
  • src/main/automations/schedule-drift-report.test.ts
  • src/main/automations/schedule-drift-report.ts
  • src/main/automations/service.ts
  • src/shared/automation-cron-dialect.test.ts
  • src/shared/automation-cron-field-parsing.ts
  • src/shared/automation-cron-occurrence.ts
  • src/shared/automation-schedule-drift.test.ts
  • src/shared/automation-schedule-drift.ts
  • src/shared/automation-schedule-parsing.ts
  • src/shared/automation-schedules.test.ts
  • src/shared/automation-schedules.ts

Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.

Comment on lines 116 to 122
void this.evaluateDueRuns()
}, this.tickMs)
this.completionWatcher?.reconcileRetainedRuns(this.store.listAutomationRuns())
reportAutomationScheduleDrift(this.store.listAutomations())
// Why: headless serve never gets a renderer-ready IPC, but due runs still
// need the same startup catch-up pass desktop gets after renderer attach.
if (this.rendererReady || this.headlessDispatcher) {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Add a service-level assertion for startup drift reporting. src/main/automations/service.test.ts calls AutomationService.start() but only asserts dispatch and persisted run state. schedule-drift-report.test.ts tests reportAutomationScheduleDrift directly. A regression that removes or moves the start() call can therefore pass the current service tests.

@nwparker
nwparker force-pushed the fix/cron-dialect branch 2 times, most recently from c3c4c68 to b2dccf2 Compare September 15, 2026 08:11
The semantic half of the cron repair. Both defects change what an already-saved
schedule does, so they ship together and behind a decision.

#15723: parseCronField set end = start for a bare numeric field even with a
slash step, so 5/15 expanded to [5] and fired hourly instead of every fifteen
minutes. N/step is the open-ended N-max/step sequence now.

#15896: day restriction came from expanded set cardinality, so 1-31 read as
unrestricted and */2 as restricted. Restriction is lexical now: a day field
restricts iff no term of it ranges over a star, matching vixie cron and
robfig/cron rather than crontab(5)'s prose. Verified differentially against
robfig/cron v1.2.0 across 22 expressions, 424 days, zero divergences.

The two cannot ship apart: 0 9 1/1 * 1 matches 124 days under the old parser,
104 under #15723 alone, and 730 under both, because the old cardinality flags
react to the corrected expansion.

describeAutomationScheduleDrift reads a saved expression under both semantics
and reports the ones that moved, so neither direction is silent; the service
names them once at startup. No expression Orca's own presets generate drifts.

Fixes #15723
Fixes #15896
@nwparker
nwparker merged commit e4a9d24 into main Sep 15, 2026
28 checks passed
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…blyai#20202)

The semantic half of the cron repair. Both defects change what an already-saved
schedule does, so they ship together and behind a decision.

stablyai#15723: parseCronField set end = start for a bare numeric field even with a
slash step, so 5/15 expanded to [5] and fired hourly instead of every fifteen
minutes. N/step is the open-ended N-max/step sequence now.

stablyai#15896: day restriction came from expanded set cardinality, so 1-31 read as
unrestricted and */2 as restricted. Restriction is lexical now: a day field
restricts iff no term of it ranges over a star, matching vixie cron and
robfig/cron rather than crontab(5)'s prose. Verified differentially against
robfig/cron v1.2.0 across 22 expressions, 424 days, zero divergences.

The two cannot ship apart: 0 9 1/1 * 1 matches 124 days under the old parser,
104 under stablyai#15723 alone, and 730 under both, because the old cardinality flags
react to the corrected expansion.

describeAutomationScheduleDrift reads a saved expression under both semantics
and reports the ones that moved, so neither direction is silent; the service
names them once at startup. No expression Orca's own presets generate drifts.

Fixes stablyai#15723
Fixes stablyai#15896
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment