Repository navigation
Description
Pausing or deleting a scheduled task can still allow its pending prompt to be admitted and executed.
Observed on cm-ui-mocks at commit 94116bfd4fa7063ba15d33863f8bffcdc0a16d28. Severity: P1. This is a known issue in the requested Windows review build.
Expected behavior
The scheduling contract in specs/scheduling/README.md:38 states: "Pause/delete takes effect before the next prompt admission."
A task paused or deleted before its prompt is persisted must not run, even if dispatch has already started preparing a worktree or waiting for session ownership.
Actual behavior
packages/opencode/src/schedule/engine.ts:345-354 checks enabled/deleted state before adapter.execute. Execution may then wait for worktree/session preparation in schedule/runtime.ts or for the cross-process session ownership lock. packages/opencode/src/session/prompt.ts:1367-1376 subsequently persists the prompt and calls the admission callback without checking schedule state again. The callback in engine.ts:334-342 increments the run count without a final liveness check.
Reproduction
- Create a one-time schedule due on the next tick.
- Start dispatch and delay execution immediately before durable prompt admission, as worktree preparation or session ownership waiting can do.
- Pause the schedule and wait for pause persistence.
- Release the delayed admission.
A probe using the actual Scheduler implementation returned:
{"enabled":false,"admitCount":1,"occurrenceState":"completed","runs":1}
The probe used a temporary store and a delayed adapter, with no model execution or user session changes. The reviewing agent independently reran it and observed the same result.
Acceptance criteria
- Perform final authorization inside the reserved execution boundary, before durable prompt persistence.
- Pause and delete completed before admission must prevent admission, execution and run-count increment.
- Preserve exact occurrence/session/prompt IDs and restart reconciliation; do not turn cancellation into automatic replay of admitted work.
- Add regression coverage for pause and delete while dispatch is delayed, including the session ownership wait path.
This issue records the defect; it does not authorize or record a merge to dev.
Activity
trmosala commentedon Oct 17, 2026
Verified that this was already fixed by f005862 (
fix(schedule): authorize prompts before durable admission), which is contained in the current remotedevbranch.The scheduler now rechecks pause/deletion inside the reserved session execution boundary immediately before the durable user-message write. Admission and run-count accounting share the serialized commit boundary. Denied admission makes no model request, and restart reconciliation preserves occurrence/session/prompt IDs without replaying admitted work.
Focused verification on 2026-10-17, from
packages/opencode:Result: 39 passed, 0 failed. Coverage includes pause and delete during dispatch, real session-ownership lock waits, prompt preparation, restart with stable IDs, and preservation of already admitted work.
The tested scheduling implementation and regression files match current
origin/dev. No additional code change, commit, push, or merge was needed. Native Windows execution was not repeated in this verification.