Skip to content

fix(cron): preserve next-run wall times across offset changes - #24864

Closed
leonlaiyc wants to merge 1 commit into
kirodotdev:mainfrom
leonlaiyc:codex/cron-dst-preview-20261027
Closed

leonlaiyc wants to merge 1 commit into
kirodotdev:mainfrom
leonlaiyc:codex/cron-dst-preview-20261027

Conversation

@leonlaiyc

@leonlaiyc leonlaiyc commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Problem / Motivation

Goal: Cron-expression next-run timestamps keep their configured local wall time across timezone offset changes.

A daily 03:00 job in America/Los_Angeles inspected before the 2026 fall-back advertises 04:00 PST. The scheduler refuses that advertised instant because the expression names 03:00.

Why it matters

The Cron list and next timer boundary give an incorrect deadline around timezone transitions. The regular polling cap keeps execution running, but the displayed time is misleading.

Not a goal

What changed (motivation → approach → change)

The Cron list's next-run time and the scheduler's next boundary keep the time named in a cron expression across a timezone offset change. Croniter's aware calculation can shift an existing local occurrence twice. A shared helper in cron_service/schedule.py compares that result with the expression's wall-clock occurrence and selects the earlier valid instant. Both timestamp paths use it, including the skip-date search. The owning spec in docs/system-specs/modules/learn-cron-dashboard.md records the behavior.

Branch Result
No offset change Keep the aware iterator's result
Existing wall time across an offset change Use the wall-clock occurrence unless the aware result is valid and earlier
Missing wall time Keep the parser's resolution
Repeated hour Retain a valid earlier aware result and its chronological ordering

Backwards compatibility

Compatible: accepted expressions, saved jobs, due decisions, and polling limits retain their contracts. The parser's existing repeated/missing-hour choices remain in place.

Removes nothing: only an incorrect computed timestamp changes.

Tests

Proof: PROVEN test/test_cron_dst_previews.py::test_the_preview_and_boundary_name_the_configured_wall_time[America/Los_Angeles-2026-10-31T12:00-0 3 * * *-2026-11-01T03:00], test/test_cron_dst_previews.py::test_the_preview_and_boundary_name_the_configured_wall_time[America/New_York-2026-10-31T12:00-0 3 * * *-2026-11-01T03:00], test/test_cron_dst_previews.py::test_the_preview_and_boundary_name_the_configured_wall_time[America/Los_Angeles-2027-03-13T12:00-0 22 * * 1-5-2027-03-15T22:00], test/test_cron_dst_previews.py::test_the_preview_and_boundary_name_the_configured_wall_time[Australia/Lord_Howe-2026-04-04T12:00-0 3 * * *-2026-04-05T03:00], test/test_cron_dst_previews.py::test_the_preview_and_boundary_name_the_configured_wall_time[Australia/Lord_Howe-2026-10-03T12:00-0 3 * * *-2026-10-04T03:00] (head 81f6af8386d4)

  • 62 focused tests passed on final head 4e877d6; 126 including the determinism ratchet passed on the preceding e7e3413 integration: new DST cases, existing DST execution, wake-boundary, skip-date, failure-backoff and determinism-ratchet tests.

  • All 19 new cases passed five serial repetitions (95 passed). A four-worker shuffled cohort passed 61 tests with seed 24853.

  • Original related backend selection before this base integration: 34 failed, 15191 passed, 592 skipped, 1 xfailed, 908 warnings in 1414.64s (0:23:34). All 34 normalized failing node IDs match a fresh clean-main replay on base 2ec42c9. Zero new failing nodes; these Windows baseline failures are not represented as a passing suite.

  • All four planned frontend-related batches were executed: 14,916 tests passed, 1 failed, 1 skipped and 3 suites failed during collection; 529 test files passed and 4 failed. The same four files and exact error messages reproduce on clean main: three CRLF-sensitive fixture readers and the Xvfb-only capture test. The runner stopped after batch 3, so its remaining batch 4 was executed separately with the unchanged selector and worker environment (842 passed). These baseline failures were not changed or treated as passing.

  • On the e7e3413 validation tree, all 39 applicable static-profile commands passed, plus Black, isort, flake8, mypy (3,678 source files) and documentation lint. The unchanged CloudFormation template inputs passed cfn-lint 1.22.3 on the same base. Semgrep 1.78.0 scanned both changed Python files with 15 rules and zero findings. Frontend dependencies and Playwright setup are provisioned; frontend build/lint gates do not apply to this backend-only diff.

  • Independent local GPT review: no findings at 4e877d6; requested gpt-6.1-sol, served model unverified.

  • WARNING: the extracted Opus discovery and validation contracts were reviewed by an independent generic-model fallback because no Opus/Sonnet model is available locally. No surviving blocking candidate; this is not an executed Opus/Sonnet verdict. Served model unverified. Remote review remains authoritative.

  • One-time published base integration onto 33590d6 includes merged test(crew-log): drop the strict xfail on the warm-session savepoint guard #24774, which removes the obsolete warm-session strict xfail. The original Cron source and regression-test blobs are unchanged. Focused regressions passed on the final head. Fresh red/green proof, all 39 static checks and full Black/isort/Flake8/mypy/documentation checks passed on e7e3413 before the final base alignment; the three intervening upstream commits change no Cron code, tests, spec, review contract or rule file. The original patch blobs are identical; unchanged earlier broad baseline comparisons are historical evidence, not a claim that current full CI passed. Current exact-head GPT and independent reduced-fidelity generic-model review of the Opus contract report no findings; remote review remains authoritative.

  • Exact-head CI diagnostic (2026-10-28): the offline E2E job failed two assertions in capture-mcp-app-message-rows.mjs, for the queued dark scene's app attribution and visible message. This PR changes no frontend or harness source. A local Windows control using the unchanged frontend product/harness inputs from base e7e3413 reproduced those same queued-dark assertions (and four additional assertions); this is diagnostic evidence, not a passing CI claim. The Cron head is preserved; no E2E retry or unrelated source fix was made.

