Skip to content

fix(cron): defer job commit until agent delivery succeeds - #57

Draft
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-8039
Draft

fix(cron): defer job commit until agent delivery succeeds#57
cursor[bot] wants to merge 1 commit into
mainfrom
cursor/critical-bug-management-8039

Conversation

@cursor

@cursor cursor Bot commented Jul 23, 2026

Copy link
Copy Markdown

Bug and impact

One-shot and recurring cron jobs were deleted or rescheduled inside cron_poll() before the message reached the agent. If strdup failed or agent_run failed, scheduled reminders were permanently lost.

Root cause

cron_poll() mutated the SQLite cron_jobs table (delete for one-shot, update next_run for recurring) before building the channel message and before handle_message() ran.

Fix

  • Build the outgoing message first; return -1 on allocation failure without touching the DB.
  • Add cron_ack_delivery() to delete one-shot jobs or advance recurring schedules only after successful agent delivery.
  • Call cron_ack_delivery() from dispatch.c when the cron channel completes a successful agent_run + send.

Validation

  • ./build/test_cron — all tests pass, including new coverage for deferred ack and poll-without-commit.
Open in Web View Automation 

One-shot and recurring cron jobs were deleted or rescheduled in cron_poll
before the message was handed to the agent, causing permanent data loss when
allocation or dispatch failed. Ack delivery only after successful agent_run.

Co-authored-by: esadrianno <esadrianno@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant