maybeAttachStandaloneTasks in space-runtime.ts re-reads the task before attaching and re-checks workflowRunId and status, but not preferredWorkflowId:
const selected = await this.selectWorkflowForStandaloneTask(fresh, workflows);
if (!selected) continue;
const current = this.config.taskRepo.getTask(fresh.id);
if (!current || current.workflowRunId) continue;
if (current.status !== 'open') continue;
...
await this.startWorkflowRun(space.id, selected.id, ...)
A preference change committing between selectWorkflowForStandaloneTask and startWorkflowRun is therefore ignored: the scheduler starts workflow A while the write that chose B has already succeeded. The task runs a workflow the user did not pick, with no error anywhere.
Pre-existing — the loop dates to the #1991/#2004 era and the same window is reachable today through spaceTask.update. It is not introduced by task.setPreferredWorkflow (#4573), whose own guard covers a different window: a write landing after the task has already started.
Fixing it means including the selected preference in the attachment CAS, so a winning preference update forces the scheduler to reselect.
Found by Codex review on #4573.
Part of #4164.
maybeAttachStandaloneTasksinspace-runtime.tsre-reads the task before attaching and re-checksworkflowRunIdandstatus, but notpreferredWorkflowId:A preference change committing between
selectWorkflowForStandaloneTaskandstartWorkflowRunis therefore ignored: the scheduler starts workflow A while the write that chose B has already succeeded. The task runs a workflow the user did not pick, with no error anywhere.Pre-existing — the loop dates to the #1991/#2004 era and the same window is reachable today through
spaceTask.update. It is not introduced bytask.setPreferredWorkflow(#4573), whose own guard covers a different window: a write landing after the task has already started.Fixing it means including the selected preference in the attachment CAS, so a winning preference update forces the scheduler to reselect.
Found by Codex review on #4573.
Part of #4164.