fix(dreamer): keep shared schedule reconciliation monotone

Merged
OS
2mo ago
+122-26

Approved issue: #498

Harness coverage (required)

  • OpenCode 1: covered — shared host-side Dreamer scheduler
  • OpenCode 2: covered — shared host-side Dreamer scheduler
  • Pi: covered — shared host-side Dreamer scheduler
  • OMP: covered — shared host-side Dreamer scheduler
  • Rust module: not applicable — Rust module does not run Dreamer scheduling today

What changed

Schedule edits compute a future candidate from the current time and retain an earlier armed slot, including its retry count. Disabled worktrees leave shared state untouched and cannot run scheduled tasks.

Validation

  • npx --yes bun@1.4.2 test packages/plugin/src/features/magic-context/dreamer/schedule-owner-repro.test.ts packages/plugin/src/features/magic-context/dreamer/task-scheduler.test.ts (35 passed; includes retry exhaustion and disable/re-enable coverage)
  • git diff --check

The alternating-worktree regression advances consumed slots and verifies six successive executions. Biome 2.5.1 checks pass on all three changed files. Full workspace typecheck remains unverified locally (the existing Windows dependency limitations are unchanged).


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

For issue 498: a schedule change can no longer postpone an already-armed shared slot or restart its retry count. Conflicting worktrees can bring a task forward but never delay it.

  • Computes the next due slot from the durable run anchor and keeps the earlier of the existing and recalculated slots, preserving the retry count when the earlier slot is retained.
  • Disabled worktrees are filtered locally and never mutate shared schedule state.
  • Adds regressions for alternating-worktree schedules on a shared identity and for retry-cap preservation across schedule edits.

RetriggerConfidence Score: 4/5

The PR is not yet safe to merge because changing an armed task to a later schedule can still run it at the old slot.

Findings

  1. P1 Later schedule keeps old slot ▶
Summary

The PR keeps shared Dreamer schedule reconciliation from postponing an armed slot, preserves its retry count, and makes disabled worktrees leave scheduled state untouched. Tests now advance consumed slots across alternating worktrees and cover retry exhaustion and disable/re-enable behavior.

Diagram
%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A[Worktree schedule] --> B{Disabled?}
  B -->|Yes| C[Leave shared row untouched]
  B -->|No| D[Reconcile shared row]
  D --> E[Keep earlier armed or calculated slot]
  E --> F{Due?}
  F -->|Yes| G[Gate and execute under lease]
  G --> H[Advance slot or retain bounded retry]

Reviews (2) · Last reviewed commit: "fix(dreamer): preserve shared retries ac..."