Skip to content

fix: improve cron runtime observability and deterministic sleep calculation#5

Merged
YspCoder merged 1 commit intomainfrom
codex/review-recent-commits
Feb 15, 2026
Merged

fix: improve cron runtime observability and deterministic sleep calculation#5
YspCoder merged 1 commit intomainfrom
codex/review-recent-commits

Conversation

@YspCoder
Copy link
Copy Markdown
Owner

Motivation

  • Surface and preserve store persistence failures instead of discarding them so runtime operators can detect and react to saveStore errors.
  • Make nextSleepDuration(now time.Time) deterministic by respecting the provided now argument, which fixes a semantics mismatch and improves testability.
  • Add a regression test to lock in the deterministic sleep behavior.
  • No skills were used for this change because it is a focused code repair to the cron runtime.

Description

  • Add lastSaveError string to CronService to hold the most recent saveStore error.
  • Update mutation paths that previously ignored saveStore errors (checkJobs, removeJobUnsafe, EnableJob) to set or clear lastSaveError based on the result of saveStore.
  • Expose lastSaveError in CronService.Status() to make persistence failures observable via the status API.
  • Change nextSleepDuration(now time.Time) to compute sleep using time.UnixMilli(*nextWake).Sub(now) and add TestNextSleepDuration_UsesProvidedNow to ensure the function uses the provided time argument.

Testing

  • Ran gofmt -w pkg/cron/service.go pkg/cron/service_test.go to normalize formatting and ensure no gofmt issues. (succeeded.)
  • Ran go test ./pkg/cron ./pkg/config which passed for the cron package. (succeeded.)
  • Ran go test ./... to validate the full test suite for packages in the repo, which completed successfully for the tested packages. (succeeded.)

Codex Task

@YspCoder YspCoder merged commit 41cc941 into main Feb 15, 2026
@YspCoder YspCoder deleted the codex/review-recent-commits branch February 15, 2026 15:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant