Repository navigation
Count a docket-rs Cron run's next match from its start, and parse as pydocket does - #548
Conversation
…pydocket does docket-rs's `Cron` computed the next match when a run ended, so a run still going at its next match skipped it, where pydocket runs it as soon as the run ends. docket-rs also accepted five kinds of expression that pydocket refuses: a field for the year, `?`, a `W` other than `LW`, and dates or weekdays that never match, which it accepted and then never ran. The next match now counts from when the run started, which `PerpetualControl` records, and `Cron::new` refuses what pydocket's parser refuses. `conformance/cron-expressions.json` lists 53 expressions, each with its first match after one instant or `null` for a refusal, and both languages' tests read it. The overlap has a test in each language: a run of 1.5 s under `* * * * * *` is followed by the run due one second after it. It has no conformance scenario, because a cron's slots are at least a second apart and a useful overlap scenario would run for minutes. Closes #546 Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Y2QtufEUxxm9XgTqCWySHG
Codex Review SummaryThis comment shows the latest Codex review activity on this pull request.
ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings. |
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: 182f83325e
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| } else if day_of_month.is_some_and(|day| day.contains('W') && day != "LW") { | ||
| Some("its day of the month uses W, other than LW") |
There was a problem hiding this comment.
Make the W rejection case-insensitive
For lowercase special syntax such as 0 0 15w * *, cronsim uppercases fields before parsing and rejects it just like 15W, while croner accepts lowercase cron syntax; this raw, case-sensitive check therefore lets the Rust expression through. Normalize the day-of-month field before checking W so the promised parser parity also covers casing variants.
Useful? React with 👍 / 👎.
| # docket-rs's tests read the same table, so both implementations accept and | ||
| # refuse the same expressions, and find the same next match for each one. | ||
| CRON_TABLE = json.loads( | ||
| (Path(__file__).parents[3] / "conformance" / "cron-expressions.json").read_text() | ||
| ) |
There was a problem hiding this comment.
Move the exhaustive parser cases out of fundamentals
The shared 53-expression acceptance/refusal table is exhaustive parser compatibility and error-condition coverage rather than a newcomer-facing happy path. Keeping these parametrizations in tests/fundamentals makes the living-documentation suite depend on a large external fixture and directly conflicts with its prescribed scope; move them to a regular cron test module while retaining the concise overlap example here.
AGENTS.md reference: python/tests/fundamentals/AGENTS.md:L144-L147
Useful? React with 👍 / 👎.
… findings (#562) An adversarial review of the changes since python/v0.26.2 and rust/v0.2.0 found these problems. The fixes follow this order: pydocket's compatibility with 0.26.2 first, then docket-rs behaving as pydocket does, then correctness in each. pydocket and the shared scripts: - `clear()` (#536) ran as one Lua script, so a large docket blocked every other Redis client. At 500k tasks, Redis answered `BUSY`. `clear.lua` now clears at most 1000 queue entries and 1000 stream messages per call, and `clear()` calls it until a call clears less than a full batch. Each task is still read and cancelled in one call. With 100k tasks the worst ping during a clear drops from 1215 ms to 62 ms. A worker can start a task between two batches, and the docstrings say so. - A retry that a replace superseded (#554) published a `failed` state on the key, so `get_result()` on the replacement returned `None` in pydocket, and the old run's error in docket-rs. `terminal.lua` now publishes nothing for an empty payload, and only that retry path sends one. - #554 made a missing runs hash refuse a Retry or Perpetual reschedule. An eviction, or a 0.26.2 `clear()` during a rolling upgrade, removes the hash of a running task, so that retry or Perpetual chain ended where 0.26.2 went on. `schedule.lua` goes back to 0.26.2's rule. One case that #554 fixed comes back with it: with `execution_ttl=0`, a replacement that already finished lets the old run retry, or reschedule its Perpetual, with its old arguments. 0.26.2 behaves the same way. - `--dependencies ""` (#551) crashed the worker. It now means no dependencies, as an empty `--fallback-task` means no fallback task. docket-rs: - On Redis 6.2, an `OOM` inside a script arrives as `ERR ... -OOM ...`, so #559 took it for one run's error, and the worker read every ready task into its pending list. That text now ends the session, as the `OOM` code does. - #547 failed a task with a missing field under a `RateLimit`, `Cooldown`, or `Debounce`. pydocket runs it and counts the field as `None`, so docket-rs counts it as `null`. `ConcurrencyLimit` still fails it, as in pydocket. - `admit` now runs every admission hook, as pydocket enters every dependency. A block wins over a failure, and after a failure only, the admitted hooks release as a run that ran, so a `RateLimit` keeps its call. - #548 refused day lists that hold `LW`, such as `15,LW`, and accepted a lowercase `15w`. It also joined the two day fields with OR when one starts with `*`, where pydocket uses AND. Nine new rows in `conformance/cron-expressions.json` cover these. - The cluster retry docs said that the defaults ride out a failover. The 10 retries wait about 5 seconds at most, less than a failover takes. Two behaviors stay as they are and match pydocket. A `Cooldown` after a `ConcurrencyLimit` that parked the task still sets its cooldown, so the parked task is dropped when it wakes; that is worth a pydocket issue. A `per_field` name with a typo on a docket-rs `RateLimit`, `Cooldown`, or `Debounce` now counts every task under one `null` key instead of failing them. 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01Y2QtufEUxxm9XgTqCWySHG --------- Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
docket-rs's
Croncomputed the next match when a run ended, so a run still going at its next match skipped it, where pydocket runs it as soon as the run ends. docket-rs also accepted five kinds of expression that pydocket refuses: a field for the year,?, aWother thanLW, and dates or weekdays that never match, which it accepted and then never ran.The next match now counts from when the run started, which
PerpetualControlrecords, andCron::newrefuses what pydocket's parser refuses.conformance/cron-expressions.jsonlists 53 expressions, each with its first match after one instant ornullfor a refusal, and both languages' tests read it. The overlap has a test in each language: a run of 1.5 s under* * * * * *is followed by the run due one second after it. It has no conformance scenario, because a cron's slots are at least a second apart and a useful overlap scenario would run for minutes.Closes #546
Session context
The second of the gap issues. Probing both parsers with the same expressions showed that they agree on six fields (seconds first) and on joining a day of the month and a day of the week with OR, and differ only where croner accepts what cronsim refuses. pydocket is the spec, so docket-rs refuses those too. The maintainer ruled out a conformance scenario for the overlap, because it would take minutes; the shared table checks the grammar in both languages instead. It sits in
conformance/and the Rust test reads it withinclude_str!, which compiles only for tests, socargo publishstill builds. Tests came first: the Rust table test listed eight differences and the overlap test saw a two-second gap before the fix. Locally, the Rust workspace passes on memory and on a real Redis 8, clippy is clean, the Python suite passes on Redis 8.10 at 100% coverage, and prek passes.🤖 Generated with Claude Code
https://claude.ai/code/session_01Y2QtufEUxxm9XgTqCWySHG