Claude Sonnet 5.5 (effort default (no --effort flag) · thinking on) on Fix a cron next-fire-time calculator (steps, names, macros, day-of-month OR day-of-week, leap days, strict validation)
AClaude Sonnet 5.5default · thinking on · Claude Code 2.1.299 (headless -p) · cloud · 2026-10-19 · by @bobsiopener
- Estimated cost
- $0.07
- Wall time
- 22s
- Human step-ins
- 0
- Outcome
- Pass
Compare with other models on this task →
Summary
Exact prompt
# Task: fix the cron schedule calculator `cron.py` has a function `next_fire(expr, after)` that should return the next time a cron schedule fires, but it gets many schedules wrong and is too slow for rare schedules. Fix it (rewrite freely) so it follows every rule below exactly. Python standard library only. Keep the function name and signature. No network. ## Rules 1. `expr` has exactly 5 whitespace-separated fields: minute (0-59), hour (0-23), day-of-month (1-31), month (1-12), day-of-week (0-7, where both 0 and 7 mean Sunday, 1 = Monday ... 6 = Saturday). Leading/trailing whitespace and multiple spaces between fields are allowed. 2. Each field is a comma-separated list of items. An item is `*`, a number `n`, a range `a-b` (inclusive, requires a <= b), or any of those followed by `/step` (step >= 1): `*/s` = every s-th value starting at the field minimum, `a-b/s` = a, a+s, ... up to b, and `a/s` = a, a+s, ... up to the field maximum. 3. Month names `JAN`-`DEC` and day names `SUN`-`SAT` may be used anywhere a number may be used in the month and day-of-week fields (including in ranges, e.g. `MON-FRI`), case-insensitive. 4. Macros (case-insensitive) replace the whole expression: `@yearly` and `@annually` = `0 0 1 1 *`, `@monthly` = `0 0 1 * *`, `@weekly` = `0 0 * * 0`, `@daily` and `@midnight` = `0 0 * * *`, `@hourly` = `0 * * * *`. 5. Day matching: if BOTH day-of-month and day-of-week are restricted (the field text is not exactly `*`), a day matches when EITHER field matches. If only one of them is restricted, only that one counts. A field like `*/1` or `1-31` counts as restricted. 6. `after` is a naive `datetime`. Return the earliest matching minute STRICTLY after `after`, as a naive `datetime` with seconds and microseconds 0. (If `after` is 10:00:30 and the schedule fires every minute, the answer is 10:01:00.) No time zones, no DST: treat times as plain calendar times. 7. Raise `ValueError` for: wrong number of fields, unknown macro, any value outside the field's range, `a > b` in a range, step 0 or a non-numeric step, empty items (e.g. `1,,2`), unknown names, or any other unparsable text. 8. If the schedule can never fire within 5 years after `after` (e.g. `0 0 31 2 *`), raise `ValueError` instead of looping forever. A schedule that fires only on 29 February must still be found (it is at most ~4 years away). 9. Every call must return (or raise) within 1 second on an ordinary machine, including the leap-day case. The grader runs a hidden unittest suite that checks exactly these rules.
The starting code ANDs day fields, ignores names/macros/7=Sunday, is inclusive of 'after', accepts invalid fields and scans minute by minute (too slow / never terminates for rare schedules). Each rule has exact expected datetimes. Original benchmark task written for usecaserank.com (not based on a specific public post). Headless, offline run on a reproducible fixture. Each run's notes say how its cost was measured (estimates are marked).
Success criteria: 1. All 8 hidden unittest cases pass (strictly-after semantics, lists/ranges/steps incl. a/s, month/day names, 0 and 7 = Sunday, macros, DOM/DOW OR rule incl. */1 as restricted, 18 invalid expressions raise ValueError, never-firing schedule raises within 1 s, 29 Feb found within 1 s).
Setup notes: Use Case Scout batch 7 case g01-cron-next-fire (offline fixture). Prepared with batch7/prepare.sh; hidden key/tests kept outside the agent's work dir. Prompt = TASK.md verbatim. Scored with the scout's scorer: `python score.py WORKDIR KEYDIR`. Tools: Read/Write/Edit/Glob/Grep/Bash, web disabled. Single run, no retries. Claude Code's own reported cost for claude-sonnet-5.5: $0.071293. Score: 8/8. Cost is an ESTIMATE: measured tokens x pricing.json list price (Claude Pro subscription, nothing billed); input_tokens include cache reads and writes. Single run.
Estimated cost List-price estimate; not actually billed.
Metrics
- Estimated cost
- $0.07
- Wall time
- 22s
- Human step-ins
- 0
- Turns
- 3
| Model | Input tok | Output tok | Cost |
|---|---|---|---|
| AClaude Sonnet 5.5anthropic/claude-sonnet-5.5effort default (no --effort flag) · thinking on | 60,044 | 2,923 | $0.07 |
Reproduce this run
- Use the use case prompt on the use case page.
- Same setup: Claude Sonnet 5.5 (anthropic/claude-sonnet-5.5, effort default (no --effort flag) · thinking on) via
Claude Code 2.1.299 (headless -p), cloud. - It counts as a success only if it meets every success criterion: 1. All 8 hidden unittest cases pass (strictly-after semantics, lists/ranges/steps incl. a/s, month/day names, 0 and 7 = Sunday, macros, DOM/DOW OR rule incl. */1 as restricted, 18 invalid expressions raise ValueError, never-firing schedule raises within 1 s, 29 Feb found within 1 s).
- Log model, tokens, wall time, human step-ins and the evidence log, then submit it as a reproduction. A different model? Submit a head-to-head rerun.
How runs are scored: Methodology.
Was this useful?
Automated checks
Trust 80% comes from these checks (how Trust % works).
- Run date is not in the future : passed
- Model is in the dated pricing table : passed
- Cost recomputed from tokens matches : passed
- Cached tokens are consistent : passed
- Output throughput is plausible : passed
- Autonomy matches step-ins : passed
- Step-ins do not exceed turns : passed
- Retries agree with first-try result : passed
- Evidence log SHA-256 matches : passed
- Evidence log is substantial : passed
Evidence log
[
{
"duration_api_ms": 20509,
"stop_reason": "end_turn",
"session_id": "[REDACTED]",
"total_cost_usd": 0.0712935,
"usage": {
"input_tokens": 6,
"cache_creation_input_tokens": 9243,
"cache_read_input_tokens": 50795,
"output_tokens": 2923,
"output_tokens_details": {
"thinking_tokens": 705
},
"server_tool_use": {
"web_search_requests": 0,
"web_fetch_requests": 0
},
"service_tier": "standard",
"cache_creation": {
"ephemeral_1h_input_tokens": 9243,
"ephemeral_5m_input_tokens": 0
},
"inference_geo": "global",
"iterations": [
{
"input_tokens": 2,
"output_tokens": 515,
"cache_read_input_tokens": 19395,
"cache_creation_input_tokens": 2387,
"cache_creation": {
"ephemeral_5m_input_tokens": 0,
"ephemeral_1h_input_tokens": 2387
},
"type": "message"
}
],
"speed": "standard",
"fallback_credit": null
},
"modelUsage": {
"claude-sonnet-5-5": {
"inputTokens": 6,
"outputTokens": 2923,
"cacheReadInputTokens": 50795,
"cacheCreationInputTokens": 9243,
"webSearchRequests": 0,
"costUSD": 0.0712935,
"contextWindow": 1000000,
"maxOutputTokens": 128000,
"thinkingTokens": 705,
"canonicalModel": "claude-sonnet-5-5",
"provider": "firstParty",
"costBasis": "list"
}
},
"permission_denials": [],
"terminal_reason": "completed",
"fast_mode_state": "off",
"fast_mode_disabled_reason": "sdk_opt_in_required",
"subagent_stats": {
"spawned": 0,
"requested": {
"background": 0,
"foreground": 0,
"unset": 0
},
"started_in_background": 0,
"max_depth": 0,
"spawned_by_subagents": 0,
"completed": 0,
"failed": 0,
"killed": {
"parent": 0,
"user": 0,
"system": 0
},
"refused": {
"depth_limit": 0,
"concurrency_limit": 0,
"budget": 0
},
"by_type": {}
},
"safety_stops": 0,
"is_error": false,
"num_turns": 3,
"subtype": "success",
"api_error_status": null,
"result": "I rewrote `next_fire` in `cron.py`, keeping the name and signature. I only ran a handful of spot checks, not a full test suite, and they gave the expected results:\n\n- `0 0 29 2 *` from 2026-10-19 returns 2028-02-29 00:00.\n- `*/15 9-17 * * MON-FRI` from 10:00:30 returns 10:15.\n- `@weekly` returns the next Sunday at midnight.\n- `0 0 1 1 5-7` returns 2027-01-01.\n- `0 0 31 2 *` raises `ValueError`.\n\nHow it works:\n\n- **Parsing:** it handles all the field syntax, names, macros and `ValueError` cases from the rules. Numbers must be plain ASCII digits, so `+1` or a unicode digit is rejected. Day-of-week 7 is folded to Sunday (0), so `5-7` works.\n- **Search:** it walks forward one day at a time and checks the month and day rules. The either/or rule applies only when both day fields are something other than a literal `*`. On a matching day it takes the earliest listed hour and minute strictly after `after`. That is at most about 1,830 day checks, so rare schedules and the leap-day case return well inside the one-second limit.\n- **Never-firing schedules:** if nothing matches within five years of `after`, it raises `ValueError`.\n\nI did not time the calls or exercise every error case.",
"ttft_ms": 1903,
"type": "result",
"duration_ms": 21000,
"uuid": "[REDACTED]",
"ttft_stream_ms": 1367,
"time_to_request_ms": 387,
"first_content_frame_ms": 1368,
"queued_turn_count": 0,
"result_index": 0
}
]