Manual verification

Fixed-zone examples exercise the real compute_next_run_ts, timer boundary and is_due functions across US spring/fall transitions and Lord Howe's half-hour changes. Returned timestamps are checked against explicit expected epochs. No live gateway was started.

Screenshots / video

N/A — backend timestamp computation; no frontend code or layout changes.

Related Issues

Closes #24853

The timestamp residual is explicitly excluded by merged #24718, which fixes the human-readable schedule label. This patch is independent of the interval/one-shot work in #24479 and the timer retry work in #24409.

Sibling sweep

Swept: git grep -nE 'croniter(|get_next(' -- src/kiro_crew/cron_service

Sibling: src/kiro_crew/cron_service/schedule.py -- changed here

Both _next_cron_boundary_ts and _compute_next_run_ts_raw use the shared helper. _humanize_cron already iterates from the naive job wall clock. _cron_occurrence_ts uses get_prev only to identify one occurrence across adjacent minutes; the existing DST execution regressions pass.

Pattern harvest

Rule candidate: review-prompt
Pattern: A timezone-aware recurrence calculation must be checked against the configured wall time across offset transitions; a dependency can adjust an already-correct instant a second time.

Checklist

  • One commit with a Conventional Commits title
  • Change-related tests and regression proof pass
  • Self-review and independent local review completed
  • Owning spec updated
  • No secrets, credentials, or internal references in the diff

Contribution License Agreement

Contributed under the project's Apache-2.0 license.

@leonlaiyc
leonlaiyc requested review from a team and KiroCrewCaptain as code owners October 27, 2026 11:07
@github-actions github-actions Bot added fork Pull request from a fork (external contributor) readiness: checking Automated validation is still running labels Oct 27, 2026
@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

UX Review (Opus 5.5, fork) — ⏭️ skipped

Revision 4e877d69a9878011d4cf4bd7e3cdbefd9819f713 touches no user-facing surface (no changes under website/ or committed screenshots), so the UX review was skipped. Does not block merge.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

First Principles Review (Opus 5.5, fork) — ✅ PASS

Premise-level review of 4e877d69a9878011d4cf4bd7e3cdbefd9819f713 via the fork AI-review pipeline — why this exists and whether the shipped surface is the smallest honest version. Updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

First-Principles-Verdict: PASS

Nothing blocks. One new helper wraps both croniter call sites in cron_service/schedule.py that advance an aware iterator. The fix lands where the wrong timestamp is computed, and no sibling call site is left unfixed.

Notes

  • Item 1 — symptom-level, cause out of scope: the fix works around croniter's aware DST double-shift ("croniter's aware result can include an extra DST adjustment") instead of fixing croniter itself. The Goal's ## Not a goal excludes changing dependency versions, so this is acceptable.

What this change ships

Inventory (4 items) — 3 justified

Intent: the Cron list and the scheduler should show and use the configured local wall time for a cron job's next run, even across a DST or offset change. This is a FIX (#24853).

  1. Next-run time in the Cron list shows the configured wall time (03:00, not 04:00) across a timezone offset change — symptom-level, works around a croniter defect
  2. The scheduler's next timer boundary uses the same corrected instant — justified
  3. A skip-date search that crosses a transition keeps the configured wall time — justified
  4. The cron spec records the wall-time retention behavior — justified

[FIRST-PRINCIPLES-REVIEWED] 4e877d6

Description read

[DESCRIPTION-READ] 9a367610fee740d293bf8e64959ec47d8c64ee9db7fb789d8ed09c88eebbf5c4

