Skip to content

fix(dreamer): advance last_run_at from run start, not completion - #463

Open
TreedsSlop wants to merge 1 commit into
cortexkit:masterfrom
TreedsSlop:dreamer-last-run-start
Open

TreedsSlop wants to merge 1 commit into
cortexkit:masterfrom
TreedsSlop:dreamer-last-run-start

Conversation

@TreedsSlop

@TreedsSlop TreedsSlop commented Sep 18, 2026

Copy link
Copy Markdown

last_run_at is the cutoff the "changed since" gates compare against the timestamps of the input they govern (maintain-docs: compartments since the last run). advanceAfterRun wrote the run's COMPLETION time, so a message or compartment that arrived during the run was older than the new cutoff and was silently skipped on the next slot.

Record the run's start instead: input that lands mid-run is newer than the cutoff and re-triggers the gate next slot (at-least-once).


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.


Summary by cubic

Fixes last_run_at advancement in the dreamer scheduler so input that arrives mid-run re-triggers the "changed since" gates next slot instead of being silently skipped.

  • Records the run's start time as the cutoff rather than its completion time.
  • Failed/skipped runs still never advance the cutoff; nextDueAt still advances from completion.

Written for commit 3bf683c. Summary will update on new commits.

Review in cubic

RetriggerConfidence Score: 5/5

The PR appears safe to merge, with no outstanding correctness, security, or repository-rule issues identified.

Summary

Updates Dreamer scheduling bookkeeping so successful tasks record their start time as last_run_at, preserving at-least-once processing for inputs that arrive while a task is running.

  • Keeps failed and skipped runs from advancing the successful-run cutoff.
  • Continues calculating next_due_at from completion time.
  • Adds scheduler coverage for the start-versus-completion distinction and updates executor expectations.
Diagram
sequenceDiagram
    participant S as Scheduler
    participant E as Executor
    participant DB as Schedule State
    S->>S: Record startedAt
    S->>E: Execute due task
    Note over E: New input may arrive during execution
    E-->>S: Completed
    S->>DB: "last_run_at = startedAt"
    S->>DB: "next_due_at = schedule from finishedAt"
    Note over DB: Mid-run input remains newer than cutoff
Loading

Reviews (2) · Last reviewed commit: "fix(dreamer): advance last_run_at from r..."

last_run_at is the cutoff the "changed since" gates compare against the timestamps of the input they govern (maintain-docs: compartments since the last run). advanceAfterRun wrote the run's COMPLETION time, so a message or compartment that arrived during the run was older than the new cutoff and was silently skipped on the next slot.

Record the run's start instead: input that lands mid-run is newer than the cutoff and re-triggers the gate next slot (at-least-once).

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

No issues found across 3 files

You’re at about 94% of the monthly reviewed-line limit. You may want to disable incremental reviews to conserve quota. Reviews will continue until that limit is exceeded. If you need help avoiding interruptions, please contact contact@cubic.dev.

Re-trigger cubic

@TreedsSlop
TreedsSlop force-pushed the dreamer-last-run-start branch from e4e2863 to 3bf683c Compare September 18, 2026 01:06
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