That sha256 names the PR description this verdict read. Recompute it with .github/scripts/pr-description-capture.sh; if it differs, the description changed after this verdict was formed and any finding drawn from the description is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Design Review (Opus 5.5, fork) — ✅ PASS

Design-level review of 4e877d69a9878011d4cf4bd7e3cdbefd9819f713 via the fork AI-review pipeline — updated in place on each push. A BLOCK verdict blocks PR readiness; PASS does not.

Design-Verdict: PASS

Nothing blocks: the fix is a single shared helper on both next-run paths, it takes nothing away, and it renders nothing new.

Notes

  • _next_cron_epoch works around croniter's double DST shift rather than fixing the cause. If a croniter upgrade fixes that shift, the naive candidate should equal the aware result and the helper becomes a no-op, but no test pins croniter's current behaviour. Name the croniter version or issue in the docstring so a later reader knows when the helper can be deleted.

[DESIGN-REVIEWED] 4e877d6

Description read

[DESCRIPTION-READ] d72b095738668323db1f1e1da772a4c5ccbe19cb5ab7b9b4be8f9211e7f2ad21

That sha256 names everything this verdict read: the PR description, plus the 1 evidence file(s) the workflow collected from it and handed this review. It covers that evidence because the media strip replaces every attachment URL with the same placeholder, so an edit swapping one attachment for another would leave the description's captured text identical while what this review judged changed. Recompute it with .github/scripts/pr-description-capture.sh over the same inputs; if it differs, the description or that evidence changed after this verdict was formed and any finding drawn from either is unproven.

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

GPT 6.1 Review (fork) — ✅ no blocking findings

Reviewed 4e877d69a9878011d4cf4bd7e3cdbefd9819f713 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.
[GPT-REVIEWED] 4e877d6

@github-actions

github-actions Bot commented Oct 27, 2026 •

Copy link
Copy Markdown
Contributor

Opus 5.5 Review (fork) — ✅ no blocking findings

Reviewed 4e877d69a9878011d4cf4bd7e3cdbefd9819f713 via the fork AI-review pipeline; updated in place on each push.

Review details

No findings.

[OPUS-REVIEWED] 4e877d6

@github-actions github-actions Bot added readiness: action required A blocking check or review needs attention and removed readiness: checking Automated validation is still running labels Oct 27, 2026
@leonlaiyc
leonlaiyc force-pushed the codex/cron-dst-preview-20261027 branch from 9941895 to 4e877d6 Compare October 28, 2026 02:37
@github-actions github-actions Bot added readiness: checking Automated validation is still running readiness: action required A blocking check or review needs attention merge conflict Branch has merge conflicts with its base — author must resolve before merge and removed readiness: action required A blocking check or review needs attention readiness: checking Automated validation is still running labels Oct 28, 2026
@bolichen97

Copy link
Copy Markdown
Contributor

[operator: bolichen97] Continuing this in #32403; thanks for the start.

bolichen97 added a commit that referenced this pull request Nov 7, 2026
…#32403)

A cron job's advertised next run and its timer boundary were computed
by handing croniter an aware start in the job's zone. croniter 2 then
shifts any run that lies past a DST change by the offset change a
second time: a 03:00 job read 04:00 PST the day before the fall-back,
a 22:00 job 21:00 PDT the day before the spring-forward, and is_due
refused the advertised instant.

Step the zone's naive wall clock instead and attach the zone to the
result, as the schedule label already does. A repeated wall time whose
first instant is not after now takes its second; a spring-forward gap
resolves as fold=0 does, as before.

Builds on #24864.

Closes #24853
buluoray pushed a commit that referenced this pull request Nov 7, 2026
…#32403)

A cron job's advertised next run and its timer boundary were computed
by handing croniter an aware start in the job's zone. croniter 2 then
shifts any run that lies past a DST change by the offset change a
second time: a 03:00 job read 04:00 PST the day before the fall-back,
a 22:00 job 21:00 PDT the day before the spring-forward, and is_due
refused the advertised instant.

Step the zone's naive wall clock instead and attach the zone to the
result, as the schedule label already does. A repeated wall time whose
first instant is not after now takes its second; a spring-forward gap
resolves as fold=0 does, as before.

Builds on #24864.

Closes #24853

(cherry picked from commit 83ec532)
@iamwhatever

Copy link
Copy Markdown
Contributor

Thank you for this work! As noted in the thread, it continued in #32403, which has now merged. Closing this one as superseded by #32403.

@iamwhatever iamwhatever closed this Nov 8, 2026
@github-actions github-actions Bot removed the readiness: action required A blocking check or review needs attention label Nov 8, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fork Pull request from a fork (external contributor) merge conflict Branch has merge conflicts with its base — author must resolve before merge

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Cron next-run timestamps shift off the configured wall time across DST

3 participants